refactoring, stage 4: sub-windows now just get one pointer to their parent,

as the first parameter to their constructor, instead of various collections
of gLiveSupport, bundle and glade, in various orders.
This commit is contained in:
fgerlits 2007-08-10 13:49:12 +00:00
parent 2f233f9aec
commit 8b9ad7968d
35 changed files with 394 additions and 341 deletions

View File

@ -42,6 +42,7 @@
#include <exception>
#include <stdexcept>
#include <glibmm/ustring.h>
#include "LiveSupport/Core/Ptr.h"

View File

@ -260,6 +260,7 @@ G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \
${TMP_DIR}/NowPlaying.o \
${TMP_DIR}/GuiObject.o \
${TMP_DIR}/GuiWindow.o \
${TMP_DIR}/GuiComponent.o \
${TMP_DIR}/LoginWindow.o \
${TMP_DIR}/UploadFileWindow.o \
${TMP_DIR}/ScratchpadWindow.o \

View File

@ -48,10 +48,15 @@ using namespace LiveSupport::GLiveSupport;
namespace {
/*------------------------------------------------------------------------------
* The name of the localization resource bundle.
*----------------------------------------------------------------------------*/
const Glib::ustring bundleName = "advancedSearchEntry";
/*------------------------------------------------------------------------------
* The maximum number of AdvancedSearchItem children.
*----------------------------------------------------------------------------*/
const int maxChildren = 5;
const int maxChildren = 5;
}
@ -63,16 +68,11 @@ const int maxChildren = 5;
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
AdvancedSearchEntry :: AdvancedSearchEntry(
Ptr<GLiveSupport>::Ref gLiveSupport,
Glib::RefPtr<Gnome::Glade::Xml> glade)
AdvancedSearchEntry :: AdvancedSearchEntry(GuiObject * parent)
throw ()
: gLiveSupport(gLiveSupport)
: GuiComponent(parent,
bundleName)
{
Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle(
"advancedSearchEntry");
setBundle(bundle);
metadataTypes = gLiveSupport->getMetadataTypeContainer();
Gtk::Label * fileTypeLabel;
@ -87,10 +87,9 @@ AdvancedSearchEntry :: AdvancedSearchEntry(
for (int i = 0; i < maxChildren; ++i) {
Ptr<AdvancedSearchItem>::Ref searchItem(new AdvancedSearchItem(
i,
metadataTypes,
getBundle(),
glade));
this,
i,
metadataTypes));
children.push_back(searchItem);
}

View File

