From: dvlierop2 Date: Sat, 10 Jan 2009 22:21:59 +0000 (+0000) Subject: Added a new toolbar with snapping controls X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9b9200009d4fe5063f0c2a6a3f9b1cd534352014;p=inkscape.git Added a new toolbar with snapping controls --- diff --git a/share/icons/icons.svg b/share/icons/icons.svg index 527bcb991..297e9aa1d 100644 --- a/share/icons/icons.svg +++ b/share/icons/icons.svg @@ -1,6 +1,7 @@ - + + @@ -646,9 +647,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -670,7 +727,7 @@ http://www.inkscape.org/ Inkscape Developers -Icon Sheet + @@ -778,14 +835,14 @@ http://www.inkscape.org/ - - + + - - + + @@ -793,9 +850,9 @@ http://www.inkscape.org/ - + - + @@ -902,10 +959,10 @@ http://www.inkscape.org/ - + - + @@ -1130,8 +1187,8 @@ http://www.inkscape.org/ - - + + @@ -1235,7 +1292,7 @@ http://www.inkscape.org/ - + @@ -1244,7 +1301,7 @@ http://www.inkscape.org/ - + @@ -1370,7 +1427,7 @@ http://www.inkscape.org/ - + @@ -1492,18 +1549,18 @@ http://www.inkscape.org/ - + - - + + - + - + @@ -1535,7 +1592,7 @@ http://www.inkscape.org/ - + @@ -2115,13 +2172,13 @@ http://www.inkscape.org/ - - - - - - - + + + + + + + @@ -2227,9 +2284,9 @@ http://www.inkscape.org/ - + - + @@ -2241,8 +2298,8 @@ http://www.inkscape.org/ - - + + @@ -2421,8 +2478,8 @@ http://www.inkscape.org/ - - + + @@ -2588,7 +2645,7 @@ http://www.inkscape.org/ - + @@ -2596,8 +2653,8 @@ http://www.inkscape.org/ - - + + @@ -2614,7 +2671,7 @@ http://www.inkscape.org/ - + @@ -2624,11 +2681,11 @@ http://www.inkscape.org/ - + - + @@ -2740,7 +2797,7 @@ http://www.inkscape.org/ - + @@ -2850,7 +2907,7 @@ http://www.inkscape.org/ - + @@ -2960,7 +3017,7 @@ http://www.inkscape.org/ - + @@ -2996,7 +3053,7 @@ http://www.inkscape.org/ - + @@ -3018,7 +3075,7 @@ http://www.inkscape.org/ - + @@ -3046,7 +3103,7 @@ http://www.inkscape.org/ - + @@ -3102,45 +3159,45 @@ http://www.inkscape.org/ - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3148,4 +3205,89 @@ http://www.inkscape.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/share/keys/default.xml b/share/keys/default.xml index c52e45608..0fa71c1e1 100644 --- a/share/keys/default.xml +++ b/share/keys/default.xml @@ -238,8 +238,8 @@ override) the bindings in the main default.xml. - - + + diff --git a/share/keys/inkscape.xml b/share/keys/inkscape.xml index e5ef7d430..49423c0aa 100644 --- a/share/keys/inkscape.xml +++ b/share/keys/inkscape.xml @@ -235,8 +235,8 @@ override) the bindings in the main default.xml. - - + + diff --git a/src/desktop.cpp b/src/desktop.cpp index 8b60291ef..85df3af04 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -869,7 +869,7 @@ SPDesktop::next_zoom() \param enable Whether we're going in or out of quick zoom */ -void +void SPDesktop::zoom_quick (bool enable) { if (enable == _quick_zoom_enabled) { @@ -940,7 +940,7 @@ SPDesktop::zoom_quick (bool enable) if (d && d->area() * 2.0 < _quick_zoom_stored_area.area()) { set_display_area(*d, 10); zoomed = true; - } + } } if (!zoomed) { @@ -1325,7 +1325,7 @@ SPDesktop::shutdown() bool SPDesktop::onDeleteUI (GdkEventAny*) { - if(shutdown()) + if(shutdown()) return true; destroyWidget(); @@ -1448,7 +1448,7 @@ void SPDesktop::showGrids(bool show, bool dirty_document) } } -void SPDesktop::toggleSnapping() +void SPDesktop::toggleSnapGlobal() { bool v = namedview->snap_manager.snapprefs.getSnapEnabledGlobally(); Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); diff --git a/src/desktop.h b/src/desktop.h index b55d9da01..50041543c 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -289,7 +289,7 @@ struct SPDesktop : public Inkscape::UI::View::View void toggleColorProfAdjust(); void toggleGrids(); - void toggleSnapping(); + void toggleSnapGlobal(); bool gridsEnabled() { return grids_visible; } void showGrids(bool show, bool dirty_document = true); diff --git a/src/ink-action.cpp b/src/ink-action.cpp index acb65d131..7bcb297d3 100644 --- a/src/ink-action.cpp +++ b/src/ink-action.cpp @@ -15,8 +15,6 @@ #include "widgets/button.h" #include "widgets/icon.h" - - static void ink_action_class_init( InkActionClass* klass ); static void ink_action_init( InkAction* action ); static void ink_action_finalize( GObject* obj ); @@ -354,7 +352,8 @@ InkToggleAction* ink_toggle_action_new( const gchar *name, const gchar *label, const gchar *tooltip, const gchar *inkId, - Inkscape::IconSize size ) + Inkscape::IconSize size, + SPAttributeEnum attr) { GObject* obj = (GObject*)g_object_new( INK_TOGGLE_ACTION_TYPE, "name", name, @@ -362,8 +361,10 @@ InkToggleAction* ink_toggle_action_new( const gchar *name, "tooltip", tooltip, "iconId", inkId, "iconSize", Inkscape::getRegisteredIconSize(size), + //"SP_ATTR_INKSCAPE", attr, // Why doesn't this work and do I need to use g_object_set_data below? NULL ); + g_object_set_data(obj, "SP_ATTR_INKSCAPE", GINT_TO_POINTER(attr)); InkToggleAction* action = INK_TOGGLE_ACTION( obj ); return action; diff --git a/src/ink-action.h b/src/ink-action.h index ed3c92511..7b48d40af 100644 --- a/src/ink-action.h +++ b/src/ink-action.h @@ -8,6 +8,7 @@ #include #include #include "icon-size.h" +#include "attributes.h" /* Equivalent to GTK Actions of the same type, but can support Inkscape SVG icons */ @@ -78,7 +79,8 @@ InkToggleAction* ink_toggle_action_new( const gchar *name, const gchar *label, const gchar *tooltip, const gchar *inkId, - Inkscape::IconSize size ); + Inkscape::IconSize size, + SPAttributeEnum attr = SP_ATTR_INVALID); /* --------------------------------------------------------------- */ diff --git a/src/interface.cpp b/src/interface.cpp index 2242e6224..b14e14c60 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -130,7 +130,7 @@ static void sp_ui_drag_leave( GtkWidget *widget, static void sp_ui_menu_item_set_sensitive(SPAction *action, unsigned int sensitive, void *data); -static void sp_ui_menu_item_set_name(SPAction *action, +static void sp_ui_menu_item_set_name(SPAction *action, Glib::ustring name, void *data); static void sp_recent_open(GtkRecentChooser *, gpointer); @@ -159,21 +159,21 @@ sp_create_window(SPViewWidget *vw, gboolean editable) if (editable) { g_object_set_data(G_OBJECT(vw), "window", win); - + SPDesktopWidget *desktop_widget = reinterpret_cast(vw); SPDesktop* desktop = desktop_widget->desktop; - + desktop_widget->window = win; 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)); - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint prefs_geometry = + gint prefs_geometry = (2==prefs->getInt("/options/savewindowgeometry/value", 0)); if (prefs_geometry) { gint pw = prefs->getInt("/desktop/geometry/width", -1); @@ -827,6 +827,8 @@ sp_ui_checkboxes_menus(GtkMenu *m, Inkscape::UI::View::View *view) // checkitem_toggled, checkitem_update, 0); sp_ui_menu_append_check_item_from_verb(m, view, _("Commands Bar"), _("Show or hide the Commands bar (under the menu)"), "commands", checkitem_toggled, checkitem_update, 0); + sp_ui_menu_append_check_item_from_verb(m, view, _("Snap controls Bar"), _("Show or hide the snapping controls"), "snaptoolbox", + checkitem_toggled, checkitem_update, 0); sp_ui_menu_append_check_item_from_verb(m, view, _("Tool Controls Bar"), _("Show or hide the Tool Controls bar"), "toppanel", checkitem_toggled, checkitem_update, 0); sp_ui_menu_append_check_item_from_verb(m, view, _("_Toolbox"), _("Show or hide the main toolbox (on the left)"), "toolbox", @@ -924,7 +926,7 @@ sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI: // sort most recently used documents first to preserve previous behavior gtk_recent_chooser_set_sort_type(GTK_RECENT_CHOOSER(recent_menu), GTK_RECENT_SORT_MRU); g_signal_connect(G_OBJECT(recent_menu), "item-activated", G_CALLBACK(sp_recent_open), (gpointer) NULL); - + // add filter to only open files added by Inkscape GtkRecentFilter *inkscape_only_filter = gtk_recent_filter_new(); gtk_recent_filter_add_application(inkscape_only_filter, g_get_prgname()); @@ -932,7 +934,7 @@ sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI: GtkWidget *recent_item = gtk_menu_item_new_with_mnemonic(_("Open _Recent")); gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent_item), recent_menu); - + gtk_menu_append(GTK_MENU(menu), GTK_WIDGET(recent_item)); continue; } @@ -1129,7 +1131,7 @@ sp_ui_drag_data_received(GtkWidget *widget, sp_desktop_apply_css_recursive( item, css, true ); item->updateRepr(); - sp_document_done( doc , SP_VERB_NONE, + sp_document_done( doc , SP_VERB_NONE, _("Drop color")); if ( srgbProf ) { @@ -1183,7 +1185,7 @@ sp_ui_drag_data_received(GtkWidget *widget, if (!consumed && item) { bool fillnotstroke = (drag_context->action != GDK_ACTION_MOVE); - if (fillnotstroke && + if (fillnotstroke && (SP_IS_SHAPE(item) || SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item))) { Path *livarot_path = Path_for_item(item, true, true); livarot_path->ConvertWithBackData(0.04); @@ -1200,7 +1202,7 @@ sp_ui_drag_data_received(GtkWidget *widget, SP_OBJECT_STYLE (item)->stroke_width.computed * to_2geom(sp_item_i2d_affine(item)).descrim() * 0.5 : 0.0) - + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); + + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); if (Geom::L2 (delta) < stroke_tolerance) { fillnotstroke = false; @@ -1215,7 +1217,7 @@ sp_ui_drag_data_received(GtkWidget *widget, sp_desktop_apply_css_recursive( item, css, true ); item->updateRepr(); - sp_document_done( doc , SP_VERB_NONE, + sp_document_done( doc , SP_VERB_NONE, _("Drop color")); } } @@ -1271,7 +1273,7 @@ sp_ui_drag_data_received(GtkWidget *widget, } Inkscape::GC::release(newgroup); - sp_document_done(doc, SP_VERB_NONE, + sp_document_done(doc, SP_VERB_NONE, _("Drop SVG")); break; } @@ -1329,7 +1331,7 @@ sp_ui_drag_data_received(GtkWidget *widget, desktop->currentLayer()->appendChildRepr(newImage); Inkscape::GC::release(newImage); - sp_document_done( doc , SP_VERB_NONE, + sp_document_done( doc , SP_VERB_NONE, _("Drop bitmap image")); break; } @@ -1466,7 +1468,7 @@ sp_ui_menu_item_set_name(SPAction */*action*/, Glib::ustring name, void *data) gtk_label_set_markup_with_mnemonic(GTK_LABEL (child), name.c_str()); } else if (GTK_IS_HBOX(child)) { gtk_label_set_markup_with_mnemonic( - GTK_LABEL (gtk_container_get_children(GTK_CONTAINER (child))->data), + GTK_LABEL (gtk_container_get_children(GTK_CONTAINER (child))->data), name.c_str()); }//else sp_ui_menu_append_item_from_verb has been modified and can set //a menu item in yet another way... diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 86ffa8e21..c31ff63cd 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -113,7 +113,7 @@ static char const menus_skeleton[] = " \n" " \n" " \n" -" \n" +" \n" " \n" " \n" " \n" diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 1c8287fe0..1d17613c6 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -10,6 +10,7 @@ static char const preferences_skeleton[] = " \n" " \n" " \n" +" \n" " \n" " \n" " \n" @@ -20,6 +21,7 @@ static char const preferences_skeleton[] = " \n" " \n" " \n" +" \n" " \n" " \n" " \n" @@ -30,6 +32,7 @@ static char const preferences_skeleton[] = " \n" " \n" " \n" +" \n" " \n" " \n" " \n" @@ -248,7 +251,7 @@ static char const preferences_skeleton[] = " \n" " \n" " \n" -" \n" +" \n" " \n" " \n" " \n" diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 9f025120e..ce73888ed 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -1074,7 +1074,7 @@ static void sp_shape_snappoints(SPItem const *item, SnapPointsIter p, Inkscape:: Geom::Matrix const i2d (sp_item_i2d_affine (item)); for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - *p = from_2geom(path_it->initialPoint() * i2d); + *p = path_it->initialPoint() * i2d; Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve @@ -1090,13 +1090,13 @@ static void sp_shape_snappoints(SPItem const *item, SnapPointsIter p, Inkscape:: // Depending on the snapping preferences, either add only cusp nodes, or add add both cusp and smooth nodes if (snapprefs->getSnapSmoothNodes() || nodetype == Geom::NODE_NONE || nodetype == Geom::NODE_CUSP) { - *p = from_2geom(curve_it1->finalPoint() * i2d); + *p = curve_it1->finalPoint() * i2d; } // Consider midpoints of line segments for snapping if (snapprefs->getSnapMidpoints()) { - if (Geom::LineSegment const* line_segment = dynamic_cast(&(*curve_it1))) { - *p = from_2geom(Geom::middle_point(*line_segment) * i2d); + if (Geom::LineSegment const* line_segment = dynamic_cast(&(*curve_it1))) { + *p = Geom::middle_point(*line_segment) * i2d; } } @@ -1111,7 +1111,7 @@ static void sp_shape_snappoints(SPItem const *item, SnapPointsIter p, Inkscape:: if (cs.size() > 0) { // There might be multiple intersections... for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); i++) { Geom::Point p_ix = (*path_it).pointAt((*i).ta); - *p = from_2geom(p_ix * i2d); + *p = p_ix * i2d; } } } diff --git a/src/verbs.cpp b/src/verbs.cpp index c84a17da6..262ec4884 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -629,11 +629,11 @@ Verb::sensitive(SPDocument *in_doc, bool in_sensitive) return; } -/** \brief Accessor to get the tooltip for verb as localised string */ +/** \brief Accessor to get the tooltip for verb as localised string */ gchar const * -Verb::get_tip (void) +Verb::get_tip (void) { - return _(_tip); + return _(_tip); } void @@ -1244,7 +1244,7 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/) sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_DUPLICATE, _("Duplicate layer")); - + // TRANSLATORS: this means "The layer has been duplicated." dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Duplicated layer.")); } else { @@ -1697,8 +1697,8 @@ ZoomVerb::perform(SPAction *action, void *data, void */*pdata*/) sp_namedview_toggle_guides(doc, repr); break; case SP_VERB_TOGGLE_SNAPPING: - dt->toggleSnapping(); - break; + dt->toggleSnapGlobal(); + break; case SP_VERB_TOGGLE_GRID: dt->toggleGrids(); break; @@ -2565,7 +2565,7 @@ Verb *Verb::_base_verbs[] = { new ZoomVerb(SP_VERB_TOGGLE_SCROLLBARS, "ToggleScrollbars", N_("Scroll_bars"), N_("Show or hide the canvas scrollbars"), "scrollbars"), new ZoomVerb(SP_VERB_TOGGLE_GRID, "ToggleGrid", N_("_Grid"), N_("Show or hide the grid"), "grid"), new ZoomVerb(SP_VERB_TOGGLE_GUIDES, "ToggleGuides", N_("G_uides"), N_("Show or hide guides (drag from a ruler to create a guide)"), "guides"), - new ZoomVerb(SP_VERB_TOGGLE_SNAPPING, "ToggleSnapping", N_("Snap"), N_("Toggle snapping on or off"), NULL), + new ZoomVerb(SP_VERB_TOGGLE_SNAPPING, "ToggleSnapGlobal", N_("Snap"), N_("Toggle snapping on or off"), NULL), new ZoomVerb(SP_VERB_ZOOM_NEXT, "ZoomNext", N_("Nex_t Zoom"), N_("Next zoom (from the history of zooms)"), "zoom_next"), new ZoomVerb(SP_VERB_ZOOM_PREV, "ZoomPrev", N_("Pre_vious Zoom"), N_("Previous zoom (from the history of zooms)"), diff --git a/src/verbs.h b/src/verbs.h index 2524aefef..28812dde6 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -38,7 +38,7 @@ enum { SP_VERB_FILE_REVERT, /**< Revert this file to its original state. */ SP_VERB_FILE_SAVE, /**< Save the current file with its saved filename */ SP_VERB_FILE_SAVE_AS, /**< Save the current file with a new filename */ - SP_VERB_FILE_SAVE_A_COPY, /**< Save a copy of the current file */ + SP_VERB_FILE_SAVE_A_COPY, /**< Save a copy of the current file */ SP_VERB_FILE_PRINT, SP_VERB_FILE_VACUUM, SP_VERB_FILE_PRINT_PREVIEW, diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index c80c1b4e7..a64d53bb6 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -48,6 +48,7 @@ #include "widgets/spw-utilities.h" #include "widgets/spinbutton-events.h" #include "widgets/layer-selector.h" +#include "widgets/toolbox.h" #include "ui/dialog/dialog-manager.h" #include "ui/widget/dock.h" #include "ui/widget/selected-style.h" @@ -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); @@ -1210,6 +1214,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 { @@ -1345,6 +1355,7 @@ sp_desktop_widget_new (SPNamedView *namedview) 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 +1417,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 +1427,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); } } diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 51c9141de..3c6434efa 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -84,7 +84,7 @@ struct SPDesktopWidget { GtkWidget *hscrollbar, *vscrollbar, *vscrollbar_box; - GtkWidget *tool_toolbox, *aux_toolbox, *commands_toolbox; + GtkWidget *tool_toolbox, *aux_toolbox, *commands_toolbox, *snap_toolbox; /* Rulers */ GtkWidget *hruler, *vruler; diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index e6929fcff..171fb00cf 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -66,7 +66,7 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) using Geom::Y; if ( sel && !sel->isEmpty() ) { int prefs_bbox = prefs->getInt("/tools/bounding_box", 0); - SPItem::BBoxType bbox_type = (prefs_bbox ==0)? + SPItem::BBoxType bbox_type = (prefs_bbox ==0)? SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; Geom::OptRect const bbox(sel->bounds(bbox_type)); if ( bbox ) { @@ -157,7 +157,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) sp_document_ensure_up_to_date (document); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getInt("/tools/bounding_box"); - SPItem::BBoxType bbox_type = (prefs_bbox ==0)? + SPItem::BBoxType bbox_type = (prefs_bbox ==0)? SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; Geom::OptRect bbox = selection->bounds(bbox_type); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index c2e80db78..4b3ea042f 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -475,7 +475,6 @@ static void update_aux_toolbox (SPDesktop *desktop, SPEventContext *eventcontext static void setup_commands_toolbox (GtkWidget *toolbox, SPDesktop *desktop); static void update_commands_toolbox (SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox); - GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick( GtkWidget *t, Inkscape::IconSize size, SPButtonType type, Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb, Inkscape::UI::View::View *view, GtkTooltips *tt); @@ -897,6 +896,34 @@ sp_commands_toolbox_new() return hb; } +GtkWidget * +sp_snap_toolbox_new() +{ + GtkWidget *tb = gtk_vbox_new(FALSE, 0); + gtk_box_set_spacing(GTK_BOX(tb), AUX_SPACING); + g_object_set_data(G_OBJECT(tb), "desktop", NULL); + + //GtkWidget *tb = gtk_toolbar_new(); + //g_object_set_data(G_OBJECT(tb), "desktop", NULL); + + gtk_widget_set_sensitive(tb, FALSE); + + GtkWidget *hb = gtk_handle_box_new(); + gtk_handle_box_set_handle_position(GTK_HANDLE_BOX(hb), GTK_POS_LEFT); + gtk_handle_box_set_shadow_type(GTK_HANDLE_BOX(hb), GTK_SHADOW_OUT); + gtk_handle_box_set_snap_edge(GTK_HANDLE_BOX(hb), GTK_POS_LEFT); + + gtk_container_add(GTK_CONTAINER(hb), tb); + gtk_widget_show(GTK_WIDGET(tb)); + + sigc::connection* conn = new sigc::connection; + g_object_set_data(G_OBJECT(hb), "event_context_connection", conn); + + g_signal_connect(G_OBJECT(hb), "child_detached", G_CALLBACK(handlebox_detached), static_cast(0)); + g_signal_connect(G_OBJECT(hb), "child_attached", G_CALLBACK(handlebox_attached), static_cast(0)); + + return hb; +} static EgeAdjustmentAction * create_adjustment_action( gchar const *name, gchar const *label, gchar const *shortLabel, gchar const *tooltip, @@ -1547,6 +1574,18 @@ sp_commands_toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop) "event_context_connection"))); } +void +sp_snap_toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop) +{ + toolbox_set_desktop(toolbox, + desktop, + setup_snap_toolbox, + update_snap_toolbox, + static_cast(g_object_get_data(G_OBJECT(toolbox), + "event_context_connection"))); +} + + static void toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop, SetupFunction setup_func, UpdateFunction update_func, sigc::connection *conn) { @@ -1709,12 +1748,12 @@ setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop) g_free( tmp ); tmp = 0; - Inkscape::IconSize toolboxSize = prefToSize("/toolbox/small"); if ( prefs->getBool( "/toolbox/icononly", true) ) { gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS ); } - gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast(toolboxSize) ); + Inkscape::IconSize toolboxSize = prefToSize("/toolbox/small"); + gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast(toolboxSize) ); gtk_table_attach( GTK_TABLE(holder), toolBar, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0 ); @@ -1834,6 +1873,383 @@ update_commands_toolbox(SPDesktop */*desktop*/, SPEventContext */*eventcontext*/ { } +void toggle_snap_callback (GtkToggleAction *act, gpointer data) { //data points to the toolbox + + if (g_object_get_data(G_OBJECT(data), "freeze" )) { + return; + } + + gpointer ptr = g_object_get_data(G_OBJECT(data), "desktop"); + g_assert(ptr != NULL); + + SPDesktop *dt = reinterpret_cast(ptr); + SPNamedView *nv = sp_desktop_namedview(dt); + + if (dt == NULL || nv == NULL) { + g_warning("No desktop or namedview specified (in toggle_snap_callback)!"); + return; + } + + Inkscape::XML::Node *repr = SP_OBJECT_REPR(nv); + + if (repr == NULL) { + g_warning("This namedview doesn't have a xml representation attached!"); + return; + } + + bool v = false; + SPAttributeEnum attr = (SPAttributeEnum) GPOINTER_TO_INT(g_object_get_data(G_OBJECT(act), "SP_ATTR_INKSCAPE")); + + switch (attr) { + case SP_ATTR_INKSCAPE_SNAP_GLOBAL: + dt->toggleSnapGlobal(); + break; + case SP_ATTR_INKSCAPE_SNAP_BBOX: + v = nv->snap_manager.snapprefs.getSnapModeBBox(); + sp_repr_set_boolean(repr, "inkscape:snap-bbox", !v); + break; + case SP_ATTR_INKSCAPE_BBOX_PATHS: + v = nv->snap_manager.object.getSnapToBBoxPath(); + sp_repr_set_boolean(repr, "inkscape:bbox-paths", !v); + break; + case SP_ATTR_INKSCAPE_BBOX_NODES: + v = nv->snap_manager.object.getSnapToBBoxNode(); + sp_repr_set_boolean(repr, "inkscape:bbox-nodes", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_NODES: + v = nv->snap_manager.snapprefs.getSnapModeNode(); + sp_repr_set_boolean(repr, "inkscape:snap-nodes", !v); + break; + case SP_ATTR_INKSCAPE_OBJECT_PATHS: + v = nv->snap_manager.object.getSnapToItemPath(); + sp_repr_set_boolean(repr, "inkscape:object-paths", !v); + break; + case SP_ATTR_INKSCAPE_OBJECT_NODES: + v = nv->snap_manager.object.getSnapToItemNode(); + sp_repr_set_boolean(repr, "inkscape:object-nodes", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES: + v = nv->snap_manager.snapprefs.getSnapSmoothNodes(); + sp_repr_set_boolean(repr, "inkscape:snap-smooth-nodes", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_MIDPOINTS: + v = nv->snap_manager.snapprefs.getSnapMidpoints(); + sp_repr_set_boolean(repr, "inkscape:snap-midpoints", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS: + v = nv->snap_manager.snapprefs.getSnapIntersectionCS(); + sp_repr_set_boolean(repr, "inkscape:snap-intersection-paths", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_CENTER: + v = nv->snap_manager.snapprefs.getIncludeItemCenter(); + sp_repr_set_boolean(repr, "inkscape:snap-center", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_PAGE: + v = nv->snap_manager.object.getSnapToPageBorder(); + sp_repr_set_boolean(repr, "inkscape:snap-page", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE: + v = nv->snap_manager.snapprefs.getSnapIntersectionGG(); + sp_repr_set_boolean(repr, "inkscape:snap-intersection-grid-guide", !v); + break; + default: + g_warning("toggle_snap_callback has been called with an ID for which no action has been defined"); + break; + } + + // The snapping preferences are stored in the document, and therefore toggling makes the document dirty + SPDocument *doc = SP_OBJECT_DOCUMENT(nv); + doc->setModifiedSinceSave(); +} + +void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::RefPtr mainActions = create_or_fetch_actions(desktop); + + gchar const * descr = + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; + + Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1); + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapGlobal", // "name" + _("Snap"), // "label" + _("Toggle all snapping"), // "tooltip" + "toggle_snap_global", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_SNAP_GLOBAL); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromBBoxCorner",// "name" + _("Bounding box"), // "label" + _("Toggle snapping of bounding box corners"), // "tooltip" + "toggle_snap_bbox", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_SNAP_BBOX); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapToBBoxPath", // "name" + _("Bounding box edges"), // "label" + _("Toggle snapping to edges of a bounding box"), // "tooltip" + "toggle_snap_to_bbox_path", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_BBOX_PATHS); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapToBBoxNode", // "name" + _("Bounding box corners"), // "label" + _("Toggle snapping to bounding box corners"), // "tooltip" + "toggle_snap_to_bbox_node", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_BBOX_NODES); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromNode", // "name" + _("Nodes"), // "label" + _("Toggle snapping of nodes"), // "tooltip" + "toggle_snap_nodes", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_SNAP_NODES); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapToItemPath", // "name" + _("Paths"), // "label" + _("Toggle snapping to paths"), // "tooltip" + "toggle_snap_to_paths", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_OBJECT_PATHS); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapToItemNode", // "name" + _("To nodes"), // "label" + _("Toggle snapping to nodes"), // "tooltip" + "toggle_snap_to_nodes", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_OBJECT_NODES); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapToSmoothNodes", // "name" + _("Smooth nodes"), // "label" + _("Toggle snapping to smooth nodes"), // "tooltip" + "toggle_snap_to_smooth_nodes", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromMidpoints", // "name" + _("Midpoints"), // "label" + _("Toggle snapping from and to midpoints of line segments and bounding boxes"), // "tooltip" + "toggle_snap_to_midpoints", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_SNAP_MIDPOINTS); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapToPathIntersections", // "name" + _("Path intersections"), // "label" + _("Toggle snapping to path intersections"), // "tooltip" + "toggle_snap_to_path_intersections", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromCenter",// "name" + _("Center"), // "label" + _("Toggle snapping from and to an item's rotation center"), // "tooltip" + "toggle_snap_center", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_SNAP_CENTER); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapToPageBorder", // "name" + _("Page border"), // "label" + _("Toggle snapping to the page border"), // "tooltip" + "toggle_snap_page_border", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_SNAP_PAGE); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGridGuideIntersections", // "name" + _("Grid/guide intersections"), // "label" + _("Toggle snapping to intersections of a grid with a guide"), // "tooltip" + "toggle_snap_grid_guide_intersections", // "iconId" + secondarySize, + SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + GtkUIManager* mgr = gtk_ui_manager_new(); + GError* errVal = 0; + + gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 ); + gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal ); + + GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, "/ui/SnapToolbar" ); + if ( prefs->getBool("/toolbox/icononly", true) ) { + gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS ); + } + + Inkscape::IconSize toolboxSize = prefToSize("/toolbox/secondary"); + gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast(toolboxSize) ); + + gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), GTK_ORIENTATION_HORIZONTAL); + gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolBar), TRUE); + + g_object_set_data(G_OBJECT(toolBar), "desktop", NULL); + + GtkWidget* child = gtk_bin_get_child(GTK_BIN(toolbox)); + if ( child ) { + gtk_container_remove( GTK_CONTAINER(toolbox), child ); + } + + gtk_container_add( GTK_CONTAINER(toolbox), toolBar ); + +} + +void update_snap_toolbox(SPDesktop *desktop, SPEventContext */*eventcontext*/, GtkWidget *toolbox) +{ + g_assert(desktop != NULL); + g_assert(toolbox != NULL); + + SPNamedView *nv = sp_desktop_namedview(desktop); + if (nv == NULL) { + g_warning("Namedview cannot be retrieved (in update_snap_toolbox)!"); + return; + } + + Glib::RefPtr mainActions = create_or_fetch_actions(desktop); + + Glib::RefPtr act1 = mainActions->get_action("ToggleSnapGlobal"); + Glib::RefPtr act2 = mainActions->get_action("ToggleSnapFromBBoxCorner"); + Glib::RefPtr act3 = mainActions->get_action("ToggleSnapToBBoxPath"); + Glib::RefPtr act4 = mainActions->get_action("ToggleSnapToBBoxNode"); + Glib::RefPtr act5 = mainActions->get_action("ToggleSnapFromNode"); + Glib::RefPtr act6 = mainActions->get_action("ToggleSnapToItemPath"); + Glib::RefPtr act7 = mainActions->get_action("ToggleSnapToItemNode"); + Glib::RefPtr act8 = mainActions->get_action("ToggleSnapToSmoothNodes"); + Glib::RefPtr act10 = mainActions->get_action("ToggleSnapToPathIntersections"); + Glib::RefPtr act11 = mainActions->get_action("ToggleSnapToFromCenter"); + Glib::RefPtr act12 = mainActions->get_action("ToggleSnapToPageBorder"); + Glib::RefPtr act13 = mainActions->get_action("ToggleSnapToGridGuideIntersections"); + Glib::RefPtr act14 = mainActions->get_action("ToggleSnapToFromMidpoints"); + + + if (!act1) { + return; // The snap actions haven't been defined yet (might be the case during startup) + } + + // The ..._set_active calls below will toggle the buttons, but this shouldn't lead to + // changes in our document because we're only updating the UI; + // Setting the "freeze" parameter to true will block the code in toggle_snap_callback() + g_object_set_data(G_OBJECT(toolbox), "freeze", GINT_TO_POINTER(TRUE)); + + bool const c1 = nv->snap_manager.snapprefs.getSnapEnabledGlobally(); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act1->gobj()), c1); + + bool const c2 = nv->snap_manager.snapprefs.getSnapModeBBox(); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act2->gobj()), c2); + gtk_action_set_sensitive(GTK_ACTION(act2->gobj()), c1); + + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act3->gobj()), nv->snap_manager.object.getSnapToBBoxPath()); + gtk_action_set_sensitive(GTK_ACTION(act3->gobj()), c1 && c2); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4->gobj()), nv->snap_manager.object.getSnapToBBoxNode()); + gtk_action_set_sensitive(GTK_ACTION(act4->gobj()), c1 && c2); + + bool const c3 = nv->snap_manager.snapprefs.getSnapModeNode(); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act5->gobj()), c3); + gtk_action_set_sensitive(GTK_ACTION(act5->gobj()), c1); + + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6->gobj()), nv->snap_manager.object.getSnapToItemPath()); + gtk_action_set_sensitive(GTK_ACTION(act6->gobj()), c1 && c3); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act7->gobj()), nv->snap_manager.object.getSnapToItemNode()); + gtk_action_set_sensitive(GTK_ACTION(act7->gobj()), c1 && c3); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act8->gobj()), nv->snap_manager.snapprefs.getSnapSmoothNodes()); + gtk_action_set_sensitive(GTK_ACTION(act8->gobj()), c1 && c3); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10->gobj()), nv->snap_manager.snapprefs.getSnapIntersectionCS()); + gtk_action_set_sensitive(GTK_ACTION(act10->gobj()), c1 && c3); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11->gobj()), nv->snap_manager.snapprefs.getIncludeItemCenter()); + gtk_action_set_sensitive(GTK_ACTION(act11->gobj()), c1 && c3); + + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act12->gobj()), nv->snap_manager.object.getSnapToPageBorder()); + gtk_action_set_sensitive(GTK_ACTION(act12->gobj()), c1); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act13->gobj()), nv->snap_manager.snapprefs.getSnapIntersectionGG()); + gtk_action_set_sensitive(GTK_ACTION(act13->gobj()), c1); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act14->gobj()), nv->snap_manager.snapprefs.getSnapMidpoints()); + gtk_action_set_sensitive(GTK_ACTION(act14->gobj()), c1); + + + g_object_set_data(G_OBJECT(toolbox), "freeze", GINT_TO_POINTER(FALSE)); // unfreeze (see above) +} + void show_aux_toolbox(GtkWidget *toolbox_toplevel) { gtk_widget_show(toolbox_toplevel); @@ -3918,7 +4334,7 @@ static void update_presets_list (GObject *tbl) int ege_index = 1; for (std::vector::iterator i = presets.begin(); i != presets.end(); ++i, ++ege_index) { bool match = true; - + std::vector preset = prefs->getAllEntries(*i); for (std::vector::iterator j = preset.begin(); j != preset.end(); ++j) { Glib::ustring entry_name = j->getEntryName(); @@ -3945,7 +4361,7 @@ static void update_presets_list (GObject *tbl) } } } - + if (match) { // newly added item is at the same index as the // save command, so we need to change twice for it to take effect @@ -4068,12 +4484,12 @@ static void sp_dcc_build_presets_list(GObject *tbl) gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("No preset"), 1, 0, -1 ); } - + // iterate over all presets to populate the list Inkscape::Preferences *prefs = Inkscape::Preferences::get(); std::vector presets = prefs->getAllDirs("/tools/calligraphic/preset"); int ii=1; - + for (std::vector::iterator i = presets.begin(); i != presets.end(); ++i) { GtkTreeIter iter; Glib::ustring preset_name = prefs->getString(*i + "/name"); @@ -4118,13 +4534,13 @@ static void sp_dcc_save_profile (GtkWidget */*widget*/, GObject *tbl) } g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE)); - + // If there's a preset with the given name, find it and set save_path appropriately std::vector presets = prefs->getAllDirs("/tools/calligraphic/preset"); int total_presets = presets.size(); int new_index = -1; Glib::ustring save_path; // profile pref path without a trailing slash - + int temp_index = 0; for (std::vector::iterator i = presets.begin(); i != presets.end(); ++i, ++temp_index) { Glib::ustring name = prefs->getString(*i + "/name"); @@ -4196,7 +4612,7 @@ static void sp_ddc_change_profile(EgeSelectOneAction* act, GObject* tbl) { if (!preset_path.empty()) { g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE)); //temporarily block the selector so no one will updadte it while we're reading it - + std::vector preset = prefs->getAllEntries(preset_path); // Shouldn't this be std::map? @@ -5367,9 +5783,9 @@ sp_text_toolbox_selection_changed (Inkscape::Selection */*selection*/, GObject * // If querying returned nothing, read the style from the text tool prefs (default style for new texts) if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING) { // there are no texts in selection, read from prefs - + sp_style_read_from_prefs(query, "/tools/text"); - + if (g_object_get_data(tbl, "text_style_from_prefs")) { // do not reset the toolbar style from prefs if we already did it last time sp_style_unref(query); diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h index a4d6f21a5..4bc417e8f 100644 --- a/src/widgets/toolbox.h +++ b/src/widgets/toolbox.h @@ -29,6 +29,11 @@ void sp_aux_toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop); GtkWidget *sp_commands_toolbox_new (); void sp_commands_toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop); +GtkWidget *sp_snap_toolbox_new (); +void sp_snap_toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop); +void update_snap_toolbox(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox); +void setup_snap_toolbox (GtkWidget *toolbox, SPDesktop *desktop); + void show_aux_toolbox(GtkWidget *toolbox); GtkWidget *sp_toolbox_button_normal_new_from_verb(GtkWidget *t,