Code

Move files from the src/dialogs/ directory to the places where they
[inkscape.git] / src / widgets / desktop-widget.cpp
index 1fdf1fceb632db1f942b659f03cb826e5d5fcb4b..356a09418de9439c8661762afcec391cfb44d1d4 100644 (file)
 #include <gtkmm/paned.h>
 #include <gtk/gtk.h>
 
-#include "macros.h"
-#include "inkscape-private.h"
-#include "desktop-handles.h"
+#include "box3d-context.h"
+#include "color-profile-fns.h"
+#include "conn-avoid-ref.h"
 #include "desktop-events.h"
-#include "document.h"
+#include "desktop-handles.h"
 #include "desktop-widget.h"
-#include "sp-namedview.h"
-#include "interface.h"
-#include "toolbox.h"
-#include "preferences.h"
-#include "file.h"
 #include "display/canvas-arena.h"
 #include "display/nr-arena.h"
+#include "document.h"
+#include "ege-color-prof-tracker.h"
+#include "ege-select-one-action.h"
 #include <extension/db.h>
+#include "file.h"
 #include "helper/units.h"
-#include "widgets/button.h"
-#include "widgets/ruler.h"
-#include "widgets/widget-sizes.h"
-#include "widgets/spw-utilities.h"
-#include "widgets/spinbutton-events.h"
-#include "widgets/layer-selector.h"
+#include "inkscape-private.h"
+#include "interface.h"
+#include "macros.h"
+#include "preferences.h"
+#include "sp-image.h"
+#include "sp-item.h"
+#include "sp-namedview.h"
+#include "toolbox.h"
 #include "ui/dialog/dialog-manager.h"
+#include "ui/dialog/swatches.h"
 #include "ui/widget/dock.h"
+#include "ui/widget/layer-selector.h"
 #include "ui/widget/selected-style.h"
-#include "sp-item.h"
-#include "dialogs/swatches.h"
-#include "conn-avoid-ref.h"
-#include "ege-select-one-action.h"
-#include "ege-color-prof-tracker.h"
-#include "color-profile-fns.h"
-#include "box3d-context.h"
-#include "sp-image.h"
+#include "widgets/button.h"
+#include "widgets/ruler.h"
+#include "widgets/spinbutton-events.h"
+#include "widgets/spw-utilities.h"
+#include "widgets/toolbox.h"
+#include "widgets/widget-sizes.h"
 
 #if defined (SOLARIS) && (SOLARIS == 8)
 #include "round.h"
@@ -137,11 +138,11 @@ public:
 
 private:
     static void hook(EgeColorProfTracker *tracker, gint a, gint b, CMSPrefWatcher *watcher);
-    
+
     class DisplayProfileWatcher : public Inkscape::Preferences::Observer {
     public:
         DisplayProfileWatcher(CMSPrefWatcher &pw) : Observer("/options/displayprofile"), _pw(pw) {}
-        virtual void notify(Inkscape::Preferences::Entry const &val) {
+        virtual void notify(Inkscape::Preferences::Entry const &/*val*/) {
             Inkscape::Preferences *prefs = Inkscape::Preferences::get();
             _pw._setCmsSensitive(!prefs->getString("/options/displayprofile/uri").empty());
             _pw._refreshAll();
@@ -149,9 +150,9 @@ private:
     private:
         CMSPrefWatcher &_pw;
     };
-    
+
     DisplayProfileWatcher _dpw;
-    
+
     class SoftProofWatcher : public Inkscape::Preferences::Observer {
     public:
         SoftProofWatcher(CMSPrefWatcher &pw) : Observer("/options/softproof"), _pw(pw) {}
@@ -161,15 +162,15 @@ private:
     private:
         CMSPrefWatcher &_pw;
     };
-    
+
     SoftProofWatcher _spw;
-    
+
     void _refreshAll();
     void _setCmsSensitive(bool value);
 
     std::list<SPDesktopWidget*> _widget_list;
     EgeColorProfTracker *_tracker;
-    
+
     friend class DisplayProfileWatcher;
     friend class SoftproofWatcher;
 };
@@ -289,7 +290,7 @@ sp_desktop_widget_init (SPDesktopWidget *dtw)
     GtkWidget *hbox;
     GtkWidget *eventbox;
     GtkStyle *style;
-    
+
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
     new (&dtw->modified_connection) sigc::connection();
@@ -325,6 +326,9 @@ sp_desktop_widget_init (SPDesktopWidget *dtw)
     dtw->aux_toolbox = sp_aux_toolbox_new ();
     gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->aux_toolbox, FALSE, TRUE, 0);
 
+    dtw->snap_toolbox = sp_snap_toolbox_new ();
+    gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->snap_toolbox, FALSE, TRUE, 0);
+
     dtw->commands_toolbox = sp_commands_toolbox_new ();
     gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->commands_toolbox, FALSE, TRUE, 0);
 
