From 8f201b76b7a707d25b4ff7c89d7c1932a38a2b61 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Tue, 14 Apr 2009 19:39:58 +0100 Subject: [PATCH] Added Hide command --- src/gui/panels/panel.cpp | 12 ++++++++++-- src/gui/panels/panel.hpp | 12 ++++++++++++ src/gui/widgets/panel-bar.cpp | 20 +++++++++++++++++++- src/gui/widgets/panel-bar.hpp | 12 ++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/gui/panels/panel.cpp b/src/gui/panels/panel.cpp index 416f0d2a8..1c41782f9 100644 --- a/src/gui/panels/panel.cpp +++ b/src/gui/panels/panel.cpp @@ -80,10 +80,18 @@ Panel::show(bool show) } bool -Panel::is_shown() const +Panel::is_locked() const { REQUIRE(dockItem != NULL); - return GTK_WIDGET_VISIBLE((GtkWidget*)dockItem); + return !GDL_DOCK_ITEM_NOT_LOCKED(dockItem); +} + +void +Panel::lock(bool lock) +{ + REQUIRE(dockItem != NULL); + if(lock) gdl_dock_item_lock (dockItem); + else gdl_dock_item_unlock (dockItem); } workspace::PanelManager& diff --git a/src/gui/panels/panel.hpp b/src/gui/panels/panel.hpp index a44f45643..89559be3b 100644 --- a/src/gui/panels/panel.hpp +++ b/src/gui/panels/panel.hpp @@ -81,6 +81,18 @@ public: */ bool is_shown() const; + /** + * Locks or unlocks the panel. + * @param show A value of true will lock the panel, false will unlock + * it. + **/ + void lock(bool show = true); + + /** + * Returns true if the panel is currently locked. + **/ + bool is_locked() const; + /** * Returns a reference to the owner panel manager object. **/ diff --git a/src/gui/widgets/panel-bar.cpp b/src/gui/widgets/panel-bar.cpp index 95a4b831f..777b2a149 100644 --- a/src/gui/widgets/panel-bar.cpp +++ b/src/gui/widgets/panel-bar.cpp @@ -41,7 +41,8 @@ namespace widgets { PanelBar::PanelBar(panels::Panel &owner_panel, const gchar *stock_id) : HBox(), panel(owner_panel), - panelButton(StockID(stock_id)) + panelButton(StockID(stock_id)), + lockItem(NULL) { set_border_width(1); @@ -56,6 +57,8 @@ PanelBar::PanelBar(panels::Panel &owner_panel, const gchar *stock_id) : void PanelBar::setup_panel_button() { + REQUIRE(lockItem == NULL); + Menu& menu = panelButton.get_menu(); Menu::MenuList& list = menu.items(); @@ -72,6 +75,12 @@ PanelBar::setup_panel_button() // Add extra commands list.push_back( Menu_Helpers::MenuElem(_("_Hide"), mem_fun(*this, &PanelBar::on_hide) ) ); + + list.push_back( Menu_Helpers::CheckMenuElem(_("_Lock"), + mem_fun(*this, &PanelBar::on_lock) ) ); + lockItem = dynamic_cast(&list.back()); + ENSURE(lockItem); + lockItem->set_active(panel.is_locked()); } void @@ -138,5 +147,14 @@ PanelBar::on_hide() panel.show(false); } +void +PanelBar::on_lock() +{ + REQUIRE(lockItem); + const bool lock = !panel.is_locked(); + panel.lock(lock); + lockItem->set_active(lock); +} + } // widgets } // gui diff --git a/src/gui/widgets/panel-bar.hpp b/src/gui/widgets/panel-bar.hpp index 2df66f035..36a327c11 100644 --- a/src/gui/widgets/panel-bar.hpp +++ b/src/gui/widgets/panel-bar.hpp @@ -82,6 +82,11 @@ private: * An event handler for when the "Hide" menu item is clicked **/ void on_hide(); + + /** + * Event handler for when the "Lock" menu item is clicked + **/ + void on_lock(); private: @@ -96,6 +101,13 @@ private: **/ MenuButton panelButton; + /** + * A pointer to the lock menu item. + * @remarks This value will remain NULL until after setup_panel_button + * has been called. + **/ + Gtk::CheckMenuItem *lockItem; + /** * The bar window. * @remarks This window is used only to set the cursor as an arrow for