Code

Super duper mega (fun!) commit: replaced encoding=utf-8 with fileencoding=utf-8 in...
[inkscape.git] / src / ui / widget / dock-item.cpp
index f3fba93bffe925fb1113522e7786f7fd6f99e354..026eac8e08b3b751a72108aa7aac6d85bc696ad1 100644 (file)
@@ -9,68 +9,45 @@
  * Released under GNU GPL.  Read the file 'COPYING' for more information.
  */
 
+#include <gtk/gtk.h>
+#include <gtkmm.h>
+
 #include "dock-item.h"
 #include "desktop.h"
 #include "inkscape.h"
-#include "prefs-utils.h"
+#include "preferences.h"
 #include "ui/widget/dock.h"
 #include "widgets/icon.h"
 
-#include <gtk/gtk.h>
-
-#include <gtkmm/invisible.h>
-#include <gtkmm/stock.h>
-
 namespace Inkscape {
 namespace UI {
 namespace Widget {
 
 DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& long_name,
                    const Glib::ustring& icon_name, State state) :
-    _dock (dock),
-    _prev_state (state),
-    _window (NULL),
-    _dock_item_action_area (NULL)
-{
-    /* Add a "signal_response" signal to the GdlDockItem, make sure it is
-     * only done once for the class.
-     */
-    static guint response_signal = 0;
-
-    if (response_signal == 0) {
-        response_signal = g_signal_new ("signal_response",
-                                        GDL_TYPE_DOCK_ITEM,
-                                        G_SIGNAL_RUN_FIRST,
-                                        0,
-                                        NULL, NULL,
-                                        g_cclosure_marshal_VOID__INT,
-                                        G_TYPE_NONE, 1, G_TYPE_INT);
-    }
-
-
+    _dock(dock),
+    _prev_state(state),
+    _prev_position(0),
+    _window(0),
+    _x(0),
+    _y(0),
+    _grab_focus_on_realize(false),
+    _gdl_dock_item(0),
+    _dock_item_action_area(0)
+{
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
     GdlDockItemBehavior gdl_dock_behavior =
-        (prefs_get_int_attribute_limited ("options.dock", "cancenterdock", 1, 0, 1) == 0 ?
-         GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER
-         : GDL_DOCK_ITEM_BEH_NORMAL);
+        (prefs->getBool("/options/dock/cancenterdock", true) ?
+            GDL_DOCK_ITEM_BEH_NORMAL :
+            GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER);
 
     if (!icon_name.empty()) {
-        Gtk::Widget *icon = sp_icon_get_icon(icon_name, Inkscape::ICON_SIZE_MENU);
-        if (icon) {
-            // check icon type (inkscape, gtk, none)
-            if ( SP_IS_ICON(icon->gobj()) ) {
-                SPIcon* sp_icon = SP_ICON(icon->gobj());
-                sp_icon_fetch_pixbuf(sp_icon);
-                _icon_pixbuf = Glib::wrap(sp_icon->pb, true);
-            } else if ( GTK_IS_IMAGE(icon->gobj()) ) {
-                _icon_pixbuf = Gtk::Invisible().render_icon(Gtk::StockID(icon_name),
-                                                            Gtk::ICON_SIZE_MENU);
-            }
-            delete icon;
-
-            _gdl_dock_item =
-                gdl_dock_item_new_with_pixbuf_icon(name.c_str(), long_name.c_str(),
-                                                   _icon_pixbuf->gobj(), gdl_dock_behavior);
-        }
+        int width = 0, height = 0;
+        Gtk::IconSize::lookup(Gtk::ICON_SIZE_MENU, width, height);
+        _icon_pixbuf = Gtk::IconTheme::get_default()->load_icon(icon_name, width, (Gtk::IconLookupFlags) 0);
+        _gdl_dock_item =
+            gdl_dock_item_new_with_pixbuf_icon(name.c_str(), long_name.c_str(),
+                                               _icon_pixbuf->gobj(), gdl_dock_behavior);
     } else {
         _gdl_dock_item =
             gdl_dock_item_new(name.c_str(), long_name.c_str(), gdl_dock_behavior);
@@ -228,20 +205,6 @@ DockItem::getPlacement() const
     return (Placement)placement;
 }
 
-
-void
-DockItem::addButton(Gtk::Button* button, int /*response_id*/)
-{
-    // Create a button box for the response buttons if it's the first button to be added
-    if (!_dock_item_action_area) {
-        _dock_item_action_area = new Gtk::HButtonBox(Gtk::BUTTONBOX_END, 6);
-        _dock_item_box.pack_end(*_dock_item_action_area, Gtk::PACK_SHRINK, 0);
-        _dock_item_action_area->set_border_width(6);
-    }
-
-    _dock_item_action_area->pack_start(*button);
-}
-
 void
 DockItem::hide()
 {
@@ -326,13 +289,6 @@ DockItem::signal_delete_event()
                                                   &_signal_delete_event_proxy);
 }
 
-Glib::SignalProxy1<void, int>
-DockItem::signal_response()
-{
-    return Glib::SignalProxy1<void, int>(Glib::wrap(GTK_WIDGET(_gdl_dock_item)),
-                                         &_signal_response_proxy);
-}
-
 Glib::SignalProxy0<void>
 DockItem::signal_drag_begin()
 {
@@ -476,14 +432,6 @@ DockItem::_signal_delete_event_proxy =
 };
 
 
-const Glib::SignalProxyInfo
-DockItem::_signal_response_proxy =
-{
-    "signal_response",
-    (GCallback) &_signal_response_callback,
-    (GCallback) &_signal_response_callback
-};
-
 const Glib::SignalProxyInfo
 DockItem::_signal_drag_begin_proxy =
 {
@@ -530,22 +478,6 @@ DockItem::_signal_delete_event_callback(GtkWidget *self, GdkEventAny *event, voi
     return RType();
 }
 
-void
-DockItem::_signal_response_callback(GtkWidget *self, gint response_id, void *data)
-{
-    using namespace Gtk;
-    typedef sigc::slot<void, int> SlotType;
-
-    if (Glib::ObjectBase::_get_current_wrapper((GObject *) self)) {
-        try {
-            if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
-                (*static_cast<SlotType *>(slot))(response_id);
-        } catch(...) {
-            Glib::exception_handlers_invoke();
-        }
-    }
-}
-
 void
 DockItem::_signal_drag_end_callback(GtkWidget *self, gboolean cancelled, void *data)
 {
@@ -576,4 +508,4 @@ DockItem::_signal_drag_end_callback(GtkWidget *self, gboolean cancelled, void *d
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :