Code

Define DockItems' floating state properly. Fixes some issues with
authorgustav_b <gustav_b@users.sourceforge.net>
Tue, 25 Sep 2007 23:23:44 +0000 (23:23 +0000)
committergustav_b <gustav_b@users.sourceforge.net>
Tue, 25 Sep 2007 23:23:44 +0000 (23:23 +0000)
floating docks.

src/ui/widget/dock-item.cpp
src/ui/widget/dock-item.h
src/ui/widget/dock.cpp
src/ui/widget/dock.h

index 2187c33e907c2e48fc84071d694aff289c86ae23..74cc44be9a3ec86a7d848bca5b653888872412d1 100644 (file)
@@ -196,14 +196,8 @@ DockItem::isAttached() const
 bool
 DockItem::isFloating() const
 {
-    gboolean floating = FALSE;
-    if (GDL_IS_DOCK (gdl_dock_object_get_parent_object (GDL_DOCK_OBJECT (_gdl_dock_item)))) {
-        GdlDock* dock = GDL_DOCK (gdl_dock_object_get_parent_object (GDL_DOCK_OBJECT (_gdl_dock_item)));
-        g_object_get (dock,
-                      "floating", &floating,
-                      NULL);
-    }
-    return floating;
+    return (GTK_WIDGET(gdl_dock_object_get_toplevel(GDL_DOCK_OBJECT (_gdl_dock_item))) != 
+            _dock.getGdlWidget());
 }
 
 bool
@@ -431,7 +425,7 @@ DockItem::_onStateChanged(State prev_state, State new_state)
 {
     _window = getWindow();
 
-    if (new_state == FLOATING_STATE) {
+    if (new_state == FLOATING_STATE && _window) {
         _window->signal_hide().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onHideWindow));
         _signal_key_press_event_connection = 
             _window->signal_key_press_event().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onKeyPress));
index d2881c0053263709f4e064c511b6fa557b7b7961..af2f3ac7022b21e4e73b5af5c47eb0c22735d4c5 100644 (file)
@@ -31,7 +31,10 @@ class DockItem {
 
 public:
 
-    enum State { UNATTACHED, FLOATING_STATE, DOCKED_STATE };
+    enum State { UNATTACHED,     // item not bound to the dock (a temporary state)
+                 FLOATING_STATE, // item not in its dock (but can be docked in other,
+                                 // e.g. floating, docks)
+                 DOCKED_STATE }; // item in its assigned dock
 
     enum Placement { 
         NONE     = GDL_DOCK_NONE,
index f282449dd0994bda824c573b3e4363e953c69630..ae19ed8d6fa5197dbe9e6ad2ccec9d789ed5facf 100644 (file)
@@ -133,6 +133,11 @@ Dock::getPaned()
     return _paned;
 }
 
+GtkWidget *
+Dock::getGdlWidget()
+{
+    return GTK_WIDGET(_gdl_dock);
+}
 
 bool
 Dock::isEmpty() const
index 3cd29c01f5428b4f99e6ce1d7adf10aaa8022fb3..b5ecc02cabed6ac68b9b3146b630b1db2534b9dc 100644 (file)
@@ -37,10 +37,11 @@ public:
 
     Gtk::Widget& getWidget();     //< return the top widget
     Gtk::Paned *getParentPaned();
-
     Gtk::Paned *getPaned();
 
-    bool isEmpty() const;     //< true iff none of the dock's items are in state != UNATTACHED
+    GtkWidget* getGdlWidget();    //< return the top gdl widget
+
+    bool isEmpty() const;         //< true iff none of the dock's items are in a docked state
     bool hasIconifiedItems() const;
 
     Glib::SignalProxy0<void> signal_layout_changed();