diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 6fcc0a5a3..ff02570bd 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -70,7 +70,13 @@ lumigui_SOURCES = \ lumigui_LDFLAGS = lumigui_LDADD = $(GTK_LUMIERA_LIBS) -lumigui_DEPENDENCIES = $(top_builddir)/lumiera_ui.rc +lumigui_DEPENDENCIES = \ + $(top_builddir)/lumiera_ui.rc \ + $(top_builddir)/viewer-panel.png + $(top_builddir)/lumiera_ui.rc: cp $(lumigui_srcdir)/lumiera_ui.rc $(top_builddir) +$(top_builddir)/viewer-panel.png: + cp $(top_srcdir)/icons/viewer-panel.png $(top_builddir) + diff --git a/src/gui/panels/panel.cpp b/src/gui/panels/panel.cpp index 67ac1fd3f..efe3f3b38 100644 --- a/src/gui/panels/panel.cpp +++ b/src/gui/panels/panel.cpp @@ -29,8 +29,14 @@ namespace panels { Panel::Panel(const gchar *name, const gchar *long_name, GdlDockItemBehavior behavior) { dock_item = (GdlDockItem*)gdl_dock_item_new (name, long_name, behavior); - gtk_container_add ((GtkContainer*)dock_item, (GtkWidget*)gobj()); - gtk_widget_show ((GtkWidget*)dock_item); + internal_setup(); +} + +Panel::Panel(const gchar *name, const gchar *long_name, const gchar *stock_id, + GdlDockItemBehavior behavior) +{ + dock_item = (GdlDockItem*)gdl_dock_item_new_with_stock (name, long_name, stock_id, behavior); + internal_setup(); } Panel::~Panel() @@ -43,6 +49,12 @@ GdlDockItem* Panel::get_dock_item() const return dock_item; } +void Panel::internal_setup() +{ + gtk_container_add ((GtkContainer*)dock_item, (GtkWidget*)gobj()); + gtk_widget_show ((GtkWidget*)dock_item); +} + } // namespace panels } // namespace gui } // namespace lumiera diff --git a/src/gui/panels/panel.hpp b/src/gui/panels/panel.hpp index 05cc47dc6..05e180e77 100644 --- a/src/gui/panels/panel.hpp +++ b/src/gui/panels/panel.hpp @@ -40,13 +40,22 @@ namespace panels { class Panel : public Gtk::VBox { protected: + Panel(const gchar *name, const gchar *long_name, GdlDockItemBehavior behavior = GDL_DOCK_ITEM_BEH_NORMAL); + Panel(const gchar *name, const gchar *long_name, const gchar *stock_id, + GdlDockItemBehavior behavior = GDL_DOCK_ITEM_BEH_NORMAL); ~Panel(); public: GdlDockItem* get_dock_item() const; + private: + /** + * The internal constructor for this class, whose purpose + * is to set up the internal container widgets. + */ + void internal_setup(); protected: GdlDockItem* dock_item; diff --git a/src/gui/panels/viewer-panel.cpp b/src/gui/panels/viewer-panel.cpp index ea1bfeffd..c5a64f781 100644 --- a/src/gui/panels/viewer-panel.cpp +++ b/src/gui/panels/viewer-panel.cpp @@ -30,7 +30,7 @@ namespace gui { namespace panels { ViewerPanel::ViewerPanel() : - Panel("viewer", "Viewer"), + Panel("viewer", "Viewer", "viewer_panel"), previousButton(Stock::MEDIA_PREVIOUS), rewindButton(Stock::MEDIA_REWIND), playPauseButton(Stock::MEDIA_PLAY), diff --git a/src/gui/workspace/actions.cpp b/src/gui/workspace/actions.cpp index 6d69a8e6a..389c0059a 100644 --- a/src/gui/workspace/actions.cpp +++ b/src/gui/workspace/actions.cpp @@ -38,6 +38,8 @@ namespace workspace { Actions::Actions(WorkspaceWindow &workspace_window) : workspaceWindow(workspace_window) { + register_stock_items(); + actionGroup = ActionGroup::create(); // File menu @@ -63,7 +65,7 @@ namespace workspace { // View Menu actionGroup->add(Action::create("ViewMenu", _("_View"))); - actionGroup->add(Action::create("ViewViewer", _("_Viewer")), + actionGroup->add(Action::create("ViewViewer", Gtk::StockID("viewer_panel")), sigc::mem_fun(*this, &Actions::on_menu_view_viewer)); actionGroup->add(Action::create("ViewTimeline", _("_Timeline")), sigc::mem_fun(*this, &Actions::on_menu_view_timeline)); @@ -74,6 +76,41 @@ namespace workspace { sigc::mem_fun(*this, &Actions::on_menu_help_about) ); } + void + Actions::register_stock_items() + { + RefPtr factory = IconFactory::create(); + add_stock_item(factory, "viewer-panel.png", "viewer_panel", _("_Viewer")); + factory->add_default(); //Add factory to list of factories. + } + + void + Actions::add_stock_item(const Glib::RefPtr& factory, + const Glib::ustring& filepath, + const Glib::ustring& id, const Glib::ustring& label) + { + Gtk::IconSource source; + try + { + //This throws an exception if the file is not found: + source.set_pixbuf( Gdk::Pixbuf::create_from_file(filepath) ); + } + catch(const Glib::Exception& ex) + { + g_message(ex.what().c_str()); + } + + source.set_size(Gtk::ICON_SIZE_SMALL_TOOLBAR); + source.set_size_wildcarded(); //Icon may be scaled. + + Gtk::IconSet icon_set; + icon_set.add_source(source); //More than one source per set is allowed. + + const Gtk::StockID stock_id(id); + factory->add(stock_id, icon_set); + Gtk::Stock::add(Gtk::StockItem(stock_id, label)); + } + /* ===== File Menu Event Handlers ===== */ void diff --git a/src/gui/workspace/actions.hpp b/src/gui/workspace/actions.hpp index 5ec50c33a..9b9092250 100644 --- a/src/gui/workspace/actions.hpp +++ b/src/gui/workspace/actions.hpp @@ -46,12 +46,19 @@ class WorkspaceWindow; private: Actions(WorkspaceWindow &workspace_window); + void register_stock_items(); + + void add_stock_item(const Glib::RefPtr& factory, + const Glib::ustring& filepath, + const Glib::ustring& id, const Glib::ustring& label); + /** - * A reference to the MainWindow which owns - * this helper */ + * A reference to the MainWindow which owns + * this helper */ WorkspaceWindow &workspaceWindow; /* ===== Event Handlers ===== */ + private: void on_menu_file_new_project(); void on_menu_file_open_project(); void on_menu_file_render();