From fff605e6d8b93e15bef80921efe8853c0e4e8a75 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sat, 4 Apr 2009 18:53:09 +0100 Subject: [PATCH] Added the panel choice list --- src/gui/panels/resources-panel.cpp | 9 +++++-- src/gui/panels/resources-panel.hpp | 6 +++++ src/gui/panels/timeline-panel.cpp | 8 ++++++- src/gui/panels/timeline-panel.hpp | 6 +++++ src/gui/panels/viewer-panel.cpp | 8 ++++++- src/gui/panels/viewer-panel.hpp | 6 +++++ src/gui/widgets/panel-bar.cpp | 19 +++++++++++++++ src/gui/widgets/panel-bar.hpp | 2 ++ src/gui/workspace/panel-manager.cpp | 20 ++++++++++++---- src/gui/workspace/panel-manager.hpp | 37 ++++++++++++++++++++++++++--- 10 files changed, 109 insertions(+), 12 deletions(-) diff --git a/src/gui/panels/resources-panel.cpp b/src/gui/panels/resources-panel.cpp index 041ba12e6..67008f788 100644 --- a/src/gui/panels/resources-panel.cpp +++ b/src/gui/panels/resources-panel.cpp @@ -27,9 +27,8 @@ namespace gui { namespace panels { ResourcesPanel::ResourcesPanel(workspace::WorkspaceWindow &workspace_window) : - Panel(workspace_window, "resources", get_title(), "panel_resources") + Panel(workspace_window, "resources", get_title(), get_stock_id()) { - notebook.append_page(media, _("Media")); notebook.append_page(clips, _("Clips")); notebook.append_page(effects, _("Effects")); @@ -44,5 +43,11 @@ ResourcesPanel::get_title() return _("Resources"); } +const gchar* +ResourcesPanel::get_stock_id() +{ + return "panel_resources"; +} + } // namespace panels } // namespace gui diff --git a/src/gui/panels/resources-panel.hpp b/src/gui/panels/resources-panel.hpp index 8c969e186..74cb0c69c 100644 --- a/src/gui/panels/resources-panel.hpp +++ b/src/gui/panels/resources-panel.hpp @@ -47,6 +47,12 @@ public: **/ static const char* get_title(); + /** + * Get the stock id for this type panel. + * @return Returns a pointer to the string stock id of the panel. + **/ + static const gchar* get_stock_id(); + protected: Gtk::Notebook notebook; diff --git a/src/gui/panels/timeline-panel.cpp b/src/gui/panels/timeline-panel.cpp index b42ab0194..6206e4e42 100644 --- a/src/gui/panels/timeline-panel.cpp +++ b/src/gui/panels/timeline-panel.cpp @@ -48,7 +48,7 @@ const int TimelinePanel::ZoomToolSteps = 2; // 2 seems comfortable TimelinePanel::TimelinePanel(workspace::WorkspaceWindow &workspace_window) : - Panel(workspace_window, "timeline", get_title(), "panel_timeline"), + Panel(workspace_window, "timeline", get_title(), get_stock_id()), timeIndicator(), timeIndicatorButton(), previousButton(Stock::MEDIA_PREVIOUS), @@ -136,6 +136,12 @@ TimelinePanel::get_title() return _("Timeline"); } +const gchar* +TimelinePanel::get_stock_id() +{ + return "panel_timeline"; +} + void TimelinePanel::on_play_pause() { diff --git a/src/gui/panels/timeline-panel.hpp b/src/gui/panels/timeline-panel.hpp index c181a0202..ea33ee5f2 100644 --- a/src/gui/panels/timeline-panel.hpp +++ b/src/gui/panels/timeline-panel.hpp @@ -62,6 +62,12 @@ public: * @return Returns a pointer to the string title of the panel. **/ static const char* get_title(); + + /** + * Get the stock id for this type panel. + * @return Returns a pointer to the string stock id of the panel. + **/ + static const gchar* get_stock_id(); private: //----- Event Handlers -----// diff --git a/src/gui/panels/viewer-panel.cpp b/src/gui/panels/viewer-panel.cpp index e876ae325..e3fb168fc 100644 --- a/src/gui/panels/viewer-panel.cpp +++ b/src/gui/panels/viewer-panel.cpp @@ -37,7 +37,7 @@ namespace gui { namespace panels { ViewerPanel::ViewerPanel(workspace::WorkspaceWindow &workspace_window) : - Panel(workspace_window, "viewer", get_title(), "panel_viewer") + Panel(workspace_window, "viewer", get_title(), get_stock_id()) { //----- Pack in the Widgets -----// pack_start(display, PACK_EXPAND_WIDGET); @@ -55,6 +55,12 @@ ViewerPanel::get_title() return _("Viewer"); } +const gchar* +ViewerPanel::get_stock_id() +{ + return "panel_viewer"; +} + void ViewerPanel::on_frame(void *buffer) { diff --git a/src/gui/panels/viewer-panel.hpp b/src/gui/panels/viewer-panel.hpp index 1e7e6aea6..f01b85689 100644 --- a/src/gui/panels/viewer-panel.hpp +++ b/src/gui/panels/viewer-panel.hpp @@ -52,6 +52,12 @@ public: **/ static const char* get_title(); + /** + * Get the stock id for this type panel. + * @return Returns a pointer to the string stock id of the panel. + **/ + static const gchar* get_stock_id(); + protected: void on_frame(void *buffer); diff --git a/src/gui/widgets/panel-bar.cpp b/src/gui/widgets/panel-bar.cpp index adab2ada9..0b2a6e32a 100644 --- a/src/gui/widgets/panel-bar.cpp +++ b/src/gui/widgets/panel-bar.cpp @@ -21,6 +21,7 @@ * *****************************************************/ #include "panel-bar.hpp" +#include "../workspace/panel-manager.hpp" #include "../panels/panel.hpp" #include "../util/rectangle.hpp" @@ -31,6 +32,7 @@ using namespace Gtk; using namespace Glib; using namespace sigc; using namespace std; +using namespace gui::workspace; namespace gui { namespace widgets { @@ -55,7 +57,18 @@ PanelBar::setup_panel_button() { Menu& menu = panelButton.get_menu(); Menu::MenuList& list = menu.items(); + + // Add items for each type of panel + for(int i = 0; i < PanelManager::get_panel_description_count(); i++) + { + list.push_back( Menu_Helpers::StockMenuElem( + StockID(PanelManager::get_panel_stock_id(i)), + bind(mem_fun(*this, &PanelBar::on_panel_type), i) )); + } + list.push_back( Menu_Helpers::SeparatorElem() ); + + // Add extra commands list.push_back( Menu_Helpers::MenuElem(_("_Hide"), mem_fun(*this, &PanelBar::on_hide) ) ); } @@ -112,6 +125,12 @@ PanelBar::on_size_allocate(Gtk::Allocation& allocation) HBox::on_size_allocate(allocation); } +void +PanelBar::on_panel_type(int type_index) +{ + g_message("on_panel_type %d", type_index); +} + void PanelBar::on_hide() { diff --git a/src/gui/widgets/panel-bar.hpp b/src/gui/widgets/panel-bar.hpp index 4e4b2d98f..cdb2167f9 100644 --- a/src/gui/widgets/panel-bar.hpp +++ b/src/gui/widgets/panel-bar.hpp @@ -70,6 +70,8 @@ private: private: + void on_panel_type(int type_index); + void on_hide(); private: diff --git a/src/gui/workspace/panel-manager.cpp b/src/gui/workspace/panel-manager.cpp index 62079d1e2..8b08c0e11 100644 --- a/src/gui/workspace/panel-manager.cpp +++ b/src/gui/workspace/panel-manager.cpp @@ -111,6 +111,19 @@ PanelManager::get_dock_bar() const return dockBar; } +int +PanelManager::get_panel_description_count() +{ + return sizeof(panelDescriptionList) / sizeof(PanelDescription); +} + +const gchar* +PanelManager::get_panel_stock_id(int index) +{ + REQUIRE(index >= 0 && index < get_panel_description_count()); + return panelDescriptionList[index].get_stock_id(); +} + void PanelManager::create_panels() { @@ -144,11 +157,8 @@ PanelManager::create_panels() shared_ptr PanelManager::create_panel_by_name(const char* class_name) { - const int panelDescriptionCount = - sizeof(panelDescriptionList) / - sizeof(PanelDescription); - - for(int i = 0; i < panelDescriptionCount; i++) + const int count = get_panel_description_count(); + for(int i = 0; i < count; i++) { if(strstr(panelDescriptionList[i].get_class_name(), class_name)) return shared_ptr(panelDescriptionList[i].create( diff --git a/src/gui/workspace/panel-manager.hpp b/src/gui/workspace/panel-manager.hpp index a1822fe2c..1fc014c1b 100644 --- a/src/gui/workspace/panel-manager.hpp +++ b/src/gui/workspace/panel-manager.hpp @@ -75,6 +75,20 @@ public: * @remarks Note that this must not be called before setup_dock. **/ GdlDockBar* get_dock_bar() const; + +public: + + /** + * Gets the number of panel descriptions. + **/ + static int get_panel_description_count(); + + /** + * Gets a panel description. + * @param index The index of the panel to retrieve. + * @return Returns the stock id of a panel at this index. + **/ + static const gchar* get_panel_stock_id(int index); private: @@ -139,14 +153,17 @@ private: * @param class_name The name of the Panel class * @param title The localized title that will be shown on the * panel. + * @param stock_id The Stock ID for this type of panel. * @param create_panel_proc A pointer to a function that will * instantiate the panel object. **/ PanelDescription(const char* class_name, const char *title, + const gchar *stock_id, boost::shared_ptr (*const create_panel_proc)( WorkspaceWindow&)) : className(class_name), titleName(title), + stockID(stock_id), createPanelProc(create_panel_proc) { REQUIRE(className); @@ -171,6 +188,15 @@ private: ENSURE(titleName); return titleName; } + + /** + * Returns the Stock ID for this type of panel. + **/ + const gchar* get_stock_id() const + { + ENSURE(stockID); + return stockID; + } /** * Creates an instance of this panel. @@ -186,12 +212,17 @@ private: /** * A pointer to the string name of class. **/ - const char* className; + const char* const className; /** * The localized title that will be shown on the panel. **/ - const char* titleName; + const char* const titleName; + + /** + * The Stock ID for this type of panel. + **/ + const gchar* const stockID; /** * A pointer to a function that will instantiate the panel object. @@ -213,7 +244,7 @@ private: **/ Panel() : PanelDescription(typeid(P).name(), P::get_title(), - Panel::create_panel) + P::get_stock_id(), Panel::create_panel) {} private: