X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdialogs%2Fstroke-style.cpp;h=08f3d90317fd5c8c76966f0de65041c8fb059510;hb=6d7d846dbf27d17b82110d99015a85cff809a789;hp=334b01dd1aa1a70676a7bccfac171605236c01e7;hpb=843dd3b4fe0d464b30c1e563da3f713cb463eac7;p=inkscape.git diff --git a/src/dialogs/stroke-style.cpp b/src/dialogs/stroke-style.cpp index 334b01dd1..08f3d9031 100644 --- a/src/dialogs/stroke-style.cpp +++ b/src/dialogs/stroke-style.cpp @@ -73,7 +73,7 @@ static void sp_stroke_style_paint_dragged(SPPaintSelector *psel, SPWidget *spw); static void sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw); static void sp_stroke_style_widget_change_subselection ( Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw ); -static void sp_stroke_style_widget_transientize_callback(Inkscape::Application *inkscape, +static void sp_stroke_style_widget_transientize_callback(Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw ); @@ -83,7 +83,7 @@ static GtkWidget * marker_mid_menu = NULL; static GtkWidget * marker_end_menu = NULL; static SPObject *ink_extract_marker_name(gchar const *n); -static void ink_markers_menu_update(); +static void ink_markers_menu_update(SPWidget* spw); static Inkscape::UI::Cache::SvgPreview svg_preview_cache; @@ -136,13 +136,14 @@ sp_stroke_style_paint_widget_new(void) static void sp_stroke_style_paint_construct(SPWidget *spw, SPPaintSelector *psel) { + (void)psel; #ifdef SP_SS_VERBOSE g_print( "Stroke style widget constructed: inkscape %p repr %p\n", spw->inkscape, spw->repr ); #endif if (spw->inkscape) { sp_stroke_style_paint_update (spw); - } + } } /** @@ -154,6 +155,7 @@ sp_stroke_style_paint_selection_modified ( SPWidget *spw, guint flags, SPPaintSelector *psel) { + (void)selection; if (flags & ( SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG) ) { sp_stroke_style_paint_update(spw); @@ -169,6 +171,7 @@ sp_stroke_style_paint_selection_changed ( SPWidget *spw, Inkscape::Selection *selection, SPPaintSelector *psel ) { + (void)selection; sp_stroke_style_paint_update (spw); } @@ -177,21 +180,14 @@ sp_stroke_style_paint_selection_changed ( SPWidget *spw, * On signal change subselection, invoke an update of the stroke style widget. */ static void -sp_stroke_style_widget_change_subselection ( Inkscape::Application *inkscape, +sp_stroke_style_widget_change_subselection ( Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw ) { + (void)inkscape; sp_stroke_style_paint_update (spw); } -static void -sp_stroke_style_widget_transientize_callback(Inkscape::Application *inkscape, - SPDesktop *desktop, - SPWidget *spw ) -{ - ink_markers_menu_update(); -} - /** * Gets the active stroke style property, then sets the appropriate color, alpha, gradient, * pattern, etc. for the paint-selector. @@ -208,9 +204,9 @@ sp_stroke_style_paint_update (SPWidget *spw) SPPaintSelector *psel = SP_PAINT_SELECTOR(gtk_object_get_data(GTK_OBJECT(spw), "paint-selector")); // create temporary style - SPStyle *query = sp_style_new (); + SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); // query into it - int result = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKE); + int result = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKE); switch (result) { case QUERY_STYLE_NOTHING: @@ -227,14 +223,7 @@ sp_stroke_style_paint_update (SPWidget *spw) SPPaintSelectorMode pselmode = sp_style_determine_paint_selector_mode (query, false); sp_paint_selector_set_mode (psel, pselmode); - if (query->stroke.set && query->stroke.type == SP_PAINT_TYPE_COLOR) { - gfloat d[3]; - sp_color_get_rgb_floatv (&query->stroke.value.color, d); - SPColor color; - sp_color_set_rgb_float (&color, d[0], d[1], d[2]); - sp_paint_selector_set_color_alpha (psel, &color, SP_SCALE24_TO_FLOAT (query->stroke_opacity.value)); - - } else if (query->stroke.set && query->stroke.type == SP_PAINT_TYPE_PAINTSERVER) { + if (query->stroke.set && query->stroke.isPaintserver()) { SPPaintServer *server = SP_STYLE_STROKE_SERVER (query); @@ -258,6 +247,9 @@ sp_stroke_style_paint_update (SPWidget *spw) SPPattern *pat = pattern_getroot (SP_PATTERN (server)); sp_update_pattern_list (psel, pat); } + } else if (query->stroke.set && query->stroke.isColor()) { + sp_paint_selector_set_color_alpha (psel, &query->stroke.value.color, SP_SCALE24_TO_FLOAT (query->stroke_opacity.value)); + } break; } @@ -269,7 +261,7 @@ sp_stroke_style_paint_update (SPWidget *spw) } } - g_free (query); + sp_style_unref(query); gtk_object_set_data(GTK_OBJECT(spw), "update", GINT_TO_POINTER(FALSE)); } @@ -282,6 +274,7 @@ sp_stroke_style_paint_mode_changed( SPPaintSelector *psel, SPPaintSelectorMode mode, SPWidget *spw ) { + (void)mode; if (gtk_object_get_data(GTK_OBJECT(spw), "update")) { return; } @@ -298,7 +291,7 @@ static gchar *undo_label_2 = "stroke:flatcolor:2"; static gchar *undo_label = undo_label_1; /** - * When a drag callback occurs on a paint selector object, if it is a RGB or CMYK + * When a drag callback occurs on a paint selector object, if it is a RGB or CMYK * color mode, then set the stroke opacity to psel's flat color. */ static void @@ -313,7 +306,7 @@ sp_stroke_style_paint_dragged(SPPaintSelector *psel, SPWidget *spw) case SP_PAINT_SELECTOR_MODE_COLOR_CMYK: { sp_paint_selector_set_flat_color (psel, SP_ACTIVE_DESKTOP, "stroke", "stroke-opacity"); - sp_document_maybe_done (sp_desktop_document(SP_ACTIVE_DESKTOP), undo_label, SP_VERB_DIALOG_FILL_STROKE, + sp_document_maybe_done (sp_desktop_document(SP_ACTIVE_DESKTOP), undo_label, SP_VERB_DIALOG_FILL_STROKE, _("Set stroke color")); break; } @@ -363,7 +356,7 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) sp_repr_css_attr_unref(css); - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, + sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, _("Remove stroke")); break; } @@ -372,13 +365,13 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) case SP_PAINT_SELECTOR_MODE_COLOR_CMYK: { sp_paint_selector_set_flat_color (psel, desktop, "stroke", "stroke-opacity"); - sp_document_maybe_done (sp_desktop_document(desktop), undo_label, SP_VERB_DIALOG_FILL_STROKE, + sp_document_maybe_done (sp_desktop_document(desktop), undo_label, SP_VERB_DIALOG_FILL_STROKE, _("Set stroke color")); // on release, toggle undo_label so that the next drag will not be lumped with this one if (undo_label == undo_label_1) undo_label = undo_label_2; - else + else undo_label = undo_label_1; break; @@ -394,22 +387,22 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) if (!vector) { /* No vector in paint selector should mean that we just changed mode */ - SPStyle *query = sp_style_new (); - int result = objects_query_fillstroke ((GSList *) items, query, false); + SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); + int result = objects_query_fillstroke ((GSList *) items, query, false); guint32 common_rgb = 0; if (result == QUERY_STYLE_MULTIPLE_SAME) { - if (query->fill.type != SP_PAINT_TYPE_COLOR) { + if (!query->fill.isColor()) { common_rgb = sp_desktop_get_color(desktop, false); } else { - common_rgb = sp_color_get_rgba32_ualpha(&query->stroke.value.color, 0xff); + common_rgb = query->stroke.value.color.toRGBA32( 0xff ); } vector = sp_document_default_gradient_vector(document, common_rgb); } - g_free (query); + sp_style_unref(query); for (GSList const *i = items; i != NULL; i = i->next) { if (!vector) { - sp_item_set_gradient(SP_ITEM(i->data), + sp_item_set_gradient(SP_ITEM(i->data), sp_gradient_vector_for_object(document, desktop, SP_OBJECT(i->data), false), gradient_type, false); } else { @@ -424,7 +417,7 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) } } - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, + sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, _("Set gradient on stroke")); } break; @@ -453,7 +446,7 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) continue; SPStyle *style = SP_OBJECT_STYLE (selobj); - if (style && style->stroke.type == SP_PAINT_TYPE_PAINTSERVER) { + if (style && style->stroke.isPaintserver()) { SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (selobj); if (SP_IS_PATTERN (server) && pattern_getroot (SP_PATTERN(server)) == pattern) // only if this object's pattern is not rooted in our selected pattern, apply @@ -468,7 +461,7 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) } // end if - sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE, + sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE, _("Set pattern on stroke")); } // end if @@ -478,11 +471,18 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) if (items) { SPCSSAttr *css = sp_repr_css_attr_new (); sp_repr_css_unset_property (css, "stroke"); + sp_repr_css_unset_property (css, "stroke-opacity"); + sp_repr_css_unset_property (css, "stroke-width"); + sp_repr_css_unset_property (css, "stroke-miterlimit"); + sp_repr_css_unset_property (css, "stroke-linejoin"); + sp_repr_css_unset_property (css, "stroke-linecap"); + sp_repr_css_unset_property (css, "stroke-dashoffset"); + sp_repr_css_unset_property (css, "stroke-dasharray"); sp_desktop_set_style (desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE, + sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE, _("Unset stroke")); } break; @@ -567,6 +567,19 @@ sp_stroke_radio_button(GtkWidget *tb, char const *icon, } +static void +sp_stroke_style_widget_transientize_callback(Inkscape::Application *inkscape, + SPDesktop *desktop, + SPWidget *spw ) +{ + (void)inkscape; + (void)desktop; + (void)spw; +// TODO: Either of these will cause crashes sometimes +// sp_stroke_style_line_update( SP_WIDGET(spw), desktop ? sp_desktop_selection(desktop) : NULL); +// ink_markers_menu_update(spw); +} + /** * Creates a copy of the marker named mname, determines its visible and renderable * area in menu_id's bounding box, and then renders it. This allows us to fill in @@ -577,13 +590,16 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, SPDocument *source, SPDocument *sandbox, gchar *menu_id, NRArena const *arena, unsigned visionkey, NRArenaItem *root) { + (void)arena; + (void)visionkey; // Retrieve the marker named 'mname' from the source SVG document SPObject const *marker = source->getObjectById(mname); if (marker == NULL) return NULL; // Create a copy repr of the marker with id="sample" - Inkscape::XML::Node *mrepr = SP_OBJECT_REPR (marker)->duplicate(); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(sandbox); + Inkscape::XML::Node *mrepr = SP_OBJECT_REPR (marker)->duplicate(xml_doc); mrepr->setAttribute("id", "sample"); // Replace the old sample in the sandbox by the new one @@ -609,9 +625,9 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, // Find object's bbox in document NR::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object))); - NR::Rect const dbox = SP_ITEM(object)->invokeBbox(i2doc); + NR::Maybe dbox = SP_ITEM(object)->getBounds(i2doc); - if (dbox.isEmpty()) { + if (!dbox) { return NULL; } @@ -619,11 +635,11 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, double sf = 0.8; GdkPixbuf* pixbuf = NULL; - Glib::ustring key = svg_preview_cache.cache_key(mname, psize); + Glib::ustring key = svg_preview_cache.cache_key(source->uri, mname, psize); pixbuf = svg_preview_cache.get_preview_from_cache(key); if (pixbuf == NULL) { - pixbuf = render_pixbuf(root, sf, dbox, psize); + pixbuf = render_pixbuf(root, sf, *dbox, psize); svg_preview_cache.set_preview_in_cache(key, pixbuf); } @@ -687,6 +703,7 @@ sp_marker_menu_build (GtkWidget *m, GSList *marker_list, SPDocument *source, SPD gtk_widget_show(hb); // generate preview + GtkWidget *prv = sp_marker_prev_new (22, markid, source, sandbox, menu_id, arena, visionkey, root); gtk_widget_show(prv); gtk_box_pack_start(GTK_BOX(hb), prv, FALSE, FALSE, 6); @@ -715,18 +732,11 @@ sp_marker_menu_build (GtkWidget *m, GSList *marker_list, SPDocument *source, SPD static void sp_marker_list_from_doc (GtkWidget *m, SPDocument *current_doc, SPDocument *source, SPDocument *markers_doc, SPDocument *sandbox, gchar *menu_id) { + (void)current_doc; + (void)markers_doc; GSList *ml = ink_marker_list_get(source); GSList *clean_ml = NULL; - // Do this here, outside of loop, to speed up preview generation: - /* Create new arena */ - NRArena const *arena = NRArena::create(); - /* Create ArenaItem and set transform */ - unsigned const visionkey = sp_item_display_key_new(1); -/* - NRArenaItem *root = sp_item_invoke_show( SP_ITEM(SP_DOCUMENT_ROOT (sandbox)), (NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY ); -*/ - for (; ml != NULL; ml = ml->next) { if (!SP_IS_MARKER(ml->data)) continue; @@ -785,7 +795,7 @@ ink_marker_menu_create_menu(GtkWidget *m, gchar *menu_id, SPDocument *doc, SPDoc GtkWidget *i = gtk_menu_item_new(); gtk_widget_show(i); -// g_object_set_data(G_OBJECT(i), "marker", (void *) "none"); + g_object_set_data(G_OBJECT(i), "marker", (void *) "none"); GtkWidget *hb = gtk_hbox_new(FALSE, MARKER_ITEM_MARGIN); gtk_widget_show(hb); @@ -811,7 +821,7 @@ ink_marker_menu_create_menu(GtkWidget *m, gchar *menu_id, SPDocument *doc, SPDoc // suck in from current doc sp_marker_list_from_doc ( m, NULL, doc, markers_doc, sandbox, menu_id ); - + // add separator { GtkWidget *i = gtk_separator_menu_item_new(); @@ -824,6 +834,7 @@ ink_marker_menu_create_menu(GtkWidget *m, gchar *menu_id, SPDocument *doc, SPDoc sp_document_ensure_up_to_date(doc); sp_marker_list_from_doc ( m, doc, markers_doc, NULL, sandbox, menu_id ); } + } @@ -833,6 +844,7 @@ ink_marker_menu_create_menu(GtkWidget *m, gchar *menu_id, SPDocument *doc, SPDoc static GtkWidget * ink_marker_menu( GtkWidget *tbl, gchar *menu_id, SPDocument *sandbox) { + (void)tbl; SPDesktop *desktop = inkscape_active_desktop(); SPDocument *doc = sp_desktop_document(desktop); GtkWidget *mnu = gtk_option_menu_new(); @@ -911,9 +923,14 @@ sp_marker_select(GtkOptionMenu *mnu, GtkWidget *spw) gchar *menu_id = (gchar *) g_object_get_data(G_OBJECT(mnu), "menu_id"); sp_repr_css_set_property(css, menu_id, marker); - Inkscape::Selection *selection = sp_desktop_selection(desktop); - GSList const *items = selection->itemList(); - for (; items != NULL; items = items->next) { + // Also update the marker dropdown menus, so the document's markers + // show up at the top of the menu +// sp_stroke_style_line_update( SP_WIDGET(spw), desktop ? sp_desktop_selection(desktop) : NULL); + ink_markers_menu_update(SP_WIDGET(spw)); + + Inkscape::Selection *selection = sp_desktop_selection(desktop); + GSList const *items = selection->itemList(); + for (; items != NULL; items = items->next) { SPItem *item = (SPItem *) items->data; if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) // can't set marker to rect, until it's converted to using continue; @@ -927,38 +944,69 @@ sp_marker_select(GtkOptionMenu *mnu, GtkWidget *spw) sp_repr_css_attr_unref(css); - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, + sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, _("Set markers")); - // Lastly, also update the marker dropdown menus, so the document's markers - // show up at the top of the menu - ink_markers_menu_update(); }; +static int +ink_marker_menu_get_pos(GtkMenu* mnu, gchar* markname) { + + if (markname == NULL) + markname = (gchar *) g_object_get_data(G_OBJECT(gtk_menu_get_active(mnu)), "marker"); + + if (markname == NULL) + return 0; + + GList *kids = GTK_MENU_SHELL(mnu)->children; + int i = 0; + for (; kids != NULL; kids = kids->next) { + gchar *mark = (gchar *) g_object_get_data(G_OBJECT(kids->data), "marker"); + if ( mark && strcmp(mark, markname) == 0 ) { + break; + } + i++; + } + return i; +} + static void -ink_markers_menu_update() { +ink_markers_menu_update(SPWidget* spw) { SPDesktop *desktop = inkscape_active_desktop(); SPDocument *document = sp_desktop_document(desktop); SPDocument *sandbox = ink_markers_preview_doc (); GtkWidget *m; + int pos; + gtk_signal_handler_block_by_func( GTK_OBJECT(marker_start_menu), GTK_SIGNAL_FUNC(sp_marker_select), spw); + pos = ink_marker_menu_get_pos(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(marker_start_menu))), NULL); m = gtk_menu_new(); gtk_widget_show(m); ink_marker_menu_create_menu(m, "marker-start", document, sandbox); gtk_option_menu_remove_menu(GTK_OPTION_MENU(marker_start_menu)); gtk_option_menu_set_menu(GTK_OPTION_MENU(marker_start_menu), m); + gtk_option_menu_set_history(GTK_OPTION_MENU(marker_start_menu), pos); + gtk_signal_handler_unblock_by_func( GTK_OBJECT(marker_start_menu), GTK_SIGNAL_FUNC(sp_marker_select), spw); + gtk_signal_handler_block_by_func( GTK_OBJECT(marker_mid_menu), GTK_SIGNAL_FUNC(sp_marker_select), spw); + pos = ink_marker_menu_get_pos(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(marker_mid_menu))), NULL); m = gtk_menu_new(); gtk_widget_show(m); ink_marker_menu_create_menu(m, "marker-mid", document, sandbox); gtk_option_menu_remove_menu(GTK_OPTION_MENU(marker_mid_menu)); gtk_option_menu_set_menu(GTK_OPTION_MENU(marker_mid_menu), m); + gtk_option_menu_set_history(GTK_OPTION_MENU(marker_mid_menu), pos); + gtk_signal_handler_unblock_by_func( GTK_OBJECT(marker_mid_menu), GTK_SIGNAL_FUNC(sp_marker_select), spw); + gtk_signal_handler_block_by_func( GTK_OBJECT(marker_end_menu), GTK_SIGNAL_FUNC(sp_marker_select), spw); + pos = ink_marker_menu_get_pos(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(marker_end_menu))), NULL); m = gtk_menu_new(); gtk_widget_show(m); ink_marker_menu_create_menu(m, "marker-end", document, sandbox); gtk_option_menu_remove_menu(GTK_OPTION_MENU(marker_end_menu)); gtk_option_menu_set_menu(GTK_OPTION_MENU(marker_end_menu), m); + gtk_option_menu_set_history(GTK_OPTION_MENU(marker_end_menu), pos); + gtk_signal_handler_unblock_by_func( GTK_OBJECT(marker_end_menu), GTK_SIGNAL_FUNC(sp_marker_select), spw); } /** @@ -1253,7 +1301,7 @@ sp_stroke_style_line_widget_new(void) static void sp_stroke_style_line_construct(SPWidget *spw, gpointer data) { - + (void)data; #ifdef SP_SS_VERBOSE g_print( "Stroke style widget constructed: inkscape %p repr %p\n", spw->inkscape, spw->repr ); @@ -1263,11 +1311,11 @@ sp_stroke_style_line_construct(SPWidget *spw, gpointer data) ( SP_ACTIVE_DESKTOP ? sp_desktop_selection(SP_ACTIVE_DESKTOP) : NULL )); - } + } } /** - * Callback for when stroke style widget is modified. + * Callback for when stroke style widget is modified. * Triggers update action. */ static void @@ -1276,6 +1324,7 @@ sp_stroke_style_line_selection_modified ( SPWidget *spw, guint flags, gpointer data ) { + (void)data; if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG)) { sp_stroke_style_line_update (spw, selection); } @@ -1291,6 +1340,7 @@ sp_stroke_style_line_selection_changed ( SPWidget *spw, Inkscape::Selection *selection, gpointer data ) { + (void)data; sp_stroke_style_line_update (spw, selection); } @@ -1385,12 +1435,12 @@ sp_stroke_style_line_update(SPWidget *spw, Inkscape::Selection *sel) GtkWidget *dsel = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "dash")); // create temporary style - SPStyle *query = sp_style_new (); + SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); // query into it - int result_sw = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEWIDTH); - int result_ml = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT); - int result_cap = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKECAP); - int result_join = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEJOIN); + int result_sw = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEWIDTH); + int result_ml = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT); + int result_cap = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKECAP); + int result_join = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEJOIN); if (result_sw == QUERY_STYLE_NOTHING) { /* No objects stroked, set insensitive */ @@ -1437,7 +1487,7 @@ sp_stroke_style_line_update(SPWidget *spw, Inkscape::Selection *sel) sp_stroke_style_set_cap_buttons(spw, NULL); } - g_free (query); + sp_style_unref(query); if (!sel || sel->isEmpty()) return; @@ -1565,7 +1615,7 @@ sp_stroke_style_scale_line(SPWidget *spw) sp_repr_css_attr_unref(css); - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, + sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, _("Set stroke style")); gtk_object_set_data(GTK_OBJECT(spw), "update", GINT_TO_POINTER(FALSE)); @@ -1573,12 +1623,13 @@ sp_stroke_style_scale_line(SPWidget *spw) /** - * Callback for when the stroke style's width changes. + * Callback for when the stroke style's width changes. * Causes all line styles to be applied to all selected items. */ static void sp_stroke_style_width_changed(GtkAdjustment *adj, SPWidget *spw) { + (void)adj; if (gtk_object_get_data(GTK_OBJECT(spw), "update")) { return; } @@ -1587,12 +1638,13 @@ sp_stroke_style_width_changed(GtkAdjustment *adj, SPWidget *spw) } /** - * Callback for when the stroke style's miterlimit changes. + * Callback for when the stroke style's miterlimit changes. * Causes all line styles to be applied to all selected items. */ static void sp_stroke_style_miterlimit_changed(GtkAdjustment *adj, SPWidget *spw) { + (void)adj; if (gtk_object_get_data(GTK_OBJECT(spw), "update")) { return; } @@ -1601,12 +1653,13 @@ sp_stroke_style_miterlimit_changed(GtkAdjustment *adj, SPWidget *spw) } /** - * Callback for when the stroke style's dash changes. + * Callback for when the stroke style's dash changes. * Causes all line styles to be applied to all selected items. */ static void sp_stroke_style_line_dash_changed(SPDashSelector *dsel, SPWidget *spw) { + (void)dsel; if (gtk_object_get_data(GTK_OBJECT(spw), "update")) { return; } @@ -1733,19 +1786,7 @@ ink_marker_menu_set_current(SPObject *marker, GtkOptionMenu *mnu) else markname = g_strdup(SP_OBJECT_REPR(marker)->attribute("id")); - int markpos = 0; - GList *kids = GTK_MENU_SHELL(m)->children; - int i = 0; - for (; kids != NULL; kids = kids->next) { - gchar *mark = (gchar *) g_object_get_data(G_OBJECT(kids->data), "marker"); - if ( mark && strcmp(mark, markname) == 0 ) { - if ( mark_is_stock && !strcmp((gchar *) g_object_get_data(G_OBJECT(kids->data), "stockid"), "true")) - markpos = i; - if ( !mark_is_stock && !strcmp((gchar *) g_object_get_data(G_OBJECT(kids->data), "stockid"), "false")) - markpos = i; - } - i++; - } + int markpos = ink_marker_menu_get_pos(m, markname); gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), markpos); g_free (markname); @@ -1757,7 +1798,7 @@ ink_marker_menu_set_current(SPObject *marker, GtkOptionMenu *mnu) } /** - * Updates the marker menus to highlight the appropriate marker and scroll to + * Updates the marker menus to highlight the appropriate marker and scroll to * that marker. */ static void @@ -1848,7 +1889,6 @@ ink_extract_marker_name(gchar const *n) gchar* b = g_strdup(p); b[c] = '\0'; - SPDesktop *desktop = inkscape_active_desktop(); SPDocument *doc = sp_desktop_document(desktop); SPObject *marker = doc->getObjectById(b);