Added Hide command

This commit is contained in:
Joel Holdsworth 2009-04-14 19:39:58 +01:00
parent fbbebc9ab7
commit 8f201b76b7
4 changed files with 53 additions and 3 deletions

View file

@ -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&

View file

@ -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.
**/

View file

@ -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<CheckMenuItem*>(&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

View file

@ -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