@ -41,17 +41,17 @@
#endif
#include <vector>
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/MetadataTypeContainer.h"
#include "LiveSupport/Core/SearchCriteria.h"
#include "LiveSupport/Widgets/ComboBoxText.h"
#include "AdvancedSearchItem.h"
#include "GLiveSupport.h"
#include "GuiComponent.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -72,14 +72,9 @@ using namespace LiveSupport::Widgets;
* @author $Author$
* @version $Revision$
*/
class AdvancedSearchEntry : public LocalizedObject
class AdvancedSearchEntry : public GuiComponent
{
private:
/**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* A container holding all known metadata types.
@ -102,13 +97,9 @@ class AdvancedSearchEntry : public LocalizedObject
/**
* Constructor.
*
* @param gLiveSupport the GLiveSupport object, containing
* all the vital info.
* @param glade the Glade file which specifies the visual
* components for this class.
* @param parent the GuiObject which contains this one.
*/
AdvancedSearchEntry(Ptr<GLiveSupport>::Ref gLiveSupport,
Glib::RefPtr<Gnome::Glade::Xml> glade)
AdvancedSearchEntry(GuiObject * parent)
throw ();
/**

View File

@ -56,12 +56,11 @@ using namespace LiveSupport::GLiveSupport;
* Constructor.
*----------------------------------------------------------------------------*/
AdvancedSearchItem :: AdvancedSearchItem(
GuiObject * parent,
int index,
Ptr<MetadataTypeContainer>::Ref metadataTypes,
Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
Ptr<MetadataTypeContainer>::Ref metadataTypes)
throw ()
: LocalizedObject(bundle)
: GuiComponent(parent)
{
glade->get_widget(addIndex("advancedSearchItem", index), enclosingBox);
@ -75,7 +74,7 @@ AdvancedSearchItem :: AdvancedSearchItem(
glade->get_widget_derived(addIndex("advancedOperatorEntry", index),
operatorEntry);
operatorEntry->setContents(bundle);
operatorEntry->setContents(getBundle());
glade->get_widget(addIndex("advancedValueEntry", index), valueEntry);

View File

@ -42,17 +42,16 @@
#include <vector>
#include <utility>
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/NumericTools.h"
#include "LiveSupport/Core/MetadataTypeContainer.h"
#include "LiveSupport/Core/SearchCriteria.h"
#include "LiveSupport/Widgets/MetadataComboBoxText.h"
#include "LiveSupport/Widgets/OperatorComboBoxText.h"
#include "GuiComponent.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -74,7 +73,7 @@ using namespace LiveSupport::Widgets;
* @author $Author$
* @version $Revision$
*/
class AdvancedSearchItem : public LocalizedObject,
class AdvancedSearchItem : public GuiComponent,
private NumericTools
{
private:
@ -138,18 +137,14 @@ class AdvancedSearchItem : public LocalizedObject,
/**
* Constructor.
*
* @param parent the GuiObject which contains this one.
* @param index the position of this item in the list of
* advanced search items.
* @param metadataTypes container holding all known metadata types
* @param bundle the resource bundle holding the localized
* resources for this widget.
* @param glade the Glade file which specifies the visual
* components for this class.
*/
AdvancedSearchItem(int index,
Ptr<MetadataTypeContainer>::Ref metadataTypes,
Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
AdvancedSearchItem(GuiObject * parent,
int index,
Ptr<MetadataTypeContainer>::Ref metadataTypes)
throw ();
/**

View File

@ -77,12 +77,9 @@ const Glib::ustring userPreferencesKeyName = "activeBackups";
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
BackupList :: BackupList (Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
BackupList :: BackupList (GuiObject * parent)
throw ()
: LocalizedObject(bundle),
gLiveSupport(gLiveSupport)
: GuiComponent(parent)
{
// create the tree view
treeModel = Gtk::ListStore::create(modelColumns);

View File

@ -40,16 +40,15 @@
#include "configure.h"
#endif
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/XmlRpcException.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
#include "LiveSupport/Widgets/ZebraTreeView.h"
#include "GLiveSupport.h"
#include "GuiComponent.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -88,7 +87,7 @@ using namespace LiveSupport::Widgets;
* @author $Author$
* @version $Revision$
*/
class BackupList : public LocalizedObject,
class BackupList : public GuiComponent,
public ContentsStorable
{
private:
@ -144,11 +143,6 @@ class BackupList : public LocalizedObject,
protected:
/**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The columns model needed by ZebraTreeView.
*
@ -224,16 +218,9 @@ class BackupList : public LocalizedObject,
/**
* Constructor.
*
* @param gLiveSupport the gLiveSupport object, containing
* all the vital info.
* @param bundle the resource bundle holding the localized
* resources for this window.
* @param glade the Glade file which specifies the visual
* components for this class.
* @param parent the GuiObject which contains this one.
*/
BackupList(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
BackupList(GuiObject * parent)
throw ();
/**

View File

@ -39,10 +39,6 @@
#error need pwd.h
#endif
#include <gtkmm/filechooserdialog.h>
#include <gtkmm/stock.h>
#include <gtkmm/paned.h>
#include "LiveSupport/Core/FileTools.h"
#include "BackupView.h"
@ -57,6 +53,14 @@ using namespace boost::posix_time;
/* ================================================ local constants & macros */
namespace {
/*------------------------------------------------------------------------------
* The name of the localization resource bundle.
*----------------------------------------------------------------------------*/
const Glib::ustring bundleName = "backupView";
}
/* =============================================== local function prototypes */
@ -66,15 +70,11 @@ using namespace boost::posix_time;
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
BackupView :: BackupView (Ptr<GLiveSupport>::Ref gLiveSupport,
Glib::RefPtr<Gnome::Glade::Xml> glade)
BackupView :: BackupView (GuiObject * parent)
throw ()
: gLiveSupport(gLiveSupport),
glade(glade)
: GuiComponent(parent,
bundleName)
{
Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle("backupView");
setBundle(bundle);
Gtk::Label * backupTitleLabel;
Gtk::Label * mtimeLabel;
Gtk::Button * chooseTimeButton;
@ -111,7 +111,7 @@ BackupView :: BackupView (Ptr<GLiveSupport>::Ref gLiveSupport,
void
BackupView :: constructCriteriaView(void) throw ()
{
criteriaEntry.reset(new AdvancedSearchEntry(gLiveSupport, glade));
criteriaEntry.reset(new AdvancedSearchEntry(this));
criteriaEntry->connectCallback(sigc::mem_fun(*this,
&BackupView::onCreateBackup));
@ -129,7 +129,7 @@ BackupView :: constructCriteriaView(void) throw ()
void
BackupView :: constructBackupListView(void) throw ()
{
backupList.reset(new BackupList(gLiveSupport, getBundle(), glade));
backupList.reset(new BackupList(this));
glade->connect_clicked("backupDeleteButton1", sigc::mem_fun(*this,
&BackupView::onDeleteButtonClicked));

View File

@ -40,18 +40,18 @@
#include "configure.h"
#endif
#include <gtkmm.h>
#include <libglademm.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/TimeConversion.h"
#include "DateTimeChooserWindow.h"
#include "AdvancedSearchEntry.h"
#include "BackupList.h"
#include "GLiveSupport.h"
#include "GuiComponent.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -88,7 +88,7 @@ using namespace boost::posix_time;
* @author $Author$
* @version $Revision$
*/
class BackupView : public LocalizedObject
class BackupView : public GuiComponent
{
private:
@ -156,16 +156,6 @@ class BackupView : public LocalizedObject
protected:
/**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The Glade object, which specifies the visual components.
*/
Glib::RefPtr<Gnome::Glade::Xml> glade;
/**
* Event handler for the time chooser button being clicked.
*/
@ -202,13 +192,9 @@ class BackupView : public LocalizedObject
/**
* Constructor.
*
* @param gLiveSupport the gLiveSupport object, containing
* all the vital info.
* @param glade the Glade file which specifies the visual
* components for this class.
* @param parent the GuiObject which contains this one.
*/
BackupView(Ptr<GLiveSupport>::Ref gLiveSupport,
Glib::RefPtr<Gnome::Glade::Xml> glade)
BackupView(GuiObject * parent)
throw ();
/**

View File

@ -55,26 +55,18 @@ using namespace LiveSupport::GLiveSupport;
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
BrowseEntry :: BrowseEntry(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
BrowseEntry :: BrowseEntry(GuiObject * parent)
throw ()
: LocalizedObject(bundle)
: GuiComponent(parent)
{
browseItemOne.reset(new BrowseItem(0,
gLiveSupport,
bundle,
glade,
browseItemOne.reset(new BrowseItem(this,
0,
4 /* Genre */));
browseItemTwo.reset(new BrowseItem(1,
gLiveSupport,
bundle,
glade,
browseItemTwo.reset(new BrowseItem(this,
1,
1 /* Creator */));
browseItemThree.reset(new BrowseItem(2,
gLiveSupport,
bundle,
glade,
browseItemThree.reset(new BrowseItem(this,
2,
2 /* Album */));
// TODO: change hard-coded indices to stuff read from config

View File

@ -40,15 +40,13 @@
#include "configure.h"
#endif
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/SearchCriteria.h"
#include "BrowseItem.h"
#include "GLiveSupport.h"
#include "GuiComponent.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -69,7 +67,7 @@ using namespace LiveSupport::Core;
* @author $Author$
* @version $Revision$
*/
class BrowseEntry : public LocalizedObject
class BrowseEntry : public GuiComponent
{
private:
@ -99,15 +97,9 @@ class BrowseEntry : public LocalizedObject
/**
* Constructor with localization parameter.
*
* @param gLiveSupport the GLiveSupport object, containing
* all the vital info.
* @param bundle the resource bundle for localization.
* @param glade the Glade file which specifies the visual
* components for this class.
* @param parent the GuiObject which contains this one.
*/
BrowseEntry(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
BrowseEntry(GuiObject * parent)
throw ();
/**

View File

@ -56,14 +56,11 @@ using namespace LiveSupport::GLiveSupport;
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
BrowseItem :: BrowseItem(int index,
Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade,
int defaultIndex)
BrowseItem :: BrowseItem(GuiObject * parent,
int index,
int defaultIndex)
throw ()
: LocalizedObject(bundle),
gLiveSupport(gLiveSupport)
: GuiComponent(parent)
{
parentCriteria.reset(new SearchCriteria);

View File

@ -42,19 +42,17 @@
#include <vector>
#include <utility>
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/NumericTools.h"
#include "LiveSupport/Core/SearchCriteria.h"
#include "LiveSupport/Widgets/MetadataComboBoxText.h"
#include "LiveSupport/Widgets/ZebraTreeView.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
#include "GLiveSupport.h"
#include "GuiComponent.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -83,7 +81,7 @@ using namespace LiveSupport::Widgets;
* @author $Author$
* @version $Revision$
*/
class BrowseItem : public LocalizedObject,
class BrowseItem : public GuiComponent,
private NumericTools
{
private:
@ -150,11 +148,6 @@ class BrowseItem : public LocalizedObject,
*/
Glib::ustring allString;
/**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The criteria from the browse items to the left of this one.
*/
@ -188,20 +181,15 @@ class BrowseItem : public LocalizedObject,
/**
* Constructor with parent and localization parameter.
*
* @param index the position of this item in the list of
* browse items.
* @param gLiveSupport the main program object
* @param bundle the resource bundle for localization
* @param glade the Glade file which specifies the visual
* components for this class.
* @param defaultIndex the index of the metadata entry to display
* initially
* @param parent the GuiObject which contains this one.
* @param index the position of this item in the list of
* browse items.
* @param defaultIndex the index of the metadata entry to display
* initially
*/
BrowseItem(int index,
Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade,
int defaultIndex)
BrowseItem(GuiObject * parent,
int index,
int defaultIndex)
throw ();
/**

View File

@ -68,12 +68,11 @@ const Glib::ustring pauseStockImageName = "gtk-media-pause";
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
CuePlayer :: CuePlayer(Ptr<GLiveSupport>::Ref gLiveSupport,
CuePlayer :: CuePlayer(GuiObject * parent,
Gtk::TreeView * treeView,
const PlayableTreeModelColumnRecord & modelColumns,
Glib::RefPtr<Gnome::Glade::Xml> glade)
const PlayableTreeModelColumnRecord & modelColumns)
throw ()
: gLiveSupport(gLiveSupport),
: GuiComponent(parent),
treeView(treeView),
modelColumns(modelColumns)
{

View File

@ -40,15 +40,13 @@
#include "configure.h"
#endif
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/PlaylistExecutor/AudioPlayerEventListener.h"
#include "LiveSupport/Widgets/PlayableTreeModelColumnRecord.h"
#include "GLiveSupport.h"
#include "GuiComponent.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -71,9 +69,11 @@ using namespace LiveSupport::Widgets;
* @author $Author$
* @version $Revision$
*/
class CuePlayer : public PlaylistExecutor::AudioPlayerEventListener
class CuePlayer : public GuiComponent,
public PlaylistExecutor::AudioPlayerEventListener
{
private:
/**
* The possible states of the (cue) audio player.
*/
@ -94,11 +94,6 @@ class CuePlayer : public PlaylistExecutor::AudioPlayerEventListener
*/
Gtk::Button * stopButton;
/**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The Gtk::TreeView of the parent.
*/
@ -145,19 +140,17 @@ class CuePlayer : public PlaylistExecutor::AudioPlayerEventListener
public:
/**
* Constructor with parent parameters.
*
* @param gLiveSupport the GLiveSupport, application object.
* @param treeView the TreeView object showing the selection.
* @param modelColumns the object holding the types of the columns.
* @param glade the Glade file which specifies the visual
* components for this class.
* @param parent the GuiObject which contains this one.
* @param treeView the TreeView object showing the selection.
* @param modelColumns the object holding the types of the columns.
*/
CuePlayer(Ptr<GLiveSupport>::Ref gLiveSupport,
CuePlayer(GuiObject * parent,
Gtk::TreeView * treeView,
const PlayableTreeModelColumnRecord & modelColumns,
Glib::RefPtr<Gnome::Glade::Xml> glade)
const PlayableTreeModelColumnRecord & modelColumns)
throw ();
/**

View File

@ -0,0 +1,71 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
http://campcaster.campware.org/
To report bugs, send an e-mail to bugs@campware.org
Campcaster is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Campcaster is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 3204 $
Location : $URL: svn://code.campware.org/campcaster/trunk/campcaster/src/products/gLiveSupport/src/GuiComponent.cxx $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include "GLiveSupport.h"
#include "GuiComponent.h"
using namespace LiveSupport::Core;
using namespace LiveSupport::GLiveSupport;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Protected constructor.
*----------------------------------------------------------------------------*/
GuiComponent :: GuiComponent (GuiObject * parent,
const Glib::ustring & bundleName)
throw ()
: GuiObject(),
parent(parent)
{
if (bundleName == "") {
setBundle(parent->getBundle());
} else {
setBundle(gLiveSupport->getBundle(bundleName));
}
glade = parent->getGlade();
}

View File

@ -0,0 +1,110 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the Campcaster project.
http://campcaster.campware.org/
To report bugs, send an e-mail to bugs@campware.org
Campcaster is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Campcaster is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Campcaster; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author$
Version : $Revision$
Location : $URL$
------------------------------------------------------------------------------*/
#ifndef GuiComponent_h
#define GuiComponent_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include "GuiObject.h"
namespace LiveSupport {
namespace GLiveSupport {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* The common ancestor of all window components in the GUI.
* These are non-standalone sub-windows, like the AdvancedSearchEntry, and
* sub-widgets of those, like the AdvancedSearchItem.
*
* @author $Author$
* @version $Revision$
*/
class GuiComponent : public GuiObject
{
protected:
/**
* The parent object.
*/
GuiObject * parent;
/**
* Protected constructor.
*
* @param parent the GuiObject which contains this one.
* @param bundleName the name of the localization resource bundle
* (optional); if missing, the parent's bundle
* is used.
*/
GuiComponent(GuiObject * parent,
const Glib::ustring & bundleName = "")
throw ();
public:
/**
* Virtual destructor.
*/
virtual
~GuiComponent(void) throw ()
{
}
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace GLiveSupport
} // namespace LiveSupport
#endif // GuiComponent_h

View File

@ -52,18 +52,12 @@ using namespace LiveSupport::GLiveSupport;
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Constructor.
* Protected constructor.
*----------------------------------------------------------------------------*/
GuiObject :: GuiObject (const Glib::ustring & bundleName)
GuiObject :: GuiObject (void)
throw ()
: LocalizedObject()
{
gLiveSupport = GLiveSupport::getInstance();
if (bundleName == "") {
setBundle(gLiveSupport->getBundle());
} else {
setBundle(gLiveSupport->getBundle(bundleName));
}
}

View File

@ -77,12 +77,14 @@ class GuiObject : public LocalizedObject
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* Constructor.
*
* @param bundleName the name of the sub-bundle for this object;
* can be "" to indicate the outermost bundle.
* The Glade object, containing the visual design.
*/
GuiObject(const Glib::ustring & bundleName) throw ();
Glib::RefPtr<Gnome::Glade::Xml> glade;
/**
* Protected constructor.
*/
GuiObject(void) throw ();
public:
@ -94,6 +96,15 @@ class GuiObject : public LocalizedObject
~GuiObject(void) throw ()
{
}
/**
* Get the Glade object.
*/
virtual Glib::RefPtr<Gnome::Glade::Xml>
getGlade(void) const throw ()
{
return glade;
}
};
/* ================================================= external data structures */

View File

@ -60,15 +60,21 @@ const Glib::ustring applicationTitle = "Campcaster";
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Constructor.
* Protected constructor.
*----------------------------------------------------------------------------*/
GuiWindow :: GuiWindow (const Glib::ustring & bundleName,
const Glib::ustring & gladeFileName,
Gtk::ToggleButton * windowOpenerButton)
throw ()
: GuiObject(bundleName),
: GuiObject(),
windowOpenerButton(windowOpenerButton)
{
if (bundleName == "") {
setBundle(gLiveSupport->getBundle());
} else {
setBundle(gLiveSupport->getBundle(bundleName));
}
glade = Gnome::Glade::Xml::create(gLiveSupport->getGladeDir() +
gladeFileName);

View File

@ -86,11 +86,6 @@ class GuiWindow : public GuiObject
protected:
/**
* The Glade object, containing the visual design.
*/
Glib::RefPtr<Gnome::Glade::Xml> glade;
/**
* The button which was used to open this window.
*/
@ -108,7 +103,7 @@ class GuiWindow : public GuiObject
onDeleteEvent(GdkEventAny * event) throw ();
/**
* Constructor.
* Protected constructor.
*
* @param bundleName the name of the sub-bundle for this object;
* can be "" to indicate the outermost bundle.

View File

@ -106,10 +106,9 @@ LiveModeWindow :: LiveModeWindow (Gtk::ToggleButton * windowOpenerButton)
glade->get_widget("cueLabel1", cueLabel);
cueLabel->set_label(*getResourceUstring("cuePlayerLabel"));
cuePlayer.reset(new CuePlayer(gLiveSupport,
cuePlayer.reset(new CuePlayer(this,
treeView,
modelColumns,
glade));
modelColumns));
glade->get_widget("autoPlayNext1", autoPlayNext);
autoPlayNext->set_label(*getResourceUstring("autoPlayNextLabel"));

View File

@ -129,9 +129,7 @@ MasterPanelWindow :: MasterPanelWindow (void)
// create the Now Playing widget
Gtk::Box * nowPlayingBox;
glade->get_widget("nowPlayingWidget1", nowPlayingBox);
nowPlayingWidget.reset(new NowPlaying(gLiveSupport,
getBundle(),
glade));
nowPlayingWidget.reset(new NowPlaying(this));
// get a reference for the window-opener buttons
glade->get_widget("liveModeButton1", liveModeButton);
@ -209,7 +207,7 @@ MasterPanelWindow :: changeLanguage(void)
Ptr<ResourceBundle>::Ref newBundle = gLiveSupport->getBundle(
bundleName);
setBundle(newBundle);
nowPlayingWidget->changeLanguage(newBundle);
nowPlayingWidget->changeLanguage();
setTitle(getResourceUstring("windowTitle"));

View File

@ -77,13 +77,9 @@ const Glib::ustring pauseStockImageName = "gtk-media-pause";
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
NowPlaying :: NowPlaying(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
NowPlaying :: NowPlaying(GuiObject * parent)
throw ()
: LocalizedObject(bundle),
glade(glade),
gLiveSupport(gLiveSupport)
: GuiComponent(parent)
{
glade->get_widget("playButton1", playButton);
glade->get_widget("stopButton1", stopButton);
@ -352,10 +348,10 @@ NowPlaying :: resetRemainsTimeState(void) throw ()
* Change the language of the widget.
*----------------------------------------------------------------------------*/
void
NowPlaying :: changeLanguage(Ptr<ResourceBundle>::Ref bundle)
NowPlaying :: changeLanguage(void)
throw ()
{
setBundle(bundle);
setBundle(parent->getBundle());
elapsedTimeText->set_text(*getResourceUstring("elapsedTimeLabel"));
remainsTimeText->set_text(*getResourceUstring("remainingTimeLabel"));

View File

@ -40,15 +40,12 @@
#include "configure.h"
#endif
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/Mutex.h"
#include "GLiveSupport.h"
#include "GuiComponent.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -69,14 +66,9 @@ using namespace LiveSupport::Core;
* @author $Author$
* @version $Revision$
*/
class NowPlaying : public LocalizedObject
class NowPlaying : public GuiComponent
{
private:
/**
* The Glade object, containing the visual design.
*/
Glib::RefPtr<Gnome::Glade::Xml> glade;
/**
* Whether anything is shown in the widget.
@ -166,11 +158,6 @@ class NowPlaying : public LocalizedObject
*/
int remainsTimeCounter;
/**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* A mutex to make the writing, and some reading, of the
* 'playable' variable atomic.
@ -180,19 +167,19 @@ class NowPlaying : public LocalizedObject
/**
* Default constructor.
*/
NowPlaying(void) throw ();
NowPlaying(void) throw ();
/**
* Event handler for the Play button being clicked.
*/
void
onPlayButtonClicked(void) throw ();
onPlayButtonClicked(void) throw ();
/**
* Event handler for the Stop button being clicked.
*/
void
onStopButtonClicked(void) throw ();
onStopButtonClicked(void) throw ();
/**
* Set the color of the 'remains time' label.
@ -205,7 +192,7 @@ class NowPlaying : public LocalizedObject
*/
void
setRemainsTimeColor(RemainsTimeStateType state)
throw ();
throw ();
/**
* Reset all remains-time-blinking related variables.
@ -214,7 +201,7 @@ class NowPlaying : public LocalizedObject
* and the background color of the label to blue.
*/
void inline
resetRemainsTimeState(void) throw ();
resetRemainsTimeState(void) throw ();
public:
@ -222,22 +209,16 @@ class NowPlaying : public LocalizedObject
/**
* Constructor with parent and localization parameter.
*
* @param gLiveSupport the GLiveSupport, application object.
* @param bundle the resource bundle holding the localized
* resources for this widget
* @param glade the Glade file which specifies the visual
* components for this class.
* @param parent the GuiObject which contains this one.
*/
NowPlaying(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
throw ();
NowPlaying(GuiObject * parent)
throw ();
/**
* A virtual destructor.
*/
virtual
~NowPlaying(void) throw ()
~NowPlaying(void) throw ()
{
}
@ -247,14 +228,14 @@ class NowPlaying : public LocalizedObject
* @param playable the playable to be displayed
*/
void
setPlayable(Ptr<Playable>::Ref playable) throw ();
setPlayable(Ptr<Playable>::Ref playable) throw ();
/**
* Function that updates the elapsed and remaining time displays.
* This is called by the MasterPanelWindow every second.
*/
void
onUpdateTime(void) throw ();
onUpdateTime(void) throw ();
/**
* Public interface for restarting the audio.
@ -262,7 +243,7 @@ class NowPlaying : public LocalizedObject
* This is used by MasterPanelWindow::onKeyPressed().
*/
void
onPlayAudio(void) throw ()
onPlayAudio(void) throw ()
{
onPlayButtonClicked();
}
@ -273,7 +254,7 @@ class NowPlaying : public LocalizedObject
* This is used by MasterPanelWindow::onKeyPressed().
*/
void
onStopAudio(void) throw ()
onStopAudio(void) throw ()
{
onStopButtonClicked();
}
@ -288,7 +269,7 @@ class NowPlaying : public LocalizedObject
* @return the currently playing item; 0 if nothing is playing.
*/
Ptr<Playable>::Ref
getCurrentInnerPlayable(void) throw ()
getCurrentInnerPlayable(void) throw ()
{
return currentInnerPlayable;
}
@ -296,10 +277,11 @@ class NowPlaying : public LocalizedObject
/**
* Change the user interface language of the widget.
*
* @param bundle the new resource bundle.
* This is called by the parent when its locale has changed;
* NowPlaying then updates its own bundle to match the parent's.
*/
void
changeLanguage(Ptr<ResourceBundle>::Ref bundle) throw ();
changeLanguage() throw ();
};

View File

@ -559,7 +559,7 @@ OptionsWindow :: constructSchedulerSection(void) throw ()
void
OptionsWindow :: constructBackupSection(void) throw ()
{
backupView.reset(new BackupView(gLiveSupport, glade));
backupView.reset(new BackupView(this));
}
@ -569,7 +569,7 @@ OptionsWindow :: constructBackupSection(void) throw ()
void
OptionsWindow :: constructRdsSection(void) throw ()
{
rdsView.reset(new RdsView(gLiveSupport, glade));
rdsView.reset(new RdsView(this));
}

View File

@ -54,13 +54,12 @@ using namespace LiveSupport::GLiveSupport;
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
RdsEntry :: RdsEntry(Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade,
int index,
const Glib::ustring & type,
int width)
RdsEntry :: RdsEntry(GuiObject * parent,
int index,
const Glib::ustring & type,
int width)
throw ()
: LocalizedObject(bundle)
: GuiComponent(parent)
{
this->type.reset(new const Glib::ustring(type));
@ -91,7 +90,7 @@ RdsEntry :: setOptions(bool enabled,
* Save the changes made by the user.
*----------------------------------------------------------------------------*/
bool
RdsEntry :: saveChanges(Ptr<GLiveSupport>::Ref gLiveSupport) throw ()
RdsEntry :: saveChanges(void) throw ()
{
bool checkButtonNow = checkButton->get_active();
Ptr<const Glib::ustring>::Ref

View File

@ -40,14 +40,12 @@
#include "configure.h"
#endif
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/NumericTools.h"
#include "GLiveSupport.h"
#include "GuiComponent.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -69,7 +67,7 @@ using namespace LiveSupport::GLiveSupport;
* @author $Author$
* @version $Revision$
*/
class RdsEntry : public LocalizedObject,
class RdsEntry : public GuiComponent,
private NumericTools
{
private:
@ -110,20 +108,16 @@ class RdsEntry : public LocalizedObject,
* The type parameter is a string of 2 or 3 upper-case characters,
* see http://en.wikipedia.org/wiki/Radio_Data_System.
*
* @param bundle the resource bundle holding the localized
* resources for this window.
* @param glade the Glade file which specifies the visual
* components for this class.
* @param parent the GuiObject which contains this one.
* @param index the position of this item in the list of
* RDS entries.
* @param type the type of RDS data (PS, PI, RT, etc).
* @param width the width of the entry, in characters.
*/
RdsEntry(Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade,
int index,
const Glib::ustring & type,
int width) throw ();
RdsEntry(GuiObject * parent,
int index,
const Glib::ustring & type,
int width) throw ();
/**
* A virtual destructor.
@ -158,12 +152,10 @@ class RdsEntry : public LocalizedObject,
/**
* Save the changes made by the user.
*
* @param gLiveSupport the GLiveSupport object holding the
* RDS options to be modified.
* @return true if any changes were saved; false otherwise.
*/
bool
saveChanges(Ptr<GLiveSupport>::Ref gLiveSupport) throw ();
saveChanges(void) throw ();
/**
* Clear the entries of the widget.

View File

@ -44,6 +44,14 @@ using namespace LiveSupport::GLiveSupport;
/* ================================================ local constants & macros */
namespace {
/*------------------------------------------------------------------------------
* The name of the localization resource bundle.
*----------------------------------------------------------------------------*/
const Glib::ustring bundleName = "rdsView";
}
/* =============================================== local function prototypes */
@ -53,23 +61,20 @@ using namespace LiveSupport::GLiveSupport;
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
RdsView :: RdsView (Ptr<GLiveSupport>::Ref gLiveSupport,
Glib::RefPtr<Gnome::Glade::Xml> glade)
RdsView :: RdsView (GuiObject * parent)
throw ()
: gLiveSupport(gLiveSupport)
: GuiComponent(parent,
bundleName)
{
Ptr<ResourceBundle>::Ref bundle = gLiveSupport->getBundle("rdsView");
setBundle(bundle);
Gtk::Label * deviceLabel;
glade->get_widget("rdsDeviceLabel1", deviceLabel);
deviceLabel->set_label(*getResourceUstring("deviceLabel"));
glade->get_widget("rdsDeviceEntry1", deviceEntry);
Ptr<RdsEntry>::Ref psEntry(new RdsEntry(getBundle(), glade, 0, "PS", 8));
Ptr<RdsEntry>::Ref piEntry(new RdsEntry(getBundle(), glade, 1, "PI", 4));
Ptr<RdsEntry>::Ref rtEntry(new RdsEntry(getBundle(), glade, 2, "RT", 32));
Ptr<RdsEntry>::Ref psEntry(new RdsEntry(this, 0, "PS", 8));
Ptr<RdsEntry>::Ref piEntry(new RdsEntry(this, 1, "PI", 4));
Ptr<RdsEntry>::Ref rtEntry(new RdsEntry(this, 2, "RT", 32));
rdsEntryList.push_back(psEntry);
rdsEntryList.push_back(piEntry);
@ -100,7 +105,7 @@ RdsView :: saveChanges(void) throw ()
RdsEntryListType::const_iterator it;
for (it = rdsEntryList.begin(); it != rdsEntryList.end(); ++it) {
Ptr<RdsEntry>::Ref rdsEntry = *it;
touched |= rdsEntry->saveChanges(gLiveSupport);
touched |= rdsEntry->saveChanges();
}
return touched;

View File

@ -40,15 +40,15 @@
#include "configure.h"
#endif
#include <gtkmm.h>
#include <libglademm.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "RdsEntry.h"
#include "GLiveSupport.h"
#include "GuiComponent.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -88,7 +88,7 @@ using namespace LiveSupport::Core;
* @author $Author$
* @version $Revision$
*/
class RdsView : public LocalizedObject
class RdsView : public GuiComponent
{
private:
@ -113,11 +113,6 @@ class RdsView : public LocalizedObject
protected:
/**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The entry field for the serial device.
*/
@ -125,16 +120,13 @@ class RdsView : public LocalizedObject
public:
/**
* Constructor.
*
* @param gLiveSupport the gLiveSupport object, containing
* all the vital info.
* @param glade the Glade file which specifies the visual
* components for this class.
* @param parent the GuiObject which contains this one.
*/
RdsView(Ptr<GLiveSupport>::Ref gLiveSupport,
Glib::RefPtr<Gnome::Glade::Xml> glade)
RdsView(GuiObject * parent)
throw ();
/**

View File

@ -108,10 +108,9 @@ ScratchpadWindow :: ScratchpadWindow (
&ScratchpadWindow::onKeyPressed));
// create the cue player widget
cuePlayer.reset(new CuePlayer(gLiveSupport,
cuePlayer.reset(new CuePlayer(this,
treeView,
modelColumns,
glade));
modelColumns));
// create the right-click entry context menu for audio clips
audioClipMenu.reset(new Gtk::Menu());

View File

@ -166,7 +166,7 @@ SearchWindow :: constructSimpleSearchView(void) throw ()
void
SearchWindow :: constructAdvancedSearchView(void) throw ()
{
advancedSearchEntry.reset(new AdvancedSearchEntry(gLiveSupport, glade));
advancedSearchEntry.reset(new AdvancedSearchEntry(this));
advancedSearchEntry->connectCallback(sigc::mem_fun(*this,
&SearchWindow::onAdvancedSearch ));
@ -184,7 +184,7 @@ SearchWindow :: constructAdvancedSearchView(void) throw ()
void
SearchWindow :: constructBrowseView(void) throw ()
{
browseEntry.reset(new BrowseEntry(gLiveSupport, getBundle(), glade));
browseEntry.reset(new BrowseEntry(this));
browseEntry->signalChanged().connect(sigc::mem_fun(*this,
&SearchWindow::onBrowse));
}
@ -196,10 +196,7 @@ SearchWindow :: constructBrowseView(void) throw ()
void
SearchWindow :: constructTransportsView(void) throw ()
{
transportList.reset(new TransportList(
gLiveSupport,
gLiveSupport->getBundle("transportList"),
glade));
transportList.reset(new TransportList(this));
}

View File

@ -48,6 +48,11 @@ using namespace LiveSupport::GLiveSupport;
namespace {
/*------------------------------------------------------------------------------
* The name of the localization resource bundle.
*----------------------------------------------------------------------------*/
const Glib::ustring bundleName = "transportList";
/*------------------------------------------------------------------------------
* The localization key for the 'working' status.
*----------------------------------------------------------------------------*/
@ -88,12 +93,10 @@ const Glib::ustring downloadSymbol = "⇩";
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
TransportList :: TransportList(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade)
TransportList :: TransportList(GuiObject * parent)
throw ()
: LocalizedObject(bundle),
gLiveSupport(gLiveSupport)
: GuiComponent(parent,
bundleName)
{
// create the tree view
treeModel = Gtk::ListStore::create(modelColumns);

View File

@ -40,17 +40,16 @@
#include "configure.h"
#endif
#include <gtkmm.h>
#include <libglademm.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/UniqueId.h"
#include "LiveSupport/Core/LocalizedObject.h"
#include "LiveSupport/Core/XmlRpcException.h"
#include "LiveSupport/Widgets/ZebraTreeModelColumnRecord.h"
#include "LiveSupport/Widgets/ZebraTreeView.h"
#include "GLiveSupport.h"
#include "GuiComponent.h"
namespace LiveSupport {
namespace GLiveSupport {
@ -90,7 +89,7 @@ using namespace LiveSupport::Widgets;
* @author $Author$
* @version $Revision$
*/
class TransportList : public LocalizedObject,
class TransportList : public GuiComponent,
public ContentsStorable
{
private:
@ -160,11 +159,6 @@ class TransportList : public LocalizedObject,
protected:
/**
* The GLiveSupport object, holding the state of the application.
*/
Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The columns model needed by ZebraTreeView.
*
@ -266,16 +260,9 @@ class TransportList : public LocalizedObject,
/**
* Constructor.
*
* @param gLiveSupport the gLiveSupport object, containing
* all the vital info.
* @param bundle the resource bundle holding the localized
* resources for this window.
* @param glade the Glade file which specifies the visual
* components for this class.
* @param parent the GuiObject which contains this one.
*/
TransportList(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle,
Glib::RefPtr<Gnome::Glade::Xml> glade) throw ();
TransportList(GuiObject * parent) throw ();
/**
* Virtual destructor.