From 2d8805c5545ad0f181f7156e6287c0f1bf5be587 Mon Sep 17 00:00:00 2001 From: "Michael R. Fisher" Date: Sun, 16 Oct 2011 21:28:55 -0500 Subject: [PATCH] Gdlmm port nuances. Signals/Containers etc... --- src/gui/panels/panel.cpp | 47 +++++++++++--------------- src/gui/panels/panel.hpp | 3 +- src/gui/workspace/panel-manager.cpp | 24 +++++++------ src/gui/workspace/workspace-window.cpp | 10 +----- 4 files changed, 36 insertions(+), 48 deletions(-) diff --git a/src/gui/panels/panel.cpp b/src/gui/panels/panel.cpp index e28beddc9..2ba98931d 100644 --- a/src/gui/panels/panel.cpp +++ b/src/gui/panels/panel.cpp @@ -47,42 +47,36 @@ Panel::Panel(workspace::PanelManager &panel_manager, val.set(long_name); g_object_set_property (G_OBJECT (dockItem.gobj()), "long-name", val.gobj()); - // Set the grip handle + /* 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 */ GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP( gdl_dock_item_get_grip(dockItem.gobj())); gdl_dock_item_grip_show_handle(grip); gdl_dock_item_grip_set_label(grip, ((Widget&)panelBar).gobj()); - - // Set up the panel body - gtk_container_add (GTK_CONTAINER(dockItem.gobj()), GTK_WIDGET(gobj())); - - gtk_widget_show (GTK_WIDGET(dockItem.gobj())); - - // Connect the signals - hide_panel_handler_id = g_signal_connect (GTK_OBJECT(dockItem.gobj()), - "hide", G_CALLBACK(on_item_hidden), this); + /* 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(); } Panel::~Panel() { - TODO("Fix for Gdlmm"); - //REQUIRE(dockItem != NULL); - - // Detach the panel bar + /* Detach the panel bar */ GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP( gdl_dock_item_get_grip(dockItem.gobj())); gtk_container_remove (GTK_CONTAINER(grip), ((Widget&)panelBar).gobj()); - - gtk_container_remove (GTK_CONTAINER(dockItem.gobj()), GTK_WIDGET(gobj())); - - // Detach the signals - g_signal_handler_disconnect( - GTK_OBJECT(dockItem.gobj()), hide_panel_handler_id); - // Unref the dock item - // g_object_unref(dockItem); - // dockItem = NULL; + /* Remove this panel's container from the DockItem */ + dockItem.remove((Gtk::Widget&)*this); } Gdl::DockItem& @@ -162,17 +156,16 @@ Panel::get_controller() return panelManager.get_workspace_window().get_controller(); } -sigc::signal& +sigc::signal Panel::signal_hide_panel() { return hidePanelSignal; } void -Panel::on_item_hidden(GdlDockItem*, Panel *panel) +Panel::on_item_hidden() { - REQUIRE(panel); - panel->hidePanelSignal(); + hidePanelSignal.emit(); } } // namespace panels diff --git a/src/gui/panels/panel.hpp b/src/gui/panels/panel.hpp index f5c3978de..43fe5c7f2 100644 --- a/src/gui/panels/panel.hpp +++ b/src/gui/panels/panel.hpp @@ -135,9 +135,8 @@ private: /** * An event handler for when dockItem is hidden. - * @param func_data A pointer to the panel that owns dock_item */ - static void on_item_hidden(GdlDockItem*, Panel *panel); + void on_item_hidden(); protected: diff --git a/src/gui/workspace/panel-manager.cpp b/src/gui/workspace/panel-manager.cpp index 7a1368340..cc479b78b 100644 --- a/src/gui/workspace/panel-manager.cpp +++ b/src/gui/workspace/panel-manager.cpp @@ -50,7 +50,13 @@ PanelManager::PanelManager(WorkspaceWindow &workspace_window) : dockBar(dock), dockLayout() { + /* Create the DockLayout */ dockLayout = Gdl::DockLayout::create(dock); + + /* Setup the Switcher Style */ + Glib::RefPtr dock_master = dock.property_master(); + dock_master->property_switcher_style() = Gdl::SWITCHER_STYLE_ICON; + memset(&dockPlaceholders, 0, sizeof(dockPlaceholders)); } @@ -118,7 +124,6 @@ PanelManager::show_panel(const int description_index) Gdl::DockItem &dock_item = panel->get_dock_item(); // ENSURE(dock_item); dock_item.present(dock); - // gdl_dock_object_present(GDL_DOCK_OBJECT(dock_item.gobj()), NULL); return; } } @@ -144,37 +149,36 @@ void PanelManager::switch_panel(panels::Panel &old_panel, // Create the new panel create_panel_by_index(description_index, dock_item); - } void PanelManager::split_panel(panels::Panel &panel, Gtk::Orientation split_direction) { - TODO("Port to Gdlmm"); + // Create the new panel const int index = get_panel_type(&panel); panels::Panel *new_panel = create_panel_by_index(index); // Dock the panel - // Gdl::DockPlacement placement = Gdl::DOCK_NONE; - GdlDockPlacement placement = GDL_DOCK_NONE; + Gdl::DockPlacement placement = Gdl::DOCK_NONE; switch(split_direction) { case ORIENTATION_HORIZONTAL: - placement = GDL_DOCK_RIGHT; + placement = Gdl::DOCK_RIGHT; break; case ORIENTATION_VERTICAL: - placement = GDL_DOCK_BOTTOM; + placement = Gdl::DOCK_BOTTOM; break; default: - ERROR(gui, "Unrecognisized split_direction: %d", split_direction); + ERROR(gui, "Unrecognisized split_direction: %d", + split_direction); return; break; } - gdl_dock_object_dock(GDL_DOCK_OBJECT(panel.get_dock_item().gobj()), - GDL_DOCK_OBJECT(new_panel->get_dock_item().gobj()), placement, NULL); + panel.get_dock_item().dock( + new_panel->get_dock_item(),placement); } int diff --git a/src/gui/workspace/workspace-window.cpp b/src/gui/workspace/workspace-window.cpp index 8e078f90e..32cc32389 100644 --- a/src/gui/workspace/workspace-window.cpp +++ b/src/gui/workspace/workspace-window.cpp @@ -57,7 +57,7 @@ WorkspaceWindow::WorkspaceWindow(Project &source_project, WorkspaceWindow::~WorkspaceWindow() { - INFO (gui_dbg, "closing workspace window..."); + INFO (gui_dbg, "Closing workspace window..."); } Project& @@ -103,14 +103,6 @@ WorkspaceWindow::create_ui() //----- Create the Docks -----// panelManager.setup_dock(); - /* - GdlDock const *dock = panelManager.get_dock(); - - gtk_box_pack_start(GTK_BOX(dockContainer.gobj()), - GTK_WIDGET(panelManager.get_dock_bar()), FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(dockContainer.gobj()), - GTK_WIDGET(dock), TRUE, TRUE, 0); - */ dockContainer.pack_start(panelManager.get_dock_bar(),false,false,0); dockContainer.pack_start(panelManager.get_dock(),true,true,0); baseContainer.pack_start(dockContainer, PACK_EXPAND_WIDGET);