Code

UI generalisation
[inkscape.git] / src / ui / widget / dock-item.h
index 38d13a5799479ddd42c9d95edb6d79a8450df927..c0f52a77a6735337904a5d1e6cea289eba900e62 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,
@@ -70,7 +73,7 @@ public:
     State getPrevState() const;
     Placement getPlacement() const;
 
-    void addButton(Gtk::Button *button, int response_id);
+    Gtk::Window *getWindow();   //< gives the parent window, if the dock item has one (i.e. it's floating)
 
     void hide();
     void show();
@@ -78,12 +81,14 @@ public:
 
     void present();
 
+    void grab_focus();
+
     Glib::SignalProxy0<void> signal_show();
     Glib::SignalProxy0<void> signal_hide();
     Glib::SignalProxy1<bool, GdkEventAny *> signal_delete_event();
-    Glib::SignalProxy1<void, int> signal_response();
     Glib::SignalProxy0<void> signal_drag_begin();
     Glib::SignalProxy1<void, bool> signal_drag_end();
+    Glib::SignalProxy0<void> signal_realize();
 
     sigc::signal<void, State, State> signal_state_changed();
 
@@ -97,6 +102,8 @@ private:
     Gtk::Window *_window;     //< reference to floating window, if any 
     int _x, _y;               //< last known position of window, if floating
 
+    bool _grab_focus_on_realize;   //< if the dock item should grab focus on the next realize
+
     GtkWidget *_gdl_dock_item;
     Glib::RefPtr<Gdk::Pixbuf> _icon_pixbuf;
 
@@ -111,37 +118,28 @@ private:
     void _onHide();
     void _onHideWindow();
     void _onShow();
-    void _onResponse(int response_id);
     void _onDragBegin();
     void _onDragEnd(bool cancelled);
+    void _onRealize();
+
     bool _onKeyPress(GdkEventKey *event);
     void _onStateChanged(State prev_state, State new_state);
     bool _onDeleteEvent(GdkEventAny *event);
 
-    void _onFoo();
-
     sigc::connection _signal_key_press_event_connection;
 
     /** GdlDockItem signal proxy structures */
     static const Glib::SignalProxyInfo _signal_show_proxy;
     static const Glib::SignalProxyInfo _signal_hide_proxy;
     static const Glib::SignalProxyInfo _signal_delete_event_proxy;
-    static const Glib::SignalProxyInfo _signal_response_proxy;
+
     static const Glib::SignalProxyInfo _signal_drag_begin_proxy;
     static const Glib::SignalProxyInfo _signal_drag_end_proxy;
+    static const Glib::SignalProxyInfo _signal_realize_proxy;
 
     static gboolean _signal_delete_event_callback(GtkWidget *self, GdkEventAny *event, void *data);
     static void _signal_drag_end_callback(GtkWidget* self, gboolean p0, void* data);
 
-    /** Internal helpers */
-    Gtk::Window *_getWindow();   //< gives the parent window, if the dock item has one (i.e. it's floating)
-
-    /** In order to emulate a signal_response signal like the one for Gtk::Dialog we inject a new
-     * signal into GdlDockItem. This signal will be emitted when a button in the dock item added
-     * through the addButton(..., response_id) method, is clicked. 
-     */
-    static void _signal_response_callback(GtkWidget* self, gint p0, void* data);
-
     sigc::signal<void, State, State> _signal_state_changed;
 
     DockItem();