2008-04-12 22:15:07 +02:00
/*
panel . cpp - Implementation of Panel , the base class for docking panels
2010-12-17 23:28:49 +01:00
2008-04-12 22:15:07 +02:00
Copyright ( C ) Lumiera . org
2008 , Joel Holdsworth < joel @ airwebreathe . org . uk >
2010-12-17 23:28:49 +01:00
2008-04-12 22:15:07 +02:00
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License as
2010-12-17 23:28:49 +01:00
published by the Free Software Foundation ; either version 2 of
the License , or ( at your option ) any later version .
2008-04-12 22:15:07 +02:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2010-12-17 23:28:49 +01:00
2008-04-12 22:15:07 +02:00
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
2010-12-17 23:28:49 +01:00
2008-04-12 22:15:07 +02:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-12-27 05:50:40 +01:00
# include "gui/gtk-lumiera.hpp"
2014-08-17 07:02:48 +02:00
# include "gui/panels/panel.hpp"
2010-12-27 05:50:40 +01:00
# include "gui/workspace/panel-manager.hpp"
# include "gui/workspace/workspace-window.hpp"
2014-08-17 07:02:48 +02:00
# include <gdl/gdl-dock-item-grip.h>
2010-12-27 05:50:40 +01:00
2009-04-13 17:11:50 +02:00
using namespace Gtk ;
2008-04-12 22:15:07 +02:00
namespace gui {
namespace panels {
2009-04-13 17:11:50 +02:00
Panel : : Panel ( workspace : : PanelManager & panel_manager ,
2011-10-16 16:43:59 +02:00
Gdl : : DockItem & dock_item , const gchar * long_name ,
2009-04-13 17:50:42 +02:00
const gchar * stock_id ) :
2009-04-13 17:11:50 +02:00
panelManager ( panel_manager ) ,
dockItem ( dock_item ) ,
2009-04-15 21:12:06 +02:00
hide_panel_handler_id ( 0 ) ,
2009-04-13 17:11:50 +02:00
panelBar ( * this , stock_id )
{
2011-10-16 16:43:59 +02:00
// Set dockItems long-name property
2009-04-13 17:11:50 +02:00
Glib : : Value < std : : string > val ;
val . init ( val . value_type ( ) ) ;
2009-04-13 17:50:42 +02:00
val . set ( long_name ) ;
2011-10-16 16:43:59 +02:00
g_object_set_property ( G_OBJECT ( dockItem . gobj ( ) ) , " long-name " , val . gobj ( ) ) ;
2009-04-13 17:11:50 +02:00
2011-10-17 04:28:55 +02:00
/* Set the grip handle */
FIXME ( " Implement interpanel docking. Try using the dockItem.signal_dock(). Signal Handler will switch the grip depending on dock position. For iconify and interpanel docking, it needs to be a plain label " ) ;
/* @todo This code causes a crash on panel iconify and interpanel docking */
2009-04-13 17:11:50 +02:00
GdlDockItemGrip * grip = GDL_DOCK_ITEM_GRIP (
2011-10-16 16:43:59 +02:00
gdl_dock_item_get_grip ( dockItem . gobj ( ) ) ) ;
2009-04-13 17:11:50 +02:00
gdl_dock_item_grip_show_handle ( grip ) ;
gdl_dock_item_grip_set_label ( grip , ( ( Widget & ) panelBar ) . gobj ( ) ) ;
2011-10-17 04:28:55 +02:00
/* End FIXME */
/* Set up the panel body */
// Add this panel's container to the DockItem
dockItem . add ( ( Gtk : : Widget & ) * this ) ;
/* Connect the signals */
dockItem . signal_hide ( ) . connect (
sigc : : mem_fun ( * this , & Panel : : on_item_hidden ) ) ;
dockItem . show ( ) ;
2008-04-12 22:15:07 +02:00
}
Panel : : ~ Panel ( )
{
2011-10-17 04:28:55 +02:00
/* Detach the panel bar */
2009-04-14 22:40:58 +02:00
GdlDockItemGrip * grip = GDL_DOCK_ITEM_GRIP (
2011-10-16 16:43:59 +02:00
gdl_dock_item_get_grip ( dockItem . gobj ( ) ) ) ;
2009-04-14 22:40:58 +02:00
gtk_container_remove ( GTK_CONTAINER ( grip ) ,
( ( Widget & ) panelBar ) . gobj ( ) ) ;
2011-10-17 04:28:55 +02:00
/* Remove this panel's container from the DockItem */
dockItem . remove ( ( Gtk : : Widget & ) * this ) ;
2008-04-12 22:15:07 +02:00
}
2011-10-16 16:43:59 +02:00
Gdl : : DockItem &
Panel : : get_dock_item ( )
2008-04-12 22:15:07 +02:00
{
2009-04-13 17:11:50 +02:00
return dockItem ;
2008-04-12 22:15:07 +02:00
}
2008-05-17 12:20:49 +02:00
void
Panel : : show ( bool show )
{
2011-10-16 16:43:59 +02:00
//REQUIRE(dockItem != NULL);
if ( show ) dockItem . show_item ( ) ;
else dockItem . hide_item ( ) ;
2008-05-17 12:20:49 +02:00
}
bool
2009-04-15 21:12:06 +02:00
Panel : : is_shown ( ) const
2008-05-17 12:20:49 +02:00
{
2011-10-16 16:43:59 +02:00
//REQUIRE(dockItem != NULL);
return dockItem . is_visible ( ) ;
2009-04-15 21:12:06 +02:00
}
void
Panel : : iconify ( )
{
2011-10-16 16:43:59 +02:00
// //REQUIRE(dockItem != NULL);
// gdl_dock_item_iconify_item(dockItem);
dockItem . iconify_item ( ) ;
2009-04-15 21:12:06 +02:00
}
bool
Panel : : is_iconified ( ) const
{
2011-10-16 16:43:59 +02:00
// REQUIRE(dockItem);
TODO ( " Port to Gdlmm " ) ;
return GDL_DOCK_ITEM_ICONIFIED ( dockItem . gobj ( ) ) ;
2009-04-14 20:39:58 +02:00
}
void
Panel : : lock ( bool lock )
{
2011-10-16 16:43:59 +02:00
// //REQUIRE(dockItem != NULL);
if ( lock ) dockItem . lock ( ) ;
else dockItem . unlock ( ) ;
2009-04-13 17:11:50 +02:00
}
2009-04-15 21:12:06 +02:00
bool
Panel : : is_locked ( ) const
{
2011-10-16 16:43:59 +02:00
////REQUIRE(dockItem != NULL);
return ! GDL_DOCK_ITEM_NOT_LOCKED ( dockItem . gobj ( ) ) ;
2009-04-15 21:12:06 +02:00
}
2009-04-13 17:11:50 +02:00
workspace : : PanelManager &
Panel : : get_panel_manager ( )
{
return panelManager ;
2008-05-17 12:20:49 +02:00
}
2009-04-05 00:01:50 +02:00
workspace : : WorkspaceWindow &
Panel : : get_workspace_window ( )
{
2009-04-13 17:11:50 +02:00
return panelManager . get_workspace_window ( ) ;
2009-04-05 00:01:50 +02:00
}
2009-04-13 17:11:50 +02:00
model : : Project &
Panel : : get_project ( )
2008-05-15 01:04:10 +02:00
{
2009-04-13 17:11:50 +02:00
return panelManager . get_workspace_window ( ) . get_project ( ) ;
}
controller : : Controller &
Panel : : get_controller ( )
{
return panelManager . get_workspace_window ( ) . get_controller ( ) ;
2008-05-15 01:04:10 +02:00
}
2011-10-17 04:28:55 +02:00
sigc : : signal < void >
2009-04-15 21:12:06 +02:00
Panel : : signal_hide_panel ( )
{
return hidePanelSignal ;
}
void
2011-10-17 04:28:55 +02:00
Panel : : on_item_hidden ( )
2009-04-15 21:12:06 +02:00
{
2011-10-17 04:28:55 +02:00
hidePanelSignal . emit ( ) ;
2009-04-15 21:12:06 +02:00
}
2008-04-12 22:15:07 +02:00
} // namespace panels
} // namespace gui