Code

NR::Maybe => boost::optional
[inkscape.git] / src / interface.cpp
index f7a2bc47fd799b4ff903dcf6c389c5cd5101df74..0ec73d81bbcb735a39ae502bd5acfa22ee6d03ed 100644 (file)
 #include "event-context.h"
 #include "gradient-drag.h"
 
+// Include Mac OS X menu synchronization on native OSX build
+#ifdef GDK_WINDOWING_QUARTZ
+#include "ige-mac-menu.h"
+#endif
+
 using Inkscape::IO::StringOutputStream;
 using Inkscape::IO::Base64OutputStream;
 
@@ -84,15 +89,15 @@ typedef enum {
 } ui_drop_target_info;
 
 static GtkTargetEntry ui_drop_target_entries [] = {
-    {"text/uri-list", 0, URI_LIST},
-    {"image/svg+xml", 0, SVG_XML_DATA},
-    {"image/svg",     0, SVG_DATA},
-    {"image/png",     0, PNG_DATA},
-    {"image/jpeg",    0, JPEG_DATA},
+    {(gchar *)"text/uri-list",                0, URI_LIST        },
+    {(gchar *)"image/svg+xml",                0, SVG_XML_DATA    },
+    {(gchar *)"image/svg",                    0, SVG_DATA        },
+    {(gchar *)"image/png",                    0, PNG_DATA        },
+    {(gchar *)"image/jpeg",                   0, JPEG_DATA       },
 #if ENABLE_MAGIC_COLORS
-    {"application/x-inkscape-color", 0, APP_X_INKY_COLOR},
+    {(gchar *)"application/x-inkscape-color", 0, APP_X_INKY_COLOR},
 #endif // ENABLE_MAGIC_COLORS
-    {"application/x-color", 0, APP_X_COLOR}
+    {(gchar *)"application/x-color",          0, APP_X_COLOR     }
 };
 
 static GtkTargetEntry *completeDropTargets = 0;
@@ -147,6 +152,9 @@ sp_create_window(SPViewWidget *vw, gboolean editable)
 
     Gtk::Window *win = Inkscape::UI::window_new("", TRUE);
 
+    gtk_container_add(GTK_CONTAINER(win->gobj()), GTK_WIDGET(vw));
+    gtk_widget_show(GTK_WIDGET(vw));
+
     if (editable) {
                g_object_set_data(G_OBJECT(vw), "window", win);
                
@@ -155,16 +163,13 @@ sp_create_window(SPViewWidget *vw, gboolean editable)
                
                desktop_widget->window = win;
 
-        /* fixme: doesn't allow making window any smaller than this */
-        win->set_default_size(640, 480);
-               
         win->set_data("desktop", desktop);
         win->set_data("desktopwidget", desktop_widget);
                
         win->signal_delete_event().connect(sigc::mem_fun(*(SPDesktop*)vw->view, &SPDesktop::onDeleteUI));
                win->signal_window_state_event().connect(sigc::mem_fun(*desktop, &SPDesktop::onWindowStateEvent));
                win->signal_focus_in_event().connect(sigc::mem_fun(*desktop_widget, &SPDesktopWidget::onFocusInEvent));
-               
+       
         gint prefs_geometry = 
             (2==prefs_get_int_attribute("options.savewindowgeometry", "value", 0));
         if (prefs_geometry) {
@@ -212,9 +217,6 @@ sp_create_window(SPViewWidget *vw, gboolean editable)
         gtk_window_set_policy(GTK_WINDOW(win->gobj()), TRUE, TRUE, TRUE);
     }
 
-    gtk_container_add(GTK_CONTAINER(win->gobj()), GTK_WIDGET(vw));
-    gtk_widget_show(GTK_WIDGET(vw));
-
     if ( completeDropTargets == 0 || completeDropTargetsCount == 0 )
     {
         std::vector<gchar*> types;
@@ -945,9 +947,17 @@ sp_ui_main_menubar(Inkscape::UI::View::View *view)
 {
     GtkWidget *mbar = gtk_menu_bar_new();
 
+#ifdef GDK_WINDOWING_QUARTZ
+       ige_mac_menu_set_menu_bar(GTK_MENU_SHELL(mbar));
+#endif
+
     sp_ui_build_dyn_menus(inkscape_get_menus(INKSCAPE), mbar, view);
 
+#ifdef GDK_WINDOWING_QUARTZ
+       return NULL;
+#else
     return mbar;
+#endif
 }
 
 static void leave_group(GtkMenuItem *, SPDesktop *desktop) {
@@ -1170,7 +1180,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
                         Path *livarot_path = Path_for_item(item, true, true);
                         livarot_path->ConvertWithBackData(0.04);
 
-                        NR::Maybe<Path::cut_position> position = get_nearest_position_on_Path(livarot_path, button_doc);
+                        boost::optional<Path::cut_position> position = get_nearest_position_on_Path(livarot_path, button_doc);
                         if (position) {
                             NR::Point nearest = get_point_on_Path(livarot_path, position->piece, position->t);
                             NR::Point delta = nearest - button_doc;
@@ -1179,7 +1189,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
                                 ( !SP_OBJECT_STYLE(item)->stroke.isNone() ?
                                   desktop->current_zoom() *
                                   SP_OBJECT_STYLE (item)->stroke_width.computed *
-                                  sp_item_i2d_affine (item).expansion() * 0.5
+                                  NR::expansion(from_2geom(sp_item_i2d_affine(item))) * 0.5
                                   : 0.0)
                                 + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100); 
 
@@ -1242,7 +1252,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
                 int const saved_pref = prefs_get_int_attribute("options.transform", "pattern", 1);
                 prefs_set_int_attribute("options.transform", "pattern", 1);
                 sp_document_ensure_up_to_date(sp_desktop_document(desktop));
-                NR::Maybe<NR::Rect> sel_bbox = selection->bounds();
+                boost::optional<NR::Rect> sel_bbox = selection->bounds();
                 if (sel_bbox) {
                     NR::Point m( desktop->point() - sel_bbox->midpoint() );
                     sp_selection_move_relative(selection, m);