From dd5683d0c275f8c042a8982d55f8abd3098e00a3 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 26 Dec 2009 17:16:40 -0800 Subject: [PATCH] Parens added for safety and misc whitespace cleanup. --- src/widgets/toolbox.cpp | 843 ++++++++++++++++++++-------------------- 1 file changed, 422 insertions(+), 421 deletions(-) diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f19af295a..02cd0b478 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -926,11 +926,11 @@ sp_commands_toolbox_new() 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_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(); + //GtkWidget *tb = gtk_toolbar_new(); //g_object_set_data(G_OBJECT(tb), "desktop", NULL); gtk_widget_set_sensitive(tb, FALSE); @@ -1904,314 +1904,314 @@ 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); - SPDocument *doc = SP_OBJECT_DOCUMENT(nv); - - 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 saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); - - 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.snapprefs.getSnapToBBoxPath(); - sp_repr_set_boolean(repr, "inkscape:bbox-paths", !v); - break; - case SP_ATTR_INKSCAPE_BBOX_NODES: - v = nv->snap_manager.snapprefs.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.snapprefs.getSnapToItemPath(); - sp_repr_set_boolean(repr, "inkscape:object-paths", !v); - break; - case SP_ATTR_INKSCAPE_OBJECT_NODES: - v = nv->snap_manager.snapprefs.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_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_GRIDS: - v = nv->snap_manager.snapprefs.getSnapToGrids(); - sp_repr_set_boolean(repr, "inkscape:snap-grids", !v); - break; - case SP_ATTR_INKSCAPE_SNAP_TO_GUIDES: - v = nv->snap_manager.snapprefs.getSnapToGuides(); - sp_repr_set_boolean(repr, "inkscape:snap-to-guides", !v); - break; - case SP_ATTR_INKSCAPE_SNAP_PAGE: - v = nv->snap_manager.snapprefs.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;*/ - case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS: - v = nv->snap_manager.snapprefs.getSnapLineMidpoints(); - sp_repr_set_boolean(repr, "inkscape:snap-midpoints", !v); - break; - case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS: - v = nv->snap_manager.snapprefs.getSnapObjectMidpoints(); - sp_repr_set_boolean(repr, "inkscape:snap-object-midpoints", !v); - break; - case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS: - v = nv->snap_manager.snapprefs.getSnapBBoxEdgeMidpoints(); - sp_repr_set_boolean(repr, "inkscape:snap-bbox-edge-midpoints", !v); - break; - case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS: - v = nv->snap_manager.snapprefs.getSnapBBoxMidpoints(); - sp_repr_set_boolean(repr, "inkscape:snap-bbox-midpoints", !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 - doc->setModifiedSinceSave(); - - sp_document_set_undo_sensitive(doc, saved); + 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); + SPDocument *doc = SP_OBJECT_DOCUMENT(nv); + + 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 saved = sp_document_get_undo_sensitive(doc); + sp_document_set_undo_sensitive(doc, false); + + 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.snapprefs.getSnapToBBoxPath(); + sp_repr_set_boolean(repr, "inkscape:bbox-paths", !v); + break; + case SP_ATTR_INKSCAPE_BBOX_NODES: + v = nv->snap_manager.snapprefs.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.snapprefs.getSnapToItemPath(); + sp_repr_set_boolean(repr, "inkscape:object-paths", !v); + break; + case SP_ATTR_INKSCAPE_OBJECT_NODES: + v = nv->snap_manager.snapprefs.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_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_GRIDS: + v = nv->snap_manager.snapprefs.getSnapToGrids(); + sp_repr_set_boolean(repr, "inkscape:snap-grids", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_TO_GUIDES: + v = nv->snap_manager.snapprefs.getSnapToGuides(); + sp_repr_set_boolean(repr, "inkscape:snap-to-guides", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_PAGE: + v = nv->snap_manager.snapprefs.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;*/ + case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS: + v = nv->snap_manager.snapprefs.getSnapLineMidpoints(); + sp_repr_set_boolean(repr, "inkscape:snap-midpoints", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS: + v = nv->snap_manager.snapprefs.getSnapObjectMidpoints(); + sp_repr_set_boolean(repr, "inkscape:snap-object-midpoints", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS: + v = nv->snap_manager.snapprefs.getSnapBBoxEdgeMidpoints(); + sp_repr_set_boolean(repr, "inkscape:snap-bbox-edge-midpoints", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS: + v = nv->snap_manager.snapprefs.getSnapBBoxMidpoints(); + sp_repr_set_boolean(repr, "inkscape:snap-bbox-midpoints", !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 + doc->setModifiedSinceSave(); + + sp_document_set_undo_sensitive(doc, saved); } 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", - _("Snap"), _("Enable snapping"), INKSCAPE_ICON_SNAP, 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", - _("Bounding box"), _("Snap bounding box corners"), INKSCAPE_ICON_SNAP_BOUNDING_BOX, - 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", - _("Bounding box edges"), _("Snap to edges of a bounding box"), - INKSCAPE_ICON_SNAP_BOUNDING_BOX_EDGES, 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", - _("Bounding box corners"), _("Snap to bounding box corners"), - INKSCAPE_ICON_SNAP_BOUNDING_BOX_CORNERS, 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("ToggleSnapToFromBBoxEdgeMidpoints", - _("BBox Edge Midpoints"), _("Snap from and to midpoints of bounding box edges"), - INKSCAPE_ICON_SNAP_BOUNDING_BOX_MIDPOINTS, secondarySize, - SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_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("ToggleSnapToFromBBoxCenters", - _("BBox Centers"), _("Snapping from and to centers of bounding boxes"), - INKSCAPE_ICON_SNAP_BOUNDING_BOX_CENTER, secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_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("ToggleSnapFromNode", - _("Nodes"), _("Snap nodes or handles"), INKSCAPE_ICON_SNAP_NODES, 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", - _("Paths"), _("Snap to paths"), INKSCAPE_ICON_SNAP_NODES_PATH, 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("ToggleSnapToPathIntersections", - _("Path intersections"), _("Snap to path intersections"), - INKSCAPE_ICON_SNAP_NODES_INTERSECTION, 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("ToggleSnapToItemNode", - _("To nodes"), _("Snap to cusp nodes"), INKSCAPE_ICON_SNAP_NODES_CUSP, 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", - _("Smooth nodes"), _("Snap to smooth nodes"), INKSCAPE_ICON_SNAP_NODES_SMOOTH, - 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("ToggleSnapToFromLineMidpoints", - _("Line Midpoints"), _("Snap from and to midpoints of line segments"), - INKSCAPE_ICON_SNAP_NODES_MIDPOINT, secondarySize, SP_ATTR_INKSCAPE_SNAP_LINE_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("ToggleSnapToFromObjectCenters", - _("Object Centers"), _("Snap from and to centers of objects"), - INKSCAPE_ICON_SNAP_NODES_CENTER, secondarySize, SP_ATTR_INKSCAPE_SNAP_OBJECT_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("ToggleSnapToFromRotationCenter", - _("Rotation Centers"), _("Snap from and to an item's rotation center"), - INKSCAPE_ICON_SNAP_NODES_ROTATION_CENTER, 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", - _("Page border"), _("Snap to the page border"), INKSCAPE_ICON_SNAP_PAGE, - 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("ToggleSnapToGrids", - _("Grids"), _("Snap to grids"), INKSCAPE_ICON_GRID_RECTANGULAR, secondarySize, - SP_ATTR_INKSCAPE_SNAP_GRIDS); - - 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("ToggleSnapToGuides", - _("Guides"), _("Snap to guides"), INKSCAPE_ICON_GUIDES, secondarySize, - SP_ATTR_INKSCAPE_SNAP_TO_GUIDES); - - 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", - _("Grid/guide intersections"), _("Snap to intersections of a grid with a guide"), - INKSCAPE_ICON_SNAP_GRID_GUIDE_INTERSECTIONS, 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 ); - }*/ + 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", + _("Snap"), _("Enable snapping"), INKSCAPE_ICON_SNAP, 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", + _("Bounding box"), _("Snap bounding box corners"), INKSCAPE_ICON_SNAP_BOUNDING_BOX, + 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", + _("Bounding box edges"), _("Snap to edges of a bounding box"), + INKSCAPE_ICON_SNAP_BOUNDING_BOX_EDGES, 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", + _("Bounding box corners"), _("Snap to bounding box corners"), + INKSCAPE_ICON_SNAP_BOUNDING_BOX_CORNERS, 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("ToggleSnapToFromBBoxEdgeMidpoints", + _("BBox Edge Midpoints"), _("Snap from and to midpoints of bounding box edges"), + INKSCAPE_ICON_SNAP_BOUNDING_BOX_MIDPOINTS, secondarySize, + SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_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("ToggleSnapToFromBBoxCenters", + _("BBox Centers"), _("Snapping from and to centers of bounding boxes"), + INKSCAPE_ICON_SNAP_BOUNDING_BOX_CENTER, secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_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("ToggleSnapFromNode", + _("Nodes"), _("Snap nodes or handles"), INKSCAPE_ICON_SNAP_NODES, 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", + _("Paths"), _("Snap to paths"), INKSCAPE_ICON_SNAP_NODES_PATH, 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("ToggleSnapToPathIntersections", + _("Path intersections"), _("Snap to path intersections"), + INKSCAPE_ICON_SNAP_NODES_INTERSECTION, 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("ToggleSnapToItemNode", + _("To nodes"), _("Snap to cusp nodes"), INKSCAPE_ICON_SNAP_NODES_CUSP, 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", + _("Smooth nodes"), _("Snap to smooth nodes"), INKSCAPE_ICON_SNAP_NODES_SMOOTH, + 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("ToggleSnapToFromLineMidpoints", + _("Line Midpoints"), _("Snap from and to midpoints of line segments"), + INKSCAPE_ICON_SNAP_NODES_MIDPOINT, secondarySize, SP_ATTR_INKSCAPE_SNAP_LINE_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("ToggleSnapToFromObjectCenters", + _("Object Centers"), _("Snap from and to centers of objects"), + INKSCAPE_ICON_SNAP_NODES_CENTER, secondarySize, SP_ATTR_INKSCAPE_SNAP_OBJECT_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("ToggleSnapToFromRotationCenter", + _("Rotation Centers"), _("Snap from and to an item's rotation center"), + INKSCAPE_ICON_SNAP_NODES_ROTATION_CENTER, 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", + _("Page border"), _("Snap to the page border"), INKSCAPE_ICON_SNAP_PAGE, + 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("ToggleSnapToGrids", + _("Grids"), _("Snap to grids"), INKSCAPE_ICON_GRID_RECTANGULAR, secondarySize, + SP_ATTR_INKSCAPE_SNAP_GRIDS); + + 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("ToggleSnapToGuides", + _("Guides"), _("Snap to guides"), INKSCAPE_ICON_GUIDES, secondarySize, + SP_ATTR_INKSCAPE_SNAP_TO_GUIDES); + + 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", + _("Grid/guide intersections"), _("Snap to intersections of a grid with a guide"), + INKSCAPE_ICON_SNAP_GRID_GUIDE_INTERSECTIONS, 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; @@ -2243,94 +2243,94 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) 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 act4b = mainActions->get_action("ToggleSnapToFromBBoxEdgeMidpoints"); - Glib::RefPtr act4c = mainActions->get_action("ToggleSnapToFromBBoxCenters"); - Glib::RefPtr act5 = mainActions->get_action("ToggleSnapFromNode"); - Glib::RefPtr act6 = mainActions->get_action("ToggleSnapToItemPath"); - Glib::RefPtr act6b = mainActions->get_action("ToggleSnapToPathIntersections"); - Glib::RefPtr act7 = mainActions->get_action("ToggleSnapToItemNode"); - Glib::RefPtr act8 = mainActions->get_action("ToggleSnapToSmoothNodes"); - Glib::RefPtr act9 = mainActions->get_action("ToggleSnapToFromLineMidpoints"); - Glib::RefPtr act10 = mainActions->get_action("ToggleSnapToFromObjectCenters"); - Glib::RefPtr act11 = mainActions->get_action("ToggleSnapToFromRotationCenter"); - Glib::RefPtr act12 = mainActions->get_action("ToggleSnapToPageBorder"); - //Glib::RefPtr act13 = mainActions->get_action("ToggleSnapToGridGuideIntersections"); - Glib::RefPtr act14 = mainActions->get_action("ToggleSnapToGrids"); - Glib::RefPtr act15 = mainActions->get_action("ToggleSnapToGuides"); - - - 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.snapprefs.getSnapToBBoxPath()); - gtk_action_set_sensitive(GTK_ACTION(act3->gobj()), c1 && c2); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4->gobj()), nv->snap_manager.snapprefs.getSnapToBBoxNode()); - gtk_action_set_sensitive(GTK_ACTION(act4->gobj()), c1 && c2); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4b->gobj()), nv->snap_manager.snapprefs.getSnapBBoxEdgeMidpoints()); - gtk_action_set_sensitive(GTK_ACTION(act4b->gobj()), c1 && c2); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4c->gobj()), nv->snap_manager.snapprefs.getSnapBBoxMidpoints()); - gtk_action_set_sensitive(GTK_ACTION(act4c->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); - - bool const c4 = nv->snap_manager.snapprefs.getSnapToItemPath(); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6->gobj()), c4); - gtk_action_set_sensitive(GTK_ACTION(act6->gobj()), c1 && c3); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6b->gobj()), nv->snap_manager.snapprefs.getSnapIntersectionCS()); - gtk_action_set_sensitive(GTK_ACTION(act6b->gobj()), c1 && c3 && c4); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act7->gobj()), nv->snap_manager.snapprefs.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(act9->gobj()), nv->snap_manager.snapprefs.getSnapLineMidpoints()); - gtk_action_set_sensitive(GTK_ACTION(act9->gobj()), c1 && c3); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10->gobj()), nv->snap_manager.snapprefs.getSnapObjectMidpoints()); - 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.snapprefs.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.getSnapToGrids()); - gtk_action_set_sensitive(GTK_ACTION(act14->gobj()), c1); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act15->gobj()), nv->snap_manager.snapprefs.getSnapToGuides()); - gtk_action_set_sensitive(GTK_ACTION(act15->gobj()), c1); - - - g_object_set_data(G_OBJECT(toolbox), "freeze", GINT_TO_POINTER(FALSE)); // unfreeze (see above) + 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 act4b = mainActions->get_action("ToggleSnapToFromBBoxEdgeMidpoints"); + Glib::RefPtr act4c = mainActions->get_action("ToggleSnapToFromBBoxCenters"); + Glib::RefPtr act5 = mainActions->get_action("ToggleSnapFromNode"); + Glib::RefPtr act6 = mainActions->get_action("ToggleSnapToItemPath"); + Glib::RefPtr act6b = mainActions->get_action("ToggleSnapToPathIntersections"); + Glib::RefPtr act7 = mainActions->get_action("ToggleSnapToItemNode"); + Glib::RefPtr act8 = mainActions->get_action("ToggleSnapToSmoothNodes"); + Glib::RefPtr act9 = mainActions->get_action("ToggleSnapToFromLineMidpoints"); + Glib::RefPtr act10 = mainActions->get_action("ToggleSnapToFromObjectCenters"); + Glib::RefPtr act11 = mainActions->get_action("ToggleSnapToFromRotationCenter"); + Glib::RefPtr act12 = mainActions->get_action("ToggleSnapToPageBorder"); + //Glib::RefPtr act13 = mainActions->get_action("ToggleSnapToGridGuideIntersections"); + Glib::RefPtr act14 = mainActions->get_action("ToggleSnapToGrids"); + Glib::RefPtr act15 = mainActions->get_action("ToggleSnapToGuides"); + + + 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.snapprefs.getSnapToBBoxPath()); + gtk_action_set_sensitive(GTK_ACTION(act3->gobj()), c1 && c2); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4->gobj()), nv->snap_manager.snapprefs.getSnapToBBoxNode()); + gtk_action_set_sensitive(GTK_ACTION(act4->gobj()), c1 && c2); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4b->gobj()), nv->snap_manager.snapprefs.getSnapBBoxEdgeMidpoints()); + gtk_action_set_sensitive(GTK_ACTION(act4b->gobj()), c1 && c2); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4c->gobj()), nv->snap_manager.snapprefs.getSnapBBoxMidpoints()); + gtk_action_set_sensitive(GTK_ACTION(act4c->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); + + bool const c4 = nv->snap_manager.snapprefs.getSnapToItemPath(); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6->gobj()), c4); + gtk_action_set_sensitive(GTK_ACTION(act6->gobj()), c1 && c3); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6b->gobj()), nv->snap_manager.snapprefs.getSnapIntersectionCS()); + gtk_action_set_sensitive(GTK_ACTION(act6b->gobj()), c1 && c3 && c4); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act7->gobj()), nv->snap_manager.snapprefs.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(act9->gobj()), nv->snap_manager.snapprefs.getSnapLineMidpoints()); + gtk_action_set_sensitive(GTK_ACTION(act9->gobj()), c1 && c3); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10->gobj()), nv->snap_manager.snapprefs.getSnapObjectMidpoints()); + 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.snapprefs.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.getSnapToGrids()); + gtk_action_set_sensitive(GTK_ACTION(act14->gobj()), c1); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act15->gobj()), nv->snap_manager.snapprefs.getSnapToGuides()); + gtk_action_set_sensitive(GTK_ACTION(act15->gobj()), c1); + + + g_object_set_data(G_OBJECT(toolbox), "freeze", GINT_TO_POINTER(FALSE)); // unfreeze (see above) } void show_aux_toolbox(GtkWidget *toolbox_toplevel) @@ -2412,8 +2412,8 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { if (!IS_NAN(adj->value)) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/tools/shapes/star/proportion", adj->value); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/tools/shapes/star/proportion", adj->value); } } @@ -4000,7 +4000,7 @@ public: } virtual ~PencilToleranceObserver() { if (g_object_get_data(_obj, "prefobserver") == this) { - g_object_set_data(_obj, "prefobserver", NULL); + g_object_set_data(_obj, "prefobserver", NULL); } } virtual void notify(Inkscape::Preferences::Entry const &val) { @@ -4640,9 +4640,9 @@ static void update_presets_list (GObject *tbl) } } } - } + } - if (match) { + 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 ege_select_one_action_set_active(sel, 0); @@ -4771,7 +4771,7 @@ static void sp_dcc_build_presets_list(GObject *tbl) int ii=1; for (std::vector::iterator i = presets.begin(); i != presets.end(); ++i) { - GtkTreeIter iter; + GtkTreeIter iter; Glib::ustring preset_name = prefs->getString(*i + "/name"); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _(preset_name.data()), 1, ii++, -1 ); @@ -4823,12 +4823,12 @@ static void sp_dcc_save_profile (GtkWidget */*widget*/, GObject *tbl) int temp_index = 0; for (std::vector::iterator i = presets.begin(); i != presets.end(); ++i, ++temp_index) { - Glib::ustring name = prefs->getString(*i + "/name"); - if (!name.empty() && profile_name == name) { - new_index = temp_index; + Glib::ustring name = prefs->getString(*i + "/name"); + if (!name.empty() && profile_name == name) { + new_index = temp_index; save_path = *i; break; - } + } } if (new_index == -1) { @@ -6066,9 +6066,9 @@ sp_text_toolbox_selection_changed (Inkscape::Selection */*selection*/, GObject * 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"); + sp_style_read_from_prefs(query, "/tools/text"); - if (g_object_get_data(tbl, "text_style_from_prefs")) { + 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); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@ -6348,8 +6348,7 @@ sp_text_toolbox_anchoring_toggled (GtkRadioButton *button, // move the x of all texts to preserve the same bbox Inkscape::Selection *selection = sp_desktop_selection(desktop); - GSList const *items = selection->itemList(); - for (; items != NULL; items = items->next) { + for (GSList const *items = selection->itemList(); items != NULL; items = items->next) { if (SP_IS_TEXT((SPItem *) items->data)) { SPItem *item = SP_ITEM(items->data); @@ -6357,13 +6356,14 @@ sp_text_toolbox_anchoring_toggled (GtkRadioButton *button, // below, variable names suggest horizontal move, but we check the writing direction // and move in the corresponding axis int axis; - if (writing_mode == SP_CSS_WRITING_MODE_LR_TB || writing_mode == SP_CSS_WRITING_MODE_RL_TB) + if (writing_mode == SP_CSS_WRITING_MODE_LR_TB || writing_mode == SP_CSS_WRITING_MODE_RL_TB) { axis = NR::X; - else + } else { axis = NR::Y; + } Geom::OptRect bbox - = item->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX); + = item->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX); if (!bbox) continue; double width = bbox->dimensions()[axis]; @@ -6412,10 +6412,11 @@ sp_text_toolbox_anchoring_toggled (GtkRadioButton *button, } } Geom::Point XY = SP_TEXT(item)->attributes.firstXY(); - if (axis == NR::X) + if (axis == NR::X) { XY = XY + Geom::Point (move, 0); - else + } else { XY = XY + Geom::Point (0, move); + } SP_TEXT(item)->attributes.setFirstXY(XY); SP_OBJECT(item)->updateRepr(); SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -6461,8 +6462,8 @@ sp_text_toolbox_anchoring_toggled (GtkRadioButton *button, // If querying returned nothing, read the style from the text tool prefs (default style for new texts) if (result_numbers == QUERY_STYLE_NOTHING) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->mergeStyle("/tools/text/style", css); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->mergeStyle("/tools/text/style", css); } sp_style_unref(query); @@ -6565,8 +6566,8 @@ sp_text_toolbox_style_toggled (GtkToggleButton *button, // If querying returned nothing, read the style from the text tool prefs (default style for new texts) if (result_fontspec == QUERY_STYLE_NOTHING) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->mergeStyle("/tools/text/style", css); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->mergeStyle("/tools/text/style", css); } sp_style_unref(query); @@ -6615,7 +6616,7 @@ sp_text_toolbox_orientation_toggled (GtkRadioButton *button, if (result_numbers == QUERY_STYLE_NOTHING) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->mergeStyle("/tools/text/style", css); + prefs->mergeStyle("/tools/text/style", css); } sp_desktop_set_style (desktop, css, true, true); @@ -6727,7 +6728,7 @@ sp_text_toolbox_size_changed (GtkComboBox *cbox, if (result_numbers == QUERY_STYLE_NOTHING) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->mergeStyle("/tools/text/style", css); + prefs->mergeStyle("/tools/text/style", css); } sp_style_unref(query); -- 2.30.2