@@ -1065,9 +1069,10 @@ SPDesktopWidget::setWindowSize (gint w, gint h)
 void
 SPDesktopWidget::setWindowTransient (void *p, int transient_policy)
 {
-    GtkWindow *w =GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(this)));
-    if (w)
+    Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
+    if (window)
     {
+        GtkWindow *w = (GtkWindow *) window->gobj();
         gtk_window_set_transient_for (GTK_WINDOW(p), w);
 
         /*
@@ -1078,7 +1083,6 @@ SPDesktopWidget::setWindowTransient (void *p, int transient_policy)
          * (so that its transients also could raise)
          */
         if (transient_policy == 2)
-
             // without this, a transient window not always emerges on top
             gtk_window_present (w);
     }
@@ -1198,11 +1202,13 @@ sp_desktop_widget_layout (SPDesktopWidget *dtw)
            pref_root = "/window/";
     }
 
+#ifndef GDK_WINDOWING_QUARTZ
     if (!prefs->getBool(pref_root + "menu/state", true)) {
         gtk_widget_hide_all (dtw->menubar);
     } else {
         gtk_widget_show_all (dtw->menubar);
     }
+#endif
 
     if (!prefs->getBool(pref_root + "commands/state", true)) {
         gtk_widget_hide_all (dtw->commands_toolbox);
@@ -1210,6 +1216,12 @@ sp_desktop_widget_layout (SPDesktopWidget *dtw)
         gtk_widget_show_all (dtw->commands_toolbox);
     }
 
+    if (!prefs->getBool(pref_root + "snaptoolbox/state", true)) {
+               gtk_widget_hide_all (dtw->snap_toolbox);
+       } else {
+               gtk_widget_show_all (dtw->snap_toolbox);
+       }
+
     if (!prefs->getBool(pref_root + "toppanel/state", true)) {
         gtk_widget_hide_all (dtw->aux_toolbox);
     } else {
@@ -1308,7 +1320,7 @@ SPDesktopWidget::isToolboxButtonActive (const gchar* id)
 SPViewWidget *
 sp_desktop_widget_new (SPNamedView *namedview)
 {
-    SPDesktopWidget *dtw = (SPDesktopWidget*)gtk_type_new (SP_TYPE_DESKTOP_WIDGET);
+    SPDesktopWidget *dtw = (SPDesktopWidget*)g_object_new(SP_TYPE_DESKTOP_WIDGET, NULL);
 
     dtw->dt2r = 1.0 / namedview->doc_units->unittobase;
 
@@ -1337,14 +1349,17 @@ sp_desktop_widget_new (SPNamedView *namedview)
     dtw->layer_selector->setDesktop(dtw->desktop);
 
     dtw->menubar = sp_ui_main_menubar (dtw->desktop);
+#ifndef GDK_WINDOWING_QUARTZ
     gtk_widget_show_all (dtw->menubar);
     gtk_box_pack_start (GTK_BOX (dtw->vbox), dtw->menubar, FALSE, FALSE, 0);
+#endif
 
     sp_desktop_widget_layout (dtw);
 
     sp_tool_toolbox_set_desktop (dtw->tool_toolbox, dtw->desktop);
     sp_aux_toolbox_set_desktop (dtw->aux_toolbox, dtw->desktop);
     sp_commands_toolbox_set_desktop (dtw->commands_toolbox, dtw->desktop);
+    sp_snap_toolbox_set_desktop (dtw->snap_toolbox, dtw->desktop);
 
     return SP_VIEW_WIDGET (dtw);
 }
@@ -1406,7 +1421,7 @@ sp_desktop_widget_namedview_modified (SPObject *obj, guint flags, SPDesktopWidge
 {
     SPNamedView *nv=SP_NAMEDVIEW(obj);
     if (flags & SP_OBJECT_MODIFIED_FLAG) {
-        dtw->dt2r = 1.0 / nv->doc_units->unittobase;
+       dtw->dt2r = 1.0 / nv->doc_units->unittobase;
         dtw->ruler_origin = Geom::Point(0,0); //nv->gridorigin;   Why was the grid origin used here?
 
         sp_ruler_set_metric (GTK_RULER (dtw->vruler), nv->getDefaultMetric());
@@ -1416,6 +1431,7 @@ sp_desktop_widget_namedview_modified (SPObject *obj, guint flags, SPDesktopWidge
         gtk_tooltips_set_tip (dtw->tt, dtw->vruler_box, gettext(sp_unit_get_plural (nv->doc_units)), NULL);
 
         sp_desktop_widget_update_rulers (dtw);
+        update_snap_toolbox(dtw->desktop, NULL, dtw->snap_toolbox);
     }
 }