diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h index cd4d99425..acd16ef16 100644 --- a/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.23 $ + Version : $Revision: 1.24 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WidgetFactory.h,v $ ------------------------------------------------------------------------------*/ @@ -92,7 +92,7 @@ class ZebraTreeView; * * * @author $Author: fgerlits $ - * @version $Revision: 1.23 $ + * @version $Revision: 1.24 $ */ class WidgetFactory : virtual public Configurable @@ -123,7 +123,9 @@ class WidgetFactory : searchWindowTitleImage, liveModeWindowTitleImage, playlistsWindowTitleImage, - schedulerWindowTitleImage } + schedulerWindowTitleImage, + audioClipIconImage, + playlistIconImage } ImageType; @@ -188,6 +190,12 @@ class WidgetFactory : */ Glib::RefPtr comboBoxRightImage; + /** + * A container holding the miscallenous image pixbuf references. + */ + std::map > + imageTypePixbufs; + /** * The default constructor. */ @@ -352,6 +360,14 @@ class WidgetFactory : return whiteWindowImages; } + /** + * Return a smart pointer to a Gdk::Pixbuf holding a named image. + * + * @return the image. + */ + Glib::RefPtr + getPixbuf(ImageType imageName) throw (); + /** * Create and return a container holding an image. * It is the reponsibility of the caller to dispose of the created diff --git a/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h b/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h index 081983b48..4138ac7e1 100644 --- a/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h +++ b/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.13 $ + Version : $Revision: 1.14 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h,v $ ------------------------------------------------------------------------------*/ @@ -92,7 +92,7 @@ using namespace LiveSupport::Core; * 3) connected with a TreeModelColumn using set_renderer(). * * @author $Author: fgerlits $ - * @version $Revision: 1.13 $ + * @version $Revision: 1.14 $ */ class ZebraTreeView : public Gtk::TreeView { @@ -162,6 +162,23 @@ class ZebraTreeView : public Gtk::TreeView int minimumWidth = 0) throw (); + /** + * Add an image column to the TreeView. + * + * @param title the title of the column + * @param image the type of button this view will display + * @param minimumWidth the minimum width of the column, in pixels + * (optional) + * @return the number of columns after adding this one + */ + int + appendColumn( + const Glib::ustring& title, + const Gtk::TreeModelColumn > & + modelColumn, + int minimumWidth = 0) + throw (); + /** * Add a button column to the TreeView. * diff --git a/livesupport/modules/widgets/src/WidgetFactory.cxx b/livesupport/modules/widgets/src/WidgetFactory.cxx index 310cf5ff9..1913a607c 100644 --- a/livesupport/modules/widgets/src/WidgetFactory.cxx +++ b/livesupport/modules/widgets/src/WidgetFactory.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.26 $ + Version : $Revision: 1.27 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WidgetFactory.cxx,v $ ------------------------------------------------------------------------------*/ @@ -268,6 +268,16 @@ static const std::string liveModeWindowTitleImageName static const std::string playlistsWindowTitleImageName = "titleImages/playlistsWindowTitle.png"; +/** + * The name of the image for the audio clip icon. + */ +static const std::string audioClipIconImageName = "icons/audioClipIcon.gif"; + +/** + * The name of the image for the playlist icon. + */ +static const std::string playlistIconImageName = "icons/playlistIcon.gif"; + /** * The name of the image for the title of the scheduler window. */ @@ -367,6 +377,23 @@ WidgetFactory :: configure(const xmlpp::Element & element) // load the white window corner images whiteWindowImages.reset(new CornerImages(path + whiteWindowPath)); + + // load the miscellaneous images + imageTypePixbufs[resizeImage] = loadImage(resizeImageName); + imageTypePixbufs[scratchpadWindowTitleImage] + = loadImage(scratchpadWindowTitleImageName); + imageTypePixbufs[searchWindowTitleImage] + = loadImage(searchWindowTitleImageName); + imageTypePixbufs[liveModeWindowTitleImage] + = loadImage(liveModeWindowTitleImageName); + imageTypePixbufs[playlistsWindowTitleImage] + = loadImage(playlistsWindowTitleImageName); + imageTypePixbufs[schedulerWindowTitleImage] + = loadImage(schedulerWindowTitleImageName); + imageTypePixbufs[audioClipIconImage] + = loadImage(audioClipIconImageName); + imageTypePixbufs[playlistIconImage] + = loadImage(playlistIconImageName); } @@ -568,44 +595,22 @@ WidgetFactory :: createButton(ImageButtonType type) throw () /*------------------------------------------------------------------------------ - * Create a resize image + * Return a Gdk::Pixbuf reference to a named image + *----------------------------------------------------------------------------*/ +Glib::RefPtr +WidgetFactory :: getPixbuf(ImageType imageName) throw () +{ + return imageTypePixbufs[imageName]; +} + + +/*------------------------------------------------------------------------------ + * Create a Gtk::Image *----------------------------------------------------------------------------*/ Gtk::Image * WidgetFactory :: createImage(ImageType imageName) throw () { - Glib::RefPtr rawImage; - - switch (imageName) { - - case resizeImage: - rawImage = loadImage(resizeImageName); - break; - - case scratchpadWindowTitleImage: - rawImage = loadImage(scratchpadWindowTitleImageName); - break; - - case searchWindowTitleImage: - rawImage = loadImage(searchWindowTitleImageName); - break; - - case liveModeWindowTitleImage: - rawImage = loadImage(liveModeWindowTitleImageName); - break; - - case playlistsWindowTitleImage: - rawImage = loadImage(playlistsWindowTitleImageName); - break; - - case schedulerWindowTitleImage: - rawImage = loadImage(schedulerWindowTitleImageName); - break; - - default: - return 0; - } - - return new Gtk::Image(rawImage); + return new Gtk::Image(getPixbuf(imageName)); } diff --git a/livesupport/modules/widgets/src/ZebraTreeView.cxx b/livesupport/modules/widgets/src/ZebraTreeView.cxx index 52f0546ee..362a24218 100644 --- a/livesupport/modules/widgets/src/ZebraTreeView.cxx +++ b/livesupport/modules/widgets/src/ZebraTreeView.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.16 $ + Version : $Revision: 1.17 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ZebraTreeView.cxx,v $ ------------------------------------------------------------------------------*/ @@ -74,7 +74,7 @@ ZebraTreeView :: ~ZebraTreeView(void) throw () /*------------------------------------------------------------------------------ - * Add a column to the TreeView. + * Add a text column to the TreeView. *----------------------------------------------------------------------------*/ int ZebraTreeView :: appendColumn( @@ -87,8 +87,8 @@ ZebraTreeView :: appendColumn( Gtk::CellRendererText* renderer = Gtk::manage(new Gtk::CellRendererText); // the constructor packs the renderer into the TreeViewColumn - Gtk::TreeViewColumn* viewColumn = Gtk::manage(new - Gtk::TreeViewColumn(title, *renderer) ); + Gtk::TreeViewColumn* viewColumn = Gtk::manage( + new Gtk::TreeViewColumn(title, *renderer) ); // and then we associate this renderer with the model column viewColumn->add_attribute(renderer->property_markup(), modelColumn); @@ -107,6 +107,42 @@ ZebraTreeView :: appendColumn( } +/*------------------------------------------------------------------------------ + * Add an image column to the TreeView. + *----------------------------------------------------------------------------*/ +int +ZebraTreeView :: appendColumn( + const Glib::ustring& title, + const Gtk::TreeModelColumn > & + modelColumn, + int minimumWidth) + throw () +{ + // a standard cell renderer; can be replaced with a ZebraCellRenderer + Gtk::CellRendererPixbuf* renderer = Gtk::manage( + new Gtk::CellRendererPixbuf ); + + // the constructor packs the renderer into the TreeViewColumn + Gtk::TreeViewColumn* viewColumn = Gtk::manage( + new Gtk::TreeViewColumn(title, *renderer) ); + + // and then we associate this renderer with the model column + viewColumn->add_attribute(renderer->property_pixbuf(), modelColumn); + + // this cell data function will do the blue-gray zebra stripes + viewColumn->set_cell_data_func( + *renderer, + sigc::mem_fun(*this, &ZebraTreeView::cellDataFunction) ); + + // set the minimum width of the column + if (minimumWidth) { + viewColumn->set_min_width(minimumWidth); + } + + return append_column(*viewColumn); +} + + /*------------------------------------------------------------------------------ * Add a button column to the TreeView. *----------------------------------------------------------------------------*/ @@ -130,8 +166,8 @@ ZebraTreeView :: appendColumn( renderer->property_pixbuf() = passiveImage; // the constructor packs the renderer into the TreeViewColumn - Gtk::TreeViewColumn* viewColumn = Gtk::manage(new - Gtk::TreeViewColumn(title, *renderer) ); + Gtk::TreeViewColumn* viewColumn = Gtk::manage( + new Gtk::TreeViewColumn(title, *renderer) ); // this cell data function will do the blue-gray zebra stripes viewColumn->set_cell_data_func( @@ -180,8 +216,8 @@ ZebraTreeView :: appendCenteredColumn( renderer->property_xalign() = 0.5; // the constructor packs the renderer into the TreeViewColumn - Gtk::TreeViewColumn* viewColumn = Gtk::manage(new - Gtk::TreeViewColumn(title, *renderer) ); + Gtk::TreeViewColumn* viewColumn = Gtk::manage( + new Gtk::TreeViewColumn(title, *renderer) ); // and then we associate this renderer with the model column viewColumn->add_attribute(renderer->property_markup(), modelColumn); @@ -217,8 +253,8 @@ ZebraTreeView :: appendLineNumberColumn( renderer->property_xalign() = 0.5; // the constructor packs the renderer into the TreeViewColumn - Gtk::TreeViewColumn* viewColumn = Gtk::manage(new - Gtk::TreeViewColumn(title, *renderer) ); + Gtk::TreeViewColumn* viewColumn = Gtk::manage( + new Gtk::TreeViewColumn(title, *renderer) ); // this cell data function will do the blue-gray zebra stripes // and fill in the line number from the model.rowNumberColumn diff --git a/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx b/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx index 41ff4d7a5..b7aae95b9 100644 --- a/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx +++ b/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.23 $ + Version : $Revision: 1.24 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -108,7 +108,7 @@ ScratchpadWindow :: ScratchpadWindow (Ptr::Ref gLiveSupport, // Add the TreeView's view columns: try { treeView->appendColumn(*getResourceUstring("typeColumnLabel"), - modelColumns.typeColumn, 60); + modelColumns.typeColumn, 20); treeView->appendColumn(*getResourceUstring("titleColumnLabel"), modelColumns.titleColumn, 200); } catch (std::invalid_argument &e) { @@ -251,6 +251,8 @@ ScratchpadWindow :: showContents(void) throw () treeModel->clear(); int rowNumber = 0; + Ptr::Ref widgetFactory = WidgetFactory::getInstance(); + while (it != end) { playable = *it; row = *(treeModel->append()); @@ -258,11 +260,13 @@ ScratchpadWindow :: showContents(void) throw () row[modelColumns.playableColumn] = playable; switch (playable->getType()) { case Playable::AudioClipType: - row[modelColumns.typeColumn] = "audioclip"; + row[modelColumns.typeColumn] = widgetFactory->getPixbuf( + WidgetFactory::audioClipIconImage); break; case Playable::PlaylistType: - row[modelColumns.typeColumn] = "playlist"; + row[modelColumns.typeColumn] = widgetFactory->getPixbuf( + WidgetFactory::playlistIconImage); break; default: diff --git a/livesupport/products/gLiveSupport/src/ScratchpadWindow.h b/livesupport/products/gLiveSupport/src/ScratchpadWindow.h index 661daf2aa..96b18fa45 100644 --- a/livesupport/products/gLiveSupport/src/ScratchpadWindow.h +++ b/livesupport/products/gLiveSupport/src/ScratchpadWindow.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -73,7 +73,7 @@ using namespace LiveSupport::Widgets; * playlists. * * @author $Author: fgerlits $ - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ */ class ScratchpadWindow : public WhiteWindow, public LocalizedObject @@ -87,7 +87,7 @@ class ScratchpadWindow : public WhiteWindow, * Lists one clip per row. * * @author $Author: fgerlits $ - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ */ class ModelColumns : public PlayableTreeModelColumnRecord { @@ -95,7 +95,8 @@ class ScratchpadWindow : public WhiteWindow, /** * The column for the type of the entry in the list */ - Gtk::TreeModelColumn typeColumn; + Gtk::TreeModelColumn > + typeColumn; /** * The column for the title of the audio clip or playlist. diff --git a/livesupport/products/gLiveSupport/src/SearchWindow.cxx b/livesupport/products/gLiveSupport/src/SearchWindow.cxx index ea82addd6..c1b8d84dc 100644 --- a/livesupport/products/gLiveSupport/src/SearchWindow.cxx +++ b/livesupport/products/gLiveSupport/src/SearchWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.19 $ + Version : $Revision: 1.20 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SearchWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -232,7 +232,7 @@ SearchWindow :: constructSearchResultsView(void) throw () // add the TreeView's view columns try { searchResults->appendColumn(*getResourceUstring("typeColumnLabel"), - modelColumns.typeColumn, 60); + modelColumns.typeColumn, 20); searchResults->appendColumn(*getResourceUstring("titleColumnLabel"), modelColumns.titleColumn, 200); searchResults->appendColumn(*getResourceUstring("creatorColumnLabel"), @@ -324,6 +324,8 @@ SearchWindow :: onSearch(Ptr::Ref criteria) return; } + Ptr::Ref widgetFactory = WidgetFactory::getInstance(); + std::list::Ref>::const_iterator it; treeModel->clear(); int rowNumber = 0; @@ -339,10 +341,12 @@ SearchWindow :: onSearch(Ptr::Ref criteria) switch (playable->getType()) { case Playable::AudioClipType: - row[modelColumns.typeColumn] = "audioclip"; + row[modelColumns.typeColumn] = widgetFactory->getPixbuf( + WidgetFactory::audioClipIconImage); break; case Playable::PlaylistType: - row[modelColumns.typeColumn] = "playlist"; + row[modelColumns.typeColumn] = widgetFactory->getPixbuf( + WidgetFactory::playlistIconImage); break; default: break; diff --git a/livesupport/products/gLiveSupport/src/SearchWindow.h b/livesupport/products/gLiveSupport/src/SearchWindow.h index f9d593950..5308733e1 100644 --- a/livesupport/products/gLiveSupport/src/SearchWindow.h +++ b/livesupport/products/gLiveSupport/src/SearchWindow.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.13 $ + Version : $Revision: 1.14 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SearchWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -73,7 +73,7 @@ using namespace LiveSupport::Widgets; * The Search/Browse window. * * @author $Author: fgerlits $ - * @version $Revision: 1.13 $ + * @version $Revision: 1.14 $ */ class SearchWindow : public WhiteWindow, public LocalizedObject { @@ -181,7 +181,7 @@ class SearchWindow : public WhiteWindow, public LocalizedObject * Lists one clip per row. * * @author $Author: fgerlits $ - * @version $Revision: 1.13 $ + * @version $Revision: 1.14 $ */ class ModelColumns : public PlayableTreeModelColumnRecord { @@ -189,7 +189,8 @@ class SearchWindow : public WhiteWindow, public LocalizedObject /** * The column for the type of the entry in the list */ - Gtk::TreeModelColumn typeColumn; + Gtk::TreeModelColumn > + typeColumn; /** * The column for the title of the audio clip or playlist. diff --git a/livesupport/products/gLiveSupport/var/widgets/icons/audioClipIcon.gif b/livesupport/products/gLiveSupport/var/widgets/icons/audioClipIcon.gif new file mode 100755 index 000000000..ebfb2ba02 Binary files /dev/null and b/livesupport/products/gLiveSupport/var/widgets/icons/audioClipIcon.gif differ diff --git a/livesupport/products/gLiveSupport/var/widgets/icons/playlistIcon.gif b/livesupport/products/gLiveSupport/var/widgets/icons/playlistIcon.gif new file mode 100755 index 000000000..c38edfff7 Binary files /dev/null and b/livesupport/products/gLiveSupport/var/widgets/icons/playlistIcon.gif differ