From aa45c83d224836b06d805b74912a2e98dfe32874 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 2 Apr 2012 23:10:25 +0900 Subject: Fix for 367607 : Remove deprecated GTK+ symbols - Deprecated *_unref symbols replaced with g_object_unref (bzr r11139) --- src/display/sodipodi-ctrl.cpp | 2 +- src/display/sp-canvas.cpp | 6 +++--- src/extension/internal/cairo-renderer.cpp | 2 +- src/helper/pixbuf-ops.cpp | 2 +- src/helper/unit-menu.cpp | 4 ++-- src/selection-chemistry.cpp | 2 +- src/sp-image.cpp | 6 +++--- src/widgets/sp-color-slider.cpp | 4 ++-- src/widgets/sp-widget.cpp | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index 1380b491a..a82aa8622 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -205,7 +205,7 @@ sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) ctrl->pixbuf = pixbuf; } else { ctrl->pixbuf = gdk_pixbuf_add_alpha (pixbuf, FALSE, 0, 0, 0); - gdk_pixbuf_unref (pixbuf); + g_object_unref (pixbuf); } ctrl->build = FALSE; break; diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 11836baa2..e5be4f8a9 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1100,7 +1100,7 @@ void SPCanvasGroup::remove(SPCanvasItem *item) // Unparent the child item->parent = NULL; - gtk_object_unref(GTK_OBJECT(item)); + g_object_unref(item); // Remove it from the list if (children == last) { @@ -1242,7 +1242,7 @@ void SPCanvasImpl::destroy(GtkObject *object) SPCanvas *canvas = SP_CANVAS(object); if (canvas->root) { - gtk_object_unref (GTK_OBJECT (canvas->root)); + g_object_unref (canvas->root); canvas->root = NULL; } @@ -1487,7 +1487,7 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event) gtk_object_ref (GTK_OBJECT (item)); g_signal_emit (G_OBJECT (item), item_signals[ITEM_EVENT], 0, &ev, &finished); SPCanvasItem *parent = item->parent; - gtk_object_unref (GTK_OBJECT (item)); + g_object_unref (item); item = parent; } diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 61e943dba..09d69becb 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -507,7 +507,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) // TODO this is stupid - we just converted to pixbuf format when generating the bitmap! convert_pixbuf_normal_to_argb32(pb); ctx->renderImage(pb, t, item->style); - gdk_pixbuf_unref(pb); + g_object_unref(pb); pb = 0; } g_slist_free (items); diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index f980953dc..cae297e89 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -77,7 +77,7 @@ bool sp_export_jpg_file(SPDocument *doc, gchar const *filename, g_snprintf(c, 32, "%f", quality); gboolean saved = gdk_pixbuf_save (pixbuf, filename, "jpeg", NULL, "quality", c, NULL); g_free(c); - gdk_pixbuf_unref (pixbuf); + g_object_unref (pixbuf); return saved; } diff --git a/src/helper/unit-menu.cpp b/src/helper/unit-menu.cpp index ce64cabf4..ea1ddde5e 100644 --- a/src/helper/unit-menu.cpp +++ b/src/helper/unit-menu.cpp @@ -132,7 +132,7 @@ sp_unit_selector_finalize(GObject *object) } while (selector->adjustments) { - gtk_object_unref(GTK_OBJECT(selector->adjustments->data)); + g_object_unref(selector->adjustments->data); selector->adjustments = g_slist_remove(selector->adjustments, selector->adjustments->data); } @@ -341,7 +341,7 @@ sp_unit_selector_remove_adjustment(SPUnitSelector *us, GtkAdjustment *adj) g_return_if_fail(g_slist_find(us->adjustments, adj)); us->adjustments = g_slist_remove(us->adjustments, adj); - gtk_object_unref(GTK_OBJECT(adj)); + g_object_unref(adj); } gboolean diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index d0fba0de5..7f3b14d58 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2907,7 +2907,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) // Clean up Inkscape::GC::release(repr); - gdk_pixbuf_unref(pb); + g_object_unref(pb); // Complete undoable transaction DocumentUndo::done(document, SP_VERB_SELECTION_CREATE_BITMAP, diff --git a/src/sp-image.cpp b/src/sp-image.cpp index df0d052dd..07885ff4d 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -657,7 +657,7 @@ static void sp_image_release( SPObject *object ) } if (image->pixbuf) { - gdk_pixbuf_unref (image->pixbuf); + g_object_unref (image->pixbuf); image->pixbuf = NULL; } @@ -815,7 +815,7 @@ static void sp_image_update( SPObject *object, SPCtx *ctx, unsigned int flags ) if (flags & SP_IMAGE_HREF_MODIFIED_FLAG) { if (image->pixbuf) { - gdk_pixbuf_unref (image->pixbuf); + g_object_unref (image->pixbuf); image->pixbuf = NULL; } if ( image->pixPath ) { @@ -1254,7 +1254,7 @@ static GdkPixbuf *sp_image_pixbuf_force_rgba( GdkPixbuf * pixbuf ) result = pixbuf; } else { result = gdk_pixbuf_add_alpha(pixbuf, FALSE, 0, 0, 0); - gdk_pixbuf_unref(pixbuf); + g_object_unref(pixbuf); } return result; } diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 5ec6d57df..047083b43 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -171,7 +171,7 @@ sp_color_slider_destroy (GtkObject *object) if (slider->adjustment) { g_signal_handlers_disconnect_matched (G_OBJECT (slider->adjustment), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, slider); - gtk_object_unref (GTK_OBJECT (slider->adjustment)); + g_object_unref (slider->adjustment); slider->adjustment = NULL; } @@ -343,7 +343,7 @@ void sp_color_slider_set_adjustment(SPColorSlider *slider, GtkAdjustment *adjust if (slider->adjustment != adjustment) { if (slider->adjustment) { g_signal_handlers_disconnect_matched (G_OBJECT (slider->adjustment), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, slider); - gtk_object_unref (GTK_OBJECT (slider->adjustment)); + g_object_unref (slider->adjustment); } slider->adjustment = adjustment; diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index aa4c85851..8645d90f7 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -234,7 +234,7 @@ sp_widget_new_global (Inkscape::Application *inkscape) spw = (SPWidget*)g_object_new (SP_TYPE_WIDGET, NULL); if (!sp_widget_construct_global (spw, inkscape)) { - gtk_object_unref (GTK_OBJECT (spw)); + g_object_unref (spw); return NULL; } -- cgit v1.2.3 From 7e8797abd4ff266134f2d60ea59f4cc82f18cf82 Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 3 Apr 2012 10:32:18 +0900 Subject: Fix for 367607 : Remove deprecated GTK+ symbols - Deprecated *_unref symbols and combo_box fixes (bzr r11140) --- src/display/canvas-grid.cpp | 2 +- src/display/sp-canvas.cpp | 6 +++--- src/helper/unit-menu.cpp | 2 +- src/widgets/font-selector.cpp | 29 ++++++++++++++++++++++++----- src/widgets/sp-color-slider.cpp | 2 +- 5 files changed, 30 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 1cc6e72ed..92a1b0fb8 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -311,7 +311,7 @@ CanvasGrid::createCanvasItem(SPDesktop * desktop) item->grid = this; sp_canvas_item_show(SP_CANVAS_ITEM(item)); - gtk_object_ref(GTK_OBJECT(item)); // since we're keeping a link to this item, we need to bump up the ref count + g_object_ref(item); // since we're keeping a link to this item, we need to bump up the ref count canvasitems = g_slist_prepend(canvasitems, item); return item; diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index e5be4f8a9..f352133e5 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1078,7 +1078,7 @@ void SPCanvasGroup::viewboxChanged(SPCanvasItem *item, Geom::IntRect const &new_ void SPCanvasGroup::add(SPCanvasItem *item) { - gtk_object_ref( GTK_OBJECT(item) ); + g_object_ref(item); g_object_ref_sink(item); if (!items) { @@ -1181,7 +1181,7 @@ void SPCanvasImpl::init(SPCanvas *canvas) canvas->root = SP_CANVAS_ITEM(g_object_new(SPCanvasGroup::getType(), NULL)); canvas->root->canvas = canvas; - gtk_object_ref (GTK_OBJECT (canvas->root)); + g_object_ref (canvas->root); g_object_ref_sink (canvas->root); canvas->need_repick = TRUE; @@ -1484,7 +1484,7 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event) gint finished = FALSE; while (item && !finished) { - gtk_object_ref (GTK_OBJECT (item)); + g_object_ref (item); g_signal_emit (G_OBJECT (item), item_signals[ITEM_EVENT], 0, &ev, &finished); SPCanvasItem *parent = item->parent; g_object_unref (item); diff --git a/src/helper/unit-menu.cpp b/src/helper/unit-menu.cpp index ea1ddde5e..964ca9d67 100644 --- a/src/helper/unit-menu.cpp +++ b/src/helper/unit-menu.cpp @@ -326,7 +326,7 @@ sp_unit_selector_add_adjustment(SPUnitSelector *us, GtkAdjustment *adj) g_return_if_fail(!g_slist_find(us->adjustments, adj)); - gtk_object_ref(GTK_OBJECT(adj)); + g_object_ref(adj); us->adjustments = g_slist_prepend(us->adjustments, adj); } diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 5aa8d3d00..894fc2cd8 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -205,7 +205,17 @@ static void sp_font_selector_init(SPFontSelector *fsel) gtk_widget_show(hb); gtk_box_pack_start(GTK_BOX(vb), hb, FALSE, FALSE, 0); +/* +This would introduce dependency on gtk version 2.24 which is currently not available in +Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) +This conditional and its #else block can be deleted in the future. +*/ +#if GTK_CHECK_VERSION(2, 24,0) + fsel->size = gtk_combo_box_text_new_with_entry (); +#else fsel->size = gtk_combo_box_entry_new_text (); +#endif + gtk_widget_set_tooltip_text (fsel->size, _("Font size (px)")); gtk_widget_set_size_request(fsel->size, 90, -1); g_signal_connect (G_OBJECT(fsel->size), "changed", G_CALLBACK (sp_font_selector_size_changed), fsel); @@ -216,9 +226,13 @@ static void sp_font_selector_init(SPFontSelector *fsel) gtk_box_pack_end(GTK_BOX (hb), l, FALSE, FALSE, 0); for (unsigned int n = 0; sizes[n]; ++n) - { - gtk_combo_box_append_text (GTK_COMBO_BOX(fsel->size), sizes[n]); - } + { +#if GTK_CHECK_VERSION(2, 24,0) + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(fsel->size), sizes[n]); +#else + gtk_combo_box_append_text (GTK_COMBO_BOX(fsel->size), sizes[n]); +#endif + } gtk_widget_show_all (fsel->size); @@ -304,7 +318,12 @@ static void sp_font_selector_style_select_row (GtkTreeSelection *selection, static void sp_font_selector_size_changed( GtkComboBox */*cbox*/, SPFontSelector *fsel ) { - char *text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (fsel->size)); + char *text = NULL; +#if GTK_CHECK_VERSION(2, 24,0) + text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (fsel->size)); +#else + text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (fsel->size)); +#endif gfloat old_size = fsel->fontsize; gchar *endptr; @@ -375,7 +394,7 @@ static void sp_font_selector_emit_set (SPFontSelector *fsel) fsel->font->Unref(); } fsel->font = font; - gtk_signal_emit(GTK_OBJECT(fsel), fs_signals[FONT_SET], fsel->font); + g_signal_emit(GTK_OBJECT(fsel), fs_signals[FONT_SET], 0, fsel->font); } fsel->fontsize_dirty = false; if (font) { diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 047083b43..17a33affe 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -347,7 +347,7 @@ void sp_color_slider_set_adjustment(SPColorSlider *slider, GtkAdjustment *adjust } slider->adjustment = adjustment; - gtk_object_ref (GTK_OBJECT (adjustment)); + g_object_ref (adjustment); g_object_ref_sink (adjustment); g_signal_connect (G_OBJECT (adjustment), "changed", -- cgit v1.2.3 From bf5917550889e6a3af05b4b997327dbcc583381a Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 3 Apr 2012 12:32:00 +0900 Subject: Fix for 170378 : Select same objects by fill or stroke (bzr r11141) --- src/menus-skeleton.h | 5 ++ src/selection-chemistry.cpp | 117 ++++++++++++++++++++++++++++++++++++++++++++ src/selection-chemistry.h | 6 +++ src/ui/context-menu.cpp | 19 +++++++ src/verbs.cpp | 15 ++++++ src/verbs.h | 3 ++ 6 files changed, 165 insertions(+) (limited to 'src') diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 3236d9a55..d92274a9e 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -78,6 +78,11 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +" \n" +" \n" +" \n" +" \n" +" \n" " \n" " \n" " \n" diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 7f3b14d58..ff6c137a6 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -151,6 +151,22 @@ void SelectionHelper::selectNone(SPDesktop *dt) } } +void SelectionHelper::selectSameFillStroke(SPDesktop *dt) +{ + sp_select_same_fill_stroke(dt, true, true); +} + +void SelectionHelper::selectSameFill(SPDesktop *dt) +{ + sp_select_same_fill_stroke(dt, true, false); +} + +void SelectionHelper::selectSameStroke(SPDesktop *dt) +{ + sp_select_same_fill_stroke(dt, false, true); +} + + void SelectionHelper::invert(SPDesktop *dt) { if (tools_isactive(dt, TOOLS_NODES)) { @@ -1610,6 +1626,107 @@ sp_selection_rotate(Inkscape::Selection *selection, gdouble const angle_degrees) _("Rotate")); } +/* + * Selects all the visible items with the same fill and/or stroke style as the items in the current selection + * + * Params: + * desktop - set the selection on this desktop + * fill - select objects matching fill + * stroke - select objects matching stroke + */ +void sp_select_same_fill_stroke(SPDesktop *desktop, gboolean fill, gboolean stroke) +{ + if (!desktop) { + return; + } + + if (!fill && !stroke) { + return; + } + + GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, true, true, NULL); + GSList *all_matches = NULL; + + Inkscape::Selection *selection = sp_desktop_selection (desktop); + + for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) { + SPItem *sel = SP_ITEM(sel_iter->data); + GSList *matches = all_list; + if (fill) { + matches = sp_get_same_fill_or_stroke_items(sel, matches, TRUE); + } + if (stroke) { + matches = sp_get_same_fill_or_stroke_items(sel, matches, FALSE); + } + all_matches = g_slist_concat (all_matches, matches); + } + + selection->clear(); + selection->setList(all_matches); + + g_slist_free(all_matches); + g_slist_free(all_list); + +} + +/* + * Find all items in src list that have the same fill or stroke style as sel + * Return the list of matching items + */ +GSList *sp_get_same_fill_or_stroke_items(SPItem *sel, GSList *src, gboolean fillorstroke) +{ + GSList *matches = NULL; + gboolean match = false; + + SPIPaint *sel_paint = (fillorstroke) ? &(sel->style->fill) : &(sel->style->stroke); + + for (GSList *i = src; i != NULL; i = i->next) { + SPItem *iter = SP_ITEM(i->data); + SPIPaint *iter_paint = (fillorstroke) ? &(iter->style->fill) : &(iter->style->stroke); + match = false; + if (sel_paint->isColor() && iter_paint->isColor() // color == color comparision doesnt seem to work here. + && (sel_paint->value.color.toRGBA32(1.0) == iter_paint->value.color.toRGBA32(1.0))) { + match = true; + } else if (sel_paint->isPaintserver() && iter_paint->isPaintserver()) { + + SPPaintServer *sel_server = + (fillorstroke) ? sel->style->getFillPaintServer() : sel->style->getStrokePaintServer(); + SPPaintServer *iter_server = + (fillorstroke) ? iter->style->getFillPaintServer() : iter->style->getStrokePaintServer(); + + if ((SP_IS_LINEARGRADIENT(sel_server) || SP_IS_RADIALGRADIENT(sel_server) || + (SP_IS_GRADIENT(sel_server) && SP_GRADIENT(sel_server)->getVector()->isSwatch())) + && + (SP_IS_LINEARGRADIENT(iter_server) || SP_IS_RADIALGRADIENT(iter_server) || + (SP_IS_GRADIENT(iter_server) && SP_GRADIENT(iter_server)->getVector()->isSwatch()))) { + SPGradient *sel_vector = SP_GRADIENT(sel_server)->getVector(); + SPGradient *iter_vector = SP_GRADIENT(iter_server)->getVector(); + if (sel_vector == iter_vector) { + match = true; + } + + } else if (SP_IS_PATTERN(sel_server) && SP_IS_PATTERN(iter_server)) { + SPPattern *sel_pat = pattern_getroot(SP_PATTERN(sel_server)); + SPPattern *iter_pat = pattern_getroot(SP_PATTERN(iter_server)); + if (sel_pat == iter_pat) { + match = true; + } + } + } else if (sel_paint->isNone() && iter_paint->isNone()) { + match = true; + } else if (sel_paint->isNoneSet() && iter_paint->isNoneSet()) { + match = true; + } + + if (match) { + matches = g_slist_prepend(matches, iter); + } + } + + return matches; +} + + // helper function: static Geom::Point diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 1b09d98c9..74f80b6af 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -36,6 +36,9 @@ namespace Inkscape { static void selectAll(SPDesktop *desktop); static void selectAllInAll(SPDesktop *desktop); static void selectNone(SPDesktop *desktop); + static void selectSameFillStroke(SPDesktop *dt); + static void selectSameFill(SPDesktop *dt); + static void selectSameStroke(SPDesktop *dt); static void invert(SPDesktop *desktop); static void invertAllInAll(SPDesktop *desktop); static void reverse(SPDesktop *dt); @@ -120,6 +123,9 @@ void sp_selection_next_patheffect_param(SPDesktop * dt); void sp_selection_edit_clip_or_mask(SPDesktop * dt, bool clip); +void sp_select_same_fill_stroke(SPDesktop *desktop, gboolean fill, gboolean stroke); +GSList *sp_get_same_fill_or_stroke_items(SPItem *sel, GSList *src, gboolean fillorstroke); + void scroll_to_show_item(SPDesktop *desktop, SPItem *item); void sp_undo (SPDesktop *desktop, SPDocument *doc); diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index 9e5c65af9..d8d495b1e 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -25,6 +25,8 @@ #include "preferences.h" #include "verbs.h" +#include "selection-chemistry.h" + using Inkscape::DocumentUndo; static void sp_object_type_menu(GType type, SPObject *object, SPDesktop *desktop, GtkMenu *menu); @@ -90,6 +92,7 @@ static void sp_object_type_menu(GType type, SPObject *object, SPDesktop *desktop static void sp_item_properties(GtkMenuItem *menuitem, SPItem *item); static void sp_item_select_this(GtkMenuItem *menuitem, SPItem *item); +static void sp_item_select_same_fill_stroke(GtkMenuItem *menuitem, SPItem *item); static void sp_item_create_link(GtkMenuItem *menuitem, SPItem *item); static void sp_set_mask(GtkMenuItem *menuitem, SPItem *item); static void sp_release_mask(GtkMenuItem *menuitem, SPItem *item); @@ -124,6 +127,12 @@ static void sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) } gtk_widget_show(w); gtk_menu_shell_append(GTK_MENU_SHELL(m), w); + /* Select same fill and stroke */ + w = gtk_menu_item_new_with_mnemonic(_("_Select Same Fill and Stroke")); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_select_same_fill_stroke), item); + gtk_widget_show(w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Create link */ w = gtk_menu_item_new_with_mnemonic(_("_Create Link")); g_object_set_data(G_OBJECT(w), "desktop", desktop); @@ -258,6 +267,16 @@ static void sp_item_select_this(GtkMenuItem *menuitem, SPItem *item) sp_desktop_selection(desktop)->set(item); } +static void sp_item_select_same_fill_stroke(GtkMenuItem *menuitem, SPItem *item) +{ + SPDesktop *desktop; + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); + g_return_if_fail(desktop != NULL); + + sp_select_same_fill_stroke(desktop, true, true); +} + + static void sp_item_create_link(GtkMenuItem *menuitem, SPItem *item) { g_assert(SP_IS_ITEM(item)); diff --git a/src/verbs.cpp b/src/verbs.cpp index d7e5f6841..ab16c6c93 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -961,6 +961,15 @@ void EditVerb::perform(SPAction *action, void *data) case SP_VERB_EDIT_SELECT_ALL: SelectionHelper::selectAll(dt); break; + case SP_VERB_EDIT_SELECT_SAME_FILL_STROKE: + SelectionHelper::selectSameFillStroke(dt); + break; + case SP_VERB_EDIT_SELECT_SAME_FILL: + SelectionHelper::selectSameFill(dt); + break; + case SP_VERB_EDIT_SELECT_SAME_STROKE: + SelectionHelper::selectSameStroke(dt); + break; case SP_VERB_EDIT_INVERT: SelectionHelper::invert(dt); break; @@ -2288,6 +2297,12 @@ Verb *Verb::_base_verbs[] = { N_("Select all objects or all nodes"), GTK_STOCK_SELECT_ALL), new EditVerb(SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, "EditSelectAllInAllLayers", N_("Select All in All La_yers"), N_("Select all objects in all visible and unlocked layers"), INKSCAPE_ICON("edit-select-all-layers")), + new EditVerb(SP_VERB_EDIT_SELECT_SAME_FILL_STROKE, "EditSelectSameFillStroke", N_("S_ame Fill and Stroke"), + N_("Select all objects with the same fill and stroke as the selected objects"), GTK_STOCK_SELECT_ALL), + new EditVerb(SP_VERB_EDIT_SELECT_SAME_FILL, "EditSelectSameFill", N_("Same _Fill"), + N_("Select all objects with the same fill as the selected objects"), GTK_STOCK_SELECT_ALL), + new EditVerb(SP_VERB_EDIT_SELECT_SAME_STROKE, "EditSelectSameStroke", N_("Same _Stroke"), + N_("Select all objects with the same stroke as the selected objects"), GTK_STOCK_SELECT_ALL), new EditVerb(SP_VERB_EDIT_INVERT, "EditInvert", N_("In_vert Selection"), N_("Invert selection (unselect what is selected and select everything else)"), INKSCAPE_ICON("edit-select-invert")), new EditVerb(SP_VERB_EDIT_INVERT_IN_ALL_LAYERS, "EditInvertInAllLayers", N_("Invert in All Layers"), diff --git a/src/verbs.h b/src/verbs.h index 979a578d5..ec394b9a5 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -87,6 +87,9 @@ enum { SP_VERB_EDIT_CLEAR_ALL, SP_VERB_EDIT_SELECT_ALL, SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, + SP_VERB_EDIT_SELECT_SAME_FILL_STROKE, + SP_VERB_EDIT_SELECT_SAME_FILL, + SP_VERB_EDIT_SELECT_SAME_STROKE, SP_VERB_EDIT_INVERT, SP_VERB_EDIT_INVERT_IN_ALL_LAYERS, SP_VERB_EDIT_SELECT_NEXT, -- cgit v1.2.3 From 02edd2123f6ea2d8df1a469ebf426db6ce4d28c0 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 3 Apr 2012 12:04:22 +0100 Subject: eek-preview: Cairo drawing (bzr r11142) --- src/document.cpp | 3 +-- src/widgets/eek-preview.cpp | 33 ++++++++++++++++++++------------- src/widgets/gradient-toolbar.cpp | 3 +-- 3 files changed, 22 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index b5383c91d..18d714bad 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -37,11 +37,11 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include #include #include #include <2geom/transforms.h> +#include "widgets/desktop-widget.h" #include "desktop.h" #include "dir-util.h" #include "display/drawing-item.h" @@ -60,7 +60,6 @@ #include "sp-object-repr.h" #include "transf_mat_3x4.h" #include "unit-constants.h" -#include "widgets/desktop-widget.h" #include "xml/repr.h" #include "xml/rebase-hrefs.h" #include "libcroco/cr-cascade.h" diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index 36281f4d8..eb77bc8d7 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -233,28 +233,31 @@ gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* event ) allocation.width, allocation.height); } - GdkGC *gc = gdk_gc_new( gtk_widget_get_window (widget) ); EekPreview* preview = EEK_PREVIEW(widget); GdkColor fg = {0, preview->_r, preview->_g, preview->_b}; gdk_colormap_alloc_color( gdk_colormap_get_system(), &fg, FALSE, TRUE ); - gdk_gc_set_foreground( gc, &fg ); gtk_widget_get_allocation (widget, &allocation); + cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(widget)); - gdk_draw_rectangle( gtk_widget_get_window (widget), - gc, - TRUE, - insetX, insetY, - allocation.width - (insetX * 2), allocation.height - (insetY * 2) ); + GdkRectangle rect = {insetX, + insetY, + allocation.width - (insetX * 2), + allocation.height - (insetY * 2)}; + + gdk_cairo_set_source_color(cr, &fg); + gdk_cairo_rectangle(cr, &rect); + cairo_paint(cr); + cairo_destroy(cr); if ( preview->_previewPixbuf ) { GtkDrawingArea* da = &(preview->drawing); - GdkDrawable* drawable = (GdkDrawable*) gtk_widget_get_window(GTK_WIDGET(da)); - gint w = 0; - gint h = 0; - gdk_drawable_get_size(drawable, &w, &h); - if ((w != preview->_scaledW) || (h != preview->_scaledH)) { + GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(da)); + gint w = gdk_window_get_width(window); + gint h = gdk_window_get_height(window); + + if ((w != preview->_scaledW) || (h != preview->_scaledH)) { if (preview->_scaled) { g_object_unref(preview->_scaled); } @@ -264,7 +267,11 @@ gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* event ) } GdkPixbuf* pix = (preview->_scaled) ? preview->_scaled : preview->_previewPixbuf; - gdk_draw_pixbuf( drawable, 0, pix, 0, 0, 0, 0, w, h, GDK_RGB_DITHER_NONE, 0, 0 ); + GdkDrawable* drawable = (GdkDrawable*) window; + cairo_t* cr2 = gdk_cairo_create(drawable); + gdk_cairo_set_source_pixbuf(cr2, pix, 0, 0); + cairo_paint(cr2); + cairo_destroy(cr); } diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 465c426fc..88e871e42 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -16,8 +16,8 @@ # include "config.h" #endif +#include "ui/widget/color-preview.h" #include "verbs.h" -#include #include "macros.h" #include "widgets/button.h" @@ -51,7 +51,6 @@ #include "../ink-comboboxentry-action.h" #include "sp-stop.h" -#include "ui/widget/color-preview.h" #include "svg/css-ostringstream.h" #include "svg/svg-color.h" #include "desktop-style.h" -- cgit v1.2.3 From 30ead97cd4cf0b28a622f54b5da9a2d93b16373f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 3 Apr 2012 23:58:43 -0700 Subject: Corrected logic error with sig::connection bool operator. Warning cleanup. (bzr r11143) --- src/ui/dialog/ocaldialogs.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index c766bae9d..4da9fa5b4 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -310,7 +310,7 @@ LoadingBox::LoadingBox() : Gtk::EventBox() signal_expose_event().connect(sigc::mem_fun(*this, &LoadingBox::_on_expose_event), false); } -bool LoadingBox::_on_expose_event(GdkEventExpose* event) +bool LoadingBox::_on_expose_event(GdkEventExpose* /*event*/) { Cairo::RefPtr cr = get_window()->create_cairo_context(); @@ -342,7 +342,7 @@ bool LoadingBox::_on_expose_event(GdkEventExpose* event) void LoadingBox::start() { // Timeout hasn't been stopped, so must be disconnected - if ((draw_spinner != false) & (timeout != NULL)) { + if ((draw_spinner != false) && timeout) { timeout.disconnect(); } @@ -447,7 +447,7 @@ void PreviewWidget::clear() image->hide(); } -bool PreviewWidget::_on_expose_event(GdkEventExpose* event) +bool PreviewWidget::_on_expose_event(GdkEventExpose* /*event*/) { Cairo::RefPtr cr = get_window()->create_cairo_context(); @@ -532,7 +532,7 @@ SearchEntry::SearchEntry() : Gtk::Entry() gtk_entry_set_icon_from_stock(gobj(), GTK_ENTRY_ICON_SECONDARY, NULL); } -void SearchEntry::_on_icon_pressed(Gtk::EntryIconPosition icon_position, const GdkEventButton* event) +void SearchEntry::_on_icon_pressed(Gtk::EntryIconPosition icon_position, const GdkEventButton* /*event*/) { if (icon_position == Gtk::ENTRY_ICON_SECONDARY) { grab_focus(); @@ -558,7 +558,7 @@ BaseBox::BaseBox() : Gtk::EventBox() set_visible_window(false); } -bool BaseBox::_on_expose_event(GdkEventExpose* event) +bool BaseBox::_on_expose_event(GdkEventExpose* /*event*/) { Cairo::RefPtr cr = get_window()->create_cairo_context(); @@ -595,7 +595,7 @@ LogoArea::LogoArea() : Gtk::EventBox() set_visible_window(false); } -bool LogoArea::_on_expose_event(GdkEventExpose* event) +bool LogoArea::_on_expose_event(GdkEventExpose* /*event*/) { if (draw_logo) { int x = get_allocation().get_x(); @@ -863,8 +863,8 @@ void ImportDialog::on_thumbnail_downloaded(Glib::ustring path, bool success) /* * Callback for row activated */ -void ImportDialog::on_list_results_row_activated(const Gtk::TreeModel::Path& path, - Gtk::TreeViewColumn* column) +void ImportDialog::on_list_results_row_activated(const Gtk::TreeModel::Path& /*path*/, + Gtk::TreeViewColumn* /*column*/) { on_list_results_cursor_changed(); button_import->signal_clicked(); -- cgit v1.2.3 From dcda11ad8115fd98fb00947e0f6d40c59def8c3e Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 3 Apr 2012 23:59:33 -0700 Subject: Warning cleanup. (bzr r11144) --- src/desktop-events.cpp | 2 +- src/extension/script/InkscapeScript.cpp | 12 ++++++------ src/ui/context-menu.cpp | 5 ++--- src/ui/dialog/export.cpp | 8 ++++---- src/ui/dialog/find.cpp | 4 ++-- src/ui/dialog/ocaldialogs.h | 2 +- src/ui/dialog/text-edit.cpp | 4 ++-- src/ui/dialog/xml-tree.cpp | 16 ++++++++-------- src/ui/tool/control-point-selection.cpp | 2 +- src/ui/tool/path-manipulator.cpp | 2 +- src/widgets/gradient-toolbar.cpp | 6 +++--- src/widgets/gradient-vector.cpp | 2 +- src/widgets/stroke-marker-selector.cpp | 2 +- 13 files changed, 33 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index d24ddfed0..b361b8404 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -658,7 +658,7 @@ void snoop_extended(GdkEvent* event, SPDesktop *desktop) } -void sp_dt_ruler_snap_new_guide(SPDesktop *desktop, SPCanvasItem *guide, Geom::Point &event_dt, Geom::Point &normal) +void sp_dt_ruler_snap_new_guide(SPDesktop *desktop, SPCanvasItem * /*guide*/, Geom::Point &event_dt, Geom::Point &normal) { SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); diff --git a/src/extension/script/InkscapeScript.cpp b/src/extension/script/InkscapeScript.cpp index 9f8ebfbbb..02cd28fa5 100644 --- a/src/extension/script/InkscapeScript.cpp +++ b/src/extension/script/InkscapeScript.cpp @@ -67,9 +67,9 @@ InkscapeScript::~InkscapeScript() * enumerated types in ScriptLanguage above. */ bool InkscapeScript::interpretScript(const Glib::ustring &script, - Glib::ustring &output, - Glib::ustring &error, - ScriptLanguage language) + Glib::ustring & /*output*/, + Glib::ustring & /*error*/, + ScriptLanguage language) { const char *langname=NULL; //if() instead of switch() lets us scope vars @@ -135,9 +135,9 @@ bool InkscapeScript::interpretScript(const Glib::ustring &script, * enumerated types in ScriptLanguage above. */ bool InkscapeScript::interpretFile(const Glib::ustring &fname, - Glib::ustring &output, - Glib::ustring &error, - ScriptLanguage language) + Glib::ustring & /*output*/, + Glib::ustring & /*error*/, + ScriptLanguage language) { const char *langname=NULL; //if() instead of switch() lets us scope vars diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index d8d495b1e..672ac440d 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -267,10 +267,9 @@ static void sp_item_select_this(GtkMenuItem *menuitem, SPItem *item) sp_desktop_selection(desktop)->set(item); } -static void sp_item_select_same_fill_stroke(GtkMenuItem *menuitem, SPItem *item) +static void sp_item_select_same_fill_stroke(GtkMenuItem *menuitem, SPItem * /*item*/) { - SPDesktop *desktop; - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); + SPDesktop *desktop = static_cast(g_object_get_data(G_OBJECT(menuitem), "desktop")); g_return_if_fail(desktop != NULL); sp_select_same_fill_stroke(desktop, true, true); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 150abd66b..3068a2de7 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -428,7 +428,7 @@ void Export::set_default_filename () { * @param sensitive Whether the spin button is sensitive or not * @param cb Callback for when this spin button is changed (optional) */ -Gtk::Adjustment * Export::createSpinbutton( gchar const *key, float val, float min, float max, +Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max, float step, float page, GtkWidget *us, GtkWidget *t, int x, int y, const gchar *ll, const gchar *lr, @@ -606,7 +606,7 @@ void Export::onSelectionChanged() updateCheckbuttons (); } -void Export::onSelectioModified ( guint flags ) +void Export::onSelectioModified ( guint /*flags*/ ) { switch (current_key) { case SELECTION_DRAWING: @@ -784,7 +784,7 @@ void Export::onAreaToggled () /// Called when dialog is deleted -gint Export::onProgressDelete ( GtkWidget *widget, GdkEvent *event, GObject *base ) +gint Export::onProgressDelete ( GtkWidget * /*widget*/, GdkEvent * /*event*/, GObject *base ) { g_object_set_data (base, "cancel", (gpointer) 1); return TRUE; @@ -792,7 +792,7 @@ gint Export::onProgressDelete ( GtkWidget *widget, GdkEvent *event, GObject *bas /// Called when progress is cancelled -void Export::onProgressCancel ( GtkWidget *widget, GObject *base ) +void Export::onProgressCancel ( GtkWidget * /*widget*/, GObject *base ) { g_object_set_data (base, "cancel", (gpointer) 1); } // end of sp_export_progress_cancel() diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index f5745e02b..5fd6e18d8 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -436,7 +436,7 @@ Find::item_style_match (SPItem *item, const gchar *text, bool exact, bool casema return found; } -bool Find::item_attr_match(SPItem *item, const gchar *text, bool exact, bool casematch, bool replace/*=false*/) +bool Find::item_attr_match(SPItem *item, const gchar *text, bool exact, bool /*casematch*/, bool replace/*=false*/) { bool found = false; @@ -492,7 +492,7 @@ bool Find::item_attrvalue_match(SPItem *item, const gchar *text, bool exact, boo } -bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool casematch, bool replace/*=false*/) +bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool casematch, bool /*replace*/ /*=false*/) { bool ret = false; diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h index 5d4ac43ad..9e471b7b5 100644 --- a/src/ui/dialog/ocaldialogs.h +++ b/src/ui/dialog/ocaldialogs.h @@ -59,7 +59,7 @@ public: /** * Constructor */ - FileDialogBase(const Glib::ustring &title, Gtk::Window& parent) : Gtk::Window(Gtk::WINDOW_TOPLEVEL) + FileDialogBase(const Glib::ustring &title, Gtk::Window& /*parent*/) : Gtk::Window(Gtk::WINDOW_TOPLEVEL) { set_title(title); sp_transientize((GtkWidget*) gobj()); diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index c64bd22c6..b09096e63 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -245,7 +245,7 @@ void TextEdit::onSelectionModified(guint flags ) onReadSelection (style, content); } -void TextEdit::onReadSelection ( gboolean dostyle, gboolean docontent ) +void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ ) { if (blocked) return; @@ -643,7 +643,7 @@ void TextEdit::onToggle() } -void TextEdit::onLineSpacingChange(GtkComboBox* widget, gpointer data) +void TextEdit::onLineSpacingChange(GtkComboBox* /*widget*/, gpointer data) { TextEdit *self = static_cast(data); if (!self || self->blocked) diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index ae1ebf5ca..51aea2935 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -509,9 +509,9 @@ void XmlTree::set_dt_select(Inkscape::XML::Node *repr) void XmlTree::on_tree_select_row(GtkCTree *tree, - GtkCTreeNode *node, - gint column, - gpointer data) + GtkCTreeNode *node, + gint /*column*/, + gpointer data) { XmlTree *self = (XmlTree *)data; @@ -535,9 +535,9 @@ void XmlTree::on_tree_select_row(GtkCTree *tree, } void XmlTree::on_tree_unselect_row(GtkCTree *tree, - GtkCTreeNode *node, - gint column, - gpointer data) + GtkCTreeNode *node, + gint /*column*/, + gpointer data) { XmlTree *self = (XmlTree *)data; @@ -764,7 +764,7 @@ void XmlTree::on_attr_select_row(GtkTreeSelection *selection, gpointer data) } -void XmlTree::on_attr_row_changed(SPXMLViewAttrList *attributes, const gchar * name, gpointer data) +void XmlTree::on_attr_row_changed(SPXMLViewAttrList *attributes, const gchar * name, gpointer /*data*/) { // Reselect the selected row if the data changes to refresh the attribute and value edit boxes. GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(attributes)); @@ -821,7 +821,7 @@ void XmlTree::on_document_replaced(SPDesktop *dt, SPDocument *doc) set_tree_document(doc); } -void XmlTree::on_document_uri_set(gchar const */*uri*/, SPDocument *document) +void XmlTree::on_document_uri_set(gchar const * /*uri*/, SPDocument * /*document*/) { /* * Seems to be no way to set the title on a docked dialog diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index b39a78979..a44fde3be 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -579,7 +579,7 @@ void ControlPointSelection::_commitHandlesTransform(CommitEvent ce) signal_commit.emit(ce); } -bool ControlPointSelection::event(SPEventContext *event_context, GdkEvent *event) +bool ControlPointSelection::event(SPEventContext * /*event_context*/, GdkEvent *event) { // implement generic event handling that should apply for all control point selections here; // for example, keyboard moves and transformations. This way this functionality doesn't need diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index cded702b4..97e25069f 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -158,7 +158,7 @@ PathManipulator::~PathManipulator() } /** Handle motion events to update the position of the curve drag point. */ -bool PathManipulator::event(SPEventContext *event_context, GdkEvent *event) +bool PathManipulator::event(SPEventContext * /*event_context*/, GdkEvent *event) { if (empty()) return false; diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 88e871e42..e5a3ab155 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -939,14 +939,14 @@ static void gr_stop_set_offset (GtkComboBox */*widget*/, GtkWidget *data) * Callback functions for user actions */ -static void gr_new_type_changed( EgeSelectOneAction *act, GObject *tbl ) +static void gr_new_type_changed( EgeSelectOneAction *act, GObject * /*tbl*/ ) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint typemode = ege_select_one_action_get_active( act ) == 0 ? SP_GRADIENT_TYPE_LINEAR : SP_GRADIENT_TYPE_RADIAL; prefs->setInt("/tools/gradient/newgradient", typemode); } -static void gr_new_fillstroke_changed( EgeSelectOneAction *act, GObject *tbl ) +static void gr_new_fillstroke_changed( EgeSelectOneAction *act, GObject * /*tbl*/ ) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool fillmode = ege_select_one_action_get_active( act ) == 0; @@ -1010,7 +1010,7 @@ void gr_spread_change (EgeSelectOneAction *act, GtkWidget *widget) /* * User selected a stop from the combobox */ -static void gr_stop_combo_changed (GtkComboBox *widget, GtkWidget *data) +static void gr_stop_combo_changed (GtkComboBox * /*widget*/, GtkWidget *data) { if (blocked) { return; diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 3d6d5a8f2..2739a47b0 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -596,7 +596,7 @@ static void update_stop_list( GtkWidget *vb, SPGradient *gradient, SPStop *new_s // user selected existing stop from list -static void sp_grad_edit_combo_box_changed (GtkComboBox *widget, GtkWidget *tbl) +static void sp_grad_edit_combo_box_changed (GtkComboBox * /*widget*/, GtkWidget *tbl) { SPStop *stop = get_selected_stop(tbl); if (!stop) { diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index a39ebf8be..427112f9b 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -405,7 +405,7 @@ void MarkerComboBox::prepareImageRenderer( Gtk::TreeModel::const_iterator const image_renderer.property_pixbuf() = empty_image->get_pixbuf(); } -gboolean MarkerComboBox::separator_cb (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { +gboolean MarkerComboBox::separator_cb (GtkTreeModel *model, GtkTreeIter *iter, gpointer /*data*/) { gboolean sep = FALSE; gtk_tree_model_get(model, iter, 5, &sep, -1); -- cgit v1.2.3 From 13a536b5f52edf6e7044d5b60c5ceb90354aaa1c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 4 Apr 2012 10:42:31 +0100 Subject: Fix build with gtk < 2.24 (bzr r11145) --- src/widgets/eek-preview.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index eb77bc8d7..134cf9342 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -254,8 +254,15 @@ gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* event ) if ( preview->_previewPixbuf ) { GtkDrawingArea* da = &(preview->drawing); GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(da)); - gint w = gdk_window_get_width(window); - gint h = gdk_window_get_height(window); + GdkDrawable* drawable = (GdkDrawable*) window; + gint w = 0; + gint h = 0; +#if GTK_CHECK_VERSION(2,24,0) + w = gdk_window_get_width(window); + h = gdk_window_get_height(window); +#else + gdk_drawable_get_size(drawable, &w, &h); +#endif if ((w != preview->_scaledW) || (h != preview->_scaledH)) { if (preview->_scaled) { @@ -267,7 +274,6 @@ gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* event ) } GdkPixbuf* pix = (preview->_scaled) ? preview->_scaled : preview->_previewPixbuf; - GdkDrawable* drawable = (GdkDrawable*) window; cairo_t* cr2 = gdk_cairo_create(drawable); gdk_cairo_set_source_pixbuf(cr2, pix, 0, 0); cairo_paint(cr2); -- cgit v1.2.3 From 4d44c257559a9cea38f69eb340fad84688aca3e8 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 4 Apr 2012 18:54:17 +0900 Subject: Fix for 170378 : Select same objects by fill or stroke : Added stroke style (bzr r11146) --- src/menus-skeleton.h | 5 +- src/selection-chemistry.cpp | 131 +++++++++++++++++++++++++++++++++++++++----- src/selection-chemistry.h | 19 +++++-- src/ui/context-menu.cpp | 10 +++- src/verbs.cpp | 19 ++++--- src/verbs.h | 5 +- 6 files changed, 156 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index d92274a9e..84ecc83ea 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -80,8 +80,9 @@ static char const menus_skeleton[] = " \n" " \n" " \n" -" \n" -" \n" +" \n" +" \n" +" \n" " \n" " \n" " \n" diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index ff6c137a6..2fe3b343f 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -153,19 +153,23 @@ void SelectionHelper::selectNone(SPDesktop *dt) void SelectionHelper::selectSameFillStroke(SPDesktop *dt) { - sp_select_same_fill_stroke(dt, true, true); + sp_select_same_fill_stroke_style(dt, true, true, true); } -void SelectionHelper::selectSameFill(SPDesktop *dt) +void SelectionHelper::selectSameFillColor(SPDesktop *dt) { - sp_select_same_fill_stroke(dt, true, false); + sp_select_same_fill_stroke_style(dt, true, false, false); } -void SelectionHelper::selectSameStroke(SPDesktop *dt) +void SelectionHelper::selectSameStrokeColor(SPDesktop *dt) { - sp_select_same_fill_stroke(dt, false, true); + sp_select_same_fill_stroke_style(dt, false, true, false); } +void SelectionHelper::selectSameStrokeStyle(SPDesktop *dt) +{ + sp_select_same_stroke_style(dt); +} void SelectionHelper::invert(SPDesktop *dt) { @@ -1627,20 +1631,20 @@ sp_selection_rotate(Inkscape::Selection *selection, gdouble const angle_degrees) } /* - * Selects all the visible items with the same fill and/or stroke style as the items in the current selection + * Selects all the visible items with the same fill and/or stroke color/style as the items in the current selection * * Params: * desktop - set the selection on this desktop * fill - select objects matching fill * stroke - select objects matching stroke */ -void sp_select_same_fill_stroke(SPDesktop *desktop, gboolean fill, gboolean stroke) +void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolean stroke, gboolean style) { if (!desktop) { return; } - if (!fill && !stroke) { + if (!fill && !stroke && !style) { return; } @@ -1653,10 +1657,15 @@ void sp_select_same_fill_stroke(SPDesktop *desktop, gboolean fill, gboolean stro SPItem *sel = SP_ITEM(sel_iter->data); GSList *matches = all_list; if (fill) { - matches = sp_get_same_fill_or_stroke_items(sel, matches, TRUE); + matches = sp_get_same_fill_or_stroke_color(sel, matches, SP_FILL_COLOR); } if (stroke) { - matches = sp_get_same_fill_or_stroke_items(sel, matches, FALSE); + matches = sp_get_same_fill_or_stroke_color(sel, matches, SP_STROKE_COLOR); + } + if (style) { + matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_WIDTH); + matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_DASHES); + matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_MARKERS); } all_matches = g_slist_concat (all_matches, matches); } @@ -1669,20 +1678,52 @@ void sp_select_same_fill_stroke(SPDesktop *desktop, gboolean fill, gboolean stro } + +/* + * Selects all the visible items with the same stroke style as the items in the current selection + * + * Params: + * desktop - set the selection on this desktop + */ +void sp_select_same_stroke_style(SPDesktop *desktop) +{ + if (!desktop) { + return; + } + + GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, true, true, NULL); + GSList *matches = all_list; + + Inkscape::Selection *selection = sp_desktop_selection (desktop); + + for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) { + SPItem *sel = SP_ITEM(sel_iter->data); + matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_WIDTH); + matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_DASHES); + matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_MARKERS); + } + + selection->clear(); + selection->setList(matches); + + g_slist_free(matches); + g_slist_free(all_list); +} + /* * Find all items in src list that have the same fill or stroke style as sel * Return the list of matching items */ -GSList *sp_get_same_fill_or_stroke_items(SPItem *sel, GSList *src, gboolean fillorstroke) +GSList *sp_get_same_fill_or_stroke_color(SPItem *sel, GSList *src, SPSelectStrokeStyleType type) { GSList *matches = NULL; gboolean match = false; - SPIPaint *sel_paint = (fillorstroke) ? &(sel->style->fill) : &(sel->style->stroke); + SPIPaint *sel_paint = (type == SP_FILL_COLOR) ? &(sel->style->fill) : &(sel->style->stroke); for (GSList *i = src; i != NULL; i = i->next) { SPItem *iter = SP_ITEM(i->data); - SPIPaint *iter_paint = (fillorstroke) ? &(iter->style->fill) : &(iter->style->stroke); + SPIPaint *iter_paint = (type == SP_FILL_COLOR) ? &(iter->style->fill) : &(iter->style->stroke); match = false; if (sel_paint->isColor() && iter_paint->isColor() // color == color comparision doesnt seem to work here. && (sel_paint->value.color.toRGBA32(1.0) == iter_paint->value.color.toRGBA32(1.0))) { @@ -1690,9 +1731,9 @@ GSList *sp_get_same_fill_or_stroke_items(SPItem *sel, GSList *src, gboolean fill } else if (sel_paint->isPaintserver() && iter_paint->isPaintserver()) { SPPaintServer *sel_server = - (fillorstroke) ? sel->style->getFillPaintServer() : sel->style->getStrokePaintServer(); + (type == SP_FILL_COLOR) ? sel->style->getFillPaintServer() : sel->style->getStrokePaintServer(); SPPaintServer *iter_server = - (fillorstroke) ? iter->style->getFillPaintServer() : iter->style->getStrokePaintServer(); + (type == SP_FILL_COLOR) ? iter->style->getFillPaintServer() : iter->style->getStrokePaintServer(); if ((SP_IS_LINEARGRADIENT(sel_server) || SP_IS_RADIALGRADIENT(sel_server) || (SP_IS_GRADIENT(sel_server) && SP_GRADIENT(sel_server)->getVector()->isSwatch())) @@ -1726,6 +1767,66 @@ GSList *sp_get_same_fill_or_stroke_items(SPItem *sel, GSList *src, gboolean fill return matches; } +/* + * Find all items in src list that have the same stroke style as sel by type + * Return the list of matching items + */ +GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleType type) +{ + GSList *matches = NULL; + gboolean match = false; + + SPStyle *sel_style = sel->style; + + if (type == SP_FILL_COLOR || type == SP_STROKE_COLOR) { + return sp_get_same_fill_or_stroke_color(sel, src, type); + } + + for (GSList *i = src; i != NULL; i = i->next) { + SPItem *iter = SP_ITEM(i->data); + SPStyle *iter_style = iter->style; + match = false; + + if (type == SP_STROKE_STYLE_WIDTH) { + match = (sel_style->stroke_width.set == iter_style->stroke_width.set); + if (sel_style->stroke_width.set && iter_style->stroke_width.set) { + match = (sel_style->stroke_width.computed == iter_style->stroke_width.computed); + } + } + else if (type == SP_STROKE_STYLE_DASHES ) { + match = (sel_style->stroke_dasharray_set == iter_style->stroke_dasharray_set); + if (sel_style->stroke_dasharray_set && iter_style->stroke_dasharray_set) { + match = (sel_style->stroke_dash.n_dash == iter_style->stroke_dash.n_dash); + if (sel_style->stroke_dash.n_dash == iter_style->stroke_dash.n_dash) { + for (int i = 0; i < sel_style->stroke_dash.n_dash; i++) { + if (sel_style->stroke_dash.dash[i] != iter_style->stroke_dash.dash[i]) { + match = false; + break; + } + } + } + } + } + else if (type == SP_STROKE_STYLE_MARKERS) { + match = true; + int len = sizeof(sel_style->marker)/sizeof(SPIString); + for (int i = 0; i < len; i++) { + match = (sel_style->marker[i].set == iter_style->marker[i].set); + if (sel_style->marker[i].set && iter_style->marker[i].set && + (strcmp(sel_style->marker[i].value, iter_style->marker[i].value))) { + match = false; + break; + } + } + } + + if (match) { + matches = g_slist_prepend(matches, iter); + } + } + + return matches; +} // helper function: static diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 74f80b6af..ccb152602 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -37,8 +37,9 @@ namespace Inkscape { static void selectAllInAll(SPDesktop *desktop); static void selectNone(SPDesktop *desktop); static void selectSameFillStroke(SPDesktop *dt); - static void selectSameFill(SPDesktop *dt); - static void selectSameStroke(SPDesktop *dt); + static void selectSameFillColor(SPDesktop *dt); + static void selectSameStrokeColor(SPDesktop *dt); + static void selectSameStrokeStyle(SPDesktop *dt); static void invert(SPDesktop *desktop); static void invertAllInAll(SPDesktop *desktop); static void reverse(SPDesktop *dt); @@ -123,8 +124,18 @@ void sp_selection_next_patheffect_param(SPDesktop * dt); void sp_selection_edit_clip_or_mask(SPDesktop * dt, bool clip); -void sp_select_same_fill_stroke(SPDesktop *desktop, gboolean fill, gboolean stroke); -GSList *sp_get_same_fill_or_stroke_items(SPItem *sel, GSList *src, gboolean fillorstroke); +enum SPSelectStrokeStyleType { + SP_FILL_COLOR = 0, + SP_STROKE_COLOR = 1, + SP_STROKE_STYLE_WIDTH = 2, + SP_STROKE_STYLE_DASHES = 3, + SP_STROKE_STYLE_MARKERS = 4 +}; + +void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolean strok, gboolean style); +void sp_select_same_stroke_style(SPDesktop *desktop); +GSList *sp_get_same_fill_or_stroke_color(SPItem *sel, GSList *src, SPSelectStrokeStyleType type); +GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleType type); void scroll_to_show_item(SPDesktop *desktop, SPItem *item); diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index 672ac440d..ad47da68b 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -129,8 +129,12 @@ static void sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Select same fill and stroke */ w = gtk_menu_item_new_with_mnemonic(_("_Select Same Fill and Stroke")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_select_same_fill_stroke), item); + if (sp_desktop_selection(desktop)->isEmpty()) { + gtk_widget_set_sensitive(w, FALSE); + } else { + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_select_same_fill_stroke), item); + } gtk_widget_show(w); gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Create link */ @@ -272,7 +276,7 @@ static void sp_item_select_same_fill_stroke(GtkMenuItem *menuitem, SPItem * /*it SPDesktop *desktop = static_cast(g_object_get_data(G_OBJECT(menuitem), "desktop")); g_return_if_fail(desktop != NULL); - sp_select_same_fill_stroke(desktop, true, true); + sp_select_same_fill_stroke_style(desktop, true, true, true); } diff --git a/src/verbs.cpp b/src/verbs.cpp index ab16c6c93..913cec837 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -964,11 +964,14 @@ void EditVerb::perform(SPAction *action, void *data) case SP_VERB_EDIT_SELECT_SAME_FILL_STROKE: SelectionHelper::selectSameFillStroke(dt); break; - case SP_VERB_EDIT_SELECT_SAME_FILL: - SelectionHelper::selectSameFill(dt); + case SP_VERB_EDIT_SELECT_SAME_FILL_COLOR: + SelectionHelper::selectSameFillColor(dt); break; - case SP_VERB_EDIT_SELECT_SAME_STROKE: - SelectionHelper::selectSameStroke(dt); + case SP_VERB_EDIT_SELECT_SAME_STROKE_COLOR: + SelectionHelper::selectSameStrokeColor(dt); + break; + case SP_VERB_EDIT_SELECT_SAME_STROKE_STYLE: + SelectionHelper::selectSameStrokeStyle(dt); break; case SP_VERB_EDIT_INVERT: SelectionHelper::invert(dt); @@ -2297,12 +2300,14 @@ Verb *Verb::_base_verbs[] = { N_("Select all objects or all nodes"), GTK_STOCK_SELECT_ALL), new EditVerb(SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, "EditSelectAllInAllLayers", N_("Select All in All La_yers"), N_("Select all objects in all visible and unlocked layers"), INKSCAPE_ICON("edit-select-all-layers")), - new EditVerb(SP_VERB_EDIT_SELECT_SAME_FILL_STROKE, "EditSelectSameFillStroke", N_("S_ame Fill and Stroke"), + new EditVerb(SP_VERB_EDIT_SELECT_SAME_FILL_STROKE, "EditSelectSameFillStroke", N_("Fill _and Stroke"), N_("Select all objects with the same fill and stroke as the selected objects"), GTK_STOCK_SELECT_ALL), - new EditVerb(SP_VERB_EDIT_SELECT_SAME_FILL, "EditSelectSameFill", N_("Same _Fill"), + new EditVerb(SP_VERB_EDIT_SELECT_SAME_FILL_COLOR, "EditSelectSameFillColor", N_("_Fill Color"), N_("Select all objects with the same fill as the selected objects"), GTK_STOCK_SELECT_ALL), - new EditVerb(SP_VERB_EDIT_SELECT_SAME_STROKE, "EditSelectSameStroke", N_("Same _Stroke"), + new EditVerb(SP_VERB_EDIT_SELECT_SAME_STROKE_COLOR, "EditSelectSameStrokeColor", N_("_Stroke Color"), N_("Select all objects with the same stroke as the selected objects"), GTK_STOCK_SELECT_ALL), + new EditVerb(SP_VERB_EDIT_SELECT_SAME_STROKE_STYLE, "EditSelectSameStrokeStyle", N_("Stroke St_yle"), + N_("Select all objects with the same stroke style (width, dsh, markers) as the selected objects"), GTK_STOCK_SELECT_ALL), new EditVerb(SP_VERB_EDIT_INVERT, "EditInvert", N_("In_vert Selection"), N_("Invert selection (unselect what is selected and select everything else)"), INKSCAPE_ICON("edit-select-invert")), new EditVerb(SP_VERB_EDIT_INVERT_IN_ALL_LAYERS, "EditInvertInAllLayers", N_("Invert in All Layers"), diff --git a/src/verbs.h b/src/verbs.h index ec394b9a5..1a9efdb81 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -88,8 +88,9 @@ enum { SP_VERB_EDIT_SELECT_ALL, SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, SP_VERB_EDIT_SELECT_SAME_FILL_STROKE, - SP_VERB_EDIT_SELECT_SAME_FILL, - SP_VERB_EDIT_SELECT_SAME_STROKE, + SP_VERB_EDIT_SELECT_SAME_FILL_COLOR, + SP_VERB_EDIT_SELECT_SAME_STROKE_COLOR, + SP_VERB_EDIT_SELECT_SAME_STROKE_STYLE, SP_VERB_EDIT_INVERT, SP_VERB_EDIT_INVERT_IN_ALL_LAYERS, SP_VERB_EDIT_SELECT_NEXT, -- cgit v1.2.3 From 658f53f8f2e1352a37841ac3287e50e44856da7d Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 4 Apr 2012 20:11:46 +0200 Subject: gradient chemistry: fix null pointer dereference (bzr r11147) --- src/gradient-chemistry.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index b56352c19..a0da1e430 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -513,13 +513,16 @@ SPStop *sp_last_stop(SPGradient *gradient) SPStop *sp_get_stop_i(SPGradient *gradient, guint stop_i) { SPStop *stop = gradient->getFirstStop(); + if (!stop) { + return NULL; + } // if this is valid but weird gradient without an offset-zero stop element, // inkscape has created a handle for the start of gradient anyway, // so when it asks for stop N that corresponds to stop element N-1 if (stop->offset != 0) { - stop_i --; + stop_i--; } for (guint i = 0; i < stop_i; i++) { @@ -534,10 +537,10 @@ SPStop *sp_get_stop_i(SPGradient *gradient, guint stop_i) guint32 average_color(guint32 c1, guint32 c2, gdouble p) { - guint32 r = (guint32) (SP_RGBA32_R_U (c1) * (1 - p) + SP_RGBA32_R_U (c2) * p); - guint32 g = (guint32) (SP_RGBA32_G_U (c1) * (1 - p) + SP_RGBA32_G_U (c2) * p); - guint32 b = (guint32) (SP_RGBA32_B_U (c1) * (1 - p) + SP_RGBA32_B_U (c2) * p); - guint32 a = (guint32) (SP_RGBA32_A_U (c1) * (1 - p) + SP_RGBA32_A_U (c2) * p); + guint32 r = static_cast(SP_RGBA32_R_U (c1) * (1 - p) + SP_RGBA32_R_U (c2) * p); + guint32 g = static_cast(SP_RGBA32_G_U (c1) * (1 - p) + SP_RGBA32_G_U (c2) * p); + guint32 b = static_cast(SP_RGBA32_B_U (c1) * (1 - p) + SP_RGBA32_B_U (c2) * p); + guint32 a = static_cast(SP_RGBA32_A_U (c1) * (1 - p) + SP_RGBA32_A_U (c2) * p); return SP_RGBA32_U_COMPOSE(r, g, b, a); } -- cgit v1.2.3 From ca99e4b3f7e4c70921f6c5fe8c2f0ae192b73ea6 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 4 Apr 2012 20:14:59 +0200 Subject: png export dialog: memory leak fix (bzr r11148) --- src/ui/dialog/export.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 3068a2de7..649645aff 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -976,6 +976,16 @@ void Export::onExport () gchar const *filename = g_strdup(filename_entry.get_text().c_str()); + if (filename == NULL){ + sp_ui_error_dialog(_("You have to enter a filename")); + return; + } + if(*filename == '\0') { + g_free (const_cast(filename)); + sp_ui_error_dialog(_("You have to enter a filename")); + return; + } + float const x0 = getValuePx(x0_adj); float const y0 = getValuePx(y0_adj); float const x1 = getValuePx(x1_adj); @@ -985,19 +995,14 @@ void Export::onExport () unsigned long int const width = int(getValue(bmwidth_adj) + 0.5); unsigned long int const height = int(getValue(bmheight_adj) + 0.5); - if (filename == NULL || *filename == '\0') { - sp_ui_error_dialog(_("You have to enter a filename")); - return; - } - if (!((x1 > x0) && (y1 > y0) && (width > 0) && (height > 0))) { + g_free (const_cast(filename)); sp_ui_error_dialog (_("The chosen area to be exported is invalid")); return; } // make sure that .png is the extension of the file: gchar * filename_ext = filename_add_extension(filename, "png"); - //gtk_entry_set_text(GTK_ENTRY(filename_entry), filename_ext); filename_entry.set_text(filename_ext); gchar *path = absolutize_path_from_document_location(doc, filename_ext); @@ -1131,6 +1136,7 @@ void Export::onExport () break; } + g_free (const_cast(filename)); g_free (filename_ext); g_free (path); -- cgit v1.2.3 From d03872f4a6134627171a13e000c32648c412e100 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 4 Apr 2012 20:36:46 +0200 Subject: cppcheck (bzr r11149) --- src/ui/dialog/swatches.cpp | 6 +++--- src/ui/dialog/xml-tree.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 29492db55..a1768363c 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -420,11 +420,11 @@ void _loadPaletteFile( gchar const *filename ) inHeader = false; ptr = block; Glib::ustring name(""); - int r = 0; - int g = 0; - int b = 0; skipWhitespace(ptr); if ( *ptr ) { + int r = 0; + int g = 0; + int b = 0; hasErr = parseNum(ptr, r); if ( !hasErr ) { skipWhitespace(ptr); diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 51aea2935..357114626 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -513,7 +513,7 @@ void XmlTree::on_tree_select_row(GtkCTree *tree, gint /*column*/, gpointer data) { - XmlTree *self = (XmlTree *)data; + XmlTree *self = static_cast(data); Inkscape::XML::Node *repr = sp_xmlview_tree_node_get_repr(SP_XMLVIEW_TREE(tree), node); g_assert(repr != NULL); @@ -539,7 +539,7 @@ void XmlTree::on_tree_unselect_row(GtkCTree *tree, gint /*column*/, gpointer data) { - XmlTree *self = (XmlTree *)data; + XmlTree *self = static_cast(data); if (self->blocked) { return; @@ -569,7 +569,7 @@ void XmlTree::after_tree_move(GtkCTree */*tree*/, GtkCTreeNode *new_sibling, gpointer data) { - XmlTree *self = (XmlTree *)data; + XmlTree *self = static_cast(data); if (GTK_CTREE_ROW(node)->parent == new_parent && GTK_CTREE_ROW(node)->sibling == new_sibling) @@ -732,7 +732,7 @@ void XmlTree::on_tree_unselect_row_hide() void XmlTree::on_attr_select_row(GtkTreeSelection *selection, gpointer data) { - XmlTree *self = (XmlTree *)data; + XmlTree *self = static_cast(data); GtkTreeIter iter; GtkTreeModel *model; @@ -899,7 +899,7 @@ void XmlTree::cmd_new_element_node() gchar *new_name = g_strdup(name_entry->get_text().c_str()); - if (selected_repr != NULL && new_name) { + if (new_name) { Inkscape::XML::Document *xml_doc = current_document->getReprDoc(); Inkscape::XML::Node *new_repr; new_repr = xml_doc->createElement(new_name); -- cgit v1.2.3 From 5d0527f2493a9a011e41b3da786ca75974d8298d Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 4 Apr 2012 21:54:02 +0200 Subject: UI. Fix for Bug #437521 (Save As dialog should be resizable in Windows) by Jaroslaw M. Gliwinski. (bzr r11150) --- src/ui/dialog/filedialogimpl-win32.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 7dd619fa6..75c8b4b8a 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -1714,7 +1714,7 @@ void FileSaveDialogImplWin32::GetSaveFileName_thread() ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = current_directory_string; ofn.lpstrTitle = _title; - ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ENABLEHOOK; + ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_ENABLESIZING; ofn.lpstrFilter = _filter; ofn.nFilterIndex = _filter_index; ofn.lpfnHook = GetSaveFileName_hookproc; -- cgit v1.2.3 From 0d90c087fb79f1de6307b22b8f685776516f3802 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 4 Apr 2012 22:05:31 +0200 Subject: OCAL. Fix brush icon crash (see Bug #943275) by Jaroslaw M. Gliwinski. (bzr r11151) --- src/ui/dialog/ocaldialogs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index 4da9fa5b4..a08e80f8d 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -536,7 +536,7 @@ void SearchEntry::_on_icon_pressed(Gtk::EntryIconPosition icon_position, const G { if (icon_position == Gtk::ENTRY_ICON_SECONDARY) { grab_focus(); - set_text(""); + delete_text(0, -1); } else if (icon_position == Gtk::ENTRY_ICON_PRIMARY) { select_region(0, -1); grab_focus(); -- cgit v1.2.3 From ea872b0823a6e55c0a23972c4faea1593e077594 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 4 Apr 2012 22:23:33 +0200 Subject: c++ification: GHashTable > std::map (bug #970237 ; patch by Samuel Chase + some additional modifications) (bzr r11152) --- src/svg/itos.cpp | 2 +- src/svg/svg-color.cpp | 87 ++++++++++++++++++++++++--------------------------- 2 files changed, 42 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/svg/itos.cpp b/src/svg/itos.cpp index 0f2c64ec4..ff7ca516c 100644 --- a/src/svg/itos.cpp +++ b/src/svg/itos.cpp @@ -18,7 +18,7 @@ #include // for string #include -using namespace std; +using std::string; string itos(int n) { diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp index 705e2a76f..e045a23c7 100644 --- a/src/svg/svg-color.cpp +++ b/src/svg/svg-color.cpp @@ -24,6 +24,8 @@ #include // g_assert #include +#include + #include "strneq.h" #include "preferences.h" #include "svg-color.h" @@ -39,11 +41,12 @@ #include "cms-system.h" using std::sprintf; +using std::string; using Inkscape::CMSSystem; struct SPSVGColor { unsigned long rgb; - char const *name; + const string name; }; /* @@ -199,18 +202,16 @@ static SPSVGColor const sp_svg_color_named[] = { { 0x9ACD32, "yellowgreen" } }; -static GHashTable *sp_svg_create_color_hash(); +static std::map sp_svg_create_color_hash(); -guint32 -sp_svg_read_color(gchar const *str, guint32 const dfl) +guint32 sp_svg_read_color(gchar const *str, guint32 const dfl) { return sp_svg_read_color(str, NULL, dfl); } -static guint32 -internal_sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 def) +static guint32 internal_sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 def) { - static GHashTable *colors = NULL; + static std::map colors; guint32 val = 0; if (str == NULL) return def; @@ -295,13 +296,13 @@ internal_sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 def) ++s; if (hasp && hasd) return def; if (hasp) { - val = (guint) floor(CLAMP(r, 0.0, 100.0) * 2.559999) << 24; - val |= ((guint) floor(CLAMP(g, 0.0, 100.0) * 2.559999) << 16); - val |= ((guint) floor(CLAMP(b, 0.0, 100.0) * 2.559999) << 8); + val = static_cast(floor(CLAMP(r, 0.0, 100.0) * 2.559999)) << 24; + val |= (static_cast(floor(CLAMP(g, 0.0, 100.0) * 2.559999)) << 16); + val |= (static_cast(floor(CLAMP(b, 0.0, 100.0) * 2.559999)) << 8); } else { - val = (guint) CLAMP(r, 0, 255) << 24; - val |= ((guint) CLAMP(g, 0, 255) << 16); - val |= ((guint) CLAMP(b, 0, 255) << 8); + val = static_cast(CLAMP(r, 0, 255)) << 24; + val |= (static_cast(CLAMP(g, 0, 255)) << 16); + val |= (static_cast(CLAMP(b, 0, 255)) << 8); } if (end_ptr) { *end_ptr = s; @@ -309,7 +310,7 @@ internal_sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 def) return val; } else { gint i; - if (!colors) { + if (colors.empty()) { colors = sp_svg_create_color_hash(); } gchar c[32]; @@ -323,10 +324,10 @@ internal_sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 def) } c[31] = '\0'; - gpointer const rgb_ptr = g_hash_table_lookup(colors, c); - if (rgb_ptr) { - val = *(static_cast(rgb_ptr)); - } else { + if (colors.count(string(c))) { + val = colors[string(c)]; + } + else { return def; } if (end_ptr) { @@ -337,8 +338,7 @@ internal_sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 def) return (val << 8); } -guint32 -sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 dfl) +guint32 sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 dfl) { /* I've been rather hurried in editing the above to add support for end_ptr, so I'm adding * this check wrapper. */ @@ -369,8 +369,7 @@ sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 dfl) * Converts an RGB colour expressed in form 0x00rrggbb to a CSS/SVG representation of that colour. * The result is valid even in SVG Tiny or non-SVG CSS. */ -static void -rgb24_to_css(char *const buf, unsigned const rgb24) +static void rgb24_to_css(char *const buf, unsigned const rgb24) { assert(rgb24 < (1u << 24)); @@ -385,22 +384,22 @@ rgb24_to_css(char *const buf, unsigned const rgb24) switch (rgb24) { /* Extracted mechanically from the table at * http://www.w3.org/TR/REC-html40/types.html#h-6.5 .*/ - case 0x000000: src = "black"; break; - case 0xc0c0c0: src = "silver"; break; - case 0x808080: src = "gray"; break; - case 0xffffff: src = "white"; break; - case 0x800000: src = "maroon"; break; - case 0xff0000: src = "red"; break; - case 0x800080: src = "purple"; break; - case 0xff00ff: src = "fuchsia"; break; - case 0x008000: src = "green"; break; - case 0x00ff00: src = "lime"; break; - case 0x808000: src = "olive"; break; + case 0x000000: src = "black"; break; + case 0xc0c0c0: src = "silver"; break; + case 0x808080: src = "gray"; break; + case 0xffffff: src = "white"; break; + case 0x800000: src = "maroon"; break; + case 0xff0000: src = "red"; break; + case 0x800080: src = "purple"; break; + case 0xff00ff: src = "fuchsia"; break; + case 0x008000: src = "green"; break; + case 0x00ff00: src = "lime"; break; + case 0x808000: src = "olive"; break; case 0xffff00: src = "yellow"; break; - case 0x000080: src = "navy"; break; - case 0x0000ff: src = "blue"; break; - case 0x008080: src = "teal"; break; - case 0x00ffff: src = "aqua"; break; + case 0x000080: src = "navy"; break; + case 0x0000ff: src = "blue"; break; + case 0x008080: src = "teal"; break; + case 0x00ffff: src = "aqua"; break; default: { if ((rgb24 & 0xf0f0f) * 0x11 == rgb24) { @@ -429,8 +428,7 @@ rgb24_to_css(char *const buf, unsigned const rgb24) * \param rgba32 Colour expressed in form 0xrrggbbaa. * \pre buflen \>= 8. */ -void -sp_svg_write_color(gchar *buf, unsigned const buflen, guint32 const rgba32) +void sp_svg_write_color(gchar *buf, unsigned const buflen, guint32 const rgba32) { g_assert(8 <= buflen); @@ -443,17 +441,14 @@ sp_svg_write_color(gchar *buf, unsigned const buflen, guint32 const rgba32) } } -static GHashTable * +static std::map sp_svg_create_color_hash() { - GHashTable *colors = g_hash_table_new(g_str_hash, g_str_equal); + std::map colors; for (unsigned i = 0 ; i < G_N_ELEMENTS(sp_svg_color_named) ; i++) { - g_hash_table_insert(colors, - (gpointer)(sp_svg_color_named[i].name), - (gpointer)(&sp_svg_color_named[i].rgb)); + colors[sp_svg_color_named[i].name] = sp_svg_color_named[i].rgb; } - return colors; } @@ -480,7 +475,7 @@ g_message("profile name: %s", icc->colorProfile.c_str()); count = 4; //do we need it? Should we allow an arbitrary number of color values? Or should we limit to a maximum? (max==4?) } for (gint i = 0; i < count; i++){ - color_in[i] = (guchar) ((((gdouble)icc->colors[i])*256.0) * (gdouble)scales[i]); + color_in[i] = static_cast((((gdouble)icc->colors[i])*256.0) * (gdouble)scales[i]); g_message("input[%d]: %d",i, color_in[i]); } -- cgit v1.2.3 From 9ff6ffd913086ac953e79231c2a3345f997589fe Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 5 Apr 2012 07:06:43 +0200 Subject: Clipboard code cleaning (patch for bug #964852 by Romain, see devmail thread "Some clipboard functions") (bzr r11153) --- src/document.cpp | 22 ++++++ src/document.h | 2 + src/file.cpp | 84 +++++++++++++++++++++++ src/file.h | 2 + src/ui/clipboard.cpp | 185 ++------------------------------------------------- src/xml/repr-css.cpp | 71 ++++++++++++++++++++ src/xml/repr.h | 1 + 7 files changed, 187 insertions(+), 180 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 18d714bad..7b68dd499 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -48,6 +48,7 @@ #include "document-private.h" #include "document-undo.h" #include "helper/units.h" +#include "id-clash.h" #include "inkscape-private.h" #include "inkscape-version.h" #include "libavoid/router.h" @@ -1432,6 +1433,27 @@ void SPDocument::setModifiedSinceSave(bool modified) { dtw->updateTitle( this->getName() ); } + +/** + * Paste SVG defs from the document retrieved from the clipboard into the active document. + * @param clipdoc The document to paste. + * @pre @c clipdoc != NULL and pasting into the active document is possible. + */ +void SPDocument::importDefs(SPDocument *source) +{ + Inkscape::XML::Node *root = source->getReprRoot(); + Inkscape::XML::Node *defs = sp_repr_lookup_name(root, "svg:defs", 1); + Inkscape::XML::Node *target_defs = this->getDefs()->getRepr(); + + prevent_id_clashes(source, this); + + for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { + Inkscape::XML::Node * dup = def->duplicate(this->getReprDoc()); + target_defs->appendChild(dup); + Inkscape::GC::release(dup); + } +} + /* Local Variables: mode:c++ diff --git a/src/document.h b/src/document.h index e41ec4d59..ca709a8b6 100644 --- a/src/document.h +++ b/src/document.h @@ -247,6 +247,8 @@ public: unsigned int vacuumDocument(); + void importDefs(SPDocument *source); + private: void do_change_uri(gchar const *const filename, bool const rebase); void setupViewport(SPItemCtx *ctx); diff --git a/src/file.cpp b/src/file.cpp index dbf8fc7d4..88fbc542d 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -36,6 +36,7 @@ #include "dir-util.h" #include "document-private.h" #include "document-undo.h" +#include "event-context.h" #include "extension/db.h" #include "extension/input.h" #include "extension/output.h" @@ -973,6 +974,89 @@ sp_file_save_a_copy(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d ## I M P O R T ######################*/ +/** + * Paste the contents of a document into the active desktop. + * @param clipdoc The document to paste + * @param in_place Whether to paste the selection where it was when copied + * @pre @c clipdoc is not empty and items can be added to the current layer + */ +void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) +{ + //TODO: merge with file_import() + + SPDocument *target_document = sp_desktop_document(desktop); + Inkscape::XML::Node *root = clipdoc->getReprRoot(); + Inkscape::XML::Node *target_parent = desktop->currentLayer()->getRepr(); + + // copy definitions + desktop->doc()->importDefs(clipdoc); + + // copy objects + GSList *pasted_objects = NULL; + for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) { + // Don't copy metadata, defs, named views and internal clipboard contents to the document + if (!strcmp(obj->name(), "svg:defs")) { + continue; + } + if (!strcmp(obj->name(), "svg:metadata")) { + continue; + } + if (!strcmp(obj->name(), "sodipodi:namedview")) { + continue; + } + if (!strcmp(obj->name(), "inkscape:clipboard")) { + continue; + } + Inkscape::XML::Node *obj_copy = obj->duplicate(target_document->getReprDoc()); + target_parent->appendChild(obj_copy); + Inkscape::GC::release(obj_copy); + + pasted_objects = g_slist_prepend(pasted_objects, (gpointer) obj_copy); + } + + // Change the selection to the freshly pasted objects + Inkscape::Selection *selection = sp_desktop_selection(desktop); + selection->setReprList(pasted_objects); + + // invers apply parent transform + Geom::Affine doc2parent = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); + sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false); + + // Update (among other things) all curves in paths, for bounds() to work + target_document->ensureUpToDate(); + + // move selection either to original position (in_place) or to mouse pointer + Geom::OptRect sel_bbox = selection->visualBounds(); + if (sel_bbox) { + // get offset of selection to original position of copied elements + Geom::Point pos_original; + Inkscape::XML::Node *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1); + if (clipnode) { + Geom::Point min, max; + sp_repr_get_point(clipnode, "min", &min); + sp_repr_get_point(clipnode, "max", &max); + pos_original = Geom::Point(min[Geom::X], max[Geom::Y]); + } + Geom::Point offset = pos_original - sel_bbox->corner(3); + + if (!in_place) { + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop); + sp_event_context_discard_delayed_snap_event(desktop->event_context); + + // get offset from mouse pointer to bbox center, snap to grid if enabled + Geom::Point mouse_offset = desktop->point() - sel_bbox->midpoint(); + offset = m.multipleOfGridPitch(mouse_offset - offset, sel_bbox->midpoint() + offset) + offset; + m.unSetup(); + } + + sp_selection_move_relative(selection, offset); + } + + g_slist_free(pasted_objects); +} + + /** * Import a resource. Called by sp_file_import() */ diff --git a/src/file.h b/src/file.h index cd6de2eb1..4d28e57d8 100644 --- a/src/file.h +++ b/src/file.h @@ -117,6 +117,8 @@ bool sp_file_save_dialog (Gtk::Window &parentWindow, SPDocument *doc, Inkscape:: ## I M P O R T ######################*/ +void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place); + /** * Displays a file selector dialog, to allow the * user to import data into the current document. diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index b9d6e0c6b..b972997e2 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -70,12 +70,11 @@ #include "live_effects/lpeobject-reference.h" #include "live_effects/parameter/path.h" #include "svg/svg.h" // for sp_svg_transform_write, used in _copySelection -#include "svg/css-ostringstream.h" // used in _parseColor +#include "svg/css-ostringstream.h" // used in copy #include "text-context.h" #include "text-editing.h" #include "tools-switch.h" #include "path-chemistry.h" -#include "id-clash.h" #include "unit-constants.h" #include "helper/png-write.h" #include "svg/svg-color.h" @@ -129,11 +128,8 @@ private: void _copyTextPath(SPTextPath *); Inkscape::XML::Node *_copyNode(Inkscape::XML::Node *, Inkscape::XML::Document *, Inkscape::XML::Node *); - void _pasteDocument(SPDesktop *desktop, SPDocument *clipdoc, bool in_place); - void _pasteDefs(SPDesktop *desktop, SPDocument *clipdoc); bool _pasteImage(SPDocument *doc); bool _pasteText(SPDesktop *desktop); - SPCSSAttr *_parseColor(const Glib::ustring &); void _applyPathEffect(SPItem *, gchar const *); SPDocument *_retrieveClipboard(Glib::ustring = ""); @@ -334,7 +330,7 @@ bool ClipboardManagerImpl::paste(SPDesktop *desktop, bool in_place) return false; } - _pasteDocument(desktop, tempdoc, in_place); + sp_import_document(desktop, tempdoc, in_place); tempdoc->doUnref(); return true; @@ -410,7 +406,7 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop) bool pasted = false; if (clipnode) { - _pasteDefs(desktop, tempdoc); + desktop->doc()->importDefs(tempdoc); SPCSSAttr *style = sp_repr_css_attr(clipnode, "style"); sp_desktop_set_style(desktop, style); pasted = true; @@ -512,7 +508,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) if ( clipnode ) { gchar const *effectstack = clipnode->attribute("inkscape:path-effect"); if ( effectstack ) { - _pasteDefs(desktop, tempdoc); + desktop->doc()->importDefs(tempdoc); // make sure all selected items are converted to paths first (i.e. rectangles) sp_selected_to_lpeitems(desktop); for (GSList *itemptr = const_cast(selection->itemList()) ; itemptr ; itemptr = itemptr->next) { @@ -802,107 +798,6 @@ Inkscape::XML::Node *ClipboardManagerImpl::_copyNode(Inkscape::XML::Node *node, } -/** - * Paste the contents of a document into the active desktop. - * @param clipdoc The document to paste - * @param in_place Whether to paste the selection where it was when copied - * @pre @c clipdoc is not empty and items can be added to the current layer - */ -void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) -{ - SPDocument *target_document = sp_desktop_document(desktop); - Inkscape::XML::Node *root = clipdoc->getReprRoot(); - Inkscape::XML::Node *target_parent = desktop->currentLayer()->getRepr(); - Inkscape::XML::Document *target_xmldoc = target_document->getReprDoc(); - - // copy definitions - _pasteDefs(desktop, clipdoc); - - // copy objects - GSList *pasted_objects = NULL; - for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) { - // Don't copy metadata, defs, named views and internal clipboard contents to the document - if (!strcmp(obj->name(), "svg:defs")) { - continue; - } - if (!strcmp(obj->name(), "svg:metadata")) { - continue; - } - if (!strcmp(obj->name(), "sodipodi:namedview")) { - continue; - } - if (!strcmp(obj->name(), "inkscape:clipboard")) { - continue; - } - Inkscape::XML::Node *obj_copy = _copyNode(obj, target_xmldoc, target_parent); - pasted_objects = g_slist_prepend(pasted_objects, (gpointer) obj_copy); - } - - // Change the selection to the freshly pasted objects - Inkscape::Selection *selection = sp_desktop_selection(desktop); - selection->setReprList(pasted_objects); - - // invers apply parent transform - Geom::Affine doc2parent = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); - sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false); - - // Update (among other things) all curves in paths, for bounds() to work - target_document->ensureUpToDate(); - - // move selection either to original position (in_place) or to mouse pointer - Geom::OptRect sel_bbox = selection->visualBounds(); - if (sel_bbox) { - // get offset of selection to original position of copied elements - Geom::Point pos_original; - Inkscape::XML::Node *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1); - if (clipnode) { - Geom::Point min, max; - sp_repr_get_point(clipnode, "min", &min); - sp_repr_get_point(clipnode, "max", &max); - pos_original = Geom::Point(min[Geom::X], max[Geom::Y]); - } - Geom::Point offset = pos_original - sel_bbox->corner(3); - - if (!in_place) { - SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop); - sp_event_context_discard_delayed_snap_event(desktop->event_context); - - // get offset from mouse pointer to bbox center, snap to grid if enabled - Geom::Point mouse_offset = desktop->point() - sel_bbox->midpoint(); - offset = m.multipleOfGridPitch(mouse_offset - offset, sel_bbox->midpoint() + offset) + offset; - m.unSetup(); - } - - sp_selection_move_relative(selection, offset); - } - - g_slist_free(pasted_objects); -} - - -/** - * Paste SVG defs from the document retrieved from the clipboard into the active document. - * @param clipdoc The document to paste. - * @pre @c clipdoc != NULL and pasting into the active document is possible. - */ -void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc) -{ - // boilerplate vars copied from _pasteDocument - SPDocument *target_document = sp_desktop_document(desktop); - Inkscape::XML::Node *root = clipdoc->getReprRoot(); - Inkscape::XML::Node *defs = sp_repr_lookup_name(root, "svg:defs", 1); - Inkscape::XML::Node *target_defs = target_document->getDefs()->getRepr(); - Inkscape::XML::Document *target_xmldoc = target_document->getReprDoc(); - - prevent_id_clashes(clipdoc, target_document); - - for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { - _copyNode(def, target_xmldoc, target_defs); - } -} - - /** * Retrieve a bitmap image from the clipboard and paste it into the active document. */ @@ -957,7 +852,7 @@ bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop) } // try to parse the text as a color and, if successful, apply it as the current style - SPCSSAttr *css = _parseColor(_clipboard->wait_for_text()); + SPCSSAttr *css = sp_repr_css_attr_parse_color_to_fill(_clipboard->wait_for_text()); if (css) { sp_desktop_set_style(desktop, css); return true; @@ -967,76 +862,6 @@ bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop) } -/** - * Attempt to parse the passed string as a hexadecimal RGB or RGBA color. - * @param text The Glib::ustring to parse - * @return New CSS style representation if the parsing was successful, NULL otherwise - */ -SPCSSAttr *ClipboardManagerImpl::_parseColor(const Glib::ustring &text) -{ -// TODO reuse existing code instead of replicating here. - Glib::ustring::size_type len = text.bytes(); - char *str = const_cast(text.data()); - bool attempt_alpha = false; - if ( !str || ( *str == '\0' ) ) { - return NULL; // this is OK due to boolean short-circuit - } - - // those conditionals guard against parsing e.g. the string "fab" as "fab000" - // (incomplete color) and "45fab71" as "45fab710" (incomplete alpha) - if ( *str == '#' ) { - if ( len < 7 ) { - return NULL; - } - if ( len >= 9 ) { - attempt_alpha = true; - } - } else { - if ( len < 6 ) { - return NULL; - } - if ( len >= 8 ) { - attempt_alpha = true; - } - } - - unsigned int color = 0, alpha = 0xff; - - // skip a leading #, if present - if ( *str == '#' ) { - ++str; - } - - // try to parse first 6 digits - int res = sscanf(str, "%6x", &color); - if ( res && ( res != EOF ) ) { - if (attempt_alpha) {// try to parse alpha if there's enough characters - sscanf(str + 6, "%2x", &alpha); - if ( !res || res == EOF ) { - alpha = 0xff; - } - } - - SPCSSAttr *color_css = sp_repr_css_attr_new(); - - // print and set properties - gchar color_str[16]; - g_snprintf(color_str, 16, "#%06x", color); - sp_repr_css_set_property(color_css, "fill", color_str); - - float opacity = static_cast(alpha)/static_cast(0xff); - if (opacity > 1.0) { - opacity = 1.0; // safeguard - } - Inkscape::CSSOStringStream opcss; - opcss << opacity; - sp_repr_css_set_property(color_css, "fill-opacity", opcss.str().data()); - return color_css; - } - return NULL; -} - - /** * Applies a pasted path effect to a given item. */ diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index 4fb1223de..19f3f1d6c 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -89,6 +89,77 @@ SPCSSAttr *sp_repr_css_attr(Node *repr, gchar const *attr) return css; } + +/** + * Attempt to parse the passed string as a hexadecimal RGB or RGBA color. + * @param text The Glib::ustring to parse + * @return New CSS style representation if the parsing was successful, NULL otherwise + */ +SPCSSAttr *sp_repr_css_attr_parse_color_to_fill(const Glib::ustring &text) +{ +// TODO reuse existing code instead of replicating here. + Glib::ustring::size_type len = text.bytes(); + char *str = const_cast(text.data()); + bool attempt_alpha = false; + if ( !str || ( *str == '\0' ) ) { + return NULL; // this is OK due to boolean short-circuit + } + + // those conditionals guard against parsing e.g. the string "fab" as "fab000" + // (incomplete color) and "45fab71" as "45fab710" (incomplete alpha) + if ( *str == '#' ) { + if ( len < 7 ) { + return NULL; + } + if ( len >= 9 ) { + attempt_alpha = true; + } + } else { + if ( len < 6 ) { + return NULL; + } + if ( len >= 8 ) { + attempt_alpha = true; + } + } + + unsigned int color = 0, alpha = 0xff; + + // skip a leading #, if present + if ( *str == '#' ) { + ++str; + } + + // try to parse first 6 digits + int res = sscanf(str, "%6x", &color); + if ( res && ( res != EOF ) ) { + if (attempt_alpha) {// try to parse alpha if there's enough characters + sscanf(str + 6, "%2x", &alpha); + if ( !res || res == EOF ) { + alpha = 0xff; + } + } + + SPCSSAttr *color_css = sp_repr_css_attr_new(); + + // print and set properties + gchar color_str[16]; + g_snprintf(color_str, 16, "#%06x", color); + sp_repr_css_set_property(color_css, "fill", color_str); + + float opacity = static_cast(alpha)/static_cast(0xff); + if (opacity > 1.0) { + opacity = 1.0; // safeguard + } + Inkscape::CSSOStringStream opcss; + opcss << opacity; + sp_repr_css_set_property(color_css, "fill-opacity", opcss.str().data()); + return color_css; + } + return NULL; +} + + /** * Adds an attribute to an existing SPCSAttr with the cascaded value including all parents. */ diff --git a/src/xml/repr.h b/src/xml/repr.h index 3eee45385..86a798e3e 100644 --- a/src/xml/repr.h +++ b/src/xml/repr.h @@ -70,6 +70,7 @@ bool sp_repr_save_rebased_file(Inkscape::XML::Document *doc, gchar const *filena SPCSSAttr *sp_repr_css_attr_new(void); void sp_repr_css_attr_unref(SPCSSAttr *css); SPCSSAttr *sp_repr_css_attr(Inkscape::XML::Node *repr, gchar const *attr); +SPCSSAttr *sp_repr_css_attr_parse_color_to_fill(const Glib::ustring &text); SPCSSAttr *sp_repr_css_attr_inherited(Inkscape::XML::Node *repr, gchar const *attr); gchar const *sp_repr_css_property(SPCSSAttr *css, gchar const *name, gchar const *defval); -- cgit v1.2.3 From d33c52d48976eb35121b538178b11bb1247c527b Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 5 Apr 2012 21:34:48 +0900 Subject: Fix for 170378 : Select same objects by fill or stroke : Fix transformed stroke width (bzr r11154) --- src/selection-chemistry.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 2fe3b343f..f481a5337 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1782,6 +1782,18 @@ GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleTy return sp_get_same_fill_or_stroke_color(sel, src, type); } + /* + * Stroke width needs to handle transformations, so call this function + * to get the transformed stroke width + */ + GSList *objects = NULL; + SPStyle *sel_style_for_width = NULL; + if (type == SP_STROKE_STYLE_WIDTH) { + objects = g_slist_prepend(objects, sel); + sel_style_for_width = sp_style_new (SP_ACTIVE_DOCUMENT); + objects_query_strokewidth (objects, sel_style_for_width); + } + for (GSList *i = src; i != NULL; i = i->next) { SPItem *iter = SP_ITEM(i->data); SPStyle *iter_style = iter->style; @@ -1790,7 +1802,15 @@ GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleTy if (type == SP_STROKE_STYLE_WIDTH) { match = (sel_style->stroke_width.set == iter_style->stroke_width.set); if (sel_style->stroke_width.set && iter_style->stroke_width.set) { - match = (sel_style->stroke_width.computed == iter_style->stroke_width.computed); + GSList *objects = NULL; + objects = g_slist_prepend(objects, iter); + SPStyle *iter_style_for_width = sp_style_new (SP_ACTIVE_DOCUMENT); + objects_query_strokewidth (objects, iter_style_for_width); + + if (sel_style_for_width) { + match = (sel_style_for_width->stroke_width.computed == iter_style_for_width->stroke_width.computed); + } + g_slist_free(objects); } } else if (type == SP_STROKE_STYLE_DASHES ) { @@ -1825,6 +1845,8 @@ GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleTy } } + g_slist_free(objects); + return matches; } -- cgit v1.2.3 From 009aaef8060460f8ccdaf3d9dc7db0b227f684fa Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 5 Apr 2012 19:45:27 +0200 Subject: add NULL checks to perhaps fix bug 970105 Fixed bugs: - https://launchpad.net/bugs/970105 (bzr r11156) --- src/interface.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index 493ffa32f..1e1324e32 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1585,19 +1585,21 @@ sp_ui_overwrite_file(gchar const *filename) static void sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name) { - void *child = gtk_bin_get_child (GTK_BIN (data)); - //child is either - //- a GtkHBox, whose first child is a label displaying name if the menu - //item has an accel key - //- a GtkLabel if the menu has no accel key - if (GTK_IS_LABEL(child)) { - 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), - name.c_str()); - }//else sp_ui_menu_append_item_from_verb has been modified and can set - //a menu item in yet another way... + if (data || GTK_IS_BIN (data)) { + void *child = gtk_bin_get_child (GTK_BIN (data)); + //child is either + //- a GtkHBox, whose first child is a label displaying name if the menu + //item has an accel key + //- a GtkLabel if the menu has no accel key + if (GTK_IS_LABEL(child)) { + 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), + name.c_str()); + }//else sp_ui_menu_append_item_from_verb has been modified and can set + //a menu item in yet another way... + } } void injectRenamedIcons() -- cgit v1.2.3 From 59550e355d8938842f3c0816ec9711c43080a051 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 5 Apr 2012 20:02:40 +0200 Subject: fix crash (bug #941317) Fixed bugs: - https://launchpad.net/bugs/941317 (bzr r11157) --- src/sp-gradient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 0934c0705..1a99485f6 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -1018,7 +1018,7 @@ void SPGradient::rebuildVector() vector.stops.clear(); - SPGradient *reffed = ref->getObject(); + SPGradient *reffed = ref ? ref->getObject() : NULL; if ( !hasStops() && reffed ) { /* Copy vector from referenced gradient */ vector.built = true; // Prevent infinite recursion. -- cgit v1.2.3 From 5ac6a630720ce6800dea0f253f3895b4ade412fd Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 5 Apr 2012 20:11:37 +0200 Subject: fix crash (bug #973174) Fixed bugs: - https://launchpad.net/bugs/973174 (bzr r11158) --- src/file.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index 88fbc542d..0657f0b10 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -860,10 +860,11 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens g_warning( "Error converting save filename to UTF-8." ); Inkscape::Extension::Output *omod = dynamic_cast(selectionType); - Glib::ustring save_extension = (std::string)omod->get_extension(); - - if ( !hasEnding(fileName, save_extension.c_str()) ) { - fileName += save_extension.c_str(); + if (omod) { + Glib::ustring save_extension = (std::string)omod->get_extension(); + if ( !hasEnding(fileName, save_extension.c_str()) ) { + fileName += save_extension.c_str(); + } } // FIXME: does the argument !is_copy really convey the correct meaning here? -- cgit v1.2.3 From 4c88966ad38b4365401f45401b3cab38c9eea86e Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 5 Apr 2012 21:09:24 +0200 Subject: add test code for bug #967416 (bzr r11159) --- src/file.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index 0657f0b10..2ce532f03 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -643,6 +643,17 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri, return FALSE; } + if (SP_ACTIVE_DESKTOP) { + if (! SP_ACTIVE_DESKTOP->event_log) { + g_message("file_save: ->event_log == NULL. please report to bug #967416"); + } + if (! SP_ACTIVE_DESKTOP->messageStack()) { + g_message("file_save: ->messageStack() == NULL. please report to bug #967416"); + } + } else { + g_message("file_save: SP_ACTIVE_DESKTOP == NULL. please report to bug #967416"); + } + SP_ACTIVE_DESKTOP->event_log->rememberFileSave(); SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Document saved.")); return true; -- cgit v1.2.3 From bcd804c6c383e2964b072257da282d9a91db7d16 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 5 Apr 2012 22:14:44 +0200 Subject: C++ify context menu: - c++ified context-menu.cpp (and included in interface.cpp) - removed dozens of pointer conversions (of which some were erroneous) - fixed a memory leak - added some null pointer checks to prevent crashes (bzr r11160) --- src/doxygen-main.cpp | 2 +- src/event-context.cpp | 14 +- src/interface.cpp | 792 +++++++++++++++++++++++++++++++++++++++++------- src/interface.h | 61 +++- src/ui/CMakeLists.txt | 2 - src/ui/Makefile_insert | 2 - src/ui/context-menu.cpp | 715 ------------------------------------------- src/ui/context-menu.h | 36 --- 8 files changed, 751 insertions(+), 873 deletions(-) delete mode 100644 src/ui/context-menu.cpp delete mode 100644 src/ui/context-menu.h (limited to 'src') diff --git a/src/doxygen-main.cpp b/src/doxygen-main.cpp index ea4d056ce..70c62b3a9 100644 --- a/src/doxygen-main.cpp +++ b/src/doxygen-main.cpp @@ -305,7 +305,7 @@ namespace XML {} * [\ref help.cpp] [\ref inkscape.cpp] [\ref inkscape-stock.cpp] * [\ref interface.cpp, \ref memeq.h] [\ref main.cpp, \ref winmain.cpp] * [\ref menus-skeleton.h, \ref preferences-skeleton.h] - * [\ref context-menu.cpp] [\ref select-toolbar.cpp] [\ref shortcuts.cpp] + * [\ref select-toolbar.cpp] [\ref shortcuts.cpp] * [\ref sp-cursor.cpp] [\ref text-edit.cpp] [\ref toolbox.cpp, \ref ui/widget/toolbox.cpp] * Inkscape::Verb [\ref verbs.h] * diff --git a/src/event-context.cpp b/src/event-context.cpp index 0cfa18f57..4ea4068fe 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -6,8 +6,9 @@ * Frank Felfe * bulia byak * Jon A. Cruz + * Kris De Gussem * - * Copyright (C) 1999-2010 authors + * Copyright (C) 1999-2012 authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -1034,22 +1035,19 @@ static void set_event_location(SPDesktop *desktop, GdkEvent *event) { * Create popup menu and tell Gtk to show it. */ void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event) { - GtkWidget *menu; - /* fixme: This is not what I want but works for now (Lauris) */ if (event->type == GDK_KEY_PRESS) { item = sp_desktop_selection(desktop)->singleItem(); } - menu = sp_ui_context_menu(desktop, item); - gtk_widget_show(menu); + ContextMenu* CM = new ContextMenu(desktop, item); + CM->show(); switch (event->type) { case GDK_BUTTON_PRESS: - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 0, NULL, - event->button.button, event->button.time); + CM->popup(event->button.button, event->button.time); break; case GDK_KEY_PRESS: - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 0, NULL, 0, event->key.time); + CM->popup(0, event->key.time); break; default: break; diff --git a/src/interface.cpp b/src/interface.cpp index 1e1324e32..77ef9a075 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -8,11 +8,13 @@ * bulia byak * Jon A. Cruz * Abhishek Sharma + * Kris De Gussem * + * Copyright (C) 2012 Kris De Gussem * Copyright (C) 2010 authors * Copyright (C) 1999-2005 authors - * Copyright (C) 2001-2002 Ximian, Inc. * Copyright (C) 2004 David Turner + * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -37,7 +39,6 @@ #include "desktop-handles.h" #include "interface.h" #include "desktop.h" -#include "ui/context-menu.h" #include "selection.h" #include "selection-chemistry.h" #include "svg-view-widget.h" @@ -66,6 +67,16 @@ #include "gradient-drag.h" #include "widgets/ege-paint-def.h" #include "document-undo.h" +#include "sp-anchor.h" +#include "sp-clippath.h" +#include "sp-image.h" +#include "sp-item.h" +#include "sp-mask.h" +// #include "verbs.h" +#include "message-stack.h" +// #include "inkscape.h" +#include "ui/dialog/dialog-manager.h" +// #include "../xml/repr.h" #include #include @@ -296,9 +307,9 @@ void sp_ui_new_view_preview() void sp_ui_close_view(GtkWidget */*widget*/) { - SPDesktop *dt = SP_ACTIVE_DESKTOP; + SPDesktop *dt = SP_ACTIVE_DESKTOP; - if (dt == NULL) { + if (dt == NULL) { return; } @@ -329,14 +340,14 @@ sp_ui_close_all(void) /* Iterate through all the windows, destroying each in the order they become active */ while (SP_ACTIVE_DESKTOP) { - SPDesktop *dt = SP_ACTIVE_DESKTOP; - if (dt->shutdown()) { + SPDesktop *dt = SP_ACTIVE_DESKTOP; + if (dt->shutdown()) { /* The user canceled the operation, so end doing the close */ return FALSE; } - // Shutdown can proceed; use the stored reference to the desktop here instead of the current SP_ACTIVE_DESKTOP, - // because the user might have changed the focus in the meantime (see bug #381357 on Launchpad) - dt->destroyWidget(); + // Shutdown can proceed; use the stored reference to the desktop here instead of the current SP_ACTIVE_DESKTOP, + // because the user might have changed the focus in the meantime (see bug #381357 on Launchpad) + dt->destroyWidget(); } return TRUE; @@ -353,7 +364,7 @@ static void sp_ui_menu_activate(void */*object*/, SPAction *action) { if (!temporarily_block_actions) { - sp_action_perform(action, NULL); + sp_action_perform(action, NULL); } } @@ -481,8 +492,7 @@ sp_ui_dialog_title_string(Inkscape::Verb *verb, gchar *c) * */ -static GtkWidget * -sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::UI::View::View *view, bool radio = false, GSList *group = NULL) +static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::UI::View::View *view, bool radio, GSList *group) { SPAction *action; GtkWidget *item; @@ -503,18 +513,18 @@ sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape:: GtkWidget *const hb = gtk_hbox_new(FALSE, 16); GtkWidget *const name_lbl = gtk_label_new(""); gtk_label_set_markup_with_mnemonic(GTK_LABEL(name_lbl), action->name); - gtk_misc_set_alignment((GtkMisc *) name_lbl, 0.0, 0.5); - gtk_box_pack_start((GtkBox *) hb, name_lbl, TRUE, TRUE, 0); + gtk_misc_set_alignment(reinterpret_cast(name_lbl), 0.0, 0.5); + gtk_box_pack_start(reinterpret_cast(hb), name_lbl, TRUE, TRUE, 0); GtkWidget *const accel_lbl = gtk_label_new(c); - gtk_misc_set_alignment((GtkMisc *) accel_lbl, 1.0, 0.5); - gtk_box_pack_end((GtkBox *) hb, accel_lbl, FALSE, FALSE, 0); + gtk_misc_set_alignment(reinterpret_cast(accel_lbl), 1.0, 0.5); + gtk_box_pack_end(reinterpret_cast(hb), accel_lbl, FALSE, FALSE, 0); gtk_widget_show_all(hb); if (radio) { item = gtk_radio_menu_item_new (group); } else { item = gtk_image_menu_item_new(); } - gtk_container_add((GtkContainer *) item, hb); + gtk_container_add(reinterpret_cast(item), hb); g_free(c); } else { if (radio) { @@ -524,8 +534,8 @@ sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape:: } GtkWidget *const name_lbl = gtk_label_new(""); gtk_label_set_markup_with_mnemonic(GTK_LABEL(name_lbl), action->name); - gtk_misc_set_alignment((GtkMisc *) name_lbl, 0.0, 0.5); - gtk_container_add((GtkContainer *) item, name_lbl); + gtk_misc_set_alignment(reinterpret_cast(name_lbl), 0.0, 0.5); + gtk_container_add(reinterpret_cast(item), name_lbl); } action->signal_set_sensitive.connect( @@ -929,8 +939,8 @@ void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); } if (verb->get_code() != SP_VERB_NONE) { - SPAction *action = verb->get_action(view); - g_signal_connect( G_OBJECT(item), "expose_event", (GCallback) update_view_menu, (void *) action); + SPAction *action = verb->get_action(view); + g_signal_connect( G_OBJECT(item), "expose_event", (GCallback) update_view_menu, (void *) action); } } else { sp_ui_menu_append_item_from_verb(GTK_MENU(menu), verb, view); @@ -1016,87 +1026,6 @@ GtkWidget *sp_ui_main_menubar(Inkscape::UI::View::View *view) return mbar; } -static void leave_group(GtkMenuItem *, SPDesktop *desktop) { - desktop->setCurrentLayer(desktop->currentLayer()->parent); -} - -static void enter_group(GtkMenuItem *mi, SPDesktop *desktop) { - desktop->setCurrentLayer(reinterpret_cast(g_object_get_data(G_OBJECT(mi), "group"))); - sp_desktop_selection(desktop)->clear(); -} - -GtkWidget * -sp_ui_context_menu(Inkscape::UI::View::View *view, SPItem *item) -{ - GtkWidget *m; - SPDesktop *dt; - - dt = static_cast(view); - - m = gtk_menu_new(); - - /* Undo and Redo */ - sp_ui_menu_append_item_from_verb(GTK_MENU(m), Inkscape::Verb::get(SP_VERB_EDIT_UNDO), view); - sp_ui_menu_append_item_from_verb(GTK_MENU(m), Inkscape::Verb::get(SP_VERB_EDIT_REDO), view); - - /* Separator */ - sp_ui_menu_append_item(GTK_MENU(m), NULL, NULL, NULL, NULL, NULL, NULL); - - sp_ui_menu_append_item_from_verb(GTK_MENU(m), Inkscape::Verb::get(SP_VERB_EDIT_CUT), view); - sp_ui_menu_append_item_from_verb(GTK_MENU(m), Inkscape::Verb::get(SP_VERB_EDIT_COPY), view); - sp_ui_menu_append_item_from_verb(GTK_MENU(m), Inkscape::Verb::get(SP_VERB_EDIT_PASTE), view); - - /* Separator */ - sp_ui_menu_append_item(GTK_MENU(m), NULL, NULL, NULL, NULL, NULL, NULL); - - sp_ui_menu_append_item_from_verb(GTK_MENU(m), Inkscape::Verb::get(SP_VERB_EDIT_DUPLICATE), view); - sp_ui_menu_append_item_from_verb(GTK_MENU(m), Inkscape::Verb::get(SP_VERB_EDIT_DELETE), view); - - /* Item menu */ - if (item) { - sp_ui_menu_append_item(GTK_MENU(m), NULL, NULL, NULL, NULL, NULL, NULL); - sp_object_menu((SPObject *) item, dt, GTK_MENU(m)); - } - - /* layer menu */ - SPGroup *group=NULL; - if (item) { - if (SP_IS_GROUP(item)) { - group = SP_GROUP(item); - } else if ( item != dt->currentRoot() && SP_IS_GROUP(item->parent) ) { - group = SP_GROUP(item->parent); - } - } - - if (( group && group != dt->currentLayer() ) || - ( dt->currentLayer() != dt->currentRoot() && dt->currentLayer()->parent != dt->currentRoot() ) ) { - /* Separator */ - sp_ui_menu_append_item(GTK_MENU(m), NULL, NULL, NULL, NULL, NULL, NULL); - } - - if ( group && group != dt->currentLayer() ) { - /* TRANSLATORS: #%s is the id of the group e.g. , not a number. */ - gchar *label=g_strdup_printf(_("Enter group #%s"), group->getId()); - GtkWidget *w = gtk_menu_item_new_with_label(label); - g_free(label); - g_object_set_data(G_OBJECT(w), "group", group); - g_signal_connect(G_OBJECT(w), "activate", GCallback(enter_group), dt); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - } - - if ( dt->currentLayer() != dt->currentRoot() ) { - if ( dt->currentLayer()->parent != dt->currentRoot() ) { - GtkWidget *w = gtk_menu_item_new_with_label(_("Go to parent")); - g_signal_connect(G_OBJECT(w), "activate", GCallback(leave_group), dt); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - - } - } - - return m; -} /* Drag and Drop */ void @@ -1455,9 +1384,9 @@ sp_ui_drag_data_received(GtkWidget *widget, gchar *filename = g_build_filename( g_get_tmp_dir(), "inkscape-dnd-import", NULL ); g_file_set_contents(filename, - reinterpret_cast(gtk_selection_data_get_data (data)), - gtk_selection_data_get_length (data), - NULL); + reinterpret_cast(gtk_selection_data_get_data (data)), + gtk_selection_data_get_length (data), + NULL); file_import(doc, filename, ext); g_free(filename); @@ -1629,6 +1558,659 @@ void injectRenamedIcons() } +void ContextMenu::EnterGroup(Gtk::MenuItem* mi) +{ + _desktop->setCurrentLayer(reinterpret_cast(mi->get_data("group"))); + _desktop->selection->clear(); +} + +void ContextMenu::LeaveGroup(void) +{ + _desktop->setCurrentLayer(_desktop->currentLayer()->parent); +} + +ContextMenu::ContextMenu(Inkscape::UI::View::View *view, SPItem *item) : + _item(item), + separators(), + MIGroup(), + MIParent(_("Go to parent")) +{ +// g_message("ContextMenu"); + _object = static_cast(item); + _desktop = static_cast(view); + + /* Undo and Redo */ + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_UNDO), view); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_REDO), view); + + AddSeparator(); + + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_CUT), view); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_COPY), view); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_PASTE), view); + + AddSeparator(); + + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DUPLICATE), view); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DELETE), view); + + /* Item menu */ + if (item!=NULL) { + AddSeparator(); + MakeObjectMenu(); + } + + /* layer menu */ + SPGroup *group=NULL; + if (item) { + if (SP_IS_GROUP(item)) { + group = SP_GROUP(item); + } else if ( item != _desktop->currentRoot() && SP_IS_GROUP(item->parent) ) { + group = SP_GROUP(item->parent); + } + } + + if (( group && group != _desktop->currentLayer() ) || + ( _desktop->currentLayer() != _desktop->currentRoot() && _desktop->currentLayer()->parent != _desktop->currentRoot() ) ) { + AddSeparator(); + } + + if ( group && group != _desktop->currentLayer() ) { + /* TRANSLATORS: #%1 is the id of the group e.g. , not a number. */ + MIGroup.set_label (Glib::ustring::compose(_("Enter group #%1"), group->getId())); + MIGroup.set_data("group", group); + MIGroup.signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &ContextMenu::EnterGroup),&MIGroup)); + MIGroup.show(); + append(MIGroup); + } + + if ( _desktop->currentLayer() != _desktop->currentRoot() ) { + if ( _desktop->currentLayer()->parent != _desktop->currentRoot() ) { + MIParent.signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LeaveGroup)); + MIParent.show(); + append(MIParent); + } + } +} + +ContextMenu::~ContextMenu(void) +{ +// g_message("~ContextMenu"); +} + +Gtk::SeparatorMenuItem* ContextMenu::AddSeparator(void) +{ + Gtk::SeparatorMenuItem* sep = new Gtk::SeparatorMenuItem(); + sep->show(); + append(*sep); + separators.push_back(sep); + return sep; +} + +void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb, Inkscape::UI::View::View *view)//, bool radio, GSList *group) +{ + SPAction *action; + + if (verb->get_code() == SP_VERB_NONE) { + Gtk::MenuItem *item = AddSeparator(); + item->show(); + append(*item); + } else { + action = verb->get_action(view); + if (!action) + { + return; + } + + Gtk::ImageMenuItem *item = NULL; + unsigned int shortcut = sp_shortcut_get_primary(verb); + if (shortcut!=GDK_VoidSymbol) { + gchar* c = sp_shortcut_get_label(shortcut); + Gtk::HBox *const hb = new Gtk::HBox (FALSE, 16); + Gtk::Label *const name_lbl = new Gtk::Label(action->name, true); + name_lbl->set_alignment(0.0, 0.5); + hb->pack_start(*name_lbl, TRUE, TRUE, 0); + Gtk::Label *const accel_lbl = new Gtk::Label(c); + accel_lbl->set_alignment(1.0, 0.5); + hb->pack_end(*accel_lbl, FALSE, FALSE, 0); + hb->show_all(); + // if (radio) { + // item = gtk_radio_menu_item_new (group); + // } else { + item = new Gtk::ImageMenuItem(); + // } + item->add(*hb); + g_free(c); + } else { + // if (radio) { + // item = gtk_radio_menu_item_new (group); + // } else { + item = new Gtk::ImageMenuItem(); + // } + Gtk::Label *const name_lbl = new Gtk::Label(action->name, true); + name_lbl->set_alignment(0.0, 0.5); + item->add(*name_lbl); + } + + action->signal_set_sensitive.connect(sigc::mem_fun(*this, &ContextMenu::set_sensitive)); + action->signal_set_name.connect(sigc::mem_fun(*item, &ContextMenu::set_name)); + + if (!action->sensitive) { + item->set_sensitive(FALSE); + } + + if (action->image) { + sp_ui_menuitem_add_icon((GtkWidget*)item->gobj(), action->image); + } + item->set_events(Gdk::KEY_PRESS_MASK); + item->set_data("view", (gpointer) view); + item->signal_activate().connect(sigc::bind(sigc::ptr_fun(sp_ui_menu_activate),item,action)); + item->signal_select().connect(sigc::bind(sigc::ptr_fun(sp_ui_menu_select_action),item,action)); + item->signal_deselect().connect(sigc::bind(sigc::ptr_fun(sp_ui_menu_deselect_action),item,action)); + item->show(); + append(*item); + } +} + +void ContextMenu::MakeObjectMenu(void) +{ + GObjectClass *klass = G_OBJECT_GET_CLASS(_object); //to deduce the object's type from its class + GType type = G_TYPE_FROM_CLASS(klass); + + if (type | SP_TYPE_ITEM) + { + MakeItemMenu (); + } + if (type == SP_TYPE_GROUP) + { + MakeGroupMenu(); + } + if (type == SP_TYPE_ANCHOR) + { + MakeAnchorMenu(); + } + if (type == SP_TYPE_IMAGE) + { + MakeImageMenu(); + } + if (type == SP_TYPE_SHAPE) + { + MakeShapeMenu(); + } + if (type == SP_TYPE_TEXT) + { + MakeTextMenu(); + } +} + +void ContextMenu::MakeItemMenu (void) +{ + Gtk::MenuItem* mi; + + /* Item dialog */ + mi = new Gtk::MenuItem(_("_Object Properties..."),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemProperties)); + mi->show(); + append(*mi); + + AddSeparator(); + + /* Select item */ + mi = new Gtk::MenuItem(_("_Select This"),1); + if (_desktop->selection->includes(_item)) { + mi->set_sensitive(FALSE); + } else { + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemSelectThis)); + } + mi->show(); + append(*mi); + + /* Select same fill and stroke */ + mi = new Gtk::MenuItem(_("_Select Same Fill and Stroke"),1); + if (_desktop->selection->isEmpty()) { + mi->set_sensitive(FALSE); + } else { + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameFillStroke)); + } + mi->set_sensitive(!SP_IS_ANCHOR(_item)); + mi->show(); + append(*mi); + + /* Create link */ + mi = new Gtk::MenuItem(_("_Create Link"),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemCreateLink)); + mi->set_sensitive(!SP_IS_ANCHOR(_item)); + mi->show(); + append(*mi); + + bool ClipRefOK=false; + bool MaskRefOK=false; + if (_item){ + if (_item->clip_ref){ + if (_item->clip_ref->getObject()){ + ClipRefOK=true; + } + } + } + if (_item){ + if (_item->mask_ref){ + if (_item->mask_ref->getObject()){ + MaskRefOK=true; + } + } + } + /* Set mask */ + mi = new Gtk::MenuItem(_("Set Mask"),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetMask)); + if (ClipRefOK || MaskRefOK) { + mi->set_sensitive(FALSE); + } else { + mi->set_sensitive(TRUE); + } + mi->show(); + append(*mi); + + /* Release mask */ + mi = new Gtk::MenuItem(_("Release Mask"),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseMask)); + if (MaskRefOK) { + mi->set_sensitive(TRUE); + } else { + mi->set_sensitive(FALSE); + } + mi->show(); + append(*mi); + + /* Set Clip */ + mi = new Gtk::MenuItem(_("Set _Clip"),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetClip)); + if (ClipRefOK || MaskRefOK) { + mi->set_sensitive(FALSE); + } else { + mi->set_sensitive(TRUE); + } + mi->show(); + append(*mi); + + /* Release Clip */ + mi = new Gtk::MenuItem(_("Release C_lip"),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseClip)); + if (ClipRefOK) { + mi->set_sensitive(TRUE); + } else { + mi->set_sensitive(FALSE); + } + mi->show(); + append(*mi); +} + +void ContextMenu::SelectSameFillStroke(void) +{ + sp_select_same_fill_stroke_style(_desktop, true, true, true); +} + +void ContextMenu::ItemProperties(void) +{ + _desktop->selection->set(_item); + _desktop->_dlg_mgr->showDialog("ObjectProperties"); +} + +void ContextMenu::ItemSelectThis(void) +{ + _desktop->selection->set(_item); +} + +void ContextMenu::ItemCreateLink(void) +{ + Inkscape::XML::Document *xml_doc = _desktop->doc()->getReprDoc(); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:a"); + _item->parent->getRepr()->addChild(repr, _item->getRepr()); + SPObject *object = _item->document->getObjectByRepr(repr); + g_return_if_fail(SP_IS_ANCHOR(object)); + + const char *id = _item->getRepr()->attribute("id"); + Inkscape::XML::Node *child = _item->getRepr()->duplicate(xml_doc); + _item->deleteObject(false); + repr->addChild(child, NULL); + child->setAttribute("id", id); + + Inkscape::GC::release(repr); + Inkscape::GC::release(child); + + DocumentUndo::done(object->document, SP_VERB_NONE, _("Create link")); + + _desktop->selection->set(SP_ITEM(object)); + _desktop->_dlg_mgr->showDialog("ObjectAttributes"); +} + +void ContextMenu::SetMask(void) +{ + sp_selection_set_mask(_desktop, false, false); +} + +void ContextMenu::ReleaseMask(void) +{ + sp_selection_unset_mask(_desktop, false); +} + + +void ContextMenu::SetClip(void) +{ + sp_selection_set_mask(_desktop, true, false); +} + + +void ContextMenu::ReleaseClip(void) +{ + sp_selection_unset_mask(_desktop, true); +} + +void ContextMenu::MakeGroupMenu(void) +{ + /* "Ungroup" */ + Gtk::MenuItem* mi = new Gtk::MenuItem(_("_Ungroup"),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroup)); + mi->show(); + append(*mi); +} + +void ContextMenu::ActivateUngroup(void) +{ + GSList *children = NULL; + + sp_item_group_ungroup(static_cast(_item), &children); + _desktop->selection->setList(children); + g_slist_free(children); +} + +void ContextMenu::MakeAnchorMenu(void) +{ + Gtk::MenuItem* mi; + + /* Link dialog */ + mi = new Gtk::MenuItem(_("Link _Properties..."),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkProperties)); + mi->show(); + append(*mi); + + /* Select item */ + mi = new Gtk::MenuItem(_("_Follow Link"),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkFollow)); + mi->show(); + append(*mi); + + /* Reset transformations */ + mi = new Gtk::MenuItem(_("_Remove Link"),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkRemove)); + mi->show(); + append(*mi); +} + +void ContextMenu::AnchorLinkProperties(void) +{ + _desktop->_dlg_mgr->showDialog("ObjectAttributes"); +} + +void ContextMenu::AnchorLinkFollow(void) +{ + /* shell out to an external browser here */ +} + +void ContextMenu::AnchorLinkRemove(void) +{ + GSList *children = NULL; + sp_item_group_ungroup(static_cast(_item), &children); + g_slist_free(children); +} + +void ContextMenu::MakeImageMenu (void) +{ + Gtk::MenuItem* mi; + Inkscape::XML::Node *ir = _object->getRepr(); + const gchar *href = ir->attribute("xlink:href"); + + /* Image properties */ + mi = new Gtk::MenuItem(_("Image _Properties..."),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageProperties)); + mi->show(); + append(*mi); + + /* Edit externally */ + mi = new Gtk::MenuItem(_("Edit Externally..."),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEdit)); + mi->show(); + append(*mi); + if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { + mi->set_sensitive( FALSE ); + } + + /* Embed image */ + if (Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" )) { + mi = new Gtk::MenuItem(C_("Context menu", "Embed Image")); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEmbed)); + mi->show(); + append(*mi); + if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { + mi->set_sensitive( FALSE ); + } + } + + /* Extract image */ + if (Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" )) { + mi = new Gtk::MenuItem(C_("Context menu", "Extract Image...")); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageExtract)); + mi->show(); + append(*mi); + if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { + mi->set_sensitive( FALSE ); + } + } +} + +void ContextMenu::ImageProperties(void) +{ + _desktop->_dlg_mgr->showDialog("ObjectAttributes"); +} + +Glib::ustring ContextMenu::getImageEditorName() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring value; + Glib::ustring choices = prefs->getString("/options/bitmapeditor/value"); + if (!choices.empty()) { + value = choices; + } + else { + value = "gimp"; + } + return value; +} + +/* Edit Externally entry */ +void ContextMenu::ImageEdit(void) +{ + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + + GSList const *selected = _desktop->selection->itemList(); + + GError* errThing = 0; + Glib::ustring cmdline = getImageEditorName(); + Glib::ustring name; + Glib::ustring fullname; + +#ifdef WIN32 + // g_spawn_command_line_sync parsing is done according to Unix shell rules, + // not Windows command interpreter rules. Thus we need to enclose the + // executable path with single quotes. + int index = cmdline.find(".exe"); + if ( index < 0 ) index = cmdline.find(".bat"); + if ( index < 0 ) index = cmdline.find(".com"); + if ( index >= 0 ) { + Glib::ustring editorBin = cmdline.substr(0, index + 4).c_str(); + Glib::ustring args = cmdline.substr(index + 4, cmdline.length()).c_str(); + editorBin.insert(0, "'"); + editorBin.append("'"); + cmdline = editorBin; + cmdline.append(args); + } else { + // Enclose the whole command line if no executable path can be extracted. + cmdline.insert(0, "'"); + cmdline.append("'"); + } +#endif + + for (GSList const *iter = selected; iter != NULL; iter = iter->next) { + Inkscape::XML::Node *ir = SP_ITEM(iter->data)->getRepr(); + const gchar *href = ir->attribute("xlink:href"); + + if (strncmp (href,"file:",5) == 0) { + // URI to filename conversion + name = g_filename_from_uri(href, NULL, NULL); + } else { + name.append(href); + } + + if (Glib::path_is_absolute(name)) { + fullname = name; + } else if (SP_ACTIVE_DOCUMENT->getBase()) { + fullname = Glib::build_filename(SP_ACTIVE_DOCUMENT->getBase(), name); + } else { + fullname = Glib::build_filename(Glib::get_current_dir(), name); + } + + cmdline.append(" '"); + cmdline.append(fullname.c_str()); + cmdline.append("'"); + } + + //g_warning("##Command line: %s\n", cmdline.c_str()); + + g_spawn_command_line_async(cmdline.c_str(), &errThing); + + if ( errThing ) { + g_warning("Problem launching editor (%d). %s", errThing->code, errThing->message); + (_desktop->messageStack())->flash(Inkscape::ERROR_MESSAGE, errThing->message); + g_error_free(errThing); + errThing = 0; + } +} + +/* Embed Image entry */ +void ContextMenu::ImageEmbed(void) +{ + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + + Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" ); + if (verb) { + SPAction *action = verb->get_action(_desktop); + if (action) { + sp_action_perform(action, NULL); + } + } +} + +/* Extract Image entry */ +void ContextMenu::ImageExtract(void) +{ + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + + Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" ); + if (verb) { + SPAction *action = verb->get_action(_desktop); + if (action) { + sp_action_perform(action, NULL); + } + } +} + +void ContextMenu::MakeShapeMenu (void) +{ + Gtk::MenuItem* mi; + + /* Item dialog */ + mi = new Gtk::MenuItem(_("_Fill and Stroke..."),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings)); + mi->show(); + append(*mi); +} + +void ContextMenu::FillSettings(void) +{ + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + + _desktop->_dlg_mgr->showDialog("FillAndStroke"); +} + +void ContextMenu::MakeTextMenu (void) +{ + Gtk::MenuItem* mi; + + /* Fill and Stroke dialog */ + mi = new Gtk::MenuItem(_("_Fill and Stroke..."),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings)); + mi->show(); + append(*mi); + + /* Edit Text dialog */ + mi = new Gtk::MenuItem(_("_Text and Font..."),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::TextSettings)); + mi->show(); + append(*mi); + + /* Spellcheck dialog */ + mi = new Gtk::MenuItem(_("Check Spellin_g..."),1); + mi->set_data("desktop", _desktop); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SpellcheckSettings)); + mi->show(); + append(*mi); +} + +/* Edit Text entry */ +void ContextMenu::TextSettings (void) +{ + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + + _desktop->_dlg_mgr->showDialog("TextFont"); +} + +/* Spellcheck entry */ +void ContextMenu::SpellcheckSettings (void) +{ + if (_desktop->selection->isEmpty()) { + _desktop->selection->set(_item); + } + + _desktop->_dlg_mgr->showDialog("SpellCheck"); +} + /* Local Variables: mode:c++ diff --git a/src/interface.h b/src/interface.h index 2b01a20d7..db98c3ae3 100644 --- a/src/interface.h +++ b/src/interface.h @@ -8,7 +8,9 @@ * Lauris Kaplinski * Frank Felfe * Abhishek Sharma + * Kris De Gussem * + * Copyright (C) 2012 Kris De Gussem * Copyright (C) 1999-2002 authors * Copyright (C) 2001-2002 Ximian, Inc. * @@ -16,6 +18,7 @@ */ #include +#include #include "sp-item.h" @@ -58,10 +61,7 @@ unsigned int sp_ui_close_all (void); */ GtkWidget *sp_ui_main_menubar (Inkscape::UI::View::View *view); -/** - * - */ -GtkWidget *sp_ui_context_menu (Inkscape::UI::View::View *v, SPItem *item); +static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::UI::View::View *view, bool radio = false, GSList *group = NULL); /** @@ -82,6 +82,59 @@ void sp_ui_dialog_title_string (Inkscape::Verb * verb, gchar* c); void sp_ui_error_dialog (const gchar * message); bool sp_ui_overwrite_file (const gchar * filename); +class ContextMenu : public Gtk::Menu +{ + public: + ContextMenu(Inkscape::UI::View::View *view, SPItem *item); + ~ContextMenu(void); + private: + SPItem *_item; + SPObject *_object; + SPDesktop *_desktop; + + std::vector separators; + Gtk::MenuItem MIGroup; + Gtk::MenuItem MIParent; + + Gtk::SeparatorMenuItem* AddSeparator(void); + void AppendItemFromVerb(Inkscape::Verb *verb, Inkscape::UI::View::View *view); + void MakeObjectMenu (void); + void MakeItemMenu (void); + void MakeGroupMenu (void); + void MakeAnchorMenu (void); + void MakeImageMenu (void); + void MakeShapeMenu (void); + void MakeTextMenu (void); + + void EnterGroup(Gtk::MenuItem* mi); + void LeaveGroup(void); + void ItemProperties(void); + void ItemSelectThis(void); + void SelectSameFillStroke(void); + void ItemCreateLink(void); + void SetMask(void); + void ReleaseMask(void); + void SetClip(void); + void ReleaseClip(void); + + void ActivateUngroup(void); + + void AnchorLinkProperties(void); + void AnchorLinkFollow(void); + void AnchorLinkRemove(void); + + void ImageProperties(void); + void ImageEdit(void); + Glib::ustring getImageEditorName(); + void ImageEmbed(void); + void ImageExtract(void); + + void FillSettings(void); + + void TextSettings(void); + void SpellcheckSettings(void); +}; + #endif // SEEN_SP_INTERFACE_H /* diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 35840e0c4..85f0899a8 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -1,7 +1,6 @@ set(ui_SRC clipboard.cpp - context-menu.cpp previewholder.cpp uxmanager.cpp @@ -121,7 +120,6 @@ set(ui_SRC # ------- # Headers clipboard.h - context-menu.h icon-names.h previewable.h previewfillable.h diff --git a/src/ui/Makefile_insert b/src/ui/Makefile_insert index eb8966d11..19ecef0fc 100644 --- a/src/ui/Makefile_insert +++ b/src/ui/Makefile_insert @@ -1,8 +1,6 @@ ## Makefile.am fragment sourced by src/Makefile.am. ink_common_sources += \ - ui/context-menu.cpp \ - ui/context-menu.h \ ui/clipboard.cpp \ ui/clipboard.h \ ui/icon-names.h \ diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp deleted file mode 100644 index ad47da68b..000000000 --- a/src/ui/context-menu.cpp +++ /dev/null @@ -1,715 +0,0 @@ -/* - * Unser-interface related object extension - * - * Authors: - * Lauris Kaplinski - * Jon A. Cruz - * Abhishek Sharma - * - * This code is in public domain - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "ui/dialog/dialog-manager.h" -#include "context-menu.h" -#include "../xml/repr.h" -#include "desktop.h" -#include "document.h" -#include "document-undo.h" -#include "helper/action.h" //sp_action_perform -#include "inkscape.h" -#include "message-stack.h" -#include "preferences.h" -#include "verbs.h" - -#include "selection-chemistry.h" - -using Inkscape::DocumentUndo; - -static void sp_object_type_menu(GType type, SPObject *object, SPDesktop *desktop, GtkMenu *menu); - -/* Append object-specific part to context menu */ - -void sp_object_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu) -{ - GObjectClass *klass; - klass = G_OBJECT_GET_CLASS(object); - while (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_OBJECT)) { - GType type; - type = G_TYPE_FROM_CLASS(klass); - sp_object_type_menu(type, object, desktop, menu); - klass = (GObjectClass*)g_type_class_peek_parent(klass); - } -} - -/* Implementation */ - -#include -#include - -#include "selection.h" -#include "selection-chemistry.h" -#include "sp-anchor.h" -#include "sp-clippath.h" -#include "sp-image.h" -#include "sp-mask.h" -#include "sp-path.h" -#include "sp-text.h" -#include "desktop-handles.h" -#include "ui/dialog/object-attributes.h" -#include "ui/dialog/object-properties.h" -#include "ui/dialog/spellcheck.h" - - -static void sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu); -static void sp_group_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu); -static void sp_anchor_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu); -static void sp_image_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu); -static void sp_shape_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu); -static void sp_text_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu); - -static void sp_object_type_menu(GType type, SPObject *object, SPDesktop *desktop, GtkMenu *menu) -{ - static GHashTable *t2m = NULL; - void (* handler)(SPObject *object, SPDesktop *desktop, GtkMenu *menu); - if (!t2m) { - t2m = g_hash_table_new(NULL, NULL); - g_hash_table_insert(t2m, GUINT_TO_POINTER(SP_TYPE_ITEM), (void*)sp_item_menu); - g_hash_table_insert(t2m, GUINT_TO_POINTER(SP_TYPE_GROUP), (void*)sp_group_menu); - g_hash_table_insert(t2m, GUINT_TO_POINTER(SP_TYPE_ANCHOR), (void*)sp_anchor_menu); - g_hash_table_insert(t2m, GUINT_TO_POINTER(SP_TYPE_IMAGE), (void*)sp_image_menu); - g_hash_table_insert(t2m, GUINT_TO_POINTER(SP_TYPE_SHAPE), (void*)sp_shape_menu); - g_hash_table_insert(t2m, GUINT_TO_POINTER(SP_TYPE_TEXT), (void*)sp_text_menu); - } - handler = (void (*)(SPObject*, SPDesktop*, GtkMenu*))g_hash_table_lookup(t2m, GUINT_TO_POINTER(type)); - if (handler) handler(object, desktop, menu); -} - -/* SPItem */ - -static void sp_item_properties(GtkMenuItem *menuitem, SPItem *item); -static void sp_item_select_this(GtkMenuItem *menuitem, SPItem *item); -static void sp_item_select_same_fill_stroke(GtkMenuItem *menuitem, SPItem *item); -static void sp_item_create_link(GtkMenuItem *menuitem, SPItem *item); -static void sp_set_mask(GtkMenuItem *menuitem, SPItem *item); -static void sp_release_mask(GtkMenuItem *menuitem, SPItem *item); -static void sp_set_clip(GtkMenuItem *menuitem, SPItem *item); -static void sp_release_clip(GtkMenuItem *menuitem, SPItem *item); - -/* Generate context menu item section */ -static void sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) -{ - SPItem *item; - GtkWidget *w; - - item = (SPItem *) object; - - /* Item dialog */ - w = gtk_menu_item_new_with_mnemonic(_("_Object Properties...")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_properties), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - /* Separator */ - w = gtk_menu_item_new(); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - /* Select item */ - w = gtk_menu_item_new_with_mnemonic(_("_Select This")); - if (sp_desktop_selection(desktop)->includes(item)) { - gtk_widget_set_sensitive(w, FALSE); - } else { - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_select_this), item); - } - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - /* Select same fill and stroke */ - w = gtk_menu_item_new_with_mnemonic(_("_Select Same Fill and Stroke")); - if (sp_desktop_selection(desktop)->isEmpty()) { - gtk_widget_set_sensitive(w, FALSE); - } else { - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_select_same_fill_stroke), item); - } - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - /* Create link */ - w = gtk_menu_item_new_with_mnemonic(_("_Create Link")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_create_link), item); - gtk_widget_set_sensitive(w, !SP_IS_ANCHOR(item)); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - /* Set mask */ - w = gtk_menu_item_new_with_mnemonic(_("Set Mask")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_set_mask), item); - if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) { - gtk_widget_set_sensitive(w, FALSE); - } else { - gtk_widget_set_sensitive(w, TRUE); - } - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - /* Release mask */ - w = gtk_menu_item_new_with_mnemonic(_("Release Mask")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_release_mask), item); - if (item && item->mask_ref && item->mask_ref->getObject()) { - gtk_widget_set_sensitive(w, TRUE); - } else { - gtk_widget_set_sensitive(w, FALSE); - } - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - /* Set Clip */ - w = gtk_menu_item_new_with_mnemonic(_("Set _Clip")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_set_clip), item); - if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) { - gtk_widget_set_sensitive(w, FALSE); - } else { - gtk_widget_set_sensitive(w, TRUE); - } - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - /* Release Clip */ - w = gtk_menu_item_new_with_mnemonic(_("Release C_lip")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_release_clip), item); - if (item && item->clip_ref && item->clip_ref->getObject()) { - gtk_widget_set_sensitive(w, TRUE); - } else { - gtk_widget_set_sensitive(w, FALSE); - } - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - -} - -static void sp_item_properties(GtkMenuItem *menuitem, SPItem *item) -{ - SPDesktop *desktop; - - g_assert(SP_IS_ITEM(item)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - sp_desktop_selection(desktop)->set(item); - - // sp_item_dialog(); - desktop->_dlg_mgr->showDialog("ObjectProperties"); -} - - -static void sp_set_mask(GtkMenuItem *menuitem, SPItem *item) -{ - SPDesktop *desktop; - - g_assert(SP_IS_ITEM(item)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - sp_selection_set_mask(desktop, false, false); -} - - -static void sp_release_mask(GtkMenuItem *menuitem, SPItem *item) -{ - SPDesktop *desktop; - - g_assert(SP_IS_ITEM(item)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - sp_selection_unset_mask(desktop, false); -} - - -static void sp_set_clip(GtkMenuItem *menuitem, SPItem *item) -{ - SPDesktop *desktop; - - g_assert(SP_IS_ITEM(item)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - sp_selection_set_mask(desktop, true, false); -} - - -static void sp_release_clip(GtkMenuItem *menuitem, SPItem *item) -{ - SPDesktop *desktop; - - g_assert(SP_IS_ITEM(item)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - sp_selection_unset_mask(desktop, true); -} - - -static void sp_item_select_this(GtkMenuItem *menuitem, SPItem *item) -{ - SPDesktop *desktop; - - g_assert(SP_IS_ITEM(item)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - sp_desktop_selection(desktop)->set(item); -} - -static void sp_item_select_same_fill_stroke(GtkMenuItem *menuitem, SPItem * /*item*/) -{ - SPDesktop *desktop = static_cast(g_object_get_data(G_OBJECT(menuitem), "desktop")); - g_return_if_fail(desktop != NULL); - - sp_select_same_fill_stroke_style(desktop, true, true, true); -} - - -static void sp_item_create_link(GtkMenuItem *menuitem, SPItem *item) -{ - g_assert(SP_IS_ITEM(item)); - g_assert(!SP_IS_ANCHOR(item)); - - SPDesktop *desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); - Inkscape::XML::Node *repr = xml_doc->createElement("svg:a"); - item->parent->getRepr()->addChild(repr, item->getRepr()); - SPObject *object = item->document->getObjectByRepr(repr); - g_return_if_fail(SP_IS_ANCHOR(object)); - - const char *id = item->getRepr()->attribute("id"); - Inkscape::XML::Node *child = item->getRepr()->duplicate(xml_doc); - item->deleteObject(false); - repr->addChild(child, NULL); - child->setAttribute("id", id); - - Inkscape::GC::release(repr); - Inkscape::GC::release(child); - - DocumentUndo::done(object->document, SP_VERB_NONE, - _("Create link")); - - sp_desktop_selection(desktop)->set(SP_ITEM(object)); - desktop->_dlg_mgr->showDialog("ObjectAttributes"); -} - -/* SPGroup */ - -static void sp_item_group_ungroup_activate(GtkMenuItem *menuitem, SPGroup *group); - -static void sp_group_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu) -{ - SPItem *item=SP_ITEM(object); - GtkWidget *w; - - /* "Ungroup" */ - w = gtk_menu_item_new_with_mnemonic(_("_Ungroup")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_group_ungroup_activate), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), w); -} - -static void sp_item_group_ungroup_activate(GtkMenuItem *menuitem, SPGroup *group) -{ - SPDesktop *desktop; - GSList *children; - - g_assert(SP_IS_GROUP(group)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - children = NULL; - sp_item_group_ungroup(group, &children); - - sp_desktop_selection(desktop)->setList(children); - g_slist_free(children); -} - -/* SPAnchor */ - -static void sp_anchor_link_properties(GtkMenuItem *menuitem, SPAnchor *anchor); -static void sp_anchor_link_follow(GtkMenuItem *menuitem, SPAnchor *anchor); -static void sp_anchor_link_remove(GtkMenuItem *menuitem, SPAnchor *anchor); - -static void sp_anchor_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) -{ - SPItem *item; - GtkWidget *w; - - item = (SPItem *) object; - - /* Link dialog */ - w = gtk_menu_item_new_with_mnemonic(_("Link _Properties...")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_properties), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - /* Select item */ - w = gtk_menu_item_new_with_mnemonic(_("_Follow Link")); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_follow), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - /* Reset transformations */ - w = gtk_menu_item_new_with_mnemonic(_("_Remove Link")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_remove), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); -} - -static void sp_anchor_link_properties(GtkMenuItem *menuitem, SPAnchor */*anchor*/) -{ - SPDesktop *desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - desktop->_dlg_mgr->showDialog("ObjectAttributes"); -} - -static void sp_anchor_link_follow(GtkMenuItem */*menuitem*/, SPAnchor *anchor) -{ - g_return_if_fail(anchor != NULL); - g_return_if_fail(SP_IS_ANCHOR(anchor)); - - /* shell out to an external browser here */ -} - -static void sp_anchor_link_remove(GtkMenuItem */*menuitem*/, SPAnchor *anchor) -{ - GSList *children; - - g_return_if_fail(anchor != NULL); - g_return_if_fail(SP_IS_ANCHOR(anchor)); - - children = NULL; - sp_item_group_ungroup(SP_GROUP(anchor), &children); - - g_slist_free(children); -} - -/* Image */ - -static void sp_image_image_properties(GtkMenuItem *menuitem, SPAnchor *anchor); -static void sp_image_image_edit(GtkMenuItem *menuitem, SPItem *item); -static void sp_image_image_embed(GtkMenuItem *menuitem, SPItem *item); -static void sp_image_image_extract(GtkMenuItem *menuitem, SPItem *item); - -static void sp_image_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) -{ - SPItem *item = SP_ITEM(object); - GtkWidget *w; - Inkscape::XML::Node *ir = object->getRepr(); - const gchar *href = ir->attribute("xlink:href"); - - /* Image properties */ - w = gtk_menu_item_new_with_mnemonic(_("Image _Properties...")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_properties), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - - /* Edit externally */ - w = gtk_menu_item_new_with_mnemonic(_("Edit Externally...")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_edit), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { - gtk_widget_set_sensitive( w, FALSE ); - } - - /* Embed image */ - if (Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" )) { - w = gtk_menu_item_new_with_mnemonic(C_("Context menu", "Embed Image")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_embed), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { - gtk_widget_set_sensitive( w, FALSE ); - } - } - - /* Extract image */ - if (Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" )) { - w = gtk_menu_item_new_with_mnemonic(C_("Context menu", "Extract Image...")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_extract), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - if ( (!href) || ((strncmp(href, "data:", 5) != 0)) ) { - gtk_widget_set_sensitive( w, FALSE ); - } - } -} - -/* Image Properties entry */ -static void sp_image_image_properties(GtkMenuItem *menuitem, SPAnchor */*anchor*/) -{ - SPDesktop *desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - desktop->_dlg_mgr->showDialog("ObjectAttributes"); -} - -static gchar* getImageEditorName() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gchar* value = 0; - Glib::ustring choices = prefs->getString("/options/bitmapeditor/value"); - if (!choices.empty()) { - value = g_strdup(choices.c_str()); - } - if (!value) { - value = g_strdup("gimp"); - } - return value; -} - -/* Edit Externally entry */ -static void sp_image_image_edit(GtkMenuItem *menuitem, SPItem *item) -{ - SPDesktop *desktop = NULL; - - g_assert(SP_IS_ITEM(item)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - if (sp_desktop_selection(desktop)->isEmpty()) { - sp_desktop_selection(desktop)->set(item); - } - - GSList const *selected = sp_desktop_selection(desktop)->itemList(); - - GError* errThing = 0; - Glib::ustring cmdline = getImageEditorName(); - Glib::ustring name; - Glib::ustring fullname; - -#ifdef WIN32 - // g_spawn_command_line_sync parsing is done according to Unix shell rules, - // not Windows command interpreter rules. Thus we need to enclose the - // executable path with sigle quotes. - int index = cmdline.find(".exe"); - if ( index < 0 ) index = cmdline.find(".bat"); - if ( index < 0 ) index = cmdline.find(".com"); - if ( index >= 0 ) { - Glib::ustring editorBin = cmdline.substr(0, index + 4).c_str(); - Glib::ustring args = cmdline.substr(index + 4, cmdline.length()).c_str(); - editorBin.insert(0, "'"); - editorBin.append("'"); - cmdline = editorBin; - cmdline.append(args); - } else { - // Enclose the whole command line if no executable path can be extracted. - cmdline.insert(0, "'"); - cmdline.append("'"); - } -#endif - - for (GSList const *iter = selected; iter != NULL; iter = iter->next) { - Inkscape::XML::Node *ir = SP_ITEM(iter->data)->getRepr(); - const gchar *href = ir->attribute("xlink:href"); - - if (strncmp (href,"file:",5) == 0) { - // URI to filename conversion - name = g_filename_from_uri(href, NULL, NULL); - } else { - name.append(href); - } - - if (Glib::path_is_absolute(name)) { - fullname = name; - } else if (SP_ACTIVE_DOCUMENT->getBase()) { - fullname = Glib::build_filename(SP_ACTIVE_DOCUMENT->getBase(), name); - } else { - fullname = Glib::build_filename(Glib::get_current_dir(), name); - } - - cmdline.append(" '"); - cmdline.append(fullname.c_str()); - cmdline.append("'"); - } - - //g_warning("##Command line: %s\n", cmdline.c_str()); - - g_spawn_command_line_async(cmdline.c_str(), - &errThing); - - if ( errThing ) { - g_warning("Problem launching editor (%d). %s", errThing->code, errThing->message); - SPDesktop *desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, errThing->message); - g_error_free(errThing); - errThing = 0; - } -} - -/* Embed Image entry */ -static void sp_image_image_embed(GtkMenuItem *menuitem, SPItem *item) -{ - SPDesktop *desktop; - - g_assert(SP_IS_ITEM(item)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - if (sp_desktop_selection(desktop)->isEmpty()) { - sp_desktop_selection(desktop)->set(item); - } - - Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" ); - if (verb) { - SPAction *action = verb->get_action(desktop); - if (action) { - sp_action_perform(action, NULL); - } - } -} - -/* Extract Image entry */ -static void sp_image_image_extract(GtkMenuItem *menuitem, SPItem *item) -{ - SPDesktop *desktop; - - g_assert(SP_IS_ITEM(item)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - if (sp_desktop_selection(desktop)->isEmpty()) { - sp_desktop_selection(desktop)->set(item); - } - - Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" ); - if (verb) { - SPAction *action = verb->get_action(desktop); - if (action) { - sp_action_perform(action, NULL); - } - } -} - -/* Fill and Stroke entry */ -static void sp_fill_settings(GtkMenuItem *menuitem, SPItem *item) -{ - SPDesktop *desktop; - - g_assert(SP_IS_ITEM(item)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - if (sp_desktop_selection(desktop)->isEmpty()) { - sp_desktop_selection(desktop)->set(item); - } - - desktop->_dlg_mgr->showDialog("FillAndStroke"); -} - -/* SPShape */ -static void sp_shape_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) -{ - SPItem *item; - GtkWidget *w; - - item = (SPItem *) object; - - /* Item dialog */ - w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke...")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_fill_settings), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); -} - -/* Edit Text entry */ -static void sp_text_settings(GtkMenuItem *menuitem, SPItem *item) -{ - SPDesktop *desktop; - - g_assert(SP_IS_ITEM(item)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - if (sp_desktop_selection(desktop)->isEmpty()) { - sp_desktop_selection(desktop)->set(item); - } - - desktop->_dlg_mgr->showDialog("TextFont"); -} - -/* Spellcheck entry */ -static void sp_spellcheck_settings(GtkMenuItem *menuitem, SPItem *item) -{ - SPDesktop *desktop; - - g_assert(SP_IS_ITEM(item)); - - desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); - g_return_if_fail(desktop != NULL); - - if (sp_desktop_selection(desktop)->isEmpty()) { - sp_desktop_selection(desktop)->set(item); - } - - desktop->_dlg_mgr->showDialog("SpellCheck"); -} - -/* SPText */ -static void sp_text_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) -{ - SPItem *item; - GtkWidget *w; - - item = (SPItem *) object; - - /* Fill and Stroke dialog */ - w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke...")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_fill_settings), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - - /* Edit Text dialog */ - w = gtk_menu_item_new_with_mnemonic(_("_Text and Font...")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_text_settings), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); - - /* Spellcheck dialog */ - w = gtk_menu_item_new_with_mnemonic(_("Check Spellin_g...")); - g_object_set_data(G_OBJECT(w), "desktop", desktop); - g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_spellcheck_settings), item); - gtk_widget_show(w); - gtk_menu_shell_append(GTK_MENU_SHELL(m), w); -} -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/context-menu.h b/src/ui/context-menu.h deleted file mode 100644 index 39753f93f..000000000 --- a/src/ui/context-menu.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef SEEN_CONTEXT_MENU_H -#define SEEN_CONTEXT_MENU_H - -/* - * Unser-interface related object extension - * - * Authors: - * Lauris Kaplinski - * Abhishek Sharma - * - * This code is in public domain - */ - -#include - -#include "sp-object.h" - -class SPDesktop; - -/** - * Append object-specific part to context menu. - */ -void sp_object_menu (SPObject *object, SPDesktop *desktop, GtkMenu *menu); - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From a5080325d2e488598ece94094a3984dcdd292055 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 6 Apr 2012 08:09:09 +0200 Subject: build warning fix (bzr r11161) --- src/interface.cpp | 2 +- src/interface.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index 77ef9a075..05c8b9844 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -492,7 +492,7 @@ sp_ui_dialog_title_string(Inkscape::Verb *verb, gchar *c) * */ -static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::UI::View::View *view, bool radio, GSList *group) +static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::UI::View::View *view, bool radio = false, GSList *group = NULL) { SPAction *action; GtkWidget *item; diff --git a/src/interface.h b/src/interface.h index db98c3ae3..fecfa4ae4 100644 --- a/src/interface.h +++ b/src/interface.h @@ -61,9 +61,6 @@ unsigned int sp_ui_close_all (void); */ GtkWidget *sp_ui_main_menubar (Inkscape::UI::View::View *view); -static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::UI::View::View *view, bool radio = false, GSList *group = NULL); - - /** * */ -- cgit v1.2.3 From aa256328ec303abecd4c01bb662cdf7e21f69669 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 6 Apr 2012 08:38:32 +0200 Subject: fixes issue with revision 11160? (bzr r11162) --- src/interface.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index 05c8b9844..168a53ddc 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1717,27 +1717,27 @@ void ContextMenu::MakeObjectMenu(void) GObjectClass *klass = G_OBJECT_GET_CLASS(_object); //to deduce the object's type from its class GType type = G_TYPE_FROM_CLASS(klass); - if (type | SP_TYPE_ITEM) + if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_ITEM)) { MakeItemMenu (); } - if (type == SP_TYPE_GROUP) + if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_GROUP)) { MakeGroupMenu(); } - if (type == SP_TYPE_ANCHOR) + if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_ANCHOR)) { MakeAnchorMenu(); } - if (type == SP_TYPE_IMAGE) + if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_IMAGE)) { MakeImageMenu(); } - if (type == SP_TYPE_SHAPE) + if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_SHAPE)) { MakeShapeMenu(); } - if (type == SP_TYPE_TEXT) + if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_TEXT)) { MakeTextMenu(); } -- cgit v1.2.3 From f28cc16246f00cab98ae1b803adca8d62481dbee Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 6 Apr 2012 09:58:17 +0100 Subject: png-write: Fix FTBFS (bzr r11163) --- src/helper/png-write.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index febdb645e..35fd5a62a 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -16,11 +16,11 @@ # include "config.h" #endif +#include #include "interface.h" #include <2geom/rect.h> #include <2geom/transforms.h> #include -#include #include "png-write.h" #include "io/sys.h" #include "display/drawing.h" -- cgit v1.2.3 From bc72166fb6a4992d89a50ab7d9e8015a46562ee5 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 6 Apr 2012 15:31:20 +0100 Subject: filter-effects-dialog: Cairomm rendering (bzr r11164) --- src/ui/dialog/filter-effects-dialog.cpp | 86 ++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index da99594bb..dd3e90b2c 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -66,6 +66,7 @@ #include #include #include +#include using namespace Inkscape::Filters; @@ -1606,6 +1607,7 @@ bool FilterEffectsDialog::PrimitiveList::on_expose_signal(GdkEventExpose* e) Gdk::Rectangle clip(e->area.x, e->area.y, e->area.width, e->area.height); Glib::RefPtr win = get_bin_window(); Glib::RefPtr darkgc = get_style()->get_dark_gc(Gtk::STATE_NORMAL); + Cairo::RefPtr cr = get_bin_window()->create_cairo_context(); SPFilterPrimitive* prim = get_selected(); int row_count = get_model()->children().size(); @@ -1617,14 +1619,25 @@ bool FilterEffectsDialog::PrimitiveList::on_expose_signal(GdkEventExpose* e) if(row) { get_cell_area(get_model()->get_path(row), *get_column(1), rct); get_visible_rect(vis); - text_start_x = rct.get_x() + rct.get_width() - get_input_type_width() * FPInputConverter._length + 1; - for(unsigned int i = 0; i < FPInputConverter._length; ++i) { + + for(unsigned int i = 0; i < FPInputConverter._length; ++i) { _vertical_layout->set_text(_(FPInputConverter.get_label((FilterPrimitiveInput)i).c_str())); const int x = text_start_x + get_input_type_width() * i; - get_bin_window()->draw_rectangle(get_style()->get_bg_gc(Gtk::STATE_NORMAL), true, x, 0, get_input_type_width(), vis.get_height()); - get_bin_window()->draw_layout(get_style()->get_text_gc(Gtk::STATE_NORMAL), x + 1, 0, _vertical_layout); - get_bin_window()->draw_line(darkgc, x, 0, x, vis.get_height()); + cr->save(); + cr->rectangle(x, 0, get_input_type_width(), vis.get_height()); + Gdk::Cairo::set_source_color(cr, get_style()->get_bg(Gtk::STATE_NORMAL)); + cr->fill_preserve(); + Gdk::Cairo::set_source_color(cr, get_style()->get_text(Gtk::STATE_NORMAL)); + cr->move_to(x+get_input_type_width(), 0); + cr->rotate_degrees(90); + _vertical_layout->show_in_cairo_context(cr); + Gdk::Cairo::set_source_color(cr, get_style()->get_dark(Gtk::STATE_NORMAL)); + cr->set_line_width(1.0); + cr->move_to(x, 0); + cr->line_to(x, vis.get_height()); + cr->stroke(); + cr->restore(); } } @@ -1640,10 +1653,16 @@ bool FilterEffectsDialog::PrimitiveList::on_expose_signal(GdkEventExpose* e) // Outline the bottom of the connection area const int outline_x = x + fheight * (row_count - row_index); - get_bin_window()->draw_line(darkgc, x, y + h, outline_x, y + h); - + cr->save(); + Gdk::Cairo::set_source_color(cr, get_style()->get_dark(Gtk::STATE_NORMAL)); + cr->set_line_width(1.0); + cr->move_to(x, y + h); + cr->line_to(outline_x, y + h); // Side outline - get_bin_window()->draw_line(darkgc, outline_x, y - 1, outline_x, y + h); + cr->line_to(outline_x, y - 1); + + cr->stroke(); + cr->restore(); std::vector con_poly; int con_drag_y = 0; @@ -1693,10 +1712,15 @@ bool FilterEffectsDialog::PrimitiveList::on_expose_signal(GdkEventExpose* e) // Draw drag connection if(row_prim == prim && _in_drag) { - get_bin_window()->draw_line(get_style()->get_black_gc(), outline_x, con_drag_y, - mx, con_drag_y); - get_bin_window()->draw_line(get_style()->get_black_gc(), mx, con_drag_y, mx, my); - } + cr->save(); + Gdk::Cairo::set_source_color(cr, get_style()->get_black()); + cr->set_line_width(1.0); + cr->move_to(outline_x, con_drag_y); + cr->line_to(mx, con_drag_y); + cr->line_to(mx, my); + cr->stroke(); + cr->restore(); + } } return true; @@ -1708,32 +1732,37 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Gtk::TreeIter& in { int src_id = 0; Gtk::TreeIter res = find_result(input, attr, src_id); - Glib::RefPtr darkgc = get_style()->get_black_gc(); - Glib::RefPtr lightgc = get_style()->get_dark_gc(Gtk::STATE_NORMAL); - Glib::RefPtr gc; + Cairo::RefPtr cr = get_bin_window()->create_cairo_context(); const bool is_first = input == get_model()->children().begin(); const bool is_merge = SP_IS_FEMERGE((SPFilterPrimitive*)(*input)[_columns.primitive]); const bool use_default = !res && !is_merge; + cr->set_line_width(1); if(res == input || (use_default && is_first)) { // Draw straight connection to a standard input // Draw a lighter line for an implicit connection to a standard input const int tw = get_input_type_width(); gint end_x = text_start_x + tw * src_id + (int)(tw * 0.5f) + 1; - gc = (use_default && is_first) ? lightgc : darkgc; - get_bin_window()->draw_rectangle(gc, true, end_x-2, y1-2, 5, 5); - get_bin_window()->draw_line(gc, x1, y1, end_x, y1); + + if(use_default && is_first) + Gdk::Cairo::set_source_color(cr, get_style()->get_dark(Gtk::STATE_NORMAL)); + else + Gdk::Cairo::set_source_color(cr, get_style()->get_black()); + + cr->rectangle(end_x-2, y1-2, 5, 5); + cr->fill_preserve(); + cr->move_to(x1, y1); + cr->line_to(end_x, y1); + cr->stroke(); } else { // Draw an 'L'-shaped connection to another filter primitive // If no connection is specified, draw a light connection to the previous primitive - gc = use_default ? lightgc : darkgc; - - if(use_default) { - res = input; - --res; - } + if(use_default) { + res = input; + --res; + } if(res) { Gdk::Rectangle rct; @@ -1747,9 +1776,12 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Gtk::TreeIter& in const int y2 = rct.get_y() + rct.get_height(); // Draw a bevelled 'L'-shaped connection - get_bin_window()->draw_line(get_style()->get_black_gc(), x1, y1, x2-fheight/4, y1); - get_bin_window()->draw_line(get_style()->get_black_gc(), x2-fheight/4, y1, x2, y1-fheight/4); - get_bin_window()->draw_line(get_style()->get_black_gc(), x2, y1-fheight/4, x2, y2); + Gdk::Cairo::set_source_color(cr, get_style()->get_black()); + cr->move_to(x1, y1); + cr->line_to(x2-fheight/4, y1); + cr->line_to(x2, y1-fheight/4); + cr->line_to(x2, y2); + cr->stroke(); } } } -- cgit v1.2.3 From 195c3b296af31e6a6dfd22c3dfecd32ac682662d Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 6 Apr 2012 16:53:08 +0100 Subject: Fix remaining GTKMM deprecation issues Fixed bugs: - https://launchpad.net/bugs/943222 (bzr r11165) --- src/extension/internal/pdf-input-cairo.cpp | 14 ++++++++------ src/extension/internal/pdfinput/pdf-input.cpp | 17 ++++++++++------- 2 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp index bc76a30b5..36ef66713 100644 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@ -32,6 +32,7 @@ #include #include "ui/widget/spinbutton.h" +#include namespace Inkscape { namespace Extension { @@ -482,9 +483,10 @@ bool PdfImportCairoDialog::_onExposePreview(GdkEventExpose */*event*/) { if (!back_pixmap) { return true; } - back_pixmap->draw_pixbuf(Glib::RefPtr(), thumb, 0, 0, 0, 0, - _thumb_width, _thumb_height, - Gdk::RGB_DITHER_NONE, 0, 0); + + Cairo::RefPtr cr = back_pixmap->create_cairo_context(); + Gdk::Cairo::set_source_pixbuf(cr, thumb, 0, 0); + cr->paint(); _previewArea->get_window()->set_back_pixmap(back_pixmap, false); _previewArea->get_window()->clear(); } @@ -493,9 +495,9 @@ bool PdfImportCairoDialog::_onExposePreview(GdkEventExpose */*event*/) { if (_render_thumb) { copy_cairo_surface_to_pixbuf(_cairo_surface, _thumb_data, thumb->gobj()); } - _previewArea->get_window()->draw_pixbuf(Glib::RefPtr(), thumb, - 0, 0, 0, _render_thumb ? 0 : 20, - -1, -1, Gdk::RGB_DITHER_NONE, 0, 0); + Cairo::RefPtr cr = _previewArea->get_window()->create_cairo_context(); + Gdk::Cairo::set_source_pixbuf(cr, thumb, 0, _render_thumb ? 0 : 20); + cr->paint(); return true; } diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index ee091d54b..eff488c9d 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -51,6 +51,8 @@ #include "ui/widget/spinbutton.h" #include +#include + namespace Inkscape { namespace Extension { namespace Internal { @@ -513,10 +515,11 @@ bool PdfImportDialog::_onExposePreview(GdkEventExpose */*event*/) { if (!back_pixmap) { return true; } - back_pixmap->draw_pixbuf(Glib::RefPtr(), thumb, 0, 0, 0, 0, - _thumb_width, _thumb_height, - Gdk::RGB_DITHER_NONE, 0, 0); - _previewArea->get_window()->set_back_pixmap(back_pixmap, false); + + Cairo::RefPtr cr = back_pixmap->create_cairo_context(); + Gdk::Cairo::set_source_pixbuf(cr, thumb, 0, 0); + cr->paint(); + _previewArea->get_window()->set_back_pixmap(back_pixmap, false); _previewArea->get_window()->clear(); } #ifdef HAVE_POPPLER_CAIRO @@ -525,10 +528,10 @@ bool PdfImportDialog::_onExposePreview(GdkEventExpose */*event*/) { copy_cairo_surface_to_pixbuf(_cairo_surface, _thumb_data, thumb->gobj()); } #endif - _previewArea->get_window()->draw_pixbuf(Glib::RefPtr(), thumb, - 0, 0, 0, _render_thumb ? 0 : 20, - -1, -1, Gdk::RGB_DITHER_NONE, 0, 0); + Cairo::RefPtr cr = _previewArea->get_window()->create_cairo_context(); + Gdk::Cairo::set_source_pixbuf(cr, thumb, 0, _render_thumb ? 0 : 20); + cr->paint(); return true; } -- cgit v1.2.3 From e7c6906dfd496f02786ef57099629f7e6940f225 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 6 Apr 2012 18:41:00 +0100 Subject: drop some deprecated gdk_draw functions (bzr r11166) --- src/interface.h | 6 +++--- src/widgets/sp-color-slider.cpp | 26 ++++++++++++++++++-------- 2 files changed, 21 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/interface.h b/src/interface.h index fecfa4ae4..d6e4c1c4f 100644 --- a/src/interface.h +++ b/src/interface.h @@ -17,11 +17,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include -#include "sp-item.h" - +class SPItem; +class SPObject; +class SPDesktop; class SPViewWidget; namespace Inkscape { diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 17a33affe..b74be502b 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -585,30 +585,40 @@ sp_color_slider_paint (SPColorSlider *slider, GdkRectangle *area) if (gdk_rectangle_intersect (area, &aarea, &apaint)) { /* Draw arrow */ gdk_rectangle_intersect (&carea, &apaint, &apaint); - gdk_gc_set_clip_rectangle(style->white_gc, &apaint); - gdk_gc_set_clip_rectangle(style->black_gc, &apaint); + cairo_t* cr = gdk_cairo_create(window); + gdk_cairo_rectangle(cr, &apaint); + cairo_clip(cr); x = aarea.x; y1 = carea.y; y2 = aarea.y + aarea.height - 1; w = aarea.width; + cairo_set_line_width(cr, 1.0); + while ( w > 0 ) { - gdk_draw_line(window, style->white_gc, x, y1, x + w - 1, y1 ); - gdk_draw_line(window, style->white_gc, x, y2, x + w - 1, y2 ); + gdk_cairo_set_source_color(cr, &style->white); + cairo_move_to(cr, x - 0.5, y1 + 0.5); + cairo_line_to(cr, x + w - 1 + 0.5, y1 + 0.5); + cairo_move_to(cr, x - 0.5, y2 + 0.5); + cairo_line_to(cr, x + w - 1 + 0.5, y2 + 0.5); + cairo_stroke(cr); w -=2; x++; if ( w > 0 ) { - gdk_draw_line(window, style->black_gc, x, y1, x + w - 1, y1 ); - gdk_draw_line(window, style->black_gc, x, y2, x + w - 1, y2 ); + gdk_cairo_set_source_color(cr, &style->black); + cairo_move_to(cr, x - 0.5, y1 + 0.5); + cairo_line_to(cr, x + w - 1 + 0.5, y1 + 0.5); + cairo_move_to(cr, x - 0.5, y2 + 0.5); + cairo_line_to(cr, x + w - 1 + 0.5, y2 + 0.5); + cairo_stroke(cr); } y1++; y2--; } - gdk_gc_set_clip_rectangle(style->white_gc, NULL); - gdk_gc_set_clip_rectangle(style->black_gc, NULL); + cairo_destroy(cr); } } -- cgit v1.2.3 From f0e728e66264419d8dbeaab2f0b0a246cb2ae16d Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 6 Apr 2012 20:51:45 +0200 Subject: restore item order of dialogs in context menu (Bug #910529) (bzr r11167) --- src/interface.cpp | 72 +++++++++++++++++++------------------------------ src/interface.h | 80 ++++++++++++++++++++++++++++--------------------------- 2 files changed, 68 insertions(+), 84 deletions(-) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index 168a53ddc..319eceaec 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1593,6 +1593,8 @@ ContextMenu::ContextMenu(Inkscape::UI::View::View *view, SPItem *item) : AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DUPLICATE), view); AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DELETE), view); + + positionOfLastDialog = 10; // 9 in front + 1 for the separator in the next if; used to position the dialog menu entries below each other /* Item menu */ if (item!=NULL) { @@ -1749,10 +1751,9 @@ void ContextMenu::MakeItemMenu (void) /* Item dialog */ mi = new Gtk::MenuItem(_("_Object Properties..."),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemProperties)); mi->show(); - append(*mi); + append(*mi);//insert(*mi,positionOfLastDialog++); AddSeparator(); @@ -1761,7 +1762,6 @@ void ContextMenu::MakeItemMenu (void) if (_desktop->selection->includes(_item)) { mi->set_sensitive(FALSE); } else { - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemSelectThis)); } mi->show(); @@ -1772,7 +1772,6 @@ void ContextMenu::MakeItemMenu (void) if (_desktop->selection->isEmpty()) { mi->set_sensitive(FALSE); } else { - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SelectSameFillStroke)); } mi->set_sensitive(!SP_IS_ANCHOR(_item)); @@ -1781,7 +1780,6 @@ void ContextMenu::MakeItemMenu (void) /* Create link */ mi = new Gtk::MenuItem(_("_Create Link"),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemCreateLink)); mi->set_sensitive(!SP_IS_ANCHOR(_item)); mi->show(); @@ -1789,23 +1787,22 @@ void ContextMenu::MakeItemMenu (void) bool ClipRefOK=false; bool MaskRefOK=false; - if (_item){ - if (_item->clip_ref){ - if (_item->clip_ref->getObject()){ - ClipRefOK=true; - } - } - } - if (_item){ - if (_item->mask_ref){ - if (_item->mask_ref->getObject()){ - MaskRefOK=true; - } - } - } + if (_item){ + if (_item->clip_ref){ + if (_item->clip_ref->getObject()){ + ClipRefOK=true; + } + } + } + if (_item){ + if (_item->mask_ref){ + if (_item->mask_ref->getObject()){ + MaskRefOK=true; + } + } + } /* Set mask */ mi = new Gtk::MenuItem(_("Set Mask"),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetMask)); if (ClipRefOK || MaskRefOK) { mi->set_sensitive(FALSE); @@ -1817,7 +1814,6 @@ void ContextMenu::MakeItemMenu (void) /* Release mask */ mi = new Gtk::MenuItem(_("Release Mask"),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseMask)); if (MaskRefOK) { mi->set_sensitive(TRUE); @@ -1829,9 +1825,8 @@ void ContextMenu::MakeItemMenu (void) /* Set Clip */ mi = new Gtk::MenuItem(_("Set _Clip"),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SetClip)); - if (ClipRefOK || MaskRefOK) { + if (ClipRefOK || MaskRefOK) { mi->set_sensitive(FALSE); } else { mi->set_sensitive(TRUE); @@ -1841,9 +1836,8 @@ void ContextMenu::MakeItemMenu (void) /* Release Clip */ mi = new Gtk::MenuItem(_("Release C_lip"),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ReleaseClip)); - if (ClipRefOK) { + if (ClipRefOK) { mi->set_sensitive(TRUE); } else { mi->set_sensitive(FALSE); @@ -1917,7 +1911,6 @@ void ContextMenu::MakeGroupMenu(void) { /* "Ungroup" */ Gtk::MenuItem* mi = new Gtk::MenuItem(_("_Ungroup"),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroup)); mi->show(); append(*mi); @@ -1938,21 +1931,18 @@ void ContextMenu::MakeAnchorMenu(void) /* Link dialog */ mi = new Gtk::MenuItem(_("Link _Properties..."),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkProperties)); mi->show(); - append(*mi); + insert(*mi,positionOfLastDialog++);//append(*mi); /* Select item */ mi = new Gtk::MenuItem(_("_Follow Link"),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkFollow)); mi->show(); append(*mi); /* Reset transformations */ mi = new Gtk::MenuItem(_("_Remove Link"),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkRemove)); mi->show(); append(*mi); @@ -1983,17 +1973,15 @@ void ContextMenu::MakeImageMenu (void) /* Image properties */ mi = new Gtk::MenuItem(_("Image _Properties..."),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageProperties)); mi->show(); - append(*mi); + insert(*mi,positionOfLastDialog++);//append(*mi); /* Edit externally */ mi = new Gtk::MenuItem(_("Edit Externally..."),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEdit)); mi->show(); - append(*mi); + insert(*mi,positionOfLastDialog++);//append(*mi); if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { mi->set_sensitive( FALSE ); } @@ -2001,7 +1989,6 @@ void ContextMenu::MakeImageMenu (void) /* Embed image */ if (Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" )) { mi = new Gtk::MenuItem(C_("Context menu", "Embed Image")); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEmbed)); mi->show(); append(*mi); @@ -2013,10 +2000,9 @@ void ContextMenu::MakeImageMenu (void) /* Extract image */ if (Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" )) { mi = new Gtk::MenuItem(C_("Context menu", "Extract Image...")); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageExtract)); mi->show(); - append(*mi); + insert(*mi,positionOfLastDialog++);//append(*mi); if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { mi->set_sensitive( FALSE ); } @@ -2150,10 +2136,9 @@ void ContextMenu::MakeShapeMenu (void) /* Item dialog */ mi = new Gtk::MenuItem(_("_Fill and Stroke..."),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings)); mi->show(); - append(*mi); + insert(*mi,positionOfLastDialog++);//append(*mi); } void ContextMenu::FillSettings(void) @@ -2171,24 +2156,21 @@ void ContextMenu::MakeTextMenu (void) /* Fill and Stroke dialog */ mi = new Gtk::MenuItem(_("_Fill and Stroke..."),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings)); mi->show(); - append(*mi); + insert(*mi,positionOfLastDialog++);//append(*mi); /* Edit Text dialog */ mi = new Gtk::MenuItem(_("_Text and Font..."),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::TextSettings)); mi->show(); - append(*mi); + insert(*mi,positionOfLastDialog++);//append(*mi); /* Spellcheck dialog */ mi = new Gtk::MenuItem(_("Check Spellin_g..."),1); - mi->set_data("desktop", _desktop); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SpellcheckSettings)); mi->show(); - append(*mi); + insert(*mi,positionOfLastDialog++);//append(*mi); } /* Edit Text entry */ diff --git a/src/interface.h b/src/interface.h index d6e4c1c4f..e21a0f752 100644 --- a/src/interface.h +++ b/src/interface.h @@ -86,50 +86,52 @@ class ContextMenu : public Gtk::Menu ~ContextMenu(void); private: SPItem *_item; - SPObject *_object; - SPDesktop *_desktop; - - std::vector separators; + SPObject *_object; + SPDesktop *_desktop; + + int positionOfLastDialog; + + std::vector separators; Gtk::MenuItem MIGroup; Gtk::MenuItem MIParent; Gtk::SeparatorMenuItem* AddSeparator(void); void AppendItemFromVerb(Inkscape::Verb *verb, Inkscape::UI::View::View *view); - void MakeObjectMenu (void); - void MakeItemMenu (void); - void MakeGroupMenu (void); - void MakeAnchorMenu (void); - void MakeImageMenu (void); - void MakeShapeMenu (void); - void MakeTextMenu (void); - - void EnterGroup(Gtk::MenuItem* mi); - void LeaveGroup(void); - void ItemProperties(void); - void ItemSelectThis(void); - void SelectSameFillStroke(void); - void ItemCreateLink(void); - void SetMask(void); - void ReleaseMask(void); - void SetClip(void); - void ReleaseClip(void); - - void ActivateUngroup(void); - - void AnchorLinkProperties(void); - void AnchorLinkFollow(void); - void AnchorLinkRemove(void); - - void ImageProperties(void); - void ImageEdit(void); - Glib::ustring getImageEditorName(); - void ImageEmbed(void); - void ImageExtract(void); - - void FillSettings(void); - - void TextSettings(void); - void SpellcheckSettings(void); + void MakeObjectMenu (void); + void MakeItemMenu (void); + void MakeGroupMenu (void); + void MakeAnchorMenu (void); + void MakeImageMenu (void); + void MakeShapeMenu (void); + void MakeTextMenu (void); + + void EnterGroup(Gtk::MenuItem* mi); + void LeaveGroup(void); + void ItemProperties(void); + void ItemSelectThis(void); + void SelectSameFillStroke(void); + void ItemCreateLink(void); + void SetMask(void); + void ReleaseMask(void); + void SetClip(void); + void ReleaseClip(void); + + void ActivateUngroup(void); + + void AnchorLinkProperties(void); + void AnchorLinkFollow(void); + void AnchorLinkRemove(void); + + void ImageProperties(void); + void ImageEdit(void); + Glib::ustring getImageEditorName(); + void ImageEmbed(void); + void ImageExtract(void); + + void FillSettings(void); + + void TextSettings(void); + void SpellcheckSettings(void); }; #endif // SEEN_SP_INTERFACE_H -- cgit v1.2.3 From 969832ce77568a3af3ae1685c2c67eea11badfb4 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 7 Apr 2012 14:31:31 +0200 Subject: the knotholders for LPE parameters should not derive from LPEKnotHolderEntity as this prevents deletion (bzr r11168) --- src/live_effects/parameter/point.cpp | 2 +- src/live_effects/parameter/vector.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index e3731fdcf..eb2543ac7 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -127,7 +127,7 @@ PointParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint knot_color = color; } -class PointParamKnotHolderEntity : public LPEKnotHolderEntity { +class PointParamKnotHolderEntity : public KnotHolderEntity { public: PointParamKnotHolderEntity(PointParam *p) { this->pparam = p; } virtual ~PointParamKnotHolderEntity() {} diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index e8725c4b2..21a7222a6 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -137,7 +137,7 @@ VectorParam::set_origin_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mod ori_knot_color = color; } -class VectorParamKnotHolderEntity_Origin : public LPEKnotHolderEntity { +class VectorParamKnotHolderEntity_Origin : public KnotHolderEntity { public: VectorParamKnotHolderEntity_Origin(VectorParam *p) : param(p) { } virtual ~VectorParamKnotHolderEntity_Origin() {} @@ -158,7 +158,7 @@ private: VectorParam *param; }; -class VectorParamKnotHolderEntity_Vector : public LPEKnotHolderEntity { +class VectorParamKnotHolderEntity_Vector : public KnotHolderEntity { public: VectorParamKnotHolderEntity_Vector(VectorParam *p) : param(p) { } virtual ~VectorParamKnotHolderEntity_Vector() {} -- cgit v1.2.3 From fb8edb4724c724b6ac4d40f0546971d4082a8df7 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 7 Apr 2012 14:33:30 +0200 Subject: powerstrokepointarray : add todo comment. do not derive from LPEKnotHolderEntity. (bzr r11169) --- src/live_effects/parameter/powerstrokepointarray.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 5bf5c51c7..9e138a7ae 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -117,7 +117,7 @@ PowerStrokePointArrayParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotMode knot_color = color; } -class PowerStrokePointArrayParamKnotHolderEntity : public LPEKnotHolderEntity { +class PowerStrokePointArrayParamKnotHolderEntity : public KnotHolderEntity { public: PowerStrokePointArrayParamKnotHolderEntity(PowerStrokePointArrayParam *p, unsigned int index); virtual ~PowerStrokePointArrayParamKnotHolderEntity() {} @@ -184,6 +184,7 @@ void PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state) { //g_print ("This is the %d handle associated to parameter '%s'\n", _index, _pparam->param_key.c_str()); + bool knotarray_changed = false; if (state & GDK_CONTROL_MASK) { if (state & GDK_MOD1_MASK) { @@ -199,6 +200,10 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state) } } + if (knotarray_changed) { + // if knot array has been changed, the on-canvas knots must be reloaded + /// \todo reload knots! + } } void -- cgit v1.2.3 From 7867b2ae755a4217c14365e3b1b18484ba98712b Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 7 Apr 2012 16:09:58 +0200 Subject: cleanup knotholder code for LPEs (bzr r11170) --- src/knot-holder-entity.h | 11 +++++ src/live_effects/effect.cpp | 29 ++----------- src/live_effects/effect.h | 5 +-- src/live_effects/lpe-angle_bisector.cpp | 72 +++++++++++++++---------------- src/live_effects/lpe-angle_bisector.h | 11 ++--- src/live_effects/lpe-copy_rotate.cpp | 62 ++++++++++++++------------ src/live_effects/lpe-copy_rotate.h | 1 + src/live_effects/lpe-knot.cpp | 43 +++++++++--------- src/live_effects/lpe-knot.h | 5 ++- src/live_effects/lpe-parallel.cpp | 59 ++++++++++++++----------- src/live_effects/lpe-parallel.h | 1 + src/live_effects/lpe-perp_bisector.cpp | 47 ++++++++++++-------- src/live_effects/lpe-perp_bisector.h | 1 + src/live_effects/lpe-perspective_path.cpp | 38 ++++++++-------- src/live_effects/lpe-perspective_path.h | 1 + src/live_effects/lpe-skeleton.cpp | 25 ++++++++--- src/live_effects/lpe-skeleton.h | 13 +++--- src/live_effects/lpe-tangent_to_curve.cpp | 66 +++++++++++++++++----------- src/live_effects/lpe-tangent_to_curve.h | 1 + 19 files changed, 266 insertions(+), 225 deletions(-) (limited to 'src') diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h index 5422e6d1b..f1513779a 100644 --- a/src/knot-holder-entity.h +++ b/src/knot-holder-entity.h @@ -25,6 +25,12 @@ struct SPKnot; class SPDesktop; class KnotHolder; +namespace Inkscape { +namespace LivePathEffect { + class Effect; +} +} + typedef void (* SPKnotHolderSetFunc) (SPItem *item, Geom::Point const &p, Geom::Point const &origin, guint state); typedef Geom::Point (* SPKnotHolderGetFunc) (SPItem *item); /* fixme: Think how to make callbacks most sensitive (Lauris) */ @@ -83,6 +89,11 @@ public: // derived KnotHolderEntity class for LPEs class LPEKnotHolderEntity : public KnotHolderEntity { +public: + LPEKnotHolderEntity(Inkscape::LivePathEffect::Effect *effect) : _effect(effect) {}; +protected: + Inkscape::LivePathEffect::Effect *_effect; +private: virtual bool isDeletable() { return false; } }; diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 0b1fe1160..44e57addf 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -282,7 +282,8 @@ Effect::createAndApply(EffectType type, SPDocument *doc, SPItem *item) } Effect::Effect(LivePathEffectObject *lpeobject) - : oncanvasedit_it(0), + : _provides_knotholder_entities(false), + oncanvasedit_it(0), is_visible(_("Is visible?"), _("If unchecked, the effect remains applied to the object but is temporarily disabled on canvas"), "is_visible", &wr, this, true), show_orig_path(false), lpeobj(lpeobject), @@ -468,12 +469,6 @@ Effect::registerParameter(Parameter * param) param_vector.push_back(param); } -// TODO: should we provide a way to alter the handle's appearance? -void -Effect::registerKnotHolderHandle(KnotHolderEntity* entity, const char* descr) -{ - kh_entity_vector.push_back(std::make_pair(entity, descr)); -} /** * Add all registered LPE knotholder handles to the knotholder @@ -491,23 +486,6 @@ Effect::addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { } } -void -Effect::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { - // TODO: The entities in kh_entity_vector are already instantiated during the call - // to registerKnotHolderHandle(), but they are recreated here. Also, we must not - // delete them when the knotholder is destroyed, whence the clumsy function - // isDeletable(). If we could create entities of different classes dynamically, - // this would be much nicer. How to do this? - std::vector >::iterator i; - for (i = kh_entity_vector.begin(); i != kh_entity_vector.end(); ++i) { - KnotHolderEntity *entity = i->first; - const char *descr = i->second; - - entity->create(desktop, item, knotholder, descr); - knotholder->add(entity); - } -} - /** * Return a vector of PathVectors which contain all helperpaths that should be drawn by the effect. * This is the function called by external code like SPLPEItem. @@ -688,8 +666,9 @@ bool Effect::providesKnotholder() { // does the effect actively provide any knotholder entities of its own? - if (kh_entity_vector.size() > 0) + if (_provides_knotholder_entities) { return true; + } // otherwise: are there any parameters that have knotholderentities? for (std::vector::iterator p = param_vector.begin(); p != param_vector.end(); ++p) { diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 50d4c142b..008de5ea8 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -124,15 +124,14 @@ protected: doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); void registerParameter(Parameter * param); - void registerKnotHolderHandle(KnotHolderEntity* entity, const char* descr); Parameter * getNextOncanvasEditableParam(); - void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); + virtual void addKnotHolderEntities(KnotHolder * /*knotholder*/, SPDesktop * /*desktop*/, SPItem * /*item*/) {}; virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector &hp_vec); std::vector param_vector; - std::vector > kh_entity_vector; + bool _provides_knotholder_entities; int oncanvasedit_it; BoolParam is_visible; diff --git a/src/live_effects/lpe-angle_bisector.cpp b/src/live_effects/lpe-angle_bisector.cpp index aee4f48a1..99110c51e 100644 --- a/src/live_effects/lpe-angle_bisector.cpp +++ b/src/live_effects/lpe-angle_bisector.cpp @@ -1,47 +1,38 @@ #define INKSCAPE_LPE_ANGLE_BISECTOR_CPP -/** \file - * LPE implementation, used as an example for a base starting class - * when implementing new LivePathEffects. - * - * In vi, three global search-and-replaces will let you rename everything - * in this and the .h file: - * - * :%s/ANGLE_BISECTOR/YOURNAME/g - * :%s/AngleBisector/Yourname/g - * :%s/angle_bisector/yourname/g - */ /* * Authors: - * Johan Engelen + * Maximilian Albert + * Johan Engelen * - * Copyright (C) Johan Engelen 2007 + * Copyright (C) Authors 2007-2012 * * Released under GNU GPL, read the file 'COPYING' for more information */ #include "live_effects/lpe-angle_bisector.h" -// You might need to include other 2geom files. You can add them here: #include <2geom/path.h> #include <2geom/sbasis-to-bezier.h> #include "sp-lpe-item.h" +#include "knot-holder-entity.h" +#include "knotholder.h" namespace Inkscape { namespace LivePathEffect { namespace AB { -class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity -{ +class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity { public: + KnotHolderEntityLeftEnd(LPEAngleBisector* effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); }; -class KnotHolderEntityRightEnd : public LPEKnotHolderEntity -{ +class KnotHolderEntityRightEnd : public LPEKnotHolderEntity { public: + KnotHolderEntityRightEnd(LPEAngleBisector* effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); }; @@ -54,12 +45,10 @@ LPEAngleBisector::LPEAngleBisector(LivePathEffectObject *lpeobject) : length_right(_("Length right"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 250) { show_orig_path = true; + _provides_knotholder_entities = true; registerParameter( dynamic_cast(&length_left) ); registerParameter( dynamic_cast(&length_right) ); - - registerKnotHolderHandle(new AB::KnotHolderEntityLeftEnd(), _("Adjust the \"left\" end of the bisector")); - registerKnotHolderHandle(new AB::KnotHolderEntityRightEnd(), _("Adjust the \"right\" of the bisector")); } LPEAngleBisector::~LPEAngleBisector() @@ -89,25 +78,32 @@ LPEAngleBisector::doEffect_path (std::vector const & path_in) return path_from_piecewise(output, LPE_CONVERSION_TOLERANCE); } -namespace AB { -// TODO: make this more generic -static LPEAngleBisector * -get_effect(SPItem *item) -{ - Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); - if (effect->effectType() != ANGLE_BISECTOR) { - g_print ("Warning: Effect is not of type LPEAngleBisector!\n"); - return NULL; +void +LPEAngleBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { + { + KnotHolderEntity *e = new AB::KnotHolderEntityLeftEnd(this); + e->create( desktop, item, knotholder, + _("Adjust the \"left\" end of the bisector") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); } - return static_cast(effect); -} + { + KnotHolderEntity *e = new AB::KnotHolderEntityRightEnd(this); + e->create( desktop, item, knotholder, + _("Adjust the \"right\" of the bisector") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); + } +}; + +namespace AB { void KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { - LPEAngleBisector *lpe = get_effect(item); - + LPEAngleBisector *lpe = dynamic_cast(_effect); + Geom::Point const s = snap_knot_position(p); double lambda = Geom::nearest_point(s, lpe->ptA, lpe->dir); @@ -119,8 +115,8 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori void KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { - LPEAngleBisector *lpe = get_effect(item); - + LPEAngleBisector *lpe = dynamic_cast(_effect); + Geom::Point const s = snap_knot_position(p); double lambda = Geom::nearest_point(s, lpe->ptA, lpe->dir); @@ -132,14 +128,14 @@ KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*or Geom::Point KnotHolderEntityLeftEnd::knot_get() { - LPEAngleBisector *lpe = get_effect(item); + LPEAngleBisector *lpe = dynamic_cast(_effect); return lpe->ptA - lpe->dir * lpe->length_left; } Geom::Point KnotHolderEntityRightEnd::knot_get() { - LPEAngleBisector *lpe = get_effect(item); + LPEAngleBisector *lpe = dynamic_cast(_effect); return lpe->ptA + lpe->dir * lpe->length_right; } diff --git a/src/live_effects/lpe-angle_bisector.h b/src/live_effects/lpe-angle_bisector.h index 0fd4c112f..95048751e 100644 --- a/src/live_effects/lpe-angle_bisector.h +++ b/src/live_effects/lpe-angle_bisector.h @@ -1,22 +1,18 @@ #ifndef INKSCAPE_LPE_ANGLE_BISECTOR_H #define INKSCAPE_LPE_ANGLE_BISECTOR_H -/** \file - * LPE implementation, see lpe-angle_bisector.cpp. - */ - /* * Authors: - * Johan Engelen + * Maximilian Albert + * Johan Engelen * - * Copyright (C) Johan Engelen 2007 + * Copyright (C) Authors 2007-2012 * * Released under GNU GPL, read the file 'COPYING' for more information */ #include "live_effects/effect.h" #include "live_effects/parameter/parameter.h" -#include "live_effects/parameter/point.h" namespace Inkscape { namespace LivePathEffect { @@ -36,6 +32,7 @@ public: friend class AB::KnotHolderEntityLeftEnd; friend class AB::KnotHolderEntityRightEnd; + void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); //private: ScalarParam length_left; diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index e77d80994..c61f4c3c1 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -4,10 +4,10 @@ */ /* * Authors: - * Maximilian Albert + * Maximilian Albert + * Johan Engelen * - * Copyright (C) Johan Engelen 2007 - * Copyright (C) Maximilian Albert 2008 + * Copyright (C) Authors 2007-2012 * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -21,21 +21,24 @@ #include <2geom/d2-sbasis.h> #include <2geom/angle.h> +#include "knot-holder-entity.h" +#include "knotholder.h" + namespace Inkscape { namespace LivePathEffect { namespace CR { -class KnotHolderEntityStartingAngle : public LPEKnotHolderEntity -{ +class KnotHolderEntityStartingAngle : public LPEKnotHolderEntity { public: + KnotHolderEntityStartingAngle(LPECopyRotate *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); }; -class KnotHolderEntityRotationAngle : public LPEKnotHolderEntity -{ +class KnotHolderEntityRotationAngle : public LPEKnotHolderEntity { public: + KnotHolderEntityRotationAngle(LPECopyRotate *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); }; @@ -51,6 +54,7 @@ LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) : dist_angle_handle(100) { show_orig_path = true; + _provides_knotholder_entities = true; // register all your parameters here, so Inkscape knows which parameters this effect has: registerParameter( dynamic_cast(&starting_angle) ); @@ -58,12 +62,8 @@ LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(&num_copies) ); registerParameter( dynamic_cast(&origin) ); - registerKnotHolderHandle(new CR::KnotHolderEntityStartingAngle(), _("Adjust the starting angle")); - registerKnotHolderHandle(new CR::KnotHolderEntityRotationAngle(), _("Adjust the rotation angle")); - num_copies.param_make_integer(true); num_copies.param_set_range(0, 1000); - } LPECopyRotate::~LPECopyRotate() @@ -127,26 +127,32 @@ LPECopyRotate::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vectorcreate( desktop, item, knotholder, + _("Adjust the starting angle") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); + } + { + KnotHolderEntity *e = new CR::KnotHolderEntityRotationAngle(this); + e->create( desktop, item, knotholder, + _("Adjust the rotation angle") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); + } +}; + namespace CR { using namespace Geom; -// TODO: make this more generic -static LPECopyRotate * -get_effect(SPItem *item) -{ - Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); - if (effect->effectType() != COPY_ROTATE) { - g_print ("Warning: Effect is not of type LPECopyRotate!\n"); - return NULL; - } - return static_cast(effect); -} - void KnotHolderEntityStartingAngle::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { - LPECopyRotate* lpe = get_effect(item); + LPECopyRotate* lpe = dynamic_cast(_effect); Geom::Point const s = snap_knot_position(p); @@ -166,7 +172,7 @@ KnotHolderEntityStartingAngle::knot_set(Geom::Point const &p, Geom::Point const void KnotHolderEntityRotationAngle::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { - LPECopyRotate* lpe = get_effect(item); + LPECopyRotate* lpe = dynamic_cast(_effect); Geom::Point const s = snap_knot_position(p); @@ -186,19 +192,21 @@ KnotHolderEntityRotationAngle::knot_set(Geom::Point const &p, Geom::Point const Geom::Point KnotHolderEntityStartingAngle::knot_get() { - LPECopyRotate* lpe = get_effect(item); + LPECopyRotate* lpe = dynamic_cast(_effect); return snap_knot_position(lpe->start_pos); } Geom::Point KnotHolderEntityRotationAngle::knot_get() { - LPECopyRotate* lpe = get_effect(item); + LPECopyRotate* lpe = dynamic_cast(_effect); return snap_knot_position(lpe->rot_pos); } } // namespace CR + + /* ######################## */ } //namespace LivePathEffect diff --git a/src/live_effects/lpe-copy_rotate.h b/src/live_effects/lpe-copy_rotate.h index 8cabdfb48..b14bc4128 100644 --- a/src/live_effects/lpe-copy_rotate.h +++ b/src/live_effects/lpe-copy_rotate.h @@ -38,6 +38,7 @@ public: /* the knotholder entity classes must be declared friends */ friend class CR::KnotHolderEntityStartingAngle; friend class CR::KnotHolderEntityRotationAngle; + void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); protected: virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector &hp_vec); diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index d8c13a515..7a66b80c9 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -5,8 +5,9 @@ /* Authors: * Jean-Francois Barraud * Abhishek Sharma + * Johan Engelen * - * Copyright (C) 2007 Authors + * Copyright (C) 2007-2012 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -18,6 +19,7 @@ #include "svg/svg.h" #include "style.h" #include "knot-holder-entity.h" +#include "knotholder.h" #include <2geom/sbasis-to-bezier.h> #include <2geom/sbasis.h> @@ -38,11 +40,9 @@ namespace Inkscape { namespace LivePathEffect { -class KnotHolderEntityCrossingSwitcher : public LPEKnotHolderEntity -{ +class KnotHolderEntityCrossingSwitcher : public LPEKnotHolderEntity { public: - virtual ~KnotHolderEntityCrossingSwitcher() {} - + KnotHolderEntityCrossingSwitcher(LPEKnot *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); virtual void knot_click(guint state); @@ -357,10 +357,11 @@ LPEKnot::LPEKnot(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(&switcher_size) ); registerParameter( dynamic_cast(&crossing_points_vector) ); - registerKnotHolderHandle(new KnotHolderEntityCrossingSwitcher(), _("Drag to select a crossing, click to flip it")); crossing_points = LPEKnotNS::CrossingPoints(); selectedCrossing = 0; switcher = Geom::Point(0,0); + + _provides_knotholder_entities = true; } LPEKnot::~LPEKnot() @@ -582,18 +583,6 @@ LPEKnot::doBeforeEffect (SPLPEItem *lpeitem) updateSwitcher(); } - -static LPEKnot * -get_effect(SPItem *item) -{ - Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); - if (effect->effectType() != KNOT) { - g_print ("Warning: Effect is not of type LPEKnot!\n"); - return NULL; - } - return static_cast(effect); -} - void LPEKnot::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector &hp_vec) { @@ -617,10 +606,22 @@ LPEKnot::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vectorcreate( desktop, item, knotholder, + _("Drag to select a crossing, click to flip it") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); + } +}; + + void KnotHolderEntityCrossingSwitcher::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { - LPEKnot* lpe = get_effect(item); + LPEKnot* lpe = dynamic_cast(_effect); lpe->selectedCrossing = idx_of_nearest(lpe->crossing_points,p); lpe->updateSwitcher(); @@ -631,14 +632,14 @@ KnotHolderEntityCrossingSwitcher::knot_set(Geom::Point const &p, Geom::Point con Geom::Point KnotHolderEntityCrossingSwitcher::knot_get() { - LPEKnot* lpe = get_effect(item); + LPEKnot* lpe = dynamic_cast(_effect); return snap_knot_position(lpe->switcher); } void KnotHolderEntityCrossingSwitcher::knot_click(guint state) { - LPEKnot* lpe = get_effect(item); + LPEKnot* lpe = dynamic_cast(_effect); unsigned s = lpe->selectedCrossing; if (s < lpe->crossing_points.size()){ if (state & GDK_SHIFT_MASK){ diff --git a/src/live_effects/lpe-knot.h b/src/live_effects/lpe-knot.h index e3dcb0b7f..14c61a4e5 100644 --- a/src/live_effects/lpe-knot.h +++ b/src/live_effects/lpe-knot.h @@ -3,9 +3,9 @@ */ /* Authors: * Jean-Francois Barraud - * Johan Engelen + * Johan Engelen * - * Copyright (C) Johan Engelen 2007 + * Copyright (C) Authors 2007-2012 * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -61,6 +61,7 @@ public: /* the knotholder entity classes must be declared friends */ friend class KnotHolderEntityCrossingSwitcher; + void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); protected: virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector &hp_vec); diff --git a/src/live_effects/lpe-parallel.cpp b/src/live_effects/lpe-parallel.cpp index 5b373442b..4d15bf13e 100644 --- a/src/live_effects/lpe-parallel.cpp +++ b/src/live_effects/lpe-parallel.cpp @@ -6,7 +6,7 @@ * Authors: * Maximilian Albert * - * Copyright (C) Johan Engelen 2007 + * Copyright (C) Johan Engelen 2007-2012 * Copyright (C) Maximilian Albert 2008 * * Released under GNU GPL, read the file 'COPYING' for more information @@ -19,21 +19,24 @@ #include <2geom/path.h> #include <2geom/transforms.h> +#include "knot-holder-entity.h" +#include "knotholder.h" + namespace Inkscape { namespace LivePathEffect { namespace Pl { -class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity -{ +class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity { public: + KnotHolderEntityLeftEnd(LPEParallel *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); }; -class KnotHolderEntityRightEnd : public LPEKnotHolderEntity -{ +class KnotHolderEntityRightEnd : public LPEKnotHolderEntity { public: + KnotHolderEntityRightEnd(LPEParallel *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); }; @@ -48,13 +51,11 @@ LPEParallel::LPEParallel(LivePathEffectObject *lpeobject) : length_right(_("Length right"), _("Specifies the right end of the parallel"), "length-right", &wr, this, 150) { show_orig_path = true; + _provides_knotholder_entities = true; registerParameter(dynamic_cast(&offset_pt)); registerParameter( dynamic_cast(&length_left) ); registerParameter( dynamic_cast(&length_right) ); - - registerKnotHolderHandle(new Pl::KnotHolderEntityLeftEnd(), _("Adjust the \"left\" end of the parallel")); - registerKnotHolderHandle(new Pl::KnotHolderEntityRightEnd(), _("Adjust the \"right\" end of the parallel")); } LPEParallel::~LPEParallel() @@ -93,27 +94,33 @@ LPEParallel::doEffect_pwd2 (Geom::Piecewise > const & pwd return output + dir; } -namespace Pl { - -// TODO: make this more generic -static LPEParallel * -get_effect(SPItem *item) -{ - Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); - if (effect->effectType() != PARALLEL) { - g_print ("Warning: Effect is not of type LPEParallel!\n"); - return NULL; +void +LPEParallel::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { + { + KnotHolderEntity *e = new Pl::KnotHolderEntityLeftEnd(this); + e->create( desktop, item, knotholder, + _("Adjust the \"left\" end of the parallel") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); } - return static_cast(effect); -} + { + KnotHolderEntity *e = new Pl::KnotHolderEntityRightEnd(this); + e->create( desktop, item, knotholder, + _("Adjust the \"right\" end of the parallel") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); + } +}; + +namespace Pl { void KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { using namespace Geom; - LPEParallel *lpe = get_effect(item); - + LPEParallel *lpe = dynamic_cast(_effect); + Geom::Point const s = snap_knot_position(p); double lambda = L2(s - lpe->offset_pt) * sgn(dot(s - lpe->offset_pt, lpe->dir)); @@ -127,8 +134,8 @@ KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*or { using namespace Geom; - LPEParallel *lpe = get_effect(item); - + LPEParallel *lpe = dynamic_cast(_effect); + Geom::Point const s = snap_knot_position(p); double lambda = L2(s - lpe->offset_pt) * sgn(dot(s - lpe->offset_pt, lpe->dir)); @@ -140,14 +147,14 @@ KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*or Geom::Point KnotHolderEntityLeftEnd::knot_get() { - LPEParallel *lpe = get_effect(item); + LPEParallel *lpe = dynamic_cast(_effect); return lpe->C; } Geom::Point KnotHolderEntityRightEnd::knot_get() { - LPEParallel *lpe = get_effect(item); + LPEParallel *lpe = dynamic_cast(_effect); return lpe->D; } diff --git a/src/live_effects/lpe-parallel.h b/src/live_effects/lpe-parallel.h index 6dc426aa8..e23361675 100644 --- a/src/live_effects/lpe-parallel.h +++ b/src/live_effects/lpe-parallel.h @@ -39,6 +39,7 @@ public: /* the knotholder entity classes must be declared friends */ friend class Pl::KnotHolderEntityLeftEnd; friend class Pl::KnotHolderEntityRightEnd; + void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); private: PointParam offset_pt; diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index ac720b88b..ddf16cc9a 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -20,55 +20,48 @@ #include "sp-lpe-item.h" #include <2geom/path.h> +#include "knot-holder-entity.h" +#include "knotholder.h" + namespace Inkscape { namespace LivePathEffect { namespace PB { class KnotHolderEntityEnd : public LPEKnotHolderEntity { public: + KnotHolderEntityEnd(LPEPerpBisector *effect) : LPEKnotHolderEntity(effect) {}; void bisector_end_set(Geom::Point const &p, bool left = true); }; class KnotHolderEntityLeftEnd : public KnotHolderEntityEnd { public: + KnotHolderEntityLeftEnd(LPEPerpBisector *effect) : KnotHolderEntityEnd(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); }; class KnotHolderEntityRightEnd : public KnotHolderEntityEnd { public: + KnotHolderEntityRightEnd(LPEPerpBisector *effect) : KnotHolderEntityEnd(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); }; -// TODO: Make this more generic -static LPEPerpBisector * -get_effect(SPItem *item) -{ - Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); - if (effect->effectType() != PERP_BISECTOR) { - g_print ("Warning: Effect is not of type LPEPerpBisector!\n"); - return NULL; - } - return static_cast(effect); -} - Geom::Point KnotHolderEntityLeftEnd::knot_get() { - Inkscape::LivePathEffect::LPEPerpBisector *lpe = get_effect(item); + LPEPerpBisector *lpe = dynamic_cast(_effect); return Geom::Point(lpe->C); } Geom::Point KnotHolderEntityRightEnd::knot_get() { - Inkscape::LivePathEffect::LPEPerpBisector *lpe = get_effect(item); + LPEPerpBisector *lpe = dynamic_cast(_effect); return Geom::Point(lpe->D); } void KnotHolderEntityEnd::bisector_end_set(Geom::Point const &p, bool left) { - Inkscape::LivePathEffect::LPEPerpBisector *lpe = - dynamic_cast (sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item))); + LPEPerpBisector *lpe = dynamic_cast(_effect); if (!lpe) return; Geom::Point const s = snap_knot_position(p); @@ -105,13 +98,11 @@ LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) : A(0,0), B(0,0), M(0,0), C(0,0), D(0,0), perp_dir(0,0) { show_orig_path = true; + _provides_knotholder_entities = true; // register all your parameters here, so Inkscape knows which parameters this effect has: registerParameter( dynamic_cast(&length_left) ); registerParameter( dynamic_cast(&length_right) ); - - registerKnotHolderHandle(new PB::KnotHolderEntityLeftEnd(), _("Adjust the bisector's \"left\" end")); - registerKnotHolderHandle(new PB::KnotHolderEntityRightEnd(), _("Adjust the bisector's \"right\" end")); } LPEPerpBisector::~LPEPerpBisector() @@ -159,6 +150,24 @@ LPEPerpBisector::doEffect_pwd2 (Geom::Piecewise > const & return output; } +void +LPEPerpBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { + { + KnotHolderEntity *e = new PB::KnotHolderEntityLeftEnd(this); + e->create( desktop, item, knotholder, + _("Adjust the bisector's \"left\" end") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); + } + { + KnotHolderEntity *e = new PB::KnotHolderEntityRightEnd(this); + e->create( desktop, item, knotholder, + _("Adjust the bisector's \"right\" end") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); + } +}; + /* ######################## */ } //namespace LivePathEffect diff --git a/src/live_effects/lpe-perp_bisector.h b/src/live_effects/lpe-perp_bisector.h index baa440822..823717e62 100644 --- a/src/live_effects/lpe-perp_bisector.h +++ b/src/live_effects/lpe-perp_bisector.h @@ -47,6 +47,7 @@ public: friend class PB::KnotHolderEntityLeftEnd; friend class PB::KnotHolderEntityRightEnd; friend void PB::bisector_end_set(SPItem *item, Geom::Point const &p, bool left = true); + void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); private: ScalarParam length_left; diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index 9208d4aeb..d9df32076 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -4,9 +4,9 @@ */ /* Authors: * Maximilian Albert - * Johan Engelen + * Johan Engelen * - * Copyright (C) 2007-2008 Authors + * Copyright (C) 2007-2012 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -18,6 +18,7 @@ #include "live_effects/lpe-perspective_path.h" #include "sp-item-group.h" #include "knot-holder-entity.h" +#include "knotholder.h" #include "inkscape.h" @@ -31,6 +32,7 @@ namespace PP { class KnotHolderEntityOffset : public LPEKnotHolderEntity { public: + KnotHolderEntityOffset(LPEPerspectivePath *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); }; @@ -53,14 +55,11 @@ LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(&offsety) ); registerParameter( dynamic_cast(&uses_plane_xy) ); - registerKnotHolderHandle(new PP::KnotHolderEntityOffset(), _("Adjust the origin")); - concatenate_before_pwd2 = true; // don't split the path into its subpaths + _provides_knotholder_entities = true; Persp3D *persp = persp3d_document_first_persp(inkscape_active_document()); - Proj::TransfMat3x4 pmat = persp->perspective_impl->tmat; - pmat.copy_tmat(tmat); } @@ -138,26 +137,25 @@ LPEPerspectivePath::doEffect_pwd2 (Geom::Piecewise > cons return output; } -namespace PP { - -// TODO: make this more generic -static LPEPerspectivePath * -get_effect(SPItem *item) -{ - Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); - if (effect->effectType() != PERSPECTIVE_PATH) { - g_print ("Warning: Effect is not of type LPEPerspectivePath!\n"); - return NULL; +void +LPEPerspectivePath::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { + { + KnotHolderEntity *e = new PP::KnotHolderEntityOffset(this); + e->create( desktop, item, knotholder, + _("Adjust the origin") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); } - return static_cast(effect); -} +}; + +namespace PP { void KnotHolderEntityOffset::knot_set(Geom::Point const &p, Geom::Point const &origin, guint /*state*/) { using namespace Geom; - LPEPerspectivePath* lpe = get_effect(item); + LPEPerspectivePath* lpe = dynamic_cast(_effect); Geom::Point const s = snap_knot_position(p); @@ -171,7 +169,7 @@ KnotHolderEntityOffset::knot_set(Geom::Point const &p, Geom::Point const &origin Geom::Point KnotHolderEntityOffset::knot_get() { - LPEPerspectivePath* lpe = get_effect(item); + LPEPerspectivePath* lpe = dynamic_cast(_effect); return lpe->orig + Geom::Point(lpe->offsetx, -lpe->offsety); } diff --git a/src/live_effects/lpe-perspective_path.h b/src/live_effects/lpe-perspective_path.h index ad4d307c1..14321f52e 100644 --- a/src/live_effects/lpe-perspective_path.h +++ b/src/live_effects/lpe-perspective_path.h @@ -40,6 +40,7 @@ public: /* the knotholder entity classes must be declared friends */ friend class PP::KnotHolderEntityOffset; + void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); private: // add the parameters for your effect here: diff --git a/src/live_effects/lpe-skeleton.cpp b/src/live_effects/lpe-skeleton.cpp index 08f31da7e..f3d7788d6 100644 --- a/src/live_effects/lpe-skeleton.cpp +++ b/src/live_effects/lpe-skeleton.cpp @@ -11,9 +11,9 @@ * :%s/skeleton/yourname/g */ /* Authors: - * Johan Engelen + * Johan Engelen * - * Copyright (C) 2007 Authors + * Copyright (C) 2007-2012 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -23,6 +23,9 @@ // You might need to include other 2geom files. You can add them here: #include <2geom/path.h> +//#include "knot-holder-entity.h" +//#include "knotholder.h" + namespace Inkscape { namespace LivePathEffect { @@ -33,12 +36,11 @@ LPESkeleton::LPESkeleton(LivePathEffectObject *lpeobject) : { /* uncomment the following line to have the original path displayed while the item is selected */ //show_orig_path = true; + /* uncomment the following line to enable display of the effect-specific on-canvas handles (knotholder entities) */ + //_provides_knotholder_entities /* register all your parameters here, so Inkscape knows which parameters this effect has: */ registerParameter( dynamic_cast(&number) ); - - /* register all your knotholder handles here: */ - //registerKnotHolderHandle(new Skeleton::KnotHolderEntityAttachMyHandle(), _("help message")); } LPESkeleton::~LPESkeleton() @@ -80,7 +82,7 @@ LPESkeleton::doEffect_pwd2 (Geom::Piecewise > const & pwd } /* ######################## - * Define the classes for your knotholder handles here + * If you want to provide effect-specific on-canvas handles (knotholder entities), define them here: */ /* @@ -96,6 +98,17 @@ public: }; } // namespace Skeleton + +void +LPESkeleton::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { + { + KnotHolderEntityMyHandle *e = new KnotHolderEntityMyHandle(this); + e->create( desktop, item, knotholder, + _("Text describing what this handle does"), + //optional: knot_shape, knot_mode, knot_color); + knotholder->add(e); + } +}; */ /* ######################## */ diff --git a/src/live_effects/lpe-skeleton.h b/src/live_effects/lpe-skeleton.h index 104ef3489..124d1a4cb 100644 --- a/src/live_effects/lpe-skeleton.h +++ b/src/live_effects/lpe-skeleton.h @@ -2,9 +2,9 @@ * @brief Minimal LPE effect, see lpe-skeleton.cpp. */ /* Authors: - * Johan Engelen + * Johan Engelen * - * Copyright (C) 2007 Authors + * Copyright (C) 2007-2012 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -18,8 +18,10 @@ namespace Inkscape { namespace LivePathEffect { -// each knotholder handle for your LPE requires a separate class derived from KnotHolderEntity; -// define it in lpe-skeleton.cpp and register it in the effect's constructor +// each knotholder handle for your LPE requires a separate class derived from LPEKnotHolderEntity; +// define it in lpe-skeleton.cpp and add code to create it in addKnotHolderEntities +// note that the LPE parameter classes implement their own handles! So in most cases, you will +// not have to do anything like this. /** namespace Skeleton { // we need a separate namespace to avoid clashes with other LPEs @@ -37,8 +39,9 @@ public: // virtual std::vector doEffect_path (std::vector const & path_in); virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); - /* the knotholder entity classes (if any) must be declared friends */ + /* the knotholder entity classes (if any) can be declared friends */ //friend class Skeleton::KnotHolderEntityMyHandle; + //virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); private: // add the parameters for your effect here: diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index a2d3cd061..04cc3335f 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -23,21 +23,24 @@ #include <2geom/path.h> #include <2geom/transforms.h> +#include "knot-holder-entity.h" +#include "knotholder.h" + namespace Inkscape { namespace LivePathEffect { namespace TtC { -class KnotHolderEntityAttachPt : public LPEKnotHolderEntity -{ +class KnotHolderEntityAttachPt : public LPEKnotHolderEntity { public: + KnotHolderEntityAttachPt(LPETangentToCurve *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); }; -class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity -{ +class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity { public: + KnotHolderEntityLeftEnd(LPETangentToCurve *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); }; @@ -45,6 +48,7 @@ public: class KnotHolderEntityRightEnd : public LPEKnotHolderEntity { public: + KnotHolderEntityRightEnd(LPETangentToCurve *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get(); }; @@ -59,15 +63,12 @@ LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) : length_right(_("Length right"), _("Specifies the right end of the tangent"), "length-right", &wr, this, 150) { show_orig_path = true; + _provides_knotholder_entities = true; registerParameter( dynamic_cast(&angle) ); registerParameter( dynamic_cast(&t_attach) ); registerParameter( dynamic_cast(&length_left) ); registerParameter( dynamic_cast(&length_right) ); - - registerKnotHolderHandle(new TtC::KnotHolderEntityAttachPt(), _("Adjust the point of attachment of the tangent")); - registerKnotHolderHandle(new TtC::KnotHolderEntityLeftEnd(), _("Adjust the \"left\" end of the tangent")); - registerKnotHolderHandle(new TtC::KnotHolderEntityRightEnd(), _("Adjust the \"right\" end of the tangent")); } LPETangentToCurve::~LPETangentToCurve() @@ -95,26 +96,39 @@ LPETangentToCurve::doEffect_pwd2 (Geom::Piecewise > const return output; } -namespace TtC { - -// TODO: make this more generic -static LPETangentToCurve * -get_effect(SPItem *item) -{ - Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); - if (effect->effectType() != TANGENT_TO_CURVE) { - g_print ("Warning: Effect is not of type LPETangentToCurve!\n"); - return NULL; +void +LPETangentToCurve::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { + { + KnotHolderEntity *e = new TtC::KnotHolderEntityAttachPt(this); + e->create( desktop, item, knotholder, + _("Adjust the point of attachment of the tangent") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); } - return static_cast(effect); -} + { + KnotHolderEntity *e = new TtC::KnotHolderEntityLeftEnd(this); + e->create( desktop, item, knotholder, + _("Adjust the \"left\" end of the tangent") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); + } + { + KnotHolderEntity *e = new TtC::KnotHolderEntityRightEnd(this); + e->create( desktop, item, knotholder, + _("Adjust the \"right\" end of the tangent") + /*optional: knot_shape, knot_mode, knot_color*/); + knotholder->add(e); + } +}; + +namespace TtC { void KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { using namespace Geom; - LPETangentToCurve* lpe = get_effect(item); + LPETangentToCurve* lpe = dynamic_cast(_effect); Geom::Point const s = snap_knot_position(p); @@ -136,7 +150,7 @@ KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*or void KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { - LPETangentToCurve *lpe = get_effect(item); + LPETangentToCurve *lpe = dynamic_cast(_effect); Geom::Point const s = snap_knot_position(p); @@ -149,7 +163,7 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori void KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { - LPETangentToCurve *lpe = get_effect(item); + LPETangentToCurve *lpe = dynamic_cast(_effect); Geom::Point const s = snap_knot_position(p); @@ -162,21 +176,21 @@ KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*or Geom::Point KnotHolderEntityAttachPt::knot_get() { - LPETangentToCurve* lpe = get_effect(item); + LPETangentToCurve* lpe = dynamic_cast(_effect); return lpe->ptA; } Geom::Point KnotHolderEntityLeftEnd::knot_get() { - LPETangentToCurve *lpe = get_effect(item); + LPETangentToCurve *lpe = dynamic_cast(_effect); return lpe->C; } Geom::Point KnotHolderEntityRightEnd::knot_get() { - LPETangentToCurve *lpe = get_effect(item); + LPETangentToCurve *lpe = dynamic_cast(_effect); return lpe->D; } diff --git a/src/live_effects/lpe-tangent_to_curve.h b/src/live_effects/lpe-tangent_to_curve.h index 8fe54335c..309afc14b 100644 --- a/src/live_effects/lpe-tangent_to_curve.h +++ b/src/live_effects/lpe-tangent_to_curve.h @@ -42,6 +42,7 @@ public: friend class TtC::KnotHolderEntityLeftEnd; friend class TtC::KnotHolderEntityRightEnd; friend class TtC::KnotHolderEntityAttachPt; + virtual void addKnotHolderEntities(KnotHolder * knotholder, SPDesktop * desktop, SPItem * item); private: ScalarParam angle; -- cgit v1.2.3 From a239540f0ae3f19e8af2d85acdf12ad40563087a Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 7 Apr 2012 16:24:51 +0200 Subject: remove no longer needed knotholderentity complication (bzr r11171) --- src/knot-holder-entity.h | 8 -------- src/knotholder.cpp | 8 +------- 2 files changed, 1 insertion(+), 15 deletions(-) (limited to 'src') diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h index f1513779a..ec936d464 100644 --- a/src/knot-holder-entity.h +++ b/src/knot-holder-entity.h @@ -48,12 +48,6 @@ public: SPKnotModeType mode = SP_KNOT_MODE_XOR, guint32 color = 0xffffff00); - /* derived classes used for LPE knotholder handles use this to indicate that they - must not be deleted when a knotholder is destroyed */ - // TODO: it would be nice to ditch this but then we need to dynamically create instances of different - // KnotHolderEntity classes in Effect::addKnotHolderEntities. How to do this??? - virtual bool isDeletable() { return true; } - /* the get/set/click handlers are virtual functions; each handler class for a knot should be derived from KnotHolderEntity and override these functions */ virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) = 0; @@ -93,8 +87,6 @@ public: LPEKnotHolderEntity(Inkscape::LivePathEffect::Effect *effect) : _effect(effect) {}; protected: Inkscape::LivePathEffect::Effect *_effect; -private: - virtual bool isDeletable() { return false; } }; /* pattern manipulation */ diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 91013ad2e..513c02834 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -68,13 +68,7 @@ KnotHolder::~KnotHolder() { g_object_unref(G_OBJECT(item)); for(std::list::iterator i = entity.begin(); i != entity.end(); ++i) { KnotHolderEntity* e = (*i); - if (e->isDeletable()) { - delete (*i); - } else { - // we must not delete the entity (since it's attached to an LPE parameter), - // but the handle should be destroyed - g_object_unref(e->knot); - } + delete (*i); (*i) = NULL; } entity.clear(); // is this necessary? -- cgit v1.2.3 From 3057a2e445f0b5a4b65b4fe0c3763295469545ef Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 7 Apr 2012 18:59:21 +0100 Subject: Fix some deprecated GDK key symbols (bzr r11172) --- src/arc-context.cpp | 68 ++++++++++++++++++++++++++++++++------------------ src/box3d-context.cpp | 69 +++++++++++++++++++++++++++++++++++---------------- 2 files changed, 91 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/arc-context.cpp b/src/arc-context.cpp index b62da2db8..ceea63c05 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -48,6 +48,26 @@ #include "arc-context.h" #include "display/sp-canvas-item.h" +// Define new form of key macros if we're using an old GTK+ version +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_space 0x020 +#endif + using Inkscape::DocumentUndo; static void sp_arc_context_class_init(SPArcContextClass *klass); @@ -319,14 +339,14 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent break; case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Meta_L: // Meta is when you press Shift+Alt (at least on my machine) - case GDK_Meta_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt (at least on my machine) + case GDK_KEY_Meta_R: if (!dragging) { sp_event_show_modifier_tip(event_context->defaultMessageContext(), event, _("Ctrl: make circle or integer-ratio ellipse, snap arc/segment angle"), @@ -334,22 +354,22 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent NULL); } break; - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: // prevent the zoom field from activation if (!MOD__CTRL_ONLY) ret = TRUE; break; - case GDK_x: - case GDK_X: + case GDK_KEY_x: + case GDK_KEY_X: if (MOD__ALT_ONLY) { desktop->setToolboxFocusTo ("altx-arc"); ret = TRUE; } break; - case GDK_Escape: + case GDK_KEY_Escape: if (dragging) { dragging = false; sp_event_context_discard_delayed_snap_event(event_context); @@ -358,7 +378,7 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent ret = TRUE; } break; - case GDK_space: + case GDK_KEY_space: if (dragging) { sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); @@ -378,14 +398,14 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent break; case GDK_KEY_RELEASE: switch (event->key.keyval) { - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Meta_L: // Meta is when you press Shift+Alt - case GDK_Meta_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt + case GDK_KEY_Meta_R: event_context->defaultMessageContext()->clear(); break; default: diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index 12487d1a9..2ffef98e1 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -51,6 +51,31 @@ #include "shape-editor.h" #include "verbs.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_parenright 0x029 +#define GDK_KEY_parenleft 0x028 +#define GDK_KEY_braceright 0x07d +#define GDK_KEY_braceleft 0x07b +#define GDK_KEY_G 0x047 +#define GDK_KEY_g 0x067 +#define GDK_KEY_p 0x070 +#define GDK_KEY_P 0x050 +#define GDK_KEY_X 0x058 +#define GDK_KEY_x 0x078 +#define GDK_KEY_y 0x079 +#define GDK_KEY_Y 0x059 +#define GDK_KEY_Z 0x05a +#define GDK_KEY_z 0x07a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_space 0x020 +#endif + using Inkscape::DocumentUndo; static void sp_box3d_context_class_init(Box3DContextClass *klass); @@ -429,51 +454,51 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven break; case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: // prevent the zoom field from activation if (!MOD__CTRL_ONLY) ret = TRUE; break; - case GDK_bracketright: + case GDK_KEY_bracketright: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::X, -180/snaps, MOD__ALT); DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; - case GDK_bracketleft: + case GDK_KEY_bracketleft: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::X, 180/snaps, MOD__ALT); DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; - case GDK_parenright: + case GDK_KEY_parenright: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Y, -180/snaps, MOD__ALT); DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; - case GDK_parenleft: + case GDK_KEY_parenleft: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Y, 180/snaps, MOD__ALT); DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; - case GDK_braceright: + case GDK_KEY_braceright: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Z, -180/snaps, MOD__ALT); DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; - case GDK_braceleft: + case GDK_KEY_braceleft: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Z, 180/snaps, MOD__ALT); DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); @@ -490,16 +515,16 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven break; */ - case GDK_g: - case GDK_G: + case GDK_KEY_g: + case GDK_KEY_G: if (MOD__SHIFT_ONLY) { sp_selection_to_guides(desktop); ret = true; } break; - case GDK_p: - case GDK_P: + case GDK_KEY_p: + case GDK_KEY_P: if (MOD__SHIFT_ONLY) { if (document->getCurrentPersp3D()) { persp3d_print_debugging_info (document->getCurrentPersp3D()); @@ -508,8 +533,8 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven } break; - case GDK_x: - case GDK_X: + case GDK_KEY_x: + case GDK_KEY_X: if (MOD__ALT_ONLY) { desktop->setToolboxFocusTo ("altx-box3d"); ret = TRUE; @@ -521,8 +546,8 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven } break; - case GDK_y: - case GDK_Y: + case GDK_KEY_y: + case GDK_KEY_Y: if (MOD__SHIFT_ONLY) { persp3d_toggle_VPs(selection->perspList(), Proj::Y); bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically? @@ -530,8 +555,8 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven } break; - case GDK_z: - case GDK_Z: + case GDK_KEY_z: + case GDK_KEY_Z: if (MOD__SHIFT_ONLY) { persp3d_toggle_VPs(selection->perspList(), Proj::Z); bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically? @@ -539,12 +564,12 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven } break; - case GDK_Escape: + case GDK_KEY_Escape: sp_desktop_selection(desktop)->clear(); //TODO: make dragging escapable by Esc break; - case GDK_space: + case GDK_KEY_space: if (dragging) { sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); -- cgit v1.2.3 From 42e13d16575ec1e7563c77f6571bfc09a2059146 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 7 Apr 2012 21:17:29 +0200 Subject: gives distinguishing colors to two vector params of LPE rough hatches (bzr r11173) --- src/live_effects/lpe-rough-hatches.cpp | 4 +++- src/live_effects/parameter/vector.cpp | 7 +++++++ src/live_effects/parameter/vector.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index a6fdde02a..f9ab72373 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -246,7 +246,6 @@ LPERoughHatches::LPERoughHatches(LivePathEffectObject *lpeobject) : direction(_("Hatches width and dir"), _("Defines hatches frequency and direction"), "direction", &wr, this, Geom::Point(50,0)), // - //bender(_("Global bending"), _("Relative position to a reference point defines global bending direction and amount"), "bender", &wr, this, NULL, Geom::Point(-5,0)), bender(_("Global bending"), _("Relative position to a reference point defines global bending direction and amount"), "bender", &wr, this, Geom::Point(-5,0)) { registerParameter( dynamic_cast(&direction) ); @@ -281,6 +280,9 @@ LPERoughHatches::LPERoughHatches(LivePathEffectObject *lpeobject) : // hide the widgets for direction and bender vectorparams direction.widget_is_visible = false; bender.widget_is_visible = false; + // give distinguishing colors to direction and bender on-canvas params + direction.set_oncanvas_color(0x00ff7d00); + bender.set_oncanvas_color(0xffffb500); concatenate_before_pwd2 = false; show_orig_path = true; diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index 21a7222a6..3e0ac9092 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -137,6 +137,13 @@ VectorParam::set_origin_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mod ori_knot_color = color; } +void +VectorParam::set_oncanvas_color(guint32 color) +{ + vec_knot_color = color; + ori_knot_color = color; +} + class VectorParamKnotHolderEntity_Origin : public KnotHolderEntity { public: VectorParamKnotHolderEntity_Origin(VectorParam *p) : param(p) { } diff --git a/src/live_effects/parameter/vector.h b/src/live_effects/parameter/vector.h index 5d6d1c932..f82affe16 100644 --- a/src/live_effects/parameter/vector.h +++ b/src/live_effects/parameter/vector.h @@ -50,6 +50,7 @@ public: void set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_origin_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); + void set_oncanvas_color(guint32 color); virtual bool providesKnotHolderEntities() { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); -- cgit v1.2.3 From 38876d0538b2fff87e8fd7b54ac3d77dbd779511 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 7 Apr 2012 21:25:08 +0200 Subject: fix possible crasher in knot_clicked_handler (bzr r11174) --- src/knotholder.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 513c02834..1bb09a05b 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -105,7 +105,8 @@ bool KnotHolder::knot_mouseover() void KnotHolder::knot_clicked_handler(SPKnot *knot, guint state) { - KnotHolder *knot_holder = this; + KnotHolder *knot_holder = this; + SPItem *saved_item = this->item; for(std::list::iterator i = knot_holder->entity.begin(); i != knot_holder->entity.end(); ++i) { KnotHolderEntity *e = *i; @@ -116,33 +117,33 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state) } } - if (SP_IS_SHAPE(item)) { - SP_SHAPE(item)->setShape(); + if (SP_IS_SHAPE(saved_item)) { + SP_SHAPE(saved_item)->setShape(); } knot_holder->update_knots(); unsigned int object_verb = SP_VERB_NONE; - if (SP_IS_RECT(item)) + if (SP_IS_RECT(saved_item)) object_verb = SP_VERB_CONTEXT_RECT; - else if (SP_IS_BOX3D(item)) + else if (SP_IS_BOX3D(saved_item)) object_verb = SP_VERB_CONTEXT_3DBOX; - else if (SP_IS_GENERICELLIPSE(item)) + else if (SP_IS_GENERICELLIPSE(saved_item)) object_verb = SP_VERB_CONTEXT_ARC; - else if (SP_IS_STAR(item)) + else if (SP_IS_STAR(saved_item)) object_verb = SP_VERB_CONTEXT_STAR; - else if (SP_IS_SPIRAL(item)) + else if (SP_IS_SPIRAL(saved_item)) object_verb = SP_VERB_CONTEXT_SPIRAL; - else if (SP_IS_OFFSET(item)) { - if (SP_OFFSET(item)->sourceHref) + else if (SP_IS_OFFSET(saved_item)) { + if (SP_OFFSET(saved_item)->sourceHref) object_verb = SP_VERB_SELECTION_LINKED_OFFSET; else object_verb = SP_VERB_SELECTION_DYNAMIC_OFFSET; } // for drag, this is done by ungrabbed_handler, but for click we must do it here - DocumentUndo::done(item->document, object_verb, + DocumentUndo::done(saved_item->document, object_verb, _("Change handle")); } -- cgit v1.2.3 From bdda1cad52c9fe447028bdcea90166cdc2ac8799 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 7 Apr 2012 21:57:31 +0200 Subject: powerstroke: use path's strokewidth on applying powerstroke effect (bzr r11175) --- src/live_effects/lpe-powerstroke.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index d3843dc92..8edee1744 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -14,6 +14,7 @@ #include "live_effects/lpe-powerstroke-interpolators.h" #include "sp-shape.h" +#include "style.h" #include "display/curve.h" #include <2geom/path.h> @@ -182,11 +183,21 @@ LPEPowerStroke::doOnApply(SPLPEItem *lpeitem) { if (SP_IS_SHAPE(lpeitem)) { std::vector points; - Geom::PathVector pathv = SP_SHAPE(lpeitem)->_curve->get_pathvector(); - Geom::Path::size_type size = pathv.empty() ? 1 : pathv.front().size_open(); - points.push_back( Geom::Point(0,0) ); - points.push_back( Geom::Point(0.5*size,0) ); - points.push_back( Geom::Point(size,0) ); + Geom::PathVector const &pathv = SP_SHAPE(lpeitem)->_curve->get_pathvector(); + double width = (lpeitem && lpeitem->style) ? lpeitem->style->stroke_width.computed : 1.; + if (pathv.empty()) { + points.push_back( Geom::Point(0.,width) ); + points.push_back( Geom::Point(0.5,width) ); + points.push_back( Geom::Point(1.,width) ); + } else { + Geom::Path const &path = pathv.front(); + Geom::Path::size_type const size = path.size_default(); + points.push_back( Geom::Point(0.,width) ); + points.push_back( Geom::Point(0.5*size,width) ); + if (!path.closed()) { + points.push_back( Geom::Point(size,width) ); + } + } offset_points.param_set_and_write_new_value(points); } else { g_warning("LPE Powerstroke can only be applied to shapes (not groups)."); -- cgit v1.2.3 From 81c64dce84baa41d81d0788b88069947fb5f8c23 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 7 Apr 2012 22:12:21 +0200 Subject: complementary to rev11175 (bzr r11176) --- src/live_effects/lpe-powerstroke.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 8edee1744..fc6a46a54 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -353,7 +353,7 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise // check size of miter Geom::Point point_on_path = B[prev_i].at1() - rot90(der1) * cusp.width; Geom::Coord len = distance(bzr1.pointAt(cross[0].ta), point_on_path); - if (len > cusp.width * miter_limit) { + if (len > fabs(cusp.width) * miter_limit) { // miter too big: default to bevel pb.lineTo(B[i].at0()); } else { -- cgit v1.2.3 From 334e6ebbdc346f47014e7b00a5e17d8f60a9c0fa Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 7 Apr 2012 22:19:41 +0200 Subject: powerstroke: previous and this commit fix extrapolated and miter join behavior for negative widths (sorry, multitasking error...) (bzr r11177) --- src/live_effects/lpe-powerstroke.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index fc6a46a54..17baa837f 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -382,7 +382,7 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise // check size of miter Geom::Point point_on_path = B[prev_i].at1() - rot90(der1) * cusp.width; Geom::Coord len = distance(*p, point_on_path); - if (len <= cusp.width * miter_limit) { + if (len <= fabs(cusp.width) * miter_limit) { // miter OK pb.lineTo(*p); } -- cgit v1.2.3 From 096ec6139f4f6ab8229db1692c496770de551698 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 7 Apr 2012 23:06:28 +0200 Subject: powerstroke: fix line caps for end/start knots with no handle (1st deriv == 0) (bzr r11178) --- src/live_effects/lpe-powerstroke.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 17baa837f..878811275 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -34,6 +34,9 @@ namespace Geom { // should all be moved to 2geom at some point +/** +* note that -unitTangentAt(reverse(a),0.) == unitTangentAt(a,1.) but the former is more reliable (sometimes the sign is wrong for the latter) +*/ Point unitTangentAt( D2 const & a, Coord t, unsigned n = 3) { std::vector derivs = a.valueAndDerivatives(t, n); for (unsigned deriv_n = 1; deriv_n < derivs.size(); deriv_n++) { @@ -525,7 +528,7 @@ LPEPowerStroke::doEffect_path (std::vector const & path_in) break; case LINECAP_PEAK: { - Geom::Point end_deriv = unit_vector(der.lastValue()); + Geom::Point end_deriv = -unitTangentAt( reverse(pwd2_in.segs.back()), 0.); double radius = 0.5 * distance(pwd2_out.lastValue(), mirrorpath.firstValue()); Geom::Point midpoint = 0.5*(pwd2_out.lastValue() + mirrorpath.firstValue()) + radius*end_deriv; fixed_path.appendNew(midpoint); @@ -534,7 +537,7 @@ LPEPowerStroke::doEffect_path (std::vector const & path_in) } case LINECAP_SQUARE: { - Geom::Point end_deriv = unit_vector(der.lastValue()); + Geom::Point end_deriv = -unitTangentAt( reverse(pwd2_in.segs.back()), 0.); double radius = 0.5 * distance(pwd2_out.lastValue(), mirrorpath.firstValue()); fixed_path.appendNew( pwd2_out.lastValue() + radius*end_deriv ); fixed_path.appendNew( mirrorpath.firstValue() + radius*end_deriv ); @@ -563,7 +566,7 @@ LPEPowerStroke::doEffect_path (std::vector const & path_in) break; case LINECAP_PEAK: { - Geom::Point start_deriv = unit_vector(der.firstValue()); + Geom::Point start_deriv = unitTangentAt( pwd2_in.segs.front(), 0.); double radius = 0.5 * distance(pwd2_out.firstValue(), mirrorpath.lastValue()); Geom::Point midpoint = 0.5*(mirrorpath.lastValue() + pwd2_out.firstValue()) - radius*start_deriv; fixed_path.appendNew( midpoint ); @@ -572,7 +575,7 @@ LPEPowerStroke::doEffect_path (std::vector const & path_in) } case LINECAP_SQUARE: { - Geom::Point start_deriv = unit_vector(der.firstValue()); + Geom::Point start_deriv = unitTangentAt( pwd2_in.segs.front(), 0.); double radius = 0.5 * distance(pwd2_out.firstValue(), mirrorpath.lastValue()); fixed_path.appendNew( mirrorpath.lastValue() - radius*start_deriv ); fixed_path.appendNew( pwd2_out.firstValue() - radius*start_deriv ); -- cgit v1.2.3 From fe90e67c8b69a8c9ee4022b6e581eefa798b3353 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 7 Apr 2012 23:16:34 +0200 Subject: circle tool: fix shift click to reset to full circle for start angle node (bzr r11179) --- src/object-edit.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 1c828e1e5..528f202ab 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -719,6 +719,7 @@ class ArcKnotHolderEntityStart : public KnotHolderEntity { public: virtual Geom::Point knot_get(); virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_click(guint state); }; class ArcKnotHolderEntityEnd : public KnotHolderEntity { @@ -792,6 +793,17 @@ ArcKnotHolderEntityStart::knot_get() return sp_arc_get_xy(arc, ge->start); } +void +ArcKnotHolderEntityStart::knot_click(guint state) +{ + SPGenericEllipse *ge = SP_GENERICELLIPSE(item); + + if (state & GDK_SHIFT_MASK) { + ge->end = ge->start = 0; + (static_cast(ge))->updateRepr(); + } +} + void ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { -- cgit v1.2.3 From 736d7a269f58740a3c724914abc016542f05a16c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 8 Apr 2012 01:17:30 +0100 Subject: More GDK key macro fixes, and some cursor referencing (bzr r11180) --- src/connector-context.cpp | 23 +++-- src/knot.h | 24 +++++ src/tweak-context.cpp | 179 +++++++++++++++++++++++++------------- src/ui/widget/registered-widget.h | 2 +- src/zoom-context.cpp | 28 ++++-- 5 files changed, 178 insertions(+), 78 deletions(-) (limited to 'src') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 1c631c446..cf8d73bd2 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -194,6 +194,13 @@ using Inkscape::DocumentUndo; +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Delete 0xffff +#endif + static void sp_connector_context_class_init(SPConnectorContextClass *klass); static void sp_connector_context_init(SPConnectorContext *conn_context); static void sp_connector_context_dispose(GObject *object); @@ -1156,15 +1163,15 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) if ( cc->mode == SP_CONNECTOR_CONTEXT_DRAWING_MODE ) { switch (keyval) { - case GDK_Return: - case GDK_KP_Enter: + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: if (cc->npoints != 0) { spcc_connector_finish(cc); cc->state = SP_CONNECTOR_CONTEXT_IDLE; ret = TRUE; } break; - case GDK_Escape: + case GDK_KEY_Escape: if (cc->state == SP_CONNECTOR_CONTEXT_REROUTING) { SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); @@ -1195,7 +1202,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) switch ( cc->state ) { case SP_CONNECTOR_CONTEXT_DRAGGING: - if ( keyval == GDK_Escape ) + if ( keyval == GDK_KEY_Escape ) { // Cancel connection point dragging @@ -1209,7 +1216,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) _("Connection point drag cancelled.")); ret = TRUE; } - else if ( keyval == GDK_Return || keyval == GDK_KP_Enter ) + else if ( keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter ) { // Put connection point at current position @@ -1233,7 +1240,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) } break; case SP_CONNECTOR_CONTEXT_NEWCONNPOINT: - if ( keyval == GDK_Escape ) + if ( keyval == GDK_KEY_Escape ) { // Just destroy the knot g_object_unref( cc->selected_handle ); @@ -1241,7 +1248,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) cc->state = SP_CONNECTOR_CONTEXT_IDLE; ret = TRUE; } - else if ( keyval == GDK_Return || keyval == GDK_KP_Enter ) + else if ( keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter ) { SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); SPDocument *doc = sp_desktop_document(desktop); @@ -1272,7 +1279,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) break; case SP_CONNECTOR_CONTEXT_IDLE: - if ( keyval == GDK_Delete && cc->selected_handle ) + if ( keyval == GDK_KEY_Delete && cc->selected_handle ) { cc->active_shape->avoidRef->deleteConnectionPoint(cc->connpthandles[cc->selected_handle]); cc->selected_handle = NULL; diff --git a/src/knot.h b/src/knot.h index 73bb226c6..02f21c917 100644 --- a/src/knot.h +++ b/src/knot.h @@ -100,27 +100,51 @@ struct SPKnot : GObject { } inline void setCursor (GdkCursor* normal, GdkCursor* mouseover, GdkCursor* dragging) { if (cursor[SP_KNOT_STATE_NORMAL]) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(cursor[SP_KNOT_STATE_NORMAL]); +#else gdk_cursor_unref(cursor[SP_KNOT_STATE_NORMAL]); +#endif } cursor[SP_KNOT_STATE_NORMAL] = normal; if (normal) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_ref(normal); +#else gdk_cursor_ref(normal); +#endif } if (cursor[SP_KNOT_STATE_MOUSEOVER]) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(cursor[SP_KNOT_STATE_MOUSEOVER]); +#else gdk_cursor_unref(cursor[SP_KNOT_STATE_MOUSEOVER]); +#endif } cursor[SP_KNOT_STATE_MOUSEOVER] = mouseover; if (mouseover) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_ref(mouseover); +#else gdk_cursor_ref(mouseover); +#endif } if (cursor[SP_KNOT_STATE_DRAGGING]) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(cursor[SP_KNOT_STATE_DRAGGING]); +#else gdk_cursor_unref(cursor[SP_KNOT_STATE_DRAGGING]); +#endif } cursor[SP_KNOT_STATE_DRAGGING] = dragging; if (dragging) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_ref(dragging); +#else gdk_cursor_ref(dragging); +#endif } } diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 3d4bde2ac..112711d3b 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -81,6 +81,65 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_M 0x04d +#define GDK_KEY_m 0x06d +#define GDK_KEY_0 0x030 +#define GDK_KEY_1 0x031 +#define GDK_KEY_2 0x032 +#define GDK_KEY_3 0x033 +#define GDK_KEY_4 0x034 +#define GDK_KEY_5 0x035 +#define GDK_KEY_6 0x036 +#define GDK_KEY_7 0x037 +#define GDK_KEY_8 0x038 +#define GDK_KEY_9 0x039 +#define GDK_KEY_I 0x049 +#define GDK_KEY_i 0x069 +#define GDK_KEY_Z 0x05a +#define GDK_KEY_z 0x07a +#define GDK_KEY_less 0x03c +#define GDK_KEY_comma 0x02c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_period 0x02e +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_d 0x064 +#define GDK_KEY_D 0x044 +#define GDK_KEY_P 0x050 +#define GDK_KEY_p 0x070 +#define GDK_KEY_S 0x053 +#define GDK_KEY_s 0x073 +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_R 0x052 +#define GDK_KEY_r 0x072 +#define GDK_KEY_c 0x063 +#define GDK_KEY_C 0x043 +#define GDK_KEY_J 0x04a +#define GDK_KEY_j 0x06a +#define GDK_KEY_b 0x062 +#define GDK_KEY_B 0x042 +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_X 0x058 +#define GDK_KEY_x 0x078 +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#endif + static void sp_tweak_context_class_init(SPTweakContextClass *klass); static void sp_tweak_context_init(SPTweakContext *ddc); static void sp_tweak_context_dispose(GObject *object); @@ -1322,112 +1381,112 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_PRESS: { switch (get_group0_keyval (&event->key)) { - case GDK_m: - case GDK_M: - case GDK_0: + case GDK_KEY_m: + case GDK_KEY_M: + case GDK_KEY_0: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_MOVE, MOD__SHIFT); ret = TRUE; } break; - case GDK_i: - case GDK_I: - case GDK_1: + case GDK_KEY_i: + case GDK_KEY_I: + case GDK_KEY_1: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_MOVE_IN_OUT, MOD__SHIFT); ret = TRUE; } break; - case GDK_z: - case GDK_Z: - case GDK_2: + case GDK_KEY_z: + case GDK_KEY_Z: + case GDK_KEY_2: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_MOVE_JITTER, MOD__SHIFT); ret = TRUE; } break; - case GDK_less: - case GDK_comma: - case GDK_greater: - case GDK_period: - case GDK_3: + case GDK_KEY_less: + case GDK_KEY_comma: + case GDK_KEY_greater: + case GDK_KEY_period: + case GDK_KEY_3: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_SCALE, MOD__SHIFT); ret = TRUE; } break; - case GDK_bracketright: - case GDK_bracketleft: - case GDK_4: + case GDK_KEY_bracketright: + case GDK_KEY_bracketleft: + case GDK_KEY_4: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_ROTATE, MOD__SHIFT); ret = TRUE; } break; - case GDK_d: - case GDK_D: - case GDK_5: + case GDK_KEY_d: + case GDK_KEY_D: + case GDK_KEY_5: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_MORELESS, MOD__SHIFT); ret = TRUE; } break; - case GDK_p: - case GDK_P: - case GDK_6: + case GDK_KEY_p: + case GDK_KEY_P: + case GDK_KEY_6: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_PUSH, MOD__SHIFT); ret = TRUE; } break; - case GDK_s: - case GDK_S: - case GDK_7: + case GDK_KEY_s: + case GDK_KEY_S: + case GDK_KEY_7: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT); ret = TRUE; } break; - case GDK_a: - case GDK_A: - case GDK_8: + case GDK_KEY_a: + case GDK_KEY_A: + case GDK_KEY_8: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_ATTRACT_REPEL, MOD__SHIFT); ret = TRUE; } break; - case GDK_r: - case GDK_R: - case GDK_9: + case GDK_KEY_r: + case GDK_KEY_R: + case GDK_KEY_9: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_ROUGHEN, MOD__SHIFT); ret = TRUE; } break; - case GDK_c: - case GDK_C: + case GDK_KEY_c: + case GDK_KEY_C: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_COLORPAINT, MOD__SHIFT); ret = TRUE; } break; - case GDK_j: - case GDK_J: + case GDK_KEY_j: + case GDK_KEY_J: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_COLORJITTER, MOD__SHIFT); ret = TRUE; } break; - case GDK_b: - case GDK_B: + case GDK_KEY_b: + case GDK_KEY_B: if (MOD__SHIFT_ONLY) { sp_tweak_switch_mode(tc, TWEAK_MODE_BLUR, MOD__SHIFT); ret = TRUE; } break; - case GDK_Up: - case GDK_KP_Up: + case GDK_KEY_Up: + case GDK_KEY_KP_Up: if (!MOD__CTRL_ONLY) { tc->force += 0.05; if (tc->force > 1.0) { @@ -1437,8 +1496,8 @@ sp_tweak_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_Down: - case GDK_KP_Down: + case GDK_KEY_Down: + case GDK_KEY_KP_Down: if (!MOD__CTRL_ONLY) { tc->force -= 0.05; if (tc->force < 0.0) { @@ -1448,8 +1507,8 @@ sp_tweak_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_Right: - case GDK_KP_Right: + case GDK_KEY_Right: + case GDK_KEY_KP_Right: if (!MOD__CTRL_ONLY) { tc->width += 0.01; if (tc->width > 1.0) { @@ -1460,8 +1519,8 @@ sp_tweak_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_Left: - case GDK_KP_Left: + case GDK_KEY_Left: + case GDK_KEY_KP_Left: if (!MOD__CTRL_ONLY) { tc->width -= 0.01; if (tc->width < 0.01) { @@ -1472,35 +1531,35 @@ sp_tweak_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_Home: - case GDK_KP_Home: + case GDK_KEY_Home: + case GDK_KEY_KP_Home: tc->width = 0.01; desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); sp_tweak_update_area(tc); ret = TRUE; break; - case GDK_End: - case GDK_KP_End: + case GDK_KEY_End: + case GDK_KEY_KP_End: tc->width = 1.0; desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); sp_tweak_update_area(tc); ret = TRUE; break; - case GDK_x: - case GDK_X: + case GDK_KEY_x: + case GDK_KEY_X: if (MOD__ALT_ONLY) { desktop->setToolboxFocusTo ("altx-tweak"); ret = TRUE; } break; - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: sp_tweak_update_cursor(tc, true); break; - case GDK_Control_L: - case GDK_Control_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: sp_tweak_switch_mode_temporarily(tc, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT); break; default: @@ -1511,12 +1570,12 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_RELEASE: { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); switch (get_group0_keyval(&event->key)) { - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: sp_tweak_update_cursor(tc, false); break; - case GDK_Control_L: - case GDK_Control_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: sp_tweak_switch_mode (tc, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT); tc->_message_context->clear(); break; diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 52a44114d..2f8c51f51 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -12,11 +12,11 @@ #ifndef INKSCAPE_UI_WIDGET_REGISTERED_WIDGET__H_ #define INKSCAPE_UI_WIDGET_REGISTERED_WIDGET__H_ +#include "ui/widget/scalar.h" #include <2geom/affine.h> #include "xml/node.h" #include "registry.h" -#include "ui/widget/scalar.h" #include "ui/widget/scalar-unit.h" #include "ui/widget/point.h" #include "ui/widget/text.h" diff --git a/src/zoom-context.cpp b/src/zoom-context.cpp index 45de37652..6676733d7 100644 --- a/src/zoom-context.cpp +++ b/src/zoom-context.cpp @@ -25,6 +25,16 @@ #include "zoom-context.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#endif + static void sp_zoom_context_class_init(SPZoomContextClass *klass); static void sp_zoom_context_init(SPZoomContext *zoom_context); static void sp_zoom_context_setup(SPEventContext *ec); @@ -215,22 +225,22 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent } case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_Escape: + case GDK_KEY_Escape: Inkscape::Rubberband::get(desktop)->stop(); xp = yp = 0; escaped = true; ret = TRUE; break; - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: // prevent the zoom field from activation if (!MOD__CTRL_ONLY) ret = TRUE; break; - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: event_context->cursor_shape = cursor_zoom_out_xpm; sp_event_context_update_cursor(event_context); break; @@ -240,8 +250,8 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent break; case GDK_KEY_RELEASE: switch (get_group0_keyval (&event->key)) { - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: event_context->cursor_shape = cursor_zoom_xpm; sp_event_context_update_cursor(event_context); break; -- cgit v1.2.3 From 6d8587d57bc626bc0016a85dbda9450e4bb08ba3 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 8 Apr 2012 11:11:20 +0100 Subject: Stop using custom GtkObject flags (bzr r11181) --- src/display/sp-canvas-item.h | 5 +++++ src/display/sp-canvas.cpp | 47 ++++++++++++++++++++------------------------ 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h index c70a4e241..0a6d343b2 100644 --- a/src/display/sp-canvas-item.h +++ b/src/display/sp-canvas-item.h @@ -54,6 +54,11 @@ struct SPCanvasItem : public GtkObject { double x1, y1, x2, y2; Geom::Rect bounds; Geom::Affine xform; + + // Replacement for custom GtkObject flag enumeration + gboolean visible; + gboolean need_update; + gboolean need_affine; }; /** diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index f352133e5..0f650bf4a 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -140,11 +140,6 @@ GdkWindow *getWindow(SPCanvas *canvas) return gtk_widget_get_window(reinterpret_cast(canvas)); } -enum { - SP_CANVAS_ITEM_VISIBLE = 1 << 7, - SP_CANVAS_ITEM_NEED_UPDATE = 1 << 8, - SP_CANVAS_ITEM_NEED_AFFINE = 1 << 9 -}; // SPCanvasItem @@ -413,7 +408,7 @@ void sp_canvas_item_init(SPCanvasItem *item) // TODO items should not be visible on creation - this causes kludges with items // that should be initially invisible; examples of such items: node handles, the CtrlRect // used for rubberbanding, path outline, etc. - item->flags |= SP_CANVAS_ITEM_VISIBLE; + item->visible = TRUE; item->xform = Geom::Affine(Geom::identity()); } @@ -463,7 +458,7 @@ void sp_canvas_item_construct(SPCanvasItem *item, SPCanvasGroup *parent, gchar c */ static void redraw_if_visible(SPCanvasItem *item) { - if (item->flags & SP_CANVAS_ITEM_VISIBLE) { + if(item->visible) { int x0 = (int)(item->x1); int x1 = (int)(item->x2); int y0 = (int)(item->y1); @@ -490,7 +485,7 @@ void sp_canvas_item_dispose(GObject *object) } else { redraw_if_visible (item); } - item->flags &= ~SP_CANVAS_ITEM_VISIBLE; + item->visible = FALSE; if (item == item->canvas->current_item) { item->canvas->current_item = NULL; @@ -533,11 +528,11 @@ static void sp_canvas_item_invoke_update(SPCanvasItem *item, Geom::Affine const // apply object flags to child flags int child_flags = flags & ~SP_CANVAS_UPDATE_REQUESTED; - if (item->flags & SP_CANVAS_ITEM_NEED_UPDATE) { + if(item->need_update) { child_flags |= SP_CANVAS_UPDATE_REQUESTED; } - if (item->flags & SP_CANVAS_ITEM_NEED_AFFINE) { + if(item->need_affine) { child_flags |= SP_CANVAS_UPDATE_AFFINE; } @@ -547,8 +542,8 @@ static void sp_canvas_item_invoke_update(SPCanvasItem *item, Geom::Affine const } } - GTK_OBJECT_UNSET_FLAGS (item, SP_CANVAS_ITEM_NEED_UPDATE); - GTK_OBJECT_UNSET_FLAGS (item, SP_CANVAS_ITEM_NEED_AFFINE); + item->need_update = FALSE; + item->need_affine = FALSE; } /** @@ -578,8 +573,8 @@ void sp_canvas_item_affine_absolute(SPCanvasItem *item, Geom::Affine const &affi { item->xform = affine; - if (!(item->flags & SP_CANVAS_ITEM_NEED_AFFINE)) { - item->flags |= SP_CANVAS_ITEM_NEED_AFFINE; + if (!item->need_affine) { + item->need_affine = TRUE; if (item->parent != NULL) { sp_canvas_item_request_update (item->parent); } else { @@ -726,7 +721,7 @@ void sp_canvas_item_lower(SPCanvasItem *item, int positions) bool sp_canvas_item_is_visible(SPCanvasItem *item) { - return item->flags & SP_CANVAS_ITEM_VISIBLE; + return item->visible; } @@ -738,11 +733,11 @@ void sp_canvas_item_show(SPCanvasItem *item) g_return_if_fail (item != NULL); g_return_if_fail (SP_IS_CANVAS_ITEM (item)); - if (item->flags & SP_CANVAS_ITEM_VISIBLE) { + if (item->visible) { return; } - item->flags |= SP_CANVAS_ITEM_VISIBLE; + item->visible = TRUE; int x0 = (int)(item->x1); int x1 = (int)(item->x2); @@ -763,11 +758,11 @@ void sp_canvas_item_hide(SPCanvasItem *item) g_return_if_fail (item != NULL); g_return_if_fail (SP_IS_CANVAS_ITEM (item)); - if (!(item->flags & SP_CANVAS_ITEM_VISIBLE)) { + if (!item->visible) { return; } - item->flags &= ~SP_CANVAS_ITEM_VISIBLE; + item->visible = FALSE; int x0 = (int)(item->x1); int x1 = (int)(item->x2); @@ -882,11 +877,11 @@ bool is_descendant(SPCanvasItem const *item, SPCanvasItem const *parent) */ void sp_canvas_item_request_update(SPCanvasItem *item) { - if (item->flags & SP_CANVAS_ITEM_NEED_UPDATE) { + if (item->need_update) { return; } - item->flags |= SP_CANVAS_ITEM_NEED_UPDATE; + item->need_update = TRUE; if (item->parent != NULL) { // Recurse up the tree @@ -1020,7 +1015,7 @@ double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **ac SPCanvasItem *point_item = NULL; // cater for incomplete item implementations int has_point; - if ((child->flags & SP_CANVAS_ITEM_VISIBLE) && SP_CANVAS_ITEM_GET_CLASS (child)->point) { + if (child->visible && SP_CANVAS_ITEM_GET_CLASS (child)->point) { dist = sp_canvas_item_invoke_point (child, p, &point_item); has_point = TRUE; } else { @@ -1049,7 +1044,7 @@ void SPCanvasGroup::render(SPCanvasItem *item, SPCanvasBuf *buf) for (GList *list = group->items; list; list = list->next) { SPCanvasItem *child = (SPCanvasItem *)list->data; - if (child->flags & SP_CANVAS_ITEM_VISIBLE) { + if (child->visible) { if ((child->x1 < buf->rect.right()) && (child->y1 < buf->rect.bottom()) && (child->x2 > buf->rect.left()) && @@ -1068,7 +1063,7 @@ void SPCanvasGroup::viewboxChanged(SPCanvasItem *item, Geom::IntRect const &new_ for (GList *list = group->items; list; list = list->next) { SPCanvasItem *child = (SPCanvasItem *)list->data; - if (child->flags & SP_CANVAS_ITEM_VISIBLE) { + if (child->visible) { if (SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed) { SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed(child, new_area); } @@ -1571,7 +1566,7 @@ int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event) y += canvas->y0; // find the closest item - if (canvas->root->flags & SP_CANVAS_ITEM_VISIBLE) { + if (canvas->root->visible) { sp_canvas_item_invoke_point (canvas->root, Geom::Point(x, y), &canvas->new_current_item); } else { canvas->new_current_item = NULL; @@ -1774,7 +1769,7 @@ void SPCanvasImpl::sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect cairo_paint(buf.ct); cairo_set_operator(buf.ct, CAIRO_OPERATOR_OVER); - if (canvas->root->flags & SP_CANVAS_ITEM_VISIBLE) { + if (canvas->root->visible) { SP_CANVAS_ITEM_GET_CLASS (canvas->root)->render (canvas->root, &buf); } -- cgit v1.2.3 From 6f5b62b328655e37b3ca90bba51549077bc2b8d2 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 8 Apr 2012 17:16:07 +0200 Subject: small GSEAL fix (bzr r11182) --- src/widgets/paint-selector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index d67160483..a750ffab6 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -955,7 +955,7 @@ void SPPaintSelector::updatePatternList( SPPattern *pattern ) GtkMenu *m = GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(mnu))); - GList *kids = GTK_MENU_SHELL(m)->children; + GList *kids = gtk_container_get_children(GTK_CONTAINER(m)); int patpos = 0; int i = 0; -- cgit v1.2.3 From da6eca5e81424ad6f9e2eca5f8e0573bd6dd156c Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 8 Apr 2012 22:15:30 +0200 Subject: powerstroke parameter small fix (bzr r11183) --- src/live_effects/parameter/powerstrokepointarray.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 9e138a7ae..1fdf0aee9 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -19,6 +19,7 @@ // needed for on-canvas editting: #include "desktop.h" +#include "lpeobject.h" namespace Inkscape { @@ -31,7 +32,7 @@ PowerStrokePointArrayParam::PowerStrokePointArrayParam( const Glib::ustring& lab { knot_shape = SP_KNOT_SHAPE_DIAMOND; knot_mode = SP_KNOT_MODE_XOR; - knot_color = 0xff00ff00; + knot_color = 0xff88ff00; } PowerStrokePointArrayParam::~PowerStrokePointArrayParam() @@ -192,18 +193,20 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state) std::vector & vec = _pparam->_vector; vec.erase(vec.begin() + _index); _pparam->param_set_and_write_new_value(vec); + knotarray_changed = true; } else { // add a knot std::vector & vec = _pparam->_vector; vec.insert(vec.begin() + _index, 1, vec.at(_index)); _pparam->param_set_and_write_new_value(vec); + knotarray_changed = true; } } if (knotarray_changed) { // if knot array has been changed, the on-canvas knots must be reloaded - /// \todo reload knots! - } + /// \todo reload! + } } void -- cgit v1.2.3 From f3247153b8c5cadc14f4a00b9a9dd76f69532630 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 8 Apr 2012 16:23:05 -0400 Subject: pdf import. temporary workaround to prevent GfxRadialShading from getting corrupted during copy operation (Bug 919176 comment 8) Fixed bugs: - https://launchpad.net/bugs/919176 (bzr r11184) --- src/extension/internal/pdfinput/pdf-parser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp index 5347a85ac..5e8b005e2 100644 --- a/src/extension/internal/pdfinput/pdf-parser.cpp +++ b/src/extension/internal/pdfinput/pdf-parser.cpp @@ -3199,7 +3199,8 @@ void PdfParser::opMarkPoint(Object args[], int numArgs) { void PdfParser::saveState() { builder->saveState(); - state = state->save(); +// state = state->save(); // nasty hack to prevent GfxRadialShading from getting corrupted during copy operation + state->save(); // see LP Bug 919176 comment 8 clipHistory = clipHistory->save(); } -- cgit v1.2.3 From fdc52bf32eb849efad7cb4b7d3ed13c7b1e100a6 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 8 Apr 2012 23:03:31 +0200 Subject: clone lpe: preserve transformations on paths with clone_original lpe. This enables moving such paths. (bzr r11185) --- src/sp-path.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 3ac4666e2..107ceac16 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -377,7 +377,12 @@ sp_path_set_transform(SPItem *item, Geom::Affine const &xform) // Transform the original-d path if this is a valid LPE item, other else the (ordinary) path if (path->_curve_before_lpe && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(item))) { - path->_curve_before_lpe->transform(xform); + if (sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(item), Inkscape::LivePathEffect::CLONE_ORIGINAL)) { + // if path has the CLONE_ORIGINAL LPE applied, don't write the transform to the pathdata, but write it 'unoptimized' + return xform; + } else { + path->_curve_before_lpe->transform(xform); + } } else { path->_curve->transform(xform); } -- cgit v1.2.3 From a585c5aed5f9739c29c006ab52f3d53c882c746e Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 8 Apr 2012 23:33:36 +0200 Subject: Fix stroke-width scaling issue Fixed bugs: - https://launchpad.net/bugs/825840 - https://launchpad.net/bugs/959223 (bzr r11186) --- src/sp-item.cpp | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index f7f957a6f..d6395cfee 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1282,16 +1282,23 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (compensate) { - - // recursively compensating for stroke scaling will not work, because it can be scaled to zero or infinite + // recursively compensating for stroke scaling will not always work, because it can be scaled to zero or infinite // from which we cannot ever recover by applying an inverse scale; therefore we temporarily block any changes - // to the strokewidth instead, and unblock these after the transformation + // to the strokewidth in such a case instead, and unblock these after the transformation // (as reported in https://bugs.launchpad.net/inkscape/+bug/825840/comments/4) if (!prefs->getBool("/options/transform/stroke", true)) { - freeze_stroke_width_recursive(true); - // This will only work if the item has a set_transform method (in this method adjust_stroke() will be called) - // We will still have to apply the inverse scaling to other items, not having a set_transform method - // such as ellipses and stars + double const expansion = 1. / advertized_transform.descrim(); + if (expansion < 1e-9 || expansion > 1e9) { + freeze_stroke_width_recursive(true); + // This will only work if the item has a set_transform method (in this method adjust_stroke() will be called) + // We will still have to apply the inverse scaling to other items, not having a set_transform method + // such as ellipses and stars + // PS: We cannot use this freeze_stroke_width_recursive() trick in all circumstances. For example, it will + // break pasting objects within their group (because in such a case the transformation of the group will affect + // the strokewidth, and has to be compensated for. See https://bugs.launchpad.net/inkscape/+bug/959223/comments/10) + } else { + adjust_stroke_width_recursive(expansion); + } } // recursively compensate rx/ry of a rect if requested @@ -1325,15 +1332,19 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra !(!transform.isTranslation() && style && style->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->set_transform(this, transform); - freeze_stroke_width_recursive(false); + if (freeze_stroke_width) { + freeze_stroke_width_recursive(false); + } } else { - freeze_stroke_width_recursive(false); - if (compensate) { - if (!prefs->getBool("/options/transform/stroke", true)) { - // Recursively compensate for stroke scaling, depending on user preference - // (As to why we need to do this, see the comment a few lines above near the freeze_stroke_width_recursive(true) call) - double const expansion = 1. / advertized_transform.descrim(); - adjust_stroke_width_recursive(expansion); + if (freeze_stroke_width) { + freeze_stroke_width_recursive(false); + if (compensate) { + if (!prefs->getBool("/options/transform/stroke", true)) { + // Recursively compensate for stroke scaling, depending on user preference + // (As to why we need to do this, see the comment a few lines above near the freeze_stroke_width_recursive(true) call) + double const expansion = 1. / advertized_transform.descrim(); + adjust_stroke_width_recursive(expansion); + } } } } -- cgit v1.2.3 From efe0ce44ff6dc6dba7c185d4fc751d85ab693094 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 8 Apr 2012 23:42:00 +0200 Subject: fix inclusion. (bzr r11187) --- src/live_effects/parameter/powerstrokepointarray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 1fdf0aee9..9d91dff18 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -19,7 +19,7 @@ // needed for on-canvas editting: #include "desktop.h" -#include "lpeobject.h" +#include "live_effects/lpeobject.h" namespace Inkscape { -- cgit v1.2.3 From 821270153ace522f49f9350200c148df4e09e0f4 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 8 Apr 2012 23:49:39 +0200 Subject: clone original path lpe: add boilerplate code to allow to compensate for linked path movement. but it should be worked out how the actual compensation should be written to SVG. don't want to add something to the cloneLPE SVG syntax in a haste (bzr r11188) --- src/live_effects/parameter/originalpath.cpp | 8 ++++++++ src/live_effects/parameter/originalpath.h | 2 ++ src/live_effects/parameter/path.cpp | 10 ++++++++++ src/live_effects/parameter/path.h | 3 +++ 4 files changed, 23 insertions(+) (limited to 'src') diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp index e5c16943c..71ab006d6 100644 --- a/src/live_effects/parameter/originalpath.cpp +++ b/src/live_effects/parameter/originalpath.cpp @@ -103,6 +103,14 @@ OriginalPathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags* SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG); } +void +OriginalPathParam::linked_transformed_callback(Geom::Affine const * /*rel_transf*/, SPItem * /*moved_item*/) +{ +/** \todo find good way to compensate for referenced path transform, like done for normal clones. + * See sp-use.cpp: sp_use_move_compensate */ +} + + void OriginalPathParam::on_select_original_button_click() { diff --git a/src/live_effects/parameter/originalpath.h b/src/live_effects/parameter/originalpath.h index f05f17d9a..7dd17edb0 100644 --- a/src/live_effects/parameter/originalpath.h +++ b/src/live_effects/parameter/originalpath.h @@ -35,6 +35,8 @@ public: protected: virtual void linked_modified_callback(SPObject *linked_obj, guint flags); + virtual void linked_transformed_callback(Geom::Affine const *rel_transf, SPItem *moved_item); + void on_select_original_button_click(); private: diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 186cfff9a..69c337a7c 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -326,6 +326,9 @@ PathParam::start_listening(SPObject * to) } linked_delete_connection = to->connectDelete(sigc::mem_fun(*this, &PathParam::linked_delete)); linked_modified_connection = to->connectModified(sigc::mem_fun(*this, &PathParam::linked_modified)); + if (SP_IS_ITEM(to)) { + linked_transformed_connection = SP_ITEM(to)->connectTransformed(sigc::mem_fun(*this, &PathParam::linked_transformed)); + } linked_modified(to, SP_OBJECT_MODIFIED_FLAG); // simulate linked_modified signal, so that path data is updated } @@ -334,6 +337,7 @@ PathParam::quit_listening(void) { linked_modified_connection.disconnect(); linked_delete_connection.disconnect(); + linked_transformed_connection.disconnect(); } void @@ -368,6 +372,11 @@ void PathParam::linked_modified(SPObject *linked_obj, guint flags) linked_modified_callback(linked_obj, flags); } +void PathParam::linked_transformed(Geom::Affine const *rel_transf, SPItem *moved_item) +{ + linked_transformed_callback(rel_transf, moved_item); +} + void PathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/) { @@ -392,6 +401,7 @@ PathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/) SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG); } + /* CALLBACK FUNCTIONS FOR THE BUTTONS */ void PathParam::on_edit_button_click() diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index 7b51dc48a..a4f46f11f 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -70,13 +70,16 @@ protected: sigc::connection ref_changed_connection; sigc::connection linked_delete_connection; sigc::connection linked_modified_connection; + sigc::connection linked_transformed_connection; void ref_changed(SPObject *old_ref, SPObject *new_ref); void remove_link(); void start_listening(SPObject * to); void quit_listening(void); void linked_delete(SPObject *deleted); void linked_modified(SPObject *linked_obj, guint flags); + void linked_transformed(Geom::Affine const *rel_transf, SPItem *moved_item); virtual void linked_modified_callback(SPObject *linked_obj, guint flags); + virtual void linked_transformed_callback(Geom::Affine const * /*rel_transf*/, SPItem * /*moved_item*/) {}; void on_edit_button_click(); void on_copy_button_click(); -- cgit v1.2.3 From 9454424e3b583928162252a407ee87ec478417c9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 9 Apr 2012 00:09:59 +0200 Subject: LPE: enable "add effect" button for clones. It converts the clone to a path and applies the clone original LPE. (bzr r11189) --- src/ui/dialog/livepatheffect-editor.cpp | 105 ++++++++++++++++++++++++-------- 1 file changed, 81 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 161d92b09..1f252c089 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -32,11 +32,14 @@ #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" #include "path-chemistry.h" +#include "selection-chemistry.h" #include "selection.h" #include "sp-item-group.h" #include "sp-lpe-item.h" #include "sp-path.h" #include "sp-rect.h" +#include "sp-use.h" +#include "sp-text.h" #include "sp-shape.h" #include "ui/icon-names.h" #include "ui/widget/imagetoggler.h" @@ -284,6 +287,22 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) button_up.set_sensitive(false); button_down.set_sensitive(false); } + } else if ( SP_IS_USE(item) ) { + // test whether linked object is supported by the CLONE_ORIGINAL LPE + SPItem *orig = sp_use_get_original( SP_USE(item) ); + if ( SP_IS_SHAPE(orig) || + SP_IS_TEXT(orig) ) + { + // Note that an SP_USE cannot have an LPE applied, so we only need to worry about the "add effect" case. + set_sensitize_all(true); + showText(_("Click add button to convert clone")); + button_remove.set_sensitive(false); + button_up.set_sensitive(false); + button_down.set_sensitive(false); + } else { + showText(_("Select a path or shape")); + set_sensitize_all(false); + } } else { showText(_("Select a path or shape")); set_sensitize_all(false); @@ -369,37 +388,75 @@ LivePathEffectEditor::setDesktop(SPDesktop *desktop) void LivePathEffectEditor::onAdd() { - using Inkscape::UI::Dialog::LivePathEffectAdd; - LivePathEffectAdd::show(current_desktop); - - if ( !LivePathEffectAdd::isApplied()) { - return; - } - - const Util::EnumData* data = LivePathEffectAdd::getActiveData(); - if (!data) { - return; - } - Inkscape::Selection *sel = _getSelection(); if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); - if ( item && SP_IS_LPE_ITEM(item) ) { - SPDocument *doc = current_desktop->doc(); + if (item) { + if ( SP_IS_LPE_ITEM(item) ) { + // show effectlist dialog + using Inkscape::UI::Dialog::LivePathEffectAdd; + LivePathEffectAdd::show(current_desktop); + if ( !LivePathEffectAdd::isApplied()) { + return; + } - // If item is a SPRect, convert it to path first: - if ( SP_IS_RECT(item) ) { - sp_selected_path_to_curves(current_desktop, false); - item = sel->singleItem(); // get new item - } + SPDocument *doc = current_desktop->doc(); - LivePathEffect::Effect::createAndApply(data->key.c_str(), doc, item); + const Util::EnumData* data = LivePathEffectAdd::getActiveData(); + if (!data) { + return; + } - DocumentUndo::done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT, - _("Create and apply path effect")); + // If item is a SPRect, convert it to path first: + if ( SP_IS_RECT(item) ) { + sp_selected_path_to_curves(current_desktop, false); + item = sel->singleItem(); // get new item + } - lpe_list_locked = false; - onSelectionChanged(sel); + LivePathEffect::Effect::createAndApply(data->key.c_str(), doc, item); + + DocumentUndo::done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Create and apply path effect")); + + lpe_list_locked = false; + onSelectionChanged(sel); + } + else if ( SP_IS_USE(item) ) { + // item is a clone. do not show effectlist dialog. + // convert to path, apply CLONE_ORIGINAL LPE, link it to the cloned path + + // test whether linked object is supported by the CLONE_ORIGINAL LPE + SPItem *orig = sp_use_get_original( SP_USE(item) ); + if ( SP_IS_SHAPE(orig) || + SP_IS_TEXT(orig) ) + { + // select original + sel->set(orig); + + // delete clone but remember its id and transform + gchar *id = g_strdup(item->getRepr()->attribute("id")); + gchar *transform = g_strdup(item->getRepr()->attribute("transform")); + item->deleteObject(false); + item = NULL; + + // run sp_selection_clone_original_path_lpe + sp_selection_clone_original_path_lpe(current_desktop); + item = sel->singleItem(); + item->getRepr()->setAttribute("id", id); + item->getRepr()->setAttribute("transform", transform); + g_free(id); + g_free(transform); + + /// \todo Add the LPE stack of the original path? + + SPDocument *doc = current_desktop->doc(); + DocumentUndo::done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Create and apply Clone original path effect")); + + lpe_list_locked = false; + onSelectionChanged(sel); + } + } } } } -- cgit v1.2.3 From 0f452943d7f90ba021cd16c8bafcfcb284268e09 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 9 Apr 2012 09:28:40 +0200 Subject: fix memory leak and some minor things (bzr r11190) --- src/widgets/gradient-toolbar.cpp | 2 +- src/widgets/gradient-vector.cpp | 10 +++++----- src/widgets/stroke-marker-selector.cpp | 29 +++++++++++++++++------------ 3 files changed, 23 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index e5a3ab155..e239457fd 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -175,7 +175,6 @@ gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection gl = g_slist_reverse (gl); guint pos = 0; - guint idx = 0; if (!gl) { // The document has no gradients @@ -205,6 +204,7 @@ gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection sensitive = FALSE; } + guint idx = 0; while (gl) { SPGradient *gradient = SP_GRADIENT (gl->data); gl = g_slist_remove (gl, gradient); diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 2739a47b0..d5e55661a 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -289,7 +289,6 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs) gl = g_slist_reverse(gl); gint pos = 0; - gint idx = 0; if (!gvs->doc) { gtk_list_store_append (gvs->store, &iter); @@ -307,6 +306,7 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs) gtk_widget_set_sensitive (gvs->combo_box, FALSE); } else { + gint idx = 0; while (gl) { SPGradient *gr; gr = SP_GRADIENT(gl->data); @@ -457,7 +457,7 @@ static gboolean blocked = FALSE; static void grad_edit_dia_stop_added_or_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, gpointer data) { GtkWidget *vb = GTK_WIDGET(data); - SPGradient *gradient = (SPGradient *)g_object_get_data(G_OBJECT(vb), "gradient"); + SPGradient *gradient = static_cast(g_object_get_data(G_OBJECT(vb), "gradient")); update_stop_list(vb, gradient, NULL); } @@ -996,14 +996,14 @@ static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradien SPGradient *old; - old = (SPGradient*)g_object_get_data(G_OBJECT(widget), "gradient"); + old = static_cast(g_object_get_data(G_OBJECT(widget), "gradient")); if (old != gradient) { sigc::connection *release_connection; sigc::connection *modified_connection; - release_connection = (sigc::connection *)g_object_get_data(G_OBJECT(widget), "gradient_release_connection"); - modified_connection = (sigc::connection *)g_object_get_data(G_OBJECT(widget), "gradient_modified_connection"); + release_connection = static_cast(g_object_get_data(G_OBJECT(widget), "gradient_release_connection")); + modified_connection = static_cast(g_object_get_data(G_OBJECT(widget), "gradient_modified_connection")); if (old) { g_assert( release_connection != NULL ); diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 427112f9b..9b2c3bb42 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -177,14 +177,21 @@ const gchar * MarkerComboBox::get_active_marker_uri() gchar const *marker = ""; if (strcmp(markid, "none")) { - bool stockid = get_active()->get_value(marker_columns.isstock); - - gchar *markurn = g_strdup(markid); - if (stockid) markurn = g_strconcat("urn:inkscape:marker:",markid,NULL); - SPObject *mark = get_stock_item(markurn); - g_free(markurn); - if (mark) { - Inkscape::XML::Node *repr = mark->getRepr(); + bool stockid = get_active()->get_value(marker_columns.isstock); + + gchar *markurn; + if (stockid) + { + markurn = g_strconcat("urn:inkscape:marker:",markid,NULL); + } + else + { + markurn = g_strdup(markid); + } + SPObject *mark = get_stock_item(markurn); + g_free(markurn); + if (mark) { + Inkscape::XML::Node *repr = mark->getRepr(); marker = g_strconcat("url(#", repr->attribute("id"), ")", NULL); } } else { @@ -211,7 +218,7 @@ void MarkerComboBox::set_selected(const gchar *name) { iter != marker_store->children().end(); ++iter) { Gtk::TreeModel::Row row = (*iter); if (row[marker_columns.marker] && - !strcmp(row[marker_columns.marker], name)) { + !strcmp(row[marker_columns.marker], name)) { set_active(iter); if (strcmp(name, "none")) set_history(row); @@ -373,15 +380,13 @@ MarkerComboBox::create_marker_image(unsigned psize, gchar const *mname, } /* Update to renderable state */ - double sf = 0.8; - gchar *cache_name = g_strconcat(combo_id, mname, NULL); Glib::ustring key = svg_preview_cache.cache_key(source->getURI(), cache_name, psize); g_free (cache_name); Glib::RefPtr pixbuf = Glib::wrap(svg_preview_cache.get_preview_from_cache(key)); if (!pixbuf) { - pixbuf = Glib::wrap(render_pixbuf(drawing, sf, *dbox, psize)); + pixbuf = Glib::wrap(render_pixbuf(drawing, 0.8, *dbox, psize)); svg_preview_cache.set_preview_in_cache(key, pixbuf->gobj()); } -- cgit v1.2.3 From c906d0a5e77cbfd7a52e2f532cad69fe22047713 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 9 Apr 2012 09:43:40 +0200 Subject: cppcheck tells us: "scanf without field width limits can crash with huge input data" (bzr r11191) --- src/sp-filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index b39694b3a..a20856f53 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -564,7 +564,7 @@ Glib::ustring sp_filter_get_new_result_name(SPFilter *filter) { int index; if (result) { - if (sscanf(result, "result%d", &index) == 1) + if (sscanf(result, "result%5d", &index) == 1) { if (index > largest) { -- cgit v1.2.3 From 6ed5d94a27a8d8793c6db39b6a3b18139119275d Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 9 Apr 2012 10:01:49 +0200 Subject: omitting debug message on windows (bzr r11192) --- src/ui/dialog/inkscape-preferences.cpp | 56 ++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 269266083..6d76f5784 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -129,7 +129,6 @@ InkscapePreferences::InkscapePreferences() initPageRendering(); initPageSpellcheck(); - signalPresent().connect(sigc::mem_fun(*this, &InkscapePreferences::_presentPages)); //calculate the size request for this dialog @@ -1344,38 +1343,41 @@ void InkscapePreferences::initPageSpellcheck() GetModuleFileName(NULL, exeName, MAX_PATH); char *slashPos = strrchr(exeName, '\\'); if (slashPos) + { *slashPos = '\0'; - g_print ("%s\n", exeName); + } + // g_print ("%s\n", exeName); aspell_config_replace(config, "prefix", exeName); #endif - /* the returned pointer should _not_ need to be deleted */ - AspellDictInfoList *dlist = get_aspell_dict_info_list(config); - - /* config is no longer needed */ - delete_aspell_config(config); - - AspellDictInfoEnumeration *dels = aspell_dict_info_list_elements(dlist); - - languages.push_back(Glib::ustring(_("None"))); - langValues.push_back(Glib::ustring("")); - - const AspellDictInfo *entry; - int en_index = 0; - int i = 0; - while ( (entry = aspell_dict_info_enumeration_next(dels)) != 0) - { - languages.push_back(Glib::ustring(entry->name)); - langValues.push_back(Glib::ustring(entry->name)); - if (!strcmp (entry->name, "en")) - en_index = i; - i ++; - } - - delete_aspell_dict_info_enumeration(dels); + /* the returned pointer should _not_ need to be deleted */ + AspellDictInfoList *dlist = get_aspell_dict_info_list(config); + + /* config is no longer needed */ + delete_aspell_config(config); + + AspellDictInfoEnumeration *dels = aspell_dict_info_list_elements(dlist); + + languages.push_back(Glib::ustring(_("None"))); + langValues.push_back(Glib::ustring("")); + + const AspellDictInfo *entry; + int en_index = 0; + int i = 0; + while ( (entry = aspell_dict_info_enumeration_next(dels)) != 0) + { + languages.push_back(Glib::ustring(entry->name)); + langValues.push_back(Glib::ustring(entry->name)); + if (!strcmp (entry->name, "en")) + { + en_index = i; + } + i++; + } + delete_aspell_dict_info_enumeration(dels); - _spell_language.init( "/dialogs/spellcheck/lang", &languages[0], &langValues[0], languages.size(), languages[en_index]); + _spell_language.init( "/dialogs/spellcheck/lang", &languages[0], &langValues[0], languages.size(), languages[en_index]); _page_spellcheck.add_line( false, _("Language:"), _spell_language, "", _("Set the main spell check language"), false); -- cgit v1.2.3 From 9ffb8e156d060c154ad87a91aa1e592bc2140274 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 9 Apr 2012 13:40:51 +0200 Subject: documentation (bzr r11193) --- src/ui/widget/zoom-status.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/widget/zoom-status.cpp b/src/ui/widget/zoom-status.cpp index fa8191671..579449744 100644 --- a/src/ui/widget/zoom-status.cpp +++ b/src/ui/widget/zoom-status.cpp @@ -106,7 +106,7 @@ ZoomStatus::on_value_changed() double zoom_factor = pow(2, get_value()); Geom::Rect const d = _dt->get_display_area(); _dt->zoom_absolute(d.midpoint()[Geom::X], d.midpoint()[Geom::Y], zoom_factor); - gtk_widget_grab_focus(static_cast((void*)_dt->canvas)); /// \todo this no love song + gtk_widget_grab_focus(static_cast((void*)_dt->canvas)); _upd_f = false; } -- cgit v1.2.3 From 7cdb6930a6bedf993a946470efc2b79571de8d96 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 9 Apr 2012 17:10:43 +0100 Subject: Replace deprecated GDK key symbols (bzr r11194) --- src/dropper-context.cpp | 18 +++-- src/dyna-draw-context.cpp | 60 +++++++++----- src/eraser-context.cpp | 60 +++++++++----- src/gradient-context.cpp | 133 +++++++++++++++++++++---------- src/knot.cpp | 6 +- src/pen-context.cpp | 123 +++++++++++++++++++++-------- src/pencil-context.cpp | 78 +++++++++++++++---- src/rect-context.cpp | 108 +++++++++++++++++++------- src/select-context.cpp | 164 +++++++++++++++++++++++++++------------ src/seltrans.cpp | 6 +- src/spiral-context.cpp | 112 ++++++++++++++++++++------ src/star-context.cpp | 112 ++++++++++++++++++++------ src/ui/tool/event-utils.cpp | 90 ++++++++++++++++++--- src/ui/tool/modifier-tracker.cpp | 91 +++++++++++++++++++--- 14 files changed, 882 insertions(+), 279 deletions(-) (limited to 'src') diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 3a93df33a..336314c4f 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -44,6 +44,14 @@ #include "message-context.h" #include "verbs.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Escape 0xff1b +#endif + using Inkscape::DocumentUndo; static void sp_dropper_context_class_init(SPDropperContextClass *klass); @@ -328,16 +336,16 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv break; case GDK_KEY_PRESS: switch (get_group0_keyval(&event->key)) { - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: // prevent the zoom field from activation if (!MOD__CTRL_ONLY) { ret = TRUE; } break; - case GDK_Escape: + case GDK_KEY_Escape: sp_desktop_selection(desktop)->clear(); default: break; diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index f48db0a99..c737b8d29 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -81,6 +81,28 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#endif + static void sp_dyna_draw_context_class_init(SPDynaDrawContextClass *klass); static void sp_dyna_draw_context_init(SPDynaDrawContext *ddc); static void sp_dyna_draw_context_dispose(GObject *object); @@ -878,8 +900,8 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context, case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_Up: - case GDK_KP_Up: + case GDK_KEY_Up: + case GDK_KEY_KP_Up: if (!MOD__CTRL_ONLY) { dc->angle += 5.0; if (dc->angle > 90.0) @@ -888,8 +910,8 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_Down: - case GDK_KP_Down: + case GDK_KEY_Down: + case GDK_KEY_KP_Down: if (!MOD__CTRL_ONLY) { dc->angle -= 5.0; if (dc->angle < -90.0) @@ -898,8 +920,8 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_Right: - case GDK_KP_Right: + case GDK_KEY_Right: + case GDK_KEY_KP_Right: if (!MOD__CTRL_ONLY) { dc->width += 0.01; if (dc->width > 1.0) @@ -908,8 +930,8 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_Left: - case GDK_KP_Left: + case GDK_KEY_Left: + case GDK_KEY_KP_Left: if (!MOD__CTRL_ONLY) { dc->width -= 0.01; if (dc->width < 0.01) @@ -918,34 +940,34 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_Home: - case GDK_KP_Home: + case GDK_KEY_Home: + case GDK_KEY_KP_Home: dc->width = 0.01; sp_ddc_update_toolbox (desktop, "altx-calligraphy", dc->width * 100); ret = TRUE; break; - case GDK_End: - case GDK_KP_End: + case GDK_KEY_End: + case GDK_KEY_KP_End: dc->width = 1.0; sp_ddc_update_toolbox (desktop, "altx-calligraphy", dc->width * 100); ret = TRUE; break; - case GDK_x: - case GDK_X: + case GDK_KEY_x: + case GDK_KEY_X: if (MOD__ALT_ONLY) { desktop->setToolboxFocusTo ("altx-calligraphy"); ret = TRUE; } break; - case GDK_Escape: + case GDK_KEY_Escape: if (dc->is_drawing) { // if drawing, cancel, otherwise pass it up for deselecting calligraphic_cancel (dc); ret = TRUE; } break; - case GDK_z: - case GDK_Z: + case GDK_KEY_z: + case GDK_KEY_Z: if (MOD__CTRL_ONLY && dc->is_drawing) { // if drawing, cancel, otherwise pass it up for undo calligraphic_cancel (dc); @@ -959,8 +981,8 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context, case GDK_KEY_RELEASE: switch (get_group0_keyval(&event->key)) { - case GDK_Control_L: - case GDK_Control_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: dc->_message_context->clear(); dc->hatch_spacing = 0; dc->hatch_spacing_step = 0; diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 628ad0164..3b309899b 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -83,6 +83,28 @@ using Inkscape::DocumentUndo; #define DRAG_DEFAULT 1.0 #define DRAG_MAX 1.0 +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#endif + static void sp_eraser_context_class_init(SPEraserContextClass *klass); static void sp_eraser_context_init(SPEraserContext *erc); @@ -594,8 +616,8 @@ sp_eraser_context_root_handler(SPEventContext *event_context, case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_Up: - case GDK_KP_Up: + case GDK_KEY_Up: + case GDK_KEY_KP_Up: if (!MOD__CTRL_ONLY) { dc->angle += 5.0; if (dc->angle > 90.0) @@ -604,8 +626,8 @@ sp_eraser_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_Down: - case GDK_KP_Down: + case GDK_KEY_Down: + case GDK_KEY_KP_Down: if (!MOD__CTRL_ONLY) { dc->angle -= 5.0; if (dc->angle < -90.0) @@ -614,8 +636,8 @@ sp_eraser_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_Right: - case GDK_KP_Right: + case GDK_KEY_Right: + case GDK_KEY_KP_Right: if (!MOD__CTRL_ONLY) { dc->width += 0.01; if (dc->width > 1.0) @@ -624,8 +646,8 @@ sp_eraser_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_Left: - case GDK_KP_Left: + case GDK_KEY_Left: + case GDK_KEY_KP_Left: if (!MOD__CTRL_ONLY) { dc->width -= 0.01; if (dc->width < 0.01) @@ -634,26 +656,26 @@ sp_eraser_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_Home: - case GDK_KP_Home: + case GDK_KEY_Home: + case GDK_KEY_KP_Home: dc->width = 0.01; sp_erc_update_toolbox (desktop, "altx-eraser", dc->width * 100); ret = TRUE; break; - case GDK_End: - case GDK_KP_End: + case GDK_KEY_End: + case GDK_KEY_KP_End: dc->width = 1.0; sp_erc_update_toolbox (desktop, "altx-eraser", dc->width * 100); ret = TRUE; break; - case GDK_x: - case GDK_X: + case GDK_KEY_x: + case GDK_KEY_X: if (MOD__ALT_ONLY) { desktop->setToolboxFocusTo ("altx-eraser"); ret = TRUE; } break; - case GDK_Escape: + case GDK_KEY_Escape: Inkscape::Rubberband::get(desktop)->stop(); if (dc->is_drawing) { // if drawing, cancel, otherwise pass it up for deselecting @@ -661,8 +683,8 @@ sp_eraser_context_root_handler(SPEventContext *event_context, ret = TRUE; } break; - case GDK_z: - case GDK_Z: + case GDK_KEY_z: + case GDK_KEY_Z: if (MOD__CTRL_ONLY && dc->is_drawing) { // if drawing, cancel, otherwise pass it up for undo eraser_cancel (dc); @@ -676,8 +698,8 @@ sp_eraser_context_root_handler(SPEventContext *event_context, case GDK_KEY_RELEASE: switch (get_group0_keyval(&event->key)) { - case GDK_Control_L: - case GDK_Control_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: dc->_message_context->clear(); break; default: diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index e10e42610..54f4bdfc1 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -48,6 +48,55 @@ #include "document-undo.h" #include "verbs.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#endif + using Inkscape::DocumentUndo; static void sp_gradient_context_class_init(SPGradientContextClass *klass); @@ -713,45 +762,45 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) break; case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Meta_L: // Meta is when you press Shift+Alt (at least on my machine) - case GDK_Meta_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt (at least on my machine) + case GDK_KEY_Meta_R: sp_event_show_modifier_tip (event_context->defaultMessageContext(), event, _("Ctrl: snap gradient angle"), _("Shift: draw gradient around the starting point"), NULL); break; - case GDK_x: - case GDK_X: + case GDK_KEY_x: + case GDK_KEY_X: if (MOD__ALT_ONLY) { desktop->setToolboxFocusTo ("altx-grad"); ret = TRUE; } break; - case GDK_A: - case GDK_a: + case GDK_KEY_A: + case GDK_KEY_a: if (MOD__CTRL_ONLY && drag->isNonEmpty()) { drag->selectAll(); ret = TRUE; } break; - case GDK_L: - case GDK_l: + case GDK_KEY_L: + case GDK_KEY_l: if (MOD__CTRL_ONLY && drag->isNonEmpty() && drag->hasSelection()) { sp_gradient_simplify(rc, 1e-4); ret = TRUE; } break; - case GDK_Escape: + case GDK_KEY_Escape: if (drag->selected) { drag->deselectAll(); } else { @@ -761,9 +810,9 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) //TODO: make dragging escapable by Esc break; - case GDK_Left: // move handle left - case GDK_KP_Left: - case GDK_KP_4: + case GDK_KEY_Left: // move handle left + case GDK_KEY_KP_Left: + case GDK_KEY_KP_4: if (!MOD__CTRL) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask @@ -778,9 +827,9 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } break; - case GDK_Up: // move handle up - case GDK_KP_Up: - case GDK_KP_8: + case GDK_KEY_Up: // move handle up + case GDK_KEY_KP_Up: + case GDK_KEY_KP_8: if (!MOD__CTRL) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask @@ -795,9 +844,9 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } break; - case GDK_Right: // move handle right - case GDK_KP_Right: - case GDK_KP_6: + case GDK_KEY_Right: // move handle right + case GDK_KEY_KP_Right: + case GDK_KEY_KP_6: if (!MOD__CTRL) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask @@ -812,9 +861,9 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } break; - case GDK_Down: // move handle down - case GDK_KP_Down: - case GDK_KP_2: + case GDK_KEY_Down: // move handle down + case GDK_KEY_KP_Down: + case GDK_KEY_KP_2: if (!MOD__CTRL) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask @@ -829,8 +878,8 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } break; - case GDK_r: - case GDK_R: + case GDK_KEY_r: + case GDK_KEY_R: if (MOD__SHIFT_ONLY) { // First try selected dragger if (drag && drag->selected) { @@ -848,16 +897,16 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) } break; - case GDK_Insert: - case GDK_KP_Insert: + case GDK_KEY_Insert: + case GDK_KEY_KP_Insert: // with any modifiers: sp_gradient_context_add_stops_between_selected_stops (rc); ret = TRUE; break; - case GDK_Delete: - case GDK_KP_Delete: - case GDK_BackSpace: + case GDK_KEY_Delete: + case GDK_KEY_KP_Delete: + case GDK_KEY_BackSpace: if ( drag->selected ) { drag->deleteSelected(MOD__CTRL_ONLY); ret = TRUE; @@ -869,14 +918,14 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) break; case GDK_KEY_RELEASE: switch (get_group0_keyval (&event->key)) { - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Meta_L: // Meta is when you press Shift+Alt - case GDK_Meta_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt + case GDK_KEY_Meta_R: event_context->defaultMessageContext()->clear(); break; default: diff --git a/src/knot.cpp b/src/knot.cpp index aee4fe1a5..fe99eb4e1 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -36,6 +36,10 @@ using Inkscape::DocumentUndo; GDK_POINTER_MOTION_HINT_MASK | \ GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK) +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Escape 0xff1b +#endif + static bool nograb = false; static bool grabbed = FALSE; @@ -411,7 +415,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot break; case GDK_KEY_PRESS: // keybindings for knot switch (get_group0_keyval(&event->key)) { - case GDK_Escape: + case GDK_KEY_Escape: sp_knot_set_flag(knot, SP_KNOT_GRABBED, FALSE); if (!nograb) { sp_canvas_item_ungrab(knot->item, event->button.time); diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 5e9f27fb9..dbfd436f0 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -44,6 +44,61 @@ #include "context-fns.h" #include "tools-switch.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#endif + static void sp_pen_context_class_init(SPPenContextClass *klass); static void sp_pen_context_init(SPPenContext *pc); static void sp_pen_context_dispose(GObject *object); @@ -995,9 +1050,9 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) switch (get_group0_keyval (&event->key)) { - case GDK_Left: // move last point left - case GDK_KP_Left: - case GDK_KP_4: + case GDK_KEY_Left: // move last point left + case GDK_KEY_KP_Left: + case GDK_KEY_KP_4: if (!MOD__CTRL) { // not ctrl if (MOD__ALT) { // alt if (MOD__SHIFT) pen_lastpoint_move_screen(pc, -10, 0); // shift @@ -1010,9 +1065,9 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) ret = TRUE; } break; - case GDK_Up: // move last point up - case GDK_KP_Up: - case GDK_KP_8: + case GDK_KEY_Up: // move last point up + case GDK_KEY_KP_Up: + case GDK_KEY_KP_8: if (!MOD__CTRL) { // not ctrl if (MOD__ALT) { // alt if (MOD__SHIFT) pen_lastpoint_move_screen(pc, 0, 10); // shift @@ -1025,9 +1080,9 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) ret = TRUE; } break; - case GDK_Right: // move last point right - case GDK_KP_Right: - case GDK_KP_6: + case GDK_KEY_Right: // move last point right + case GDK_KEY_KP_Right: + case GDK_KEY_KP_6: if (!MOD__CTRL) { // not ctrl if (MOD__ALT) { // alt if (MOD__SHIFT) pen_lastpoint_move_screen(pc, 10, 0); // shift @@ -1040,9 +1095,9 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) ret = TRUE; } break; - case GDK_Down: // move last point down - case GDK_KP_Down: - case GDK_KP_2: + case GDK_KEY_Down: // move last point down + case GDK_KEY_KP_Down: + case GDK_KEY_KP_2: if (!MOD__CTRL) { // not ctrl if (MOD__ALT) { // alt if (MOD__SHIFT) pen_lastpoint_move_screen(pc, 0, -10); // shift @@ -1057,32 +1112,32 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) break; /* TODO: this is not yet enabled?? looks like some traces of the Geometry tool - case GDK_P: - case GDK_p: + case GDK_KEY_P: + case GDK_KEY_p: if (MOD__SHIFT_ONLY) { sp_pen_context_wait_for_LPE_mouse_clicks(pc, Inkscape::LivePathEffect::PARALLEL, 2); ret = TRUE; } break; - case GDK_C: - case GDK_c: + case GDK_KEY_C: + case GDK_KEY_c: if (MOD__SHIFT_ONLY) { sp_pen_context_wait_for_LPE_mouse_clicks(pc, Inkscape::LivePathEffect::CIRCLE_3PTS, 3); ret = TRUE; } break; - case GDK_B: - case GDK_b: + case GDK_KEY_B: + case GDK_KEY_b: if (MOD__SHIFT_ONLY) { sp_pen_context_wait_for_LPE_mouse_clicks(pc, Inkscape::LivePathEffect::PERP_BISECTOR, 2); ret = TRUE; } break; - case GDK_A: - case GDK_a: + case GDK_KEY_A: + case GDK_KEY_a: if (MOD__SHIFT_ONLY) { sp_pen_context_wait_for_LPE_mouse_clicks(pc, Inkscape::LivePathEffect::ANGLE_BISECTOR, 3); ret = TRUE; @@ -1090,53 +1145,53 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) break; */ - case GDK_U: - case GDK_u: + case GDK_KEY_U: + case GDK_KEY_u: if (MOD__SHIFT_ONLY) { pen_lastpoint_tocurve(pc); ret = TRUE; } break; - case GDK_L: - case GDK_l: + case GDK_KEY_L: + case GDK_KEY_l: if (MOD__SHIFT_ONLY) { pen_lastpoint_toline(pc); ret = TRUE; } break; - case GDK_Return: - case GDK_KP_Enter: + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: if (pc->npoints != 0) { spdc_pen_finish(pc, FALSE); ret = TRUE; } break; - case GDK_Escape: + case GDK_KEY_Escape: if (pc->npoints != 0) { // if drawing, cancel, otherwise pass it up for deselecting pen_cancel (pc); ret = TRUE; } break; - case GDK_z: - case GDK_Z: + case GDK_KEY_z: + case GDK_KEY_Z: if (MOD__CTRL_ONLY && pc->npoints != 0) { // if drawing, cancel, otherwise pass it up for undo pen_cancel (pc); ret = TRUE; } break; - case GDK_g: - case GDK_G: + case GDK_KEY_g: + case GDK_KEY_G: if (MOD__SHIFT_ONLY) { sp_selection_to_guides(SP_EVENT_CONTEXT(pc)->desktop); ret = true; } break; - case GDK_BackSpace: - case GDK_Delete: - case GDK_KP_Delete: + case GDK_KEY_BackSpace: + case GDK_KEY_Delete: + case GDK_KEY_KP_Delete: if ( pc->green_curve->is_empty() || (pc->green_curve->last_segment() == NULL) ) { if (!pc->red_curve->is_empty()) { pen_cancel (pc); diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index e6bd8f297..03fa507de 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -45,6 +45,58 @@ #include "display/curve.h" #include "livarot/Path.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#endif + + static void sp_pencil_context_class_init(SPPencilContextClass *klass); static void sp_pencil_context_init(SPPencilContext *pc); static void sp_pencil_context_setup(SPEventContext *ec); @@ -567,16 +619,16 @@ pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint con { gint ret = FALSE; switch (keyval) { - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: // Prevent the zoom field from activation. if (!mod_ctrl_only(state)) { ret = TRUE; } break; - case GDK_Escape: + case GDK_KEY_Escape: if (pc->npoints != 0) { // if drawing, cancel, otherwise pass it up for deselecting if (pc->state != SP_PENCIL_CONTEXT_IDLE) { @@ -585,8 +637,8 @@ pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint con } } break; - case GDK_z: - case GDK_Z: + case GDK_KEY_z: + case GDK_KEY_Z: if (mod_ctrl_only(state) && pc->npoints != 0) { // if drawing, cancel, otherwise pass it up for undo if (pc->state != SP_PENCIL_CONTEXT_IDLE) { @@ -595,17 +647,17 @@ pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint con } } break; - case GDK_g: - case GDK_G: + case GDK_KEY_g: + case GDK_KEY_G: if (mod_shift_only(state)) { sp_selection_to_guides(SP_EVENT_CONTEXT(pc)->desktop); ret = true; } break; - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Meta_L: - case GDK_Meta_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + case GDK_KEY_Meta_L: + case GDK_KEY_Meta_R: if (pc->state == SP_PENCIL_CONTEXT_IDLE) { pc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Sketch mode: holding Alt interpolates between sketched paths. Release Alt to finalize.")); } diff --git a/src/rect-context.cpp b/src/rect-context.cpp index 7231038dc..d1f10d1ec 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -46,6 +46,62 @@ #include "verbs.h" #include "display/sp-canvas-item.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#endif + using Inkscape::DocumentUndo; //static const double goldenratio = 1.61803398874989484820; // golden ratio @@ -364,14 +420,14 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent break; case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Meta_L: // Meta is when you press Shift+Alt (at least on my machine) - case GDK_Meta_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt (at least on my machine) + case GDK_KEY_Meta_R: if (!dragging){ sp_event_show_modifier_tip (event_context->defaultMessageContext(), event, _("Ctrl: make square or integer-ratio rect, lock a rounded corner circular"), @@ -379,32 +435,32 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent NULL); } break; - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: // prevent the zoom field from activation if (!MOD__CTRL_ONLY) ret = TRUE; break; - case GDK_x: - case GDK_X: + case GDK_KEY_x: + case GDK_KEY_X: if (MOD__ALT_ONLY) { desktop->setToolboxFocusTo ("altx-rect"); ret = TRUE; } break; - case GDK_g: - case GDK_G: + case GDK_KEY_g: + case GDK_KEY_G: if (MOD__SHIFT_ONLY) { sp_selection_to_guides(desktop); ret = true; } break; - case GDK_Escape: + case GDK_KEY_Escape: if (dragging) { dragging = false; sp_event_context_discard_delayed_snap_event(event_context); @@ -414,7 +470,7 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent } break; - case GDK_space: + case GDK_KEY_space: if (dragging) { sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); @@ -434,14 +490,14 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent break; case GDK_KEY_RELEASE: switch (get_group0_keyval (&event->key)) { - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Meta_L: // Meta is when you press Shift+Alt - case GDK_Meta_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt + case GDK_KEY_Meta_R: event_context->defaultMessageContext()->clear(); break; default: diff --git a/src/select-context.cpp b/src/select-context.cpp index 922329d7a..70955c969 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -49,6 +49,72 @@ #include "display/sp-canvas.h" #include "display/drawing-item.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#endif + using Inkscape::DocumentUndo; @@ -265,14 +331,14 @@ sp_select_context_abort(SPEventContext *event_context) bool key_is_a_modifier (guint key) { - return (key == GDK_Alt_L || - key == GDK_Alt_R || - key == GDK_Control_L || - key == GDK_Control_R || - key == GDK_Shift_L || - key == GDK_Shift_R || - key == GDK_Meta_L || // Meta is when you press Shift+Alt (at least on my machine) - key == GDK_Meta_R); + return (key == GDK_KEY_Alt_L || + key == GDK_KEY_Alt_R || + key == GDK_KEY_Control_L || + key == GDK_KEY_Control_R || + key == GDK_KEY_Shift_L || + key == GDK_KEY_Shift_R || + key == GDK_KEY_Meta_L || // Meta is when you press Shift+Alt (at least on my machine) + key == GDK_KEY_Meta_R); } void @@ -399,18 +465,18 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE break; case GDK_KEY_PRESS: - if (get_group0_keyval (&event->key) == GDK_space) { + if (get_group0_keyval (&event->key) == GDK_KEY_space) { if (sc->dragging && sc->grabbed) { /* stamping mode: show content mode moving */ seltrans->stamp(); ret = TRUE; } - } else if (get_group0_keyval (&event->key) == GDK_Tab) { + } else if (get_group0_keyval (&event->key) == GDK_KEY_Tab) { if (sc->dragging && sc->grabbed) { seltrans->getNextClosestPoint(false); ret = TRUE; } - } else if (get_group0_keyval (&event->key) == GDK_ISO_Left_Tab) { + } else if (get_group0_keyval (&event->key) == GDK_KEY_ISO_Left_Tab) { if (sc->dragging && sc->grabbed) { seltrans->getNextClosestPoint(true); ret = TRUE; @@ -862,10 +928,10 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) { guint keyval = get_group0_keyval(&event->key); bool alt = ( MOD__ALT - || (keyval == GDK_Alt_L) - || (keyval == GDK_Alt_R) - || (keyval == GDK_Meta_L) - || (keyval == GDK_Meta_R)); + || (keyval == GDK_KEY_Alt_L) + || (keyval == GDK_KEY_Alt_R) + || (keyval == GDK_KEY_Meta_L) + || (keyval == GDK_KEY_Meta_R)); if (!key_is_a_modifier (keyval)) { event_context->defaultMessageContext()->clear(); @@ -900,9 +966,9 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); switch (get_group0_keyval (&event->key)) { - case GDK_Left: // move selection left - case GDK_KP_Left: - case GDK_KP_4: + case GDK_KEY_Left: // move selection left + case GDK_KEY_KP_Left: + case GDK_KEY_KP_4: if (!MOD__CTRL) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask @@ -917,9 +983,9 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } break; - case GDK_Up: // move selection up - case GDK_KP_Up: - case GDK_KP_8: + case GDK_KEY_Up: // move selection up + case GDK_KEY_KP_Up: + case GDK_KEY_KP_8: if (!MOD__CTRL) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask @@ -934,9 +1000,9 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } break; - case GDK_Right: // move selection right - case GDK_KP_Right: - case GDK_KP_6: + case GDK_KEY_Right: // move selection right + case GDK_KEY_KP_Right: + case GDK_KEY_KP_6: if (!MOD__CTRL) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask @@ -951,9 +1017,9 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } break; - case GDK_Down: // move selection down - case GDK_KP_Down: - case GDK_KP_2: + case GDK_KEY_Down: // move selection down + case GDK_KEY_KP_Down: + case GDK_KEY_KP_2: if (!MOD__CTRL) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask @@ -968,20 +1034,20 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } break; - case GDK_Escape: + case GDK_KEY_Escape: if (!sp_select_context_abort(event_context)) selection->clear(); ret = TRUE; break; - case GDK_a: - case GDK_A: + case GDK_KEY_a: + case GDK_KEY_A: if (MOD__CTRL_ONLY) { sp_edit_select_all(desktop); ret = TRUE; } break; - case GDK_space: + case GDK_KEY_space: /* stamping mode: show outline mode moving */ /* FIXME: Is next condition ok? (lauris) */ if (sc->dragging && sc->grabbed) { @@ -989,14 +1055,14 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } break; - case GDK_x: - case GDK_X: + case GDK_KEY_x: + case GDK_KEY_X: if (MOD__ALT_ONLY) { desktop->setToolboxFocusTo ("altx"); ret = TRUE; } break; - case GDK_bracketleft: + case GDK_KEY_bracketleft: if (MOD__ALT) { gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask @@ -1008,7 +1074,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) } ret = TRUE; break; - case GDK_bracketright: + case GDK_KEY_bracketright: if (MOD__ALT) { gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask @@ -1020,8 +1086,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) } ret = TRUE; break; - case GDK_less: - case GDK_comma: + case GDK_KEY_less: + case GDK_KEY_comma: if (MOD__ALT) { gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask @@ -1035,8 +1101,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) } ret = TRUE; break; - case GDK_greater: - case GDK_period: + case GDK_KEY_greater: + case GDK_KEY_period: if (MOD__ALT) { gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask @@ -1050,7 +1116,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) } ret = TRUE; break; - case GDK_Return: + case GDK_KEY_Return: if (MOD__CTRL_ONLY) { if (selection->singleItem()) { SPItem *clicked_item = selection->singleItem(); @@ -1065,14 +1131,14 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } break; - case GDK_BackSpace: + case GDK_KEY_BackSpace: if (MOD__CTRL_ONLY) { sp_select_context_up_one_layer(desktop); ret = TRUE; } break; - case GDK_s: - case GDK_S: + case GDK_KEY_s: + case GDK_KEY_S: if (MOD__SHIFT_ONLY) { if (!selection->isEmpty()) { seltrans->increaseState(); @@ -1080,8 +1146,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } break; - case GDK_g: - case GDK_G: + case GDK_KEY_g: + case GDK_KEY_G: if (MOD__SHIFT_ONLY) { sp_selection_to_guides(desktop); ret = true; @@ -1099,10 +1165,10 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) event_context->defaultMessageContext()->clear(); bool alt = ( MOD__ALT - || (keyval == GDK_Alt_L) - || (keyval == GDK_Alt_R) - || (keyval == GDK_Meta_L) - || (keyval == GDK_Meta_R)); + || (keyval == GDK_KEY_Alt_L) + || (keyval == GDK_KEY_Alt_R) + || (keyval == GDK_KEY_Meta_L) + || (keyval == GDK_KEY_Meta_R)); if (Inkscape::Rubberband::get(desktop)->is_started()) { // if Alt then change cursor to moving cursor: diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 45574fee1..4ddac3c20 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -47,6 +47,10 @@ #include <2geom/angle.h> #include "display/snap-indicator.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_space 0x020 +#endif + using Inkscape::DocumentUndo; static void sp_remove_handles(SPKnot *knot[], gint num); @@ -65,7 +69,7 @@ static gboolean sp_seltrans_handle_event(SPKnot *knot, GdkEvent *event, gpointer case GDK_MOTION_NOTIFY: break; case GDK_KEY_PRESS: - if (get_group0_keyval (&event->key) == GDK_space) { + if (get_group0_keyval (&event->key) == GDK_KEY_space) { /* stamping mode: both mode(show content and outline) operation with knot */ if (!SP_KNOT_IS_GRABBED(knot)) { return FALSE; diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index cb2100cca..17d46ec2b 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -45,6 +45,72 @@ #include "verbs.h" #include "display/sp-canvas-item.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#endif + using Inkscape::DocumentUndo; static void sp_spiral_context_class_init(SPSpiralContextClass * klass); @@ -318,34 +384,34 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) break; case GDK_KEY_PRESS: switch (get_group0_keyval(&event->key)) { - case GDK_Alt_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Meta_L: // Meta is when you press Shift+Alt (at least on my machine) - case GDK_Meta_R: + case GDK_KEY_Alt_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt (at least on my machine) + case GDK_KEY_Meta_R: sp_event_show_modifier_tip(event_context->defaultMessageContext(), event, _("Ctrl: snap angle"), NULL, _("Alt: lock spiral radius")); break; - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: // prevent the zoom field from activation if (!MOD__CTRL_ONLY) ret = TRUE; break; - case GDK_x: - case GDK_X: + case GDK_KEY_x: + case GDK_KEY_X: if (MOD__ALT_ONLY) { desktop->setToolboxFocusTo ("altx-spiral"); ret = TRUE; } break; - case GDK_Escape: + case GDK_KEY_Escape: if (dragging) { dragging = false; sp_event_context_discard_delayed_snap_event(event_context); @@ -355,7 +421,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) } break; - case GDK_space: + case GDK_KEY_space: if (dragging) { sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); @@ -375,14 +441,14 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) break; case GDK_KEY_RELEASE: switch (get_group0_keyval(&event->key)) { - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Meta_L: // Meta is when you press Shift+Alt - case GDK_Meta_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt + case GDK_KEY_Meta_R: event_context->defaultMessageContext()->clear(); break; default: diff --git a/src/star-context.cpp b/src/star-context.cpp index 4156384d5..226721cfc 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -49,6 +49,72 @@ #include "star-context.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#endif + using Inkscape::DocumentUndo; static void sp_star_context_class_init (SPStarContextClass * klass); @@ -334,34 +400,34 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent break; case GDK_KEY_PRESS: switch (get_group0_keyval(&event->key)) { - case GDK_Alt_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Meta_L: // Meta is when you press Shift+Alt (at least on my machine) - case GDK_Meta_R: + case GDK_KEY_Alt_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt (at least on my machine) + case GDK_KEY_Meta_R: sp_event_show_modifier_tip(event_context->defaultMessageContext(), event, _("Ctrl: snap angle; keep rays radial"), NULL, NULL); break; - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: // prevent the zoom field from activation if (!MOD__CTRL_ONLY) ret = TRUE; break; - case GDK_x: - case GDK_X: + case GDK_KEY_x: + case GDK_KEY_X: if (MOD__ALT_ONLY) { desktop->setToolboxFocusTo ("altx-star"); ret = TRUE; } break; - case GDK_Escape: + case GDK_KEY_Escape: if (dragging) { dragging = false; sp_event_context_discard_delayed_snap_event(event_context); @@ -370,7 +436,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent ret = TRUE; } break; - case GDK_space: + case GDK_KEY_space: if (dragging) { sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); @@ -390,14 +456,14 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent break; case GDK_KEY_RELEASE: switch (get_group0_keyval (&event->key)) { - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Control_L: - case GDK_Control_R: - case GDK_Shift_L: - case GDK_Shift_R: - case GDK_Meta_L: // Meta is when you press Shift+Alt - case GDK_Meta_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt + case GDK_KEY_Meta_R: event_context->defaultMessageContext()->clear(); break; default: diff --git a/src/ui/tool/event-utils.cpp b/src/ui/tool/event-utils.cpp index f71f0ab12..9d4b3e8e7 100644 --- a/src/ui/tool/event-utils.cpp +++ b/src/ui/tool/event-utils.cpp @@ -14,6 +14,72 @@ #include "display/sp-canvas.h" #include "ui/tool/event-utils.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#endif + namespace Inkscape { namespace UI { @@ -107,16 +173,16 @@ unsigned state_after_event(GdkEvent *event) case GDK_KEY_PRESS: state = event->key.state; switch(shortcut_key(event->key)) { - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: state |= GDK_SHIFT_MASK; break; - case GDK_Control_L: - case GDK_Control_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: state |= GDK_CONTROL_MASK; break; - case GDK_Alt_L: - case GDK_Alt_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: state |= GDK_MOD1_MASK; break; default: break; @@ -125,16 +191,16 @@ unsigned state_after_event(GdkEvent *event) case GDK_KEY_RELEASE: state = event->key.state; switch(shortcut_key(event->key)) { - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: state &= ~GDK_SHIFT_MASK; break; - case GDK_Control_L: - case GDK_Control_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: state &= ~GDK_CONTROL_MASK; break; - case GDK_Alt_L: - case GDK_Alt_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: state &= ~GDK_MOD1_MASK; break; default: break; diff --git a/src/ui/tool/modifier-tracker.cpp b/src/ui/tool/modifier-tracker.cpp index bbef0d469..ea247d4fb 100644 --- a/src/ui/tool/modifier-tracker.cpp +++ b/src/ui/tool/modifier-tracker.cpp @@ -12,6 +12,73 @@ #include #include "ui/tool/event-utils.h" #include "ui/tool/modifier-tracker.h" +#include + +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#endif namespace Inkscape { namespace UI { @@ -30,44 +97,44 @@ bool ModifierTracker::event(GdkEvent *event) switch (event->type) { case GDK_KEY_PRESS: switch (shortcut_key(event->key)) { - case GDK_Shift_L: + case GDK_KEY_Shift_L: _left_shift = true; break; - case GDK_Shift_R: + case GDK_KEY_Shift_R: _right_shift = true; break; - case GDK_Control_L: + case GDK_KEY_Control_L: _left_ctrl = true; break; - case GDK_Control_R: + case GDK_KEY_Control_R: _right_ctrl = true; break; - case GDK_Alt_L: + case GDK_KEY_Alt_L: _left_alt = true; break; - case GDK_Alt_R: + case GDK_KEY_Alt_R: _right_alt = true; break; } break; case GDK_KEY_RELEASE: switch (shortcut_key(event->key)) { - case GDK_Shift_L: + case GDK_KEY_Shift_L: _left_shift = false; break; - case GDK_Shift_R: + case GDK_KEY_Shift_R: _right_shift = false; break; - case GDK_Control_L: + case GDK_KEY_Control_L: _left_ctrl = false; break; - case GDK_Control_R: + case GDK_KEY_Control_R: _right_ctrl = false; break; - case GDK_Alt_L: + case GDK_KEY_Alt_L: _left_alt = false; break; - case GDK_Alt_R: + case GDK_KEY_Alt_R: _right_alt = false; break; } -- cgit v1.2.3 From d9ddbd7650ea9ef01ce73610cde62689765de83e Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 9 Apr 2012 17:52:04 +0100 Subject: Fix CheckButton header issue with GTK+ 3 (bzr r11195) --- src/ui/widget/registered-widget.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 2f8c51f51..2a7843a51 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -30,6 +30,8 @@ #include "desktop-handles.h" #include "sp-namedview.h" +#include + class SPUnit; class SPDocument; -- cgit v1.2.3 From 92a8546a868b616dcd3eeb0812c4a9ce5eb85f2c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 9 Apr 2012 18:19:31 +0100 Subject: Replace deprecated gdk_cursor_unref (bzr r11196) --- src/desktop-events.cpp | 12 ++++++++++++ src/desktop.cpp | 4 ++++ src/event-context.cpp | 12 ++++++++++++ src/inkview.cpp | 8 ++++++++ src/knot.cpp | 4 ++++ src/select-context.cpp | 8 ++++++++ src/svg-view.cpp | 4 ++++ src/ui/widget/selected-style.cpp | 8 ++++++++ 8 files changed, 60 insertions(+) (limited to 'src') diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index b361b8404..ae198f5c1 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -450,7 +450,11 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) GdkCursor *guide_cursor; guide_cursor = gdk_cursor_new (GDK_EXCHANGE); gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor); +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(guide_cursor); +#else gdk_cursor_unref(guide_cursor); +#endif } char *guide_description = sp_guide_description(guide); @@ -485,7 +489,11 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) GdkCursor *guide_cursor; guide_cursor = gdk_cursor_new (GDK_EXCHANGE); gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor); +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(guide_cursor); +#else gdk_cursor_unref(guide_cursor); +#endif ret = TRUE; break; } @@ -502,7 +510,11 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) GdkCursor *guide_cursor; guide_cursor = gdk_cursor_new (GDK_EXCHANGE); gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor); +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(guide_cursor); +#else gdk_cursor_unref(guide_cursor); +#endif break; default: // do nothing; diff --git a/src/desktop.cpp b/src/desktop.cpp index cf71c8f9e..7aabb1245 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1402,7 +1402,11 @@ void SPDesktop::setWaitingCursor() { GdkCursor *waiting = gdk_cursor_new(GDK_WATCH); gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(this))), waiting); +#if GTK_CHECK_VERSION(3,0,0) + g_cursor_unref(waiting); +#else gdk_cursor_unref(waiting); +#endif // GDK needs the flush for the cursor change to take effect gdk_flush(); waiting_cursor = true; diff --git a/src/event-context.cpp b/src/event-context.cpp index 4ea4068fe..3bf1179c8 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -158,7 +158,11 @@ static void sp_event_context_dispose(GObject *object) { } if (ec->cursor != NULL) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(ec->cursor); +#else gdk_cursor_unref(ec->cursor); +#endif ec->cursor = NULL; } @@ -204,7 +208,11 @@ void sp_event_context_update_cursor(SPEventContext *ec) { ); if (pixbuf != NULL) { if (ec->cursor) +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(ec->cursor); +#else gdk_cursor_unref(ec->cursor); +#endif ec->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, ec->hot_x, ec->hot_y); g_object_unref(pixbuf); } @@ -214,7 +222,11 @@ void sp_event_context_update_cursor(SPEventContext *ec) { sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, ec->cursor_shape); if ((bitmap != NULL) && (mask != NULL)) { if (ec->cursor) +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(ec->cursor); +#else gdk_cursor_unref(ec->cursor); +#endif ec->cursor = gdk_cursor_new_from_pixmap(bitmap, mask, &style->black, &style->white, ec->hot_x, ec->hot_y); diff --git a/src/inkview.cpp b/src/inkview.cpp index c188827ce..57963577c 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -413,11 +413,19 @@ sp_svgview_waiting_cursor(struct SPSlideShow *ss) { GdkCursor *waiting = gdk_cursor_new(GDK_WATCH); gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(ss->window)), waiting); +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(waiting); +#else gdk_cursor_unref(waiting); +#endif if (ctrlwin) { GdkCursor *waiting = gdk_cursor_new(GDK_WATCH); gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(ctrlwin)), waiting); +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(waiting); +#else gdk_cursor_unref(waiting); +#endif } while(gtk_events_pending()) gtk_main_iteration(); diff --git a/src/knot.cpp b/src/knot.cpp index fe99eb4e1..4da9f01ee 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -245,7 +245,11 @@ static void sp_knot_dispose(GObject *object) for (gint i = 0; i < SP_KNOT_VISIBLE_STATES; i++) { if (knot->cursor[i]) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(knot->cursor[i]); +#else gdk_cursor_unref(knot->cursor[i]); +#endif knot->cursor[i] = NULL; } } diff --git a/src/select-context.cpp b/src/select-context.cpp index 70955c969..37d0e79ec 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -229,11 +229,19 @@ sp_select_context_dispose(GObject *object) sc->_describer = NULL; if (CursorSelectDragging) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(CursorSelectDragging); +#else gdk_cursor_unref (CursorSelectDragging); +#endif CursorSelectDragging = NULL; } if (CursorSelectMouseover) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(CursorSelectMouseover); +#else gdk_cursor_unref (CursorSelectMouseover); +#endif CursorSelectMouseover = NULL; } diff --git a/src/svg-view.cpp b/src/svg-view.cpp index aa6666445..7559cbb24 100644 --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@ -105,7 +105,11 @@ void SPSVGView::mouseover() GdkCursor *cursor = gdk_cursor_new(GDK_HAND2); GdkWindow *window = gtk_widget_get_window (GTK_WIDGET(SP_CANVAS_ITEM(_drawing)->canvas)); gdk_window_set_cursor(window, cursor); +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(cursor); +#else gdk_cursor_unref(cursor); +#endif } void SPSVGView::mouseout() diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index ab7b99237..faf518bbd 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1259,7 +1259,11 @@ RotateableSwatch::do_motion(double by, guint modifier) { g_object_unref (bitmap); g_object_unref (mask); gdk_window_set_cursor(gtk_widget_get_window(w), cr); +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(cr); +#else gdk_cursor_unref(cr); +#endif cr_set = true; } } @@ -1314,7 +1318,11 @@ RotateableSwatch::do_release(double by, guint modifier) { GtkWidget *w = GTK_WIDGET(gobj()); gdk_window_set_cursor(gtk_widget_get_window(w), NULL); if (cr) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(cr); +#else gdk_cursor_unref (cr); +#endif cr = NULL; } cr_set = false; -- cgit v1.2.3 From dd9de5de1c9ad49810ca7bdddd22240e72c1a33f Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 9 Apr 2012 18:46:22 +0100 Subject: Replace deprecated gdk_window_get_pointer (bzr r11197) --- src/desktop-events.cpp | 10 ++++++++-- src/widgets/desktop-widget.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index ae198f5c1..b16cebee2 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -84,12 +84,18 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge int wx, wy; SPDesktop *desktop = dtw->desktop; + GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(dtw->canvas)); - gdk_window_get_pointer(gtk_widget_get_window (GTK_WIDGET(dtw->canvas)), &wx, &wy, NULL); +#if GTK_CHECK_VERSION(3,0,0) + GdkDisplay *display = gdk_window_get_display(window); + gdk_window_get_device_position(window, display->core_pointer, &wx, &wy, NULL); +#else + gdk_window_get_pointer(window, &wx, &wy, NULL); +#endif Geom::Point const event_win(wx, wy); gint width, height; - gdk_window_get_geometry(gtk_widget_get_window (GTK_WIDGET(dtw->canvas)), NULL /*x*/, NULL /*y*/, &width, &height, NULL/*depth*/); + gdk_window_get_geometry(window, NULL /*x*/, NULL /*y*/, &width, &height, NULL/*depth*/); switch (event->type) { case GDK_BUTTON_PRESS: diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index bb1a0908c..fd529e959 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -253,7 +253,14 @@ Geom::Point SPDesktopWidget::window_get_pointer() { gint x,y; - gdk_window_get_pointer(gtk_widget_get_window(GTK_WIDGET(canvas)), &x, &y, NULL); + GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(canvas)); + +#if GTK_CHECK_VERSION(3,0,0) + GdkDisplay *display = gdk_window_get_display(window); + gdk_window_get_device_position(window, display->core_pointer, &x, &y, NULL); +#else + gdk_window_get_pointer(window, &x, &y, NULL); +#endif return Geom::Point(x,y); } -- cgit v1.2.3 From 9a34c46a626e37b37769a5992e49d94d008b22cb Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 9 Apr 2012 20:06:13 +0100 Subject: ege-adjustment-action: Get rid of GtkHBox (bzr r11199) --- src/ege-adjustment-action.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 49f899372..7497b0497 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -815,7 +815,12 @@ static GtkWidget* create_tool_item( GtkAction* action ) if ( IS_EGE_ADJUSTMENT_ACTION(action) ) { EgeAdjustmentAction* act = EGE_ADJUSTMENT_ACTION( action ); GtkWidget* spinbutton = 0; +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget* hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget* hb = gtk_hbox_new( FALSE, 5 ); +#endif GValue value; memset( &value, 0, sizeof(value) ); g_value_init( &value, G_TYPE_STRING ); -- cgit v1.2.3 From d0dd1656c0c53026ea672a366e7405a6e9cfc637 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 9 Apr 2012 21:18:03 +0200 Subject: Documentation / dropping some pointer conversions in context menu (bzr r11200) --- src/interface.cpp | 112 +++++++++++++---------------------------- src/interface.h | 145 ++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 159 insertions(+), 98 deletions(-) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index 319eceaec..5d030c397 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -287,8 +287,6 @@ sp_ui_new_view() sp_namedview_update_layers_from_document(static_cast(dtw->view)); } -/* TODO: not yet working */ -/* To be re-enabled (by adding to menu) once it works. */ void sp_ui_new_view_preview() { SPDocument *document = SP_ACTIVE_DOCUMENT; @@ -301,9 +299,6 @@ void sp_ui_new_view_preview() } } -/** - * \param widget unused - */ void sp_ui_close_view(GtkWidget */*widget*/) { @@ -323,17 +318,6 @@ sp_ui_close_view(GtkWidget */*widget*/) } -/** - * sp_ui_close_all - * - * This function is called to exit the program, and iterates through all - * open document view windows, attempting to close each in turn. If the - * view has unsaved information, the user will be prompted to save, - * discard, or cancel. - * - * Returns FALSE if the user cancels the close_all operation, TRUE - * otherwise. - */ unsigned int sp_ui_close_all(void) { @@ -395,10 +379,7 @@ sp_ui_menu_deselect(gpointer object) } /** - * sp_ui_menuitem_add_icon - * * Creates and attaches a scaled icon to the given menu item. - * */ void sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name ) @@ -416,10 +397,7 @@ sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name ) } // end of sp_ui_menu_add_icon /** - * sp_ui_menu_append_item - * * Appends a UI item with specific info for Inkscape/Sodipodi. - * */ static GtkWidget * sp_ui_menu_append_item( GtkMenu *menu, gchar const *stock, @@ -486,12 +464,10 @@ sp_ui_dialog_title_string(Inkscape::Verb *verb, gchar *c) /** - * sp_ui_menu_append_item_from_verb - * * Appends a custom menu UI from a verb. - * + * + * @see ContextMenu::AppendItemFromVerb for a c++ified alternative. Consider dropping sp_ui_menu_append_item_from_verb when c++ifying interface.cpp. */ - static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::UI::View::View *view, bool radio = false, GSList *group = NULL) { SPAction *action; @@ -1010,15 +986,6 @@ void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape } } -/** - * Build the main tool bar. - * - * Currently the main tool bar is built as a dynamic XML menu using - * \c sp_ui_build_dyn_menus. This function builds the bar, and then - * pass it to get items attached to it. - * - * @param view View to build the bar for - */ GtkWidget *sp_ui_main_menubar(Inkscape::UI::View::View *view) { GtkWidget *mbar = gtk_menu_bar_new(); @@ -1558,18 +1525,7 @@ void injectRenamedIcons() } -void ContextMenu::EnterGroup(Gtk::MenuItem* mi) -{ - _desktop->setCurrentLayer(reinterpret_cast(mi->get_data("group"))); - _desktop->selection->clear(); -} - -void ContextMenu::LeaveGroup(void) -{ - _desktop->setCurrentLayer(_desktop->currentLayer()->parent); -} - -ContextMenu::ContextMenu(Inkscape::UI::View::View *view, SPItem *item) : +ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) : _item(item), separators(), MIGroup(), @@ -1577,22 +1533,17 @@ ContextMenu::ContextMenu(Inkscape::UI::View::View *view, SPItem *item) : { // g_message("ContextMenu"); _object = static_cast(item); - _desktop = static_cast(view); - - /* Undo and Redo */ - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_UNDO), view); - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_REDO), view); + _desktop = desktop; + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_UNDO)); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_REDO)); AddSeparator(); - - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_CUT), view); - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_COPY), view); - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_PASTE), view); - + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_CUT)); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_COPY)); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_PASTE)); AddSeparator(); - - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DUPLICATE), view); - AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DELETE), view); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DUPLICATE)); + AppendItemFromVerb(Inkscape::Verb::get(SP_VERB_EDIT_DELETE)); positionOfLastDialog = 10; // 9 in front + 1 for the separator in the next if; used to position the dialog menu entries below each other @@ -1649,10 +1600,22 @@ Gtk::SeparatorMenuItem* ContextMenu::AddSeparator(void) return sep; } -void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb, Inkscape::UI::View::View *view)//, bool radio, GSList *group) +void ContextMenu::EnterGroup(Gtk::MenuItem* mi) { - SPAction *action; + _desktop->setCurrentLayer(reinterpret_cast(mi->get_data("group"))); + _desktop->selection->clear(); +} +void ContextMenu::LeaveGroup(void) +{ + _desktop->setCurrentLayer(_desktop->currentLayer()->parent); +} + +void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)//, bool radio, GSList *group) +{ + SPAction *action; + SPDesktop *view = _desktop; + if (verb->get_code() == SP_VERB_NONE) { Gtk::MenuItem *item = AddSeparator(); item->show(); @@ -1705,7 +1668,6 @@ void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb, Inkscape::UI::View::V sp_ui_menuitem_add_icon((GtkWidget*)item->gobj(), action->image); } item->set_events(Gdk::KEY_PRESS_MASK); - item->set_data("view", (gpointer) view); item->signal_activate().connect(sigc::bind(sigc::ptr_fun(sp_ui_menu_activate),item,action)); item->signal_select().connect(sigc::bind(sigc::ptr_fun(sp_ui_menu_select_action),item,action)); item->signal_deselect().connect(sigc::bind(sigc::ptr_fun(sp_ui_menu_deselect_action),item,action)); @@ -1717,7 +1679,6 @@ void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb, Inkscape::UI::View::V void ContextMenu::MakeObjectMenu(void) { GObjectClass *klass = G_OBJECT_GET_CLASS(_object); //to deduce the object's type from its class - GType type = G_TYPE_FROM_CLASS(klass); if (G_TYPE_CHECK_CLASS_TYPE(klass, SP_TYPE_ITEM)) { @@ -1909,7 +1870,7 @@ void ContextMenu::ReleaseClip(void) void ContextMenu::MakeGroupMenu(void) { - /* "Ungroup" */ + /* Ungroup */ Gtk::MenuItem* mi = new Gtk::MenuItem(_("_Ungroup"),1); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroup)); mi->show(); @@ -1933,7 +1894,7 @@ void ContextMenu::MakeAnchorMenu(void) mi = new Gtk::MenuItem(_("Link _Properties..."),1); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::AnchorLinkProperties)); mi->show(); - insert(*mi,positionOfLastDialog++);//append(*mi); + insert(*mi,positionOfLastDialog++); /* Select item */ mi = new Gtk::MenuItem(_("_Follow Link"),1); @@ -1975,13 +1936,13 @@ void ContextMenu::MakeImageMenu (void) mi = new Gtk::MenuItem(_("Image _Properties..."),1); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageProperties)); mi->show(); - insert(*mi,positionOfLastDialog++);//append(*mi); + insert(*mi,positionOfLastDialog++); /* Edit externally */ mi = new Gtk::MenuItem(_("Edit Externally..."),1); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEdit)); mi->show(); - insert(*mi,positionOfLastDialog++);//append(*mi); + insert(*mi,positionOfLastDialog++); if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { mi->set_sensitive( FALSE ); } @@ -2002,7 +1963,7 @@ void ContextMenu::MakeImageMenu (void) mi = new Gtk::MenuItem(C_("Context menu", "Extract Image...")); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageExtract)); mi->show(); - insert(*mi,positionOfLastDialog++);//append(*mi); + insert(*mi,positionOfLastDialog++); if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { mi->set_sensitive( FALSE ); } @@ -2027,7 +1988,6 @@ Glib::ustring ContextMenu::getImageEditorName() { return value; } -/* Edit Externally entry */ void ContextMenu::ImageEdit(void) { if (_desktop->selection->isEmpty()) { @@ -2098,7 +2058,6 @@ void ContextMenu::ImageEdit(void) } } -/* Embed Image entry */ void ContextMenu::ImageEmbed(void) { if (_desktop->selection->isEmpty()) { @@ -2114,7 +2073,6 @@ void ContextMenu::ImageEmbed(void) } } -/* Extract Image entry */ void ContextMenu::ImageExtract(void) { if (_desktop->selection->isEmpty()) { @@ -2138,7 +2096,7 @@ void ContextMenu::MakeShapeMenu (void) mi = new Gtk::MenuItem(_("_Fill and Stroke..."),1); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings)); mi->show(); - insert(*mi,positionOfLastDialog++);//append(*mi); + insert(*mi,positionOfLastDialog++); } void ContextMenu::FillSettings(void) @@ -2158,22 +2116,21 @@ void ContextMenu::MakeTextMenu (void) mi = new Gtk::MenuItem(_("_Fill and Stroke..."),1); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::FillSettings)); mi->show(); - insert(*mi,positionOfLastDialog++);//append(*mi); + insert(*mi,positionOfLastDialog++); /* Edit Text dialog */ mi = new Gtk::MenuItem(_("_Text and Font..."),1); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::TextSettings)); mi->show(); - insert(*mi,positionOfLastDialog++);//append(*mi); + insert(*mi,positionOfLastDialog++); /* Spellcheck dialog */ mi = new Gtk::MenuItem(_("Check Spellin_g..."),1); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::SpellcheckSettings)); mi->show(); - insert(*mi,positionOfLastDialog++);//append(*mi); + insert(*mi,positionOfLastDialog++); } -/* Edit Text entry */ void ContextMenu::TextSettings (void) { if (_desktop->selection->isEmpty()) { @@ -2183,7 +2140,6 @@ void ContextMenu::TextSettings (void) _desktop->_dlg_mgr->showDialog("TextFont"); } -/* Spellcheck entry */ void ContextMenu::SpellcheckSettings (void) { if (_desktop->selection->isEmpty()) { diff --git a/src/interface.h b/src/interface.h index e21a0f752..0751171e2 100644 --- a/src/interface.h +++ b/src/interface.h @@ -41,35 +41,40 @@ class View; void sp_create_window (SPViewWidget *vw, gboolean editable); /** - * + * \param widget unused */ void sp_ui_close_view (GtkWidget *widget); +void sp_ui_new_view (void); + /** - * + * @todo TODO: not yet working. To be re-enabled (by adding to menu) once it works. */ -void sp_ui_new_view (void); void sp_ui_new_view_preview (void); /** + * This function is called to exit the program, and iterates through all + * open document view windows, attempting to close each in turn. If the + * view has unsaved information, the user will be prompted to save, + * discard, or cancel. * + * Returns FALSE if the user cancels the close_all operation, TRUE + * otherwise. */ unsigned int sp_ui_close_all (void); /** + * Build the main tool bar. + * + * Currently the main tool bar is built as a dynamic XML menu using + * \c sp_ui_build_dyn_menus. This function builds the bar, and then + * pass it to get items attached to it. * + * @param view View to build the bar for */ GtkWidget *sp_ui_main_menubar (Inkscape::UI::View::View *view); -/** - * - */ void sp_menu_append_recent_documents (GtkWidget *menu); - - -/** - * - */ void sp_ui_dialog_title_string (Inkscape::Verb * verb, gchar* c); @@ -79,34 +84,88 @@ void sp_ui_dialog_title_string (Inkscape::Verb * verb, gchar* c); void sp_ui_error_dialog (const gchar * message); bool sp_ui_overwrite_file (const gchar * filename); + +/** + * Implements the Inkscape context menu. + * + * For the context menu implementation, the ContextMenu class stores the object + * that was selected in a private data member. This should be farely safe to do + * and a pointer to the SPItem as well as SPObject class are kept. + * All callbacks of the context menu entries are implemented as private + * functions. + * + * @todo add callbacks to destroy the context menu when it is closed (=key or mouse button pressed out of the scope of the context menu) + */ class ContextMenu : public Gtk::Menu { public: - ContextMenu(Inkscape::UI::View::View *view, SPItem *item); + /** + * The ContextMenu constructor contains all code to create and show the + * menu entries (aka child widgets). + * + * @param desktop pointer to the desktop the user is currently working on. + * @param item SPItem pointer to the object selected at the time the ContextMenu is created. + */ + ContextMenu(SPDesktop *desktop, SPItem *item); ~ContextMenu(void); + private: - SPItem *_item; - SPObject *_object; - SPDesktop *_desktop; + SPItem *_item; // pointer to the object selected at the time the ContextMenu is created + SPObject *_object; // pointer to the object selected at the time the ContextMenu is created + SPDesktop *_desktop; //pointer to the desktop the user was currently working on at the time the ContextMenu is created int positionOfLastDialog; - std::vector separators; - Gtk::MenuItem MIGroup; - Gtk::MenuItem MIParent; + std::vector separators; //contains pointers to separators + Gtk::MenuItem MIGroup; //menu entry to enter a group + Gtk::MenuItem MIParent; //menu entry to leave a group + /** + * auxiliary function that adds a separator line in the context menu + */ Gtk::SeparatorMenuItem* AddSeparator(void); - void AppendItemFromVerb(Inkscape::Verb *verb, Inkscape::UI::View::View *view); - void MakeObjectMenu (void); + + /** + * c++ified version of sp_ui_menu_append_item. + * + * @see sp_ui_menu_append_item_from_verb and synchronize/drop that function when c++ifying other code in interface.cpp + */ + void AppendItemFromVerb(Inkscape::Verb *verb); + + /** + * main function which is responsible for creating the context sensitive menu items, + * calls subfunctions below to create the menu entry widgets. + */ + void MakeObjectMenu (void); + /** + * creates menu entries for an SP_TYPE_ITEM object + */ void MakeItemMenu (void); + /** + * creates menu entries for a grouped object + */ void MakeGroupMenu (void); + /** + * creates menu entries for an anchor object + */ void MakeAnchorMenu (void); + /** + * creates menu entries for a bitmap image object + */ void MakeImageMenu (void); + /** + * creates menu entries for a shape object + */ void MakeShapeMenu (void); + /** + * creates menu entries for a text object + */ void MakeTextMenu (void); void EnterGroup(Gtk::MenuItem* mi); void LeaveGroup(void); + ////////////////////////////////////////// + //callbacks for the context menu entries of an SP_TYPE_ITEM object void ItemProperties(void); void ItemSelectThis(void); void SelectSameFillStroke(void); @@ -115,22 +174,68 @@ class ContextMenu : public Gtk::Menu void ReleaseMask(void); void SetClip(void); void ReleaseClip(void); + ////////////////////////////////////////// + + /** + * callback, is executed on clicking the anchor "Ungroup" menu entry + */ void ActivateUngroup(void); + void AnchorLinkProperties(void); + /** + * placeholder for callback to be executed on clicking the anchor "Follow link" context menu entry + * @todo add code to follow link externally + */ void AnchorLinkFollow(void); + + /** + * callback, is executed on clicking the anchor "Link remove" menu entry + */ void AnchorLinkRemove(void); + + /** + * callback, opens the image properties dialog and is executed on clicking the context menu entry with similar name + */ void ImageProperties(void); + + /** + * callback, is executed on clicking the image "Edit Externally" menu entry + */ void ImageEdit(void); + + /** + * auxiliary function that loads the external image editor name from the settings. + */ Glib::ustring getImageEditorName(); + + /** + * callback, is executed on clicking the "Embed Image" menu entry + */ void ImageEmbed(void); + + /** + * callback, is executed on clicking the "Extract Image" menu entry + */ void ImageExtract(void); + + /** + * callback, is executed on clicking the "Fill and Stroke" menu entry + */ void FillSettings(void); + + /** + * callback, is executed on clicking the "Text and Font" menu entry + */ void TextSettings(void); + + /** + * callback, is executed on clicking the "Check spelling" menu entry + */ void SpellcheckSettings(void); }; -- cgit v1.2.3 From 352a8b65716e482c44920cc94d5f48ca5bc49068 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 9 Apr 2012 21:19:30 +0200 Subject: cppcheck stuff (bzr r11201) --- src/document.cpp | 2 +- src/dom/svgtypes.h | 5 ----- src/extension/dxf2svg/test_dxf.cpp | 4 ++-- src/helper/geom.cpp | 12 ++++++------ src/io/gzipstream.cpp | 18 +++++++----------- src/xml/simple-document.h | 3 ++- 6 files changed, 18 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 7b68dd499..cc139aae0 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1429,7 +1429,7 @@ void SPDocument::setModifiedSinceSave(bool modified) { this->modified_since_save = modified; Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel(); g_assert(parent != NULL); - SPDesktopWidget *dtw = (SPDesktopWidget *) parent->get_data("desktopwidget"); + SPDesktopWidget *dtw = static_cast(parent->get_data("desktopwidget")); dtw->updateTitle( this->getName() ); } diff --git a/src/dom/svgtypes.h b/src/dom/svgtypes.h index 0c30069b8..41b4de307 100644 --- a/src/dom/svgtypes.h +++ b/src/dom/svgtypes.h @@ -74,11 +74,6 @@ namespace svg { //local definitions typedef dom::DOMString DOMString; -typedef dom::DOMException DOMException; -typedef dom::Element Element; -typedef dom::Document Document; -typedef dom::NodeList NodeList; - class SVGElement; typedef Ptr SVGElementPtr; diff --git a/src/extension/dxf2svg/test_dxf.cpp b/src/extension/dxf2svg/test_dxf.cpp index 62969ca6e..c3bbdc141 100644 --- a/src/extension/dxf2svg/test_dxf.cpp +++ b/src/extension/dxf2svg/test_dxf.cpp @@ -80,7 +80,7 @@ int main(){ ents.display_all(); //char units[5] = "in"; - char units[5] = ""; + // char units[5] = ""; cout << "\nNow for the begining of the SVG...\n\n"; @@ -90,7 +90,7 @@ int main(){ //cout << "pline2pline\n" << pline2pline(ents.ret_plines()[0], units ) << endl; //cout << "pline2path\n" << pline2path(ents.ret_plines()[0], units ); - char tmp_char[10000]; + // char tmp_char[10000]; cout << "\nCircle conversion\n"; //cout << "circle2circle\n" << circle2circle(ents.ret_circles()[0], 3, units, tmp_char) << endl; diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index 33947c14d..585d2b8a5 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -75,11 +75,11 @@ cubic_bbox (Geom::Coord x000, Geom::Coord y000, Geom::Coord x001, Geom::Coord y0 if (fabs (a) < Geom::EPSILON) { /* s = -c / b */ if (fabs (b) > Geom::EPSILON) { - double s, t, xttt; + double s; s = -c / b; if ((s > 0.0) && (s < 1.0)) { - t = 1.0 - s; - xttt = s * s * s * x000 + 3 * s * s * t * x001 + 3 * s * t * t * x011 + t * t * t * x111; + double t = 1.0 - s; + double xttt = s * s * s * x000 + 3 * s * s * t * x001 + 3 * s * t * t * x011 + t * t * t * x111; bbox[0].expandTo(xttt); } } @@ -114,11 +114,11 @@ cubic_bbox (Geom::Coord x000, Geom::Coord y000, Geom::Coord x001, Geom::Coord y0 if (fabs (a) < Geom::EPSILON) { /* s = -c / b */ if (fabs (b) > Geom::EPSILON) { - double s, t, yttt; + double s; s = -c / b; if ((s > 0.0) && (s < 1.0)) { - t = 1.0 - s; - yttt = s * s * s * y000 + 3 * s * s * t * y001 + 3 * s * t * t * y011 + t * t * t * y111; + double t = 1.0 - s; + double yttt = s * s * s * y000 + 3 * s * s * t * y001 + 3 * s * t * t * y011 + t * t * t * y111; bbox[1].expandTo(yttt); } } diff --git a/src/io/gzipstream.cpp b/src/io/gzipstream.cpp index ed94974fe..efa96412d 100644 --- a/src/io/gzipstream.cpp +++ b/src/io/gzipstream.cpp @@ -37,6 +37,7 @@ GzipInputStream::GzipInputStream(InputStream &sourceStream) loaded(false), totalIn(0), totalOut(0), + srcBuf(NULL), outputBuf(NULL), crc(0), srcCrc(0), @@ -57,11 +58,11 @@ GzipInputStream::~GzipInputStream() close(); if ( srcBuf ) { free(srcBuf); - srcBuf = 0; + srcBuf = NULL; } if ( outputBuf ) { free(outputBuf); - outputBuf = 0; + outputBuf = NULL; } } @@ -94,11 +95,11 @@ void GzipInputStream::close() if ( srcBuf ) { free(srcBuf); - srcBuf = 0; + srcBuf = NULL; } if ( outputBuf ) { free(outputBuf); - outputBuf = 0; + outputBuf = NULL; } closed = true; } @@ -117,10 +118,9 @@ int GzipInputStream::get() } else { loaded = true; - int zerr = Z_OK; if ( outputBufPos >= outputBufLen ) { // time to read more, if we can - zerr = fetchMore(); + fetchMore(); } if ( outputBufPos < outputBufLen ) { @@ -201,13 +201,13 @@ bool GzipInputStream::load() //OS val = (int)srcBuf[9]; - int cur = 10; // if ( flags & FEXTRA ) { // headerLen += 2; // int xlen = // TODO deal with optional header parts // } if ( flags & FNAME ) { + int cur = 10; while ( srcBuf[cur] ) { cur++; @@ -229,10 +229,6 @@ bool GzipInputStream::load() | ((0x0ff & srcBuf[srcLen - 4]) << 0); //printf("srcSiz:%lx/%ld\n", srcSiz, srcSiz); - if ( srcSiz <= 0 ) { - return false; - } - //outputBufLen = srcSiz + srcSiz/100 + 14; unsigned char *data = srcBuf + headerLen; diff --git a/src/xml/simple-document.h b/src/xml/simple-document.h index ff1d94b0c..7cbe50dda 100644 --- a/src/xml/simple-document.h +++ b/src/xml/simple-document.h @@ -66,7 +66,8 @@ public: protected: SimpleDocument(SimpleDocument const &doc) : Node(), SimpleNode(doc), Document(), NodeObserver(), - _in_transaction(false) {} + _in_transaction(false), + _is_CData(false){} SimpleNode *_duplicate(Document* /*doc*/) const { -- cgit v1.2.3 From cdefc3a1c5cb127007c4c013f58a5bec21aa36a3 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 9 Apr 2012 21:24:32 +0200 Subject: code cleanup: dropping some unused code (bzr r11202) --- src/sp-font-face.cpp | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'src') diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 05f71cbf6..e9faabdc6 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -27,38 +27,6 @@ #include -//TODO: apparently unused. Maybe should be removed. -class ObjectContainer -{ - -public: - ObjectContainer(double def){ - this->isset = false; - this->default_value = def; - } - - double get(){ - if (this->isset) - return this->obj; - else - return this->default_value; - } - - void set(double val){ - this->obj = val; - this->isset = true; - } - - void unset(){ - this->isset = false; - } - -private: - double obj; - double default_value; - bool isset; -}; - static std::vector sp_read_fontFaceStyleType(gchar const *value){ std::vector v; -- cgit v1.2.3 From cd8cae5bf430285e5dcef81e9b46a43d8f91131b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 10 Apr 2012 01:25:07 +0100 Subject: Replace remaining gtk_hbox_new usage (bzr r11204) --- src/dialogs/find.cpp | 30 ++++++++++++++++++++ src/interface.cpp | 10 +++++++ src/ui/dialog/clonetiler.cpp | 60 +++++++++++++++++++++++++++++++++++++++ src/widgets/desktop-widget.cpp | 16 +++++++++++ src/widgets/font-selector.cpp | 5 ++++ src/widgets/gradient-selector.cpp | 10 +++++++ src/widgets/gradient-vector.cpp | 10 +++++++ src/widgets/paint-selector.cpp | 30 ++++++++++++++++++++ src/widgets/select-toolbar.cpp | 5 ++++ src/widgets/sp-color-notebook.cpp | 5 ++++ src/widgets/toolbox.cpp | 5 ++++ 11 files changed, 186 insertions(+) (limited to 'src') diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp index b96284209..b0a4e36cc 100644 --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@ -418,7 +418,12 @@ sp_find_dialog_reset (GObject *, GObject *dlg) void sp_find_new_searchfield (GtkWidget *dlg, GtkWidget *vb, const gchar *label, const gchar *id, const gchar *tip) { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new (FALSE, 0); +#endif GtkWidget *l = gtk_label_new_with_mnemonic (label); gtk_widget_set_size_request (l, FIND_LABELWIDTH, -1); gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); @@ -491,7 +496,12 @@ sp_find_types_checkbox (GtkWidget *w, const gchar *data, gboolean active, const gchar *label, void (*toggled)(GtkToggleButton *, gpointer)) { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new (FALSE, 0); +#endif gtk_widget_show (hb); { @@ -514,7 +524,12 @@ sp_find_types_checkbox_indented (GtkWidget *w, const gchar *data, gboolean activ const gchar *label, void (*toggled)(GtkToggleButton *, gpointer), guint indent) { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new (FALSE, 0); +#endif gtk_widget_show (hb); { // empty label for indent @@ -538,7 +553,12 @@ sp_find_types () gtk_widget_show (vb); { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new (FALSE, 0); +#endif gtk_widget_show (hb); { @@ -566,7 +586,12 @@ sp_find_types () { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new (FALSE, 0); +#endif gtk_widget_show (hb); { // empty label for alignment @@ -751,7 +776,12 @@ sp_find_dialog_old (void) } { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new (FALSE, 0); +#endif gtk_widget_show (hb); gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); diff --git a/src/interface.cpp b/src/interface.cpp index 5d030c397..afef8a08d 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -486,7 +486,12 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb shortcut = sp_shortcut_get_primary(verb); if (shortcut!=GDK_VoidSymbol) { gchar* c = sp_shortcut_get_label(shortcut); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *const hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 16); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *const hb = gtk_hbox_new(FALSE, 16); +#endif GtkWidget *const name_lbl = gtk_label_new(""); gtk_label_set_markup_with_mnemonic(GTK_LABEL(name_lbl), action->name); gtk_misc_set_alignment(reinterpret_cast(name_lbl), 0.0, 0.5); @@ -670,7 +675,12 @@ sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View * if (verb && shortcut!=GDK_VoidSymbol) { gchar* c = sp_shortcut_get_label(shortcut); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 16); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, 16); +#endif { GtkWidget *l = gtk_label_new_with_mnemonic(action ? action->name : label); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 36e79a682..2e44a1132 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -648,7 +648,12 @@ CloneTiler::CloneTiler (void) : GtkWidget *vb = clonetiler_new_tab (nb, _("Co_lor")); { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new (FALSE, 0); +#endif GtkWidget *l = gtk_label_new (_("Initial color: ")); gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); @@ -771,7 +776,12 @@ CloneTiler::CloneTiler (void) : { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); +#endif gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); GtkWidget *b = gtk_check_button_new_with_label (_("Trace the drawing under the tiles")); @@ -974,7 +984,12 @@ CloneTiler::CloneTiler (void) : gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0); { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); +#endif g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb); { @@ -1018,7 +1033,12 @@ CloneTiler::CloneTiler (void) : } { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); +#endif g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb); // unitmenu @@ -1103,7 +1123,12 @@ CloneTiler::CloneTiler (void) : // Use saved pos { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); +#endif gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile")); @@ -1118,7 +1143,12 @@ CloneTiler::CloneTiler (void) : // Statusbar { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); +#endif gtk_box_pack_end (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); GtkWidget *l = gtk_label_new(""); g_object_set_data (G_OBJECT(dlg), "status", (gpointer) l); @@ -1127,7 +1157,12 @@ CloneTiler::CloneTiler (void) : // Buttons { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); +#endif gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); { @@ -1141,7 +1176,12 @@ CloneTiler::CloneTiler (void) : } { // buttons which are enabled only when there are tiled clones +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *sb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(sb), FALSE); +#else GtkWidget *sb = gtk_hbox_new(FALSE, 0); +#endif gtk_box_pack_end (GTK_BOX (hb), sb, FALSE, FALSE, 0); g_object_set_data (G_OBJECT(dlg), "buttons_on_tiles", (gpointer) sb); { @@ -2549,7 +2589,12 @@ void CloneTiler::clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data GtkWidget * CloneTiler::clonetiler_checkbox(const char *tip, const char *attr) { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); +#endif GtkWidget *b = gtk_check_button_new (); gtk_widget_set_tooltip_text (b, tip); @@ -2576,7 +2621,12 @@ void CloneTiler::clonetiler_value_changed(GtkAdjustment *adj, gpointer data) GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/) { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, 0); +#endif { Gtk::Adjustment *a; @@ -2704,7 +2754,12 @@ GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) gtk_table_set_col_spacings (GTK_TABLE (table), 8); { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new (FALSE, 0); +#endif GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-rows")); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); @@ -2717,7 +2772,12 @@ GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) } { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new (FALSE, 0); +#endif GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-columns")); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index fd529e959..b18847b58 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -335,7 +335,12 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->vbox = gtk_vbox_new (FALSE, 0); gtk_container_add( GTK_CONTAINER(dtw), GTK_WIDGET(dtw->vbox) ); +#if GTK_CHECK_VERSION(3,0,0) + dtw->statusbar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(dtw->statusbar), FALSE); +#else dtw->statusbar = gtk_hbox_new (FALSE, 0); +#endif //gtk_widget_set_usize (dtw->statusbar, -1, BOTTOM_BAR_HEIGHT); gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->statusbar, FALSE, TRUE, 0); @@ -347,7 +352,12 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_box_pack_end( GTK_BOX( dtw->vbox ), GTK_WIDGET(dtw->panels->gobj()), FALSE, TRUE, 0 ); } +#if GTK_CHECK_VERSION(3,0,0) + dtw->hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(dtw->hbox), FALSE); +#else dtw->hbox = gtk_hbox_new(FALSE, 0); +#endif gtk_box_pack_end( GTK_BOX (dtw->vbox), dtw->hbox, TRUE, TRUE, 0 ); gtk_widget_show(dtw->hbox); @@ -580,7 +590,13 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_label_set_markup (GTK_LABEL (dtw->select_status), _("Welcome to Inkscape! Use shape or freehand tools to create objects; use selector (arrow) to move or transform them.")); // space label 2 pixels from left edge gtk_container_add (GTK_CONTAINER (dtw->select_status_eventbox), dtw->select_status); +#if GTK_CHECK_VERSION(3,0,0) + gtk_box_pack_start(GTK_BOX(dtw->statusbar), + gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), + FALSE, FALSE, 2); +#else gtk_box_pack_start (GTK_BOX (dtw->statusbar), gtk_hbox_new(FALSE, 0), FALSE, FALSE, 2); +#endif gtk_box_pack_start (GTK_BOX (dtw->statusbar), dtw->select_status_eventbox, TRUE, TRUE, 0); gtk_widget_show_all (dtw->vbox); diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 894fc2cd8..ba6fca16a 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -201,7 +201,12 @@ static void sp_font_selector_init(SPFontSelector *fsel) selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(fsel->style_treeview)); g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_style_select_row), fsel); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, 4); +#endif gtk_widget_show(hb); gtk_box_pack_start(GTK_BOX(vb), hb, FALSE, FALSE, 0); diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index e67d93388..e820beac6 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -133,7 +133,12 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) g_signal_connect (G_OBJECT (sel->vectors), "vector_set", G_CALLBACK (sp_gradient_selector_vector_set), sel); /* Create box for buttons */ +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new( FALSE, 0 ); +#endif sel->nonsolid.push_back(hb); gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 ); @@ -152,7 +157,12 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) gtk_widget_show_all(hb); /* Spread selector */ +#if GTK_CHECK_VERSION(3,0,0) + hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else hb = gtk_hbox_new( FALSE, 0 ); +#endif sel->nonsolid.push_back(hb); gtk_widget_show(hb); gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 ); diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index d5e55661a..355e6506e 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -825,7 +825,12 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s g_signal_connect(G_OBJECT(combo_box), "changed", G_CALLBACK(sp_grad_edit_combo_box_changed), vb); /* Add and Remove buttons */ +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, 1); +#endif // TRANSLATORS: "Stop" means: a "phase" of a gradient GtkWidget *b = gtk_button_new_with_label(_("Add stop")); gtk_widget_show(b); @@ -842,7 +847,12 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s gtk_box_pack_start(GTK_BOX(vb),hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS); /* Offset Slider and stuff */ +#if GTK_CHECK_VERSION(3,0,0) + hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else hb = gtk_hbox_new(FALSE, 0); +#endif /* Label */ GtkWidget *l = gtk_label_new(_("Offset:")); diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index a750ffab6..13b112dc6 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -216,7 +216,12 @@ sp_paint_selector_init(SPPaintSelector *psel) psel->mode = static_cast(-1); // huh? do you mean 0xff? -- I think this means "not in the enum" /* Paint style button box */ +#if GTK_CHECK_VERSION(3,0,0) + psel->style = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(psel->style), FALSE); +#else psel->style = gtk_hbox_new(FALSE, 0); +#endif gtk_widget_show(psel->style); gtk_container_set_border_width(GTK_CONTAINER(psel->style), 4); gtk_box_pack_start(GTK_BOX(psel), psel->style, FALSE, FALSE, 0); @@ -239,7 +244,12 @@ sp_paint_selector_init(SPPaintSelector *psel) /* Fillrule */ { +#if GTK_CHECK_VERSION(3,0,0) + psel->fillrulebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(psel->fillrulebox), FALSE); +#else psel->fillrulebox = gtk_hbox_new(FALSE, 0); +#endif gtk_box_pack_end(GTK_BOX(psel->style), psel->fillrulebox, FALSE, FALSE, 0); GtkWidget *w; @@ -268,7 +278,12 @@ sp_paint_selector_init(SPPaintSelector *psel) /* Frame */ psel->label = gtk_label_new(""); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *lbbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); + gtk_box_set_homogeneous(GTK_BOX(lbbox), FALSE); +#else GtkWidget *lbbox = gtk_hbox_new(FALSE, 4); +#endif gtk_widget_show(psel->label); gtk_box_pack_start(GTK_BOX(lbbox), psel->label, false, false, 4); gtk_box_pack_start(GTK_BOX(psel), lbbox, false, false, 4); @@ -820,7 +835,12 @@ sp_pattern_menu_build (GtkWidget *m, GSList *pattern_list, SPDocument */*source* gchar const *patid = repr->attribute("id"); g_object_set_data (G_OBJECT(i), "pattern", (void *) patid); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, 4); +#endif gtk_widget_show(hb); // create label @@ -997,7 +1017,12 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel gtk_widget_show(tbl); { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, 1); +#endif GtkWidget *mnu = gtk_option_menu_new(); ink_pattern_menu(mnu); @@ -1011,7 +1036,12 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel } { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); +#else GtkWidget *hb = gtk_hbox_new(FALSE, 0); +#endif GtkWidget *l = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(l), _("Use the Node tool to adjust position, scale, and rotation of the pattern on canvas. Use Object > Pattern > Objects to Pattern to create a new pattern from selection.")); gtk_label_set_line_wrap(GTK_LABEL(l), true); diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 3185e7373..e23d4f84b 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -470,7 +470,12 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb g_object_set_data(G_OBJECT(spw), "dtw", sp_desktop_canvas(desktop)); // The vb frame holds all other widgets and is used to set sensitivity depending on selection state. +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(vb), FALSE); +#else GtkWidget *vb = gtk_hbox_new(FALSE, 0); +#endif gtk_widget_show(vb); gtk_container_add(GTK_CONTAINER(spw), vb); diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index f9cda297f..863e8b762 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -323,7 +323,12 @@ void ColorNotebook::init() row++; +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *rgbabox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(rgbabox), FALSE); +#else GtkWidget *rgbabox = gtk_hbox_new (FALSE, 0); +#endif #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) /* Create color management icons */ diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 38a581cdc..ff9718815 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -3091,7 +3091,12 @@ static void sp_stb_defaults( GtkWidget * /*widget*/, GObject *dataKludge ) // public: void sp_toolbox_add_label(GtkWidget *tbl, gchar const *title, bool wide) { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *boxl = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(boxl), FALSE); +#else GtkWidget *boxl = gtk_hbox_new(FALSE, 0); +#endif if (wide) { gtk_widget_set_size_request(boxl, MODE_LABEL_WIDTH, -1); } -- cgit v1.2.3 From 83eeba04583d6fb3b1b3299af9f539d6d63f1c6e Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 10 Apr 2012 11:33:42 +0900 Subject: Fix for 903676 : Replace GtkCList with GtkTreeView in XML Tree, 64bitLion crash fix (bzr r11205) --- src/widgets/sp-xmlview-attr-list.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/widgets/sp-xmlview-attr-list.cpp b/src/widgets/sp-xmlview-attr-list.cpp index 1c92476fa..dcc34efa3 100644 --- a/src/widgets/sp-xmlview-attr-list.cpp +++ b/src/widgets/sp-xmlview-attr-list.cpp @@ -117,14 +117,14 @@ sp_xmlview_attr_list_class_init (SPXMLViewAttrListClass * klass) parent_class = (GtkTreeViewClass*)g_type_class_peek_parent (klass); - g_signal_new ( "row-value-changed", - G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (SPXMLViewAttrListClass, row_changed), - NULL, NULL, - g_cclosure_marshal_VOID__UINT, - G_TYPE_NONE, 1, - G_TYPE_UINT); + g_signal_new ( "row-value-changed", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (SPXMLViewAttrListClass, row_changed), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); } void -- cgit v1.2.3 From 0d8dc3dc049f24b9d95a3c54e666fc89dee2321c Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 9 Apr 2012 23:21:26 -0700 Subject: Additional cleanup. (bzr r11206) --- src/interface.cpp | 38 -------------------------------------- src/io/gzipstream.cpp | 2 +- src/knotholder.cpp | 4 ++-- 3 files changed, 3 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index afef8a08d..7dbcea9e7 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -396,44 +396,6 @@ sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name ) gtk_image_menu_item_set_image((GtkImageMenuItem *) item, icon); } // end of sp_ui_menu_add_icon -/** - * Appends a UI item with specific info for Inkscape/Sodipodi. - */ -static GtkWidget * -sp_ui_menu_append_item( GtkMenu *menu, gchar const *stock, - gchar const *label, gchar const *tip, Inkscape::UI::View::View *view, GCallback callback, - gpointer data, gboolean with_mnemonic = TRUE ) -{ - GtkWidget *item; - - if (stock) { - item = gtk_image_menu_item_new_from_stock(stock, NULL); - } else if (label) { - item = (with_mnemonic) - ? gtk_image_menu_item_new_with_mnemonic(label) : - gtk_image_menu_item_new_with_label(label); - } else { - item = gtk_separator_menu_item_new(); - } - - gtk_widget_show(item); - - if (callback) { - g_signal_connect(G_OBJECT(item), "activate", callback, data); - } - - if (tip && view) { - g_object_set_data(G_OBJECT(item), "view", (gpointer) view); - g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select), (gpointer) tip ); - g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect), NULL); - } - - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - - return item; - -} // end of sp_ui_menu_append_item() - void sp_ui_dialog_title_string(Inkscape::Verb *verb, gchar *c) { diff --git a/src/io/gzipstream.cpp b/src/io/gzipstream.cpp index efa96412d..cbe29a41e 100644 --- a/src/io/gzipstream.cpp +++ b/src/io/gzipstream.cpp @@ -37,8 +37,8 @@ GzipInputStream::GzipInputStream(InputStream &sourceStream) loaded(false), totalIn(0), totalOut(0), - srcBuf(NULL), outputBuf(NULL), + srcBuf(NULL), crc(0), srcCrc(0), srcSiz(0), diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 1bb09a05b..947f7c92a 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -66,8 +66,8 @@ KnotHolder::KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFun KnotHolder::~KnotHolder() { g_object_unref(G_OBJECT(item)); - for(std::list::iterator i = entity.begin(); i != entity.end(); ++i) { - KnotHolderEntity* e = (*i); + for (std::list::iterator i = entity.begin(); i != entity.end(); ++i) + { delete (*i); (*i) = NULL; } -- cgit v1.2.3 From b15a1b0f69711ff3a82a25b3aacfffbbb94df0ff Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 10 Apr 2012 11:38:21 +0100 Subject: Adopt obsolete GtkAnchorType enum as SPAnchorType (bzr r11207) --- src/connector-context.cpp | 8 +++--- src/display/snap-indicator.cpp | 7 +++--- src/display/sodipodi-ctrl.cpp | 42 ++++++++++++++++---------------- src/display/sodipodi-ctrl.h | 4 +-- src/enums.h | 22 +++++++++++++++++ src/knot.cpp | 4 +-- src/knot.h | 8 +++--- src/measure-context.cpp | 3 ++- src/seltrans-handles.cpp | 34 +++++++++++++------------- src/seltrans-handles.h | 3 ++- src/seltrans.cpp | 8 +++--- src/ui/dialog/swatches.cpp | 4 +-- src/ui/dialog/swatches.h | 3 ++- src/ui/previewfillable.h | 3 ++- src/ui/previewholder.cpp | 24 +++++++++--------- src/ui/previewholder.h | 5 ++-- src/ui/tool/control-point.cpp | 14 +++++------ src/ui/tool/control-point.h | 11 ++++----- src/ui/tool/curve-drag-point.cpp | 2 +- src/ui/tool/node.cpp | 4 +-- src/ui/tool/selectable-control-point.cpp | 4 +-- src/ui/tool/selectable-control-point.h | 4 +-- src/ui/tool/selector.cpp | 2 +- src/ui/tool/transform-handle-set.cpp | 26 ++++++++++---------- src/ui/tool/transform-handle-set.h | 3 ++- src/ui/widget/panel.cpp | 8 +++--- src/ui/widget/panel.h | 6 ++--- src/widgets/desktop-widget.cpp | 2 +- 28 files changed, 149 insertions(+), 119 deletions(-) (limited to 'src') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index cf8d73bd2..d3ad81134 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -620,7 +620,7 @@ cc_select_handle(SPKnot* knot) { knot->setShape(SP_KNOT_SHAPE_SQUARE); knot->setSize(10); - knot->setAnchor(GTK_ANCHOR_CENTER); + knot->setAnchor(SP_ANCHOR_CENTER); knot->setFill(0x0000ffff, 0x0000ffff, 0x0000ffff); sp_knot_update_ctrl(knot); } @@ -630,7 +630,7 @@ cc_deselect_handle(SPKnot* knot) { knot->setShape(SP_KNOT_SHAPE_SQUARE); knot->setSize(8); - knot->setAnchor(GTK_ANCHOR_CENTER); + knot->setAnchor(SP_ANCHOR_CENTER); knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff); sp_knot_update_ctrl(knot); } @@ -1637,7 +1637,7 @@ static void cc_active_shape_add_knot(SPDesktop* desktop, SPItem* item, Connectio knot->setShape(SP_KNOT_SHAPE_SQUARE); knot->setSize(8); - knot->setAnchor(GTK_ANCHOR_CENTER); + knot->setAnchor(SP_ANCHOR_CENTER); knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff); sp_knot_update_ctrl(knot); @@ -1821,7 +1821,7 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item) knot->setShape(SP_KNOT_SHAPE_SQUARE); knot->setSize(7); - knot->setAnchor(GTK_ANCHOR_CENTER); + knot->setAnchor(SP_ANCHOR_CENTER); knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff); knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff); sp_knot_update_ctrl(knot); diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index d5b8ce07f..1dd3022c7 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -23,6 +23,7 @@ #include "preferences.h" #include #include "tools-switch.h" +#include "enums.h" namespace Inkscape { namespace Display { @@ -245,7 +246,7 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap SPCanvasItem * canvasitem = NULL; canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (_desktop), SP_TYPE_CTRL, - "anchor", GTK_ANCHOR_CENTER, + "anchor", SP_ANCHOR_CENTER, "size", 10.0, "stroked", TRUE, "stroke_color", pre_snap ? 0x7f7f7fff : 0xff0000ff, @@ -345,7 +346,7 @@ SnapIndicator::set_new_snapsource(Inkscape::SnapCandidatePoint const &p) if (value) { SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (_desktop), SP_TYPE_CTRL, - "anchor", GTK_ANCHOR_CENTER, + "anchor", SP_ANCHOR_CENTER, "size", 6.0, "stroked", TRUE, "stroke_color", 0xff0000ff, @@ -364,7 +365,7 @@ SnapIndicator::set_new_debugging_point(Geom::Point const &p) g_assert(_desktop != NULL); SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (_desktop), SP_TYPE_CTRL, - "anchor", GTK_ANCHOR_CENTER, + "anchor", SP_ANCHOR_CENTER, "size", 10.0, "fill_color", 0x00ff00ff, "stroked", FALSE, diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index a82aa8622..c5a1b10a2 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -74,7 +74,7 @@ sp_ctrl_class_init (SPCtrlClass *klass) gtk_object_add_arg_type ("SPCtrl::shape", G_TYPE_INT, G_PARAM_READWRITE, ARG_SHAPE); gtk_object_add_arg_type ("SPCtrl::mode", G_TYPE_INT, G_PARAM_READWRITE, ARG_MODE); - gtk_object_add_arg_type ("SPCtrl::anchor", GTK_TYPE_ANCHOR_TYPE, G_PARAM_READWRITE, ARG_ANCHOR); + gtk_object_add_arg_type ("SPCtrl::anchor", G_TYPE_INT, G_PARAM_READWRITE, ARG_ANCHOR); gtk_object_add_arg_type ("SPCtrl::size", G_TYPE_DOUBLE, G_PARAM_READWRITE, ARG_SIZE); gtk_object_add_arg_type ("SPCtrl::pixbuf", G_TYPE_POINTER, G_PARAM_READWRITE, ARG_PIXBUF); gtk_object_add_arg_type ("SPCtrl::filled", G_TYPE_BOOLEAN, G_PARAM_READWRITE, ARG_FILLED); @@ -95,7 +95,7 @@ sp_ctrl_init (SPCtrl *ctrl) { ctrl->shape = SP_CTRL_SHAPE_SQUARE; ctrl->mode = SP_CTRL_MODE_COLOR; - ctrl->anchor = GTK_ANCHOR_CENTER; + ctrl->anchor = SP_ANCHOR_CENTER; ctrl->span = 3; ctrl->defined = TRUE; ctrl->shown = FALSE; @@ -161,7 +161,7 @@ sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) break; case ARG_ANCHOR: - ctrl->anchor = (GtkAnchorType)(GTK_VALUE_INT (*arg)); + ctrl->anchor = (SPAnchorType)(GTK_VALUE_INT (*arg)); ctrl->build = FALSE; sp_canvas_item_request_update (item); break; @@ -240,39 +240,39 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla y = (gint) ((affine[5] > 0) ? (affine[5] + 0.5) : (affine[5] - 0.5)) - ctrl->span; switch (ctrl->anchor) { - case GTK_ANCHOR_N: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_S: + case SP_ANCHOR_N: + case SP_ANCHOR_CENTER: + case SP_ANCHOR_S: break; - case GTK_ANCHOR_NW: - case GTK_ANCHOR_W: - case GTK_ANCHOR_SW: + case SP_ANCHOR_NW: + case SP_ANCHOR_W: + case SP_ANCHOR_SW: x += ctrl->span; break; - case GTK_ANCHOR_NE: - case GTK_ANCHOR_E: - case GTK_ANCHOR_SE: + case SP_ANCHOR_NE: + case SP_ANCHOR_E: + case SP_ANCHOR_SE: x -= (ctrl->span + 1); break; } switch (ctrl->anchor) { - case GTK_ANCHOR_W: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_E: + case SP_ANCHOR_W: + case SP_ANCHOR_CENTER: + case SP_ANCHOR_E: break; - case GTK_ANCHOR_NW: - case GTK_ANCHOR_N: - case GTK_ANCHOR_NE: + case SP_ANCHOR_NW: + case SP_ANCHOR_N: + case SP_ANCHOR_NE: y += ctrl->span; break; - case GTK_ANCHOR_SW: - case GTK_ANCHOR_S: - case GTK_ANCHOR_SE: + case SP_ANCHOR_SW: + case SP_ANCHOR_S: + case SP_ANCHOR_SE: y -= (ctrl->span + 1); break; } diff --git a/src/display/sodipodi-ctrl.h b/src/display/sodipodi-ctrl.h index 2617e7db2..cd0fcadf1 100644 --- a/src/display/sodipodi-ctrl.h +++ b/src/display/sodipodi-ctrl.h @@ -7,9 +7,9 @@ * */ -#include #include #include "sp-canvas-item.h" +#include "enums.h" #define SP_TYPE_CTRL (sp_ctrl_get_type ()) @@ -36,7 +36,7 @@ typedef enum { struct SPCtrl : public SPCanvasItem { SPCtrlShapeType shape; SPCtrlModeType mode; - GtkAnchorType anchor; + SPAnchorType anchor; gint span; guint defined : 1; guint shown : 1; diff --git a/src/enums.h b/src/enums.h index 8b9dcc71f..2a30fc4a8 100644 --- a/src/enums.h +++ b/src/enums.h @@ -12,6 +12,28 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +/* Anchor types (imported from Gtk) */ +typedef enum +{ + SP_ANCHOR_CENTER, + SP_ANCHOR_NORTH, + SP_ANCHOR_NORTH_WEST, + SP_ANCHOR_NORTH_EAST, + SP_ANCHOR_SOUTH, + SP_ANCHOR_SOUTH_WEST, + SP_ANCHOR_SOUTH_EAST, + SP_ANCHOR_WEST, + SP_ANCHOR_EAST, + SP_ANCHOR_N = SP_ANCHOR_NORTH, + SP_ANCHOR_NW = SP_ANCHOR_NORTH_WEST, + SP_ANCHOR_NE = SP_ANCHOR_NORTH_EAST, + SP_ANCHOR_S = SP_ANCHOR_SOUTH, + SP_ANCHOR_SW = SP_ANCHOR_SOUTH_WEST, + SP_ANCHOR_SE = SP_ANCHOR_SOUTH_EAST, + SP_ANCHOR_W = SP_ANCHOR_WEST, + SP_ANCHOR_E = SP_ANCHOR_EAST +} SPAnchorType; + /* preserveAspectRatio */ enum { diff --git a/src/knot.cpp b/src/knot.cpp index 4da9f01ee..770618470 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -193,7 +193,7 @@ static void sp_knot_init(SPKnot *knot) knot->size = 8; knot->pos = Geom::Point(0, 0); knot->grabbed_rel_pos = Geom::Point(0, 0); - knot->anchor = GTK_ANCHOR_CENTER; + knot->anchor = SP_ANCHOR_CENTER; knot->shape = SP_KNOT_SHAPE_SQUARE; knot->mode = SP_KNOT_MODE_XOR; knot->tip = NULL; @@ -480,7 +480,7 @@ SPKnot *sp_knot_new(SPDesktop *desktop, const gchar *tip) knot->item = sp_canvas_item_new(sp_desktop_controls (desktop), SP_TYPE_CTRL, - "anchor", GTK_ANCHOR_CENTER, + "anchor", SP_ANCHOR_CENTER, "size", 8.0, "filled", TRUE, "fill_color", 0xffffff00, diff --git a/src/knot.h b/src/knot.h index 02f21c917..c0d2f68e4 100644 --- a/src/knot.h +++ b/src/knot.h @@ -15,11 +15,12 @@ */ #include -#include #include <2geom/point.h> #include "knot-enums.h" #include #include +#include "enums.h" +#include class SPDesktop; class SPKnot; @@ -32,6 +33,7 @@ struct SPCanvasItem; #define SP_IS_KNOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_KNOT)) #define SP_IS_KNOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_KNOT)) + /** * Desktop-bound visual control object. * @@ -47,7 +49,7 @@ struct SPKnot : GObject { Geom::Point pos; /**< Our desktop coordinates. */ Geom::Point grabbed_rel_pos; /**< Grabbed relative position. */ Geom::Point drag_origin; /**< Origin of drag. */ - GtkAnchorType anchor; /**< Anchor. */ + SPAnchorType anchor; /**< Anchor. */ SPKnotShapeType shape; /**< Shape type. */ SPKnotModeType mode; @@ -80,7 +82,7 @@ struct SPKnot : GObject { //TODO: all the members above should eventualle become private, accessible via setters/getters inline void setSize (guint i) {size = i;} inline void setShape (guint i) {shape = (SPKnotShapeType) i;} - inline void setAnchor (guint i) {anchor = (GtkAnchorType) i;} + inline void setAnchor (guint i) {anchor = (SPAnchorType) i;} inline void setMode (guint i) {mode = (SPKnotModeType) i;} inline void setPixbuf (gpointer p) {pixbuf = p;} inline void setFill (guint32 normal, guint32 mouseover, guint32 dragging) { diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 9db2b8de4..3237bb3fb 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -40,6 +40,7 @@ #include <2geom/angle.h> #include "snap.h" #include "sp-namedview.h" +#include "enums.h" static void sp_measure_context_class_init(SPMeasureContextClass *klass); @@ -351,7 +352,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv SPCanvasItem * canvasitem = NULL; canvasitem = sp_canvas_item_new(sp_desktop_tempgroup(desktop), SP_TYPE_CTRL, - "anchor", GTK_ANCHOR_CENTER, + "anchor", SP_ANCHOR_CENTER, "size", 8.0, "stroked", TRUE, "stroke_color", 0xff0000ff, diff --git a/src/seltrans-handles.cpp b/src/seltrans-handles.cpp index 10b87aaff..fc03789d6 100644 --- a/src/seltrans-handles.cpp +++ b/src/seltrans-handles.cpp @@ -3,29 +3,29 @@ SPSelTransHandle const handles_scale[] = { //anchor cursor control action request x y - {GTK_ANCHOR_SE, GDK_TOP_LEFT_CORNER, 0, sp_sel_trans_scale, sp_sel_trans_scale_request, 0, 1}, - {GTK_ANCHOR_S, GDK_TOP_SIDE, 3, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0.5, 1}, - {GTK_ANCHOR_SW, GDK_TOP_RIGHT_CORNER, 1, sp_sel_trans_scale, sp_sel_trans_scale_request, 1, 1}, - {GTK_ANCHOR_W, GDK_RIGHT_SIDE, 2, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 1, 0.5}, - {GTK_ANCHOR_NW, GDK_BOTTOM_RIGHT_CORNER, 0, sp_sel_trans_scale, sp_sel_trans_scale_request, 1, 0}, - {GTK_ANCHOR_N, GDK_BOTTOM_SIDE, 3, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0.5, 0}, - {GTK_ANCHOR_NE, GDK_BOTTOM_LEFT_CORNER, 1, sp_sel_trans_scale, sp_sel_trans_scale_request, 0, 0}, - {GTK_ANCHOR_E, GDK_LEFT_SIDE, 2, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0, 0.5} + {SP_ANCHOR_SE, GDK_TOP_LEFT_CORNER, 0, sp_sel_trans_scale, sp_sel_trans_scale_request, 0, 1}, + {SP_ANCHOR_S, GDK_TOP_SIDE, 3, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0.5, 1}, + {SP_ANCHOR_SW, GDK_TOP_RIGHT_CORNER, 1, sp_sel_trans_scale, sp_sel_trans_scale_request, 1, 1}, + {SP_ANCHOR_W, GDK_RIGHT_SIDE, 2, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 1, 0.5}, + {SP_ANCHOR_NW, GDK_BOTTOM_RIGHT_CORNER, 0, sp_sel_trans_scale, sp_sel_trans_scale_request, 1, 0}, + {SP_ANCHOR_N, GDK_BOTTOM_SIDE, 3, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0.5, 0}, + {SP_ANCHOR_NE, GDK_BOTTOM_LEFT_CORNER, 1, sp_sel_trans_scale, sp_sel_trans_scale_request, 0, 0}, + {SP_ANCHOR_E, GDK_LEFT_SIDE, 2, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0, 0.5} }; SPSelTransHandle const handles_rotate[] = { - {GTK_ANCHOR_SE, GDK_EXCHANGE, 4, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 0, 1}, - {GTK_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 5, sp_sel_trans_skew, sp_sel_trans_skew_request, 0.5, 1}, - {GTK_ANCHOR_SW, GDK_EXCHANGE, 6, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 1, 1}, - {GTK_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 7, sp_sel_trans_skew, sp_sel_trans_skew_request, 1, 0.5}, - {GTK_ANCHOR_NW, GDK_EXCHANGE, 8, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 1, 0}, - {GTK_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 9, sp_sel_trans_skew, sp_sel_trans_skew_request, 0.5, 0}, - {GTK_ANCHOR_NE, GDK_EXCHANGE, 10, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 0, 0}, - {GTK_ANCHOR_E, GDK_SB_V_DOUBLE_ARROW, 11, sp_sel_trans_skew, sp_sel_trans_skew_request, 0, 0.5} + {SP_ANCHOR_SE, GDK_EXCHANGE, 4, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 0, 1}, + {SP_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 5, sp_sel_trans_skew, sp_sel_trans_skew_request, 0.5, 1}, + {SP_ANCHOR_SW, GDK_EXCHANGE, 6, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 1, 1}, + {SP_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 7, sp_sel_trans_skew, sp_sel_trans_skew_request, 1, 0.5}, + {SP_ANCHOR_NW, GDK_EXCHANGE, 8, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 1, 0}, + {SP_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 9, sp_sel_trans_skew, sp_sel_trans_skew_request, 0.5, 0}, + {SP_ANCHOR_NE, GDK_EXCHANGE, 10, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 0, 0}, + {SP_ANCHOR_E, GDK_SB_V_DOUBLE_ARROW, 11, sp_sel_trans_skew, sp_sel_trans_skew_request, 0, 0.5} }; SPSelTransHandle const handle_center = - {GTK_ANCHOR_CENTER, GDK_CROSSHAIR, 12, sp_sel_trans_center, sp_sel_trans_center_request, 0.5, 0.5}; + {SP_ANCHOR_CENTER, GDK_CROSSHAIR, 12, sp_sel_trans_center, sp_sel_trans_center_request, 0.5, 0.5}; /* diff --git a/src/seltrans-handles.h b/src/seltrans-handles.h index 53dbd3cda..f58524c1a 100644 --- a/src/seltrans-handles.h +++ b/src/seltrans-handles.h @@ -15,6 +15,7 @@ #include "display/sodipodi-ctrl.h" #include <2geom/forward.h> #include +#include "enums.h" namespace Inkscape { @@ -43,7 +44,7 @@ void sp_sel_trans_rotate(Inkscape::SelTrans *seltrans, SPSelTransHandle const &h void sp_sel_trans_center(Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &p, guint state); struct SPSelTransHandle { - GtkAnchorType anchor; + SPAnchorType anchor; GdkCursorType cursor; guint control; void (* action) (Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &p, guint state); diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 4ddac3c20..246dd82e0 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -129,7 +129,7 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : _norm = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRL, - "anchor", GTK_ANCHOR_CENTER, + "anchor", SP_ANCHOR_CENTER, "mode", SP_CTRL_MODE_COLOR, "shape", SP_CTRL_SHAPE_BITMAP, "size", 13.0, @@ -142,7 +142,7 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : _grip = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRL, - "anchor", GTK_ANCHOR_CENTER, + "anchor", SP_ANCHOR_CENTER, "mode", SP_CTRL_MODE_XOR, "shape", SP_CTRL_SHAPE_CROSS, "size", 7.0, @@ -754,7 +754,7 @@ static void sp_sel_trans_handle_click(SPKnot *knot, guint state, gpointer data) void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHandle const &handle) { switch (handle.anchor) { - case GTK_ANCHOR_CENTER: + case SP_ANCHOR_CENTER: if (state & GDK_SHIFT_MASK) { // Unset the center position for all selected items for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { @@ -776,7 +776,7 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa void Inkscape::SelTrans::handleGrab(SPKnot *knot, guint /*state*/, SPSelTransHandle const &handle) { switch (handle.anchor) { - case GTK_ANCHOR_CENTER: + case SP_ANCHOR_CENTER: g_object_set(G_OBJECT(_grip), "shape", SP_CTRL_SHAPE_BITMAP, "size", 13.0, diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index a1768363c..092887541 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -666,14 +666,14 @@ SwatchesPanel::~SwatchesPanel() } } -void SwatchesPanel::setOrientation( Gtk::AnchorType how ) +void SwatchesPanel::setOrientation(SPAnchorType how) { // Must call the parent class or bad things might happen Inkscape::UI::Widget::Panel::setOrientation( how ); if ( _holder ) { - _holder->setOrientation( Gtk::ANCHOR_SOUTH ); + _holder->setOrientation(SP_ANCHOR_SOUTH); } } diff --git a/src/ui/dialog/swatches.h b/src/ui/dialog/swatches.h index 0ff795ac3..ca4c1687d 100644 --- a/src/ui/dialog/swatches.h +++ b/src/ui/dialog/swatches.h @@ -11,6 +11,7 @@ #define SEEN_DIALOGS_SWATCHES_H #include "ui/widget/panel.h" +#include "enums.h" namespace Inkscape { namespace UI { @@ -34,7 +35,7 @@ public: static SwatchesPanel& getInstance(); - virtual void setOrientation( Gtk::AnchorType how ); + virtual void setOrientation(SPAnchorType how); virtual void setDesktop( SPDesktop* desktop ); virtual SPDesktop* getDesktop() {return _currentDesktop;} diff --git a/src/ui/previewfillable.h b/src/ui/previewfillable.h index 07fbc4fc5..d5f609a0b 100644 --- a/src/ui/previewfillable.h +++ b/src/ui/previewfillable.h @@ -15,6 +15,7 @@ #include "previewable.h" #include "../widgets/eek-preview.h" +#include "enums.h" namespace Inkscape { namespace UI { @@ -28,7 +29,7 @@ public: virtual void freezeUpdates() = 0; virtual void thawUpdates() = 0; virtual void setStyle( ::PreviewSize size, ViewType type, guint ratio) = 0; - virtual void setOrientation( Gtk::AnchorType how ) = 0; + virtual void setOrientation(SPAnchorType how) = 0; virtual ::PreviewSize getPreviewSize() const = 0; virtual ViewType getPreviewType() const = 0; virtual guint getPreviewRatio() const = 0; diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index 9e69778b7..d8f1a21a9 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -34,7 +34,7 @@ PreviewHolder::PreviewHolder() : _insides(0), _prefCols(0), _updatesFrozen(false), - _anchor(Gtk::ANCHOR_CENTER), + _anchor(SP_ANCHOR_CENTER), _baseSize(PREVIEW_SIZE_SMALL), _ratio(100), _view(VIEW_TYPE_LIST), @@ -63,7 +63,7 @@ void PreviewHolder::clear() items.clear(); _prefCols = 0; // Kludge to restore scrollbars - if ( !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == Gtk::ANCHOR_NORTH || _anchor == Gtk::ANCHOR_SOUTH) ) { + if ( !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) { dynamic_cast(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER ); } rebuildUI(); @@ -136,29 +136,29 @@ void PreviewHolder::setStyle( ::PreviewSize size, ViewType view, guint ratio ) _view = view; _ratio = ratio; // Kludge to restore scrollbars - if ( !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == Gtk::ANCHOR_NORTH || _anchor == Gtk::ANCHOR_SOUTH) ) { + if ( !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) { dynamic_cast(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER ); } rebuildUI(); } } -void PreviewHolder::setOrientation( Gtk::AnchorType how ) +void PreviewHolder::setOrientation(SPAnchorType how) { if ( _anchor != how ) { _anchor = how; switch ( _anchor ) { - case Gtk::ANCHOR_NORTH: - case Gtk::ANCHOR_SOUTH: + case SP_ANCHOR_NORTH: + case SP_ANCHOR_SOUTH: { dynamic_cast(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, _wrap ? Gtk::POLICY_AUTOMATIC : Gtk::POLICY_NEVER ); } break; - case Gtk::ANCHOR_EAST: - case Gtk::ANCHOR_WEST: + case SP_ANCHOR_EAST: + case SP_ANCHOR_WEST: { dynamic_cast(_scroller)->set_policy( Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC ); } @@ -179,8 +179,8 @@ void PreviewHolder::setWrap( bool b ) _wrap = b; switch ( _anchor ) { - case Gtk::ANCHOR_NORTH: - case Gtk::ANCHOR_SOUTH: + case SP_ANCHOR_NORTH: + case SP_ANCHOR_SOUTH: { dynamic_cast(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, _wrap ? Gtk::POLICY_AUTOMATIC : Gtk::POLICY_NEVER ); } @@ -206,7 +206,7 @@ void PreviewHolder::on_size_allocate( Gtk::Allocation& allocation ) // g_message(" anchor:%d", _anchor); Gtk::VBox::on_size_allocate( allocation ); - if ( _insides && !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == Gtk::ANCHOR_NORTH || _anchor == Gtk::ANCHOR_SOUTH) ) { + if ( _insides && !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) { Gtk::Requisition req = _insides->size_request(); gint delta = allocation.get_width() - req.width; @@ -232,7 +232,7 @@ void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int& width = itemCount; height = 1; - if ( _anchor == Gtk::ANCHOR_SOUTH || _anchor == Gtk::ANCHOR_NORTH ) { + if ( _anchor == SP_ANCHOR_SOUTH || _anchor == SP_ANCHOR_NORTH ) { Gtk::Requisition req = _scroller->size_request(); int currW = _scroller->get_width(); if ( currW > req.width ) { diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h index c396cef19..5a0dfc267 100644 --- a/src/ui/previewholder.h +++ b/src/ui/previewholder.h @@ -18,6 +18,7 @@ #include #include "previewfillable.h" #include "../widgets/eek-preview.h" +#include "enums.h" namespace Inkscape { namespace UI { @@ -33,7 +34,7 @@ public: virtual void freezeUpdates(); virtual void thawUpdates(); virtual void setStyle( ::PreviewSize size, ViewType view, guint ratio ); - virtual void setOrientation( Gtk::AnchorType how ); + virtual void setOrientation(SPAnchorType how); virtual int getColumnPref() const { return _prefCols; } virtual void setColumnPref( int cols ); virtual ::PreviewSize getPreviewSize() const { return _baseSize; } @@ -56,7 +57,7 @@ private: Gtk::Table *_insides; int _prefCols; bool _updatesFrozen; - Gtk::AnchorType _anchor; + SPAnchorType _anchor; ::PreviewSize _baseSize; guint _ratio; ViewType _view; diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp index 8525e92f4..a5509655f 100644 --- a/src/ui/tool/control-point.cpp +++ b/src/ui/tool/control-point.cpp @@ -132,7 +132,7 @@ ControlPoint::ColorSet invisible_cset = { * @param group The canvas group the point's canvas item should be created in */ ControlPoint::ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, - Gtk::AnchorType anchor, SPCtrlShapeType shape, + SPAnchorType anchor, SPCtrlShapeType shape, unsigned int size, ColorSet *cset, SPCanvasGroup *group) : _desktop (d) , _canvas_item (NULL) @@ -142,7 +142,7 @@ ControlPoint::ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, { _canvas_item = sp_canvas_item_new( group ? group : sp_desktop_controls (_desktop), SP_TYPE_CTRL, - "anchor", (GtkAnchorType) anchor, "size", (gdouble) size, "shape", shape, + "anchor", (SPAnchorType) anchor, "size", (gdouble) size, "shape", shape, "filled", TRUE, "fill_color", _cset->normal.fill, "stroked", TRUE, "stroke_color", _cset->normal.stroke, "mode", SP_CTRL_MODE_XOR, NULL); @@ -160,7 +160,7 @@ ControlPoint::ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, * @param group The canvas group the point's canvas item should be created in */ ControlPoint::ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, - Gtk::AnchorType anchor, Glib::RefPtr pixbuf, + SPAnchorType anchor, Glib::RefPtr pixbuf, ColorSet *cset, SPCanvasGroup *group) : _desktop (d) , _canvas_item (NULL) @@ -169,7 +169,7 @@ ControlPoint::ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, { _canvas_item = sp_canvas_item_new( group ? group : sp_desktop_controls(_desktop), SP_TYPE_CTRL, - "anchor", (GtkAnchorType) anchor, "size", (gdouble) pixbuf->get_width(), + "anchor", (SPAnchorType) anchor, "size", (gdouble) pixbuf->get_width(), "shape", SP_CTRL_SHAPE_BITMAP, "pixbuf", pixbuf->gobj(), "filled", TRUE, "fill_color", _cset->normal.fill, "stroked", TRUE, "stroke_color", _cset->normal.stroke, @@ -262,9 +262,9 @@ SPCtrlShapeType ControlPoint::_shape() const return ret; } -GtkAnchorType ControlPoint::_anchor() const +SPAnchorType ControlPoint::_anchor() const { - GtkAnchorType ret; + SPAnchorType ret; g_object_get(_canvas_item, "anchor", &ret, NULL); return ret; } @@ -288,7 +288,7 @@ void ControlPoint::_setShape(SPCtrlShapeType shape) g_object_set(_canvas_item, "shape", shape, NULL); } -void ControlPoint::_setAnchor(GtkAnchorType anchor) +void ControlPoint::_setAnchor(SPAnchorType anchor) { g_object_set(_canvas_item, "anchor", anchor, NULL); } diff --git a/src/ui/tool/control-point.h b/src/ui/tool/control-point.h index f37ff1451..8d1b778a7 100644 --- a/src/ui/tool/control-point.h +++ b/src/ui/tool/control-point.h @@ -19,8 +19,7 @@ #include <2geom/point.h> #include "util/accumulators.h" #include "display/sodipodi-ctrl.h" - -#include +#include "enums.h" class SPDesktop; class SPEventContext; @@ -97,9 +96,9 @@ public: virtual bool _eventHandler(SPEventContext *event_context, GdkEvent *event); protected: - ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, Gtk::AnchorType anchor, + ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor, SPCtrlShapeType shape, unsigned int size, ColorSet *cset = 0, SPCanvasGroup *group = 0); - ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, Gtk::AnchorType anchor, + ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor, Glib::RefPtr pixbuf, ColorSet *cset = 0, SPCanvasGroup *group = 0); /// @name Handle control point events in subclasses @@ -142,12 +141,12 @@ protected: unsigned int _size() const; SPCtrlShapeType _shape() const; - GtkAnchorType _anchor() const; + SPAnchorType _anchor() const; Glib::RefPtr _pixbuf(); void _setSize(unsigned int size); void _setShape(SPCtrlShapeType shape); - void _setAnchor(GtkAnchorType anchor); + void _setAnchor(SPAnchorType anchor); void _setPixbuf(Glib::RefPtr); /// @} diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index e932c022d..8754681df 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -38,7 +38,7 @@ bool CurveDragPoint::_segment_was_degenerate = false; CurveDragPoint::CurveDragPoint(PathManipulator &pm) : ControlPoint(pm._multi_path_manipulator._path_data.node_data.desktop, Geom::Point(), - Gtk::ANCHOR_CENTER, SP_CTRL_SHAPE_CIRCLE, 1.0, &invisible_cset, + SP_ANCHOR_CENTER, SP_CTRL_SHAPE_CIRCLE, 1.0, &invisible_cset, pm._multi_path_manipulator._path_data.dragpoint_group) , _pm(pm) { diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 8e39ec05a..ff644b4e3 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -81,7 +81,7 @@ double Handle::_saved_length = 0.0; bool Handle::_drag_out = false; Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node *parent) - : ControlPoint(data.desktop, initial_pos, Gtk::ANCHOR_CENTER, SP_CTRL_SHAPE_CIRCLE, 7.0, + : ControlPoint(data.desktop, initial_pos, SP_ANCHOR_CENTER, SP_CTRL_SHAPE_CIRCLE, 7.0, &handle_colors, data.handle_group) , _parent(parent) , _degenerate(true) @@ -473,7 +473,7 @@ Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) * The method move() keeps node type invariants during translations. */ Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) - : SelectableControlPoint(data.desktop, initial_pos, Gtk::ANCHOR_CENTER, + : SelectableControlPoint(data.desktop, initial_pos, SP_ANCHOR_CENTER, SP_CTRL_SHAPE_DIAMOND, 9.0, *data.selection, &node_colors, data.node_group) , _front(data, initial_pos, this) , _back(data, initial_pos, this) diff --git a/src/ui/tool/selectable-control-point.cpp b/src/ui/tool/selectable-control-point.cpp index c92dcaaae..cec2e7b07 100644 --- a/src/ui/tool/selectable-control-point.cpp +++ b/src/ui/tool/selectable-control-point.cpp @@ -27,7 +27,7 @@ static SelectableControlPoint::ColorSet default_scp_color_set = { }; SelectableControlPoint::SelectableControlPoint(SPDesktop *d, Geom::Point const &initial_pos, - Gtk::AnchorType anchor, SPCtrlShapeType shape, unsigned int size, + SPAnchorType anchor, SPCtrlShapeType shape, unsigned int size, ControlPointSelection &sel, ColorSet *cset, SPCanvasGroup *group) : ControlPoint (d, initial_pos, anchor, shape, size, cset ? reinterpret_cast(cset) @@ -37,7 +37,7 @@ SelectableControlPoint::SelectableControlPoint(SPDesktop *d, Geom::Point const & _selection.allPoints().insert(this); } SelectableControlPoint::SelectableControlPoint(SPDesktop *d, Geom::Point const &initial_pos, - Gtk::AnchorType anchor, Glib::RefPtr pixbuf, + SPAnchorType anchor, Glib::RefPtr pixbuf, ControlPointSelection &sel, ColorSet *cset, SPCanvasGroup *group) : ControlPoint (d, initial_pos, anchor, pixbuf, cset ? reinterpret_cast(cset) diff --git a/src/ui/tool/selectable-control-point.h b/src/ui/tool/selectable-control-point.h index 9467aef74..8ecb39a79 100644 --- a/src/ui/tool/selectable-control-point.h +++ b/src/ui/tool/selectable-control-point.h @@ -35,11 +35,11 @@ public: } protected: SelectableControlPoint(SPDesktop *d, Geom::Point const &initial_pos, - Gtk::AnchorType anchor, SPCtrlShapeType shape, + SPAnchorType anchor, SPCtrlShapeType shape, unsigned int size, ControlPointSelection &sel, ColorSet *cset = 0, SPCanvasGroup *group = 0); SelectableControlPoint(SPDesktop *d, Geom::Point const &initial_pos, - Gtk::AnchorType anchor, Glib::RefPtr pixbuf, + SPAnchorType anchor, Glib::RefPtr pixbuf, ControlPointSelection &sel, ColorSet *cset = 0, SPCanvasGroup *group = 0); virtual void _setState(State state); diff --git a/src/ui/tool/selector.cpp b/src/ui/tool/selector.cpp index 25d22ecdc..86ad05515 100644 --- a/src/ui/tool/selector.cpp +++ b/src/ui/tool/selector.cpp @@ -29,7 +29,7 @@ namespace UI { class SelectorPoint : public ControlPoint { public: SelectorPoint(SPDesktop *d, SPCanvasGroup *group, Selector *s) - : ControlPoint(d, Geom::Point(0,0), Gtk::ANCHOR_CENTER, SP_CTRL_SHAPE_SQUARE, + : ControlPoint(d, Geom::Point(0,0), SP_ANCHOR_CENTER, SP_CTRL_SHAPE_SQUARE, 1, &invisible_cset, group) , _selector(s) , _cancel(false) diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 2cf6fe55a..b4a27170a 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -38,20 +38,20 @@ namespace Inkscape { namespace UI { namespace { -Gtk::AnchorType corner_to_anchor(unsigned c) { +SPAnchorType corner_to_anchor(unsigned c) { switch (c % 4) { - case 0: return Gtk::ANCHOR_NE; - case 1: return Gtk::ANCHOR_NW; - case 2: return Gtk::ANCHOR_SW; - default: return Gtk::ANCHOR_SE; + case 0: return SP_ANCHOR_NE; + case 1: return SP_ANCHOR_NW; + case 2: return SP_ANCHOR_SW; + default: return SP_ANCHOR_SE; } } -Gtk::AnchorType side_to_anchor(unsigned s) { +SPAnchorType side_to_anchor(unsigned s) { switch (s % 4) { - case 0: return Gtk::ANCHOR_N; - case 1: return Gtk::ANCHOR_W; - case 2: return Gtk::ANCHOR_S; - default: return Gtk::ANCHOR_E; + case 0: return SP_ANCHOR_N; + case 1: return SP_ANCHOR_W; + case 2: return SP_ANCHOR_S; + default: return SP_ANCHOR_E; } } @@ -82,7 +82,7 @@ ControlPoint::ColorSet center_cset = { } // anonymous namespace /** Base class for node transform handles to simplify implementation */ -TransformHandle::TransformHandle(TransformHandleSet &th, Gtk::AnchorType anchor, Glib::RefPtr pb) +TransformHandle::TransformHandle(TransformHandleSet &th, SPAnchorType anchor, Glib::RefPtr pb) : ControlPoint(th._desktop, Geom::Point(), anchor, pb, &thandle_cset, th._transform_handle_group) , _th(th) @@ -180,7 +180,7 @@ void TransformHandle::ungrabbed(GdkEventButton *) class ScaleHandle : public TransformHandle { public: - ScaleHandle(TransformHandleSet &th, Gtk::AnchorType anchor, Glib::RefPtr pb) + ScaleHandle(TransformHandleSet &th, SPAnchorType anchor, Glib::RefPtr pb) : TransformHandle(th, anchor, pb) {} protected: @@ -603,7 +603,7 @@ double SkewHandle::_last_angle = 0; class RotationCenter : public ControlPoint { public: RotationCenter(TransformHandleSet &th) - : ControlPoint(th._desktop, Geom::Point(), Gtk::ANCHOR_CENTER, _get_pixbuf(), + : ControlPoint(th._desktop, Geom::Point(), SP_ANCHOR_CENTER, _get_pixbuf(), ¢er_cset, th._transform_handle_group) , _th(th) { diff --git a/src/ui/tool/transform-handle-set.h b/src/ui/tool/transform-handle-set.h index f5f208e6f..cd1a61da2 100644 --- a/src/ui/tool/transform-handle-set.h +++ b/src/ui/tool/transform-handle-set.h @@ -16,6 +16,7 @@ #include <2geom/forward.h> #include "ui/tool/commit-events.h" #include "ui/tool/manipulator.h" +#include "enums.h" class SPDesktop; class CtrlRect; @@ -81,7 +82,7 @@ private: /** Base class for node transform handles to simplify implementation */ class TransformHandle : public ControlPoint { public: - TransformHandle(TransformHandleSet &th, Gtk::AnchorType anchor, Glib::RefPtr pb); + TransformHandle(TransformHandleSet &th, SPAnchorType anchor, Glib::RefPtr pb); void getNextClosestPoint(bool reverse); protected: diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 0989c7d0d..45c4e5f07 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -88,7 +88,7 @@ void Panel::_popper(GdkEventButton* event) void Panel::_init() { Glib::ustring tmp("<"); - _anchor = Gtk::ANCHOR_CENTER; + _anchor = SP_ANCHOR_CENTER; guint panel_size = 0, panel_mode = 0, panel_ratio = 100; bool panel_wrap = 0; @@ -269,13 +269,13 @@ void Panel::setLabel(Glib::ustring const &label) _tab_title.set_label(_label); } -void Panel::setOrientation(Gtk::AnchorType how) +void Panel::setOrientation(SPAnchorType how) { if (_anchor != how) { _anchor = how; switch (_anchor) { - case Gtk::ANCHOR_NORTH: - case Gtk::ANCHOR_SOUTH: + case SP_ANCHOR_NORTH: + case SP_ANCHOR_SOUTH: { if (_menu_desired) { _menu_popper.reference(); diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index c1942ef05..7b471c2ce 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -18,7 +18,7 @@ #include #include #include - +#include "enums.h" #include class SPDesktop; @@ -80,7 +80,7 @@ public: int const &getVerb() const; Glib::ustring const &getApplyLabel() const; - virtual void setOrientation(Gtk::AnchorType how); + virtual void setOrientation(SPAnchorType how); virtual void present(); //< request to be present @@ -126,7 +126,7 @@ protected: */ Glib::ustring const _prefs_path; bool _menu_desired; - Gtk::AnchorType _anchor; + SPAnchorType _anchor; /* Signals */ sigc::signal _signal_response; diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index b18847b58..c5c278e2d 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -348,7 +348,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) using Inkscape::UI::Dialogs::SwatchesPanel; dtw->panels = new SwatchesPanel("/embedded/swatches"); - dtw->panels->setOrientation( Gtk::ANCHOR_SOUTH ); + dtw->panels->setOrientation(SP_ANCHOR_SOUTH); gtk_box_pack_end( GTK_BOX( dtw->vbox ), GTK_WIDGET(dtw->panels->gobj()), FALSE, TRUE, 0 ); } -- cgit v1.2.3 From 9e80f1d4786043549189fb2583d7fe198f688f2c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 10 Apr 2012 11:56:57 +0100 Subject: Clean up some deprecated orientable API (bzr r11208) --- src/ege-adjustment-action.cpp | 4 ++++ src/widgets/gradient-vector.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 7497b0497..47500c8c4 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -829,7 +829,11 @@ static GtkWidget* create_tool_item( GtkAction* action ) if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { /* Slider */ gchar *leakyForNow = g_value_dup_string( &value ); +#if GTK_CHECK_VERSION(3,0,0) + spinbutton = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, act->private_data->adj); +#else spinbutton = gtk_hscale_new( act->private_data->adj); +#endif gtk_widget_set_size_request(spinbutton, 100, -1); gtk_scale_set_digits( GTK_SCALE(spinbutton), 0 ); g_signal_connect( G_OBJECT(spinbutton), "format-value", G_CALLBACK(slider_format_falue), leakyForNow ); diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 355e6506e..8348f7045 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -792,7 +792,12 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s g_return_val_if_fail(!gradient || SP_IS_GRADIENT(gradient), NULL); +#if GTK_CHECK_VERSION(3,0,0) + vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, PAD); + gtk_box_set_homogeneous(GTK_BOX(vb), FALSE); +#else vb = gtk_vbox_new(FALSE, PAD); +#endif g_signal_connect(G_OBJECT(vb), "destroy", G_CALLBACK(sp_gradient_vector_widget_destroy), NULL); w = sp_gradient_image_new(gradient); @@ -873,7 +878,11 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s gtk_adjustment_set_value(Offset_adj, stop->offset); /* Slider */ +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *slider = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, Offset_adj); +#else GtkWidget *slider = gtk_hscale_new(Offset_adj); +#endif gtk_scale_set_draw_value( GTK_SCALE(slider), FALSE ); gtk_widget_show(slider); gtk_box_pack_start(GTK_BOX(hb),slider, TRUE, TRUE, AUX_BETWEEN_BUTTON_GROUPS); -- cgit v1.2.3 From 42f2462e7f57051495bf984a533b6986b9ea1b6e Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 10 Apr 2012 19:26:45 +0200 Subject: small cleanup (bzr r11209) --- src/live_effects/lpe-rough-hatches.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-rough-hatches.h b/src/live_effects/lpe-rough-hatches.h index cbc3c3b26..5051b313a 100644 --- a/src/live_effects/lpe-rough-hatches.h +++ b/src/live_effects/lpe-rough-hatches.h @@ -15,7 +15,6 @@ */ #include "live_effects/effect.h" -#include "live_effects/parameter/point.h" #include "live_effects/parameter/parameter.h" #include "live_effects/parameter/bool.h" #include "live_effects/parameter/random.h" @@ -64,7 +63,6 @@ private: ScalarParam stroke_width_bot; ScalarParam front_thickness, back_thickness; - //PointParam bender; VectorParam direction; VectorParam bender; -- cgit v1.2.3 From d7c51ea3892dcad46e01642475479ff2379a51ad Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 10 Apr 2012 19:27:41 +0200 Subject: powerstroke: remove the need to reload the node tool when adding/deleting control width knots (bzr r11210) --- src/knotholder.h | 4 ++ .../parameter/powerstrokepointarray.cpp | 45 ++++++++++++++++------ 2 files changed, 37 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/knotholder.h b/src/knotholder.h index 9a4dda1da..463436be6 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -27,6 +27,9 @@ namespace Inkscape { namespace XML { class Node; } +namespace LivePathEffect { +class PowerStrokePointArrayParamKnotHolderEntity; +} } class KnotHolder { @@ -50,6 +53,7 @@ public: bool knot_mouseover(); friend class ShapeEditor; + friend class Inkscape::LivePathEffect::PowerStrokePointArrayParamKnotHolderEntity; protected: SPDesktop *desktop; diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 9d91dff18..06048cb32 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -184,29 +184,50 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_get() void PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state) { -//g_print ("This is the %d handle associated to parameter '%s'\n", _index, _pparam->param_key.c_str()); - bool knotarray_changed = false; - if (state & GDK_CONTROL_MASK) { if (state & GDK_MOD1_MASK) { // delete the clicked knot std::vector & vec = _pparam->_vector; vec.erase(vec.begin() + _index); _pparam->param_set_and_write_new_value(vec); - knotarray_changed = true; + + // remove knot from knotholder + parent_holder->entity.remove(this); + // shift knots down one index + for(std::list::iterator ent = parent_holder->entity.begin(); ent != parent_holder->entity.end(); ++ent) { + PowerStrokePointArrayParamKnotHolderEntity *pspa_ent = dynamic_cast(*ent); + if ( pspa_ent && pspa_ent->_pparam == this->_pparam ) { // check if the knotentity belongs to this powerstrokepointarray parameter + if (pspa_ent->_index > this->_index) { + --pspa_ent->_index; + } + } + }; + // delete self and return + delete this; + return; } else { - // add a knot + // add a knot to XML std::vector & vec = _pparam->_vector; - vec.insert(vec.begin() + _index, 1, vec.at(_index)); + vec.insert(vec.begin() + _index, 1, vec.at(_index)); // this clicked knot is duplicated _pparam->param_set_and_write_new_value(vec); - knotarray_changed = true; + + // shift knots up one index + for(std::list::iterator ent = parent_holder->entity.begin(); ent != parent_holder->entity.end(); ++ent) { + PowerStrokePointArrayParamKnotHolderEntity *pspa_ent = dynamic_cast(*ent); + if ( pspa_ent && pspa_ent->_pparam == this->_pparam ) { // check if the knotentity belongs to this powerstrokepointarray parameter + if (pspa_ent->_index > this->_index) { + ++pspa_ent->_index; + } + } + }; + // add knot to knotholder + PowerStrokePointArrayParamKnotHolderEntity *e = new PowerStrokePointArrayParamKnotHolderEntity(_pparam, _index+1); + e->create( this->desktop, this->item, parent_holder, + _("Stroke width control point: drag to alter the stroke width. Ctrl+click adds a control point, Ctrl+Alt+click deletes it."), + _pparam->knot_shape, _pparam->knot_mode, _pparam->knot_color); + parent_holder->add(e); } } - - if (knotarray_changed) { - // if knot array has been changed, the on-canvas knots must be reloaded - /// \todo reload! - } } void -- cgit v1.2.3 From 20604a9037ad7c995977b20f9e5f16b4fe10125a Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 10 Apr 2012 19:56:29 +0200 Subject: fix potential issue with tangent calculation (bzr r11211) --- src/live_effects/lpe-powerstroke.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 878811275..79997ff94 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -239,7 +239,7 @@ std::vector find_discontinuities( Geom::Piecewise A 2Geom method was created to do exactly this :) */ - Geom::Point tang1 = unitTangentAt(B[prev_i],1); + Geom::Point tang1 = -unitTangentAt(reverse(B[prev_i]),0.); // = unitTangentAt(B[prev_i],1); Geom::Point tang2 = unitTangentAt(B[i],0); boost::optional O = intersection_point( B[prev_i].at1(), tang1, B[i].at0(), tang2 ); @@ -326,7 +326,7 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise /* case LINEJOIN_NONE: { if ( on_outside ) { // we are on the outside - Geom::Point der1 = unitTangentAt(B[prev_i],1); + Geom::Point der1 = -unitTangentAt(reverse(B[prev_i]),0.); // = unitTangentAt(B[prev_i],1); Geom::Point point_on_path = B[prev_i].at1() - rot90(der1) * cusp.width; pb.lineTo(point_on_path); pb.lineTo(B[i].at0()); @@ -339,7 +339,7 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise if (on_outside) { // we are on the outside, do something complicated to make it look good ;) - Geom::Point der1 = unitTangentAt(B[prev_i],1); + Geom::Point der1 = -unitTangentAt(reverse(B[prev_i]),0.); // = unitTangentAt(B[prev_i],1); Geom::Point der2 = unitTangentAt(B[i],0); Geom::D2 newcurve1 = B[prev_i] * Geom::reflection(rot90(der1), B[prev_i].at1()); @@ -377,7 +377,7 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise if (on_outside) { // we are on the outside, do something complicated to make it look good ;) - Geom::Point der1 = unitTangentAt(B[prev_i],1); + Geom::Point der1 = -unitTangentAt(reverse(B[prev_i]),0.); // = unitTangentAt(B[prev_i],1); Geom::Point der2 = unitTangentAt(B[i],0); boost::optional p = intersection_point( B[prev_i].at1(), der1, B[i].at0(), der2 ); @@ -399,7 +399,7 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise } case LINEJOIN_SPIRO: { if (on_outside) { - Geom::Point tang1 = unitTangentAt(B[prev_i],1); + Geom::Point tang1 = -unitTangentAt(reverse(B[prev_i]),0.); // = unitTangentAt(B[prev_i],1); Geom::Point tang2 = unitTangentAt(B[i],0); Geom::Point direction = B[i].at0() - B[prev_i].at1(); -- cgit v1.2.3 From 91359f05c001b67215e2690c4d7bc6b95c9cccbb Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 10 Apr 2012 21:12:47 +0200 Subject: 2geom: sbasis multiplication never returns sbasis of at least order a+b (bzr r11212) --- src/2geom/sbasis.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/2geom/sbasis.cpp b/src/2geom/sbasis.cpp index 89640af5c..a5df4309b 100644 --- a/src/2geom/sbasis.cpp +++ b/src/2geom/sbasis.cpp @@ -225,10 +225,9 @@ SBasis multiply(SBasis const &a, SBasis const &b) { // c = {a0*b0 - shift(1, a.Tri*b.Tri), a1*b1 - shift(1, a.Tri*b.Tri)} // shift(1, a.Tri*b.Tri) - SBasis c; + SBasis c(a.size() + b.size(), Linear(0,0)); if(a.isZero() || b.isZero()) return c; - c.resize(a.size() + b.size(), Linear(0,0)); for(unsigned j = 0; j < b.size(); j++) { for(unsigned i = j; i < a.size()+j; i++) { double tri = b[j].tri()*a[i-j].tri(); @@ -254,9 +253,9 @@ SBasis multiply(SBasis const &a, SBasis const &b) { The added term is almost free */ SBasis multiply_add(SBasis const &a, SBasis const &b, SBasis c) { + c.resize(a.size() + b.size(), Linear(0,0)); if(a.isZero() || b.isZero()) return c; - c.resize(a.size() + b.size(), Linear(0,0)); for(unsigned j = 0; j < b.size(); j++) { for(unsigned i = j; i < a.size()+j; i++) { double tri = b[j].tri()*a[i-j].tri(); @@ -280,7 +279,7 @@ SBasis multiply_add(SBasis const &a, SBasis const &b, SBasis c) { */ SBasis multiply(SBasis const &a, SBasis const &b) { - SBasis c; + SBasis c(a.size() + b.size(), Linear(0,0)); if(a.isZero() || b.isZero()) return c; return multiply_add(a, b, c); @@ -607,7 +606,7 @@ TODO: compute order according to tol? TODO: requires g(0)=0 & g(1)=1 atm... adaptation to other cases should be obvious! */ SBasis compose_inverse(SBasis const &f, SBasis const &g, unsigned order, double zero){ - SBasis result(order, Linear()); //result + SBasis result(order, Linear(0.)); //result SBasis r=f; //remainder SBasis Pk=Linear(1)-g,Qk=g,sg=Pk*Qk; Pk.truncate(order); @@ -616,7 +615,10 @@ SBasis compose_inverse(SBasis const &f, SBasis const &g, unsigned order, double Qk.resize(order,Linear(0.)); r.resize(order,Linear(0.)); - int vs= valuation(sg,zero); + int vs = valuation(sg,zero); + if (vs == 0) { // to prevent infinite loop + return result; + } for (unsigned k=0; k Date: Tue, 10 Apr 2012 21:21:08 +0100 Subject: Replace deprecated gtk_vbox_new and gtk_widget_size_request (bzr r11213) --- src/dialogs/find.cpp | 19 +++++++++++++++++++ src/ink-comboboxentry-action.cpp | 8 ++++++++ src/ui/dialog/aboutbox.cpp | 4 ++++ src/ui/dialog/clonetiler.cpp | 15 +++++++++++++++ src/widgets/desktop-widget.cpp | 10 ++++++++++ src/widgets/font-selector.cpp | 5 +++++ src/widgets/paint-selector.cpp | 15 +++++++++++++++ src/widgets/shrink-wrap-button.cpp | 4 ++++ src/widgets/toolbox.cpp | 20 ++++++++++++++++++++ 9 files changed, 100 insertions(+) (limited to 'src') diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp index b0a4e36cc..3bd22b8eb 100644 --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@ -108,7 +108,11 @@ void sp_find_squeeze_window() { GtkRequisition r; +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_get_preferred_size(dlg, &r, NULL); +#else gtk_widget_size_request(dlg, &r); +#endif gtk_window_resize ((GtkWindow *) dlg, r.width, r.height); } @@ -549,7 +553,12 @@ sp_find_types_checkbox_indented (GtkWidget *w, const gchar *data, gboolean activ GtkWidget * sp_find_types () { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + gtk_box_new(GTK_BOX(vb), FALSE); +#else GtkWidget *vb = gtk_vbox_new (FALSE, 4); +#endif gtk_widget_show (vb); { @@ -576,7 +585,12 @@ sp_find_types () } { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *vb_all = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + gtk_box_new(GTK_BOX(vb_all), FALSE); +#else GtkWidget *vb_all = gtk_vbox_new (FALSE, 0); +#endif gtk_widget_show (vb_all); { @@ -719,7 +733,12 @@ sp_find_dialog_old (void) gtk_container_set_border_width (GTK_CONTAINER (dlg), 4); /* Toplevel vbox */ +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + gtk_box_new(GTK_BOX(vb), FALSE); +#else GtkWidget *vb = gtk_vbox_new (FALSE, 0); +#endif gtk_container_add (GTK_CONTAINER (dlg), vb); sp_find_new_searchfield (dlg, vb, _("_Text:"), "text", _("Find objects by their text content (exact or partial match)")); diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index b9dac24e9..6b5266709 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -378,7 +378,11 @@ GtkWidget* create_tool_item( GtkAction* action ) // Optionally widen the combobox width... which widens the drop-down list in list mode. if( ink_comboboxentry_action->extra_width > 0 ) { GtkRequisition req; +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_get_preferred_size(GTK_WIDGET(ink_comboboxentry_action->combobox), &req, NULL); +#else gtk_widget_size_request( GTK_WIDGET( ink_comboboxentry_action->combobox ), &req ); +#endif gtk_widget_set_size_request( GTK_WIDGET( ink_comboboxentry_action->combobox ), req.width + ink_comboboxentry_action->extra_width, -1 ); } @@ -527,7 +531,11 @@ void ink_comboboxentry_action_set_extra_width( Ink_ComboBoxEntry_Action* action, // Widget may not have been created.... if( action->combobox ) { GtkRequisition req; +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_get_preferred_size(GTK_WIDGET(action->combobox), &req, NULL); +#else gtk_widget_size_request( GTK_WIDGET( action->combobox ), &req ); +#endif gtk_widget_set_size_request( GTK_WIDGET( action->combobox ), req.width + action->extra_width, -1 ); } } diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index f6adc71c0..885846685 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -121,7 +121,11 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) { get_vbox()->pack_start(*manage(label), false, false); Gtk::Requisition requisition; +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_get_preferred_size(reinterpret_cast(gobj()), &requisition, NULL); +#else gtk_widget_size_request (reinterpret_cast(gobj()), &requisition); +#endif // allow window to shrink set_size_request(0, 0); set_default_size(requisition.width, requisition.height); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 2e44a1132..7b7c66553 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -93,7 +93,12 @@ CloneTiler::CloneTiler (void) : dlg = GTK_WIDGET(gobj()); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + gtk_box_new(GTK_BOX(mainbox), FALSE); +#else GtkWidget *mainbox = gtk_vbox_new(FALSE, 4); +#endif gtk_container_set_border_width (GTK_CONTAINER (mainbox), 6); contents->pack_start (*Gtk::manage(Glib::wrap(mainbox)), true, true, 0); @@ -796,7 +801,12 @@ CloneTiler::CloneTiler (void) : } { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *vvb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + gtk_box_new(GTK_BOX(vvb), FALSE); +#else GtkWidget *vvb = gtk_vbox_new (FALSE, 0); +#endif gtk_box_pack_start (GTK_BOX (vb), vvb, FALSE, FALSE, 0); g_object_set_data (G_OBJECT(dlg), "dotrace", (gpointer) vvb); @@ -2574,7 +2584,12 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) GtkWidget * CloneTiler::clonetiler_new_tab(GtkWidget *nb, const gchar *label) { GtkWidget *l = gtk_label_new_with_mnemonic (label); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, VB_MARGIN); + gtk_box_new(GTK_BOX(vb), FALSE); +#else GtkWidget *vb = gtk_vbox_new (FALSE, VB_MARGIN); +#endif gtk_container_set_border_width (GTK_CONTAINER (vb), VB_MARGIN); gtk_notebook_append_page (GTK_NOTEBOOK (nb), vb, l); return vb; diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index c5c278e2d..44d3c2f9a 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -332,7 +332,12 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->_interaction_disabled_counter = 0; /* Main table */ +#if GTK_CHECK_VERSION(3,0,0) + dtw->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + gtk_box_new(GTK_BOX(dtw->vbox), FALSE); +#else dtw->vbox = gtk_vbox_new (FALSE, 0); +#endif gtk_container_add( GTK_CONTAINER(dtw), GTK_WIDGET(dtw->vbox) ); #if GTK_CHECK_VERSION(3,0,0) @@ -412,7 +417,12 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_table_attach (GTK_TABLE (canvas_tbl), dtw->hscrollbar, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_SHRINK), 0, 0); /* Vertical scrollbar and the sticky zoom button */ +#if GTK_CHECK_VERSION(3,0,0) + dtw->vscrollbar_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + gtk_box_new(GTK_BOX(dtw->vscrollbar_box), FALSE); +#else dtw->vscrollbar_box = gtk_vbox_new (FALSE, 0); +#endif dtw->sticky_zoom = sp_button_new_from_data ( Inkscape::ICON_SIZE_DECORATION, SP_BUTTON_TYPE_TOGGLE, NULL, diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index ba6fca16a..ff361a6b8 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -176,7 +176,12 @@ static void sp_font_selector_init(SPFontSelector *fsel) gtk_widget_show(f); gtk_box_pack_start(GTK_BOX (fsel), f, TRUE, TRUE, 0); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + gtk_box_new(GTK_BOX(vb), FALSE); +#else GtkWidget *vb = gtk_vbox_new(FALSE, 4); +#endif gtk_widget_show(vb); gtk_container_set_border_width(GTK_CONTAINER (vb), 4); gtk_container_add(GTK_CONTAINER(f), vb); diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 13b112dc6..d97f79cd4 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -288,7 +288,12 @@ sp_paint_selector_init(SPPaintSelector *psel) gtk_box_pack_start(GTK_BOX(lbbox), psel->label, false, false, 4); gtk_box_pack_start(GTK_BOX(psel), lbbox, false, false, 4); +#if GTK_CHECK_VERSION(3,0,0) + psel->frame = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + gtk_box_new(GTK_BOX(psel->frame), FALSE); +#else psel->frame = gtk_vbox_new(FALSE, 4); +#endif gtk_widget_show(psel->frame); //gtk_container_set_border_width(GTK_CONTAINER(psel->frame), 0); gtk_box_pack_start(GTK_BOX(psel), psel->frame, TRUE, TRUE, 0); @@ -672,7 +677,12 @@ static void sp_paint_selector_set_mode_color(SPPaintSelector *psel, SPPaintSelec sp_paint_selector_clear_frame(psel); /* Create new color selector */ /* Create vbox */ +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + gtk_box_new(GTK_BOX(vb), FALSE); +#else GtkWidget *vb = gtk_vbox_new(FALSE, 4); +#endif gtk_widget_show(vb); /* Color selector */ @@ -1013,7 +1023,12 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel sp_paint_selector_clear_frame(psel); /* Create vbox */ +#if GTK_CHECK_VERSION(3,0,0) + tbl = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + gtk_box_new(GTK_BOX(tbl), FALSE); +#else tbl = gtk_vbox_new(FALSE, 4); +#endif gtk_widget_show(tbl); { diff --git a/src/widgets/shrink-wrap-button.cpp b/src/widgets/shrink-wrap-button.cpp index ba422034e..8d5bad21c 100644 --- a/src/widgets/shrink-wrap-button.cpp +++ b/src/widgets/shrink-wrap-button.cpp @@ -21,7 +21,11 @@ void minimum_size(GtkWidget *widget, GtkRequisition *requisition, void *) { GtkWidget *child(gtk_bin_get_child(GTK_BIN(widget))); if (child) { +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_get_preferred_size(child, requisition, NULL); +#else gtk_widget_size_request(child, requisition); +#endif } else { requisition->width = 0; requisition->height = 0; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index ff9718815..aa87fb873 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -1058,14 +1058,24 @@ static GtkWidget* toolboxNewCommon( GtkWidget* tb, BarId id, GtkPositionType han GtkWidget *ToolboxFactory::createToolToolbox() { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *tb = gtk_box_new(GTK_ORIENTATION, 0); + gtk_box_new(GTK_BOX(tb), FALSE); +#else GtkWidget *tb = gtk_vbox_new(FALSE, 0); +#endif return toolboxNewCommon( tb, BAR_TOOL, GTK_POS_TOP ); } GtkWidget *ToolboxFactory::createAuxToolbox() { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + gtk_box_new(GTK_BOX(tb), FALSE); +#else GtkWidget *tb = gtk_vbox_new(FALSE, 0); +#endif return toolboxNewCommon( tb, BAR_AUX, GTK_POS_LEFT ); } @@ -1076,14 +1086,24 @@ GtkWidget *ToolboxFactory::createAuxToolbox() GtkWidget *ToolboxFactory::createCommandsToolbox() { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + gtk_box_new(GTK_BOX(tb), FALSE); +#else GtkWidget *tb = gtk_vbox_new(FALSE, 0); +#endif return toolboxNewCommon( tb, BAR_COMMANDS, GTK_POS_LEFT ); } GtkWidget *ToolboxFactory::createSnapToolbox() { +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + gtk_box_new(GTK_BOX(tb), FALSE); +#else GtkWidget *tb = gtk_vbox_new(FALSE, 0); +#endif return toolboxNewCommon( tb, BAR_SNAP, GTK_POS_LEFT ); } -- cgit v1.2.3 From d45c95471018a352b4c6856dbd16e1ad21d3ee7c Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 10 Apr 2012 22:25:24 +0200 Subject: fix 2geom (bzr r11214) --- src/2geom/sbasis.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/2geom/sbasis.cpp b/src/2geom/sbasis.cpp index a5df4309b..6ba644b14 100644 --- a/src/2geom/sbasis.cpp +++ b/src/2geom/sbasis.cpp @@ -253,9 +253,9 @@ SBasis multiply(SBasis const &a, SBasis const &b) { The added term is almost free */ SBasis multiply_add(SBasis const &a, SBasis const &b, SBasis c) { - c.resize(a.size() + b.size(), Linear(0,0)); if(a.isZero() || b.isZero()) return c; + c.resize(a.size() + b.size(), Linear(0,0)); for(unsigned j = 0; j < b.size(); j++) { for(unsigned i = j; i < a.size()+j; i++) { double tri = b[j].tri()*a[i-j].tri(); -- cgit v1.2.3 From c85efd9949049fdfda8b1decde5cb1e112893e17 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 10 Apr 2012 22:46:16 +0200 Subject: more 2geom fix (bzr r11215) --- src/2geom/sbasis-geometric.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/2geom/sbasis-geometric.cpp b/src/2geom/sbasis-geometric.cpp index b228a8ca0..74827e27c 100644 --- a/src/2geom/sbasis-geometric.cpp +++ b/src/2geom/sbasis-geometric.cpp @@ -1,9 +1,3 @@ -#include <2geom/sbasis-geometric.h> -#include <2geom/sbasis.h> -#include <2geom/sbasis-math.h> -//#include <2geom/solver.h> -#include <2geom/sbasis-geometric.h> - /** Geometric operators on D2 (1D->2D). * Copyright 2007 JF Barraud * Copyright 2007 N Hurst @@ -21,6 +15,12 @@ * **/ +#include <2geom/sbasis-geometric.h> +#include <2geom/sbasis.h> +#include <2geom/sbasis-math.h> +//#include <2geom/solver.h> +#include <2geom/sbasis-geometric.h> + //namespace Geom{ using namespace Geom; using namespace std; @@ -409,6 +409,9 @@ Geom::arc_length_parametrization(D2 const &M, Piecewise s = arcLengthSb(Piecewise >(M),tol); for (unsigned i=0; i < s.size();i++){ double t0=s.cuts[i],t1=s.cuts[i+1]; + if ( are_near(s(t0),s(t1)) ) { + continue; + } D2 sub_M = compose(M,Linear(t0,t1)); D2 sub_u; for (unsigned dim=0;dim<2;dim++){ -- cgit v1.2.3 From f586aedf401d920ba3ddf5e4e250b4c5a2755597 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 11 Apr 2012 10:34:38 +0900 Subject: Fix for 950677 : Disable gradient editor on knot double click (bzr r11216) --- src/gradient-drag.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 12ecd467c..ad66b258a 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -1012,7 +1012,7 @@ static void gr_knot_clicked_handler(SPKnot */*knot*/, guint state, gpointer data } /** - * Called when a dragger knot is doubleclicked; opens gradient editor with the stop from the first draggable. + * Called when a dragger knot is doubleclicked; */ static void gr_knot_doubleclicked_handler(SPKnot */*knot*/, guint /*state*/, gpointer data) { @@ -1023,8 +1023,11 @@ static void gr_knot_doubleclicked_handler(SPKnot */*knot*/, guint /*state*/, gpo if (dragger->draggables == NULL) return; - GrDraggable *draggable = (GrDraggable *) dragger->draggables->data; - sp_item_gradient_edit_stop (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke); + /* + * 2012/4 - Do nothing (gradient editor to be disabled) + */ + //GrDraggable *draggable = (GrDraggable *) dragger->draggables->data; + //sp_item_gradient_edit_stop (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke); } /** -- cgit v1.2.3 From 870376b7694b4667bb7a9980df4d92580070ca23 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 11 Apr 2012 10:52:16 +0900 Subject: Fix for 170378 : Select All by Stroke or Fill Color - Added search within groups (bzr r11217) --- src/selection-chemistry.cpp | 50 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index f481a5337..e9257d3af 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -490,7 +490,17 @@ void sp_edit_clear_all(SPDesktop *dt) _("Delete all")); } -GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, GSList const *exclude) +/* + * Return a list of SPItems that are the children of 'list' + * + * list - source list of items to search in + * desktop - desktop associated with the source list + * exclude - list of items to exclude from result + * onlyvisible - TRUE includes only items visible on canvas + * onlysensitive - TRUE includes only non-locked items + * ingroups - TRUE to recursively get grouped items children + */ +GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude) { for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM(child) && @@ -503,8 +513,8 @@ GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onl list = g_slist_prepend(list, SP_ITEM(child)); } - if (SP_IS_ITEM(child) && desktop->isLayer(SP_ITEM(child))) { - list = get_all_items(list, child, desktop, onlyvisible, onlysensitive, exclude); + if (ingroups || (SP_IS_ITEM(child) && desktop->isLayer(SP_ITEM(child)))) { + list = get_all_items(list, child, desktop, onlyvisible, onlysensitive, ingroups, exclude); } } @@ -561,11 +571,11 @@ void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool invert) break; } case PREFS_SELECTION_LAYER_RECURSIVE: { - items = get_all_items(NULL, dt->currentLayer(), dt, onlyvisible, onlysensitive, exclude); + items = get_all_items(NULL, dt->currentLayer(), dt, onlyvisible, onlysensitive, FALSE, exclude); break; } default: { - items = get_all_items(NULL, dt->currentRoot(), dt, onlyvisible, onlysensitive, exclude); + items = get_all_items(NULL, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); break; } } @@ -1648,7 +1658,12 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea return; } - GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, true, true, NULL); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); + bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); + bool ingroups = TRUE; + + GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL); GSList *all_matches = NULL; Inkscape::Selection *selection = sp_desktop_selection (desktop); @@ -1673,8 +1688,12 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea selection->clear(); selection->setList(all_matches); - g_slist_free(all_matches); - g_slist_free(all_list); + if (all_matches) { + g_slist_free(all_matches); + } + if (all_list) { + g_slist_free(all_list); + } } @@ -1691,7 +1710,12 @@ void sp_select_same_stroke_style(SPDesktop *desktop) return; } - GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, true, true, NULL); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); + bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); + bool ingroups = TRUE; + + GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL); GSList *matches = all_list; Inkscape::Selection *selection = sp_desktop_selection (desktop); @@ -1706,8 +1730,12 @@ void sp_select_same_stroke_style(SPDesktop *desktop) selection->clear(); selection->setList(matches); - g_slist_free(matches); - g_slist_free(all_list); + if (matches) { + g_slist_free(matches); + } + if (all_list) { + g_slist_free(all_list); + } } /* -- cgit v1.2.3 From 3e90dc57c0f70ab71cafb42ddb93884d944eeb24 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 10 Apr 2012 23:41:33 -0700 Subject: Removed unused function. (bzr r11218) --- src/extension/internal/javafx-out.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'src') diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 4cf6f3c4f..67c0fae66 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -129,21 +129,6 @@ static JavaFXOutput::String dstr(double d) #define DSTR(d) (dstr(d).c_str()) -/** - * Format a double as an integer - */ -static JavaFXOutput::String istr(double d) -{ - char dbuf[G_ASCII_DTOSTR_BUF_SIZE+1]; - g_ascii_formatd(dbuf, G_ASCII_DTOSTR_BUF_SIZE, - "%.0f", (gdouble)d); - JavaFXOutput::String s = dbuf; - return s; -} - -#define ISTR(d) (istr(d).c_str()) - - /** * Format an rgba() string */ -- cgit v1.2.3 From 3495ba3d2bf06f2fa5bd835f0ab36c260c712740 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 11 Apr 2012 16:27:43 +0900 Subject: Fix for 367607 : Replace deprecated sp_ctrl_set_arg and gtk_object_add_arg_type calls in sodipodi-ctrl.cpp (bzr r11219) --- src/display/sodipodi-ctrl.cpp | 254 +++++++++++++++++++++++++++--------------- 1 file changed, 163 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index c5a1b10a2..725ead0d6 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -29,14 +29,13 @@ enum { static void sp_ctrl_class_init (SPCtrlClass *klass); static void sp_ctrl_init (SPCtrl *ctrl); static void sp_ctrl_destroy (GtkObject *object); -static void sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); - +static void sp_ctrl_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); +static void sp_ctrl_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static void sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf); static double sp_ctrl_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); - static SPCanvasItemClass *parent_class; GType @@ -66,24 +65,36 @@ sp_ctrl_class_init (SPCtrlClass *klass) { GtkObjectClass *object_class; SPCanvasItemClass *item_class; + GObjectClass *g_object_class; object_class = (GtkObjectClass *) klass; item_class = (SPCanvasItemClass *) klass; + g_object_class = (GObjectClass *) klass; parent_class = (SPCanvasItemClass *)g_type_class_peek_parent (klass); - gtk_object_add_arg_type ("SPCtrl::shape", G_TYPE_INT, G_PARAM_READWRITE, ARG_SHAPE); - gtk_object_add_arg_type ("SPCtrl::mode", G_TYPE_INT, G_PARAM_READWRITE, ARG_MODE); - gtk_object_add_arg_type ("SPCtrl::anchor", G_TYPE_INT, G_PARAM_READWRITE, ARG_ANCHOR); - gtk_object_add_arg_type ("SPCtrl::size", G_TYPE_DOUBLE, G_PARAM_READWRITE, ARG_SIZE); - gtk_object_add_arg_type ("SPCtrl::pixbuf", G_TYPE_POINTER, G_PARAM_READWRITE, ARG_PIXBUF); - gtk_object_add_arg_type ("SPCtrl::filled", G_TYPE_BOOLEAN, G_PARAM_READWRITE, ARG_FILLED); - gtk_object_add_arg_type ("SPCtrl::fill_color", G_TYPE_INT, G_PARAM_READWRITE, ARG_FILL_COLOR); - gtk_object_add_arg_type ("SPCtrl::stroked", G_TYPE_BOOLEAN, G_PARAM_READWRITE, ARG_STROKED); - gtk_object_add_arg_type ("SPCtrl::stroke_color", G_TYPE_INT, G_PARAM_READWRITE, ARG_STROKE_COLOR); - + g_object_class->set_property = sp_ctrl_set_property; + g_object_class->get_property = sp_ctrl_get_property; object_class->destroy = sp_ctrl_destroy; - object_class->set_arg = sp_ctrl_set_arg; + + g_object_class_install_property (g_object_class, + ARG_SHAPE, g_param_spec_int ("shape", "shape", "Shape", 0, G_MAXINT, SP_CTRL_SHAPE_SQUARE, (GParamFlags) G_PARAM_READWRITE)); + g_object_class_install_property (g_object_class, + ARG_MODE, g_param_spec_int ("mode", "mode", "Mode", 0, G_MAXINT, SP_CTRL_MODE_COLOR, (GParamFlags) G_PARAM_READWRITE)); + g_object_class_install_property (g_object_class, + ARG_ANCHOR, g_param_spec_int ("anchor", "anchor", "Anchor", 0, G_MAXINT, SP_ANCHOR_CENTER, (GParamFlags) G_PARAM_READWRITE)); + g_object_class_install_property (g_object_class, + ARG_SIZE, g_param_spec_double ("size", "size", "Size", 0.0, G_MAXDOUBLE, 8.0, (GParamFlags) G_PARAM_READWRITE)); + g_object_class_install_property (g_object_class, + ARG_PIXBUF, g_param_spec_pointer ("pixbuf", "pixbuf", "Pixbuf", (GParamFlags) G_PARAM_READWRITE)); + g_object_class_install_property (g_object_class, + ARG_FILLED, g_param_spec_boolean ("filled", "filled", "Filled", TRUE, (GParamFlags) G_PARAM_READWRITE)); + g_object_class_install_property (g_object_class, + ARG_FILL_COLOR, g_param_spec_int ("fill_color", "fill_color", "Fill Color", G_MININT, G_MAXINT, 0x000000ff, (GParamFlags) G_PARAM_READWRITE)); + g_object_class_install_property (g_object_class, + ARG_STROKED, g_param_spec_boolean ("stroked", "stroked", "Stroked", FALSE, (GParamFlags) G_PARAM_READWRITE)); + g_object_class_install_property (g_object_class, + ARG_STROKE_COLOR, g_param_spec_int ("stroke_color", "stroke_color", "Stroke Color", G_MININT, G_MAXINT, 0x000000ff, (GParamFlags) G_PARAM_READWRITE)); item_class->update = sp_ctrl_update; item_class->render = sp_ctrl_render; @@ -91,55 +102,9 @@ sp_ctrl_class_init (SPCtrlClass *klass) } static void -sp_ctrl_init (SPCtrl *ctrl) -{ - ctrl->shape = SP_CTRL_SHAPE_SQUARE; - ctrl->mode = SP_CTRL_MODE_COLOR; - ctrl->anchor = SP_ANCHOR_CENTER; - ctrl->span = 3; - ctrl->defined = TRUE; - ctrl->shown = FALSE; - ctrl->build = FALSE; - ctrl->filled = 1; - ctrl->stroked = 0; - ctrl->fill_color = 0x000000ff; - ctrl->stroke_color = 0x000000ff; - - // This way we make sure that the first sp_ctrl_update() call finishes properly; - // in subsequent calls it will not update anything it the control hasn't moved - // Consider for example the case in which a snap indicator is drawn at (0, 0); - // If moveto() is called then it will not set _moved to true because we're initially already at (0, 0) - ctrl->_moved = true; // Is this flag ever going to be set back to false? I can't find where that is supposed to happen - - new (&ctrl->box) Geom::IntRect(0,0,0,0); - ctrl->cache = NULL; - ctrl->pixbuf = NULL; - - ctrl->_point = Geom::Point(0,0); -} - -static void -sp_ctrl_destroy (GtkObject *object) +sp_ctrl_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - SPCtrl *ctrl; - - g_return_if_fail (object != NULL); - g_return_if_fail (SP_IS_CTRL (object)); - - ctrl = SP_CTRL (object); - - if (ctrl->cache) { - delete[] ctrl->cache; - ctrl->cache = NULL; - } - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} -static void -sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ SPCanvasItem *item; SPCtrl *ctrl; GdkPixbuf * pixbuf = NULL; @@ -147,74 +112,181 @@ sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) item = SP_CANVAS_ITEM (object); ctrl = SP_CTRL (object); - switch (arg_id) { - case ARG_SHAPE: - ctrl->shape = (SPCtrlShapeType)(GTK_VALUE_INT (*arg)); + switch (prop_id) { + case ARG_SHAPE: { + ctrl->shape = (SPCtrlShapeType) g_value_get_int(value); ctrl->build = FALSE; - sp_canvas_item_request_update (item); + sp_canvas_item_request_update(item); + } break; - case ARG_MODE: - ctrl->mode = (SPCtrlModeType)(GTK_VALUE_INT (*arg)); + case ARG_MODE: { + ctrl->mode = (SPCtrlModeType) g_value_get_int(value); ctrl->build = FALSE; - sp_canvas_item_request_update (item); + sp_canvas_item_request_update(item); + } break; - case ARG_ANCHOR: - ctrl->anchor = (SPAnchorType)(GTK_VALUE_INT (*arg)); + case ARG_ANCHOR: { + ctrl->anchor = (SPAnchorType) g_value_get_int(value); ctrl->build = FALSE; - sp_canvas_item_request_update (item); + sp_canvas_item_request_update(item); + } break; - case ARG_SIZE: - ctrl->span = (gint) ((GTK_VALUE_DOUBLE (*arg) - 1.0) / 2.0 + 0.5); + case ARG_SIZE: { + ctrl->span = (gint)((g_value_get_double(value) - 1.0) / 2.0 + 0.5); ctrl->defined = (ctrl->span > 0); ctrl->build = FALSE; - sp_canvas_item_request_update (item); + sp_canvas_item_request_update(item); + } break; - case ARG_FILLED: - ctrl->filled = GTK_VALUE_BOOL (*arg); + case ARG_FILLED: { + ctrl->filled = g_value_get_boolean(value); ctrl->build = FALSE; - sp_canvas_item_request_update (item); + sp_canvas_item_request_update(item); + } break; case ARG_FILL_COLOR: { - guint32 fill = GTK_VALUE_INT (*arg); + guint32 fill = g_value_get_int(value); ctrl->fill_color = fill; ctrl->build = FALSE; - sp_canvas_item_request_update (item); - } break; + sp_canvas_item_request_update(item); + } + break; - case ARG_STROKED: - ctrl->stroked = GTK_VALUE_BOOL (*arg); + case ARG_STROKED: { + ctrl->stroked = g_value_get_boolean(value); ctrl->build = FALSE; - sp_canvas_item_request_update (item); + sp_canvas_item_request_update(item); + } break; case ARG_STROKE_COLOR: { - guint32 stroke = GTK_VALUE_INT (*arg); + guint32 stroke = g_value_get_int(value); ctrl->stroke_color = stroke; ctrl->build = FALSE; - sp_canvas_item_request_update (item); - } break; + sp_canvas_item_request_update(item); + } + break; - case ARG_PIXBUF: - pixbuf = (GdkPixbuf*)(GTK_VALUE_POINTER (*arg)); - if (gdk_pixbuf_get_has_alpha (pixbuf)) { + case ARG_PIXBUF: { + pixbuf = (GdkPixbuf*) g_value_get_pointer(value); + if (gdk_pixbuf_get_has_alpha(pixbuf)) { ctrl->pixbuf = pixbuf; } else { - ctrl->pixbuf = gdk_pixbuf_add_alpha (pixbuf, FALSE, 0, 0, 0); - g_object_unref (pixbuf); + ctrl->pixbuf = gdk_pixbuf_add_alpha(pixbuf, FALSE, 0, 0, 0); + g_object_unref(pixbuf); } ctrl->build = FALSE; + } break; default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } } +static void +sp_ctrl_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + SPCtrl *ctrl; + ctrl = SP_CTRL (object); + + switch (prop_id) { + + case ARG_SHAPE: + g_value_set_int(value, ctrl->shape); + break; + + case ARG_MODE: + g_value_set_int(value, ctrl->mode); + break; + + case ARG_ANCHOR: + g_value_set_int(value, ctrl->anchor); + break; + + case ARG_SIZE: + g_value_set_double(value, ctrl->span); + break; + + case ARG_FILLED: + g_value_set_boolean(value, ctrl->filled); + break; + + case ARG_FILL_COLOR: + g_value_set_int(value, ctrl->fill_color); + break; + + case ARG_STROKED: + g_value_set_boolean(value, ctrl->stroked); + break; + + case ARG_STROKE_COLOR: + g_value_set_int(value, ctrl->stroke_color); + break; + + case ARG_PIXBUF: + g_value_set_pointer(value, ctrl->pixbuf); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } + +} +static void +sp_ctrl_init (SPCtrl *ctrl) +{ + ctrl->shape = SP_CTRL_SHAPE_SQUARE; + ctrl->mode = SP_CTRL_MODE_COLOR; + ctrl->anchor = SP_ANCHOR_CENTER; + ctrl->span = 3; + ctrl->defined = TRUE; + ctrl->shown = FALSE; + ctrl->build = FALSE; + ctrl->filled = 1; + ctrl->stroked = 0; + ctrl->fill_color = 0x000000ff; + ctrl->stroke_color = 0x000000ff; + + // This way we make sure that the first sp_ctrl_update() call finishes properly; + // in subsequent calls it will not update anything it the control hasn't moved + // Consider for example the case in which a snap indicator is drawn at (0, 0); + // If moveto() is called then it will not set _moved to true because we're initially already at (0, 0) + ctrl->_moved = true; // Is this flag ever going to be set back to false? I can't find where that is supposed to happen + + new (&ctrl->box) Geom::IntRect(0,0,0,0); + ctrl->cache = NULL; + ctrl->pixbuf = NULL; + + ctrl->_point = Geom::Point(0,0); +} + +static void +sp_ctrl_destroy (GtkObject *object) +{ + SPCtrl *ctrl; + + g_return_if_fail (object != NULL); + g_return_if_fail (SP_IS_CTRL (object)); + + ctrl = SP_CTRL (object); + + if (ctrl->cache) { + delete[] ctrl->cache; + ctrl->cache = NULL; + } + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + static void sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags) { -- cgit v1.2.3 From 0013e55cc6f1d51657518c5f863e2c24b223065b Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 11 Apr 2012 22:15:03 +0900 Subject: Fix for 903676 : Replace GtkCList with GtkTreeView in XML Tree, 64bitLion crash fix (bzr r11220) --- src/ui/dialog/xml-tree.cpp | 40 ++++++++++++++++++++++------------ src/widgets/sp-xmlview-attr-list.cpp | 42 +++++++++++++++++++++--------------- src/widgets/sp-xmlview-attr-list.h | 4 +++- 3 files changed, 54 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 357114626..7efddc3cc 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -65,7 +65,6 @@ XmlTree::XmlTree (void) : attributes (NULL), content (NULL), attr_name (), - attr_value (), status (""), tree_toolbar(), xml_element_new_button ( _("New element node")), @@ -747,21 +746,27 @@ void XmlTree::on_attr_select_row(GtkTreeSelection *selection, gpointer data) return; } - self->attr_value.grab_focus (); - - self->xml_attribute_delete_button.set_sensitive(true); - - const gchar *name; - const gchar *value; - gint attr; - gtk_tree_model_get (model, &iter, 0, &name, 1, &value, 2, &attr, -1); + gchar *name = 0; + gchar *value = 0; + guint attr = 0; + gtk_tree_model_get (model, &iter, ATTR_COL_NAME, &name, ATTR_COL_VALUE, &value, ATTR_COL_ATTR, &attr, -1); self->attr_name.set_text(name); self->attr_value.get_buffer()->set_text(value); - self->selected_attr = attr; + self->attr_value.grab_focus (); + self->xml_attribute_delete_button.set_sensitive(true); + + self->selected_attr = attr; self->attr_reset_context(self->selected_attr); + if (name) { + g_free(name); + } + + if (value) { + g_free(value); + } } void XmlTree::on_attr_row_changed(SPXMLViewAttrList *attributes, const gchar * name, gpointer /*data*/) @@ -770,14 +775,21 @@ void XmlTree::on_attr_row_changed(SPXMLViewAttrList *attributes, const gchar * n GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(attributes)); GtkTreeIter iter; GtkTreeModel *model; - const gchar *attr_name; + gchar *attr_name = 0; if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get (model, &iter, 0, &attr_name, -1); - if (!strcmp(name, attr_name)) { - gtk_tree_selection_unselect_all(selection); - gtk_tree_selection_select_iter(selection, &iter); + if (gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter) ) { + if (!strcmp(name, attr_name)) { + gtk_tree_selection_unselect_all(selection); + gtk_tree_selection_select_iter(selection, &iter); + } } } + + if (attr_name) { + g_free(attr_name); + attr_name = 0; + } } void XmlTree::on_attr_unselect_row_clear_text() diff --git a/src/widgets/sp-xmlview-attr-list.cpp b/src/widgets/sp-xmlview-attr-list.cpp index dcc34efa3..0b4dcce32 100644 --- a/src/widgets/sp-xmlview-attr-list.cpp +++ b/src/widgets/sp-xmlview-attr-list.cpp @@ -36,8 +36,6 @@ static Inkscape::XML::NodeEventVector repr_events = { NULL /* order_changed */ }; -enum {COL_NAME=0, COL_VALUE, COL_ATTR}; - GtkWidget * sp_xmlview_attr_list_new (Inkscape::XML::Node * repr) { @@ -45,20 +43,24 @@ sp_xmlview_attr_list_new (Inkscape::XML::Node * repr) attr_list = (SPXMLViewAttrList*)g_object_new (SP_TYPE_XMLVIEW_ATTR_LIST, NULL); - attr_list->store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); + attr_list->store = gtk_list_store_new (ATTR_N_COLS, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING ); gtk_tree_view_set_model (GTK_TREE_VIEW(attr_list), GTK_TREE_MODEL(attr_list->store)); + // Attribute name column + int colpos = 0; GtkCellRenderer *cell = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(attr_list), COL_NAME, _("Attribute"), cell, "text", 0, NULL); - GtkTreeViewColumn *column = gtk_tree_view_get_column (GTK_TREE_VIEW(attr_list), COL_NAME); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(attr_list), colpos, _("Name"), cell, "text", ATTR_COL_NAME, NULL); + GtkTreeViewColumn *column = gtk_tree_view_get_column (GTK_TREE_VIEW(attr_list), colpos); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); - gtk_tree_view_column_set_sort_column_id (column, COL_NAME); - gtk_tree_sortable_set_sort_column_id ( GTK_TREE_SORTABLE(attr_list->store), COL_NAME, GTK_SORT_ASCENDING); + gtk_tree_view_column_set_sort_column_id (column, colpos); + gtk_tree_sortable_set_sort_column_id ( GTK_TREE_SORTABLE(attr_list->store), ATTR_COL_NAME, GTK_SORT_ASCENDING); gtk_cell_renderer_set_padding (cell, 2, 0); + // Attribute value column + colpos = 1; cell = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(attr_list), COL_VALUE, _("Value"), cell, "text", COL_VALUE, NULL); - column = gtk_tree_view_get_column (GTK_TREE_VIEW(attr_list), COL_VALUE); + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(attr_list), colpos, _("Value"), cell, "text", ATTR_COL_VALUE, NULL); + column = gtk_tree_view_get_column (GTK_TREE_VIEW(attr_list), colpos); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_cell_renderer_set_padding (cell, 2, 0); @@ -141,24 +143,28 @@ sp_xmlview_attr_list_destroy (GtkObject * object) list = SP_XMLVIEW_ATTR_LIST (object); + g_object_unref(list->store); sp_xmlview_attr_list_set_repr (list, NULL); GTK_OBJECT_CLASS (parent_class)->destroy (object); } -void sp_xmlview_attr_list_select_row_by_key(SPXMLViewAttrList * list, gchar *name) +void sp_xmlview_attr_list_select_row_by_key(SPXMLViewAttrList * list, const gchar *name) { GtkTreeIter iter; - const gchar *n; gboolean match = false; gboolean valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(list->store), &iter ); while ( valid ) { - gtk_tree_model_get (GTK_TREE_MODEL(list->store), &iter, COL_NAME, &n, -1); + gchar *n = 0; + gtk_tree_model_get (GTK_TREE_MODEL(list->store), &iter, ATTR_COL_NAME, &n, -1); if (!strcmp(n, name)) { match = true; break; } valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(list->store), &iter); + if (n) { + g_free(n); + } } if (match) { @@ -181,29 +187,31 @@ event_attr_changed (Inkscape::XML::Node * /*repr*/, list = SP_XMLVIEW_ATTR_LIST (data); GtkTreeIter iter; - const gchar *n; gboolean valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(list->store), &iter ); gboolean match = false; while ( valid ) { - gtk_tree_model_get (GTK_TREE_MODEL(list->store), &iter, COL_NAME, &n, -1); + gchar *n = 0; + gtk_tree_model_get (GTK_TREE_MODEL(list->store), &iter, ATTR_COL_NAME, &n, -1); if (!strcmp(n, name)) { match = true; break; } row++; valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(list->store), &iter); + if (n) { + g_free(n); + } } if (match) { if (new_value) { - gtk_list_store_set (list->store, &iter, COL_NAME, name, COL_VALUE, new_value, COL_ATTR, GINT_TO_POINTER (g_quark_from_string (name)), -1); + gtk_list_store_set (list->store, &iter, ATTR_COL_NAME, name, ATTR_COL_VALUE, new_value, ATTR_COL_ATTR, g_quark_from_string (name), -1); } else { gtk_list_store_remove (list->store, &iter); } } else if (new_value != NULL) { gtk_list_store_append (list->store, &iter); - gtk_list_store_set (list->store, &iter, COL_NAME, name, COL_VALUE, new_value, COL_ATTR, GINT_TO_POINTER (g_quark_from_string (name)), -1); - + gtk_list_store_set (list->store, &iter, ATTR_COL_NAME, name, ATTR_COL_VALUE, new_value, ATTR_COL_ATTR, g_quark_from_string (name), -1); } // send a "changed" signal so widget owners will know I've updated diff --git a/src/widgets/sp-xmlview-attr-list.h b/src/widgets/sp-xmlview-attr-list.h index 485ea0114..8b1dae49b 100644 --- a/src/widgets/sp-xmlview-attr-list.h +++ b/src/widgets/sp-xmlview-attr-list.h @@ -45,7 +45,9 @@ GtkWidget * sp_xmlview_attr_list_new (Inkscape::XML::Node * repr); #define SP_XMLVIEW_ATTR_LIST_GET_REPR(list) (SP_XMLVIEW_ATTR_LIST (list)->repr) void sp_xmlview_attr_list_set_repr (SPXMLViewAttrList * list, Inkscape::XML::Node * repr); -void sp_xmlview_attr_list_select_row_by_key(SPXMLViewAttrList * list, gchar *name); +void sp_xmlview_attr_list_select_row_by_key(SPXMLViewAttrList * list, const gchar *name); +/* Attribute list store columns */ +enum {ATTR_COL_NAME=0, ATTR_COL_ATTR=1, ATTR_COL_VALUE=2, ATTR_N_COLS=3 }; #endif -- cgit v1.2.3 From 13a3d964eaa45df96ade62dd63783952f8af4a12 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 11 Apr 2012 22:56:02 +0900 Subject: Fix for 903676 : Replace GtkCTree with GtkTreeView in XML Tree (bzr r11221) --- src/ui/dialog/xml-tree.cpp | 152 ++++++------ src/ui/dialog/xml-tree.h | 13 +- src/widgets/sp-xmlview-tree.cpp | 535 ++++++++++++++++++++++++++++++---------- src/widgets/sp-xmlview-tree.h | 14 +- 4 files changed, 485 insertions(+), 229 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 7efddc3cc..512cb139d 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -166,6 +166,7 @@ XmlTree::XmlTree (void) : Gtk::ScrolledWindow *tree_scroller = new Gtk::ScrolledWindow(); tree_scroller->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ); + tree_scroller->set_shadow_type(Gtk::SHADOW_IN); tree_scroller->add(*Gtk::manage(Glib::wrap(GTK_WIDGET(tree)))); left_box.pack_start(*tree_scroller); @@ -226,11 +227,11 @@ XmlTree::XmlTree (void) : text_container.add(*Gtk::manage(Glib::wrap(GTK_WIDGET(content)))); /* Signal handlers */ - g_signal_connect( G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row), this ); - g_signal_connect( G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row), this); + GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree)); + g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (on_tree_select_row), this); g_signal_connect_after( G_OBJECT(tree), "tree_move", G_CALLBACK(after_tree_move), this); - GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(attributes)); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(attributes)); g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (on_attr_select_row), this); g_signal_connect( G_OBJECT(attributes), "row-value-changed", G_CALLBACK(on_attr_row_changed), this); @@ -286,8 +287,6 @@ XmlTree::~XmlTree (void) Inkscape::GC::release(_message_stack); _message_stack = NULL; _message_changed_connection.~connection(); - - //status = ""; } void XmlTree::setDesktop(SPDesktop *desktop) @@ -393,8 +392,6 @@ void XmlTree::set_tree_repr(Inkscape::XML::Node *repr) return; } - gtk_clist_freeze(GTK_CLIST(tree)); - sp_xmlview_tree_set_repr(tree, repr); if (repr) { set_tree_select(get_dt_select()); @@ -402,8 +399,6 @@ void XmlTree::set_tree_repr(Inkscape::XML::Node *repr) set_tree_select(NULL); } - gtk_clist_thaw(GTK_CLIST(tree)); - propagate_tree_select(selected_repr); } @@ -418,26 +413,29 @@ void XmlTree::set_tree_select(Inkscape::XML::Node *repr) selected_repr = repr; if (repr) { - GtkCTreeNode *node; + GtkTreeIter node; Inkscape::GC::anchor(selected_repr); - node = sp_xmlview_tree_get_repr_node(SP_XMLVIEW_TREE(tree), repr); - if (node) { - GtkCTreeNode *parent; + if (sp_xmlview_tree_get_repr_node(SP_XMLVIEW_TREE(tree), repr, &node)) { - gtk_ctree_select(GTK_CTREE(tree), node); + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); + gtk_tree_selection_unselect_all (selection); - parent = GTK_CTREE_ROW(node)->parent; - while (parent) { - gtk_ctree_expand(GTK_CTREE(tree), parent); - parent = GTK_CTREE_ROW(parent)->parent; - } + GtkTreePath* path = gtk_tree_model_get_path(GTK_TREE_MODEL(tree->store), &node); + gtk_tree_view_expand_to_path (GTK_TREE_VIEW(tree), path); + gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(tree), path, NULL, TRUE, 0.66, 0.0); + gtk_tree_path_free(path); + + gtk_tree_selection_select_iter(selection, &node); - gtk_ctree_node_moveto(GTK_CTREE(tree), node, 0, 0.66, 0.0); + } else { + g_message("XmlTree::set_tree_select : Couldnt find repr node"); } } else { - gtk_clist_unselect_all(GTK_CLIST(tree)); + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); + gtk_tree_selection_unselect_all (selection); + on_tree_unselect_row_disable(); on_tree_unselect_row_hide(); } @@ -507,77 +505,70 @@ void XmlTree::set_dt_select(Inkscape::XML::Node *repr) } // end of set_dt_select() -void XmlTree::on_tree_select_row(GtkCTree *tree, +/*void XmlTree::on_tree_select_row(GtkCTree *tree, GtkCTreeNode *node, - gint /*column*/, - gpointer data) + gint column, + gpointer data)*/ +void XmlTree::on_tree_select_row(GtkTreeSelection *selection, gpointer data) { XmlTree *self = static_cast(data); - Inkscape::XML::Node *repr = sp_xmlview_tree_node_get_repr(SP_XMLVIEW_TREE(tree), node); - g_assert(repr != NULL); + GtkTreeIter iter; + GtkTreeModel *model; if (self->selected_repr) { Inkscape::GC::release(self->selected_repr); self->selected_repr = NULL; } - self->selected_repr = repr; - Inkscape::GC::anchor(self->selected_repr); - self->propagate_tree_select(self->selected_repr); - - self->set_dt_select(self->selected_repr); - self->tree_reset_context(); + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { + // Nothing selected, update widgets + self->propagate_tree_select(NULL); + self->set_dt_select(NULL); + self->on_tree_unselect_row_disable(); + self->on_tree_unselect_row_hide(); + self->on_attr_unselect_row_clear_text(); + return; + } - self->on_tree_select_row_enable(node); -} + Inkscape::XML::Node *repr = sp_xmlview_tree_node_get_repr(GTK_TREE_VIEW(self->tree), &iter); + g_assert(repr != NULL); -void XmlTree::on_tree_unselect_row(GtkCTree *tree, - GtkCTreeNode *node, - gint /*column*/, - gpointer data) -{ - XmlTree *self = static_cast(data); - if (self->blocked) { - return; - } + self->selected_repr = repr; + Inkscape::GC::anchor(self->selected_repr); + self->propagate_tree_select(self->selected_repr); - Inkscape::XML::Node *repr = sp_xmlview_tree_node_get_repr(SP_XMLVIEW_TREE(tree), node); - self->propagate_tree_select(NULL); - self->set_dt_select(NULL); + self->set_dt_select(self->selected_repr); - if (self->selected_repr && (self->selected_repr == repr)) { - Inkscape::GC::release(self->selected_repr); - self->selected_repr = NULL; - self->selected_attr = 0; - } + self->tree_reset_context(); - self->on_tree_unselect_row_disable(); - self->on_tree_unselect_row_hide(); - self->on_attr_unselect_row_clear_text(); + self->on_tree_select_row_enable(&iter); } +void XmlTree::after_tree_move(SPXMLViewTree *attributes, gpointer value, gpointer data) -void XmlTree::after_tree_move(GtkCTree */*tree*/, - GtkCTreeNode *node, - GtkCTreeNode *new_parent, - GtkCTreeNode *new_sibling, - gpointer data) { XmlTree *self = static_cast(data); + guint val = GPOINTER_TO_UINT(value); - if (GTK_CTREE_ROW(node)->parent == new_parent && - GTK_CTREE_ROW(node)->sibling == new_sibling) - { + if (val) { DocumentUndo::done(self->current_document, SP_VERB_DIALOG_XML_EDITOR, - _("Drag XML subtree")); + _("Drag XML subtree")); } else { - DocumentUndo::cancel(self->current_document); + //DocumentUndo::cancel(self->current_document); + /* + * There was a problem with drag & drop, + * data is probably not synchronized, so reload the tree + */ + SPDocument *document = self->current_document; + self->set_tree_document(NULL); + self->set_tree_document(document); } + } void XmlTree::_set_status_message(Inkscape::MessageType /*type*/, const gchar *message, GtkWidget *widget) @@ -587,13 +578,13 @@ void XmlTree::_set_status_message(Inkscape::MessageType /*type*/, const gchar *m } } -void XmlTree::on_tree_select_row_enable(GtkCTreeNode *node) +void XmlTree::on_tree_select_row_enable(GtkTreeIter *node) { if (!node) { return; } - Inkscape::XML::Node *repr = sp_xmlview_tree_node_get_repr(SP_XMLVIEW_TREE(tree), node); + Inkscape::XML::Node *repr = sp_xmlview_tree_node_get_repr(GTK_TREE_VIEW(tree), node); Inkscape::XML::Node *parent=repr->parent(); //on_tree_select_row_enable_if_mutable @@ -612,11 +603,10 @@ void XmlTree::on_tree_select_row_enable(GtkCTreeNode *node) //on_tree_select_row_enable_if_has_grandparent { - GtkCTreeNode *parent = GTK_CTREE_ROW(node)->parent; - - if (parent) { - GtkCTreeNode *grandparent = GTK_CTREE_ROW(parent)->parent; - if (grandparent) { + GtkTreeIter parent; + if (gtk_tree_model_iter_parent(GTK_TREE_MODEL(tree->store), &parent, node)) { + GtkTreeIter grandparent; + if (gtk_tree_model_iter_parent(GTK_TREE_MODEL(tree->store), &grandparent, &parent)) { unindent_node_button.set_sensitive(true); } else { unindent_node_button.set_sensitive(false); @@ -682,20 +672,23 @@ void XmlTree::on_tree_select_row_enable(GtkCTreeNode *node) } -gboolean XmlTree::xml_tree_node_mutable(GtkCTreeNode *node) +gboolean XmlTree::xml_tree_node_mutable(GtkTreeIter *node) { // top-level is immutable, obviously - if (!GTK_CTREE_ROW(node)->parent) { + GtkTreeIter parent; + if (!gtk_tree_model_iter_parent(GTK_TREE_MODEL(tree->store), &parent, node)) { return false; } + // if not in base level (where namedview, defs, etc go), we're mutable - if (GTK_CTREE_ROW(GTK_CTREE_ROW(node)->parent)->parent) { + GtkTreeIter child; + if (gtk_tree_model_iter_parent(GTK_TREE_MODEL(tree->store), &child, &parent)) { return true; } Inkscape::XML::Node *repr; - repr = sp_xmlview_tree_node_get_repr(SP_XMLVIEW_TREE(tree), node); + repr = sp_xmlview_tree_node_get_repr(GTK_TREE_VIEW(tree), node); g_assert(repr); // don't let "defs" or "namedview" disappear @@ -958,10 +951,13 @@ void XmlTree::cmd_duplicate_node() DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, _("Duplicate node")); - GtkCTreeNode *node = sp_xmlview_tree_get_repr_node(SP_XMLVIEW_TREE(tree), dup); + GtkTreeIter node; + + if (sp_xmlview_tree_get_repr_node(SP_XMLVIEW_TREE(tree), dup, &node)) { + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); + gtk_tree_selection_select_iter(selection, &node); + } else { - if (node) { - gtk_ctree_select(GTK_CTREE(tree), node); } } diff --git a/src/ui/dialog/xml-tree.h b/src/ui/dialog/xml-tree.h index bf43f5ae8..ee1dadc14 100644 --- a/src/ui/dialog/xml-tree.h +++ b/src/ui/dialog/xml-tree.h @@ -83,7 +83,7 @@ private: /** * Is the selected tree node editable */ - gboolean xml_tree_node_mutable(GtkCTreeNode *node); + gboolean xml_tree_node_mutable(GtkTreeIter *node); /** * Callback to close the add dialog on Escape key @@ -113,17 +113,12 @@ private: /** * Callback for a node in the tree being selected */ - static void on_tree_select_row(GtkCTree *tree, GtkCTreeNode *node, gint column, gpointer data); - - /** - * Callback when no node in the tree is selected - */ - static void on_tree_unselect_row(GtkCTree *tree, GtkCTreeNode *node, gint column, gpointer data); + static void on_tree_select_row(GtkTreeSelection *selection, gpointer data); /** * Callback when a node is moved in the tree */ - static void after_tree_move(GtkCTree *tree, GtkCTreeNode *node, GtkCTreeNode *new_parent, GtkCTreeNode *new_sibling, gpointer data); + static void after_tree_move(SPXMLViewTree *attributes, gpointer value, gpointer data); /** * Callback for when attribute selection changes @@ -138,7 +133,7 @@ private: /** * Enable widgets based on current selections */ - void on_tree_select_row_enable(GtkCTreeNode *node); + void on_tree_select_row_enable(GtkTreeIter *node); void on_tree_unselect_row_disable(); void on_tree_unselect_row_hide(); void on_attr_unselect_row_disable(); diff --git a/src/widgets/sp-xmlview-tree.cpp b/src/widgets/sp-xmlview-tree.cpp index b867b1044..18d9c1fa1 100644 --- a/src/widgets/sp-xmlview-tree.cpp +++ b/src/widgets/sp-xmlview-tree.cpp @@ -1,7 +1,7 @@ #define __SP_XMLVIEW_TREE_C__ /* - * Specialization of GtkCTree for the XML tree view + * Specialization of GtkTreeView for the XML tree view * * Authors: * MenTaLguY @@ -19,20 +19,20 @@ struct NodeData { SPXMLViewTree * tree; - GtkCTreeNode * node; + GtkTreeRowReference *rowref; Inkscape::XML::Node * repr; }; -#define NODE_DATA(node) ((NodeData *)(GTK_CTREE_ROW ((node))->row.data)) +enum { STORE_TEXT_COL = 0, STORE_DATA_COL, STORE_REPR_COL, STORE_N_COLS }; static void sp_xmlview_tree_class_init (SPXMLViewTreeClass * klass); static void sp_xmlview_tree_init (SPXMLViewTree * tree); static void sp_xmlview_tree_destroy (GtkObject * object); -static NodeData * node_data_new (SPXMLViewTree * tree, GtkCTreeNode * node, Inkscape::XML::Node * repr); +static NodeData * node_data_new (SPXMLViewTree * tree, GtkTreeIter * node, GtkTreeRowReference *rowref, Inkscape::XML::Node * repr); static void node_data_free (gpointer data); -static GtkCTreeNode * add_node (SPXMLViewTree * tree, GtkCTreeNode * parent, GtkCTreeNode * before, Inkscape::XML::Node * repr); +static GtkTreeRowReference * add_node (SPXMLViewTree * tree, GtkTreeIter * parent, GtkTreeIter * before, Inkscape::XML::Node * repr); static void element_child_added (Inkscape::XML::Node * repr, Inkscape::XML::Node * child, Inkscape::XML::Node * ref, gpointer data); static void element_attr_changed (Inkscape::XML::Node * repr, const gchar * key, const gchar * old_value, const gchar * new_value, bool is_interactive, gpointer data); @@ -43,15 +43,19 @@ static void text_content_changed (Inkscape::XML::Node * repr, const gchar * old_ static void comment_content_changed (Inkscape::XML::Node * repr, const gchar * old_content, const gchar * new_content, gpointer data); static void pi_content_changed (Inkscape::XML::Node * repr, const gchar * old_content, const gchar * new_content, gpointer data); -static void tree_move (GtkCTree * tree, GtkCTreeNode * node, GtkCTreeNode * new_parent, GtkCTreeNode * new_sibling); +static void ref_to_sibling (NodeData *node, Inkscape::XML::Node * ref, GtkTreeIter *); +static void repr_to_child (NodeData *node, Inkscape::XML::Node * repr, GtkTreeIter *); +static Inkscape::XML::Node * sibling_to_ref (GtkTreeView * tree, GtkTreeIter * parent, GtkTreeIter * sibling); +static gboolean tree_model_iter_compare(GtkTreeModel* store, GtkTreeIter * iter1, GtkTreeIter * iter2); +GtkTreeRowReference *tree_iter_to_ref (SPXMLViewTree * tree, GtkTreeIter* iter); +static void tree_ref_to_iter (SPXMLViewTree * tree, GtkTreeIter* iter, GtkTreeRowReference *ref); -static gboolean check_drag (GtkCTree * tree, GtkCTreeNode * node, GtkCTreeNode * new_parent, GtkCTreeNode * new_sibling); +gboolean search_equal_func (GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data); +gboolean foreach_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data); -static GtkCTreeNode * ref_to_sibling (GtkCTreeNode * parent, Inkscape::XML::Node * ref); -static GtkCTreeNode * repr_to_child (GtkCTreeNode * parent, Inkscape::XML::Node * repr); -static Inkscape::XML::Node * sibling_to_ref (GtkCTreeNode * parent, GtkCTreeNode * sibling); - -static gint match_node_data_by_repr(gconstpointer data_p, gconstpointer repr); +void on_row_changed(GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data); +void on_drag_data_received(GtkWidget *wgt, GdkDragContext *context, int x, int y, GtkSelectionData *seldata, guint info, guint time, gpointer userdata); +gboolean do_drag_motion(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data); static const Inkscape::XML::NodeEventVector element_repr_events = { element_child_added, @@ -85,44 +89,35 @@ static const Inkscape::XML::NodeEventVector pi_repr_events = { NULL /* order_changed */ }; -static GtkCTreeClass * parent_class = NULL; +static GtkTreeViewClass * parent_class = NULL; GtkWidget * sp_xmlview_tree_new (Inkscape::XML::Node * repr, void * /*factory*/, void * /*data*/) { SPXMLViewTree * tree; - tree = (SPXMLViewTree*)g_object_new (SP_TYPE_XMLVIEW_TREE, "n_columns", 1, "tree_column", 0, NULL); + tree = (SPXMLViewTree*)g_object_new (SP_TYPE_XMLVIEW_TREE, NULL); - gtk_clist_column_titles_hide (GTK_CLIST (tree)); - gtk_ctree_set_line_style (GTK_CTREE (tree), GTK_CTREE_LINES_NONE); - gtk_ctree_set_expander_style (GTK_CTREE (tree), GTK_CTREE_EXPANDER_TRIANGLE); - gtk_clist_set_column_auto_resize (GTK_CLIST (tree), 0, TRUE); - gtk_clist_set_reorderable (GTK_CLIST (tree), TRUE); - gtk_ctree_set_drag_compare_func (GTK_CTREE (tree), check_drag); + tree->store = gtk_tree_store_new (STORE_N_COLS, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER); + gtk_tree_view_set_model (GTK_TREE_VIEW(tree), GTK_TREE_MODEL(tree->store)); + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE); + gtk_tree_view_set_reorderable (GTK_TREE_VIEW(tree), TRUE); + gtk_tree_view_set_enable_search (GTK_TREE_VIEW(tree), TRUE); + gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW(tree), search_equal_func, NULL, NULL); - sp_xmlview_tree_set_repr (tree, repr); + GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); + GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", STORE_TEXT_COL, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); + gtk_cell_renderer_set_padding (renderer, 2, 0); + gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); - return (GtkWidget *) tree; -} + sp_xmlview_tree_set_repr (tree, repr); -void -sp_xmlview_tree_set_repr (SPXMLViewTree * tree, Inkscape::XML::Node * repr) -{ - if ( tree->repr == repr ) return; - gtk_clist_freeze (GTK_CLIST (tree)); - if (tree->repr) { - gtk_clist_clear (GTK_CLIST (tree)); - Inkscape::GC::release(tree->repr); - } - tree->repr = repr; - if (repr) { - GtkCTreeNode * node; - Inkscape::GC::anchor(repr); - node = add_node (tree, NULL, NULL, repr); - gtk_ctree_expand (GTK_CTREE (tree), node); - } - gtk_clist_thaw (GTK_CLIST (tree)); + g_signal_connect(G_OBJECT(tree->store), "row-changed", G_CALLBACK(on_row_changed), tree); + g_signal_connect(GTK_TREE_VIEW(tree), "drag_data_received", G_CALLBACK(on_drag_data_received), tree); + g_signal_connect(GTK_TREE_VIEW(tree), "drag-motion", G_CALLBACK(do_drag_motion), tree); + + return (GtkWidget *) tree; } GType @@ -141,9 +136,10 @@ sp_xmlview_tree_get_type (void) (GInstanceInitFunc) sp_xmlview_tree_init, NULL }; - type = g_type_register_static (GTK_TYPE_CTREE, "SPXMLViewTree", &info, (GTypeFlags)0); + type = g_type_register_static (GTK_TYPE_TREE_VIEW, "SPXMLViewTree", &info, (GTypeFlags)0); } + return type; } @@ -153,9 +149,17 @@ sp_xmlview_tree_class_init (SPXMLViewTreeClass * klass) GtkObjectClass * object_class; object_class = (GtkObjectClass *) klass; - parent_class = (GtkCTreeClass *) g_type_class_peek_parent (klass); - - GTK_CTREE_CLASS (object_class)->tree_move = tree_move; + parent_class = (GtkTreeViewClass *) g_type_class_peek_parent (klass); + + // Signal for when a tree drag and drop has completed + g_signal_new ( "tree_move", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, 1, + G_TYPE_UINT); object_class->destroy = sp_xmlview_tree_destroy; } @@ -165,6 +169,7 @@ sp_xmlview_tree_init (SPXMLViewTree * tree) { tree->repr = NULL; tree->blocked = 0; + tree->dndactive = FALSE; } void @@ -179,24 +184,31 @@ sp_xmlview_tree_destroy (GtkObject * object) GTK_OBJECT_CLASS (parent_class)->destroy (object); } -GtkCTreeNode * -add_node (SPXMLViewTree * tree, GtkCTreeNode * parent, GtkCTreeNode * before, Inkscape::XML::Node * repr) +/* + * Add a new row to the tree + */ +GtkTreeRowReference * +add_node (SPXMLViewTree * tree, GtkTreeIter *parent, GtkTreeIter *before, Inkscape::XML::Node * repr) { - NodeData * data; - GtkCTreeNode * node; + NodeData * data = NULL; const Inkscape::XML::NodeEventVector * vec; static const gchar *default_text[] = { "???" }; g_assert (tree != NULL); g_assert (repr != NULL); - node = gtk_ctree_insert_node (GTK_CTREE (tree), parent, before, (gchar **)default_text, 2, NULL, NULL, NULL, NULL, ( repr->type() != Inkscape::XML::ELEMENT_NODE ), FALSE); - g_assert (node != NULL); + if (before && !gtk_tree_store_iter_is_valid(tree->store, before)) { + before = NULL; + } + + GtkTreeIter iter; + gtk_tree_store_insert_before (tree->store, &iter, parent, before); - data = node_data_new (tree, node, repr); - g_assert (data != NULL); + GtkTreeRowReference *rowref = tree_iter_to_ref (tree, &iter); + data = node_data_new (tree, &iter, rowref, repr); + g_assert (data != NULL); - gtk_ctree_node_set_row_data_full (GTK_CTREE (tree), data->node, data, node_data_free); + gtk_tree_store_set (tree->store, &iter, STORE_TEXT_COL, default_text, STORE_DATA_COL, data, STORE_REPR_COL, repr, -1); if ( repr->type() == Inkscape::XML::TEXT_NODE ) { vec = &text_repr_events; @@ -211,26 +223,24 @@ add_node (SPXMLViewTree * tree, GtkCTreeNode * parent, GtkCTreeNode * before, In } if (vec) { - gtk_clist_freeze (GTK_CLIST (tree)); - /* cheat a little to get the id upated properly */ + /* cheat a little to get the id updated properly */ if (repr->type() == Inkscape::XML::ELEMENT_NODE) { element_attr_changed (repr, "id", NULL, NULL, false, data); } sp_repr_add_listener (repr, vec, data); sp_repr_synthesize_events (repr, vec, data); - gtk_clist_thaw (GTK_CLIST (tree)); } - return node; + return rowref; } NodeData * -node_data_new (SPXMLViewTree * tree, GtkCTreeNode * node, Inkscape::XML::Node * repr) +node_data_new (SPXMLViewTree * tree, GtkTreeIter * node, GtkTreeRowReference *rowref, Inkscape::XML::Node * repr) { NodeData * data; data = g_new (NodeData, 1); data->tree = tree; - data->node = node; + data->rowref = rowref; data->repr = repr; Inkscape::GC::anchor(repr); return data; @@ -250,15 +260,17 @@ void element_child_added (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * ref, gpointer ptr) { NodeData * data; - GtkCTreeNode * before; + GtkTreeIter before; data = (NodeData *) ptr; if (data->tree->blocked) return; - before = ref_to_sibling (data->node, ref); + ref_to_sibling (data, ref, &before); - add_node (data->tree, data->node, before, child); + GtkTreeIter data_iter; + tree_ref_to_iter(data->tree, &data_iter, data->rowref); + add_node (data->tree, &data_iter, &before, child); } void @@ -285,7 +297,10 @@ element_attr_changed (Inkscape::XML::Node * repr, const gchar * key, const gchar } else { label = g_strdup_printf ("<%s>", repr->name()); } - gtk_ctree_node_set_text (GTK_CTREE (data->tree), data->node, 0, label); + + GtkTreeIter iter; + tree_ref_to_iter(data->tree, &iter, data->rowref); + gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1); g_free (label); } @@ -293,30 +308,34 @@ void element_child_removed (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * /*ref*/, gpointer ptr) { NodeData * data; - data = (NodeData *) ptr; if (data->tree->blocked) return; - gtk_ctree_remove_node (GTK_CTREE (data->tree), repr_to_child (data->node, child)); + GtkTreeIter iter; + repr_to_child (data, child, &iter); + gtk_tree_store_remove (GTK_TREE_STORE(data->tree->store), &iter); + } void element_order_changed (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * /*oldref*/, Inkscape::XML::Node * newref, gpointer ptr) { NodeData * data; - GtkCTreeNode * before, * node; - + GtkTreeIter before, node; data = (NodeData *) ptr; if (data->tree->blocked) return; - before = ref_to_sibling (data->node, newref); - node = repr_to_child (data->node, child); + ref_to_sibling (data, newref, &before); + repr_to_child (data, child, &node); - if ( before == node ) before = GTK_CTREE_ROW (before)->sibling; - - parent_class->tree_move (GTK_CTREE (data->tree), node, data->node, before); + if (gtk_tree_store_iter_is_valid(data->tree->store, &before)) { + gtk_tree_store_move_before (data->tree->store, &node, &before); + } else { + repr_to_child (data, newref, &before); + gtk_tree_store_move_after (data->tree->store, &node, &before); + } } void @@ -330,7 +349,10 @@ text_content_changed (Inkscape::XML::Node * /*repr*/, const gchar * /*old_conten if (data->tree->blocked) return; label = g_strdup_printf ("\"%s\"", new_content); - gtk_ctree_node_set_text (GTK_CTREE (data->tree), data->node, 0, label); + GtkTreeIter iter; + tree_ref_to_iter(data->tree, &iter, data->rowref); + gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1); + g_free (label); } @@ -345,7 +367,10 @@ comment_content_changed (Inkscape::XML::Node */*repr*/, const gchar * /*old_cont if (data->tree->blocked) return; label = g_strdup_printf ("", new_content); - gtk_ctree_node_set_text (GTK_CTREE (data->tree), data->node, 0, label); + GtkTreeIter iter; + tree_ref_to_iter(data->tree, &iter, data->rowref); + gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1); + g_free (label); } @@ -360,102 +385,342 @@ pi_content_changed(Inkscape::XML::Node *repr, const gchar * /*old_content*/, con if (data->tree->blocked) return; label = g_strdup_printf ("", repr->name(), new_content); - gtk_ctree_node_set_text (GTK_CTREE (data->tree), data->node, 0, label); + GtkTreeIter iter; + tree_ref_to_iter(data->tree, &iter, data->rowref); + gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1); + g_free (label); } + +/* + * Save the source path on drag start, will need it in on_row_changed() when moving a row + */ void -tree_move (GtkCTree * tree, GtkCTreeNode * node, GtkCTreeNode * new_parent, GtkCTreeNode * new_sibling) +on_drag_data_received(GtkWidget *wgt, GdkDragContext *context, int x, int y, + GtkSelectionData *seldata, guint info, guint time, + gpointer userdata) { - GtkCTreeNode * old_parent; - Inkscape::XML::Node * ref; + SPXMLViewTree * tree = (SPXMLViewTree *) userdata; + if (!tree) { + return; + } + + if (tree->dndactive) { + return; + } + + GtkTreeModel *model; + GtkTreeIter iter; + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); + if (gtk_tree_selection_get_selected(selection, &model, &iter)) { + + tree->dndactive = TRUE; + + GtkTreeIter parent_iter; + GtkTreeRowReference *parent_ref = NULL; + if (gtk_tree_model_iter_parent(model, &parent_iter, &iter)) { + parent_ref = tree_iter_to_ref (tree, &parent_iter); + } + + g_object_set_data(G_OBJECT(tree), "drag-src-path", parent_ref); + } +} - old_parent = GTK_CTREE_ROW (node)->parent; - if ( !old_parent || !new_parent ) return; +/* + * Main drag & drop function + * Get the old and new paths, and change the Inkscape::XML::Node repr's + */ +void on_row_changed(GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) +{ + SPXMLViewTree *tree = (SPXMLViewTree *)user_data; + + if (!tree->dndactive) { + return; + } + tree->dndactive = FALSE; + + Inkscape::XML::Node *repr = sp_xmlview_tree_node_get_repr(GTK_TREE_VIEW(tree), iter); + GtkTreeIter new_parent; + if (!gtk_tree_model_iter_parent(tree_model, &new_parent, iter)) { + //No parent of drop location + g_signal_emit_by_name(G_OBJECT (tree), "tree_move", GUINT_TO_POINTER(0) ); + return; + } + + GtkTreeRowReference *old_parent_ref = (GtkTreeRowReference *)g_object_get_data (G_OBJECT (tree), "drag-src-path"); + if (!old_parent_ref) { + //No drag source location + g_signal_emit_by_name(G_OBJECT (tree), "tree_move", GUINT_TO_POINTER(0) ); + return; + } + + GtkTreeIter old_parent; + tree_ref_to_iter(tree, &old_parent, old_parent_ref); + if (!gtk_tree_store_iter_is_valid(GTK_TREE_STORE(tree_model), &old_parent)){ + //Drag source parent is not valid + g_signal_emit_by_name(G_OBJECT (tree), "tree_move", GUINT_TO_POINTER(0) ); + return; + } + + // Find the sibling node before iter + GtkTreeIter before_iter; + Inkscape::XML::Node *before_repr = NULL; + GtkTreeIter tmp_iter; + + gboolean valid = gtk_tree_model_iter_children(tree_model, &tmp_iter, &new_parent); + while (valid && tree_model_iter_compare (tree_model, &tmp_iter, iter)) { + before_iter = tmp_iter; + valid = gtk_tree_model_iter_next(tree_model, &tmp_iter); + } + + // If before_iter is invalid, before_repr stays as NULL which is ok + if (gtk_tree_store_iter_is_valid(GTK_TREE_STORE(tree_model), &before_iter)) { + gtk_tree_model_get (tree_model, &before_iter, STORE_REPR_COL, &before_repr, -1); + } + + // Drop onto oneself causes assert in changeOrder() below, ignore + if (repr == before_repr) + return; + + SP_XMLVIEW_TREE (tree)->blocked++; + if (!tree_model_iter_compare (tree_model, &new_parent, &old_parent)) { + sp_xmlview_tree_node_get_repr (GTK_TREE_VIEW(tree), &old_parent)->changeOrder(repr, before_repr); + } else { + sp_xmlview_tree_node_get_repr (GTK_TREE_VIEW(tree), &old_parent)->removeChild(repr); + sp_xmlview_tree_node_get_repr (GTK_TREE_VIEW(tree), &new_parent)->addChild(repr, before_repr); + } + SP_XMLVIEW_TREE (tree)->blocked--; + + // Reselect the dragged row + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); + gtk_tree_view_expand_to_path (GTK_TREE_VIEW(tree), path); + //gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(tree), path, NULL, true, 0.66, 0.0); + gtk_tree_selection_select_iter(selection, iter); + + // Signal that a drag and drop has completed successfully + g_signal_emit_by_name(G_OBJECT (tree), "tree_move", GUINT_TO_POINTER(1) ); +} - ref = sibling_to_ref (new_parent, new_sibling); +/* + * Set iter to ref or node data's child with the same repr or first child + */ +void ref_to_sibling (NodeData *data, Inkscape::XML::Node *repr, GtkTreeIter *iter) +{ + if (repr) { + repr_to_child (data, repr, iter); + gtk_tree_model_iter_next (GTK_TREE_MODEL(data->tree->store), iter); + } else { + GtkTreeIter data_iter; + tree_ref_to_iter(data->tree, &data_iter, data->rowref); + gtk_tree_model_iter_children(GTK_TREE_MODEL(data->tree->store), iter, &data_iter); + } +} - gtk_clist_freeze (GTK_CLIST (tree)); +/* + * Set iter to the node data's child with the same repr + */ +void repr_to_child (NodeData *data, Inkscape::XML::Node * repr, GtkTreeIter *iter) +{ + GtkTreeIter data_iter; + tree_ref_to_iter(data->tree, &data_iter, data->rowref); - SP_XMLVIEW_TREE (tree)->blocked++; - if (new_parent == old_parent) { - NODE_DATA (old_parent)->repr->changeOrder(NODE_DATA (node)->repr, ref); - } else { - NODE_DATA (old_parent)->repr->removeChild(NODE_DATA (node)->repr); - NODE_DATA (new_parent)->repr->addChild(NODE_DATA (node)->repr, ref); + gboolean valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(data->tree->store), iter, &data_iter); + while (valid && sp_xmlview_tree_node_get_repr (GTK_TREE_VIEW(data->tree), iter) != repr) { + valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(data->tree->store), iter); } - SP_XMLVIEW_TREE (tree)->blocked--; +} - parent_class->tree_move (tree, node, new_parent, new_sibling); +/* + * Get a matching GtkTreeRowReference for a GtkTreeIter + */ +GtkTreeRowReference *tree_iter_to_ref (SPXMLViewTree * tree, GtkTreeIter* iter) +{ + GtkTreePath* path = gtk_tree_model_get_path(GTK_TREE_MODEL(tree->store), iter); + GtkTreeRowReference *ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(tree->store), path); + gtk_tree_path_free(path); - gtk_clist_thaw (GTK_CLIST (tree)); + return ref; } -GtkCTreeNode * -ref_to_sibling (GtkCTreeNode * parent, Inkscape::XML::Node * ref) +/* + * Get a matching GtkTreeIter for a GtkTreeRowReference + */ +void tree_ref_to_iter (SPXMLViewTree * tree, GtkTreeIter* iter, GtkTreeRowReference *ref) { - if (ref) { - GtkCTreeNode * before; - before = repr_to_child (parent, ref); - g_assert (before != NULL); - before = GTK_CTREE_ROW (before)->sibling; - return before; - } else { - return GTK_CTREE_ROW (parent)->children; - } + GtkTreePath* path = gtk_tree_row_reference_get_path(ref); + gtk_tree_model_get_iter(GTK_TREE_MODEL(tree->store), iter, path); } -GtkCTreeNode * -repr_to_child (GtkCTreeNode * parent, Inkscape::XML::Node * repr) +/* + * Compare 2 GtkTreeIter and return 0 if they are equal + */ +gboolean tree_model_iter_compare(GtkTreeModel* store, GtkTreeIter * iter1, GtkTreeIter * iter2) { - GtkCTreeNode * child; - child = GTK_CTREE_ROW (parent)->children; - while ( child && NODE_DATA (child)->repr != repr ) { - child = GTK_CTREE_ROW (child)->sibling; - } - return child; + GtkTreePath *path1 = gtk_tree_model_get_path(store, iter1); + GtkTreePath *path2 = gtk_tree_model_get_path(store, iter2); + + gboolean result = gtk_tree_path_compare( path1, path2); + + gtk_tree_path_free(path1); + gtk_tree_path_free(path2); + + return result; + } +/* + * Return the node of parent iter's child sibling or NULL if sibling is the first child + */ Inkscape::XML::Node * -sibling_to_ref (GtkCTreeNode * parent, GtkCTreeNode * sibling) +sibling_to_ref (GtkTreeView * tree, GtkTreeIter * parent, GtkTreeIter * sibling) { - GtkCTreeNode * child; - child = GTK_CTREE_ROW (parent)->children; - if ( child == sibling ) return NULL; - while ( child && GTK_CTREE_ROW (child)->sibling != sibling ) { - child = GTK_CTREE_ROW (child)->sibling; + GtkTreeIter child; + GtkTreeModel* store = gtk_tree_view_get_model(tree); + + gboolean valid = gtk_tree_model_iter_children(store, &child, parent); + + if (! tree_model_iter_compare(store, &child, sibling)) { + return NULL; } - return NODE_DATA (child)->repr; -} -gboolean -check_drag (GtkCTree * /*tree*/, GtkCTreeNode * node, GtkCTreeNode * new_parent, GtkCTreeNode * /*new_sibling*/) -{ - GtkCTreeNode * old_parent; + while (valid && tree_model_iter_compare(store, &child, sibling)) { + valid = gtk_tree_model_iter_next(store, &child); + } - old_parent = GTK_CTREE_ROW (node)->parent; + if (!gtk_tree_store_iter_is_valid(GTK_TREE_STORE(store), &child)) { + return NULL; + } - if (!old_parent || !new_parent) return FALSE; - if (NODE_DATA (new_parent)->repr->type() != Inkscape::XML::ELEMENT_NODE) return FALSE; + return sp_xmlview_tree_node_get_repr (tree, &child); +} - /* fixme: we need add_child/remove_child/etc repr events without side-effects, so we can check here and give better visual feedback */ +/* + * Disable drag and drop target on : root node and non-element nodes + */ +gboolean do_drag_motion(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data) +{ + GtkTreePath *path = NULL; + GtkTreeViewDropPosition pos; + gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW(widget), x, y, &path, &pos); + + int action = 0; + + if (path) { + action = GDK_ACTION_MOVE; + + SPXMLViewTree *tree = (SPXMLViewTree *)user_data; + GtkTreeIter iter; + gtk_tree_model_get_iter(GTK_TREE_MODEL(tree->store), &iter, path); + if (sp_xmlview_tree_node_get_repr (GTK_TREE_VIEW(widget), &iter)->type() != Inkscape::XML::ELEMENT_NODE) { + action = 0; + } + + if (!gtk_tree_path_up(path)) { + action = 0; + } + if (!gtk_tree_path_up(path)) { + action = 0; + } + if (!path) { + action = 0; + } + } + + gtk_tree_path_free(path); + gdk_drag_status (context, (GdkDragAction)action, time); + + return (action == 0); +} - return TRUE; +/* + * Set the tree selection and scroll to the row with the given repr + */ +void +sp_xmlview_tree_set_repr (SPXMLViewTree * tree, Inkscape::XML::Node * repr) +{ + if ( tree->repr == repr ) return; + if (tree->repr) { + gtk_tree_store_clear(tree->store); + Inkscape::GC::release(tree->repr); + } + tree->repr = repr; + if (repr) { + GtkTreeRowReference * rowref; + Inkscape::GC::anchor(repr); + rowref = add_node (tree, NULL, NULL, repr); + GtkTreePath *path = gtk_tree_row_reference_get_path(rowref); + gtk_tree_view_expand_to_path (GTK_TREE_VIEW(tree), path); + gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(tree), path, NULL, true, 0.5, 0.0); + gtk_tree_path_free(path); + } } +/* + * Return the repr at a given GtkTreeIter position + */ Inkscape::XML::Node * -sp_xmlview_tree_node_get_repr (SPXMLViewTree * /*tree*/, GtkCTreeNode * node) +sp_xmlview_tree_node_get_repr (GtkTreeView *tree, GtkTreeIter * iter) { - return NODE_DATA (node)->repr; + Inkscape::XML::Node *repr; + GtkTreeModel *model = gtk_tree_view_get_model(tree); + gtk_tree_model_get (model, iter, STORE_REPR_COL, &repr, -1); + + return repr; } -GtkCTreeNode * -sp_xmlview_tree_get_repr_node (SPXMLViewTree * tree, Inkscape::XML::Node * repr) + +/* + * Find a GtkTreeIter position in the tree by repr + */ +gboolean +sp_xmlview_tree_get_repr_node (SPXMLViewTree * tree, Inkscape::XML::Node * repr, GtkTreeIter *iter) { - return gtk_ctree_find_by_row_data_custom (GTK_CTREE (tree), NULL, repr, match_node_data_by_repr); + /* + * Use a NodeData here to pass in the repr to the foreach function and store a rowref if found, + * if found we can return the iter + */ + NodeData anode; + anode.tree = tree; + anode.repr = repr; + anode.rowref = NULL; + + gtk_tree_model_foreach(GTK_TREE_MODEL(tree->store), foreach_func, &anode); + if (anode.rowref != NULL) { + tree_ref_to_iter(tree, iter, anode.rowref); + return TRUE; + } + + return FALSE; } -gint -match_node_data_by_repr(gconstpointer data_p, gconstpointer repr) +gboolean +foreach_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) { - return ((const NodeData *)data_p)->repr != (const Inkscape::XML::Node *)repr; + NodeData *anode = (NodeData *)user_data; + Inkscape::XML::Node *iter_repr; + gtk_tree_model_get (model, iter, STORE_REPR_COL, &iter_repr, -1); + if (anode->repr == iter_repr) { + GtkTreeRowReference *rowref = tree_iter_to_ref (anode->tree, iter); + anode->rowref = rowref; + return TRUE; + } + + return FALSE; +} + +/* + * Callback function for string searches in the tree + * Return a match on any substring + */ +gboolean search_equal_func (GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data) +{ + gboolean match = FALSE; + gchar *text; + gtk_tree_model_get (model, iter, STORE_TEXT_COL, &text, -1); + + match = (strstr(text, key) != NULL); + + g_free(text); + + return !match; } diff --git a/src/widgets/sp-xmlview-tree.h b/src/widgets/sp-xmlview-tree.h index 5d228f982..36b76f5d9 100644 --- a/src/widgets/sp-xmlview-tree.h +++ b/src/widgets/sp-xmlview-tree.h @@ -2,7 +2,7 @@ #define __SP_XMLVIEW_TREE_H__ /* - * Specialization of GtkCTree for the XML editor + * Specialization of GtkTreeView for the XML editor * * Authors: * MenTaLguY @@ -29,15 +29,16 @@ struct SPXMLViewTreeClass; struct SPXMLViewTree { - GtkCTree tree; - + GtkTreeView tree; + GtkTreeStore *store; Inkscape::XML::Node * repr; gint blocked; + gboolean dndactive; }; struct SPXMLViewTreeClass { - GtkCTreeClass parent_class; + GtkTreeViewClass parent_class; }; GType sp_xmlview_tree_get_type (void); @@ -47,9 +48,8 @@ GtkWidget * sp_xmlview_tree_new (Inkscape::XML::Node * repr, void * factory, voi void sp_xmlview_tree_set_repr (SPXMLViewTree * tree, Inkscape::XML::Node * repr); -Inkscape::XML::Node * sp_xmlview_tree_node_get_repr (SPXMLViewTree * tree, GtkCTreeNode * node); -GtkCTreeNode * sp_xmlview_tree_get_repr_node (SPXMLViewTree * tree, Inkscape::XML::Node * repr); - +Inkscape::XML::Node * sp_xmlview_tree_node_get_repr (GtkTreeView * tree, GtkTreeIter * node); +gboolean sp_xmlview_tree_get_repr_node (SPXMLViewTree * tree, Inkscape::XML::Node * repr, GtkTreeIter *node); #endif -- cgit v1.2.3 From 0da7be8ea421a11e81c3688956765f02ca043b6a Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 11 Apr 2012 20:56:34 +0200 Subject: UI. Restoring context menu items order (Embed image) and activation test (Extract image). (bzr r11223) --- src/interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index 7dbcea9e7..a14a92e83 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1924,7 +1924,7 @@ void ContextMenu::MakeImageMenu (void) mi = new Gtk::MenuItem(C_("Context menu", "Embed Image")); mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageEmbed)); mi->show(); - append(*mi); + insert(*mi,positionOfLastDialog++); if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { mi->set_sensitive( FALSE ); } @@ -1936,7 +1936,7 @@ void ContextMenu::MakeImageMenu (void) mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageExtract)); mi->show(); insert(*mi,positionOfLastDialog++); - if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { + if ( (!href) || ((strncmp(href, "data:", 5) != 0)) ) { mi->set_sensitive( FALSE ); } } -- cgit v1.2.3 From caa23c1ffef7315ff8249256267cc2ea885f5717 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 11 Apr 2012 21:30:07 +0200 Subject: i18n. Adding some context tags (disambiguation). (bzr r11224) --- src/interface.cpp | 6 +++--- src/ui/dialog/filedialogimpl-gtkmm.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index a14a92e83..91f16cbf9 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -794,9 +794,9 @@ sp_ui_checkboxes_menus(GtkMenu *m, Inkscape::UI::View::View *view) void addTaskMenuItems(GtkMenu *menu, Inkscape::UI::View::View *view) { gchar const* data[] = { - _("Default"), _("Default interface setup"), - _("Custom"), _("Set the custom task"), - _("Wide"), _("Setup for widescreen work"), + C_("Interface setup", "Default"), _("Default interface setup"), + C_("Interface setup", "Custom"), _("Set the custom task"), + C_("Interface setup", "Wide"), _("Setup for widescreen work"), 0, 0 }; diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index ab936c941..6cdd202bb 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -1457,7 +1457,7 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, selectionButton.set_group(scopeGroup); scopeBox.pack_start(selectionButton); - customButton.set_label(_("Custom")); + customButton.set_label(C_("Export dialog", "Custom")); customButton.set_group(scopeGroup); scopeBox.pack_start(customButton); -- cgit v1.2.3 From 486607590e0b140189679f7461c7d48cacd9ff56 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 11 Apr 2012 23:51:18 +0200 Subject: fix warning (bzr r11226) --- src/display/nr-filter-merge.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/nr-filter-merge.cpp b/src/display/nr-filter-merge.cpp index 28ac19a19..f1fbd7d33 100644 --- a/src/display/nr-filter-merge.cpp +++ b/src/display/nr-filter-merge.cpp @@ -74,7 +74,7 @@ double FilterMerge::complexity(Geom::Affine const &) bool FilterMerge::uses_background() { - for (int i = 0; i < _input_image.size(); ++i) { + for (unsigned int i = 0; i < _input_image.size(); ++i) { int input = _input_image[i]; if (input == NR_FILTER_BACKGROUNDIMAGE || input == NR_FILTER_BACKGROUNDALPHA) { return true; -- cgit v1.2.3 From 199638d0a8f7ce76596feb888178c5d35fd4de1d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 11 Apr 2012 23:56:00 +0200 Subject: fix deprecated glib thingie (bzr r11227) --- src/ui/dialog/filedialogimpl-win32.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 75c8b4b8a..089ec1737 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -948,7 +948,7 @@ void FileOpenDialogImplWin32::free_preview() DestroyIcon(_preview_file_icon); _preview_file_icon = NULL; - _preview_bitmap_image.clear(); + _preview_bitmap_image.reset(); _preview_emf_image = false; _mutex->unlock(); } -- cgit v1.2.3 From e90a304edc7c8c9f808733bbaedd579162928752 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 12 Apr 2012 00:00:15 +0100 Subject: Clean up a few Gtkmm orientables (bzr r11230) --- src/extension/param/bool.cpp | 5 +++++ src/ui/dialog/layers.h | 4 ++++ src/ui/dialog/livepatheffect-editor.h | 4 ++++ src/ui/dialog/spellcheck.h | 4 ++++ src/ui/widget/panel.h | 1 + 5 files changed, 18 insertions(+) (limited to 'src') diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp index ef0a06222..f7c4e6c0c 100644 --- a/src/extension/param/bool.cpp +++ b/src/extension/param/bool.cpp @@ -129,7 +129,12 @@ Gtk::Widget *ParamBool::get_widget(SPDocument * doc, Inkscape::XML::Node * node, return NULL; } +#if WITH_GTKMM_3_0 + Gtk::Box * hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 4)); + hbox->set_homogeneous(false); +#else Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); +#endif #if WITH_GTKMM_2_22 Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h index 0a6f683dd..7959d0e6e 100644 --- a/src/ui/dialog/layers.h +++ b/src/ui/dialog/layers.h @@ -109,7 +109,11 @@ private: std::vector _watchingNonBottom; Gtk::TreeView _tree; +#if WITH_GTKMM_3_0 + Gtk::ButtonBox _buttonsRow; +#else Gtk::HButtonBox _buttonsRow; +#endif Gtk::ScrolledWindow _scroller; Gtk::Menu _popupMenu; Inkscape::UI::Widget::SpinButton _spinBtn; diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index 11ab8ea89..beebbc698 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -102,7 +102,11 @@ private: void on_visibility_toggled( Glib::ustring const& str ); +#if WITH_GTKMM_3_0 + Gtk::ButtonBox toolbar_hbox; +#else Gtk::HButtonBox toolbar_hbox; +#endif Gtk::Button button_add; Gtk::Button button_remove; Gtk::Button button_up; diff --git a/src/ui/dialog/spellcheck.h b/src/ui/dialog/spellcheck.h index 74d5b76e6..8eb240097 100644 --- a/src/ui/dialog/spellcheck.h +++ b/src/ui/dialog/spellcheck.h @@ -221,7 +221,11 @@ private: * Dialogs widgets */ Gtk::Label banner_label; +#if WITH_GTKMM_3_0 + Gtk::ButtonBox banner_hbox; +#else Gtk::HButtonBox banner_hbox; +#endif Gtk::ScrolledWindow scrolled_window; Gtk::TreeView tree_view; Glib::RefPtr model; diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index 7b471c2ce..2d92d65c9 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -20,6 +20,7 @@ #include #include "enums.h" #include +#include class SPDesktop; class SPDocument; -- cgit v1.2.3 From 6b96d34a06bea7e677e0c853606916f5f71bf234 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 11 Apr 2012 22:52:40 -0700 Subject: Warning cleanup. (bzr r11231) --- src/ui/dialog/xml-tree.cpp | 4 +--- src/widgets/sp-xmlview-tree.cpp | 41 ++++++++++++++++++----------------------- 2 files changed, 19 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 512cb139d..20460474b 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -549,8 +549,7 @@ void XmlTree::on_tree_select_row(GtkTreeSelection *selection, gpointer data) } -void XmlTree::after_tree_move(SPXMLViewTree *attributes, gpointer value, gpointer data) - +void XmlTree::after_tree_move(SPXMLViewTree * /*attributes*/, gpointer value, gpointer data) { XmlTree *self = static_cast(data); guint val = GPOINTER_TO_UINT(value); @@ -568,7 +567,6 @@ void XmlTree::after_tree_move(SPXMLViewTree *attributes, gpointer value, gpointe self->set_tree_document(NULL); self->set_tree_document(document); } - } void XmlTree::_set_status_message(Inkscape::MessageType /*type*/, const gchar *message, GtkWidget *widget) diff --git a/src/widgets/sp-xmlview-tree.cpp b/src/widgets/sp-xmlview-tree.cpp index 18d9c1fa1..ade5bec39 100644 --- a/src/widgets/sp-xmlview-tree.cpp +++ b/src/widgets/sp-xmlview-tree.cpp @@ -234,16 +234,14 @@ add_node (SPXMLViewTree * tree, GtkTreeIter *parent, GtkTreeIter *before, Inksca return rowref; } -NodeData * -node_data_new (SPXMLViewTree * tree, GtkTreeIter * node, GtkTreeRowReference *rowref, Inkscape::XML::Node * repr) +NodeData *node_data_new(SPXMLViewTree * tree, GtkTreeIter * /*node*/, GtkTreeRowReference *rowref, Inkscape::XML::Node *repr) { - NodeData * data; - data = g_new (NodeData, 1); - data->tree = tree; - data->rowref = rowref; - data->repr = repr; - Inkscape::GC::anchor(repr); - return data; + NodeData *data = g_new(NodeData, 1); + data->tree = tree; + data->rowref = rowref; + data->repr = repr; + Inkscape::GC::anchor(repr); + return data; } void @@ -395,12 +393,11 @@ pi_content_changed(Inkscape::XML::Node *repr, const gchar * /*old_content*/, con /* * Save the source path on drag start, will need it in on_row_changed() when moving a row */ -void -on_drag_data_received(GtkWidget *wgt, GdkDragContext *context, int x, int y, - GtkSelectionData *seldata, guint info, guint time, - gpointer userdata) +void on_drag_data_received(GtkWidget * /*wgt*/, GdkDragContext * /*context*/, int /*x*/, int /*y*/, + GtkSelectionData * /*seldata*/, guint /*info*/, guint /*time*/, + gpointer userdata) { - SPXMLViewTree * tree = (SPXMLViewTree *) userdata; + SPXMLViewTree *tree = static_cast(userdata); if (!tree) { return; } @@ -409,7 +406,7 @@ on_drag_data_received(GtkWidget *wgt, GdkDragContext *context, int x, int y, return; } - GtkTreeModel *model; + GtkTreeModel *model = 0; GtkTreeIter iter; GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); if (gtk_tree_selection_get_selected(selection, &model, &iter)) { @@ -693,10 +690,9 @@ sp_xmlview_tree_get_repr_node (SPXMLViewTree * tree, Inkscape::XML::Node * repr, return FALSE; } -gboolean -foreach_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) +gboolean foreach_func(GtkTreeModel *model, GtkTreePath * /*path*/, GtkTreeIter *iter, gpointer user_data) { - NodeData *anode = (NodeData *)user_data; + NodeData *anode = static_cast(user_data); Inkscape::XML::Node *iter_repr; gtk_tree_model_get (model, iter, STORE_REPR_COL, &iter_repr, -1); if (anode->repr == iter_repr) { @@ -712,13 +708,12 @@ foreach_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpoin * Callback function for string searches in the tree * Return a match on any substring */ -gboolean search_equal_func (GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data) +gboolean search_equal_func(GtkTreeModel *model, gint /*column*/, const gchar *key, GtkTreeIter *iter, gpointer /*search_data*/) { - gboolean match = FALSE; - gchar *text; - gtk_tree_model_get (model, iter, STORE_TEXT_COL, &text, -1); + gchar *text = 0; + gtk_tree_model_get(model, iter, STORE_TEXT_COL, &text, -1); - match = (strstr(text, key) != NULL); + gboolean match = (strstr(text, key) != NULL); g_free(text); -- cgit v1.2.3 From d46d124918afeb7a04da14b49ab5f605512c1189 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 12 Apr 2012 01:14:09 -0700 Subject: Shortcut patch. Fixes bug #974531 Fixed bugs: - https://launchpad.net/bugs/974531 (bzr r11232) --- src/shortcuts.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index fe1d31331..aab55327d 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -60,8 +61,8 @@ sp_shortcut_invoke(unsigned int shortcut, Inkscape::UI::View::View *view) return false; } -static GHashTable *verbs = NULL; -static GHashTable *primary_shortcuts = NULL; +static std::map *verbs = NULL; +static std::map *primary_shortcuts = NULL; static void sp_shortcut_init() @@ -71,8 +72,8 @@ sp_shortcut_init() using Inkscape::IO::Resource::USER; using Inkscape::IO::Resource::KEYS; - verbs = g_hash_table_new(NULL, NULL); - primary_shortcuts = g_hash_table_new(NULL, NULL); + verbs = new std::map(); + primary_shortcuts = new std::map(); read_shortcuts_file(get_path(SYSTEM, KEYS, "default.xml")); try_shortcuts_file(get_path(USER, KEYS, "default.xml")); @@ -175,20 +176,20 @@ sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool co { if (!verbs) sp_shortcut_init(); - Inkscape::Verb *old_verb = (Inkscape::Verb *)(g_hash_table_lookup(verbs, GINT_TO_POINTER(shortcut))); - g_hash_table_insert(verbs, GINT_TO_POINTER(shortcut), (gpointer)(verb)); + Inkscape::Verb *old_verb = (*verbs)[shortcut]; + (*verbs)[shortcut] = verb; /* Maintain the invariant that sp_shortcut_get_primary(v) returns either 0 or a valid shortcut for v. */ if (old_verb && old_verb != verb) { - unsigned int const old_primary = (unsigned int)GPOINTER_TO_INT(g_hash_table_lookup(primary_shortcuts, (gpointer)old_verb)); + unsigned int const old_primary = (*primary_shortcuts)[old_verb]; if (old_primary == shortcut) { - g_hash_table_insert(primary_shortcuts, (gpointer)old_verb, GINT_TO_POINTER(0)); + (*primary_shortcuts)[old_verb] = 0; } } if (is_primary) { - g_hash_table_insert(primary_shortcuts, (gpointer)(verb), GINT_TO_POINTER(shortcut)); + (*primary_shortcuts)[verb] = shortcut; } } @@ -196,7 +197,7 @@ Inkscape::Verb * sp_shortcut_get_verb(unsigned int shortcut) { if (!verbs) sp_shortcut_init(); - return (Inkscape::Verb *)(g_hash_table_lookup(verbs, GINT_TO_POINTER(shortcut))); + return (*verbs)[shortcut]; } unsigned int sp_shortcut_get_primary(Inkscape::Verb *verb) @@ -205,9 +206,9 @@ unsigned int sp_shortcut_get_primary(Inkscape::Verb *verb) if (!primary_shortcuts) { sp_shortcut_init(); } - gpointer value = 0; - if (g_hash_table_lookup_extended(primary_shortcuts, static_cast(verb), NULL, &value)) { - result = static_cast(GPOINTER_TO_INT(value)); + + if (primary_shortcuts->count(verb)) { + result = (*primary_shortcuts)[verb]; } return result; } -- cgit v1.2.3 From 3a46bcf8a2f0eeb1cfb2064ef9fabe9452092f9c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 12 Apr 2012 10:58:11 +0100 Subject: Replace deprecated GTK_TYPE macros (bzr r11233) --- src/widgets/paint-selector.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index d97f79cd4..3f34c8ad1 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -167,7 +167,7 @@ sp_paint_selector_class_init(SPPaintSelectorClass *klass) G_STRUCT_OFFSET(SPPaintSelectorClass, mode_changed), NULL, NULL, g_cclosure_marshal_VOID__UINT, - G_TYPE_NONE, 1, GTK_TYPE_UINT); + G_TYPE_NONE, 1, G_TYPE_UINT); psel_signals[GRABBED] = g_signal_new("grabbed", G_TYPE_FROM_CLASS(object_class), (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), @@ -202,7 +202,7 @@ sp_paint_selector_class_init(SPPaintSelectorClass *klass) G_STRUCT_OFFSET(SPPaintSelectorClass, fillrule_changed), NULL, NULL, g_cclosure_marshal_VOID__UINT, - G_TYPE_NONE, 1, GTK_TYPE_UINT); + G_TYPE_NONE, 1, G_TYPE_UINT); object_class->destroy = sp_paint_selector_destroy; } -- cgit v1.2.3 From ba5269e29bf844fe52429f8549b65d716d942ac4 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 13 Apr 2012 19:54:11 +0200 Subject: Translation. More disambiguations (see Bug #832560). Fixed bugs: - https://launchpad.net/bugs/832560 (bzr r11234) --- src/ui/dialog/inkscape-preferences.cpp | 2 +- src/ui/widget/selected-style.cpp | 4 ++-- src/ui/widget/style-swatch.cpp | 4 ++-- src/verbs.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 6d76f5784..b038ae60d 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -363,7 +363,7 @@ void InkscapePreferences::initPageTools() AddGradientCheckbox(_page_zoom, "/tools/zoom", false); //Measure - this->AddPage(_page_measure, _("Measure"), iter_tools, PREFS_PAGE_TOOLS_MEASURE); + this->AddPage(_page_measure, C_("Measurement tool", "Measure"), iter_tools, PREFS_PAGE_TOOLS_MEASURE); PrefCheckButton* cb = Gtk::manage( new PrefCheckButton); cb->init ( _("Ignore first and last points"), "/tools/measure/ignore_1st_and_last", true); _page_measure.add_line( false, "", *cb, "", _("The start and end of the measurement tool's control line will not be considered for calculating lengths. Only lengths between actual curve intersections will be displayed.")); diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index faf518bbd..c81385dd7 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -164,10 +164,10 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _na[i].show_all(); __na[i] = (_("Nothing selected")); - _none[i].set_markup (_("None")); + _none[i].set_markup (C_("Fill and stroke", "None")); sp_set_font_size_smaller (GTK_WIDGET(_none[i].gobj())); _none[i].show_all(); - __none[i] = (i == SS_FILL)? (_("No fill")) : (_("No stroke")); + __none[i] = (i == SS_FILL)? (C_("Fill and stroke", "No fill")) : (C_("Fill and stroke", "No stroke")); _pattern[i].set_markup (_("Pattern")); sp_set_font_size_smaller (GTK_WIDGET(_pattern[i].gobj())); diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 0ecf2dd5e..1ee26e803 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -298,9 +298,9 @@ StyleSwatch::setStyle(SPStyle *query) place->set_tooltip_text(tip); g_free (tip); } else if (paint->set && paint->isNone()) { - _value[i].set_markup(_("None")); + _value[i].set_markup(C_("Fill and stroke", "None")); place->add(_value[i]); - place->set_tooltip_text((i == SS_FILL)? (_("No fill")) : (_("No stroke"))); + place->set_tooltip_text((i == SS_FILL)? (C_("Fill and stroke", "No fill")) : (C_("Fill and stroke", "No stroke"))); if (i == SS_STROKE) has_stroke = false; } else if (!paint->set) { _value[i].set_markup(_("Unset")); diff --git a/src/verbs.cpp b/src/verbs.cpp index 913cec837..d4ac35b33 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -2510,7 +2510,7 @@ Verb *Verb::_base_verbs[] = { N_("Create and edit gradients"), INKSCAPE_ICON("color-gradient")), new ContextVerb(SP_VERB_CONTEXT_ZOOM, "ToolZoom", N_("Zoom"), N_("Zoom in or out"), INKSCAPE_ICON("zoom")), - new ContextVerb(SP_VERB_CONTEXT_MEASURE, "ToolMeasure", N_("Measure"), + new ContextVerb(SP_VERB_CONTEXT_MEASURE, "ToolMeasure", NC_("Measurement tool", "Measure"), N_("Measurement tool"), INKSCAPE_ICON("tool-measure")), new ContextVerb(SP_VERB_CONTEXT_DROPPER, "ToolDropper", N_("Dropper"), N_("Pick colors from image"), INKSCAPE_ICON("color-picker")), -- cgit v1.2.3 From 864951e00cebcb82f40e487f4aa262c0065ec66b Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 13 Apr 2012 20:57:14 +0200 Subject: better memleak fix than rev. 11148 (bzr r11236) --- src/ui/dialog/export.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 649645aff..bb49d195c 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -974,14 +974,9 @@ void Export::onExport () } else { - gchar const *filename = g_strdup(filename_entry.get_text().c_str()); + Glib::ustring filename = filename_entry.get_text(); - if (filename == NULL){ - sp_ui_error_dialog(_("You have to enter a filename")); - return; - } - if(*filename == '\0') { - g_free (const_cast(filename)); + if (filename.empty()){ sp_ui_error_dialog(_("You have to enter a filename")); return; } @@ -996,13 +991,12 @@ void Export::onExport () unsigned long int const height = int(getValue(bmheight_adj) + 0.5); if (!((x1 > x0) && (y1 > y0) && (width > 0) && (height > 0))) { - g_free (const_cast(filename)); sp_ui_error_dialog (_("The chosen area to be exported is invalid")); return; } // make sure that .png is the extension of the file: - gchar * filename_ext = filename_add_extension(filename, "png"); + gchar * filename_ext = filename_add_extension(filename.c_str(), "png"); filename_entry.set_text(filename_ext); gchar *path = absolutize_path_from_document_location(doc, filename_ext); @@ -1099,7 +1093,7 @@ void Export::onExport () for(; reprlst != NULL; reprlst = reprlst->next) { Inkscape::XML::Node * repr = (Inkscape::XML::Node *)reprlst->data; const gchar * temp_string; - gchar *dir = g_path_get_dirname(filename); + gchar *dir = g_path_get_dirname(filename.c_str()); gchar *docdir = g_path_get_dirname(SP_ACTIVE_DOCUMENT->getURI()); if (repr->attribute("id") == NULL || @@ -1136,7 +1130,6 @@ void Export::onExport () break; } - g_free (const_cast(filename)); g_free (filename_ext); g_free (path); -- cgit v1.2.3 From 373c1189500bdde8e368e68aeac262e9f560c825 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 13 Apr 2012 21:31:13 +0200 Subject: probably this was intended (bzr r11237) --- src/ui/dialog/export.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index bb49d195c..f876b2339 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -1070,7 +1070,7 @@ void Export::onExport () modified = true; } temp_string = repr->attribute("inkscape:export-ydpi"); - if (temp_string == NULL || xdpi != atof(temp_string)) { + if (temp_string == NULL || ydpi != atof(temp_string)) { sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi); modified = true; } -- cgit v1.2.3 From 2a15ba95270445366925aa51c7f753e4353fa129 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 13 Apr 2012 21:39:12 +0200 Subject: probably this was intended (bzr r11238) --- src/ui/dialog/export.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index f876b2339..d2a51d8a7 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -1112,7 +1112,7 @@ void Export::onExport () modified = true; } temp_string = repr->attribute("inkscape:export-ydpi"); - if (temp_string == NULL || xdpi != atof(temp_string)) { + if (temp_string == NULL || ydpi != atof(temp_string)) { sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi); modified = true; } -- cgit v1.2.3 From b307246cda3ad55e4a00b596de964a492196c0fa Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 13 Apr 2012 23:42:28 +0200 Subject: small 2geom update (bzr r11239) --- src/2geom/d2-sbasis.cpp | 13 +++++++++++++ src/2geom/d2-sbasis.h | 5 +++++ src/live_effects/lpe-powerstroke.cpp | 15 --------------- 3 files changed, 18 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/2geom/d2-sbasis.cpp b/src/2geom/d2-sbasis.cpp index 7bfb7c6c5..486ada9a2 100644 --- a/src/2geom/d2-sbasis.cpp +++ b/src/2geom/d2-sbasis.cpp @@ -185,6 +185,19 @@ split_at_discontinuities (Geom::Piecewise > const & pwsbi return ret; } +Point unitTangentAt(D2 const & a, Coord t, unsigned n) +{ + std::vector derivs = a.valueAndDerivatives(t, n); + for (unsigned deriv_n = 1; deriv_n < derivs.size(); deriv_n++) { + Coord length = derivs[deriv_n].length(); + if ( ! are_near(length, 0) ) { + // length of derivative is non-zero, so return unit vector + return derivs[deriv_n] / length; + } + } + return Point (0,0); +} + static void set_first_point(Piecewise > &f, Point a){ if ( f.empty() ){ f.concat(Piecewise >(D2(Linear(a[X]),Linear(a[Y])))); diff --git a/src/2geom/d2-sbasis.h b/src/2geom/d2-sbasis.h index e61067e1b..965ec8746 100644 --- a/src/2geom/d2-sbasis.h +++ b/src/2geom/d2-sbasis.h @@ -83,6 +83,11 @@ std::vector > > fuse_nearby_ends(std::vector > > split_at_discontinuities (Geom::Piecewise > const & pwsbin, double tol = .0001); +/** +* note that -unitTangentAt(reverse(a),0.) == unitTangentAt(a,1.) but the former is more reliable (sometimes the sign is wrong for the latter) +*/ +Point unitTangentAt(D2 const & a, Coord t, unsigned n = 3); + class CoordIterator : public std::iterator { diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 79997ff94..281376cde 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -34,21 +34,6 @@ namespace Geom { // should all be moved to 2geom at some point -/** -* note that -unitTangentAt(reverse(a),0.) == unitTangentAt(a,1.) but the former is more reliable (sometimes the sign is wrong for the latter) -*/ -Point unitTangentAt( D2 const & a, Coord t, unsigned n = 3) { - std::vector derivs = a.valueAndDerivatives(t, n); - for (unsigned deriv_n = 1; deriv_n < derivs.size(); deriv_n++) { - Coord length = derivs[deriv_n].length(); - if ( ! are_near(length, 0) ) { - // length of derivative is non-zero, so return unit vector - return derivs[deriv_n] / length; - } - } - return Point (0,0); -} - /** Find the point where two straight lines cross. */ boost::optional intersection_point( Point const & origin_a, Point const & vector_a, -- cgit v1.2.3 From 515aa35ff30dbe8a84bd0941e2d5f49afba13814 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 13 Apr 2012 23:47:42 +0200 Subject: 2geom fix (bzr r11240) --- src/2geom/sbasis.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/2geom/sbasis.cpp b/src/2geom/sbasis.cpp index 6ba644b14..b56e03c74 100644 --- a/src/2geom/sbasis.cpp +++ b/src/2geom/sbasis.cpp @@ -643,9 +643,11 @@ SBasis compose_inverse(SBasis const &f, SBasis const &g, unsigned order, double Pk=Pk*sg; Qk=Qk*sg; - Pk.truncate(order); - Qk.truncate(order); - r.truncate(order); + + Pk.resize(order,Linear(0.)); // truncates if too high order, expands with zeros if too low + Qk.resize(order,Linear(0.)); + r.resize(order,Linear(0.)); + } result.normalize(); return result; -- cgit v1.2.3 From cc51441858513ed4596063086aa2581d1051a495 Mon Sep 17 00:00:00 2001 From: Veronika Irvine Date: Fri, 13 Apr 2012 16:32:19 -0700 Subject: support vertical text on path such that baseline is perpendiclar to the path and midline is centered on the path Fixed bugs: - https://launchpad.net/bugs/168862 (bzr r11241) --- src/libnrtype/Layout-TNG-OutIter.cpp | 16 ++++++++++---- src/libnrtype/Layout-TNG-Output.cpp | 43 ++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/libnrtype/Layout-TNG-OutIter.cpp b/src/libnrtype/Layout-TNG-OutIter.cpp index 1d300b210..4e61c10a0 100644 --- a/src/libnrtype/Layout-TNG-OutIter.cpp +++ b/src/libnrtype/Layout-TNG-OutIter.cpp @@ -446,6 +446,8 @@ void Layout::queryCursorShape(iterator const &it, Geom::Point &position, double } else { span = &_spans[_characters[it._char_index].in_span]; x = _chunks[span->in_chunk].left_x + span->x_start + _characters[it._char_index].x - _chunks[0].left_x; + if (_directions_are_orthogonal(_blockProgression(), TOP_TO_BOTTOM)) + x -= span->line_height.descent; if (it._char_index != 0) span = &_spans[_characters[it._char_index - 1].in_span]; } @@ -454,7 +456,7 @@ void Layout::queryCursorShape(iterator const &it, Geom::Point &position, double if (x_on_path < 0.0) x_on_path = 0.0; int unused = 0; - // as far as I know these functions are const, they're just not marked as such + // as far as I know these functions are const, they're just not marked as such Path::cut_position *path_parameter_list = const_cast(_path_fitted)->CurvilignToPosition(1, &x_on_path, unused); Path::cut_position path_parameter; if (path_parameter_list != NULL && path_parameter_list[0].piece >= 0) @@ -472,9 +474,15 @@ void Layout::queryCursorShape(iterator const &it, Geom::Point &position, double point += x * tangent; if (x > path_length ) point += (x - path_length) * tangent; - rotation = atan2(tangent); - position[Geom::X] = point[Geom::X] - tangent[Geom::Y] * span->baseline_shift; - position[Geom::Y] = point[Geom::Y] + tangent[Geom::X] * span->baseline_shift; + if (_directions_are_orthogonal(_blockProgression(), TOP_TO_BOTTOM)) { + rotation = atan2(-tangent[Geom::X], tangent[Geom::Y]); + position[Geom::X] = point[Geom::Y] - tangent[Geom::X] * span->baseline_shift; + position[Geom::Y] = point[Geom::X] + tangent[Geom::Y] * span->baseline_shift; + } else { + rotation = atan2(tangent); + position[Geom::X] = point[Geom::X] - tangent[Geom::Y] * span->baseline_shift; + position[Geom::Y] = point[Geom::Y] + tangent[Geom::X] * span->baseline_shift; + } } else { // text is not on a path if (it._char_index >= _characters.size()) { diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 07ed6062f..2830a8026 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -426,16 +426,21 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path) Geom::Point tangent; const_cast(path).PointAndTangentAt(point_otp[0].piece, point_otp[0].t, point, tangent); _empty_cursor_shape.position = point; - _empty_cursor_shape.rotation = atan2(tangent[Geom::Y], tangent[Geom::X]); + if (_directions_are_orthogonal(_blockProgression(), TOP_TO_BOTTOM)) { + _empty_cursor_shape.rotation = atan2(-tangent[Geom::X], tangent[Geom::Y]); + } else { + _empty_cursor_shape.rotation = atan2(tangent[Geom::Y], tangent[Geom::X]); + } } } for (unsigned char_index = 0 ; char_index < _characters.size() ; ) { - int next_cluster_glyph_index; + unsigned current_cluster_glyph_index, next_cluster_glyph_index; unsigned next_cluster_char_index; - double character_advance; Span const &span = _characters[char_index].span(this); + current_cluster_glyph_index = _characters[char_index].in_glyph; + for (next_cluster_char_index = char_index + 1 ; next_cluster_char_index < _characters.size() ; next_cluster_char_index++) { if (_characters[next_cluster_char_index].in_glyph != -1 && _characters[next_cluster_char_index].char_attributes.is_cursor_position) break; @@ -443,17 +448,15 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path) if (next_cluster_char_index == _characters.size()) { next_cluster_glyph_index = _glyphs.size(); - character_advance = 0.0; // arbitrary because we're not going to advance } else { next_cluster_glyph_index = _characters[next_cluster_char_index].in_glyph; - character_advance = (_glyphs[next_cluster_glyph_index].x + _glyphs[next_cluster_glyph_index].chunk(this).left_x) - - (_glyphs[_characters[char_index].in_glyph].x + span.chunk(this).left_x); } double start_offset = offset + span.x_start + _characters[char_index].x; double cluster_width = 0.0; - for (int glyph_index = _characters[char_index].in_glyph ; glyph_index < next_cluster_glyph_index ; glyph_index++) + for (int glyph_index = current_cluster_glyph_index ; glyph_index < next_cluster_glyph_index ; glyph_index++) cluster_width += _glyphs[glyph_index].width; + // TODO block progression? if (span.direction == RIGHT_TO_LEFT) start_offset -= cluster_width; double end_offset = start_offset + cluster_width; @@ -499,15 +502,23 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path) } } - double rotation = atan2(tangent[1], tangent[0]); - for (int glyph_index = _characters[char_index].in_glyph ; glyph_index < next_cluster_glyph_index ; glyph_index++) { - double tangent_shift = -cluster_width * 0.5 + _glyphs[glyph_index].x - (_characters[char_index].x + span.x_start); - double normal_shift = _glyphs[glyph_index].y; - if (span.direction == RIGHT_TO_LEFT) - tangent_shift += cluster_width; - _glyphs[glyph_index].x = midpoint[0] - span.chunk(this).left_x + tangent[0] * tangent_shift - tangent[1] * normal_shift; - _glyphs[glyph_index].y = midpoint[1] - _lines.front().baseline_y + tangent[1] * tangent_shift + tangent[0] * normal_shift; - _glyphs[glyph_index].rotation += rotation; + if (_directions_are_orthogonal(_blockProgression(), TOP_TO_BOTTOM)) { + double rotation = atan2(-tangent[Geom::X], tangent[Geom::Y]); + for (int glyph_index = current_cluster_glyph_index; glyph_index < next_cluster_glyph_index ; glyph_index++) { + _glyphs[glyph_index].x = midpoint[Geom::Y] - tangent[Geom::X] * _glyphs[glyph_index].y - span.chunk(this).left_x; + _glyphs[glyph_index].y = midpoint[Geom::X] + tangent[Geom::Y] * _glyphs[glyph_index].y - _lines.front().baseline_y; + _glyphs[glyph_index].rotation += rotation; + } + } else { + double rotation = atan2(tangent[Geom::Y], tangent[Geom::X]); + for (int glyph_index = current_cluster_glyph_index; glyph_index < next_cluster_glyph_index ; glyph_index++) { + double tangent_shift = -cluster_width * 0.5 + _glyphs[glyph_index].x - (_characters[char_index].x + span.x_start); + if (span.direction == RIGHT_TO_LEFT) + tangent_shift += cluster_width; + _glyphs[glyph_index].x = midpoint[Geom::X] + tangent[Geom::X] * tangent_shift - tangent[Geom::Y] * _glyphs[glyph_index].y - span.chunk(this).left_x; + _glyphs[glyph_index].y = midpoint[Geom::Y] + tangent[Geom::Y] * tangent_shift + tangent[Geom::X] * _glyphs[glyph_index].y - _lines.front().baseline_y; + _glyphs[glyph_index].rotation += rotation; + } } _input_truncated = false; } else { // outside the bounds of the path: hide the glyphs -- cgit v1.2.3 From 3d79d9ab8bd1474edc119e3a715e44dbfc2546ae Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 14 Apr 2012 12:31:29 +0100 Subject: Workaround for gtkmm build issue with dbus API (bzr r11243) --- src/extension/dbus/document-interface.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index dc1c8402d..c67234b34 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -15,6 +15,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "file.h" //IO #include "document-interface.h" #include #include @@ -39,8 +40,6 @@ #include "sp-root.h" #include "style.h" //style_write -#include "file.h" //IO - #include "extension/system.h" //IO #include "extension/output.h" //IO -- cgit v1.2.3 From aec93fbf715a45afea3c1314af869c240759be9e Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 14 Apr 2012 14:50:00 +0100 Subject: Add --enable-gtk3-experimental build + use external GDL if possible (bzr r11244) --- src/Makefile.am | 10 +++++++++- src/libgdl/Makefile_insert | 43 +++++++++++++++++++++++++++++++++++++++++++ src/ui/widget/dock-item.h | 4 ++++ 3 files changed, 56 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 2ab4d0030..c27af0800 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,12 +19,18 @@ bin_PROGRAMS = inkscape inkview #if WITH_INKBOARD #libpedro = pedro/libpedro.a #endif + +if !WITH_EXT_GDL +internal_GDL = libgdl/libgdl.a +endif + + noinst_LIBRARIES = \ libinkscape.a \ dom/libdom.a \ libcroco/libcroco.a \ libavoid/libavoid.a \ - libgdl/libgdl.a \ + $(internal_GDL) \ libcola/libcola.a \ libvpsc/libvpsc.a \ livarot/libvarot.a \ @@ -46,6 +52,7 @@ all_libs = \ $(INKBOARD_LIBS) \ $(LIBWPG_LIBS) \ $(DBUS_LIBS) \ + $(GDL_LIBS) \ $(IMAGEMAGICK_LIBS) # Add sources common for Inkscape and Inkview to this variable. @@ -68,6 +75,7 @@ INCLUDES = \ $(INKBOARD_CFLAGS) \ $(LIBWPG_CFLAGS) \ $(DBUS_CFLAGS) \ + $(GDL_CFLAGS) \ $(XFT_CFLAGS) \ $(LCMS_CFLAGS) \ $(POPPLER_CFLAGS) \ diff --git a/src/libgdl/Makefile_insert b/src/libgdl/Makefile_insert index e151fd5d6..788df0673 100644 --- a/src/libgdl/Makefile_insert +++ b/src/libgdl/Makefile_insert @@ -1,5 +1,46 @@ ## Makefile.am fragment sourced by src/Makefile.am. +if WITH_EXT_GDL + +EXTRA_DIST += \ + libgdl/gdl-tools.h \ + libgdl/gdl-dock-object.h \ + libgdl/gdl-dock-master.h \ + libgdl/gdl-dock.h \ + libgdl/gdl-dock-item.h \ + libgdl/gdl-dock-notebook.h \ + libgdl/gdl-dock-paned.h \ + libgdl/gdl-dock-tablabel.h \ + libgdl/gdl-dock-placeholder.h \ + libgdl/gdl-dock-bar.h \ + libgdl/gdl-stock-icons.h \ + libgdl/gdl-i18n.h \ + libgdl/gdl-i18n.c \ + libgdl/gdl-dock-object.c \ + libgdl/gdl-dock-master.c \ + libgdl/gdl-dock.c \ + libgdl/gdl-dock-item.c \ + libgdl/gdl-dock-item-button-image.c \ + libgdl/gdl-dock-item-button-image.h \ + libgdl/gdl-dock-item-grip.h \ + libgdl/gdl-dock-item-grip.c \ + libgdl/gdl-dock-notebook.c \ + libgdl/gdl-dock-paned.c \ + libgdl/gdl-dock-tablabel.c \ + libgdl/gdl-dock-placeholder.c \ + libgdl/gdl-dock-bar.c \ + libgdl/gdl-switcher.h \ + libgdl/gdl-switcher.c \ + libgdl/gdl-win32.h \ + libgdl/gdl-win32.c \ + libgdl/libgdltypebuiltins.h \ + libgdl/libgdltypebuiltins.c \ + libgdl/libgdlmarshal.h \ + libgdl/libgdlmarshal.c \ + libgdl/gdl.h + +else # WITH_EXT_GDL + libgdl/all: libgdl/libgdl.a libgdl/clean: @@ -41,3 +82,5 @@ libgdl_libgdl_a_SOURCES = \ libgdl/libgdlmarshal.h \ libgdl/libgdlmarshal.c \ libgdl/gdl.h + +endif diff --git a/src/ui/widget/dock-item.h b/src/ui/widget/dock-item.h index 75ffea1a0..608badb62 100644 --- a/src/ui/widget/dock-item.h +++ b/src/ui/widget/dock-item.h @@ -15,7 +15,11 @@ #include #include +#if WITH_EXT_GDL +#include +#else #include "libgdl/gdl.h" +#endif namespace Gtk { class HButtonBox; -- cgit v1.2.3 From 4c5b63b1dc102d1675bd24d264d974b71af8eea0 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 14 Apr 2012 15:56:38 +0200 Subject: more c++ification in export dialog / fixing warning for in case of new and unsaved document (bzr r11245) --- src/ui/dialog/export.cpp | 101 ++++++++++++++++++++++------------------------- src/ui/dialog/export.h | 4 +- 2 files changed, 49 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index d2a51d8a7..f28757734 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -8,8 +8,9 @@ * Johan Engelen * Jon A. Cruz * Abhishek Sharma + * Kris De Gussem * - * Copyright (C) 1999-2007 Authors + * Copyright (C) 1999-2007, 2012 Authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -822,8 +823,7 @@ unsigned int Export::onProgressCallback (float value, void *data) } // end of sp_export_progress_callback() -GtkWidget * Export::create_progress_dialog (gchar *progress_text) { - +GtkWidget * Export::create_progress_dialog (Glib::ustring progress_text) { GtkWidget *dlg, *prg, *btn; /* progressbar dlg widgets */ dlg = gtk_dialog_new (); @@ -836,7 +836,7 @@ GtkWidget * Export::create_progress_dialog (gchar *progress_text) { gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE); g_object_set_data ((GObject *) base, "progress", prg); - gtk_progress_bar_set_text ((GtkProgressBar *) prg, progress_text); + gtk_progress_bar_set_text ((GtkProgressBar *) prg, progress_text.c_str()); gtk_progress_bar_set_orientation ( (GtkProgressBar *) prg, GTK_PROGRESS_LEFT_TO_RIGHT); @@ -857,26 +857,26 @@ GtkWidget * Export::create_progress_dialog (gchar *progress_text) { } // FIXME: Some lib function should be available to do this ... -gchar * Export::filename_add_extension (const gchar *filename, const gchar *extension) +Glib::ustring Export::filename_add_extension (Glib::ustring filename, Glib::ustring extension) { - const gchar *dot; - - dot = strrchr (filename, '.'); - if ( !dot ) - return g_strconcat (filename, ".", extension, NULL); - { - if (dot[1] == '\0') - return g_strconcat (filename, extension, NULL); + Glib::ustring::size_type dot; + + dot = filename.find_last_of("."); + if ( !dot ) + { + return filename = filename + "." + extension; + } else { - if (g_ascii_strcasecmp (dot + 1, extension) == 0) - return g_strdup (filename); - else - { - return g_strconcat (filename, ".", extension, NULL); - } - } - } + if (dot==filename.find_last_of(Glib::ustring::compose(".", extension))) + { + return filename; + } + else + { + return filename = filename + "." + extension; + } + } } gchar *Export::absolutize_path_from_document_location (SPDocument *doc, const gchar *filename) @@ -908,24 +908,22 @@ void Export::onExport () if (batch_export.get_active ()) { // Batch export of selected objects - gint num = g_slist_length((GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList()); + gint num = g_slist_length(const_cast(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList())); gint n = 0; if (num < 1) return; - gchar *progress_text = g_strdup_printf (_("Exporting %d files"), num); - GtkWidget *prog_dlg = create_progress_dialog (progress_text); - g_free (progress_text); + GtkWidget *prog_dlg = create_progress_dialog (Glib::ustring::compose(_("Exporting %1 files"),num)); - for (GSList *i = (GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList(); + for (GSList *i = const_cast(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList()); i != NULL; i = i->next) { SPItem *item = reinterpret_cast(i->data); // retrieve export filename hint const gchar *filename = item->getRepr()->attribute("inkscape:export-filename"); - gchar *path = 0; + gchar *path = NULL; if (!filename) { path = create_filepath_from_id(item->getId(), NULL); } else { @@ -953,7 +951,7 @@ void Export::onExport () *area, width, height, dpi, dpi, nv->pagecolor, NULL, NULL, TRUE, // overwrite without asking - hide ? (GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList() : NULL + hide ? const_cast(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList()) : NULL )) { gchar * error; gchar * safeFile = Inkscape::IO::sanitizeString(path); @@ -996,10 +994,9 @@ void Export::onExport () } // make sure that .png is the extension of the file: - gchar * filename_ext = filename_add_extension(filename.c_str(), "png"); + Glib::ustring const filename_ext = filename_add_extension(filename, "png"); filename_entry.set_text(filename_ext); - - gchar *path = absolutize_path_from_document_location(doc, filename_ext); + gchar *path = absolutize_path_from_document_location(doc, filename_ext.c_str()); gchar *dirname = g_path_get_dirname(path); if ( dirname == NULL @@ -1018,18 +1015,16 @@ void Export::onExport () g_free(dirname); gchar *fn = g_path_get_basename (path); - gchar *progress_text = g_strdup_printf (_("Exporting %s (%lu x %lu)"), fn, width, height); + GtkWidget *prog_dlg = create_progress_dialog (Glib::ustring::compose(_("Exporting %1 (%2 x %3)"), fn, width, height)); g_free (fn); - GtkWidget *prog_dlg = create_progress_dialog (progress_text); - g_free (progress_text); /* Do export */ if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), path, Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi, nv->pagecolor, onProgressCallback, prog_dlg, FALSE, - hide ? (GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList() : NULL + hide ? const_cast(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList()) : NULL )) { gchar * error; gchar * safeFile = Inkscape::IO::sanitizeString(path); @@ -1042,12 +1037,13 @@ void Export::onExport () /* Reset the filename so that it can be changed again by changing selections and all that */ g_free(original_name); - original_name = g_strdup(filename_ext); + original_name = const_cast(filename_ext.c_str()); filename_modified = false; gtk_widget_destroy (prog_dlg); //g_object_set_data (G_OBJECT (base), "cancel", (gpointer) 0); + /* Setup the values in the document */ switch (current_key) { case SELECTION_PAGE: @@ -1060,8 +1056,8 @@ void Export::onExport () DocumentUndo::setUndoSensitive(doc, false); gchar const *temp_string = repr->attribute("inkscape:export-filename"); - if (temp_string == NULL || strcmp(temp_string, filename_ext)) { - repr->setAttribute("inkscape:export-filename", filename_ext); + if (temp_string == NULL || (filename_ext != temp_string)) { + repr->setAttribute("inkscape:export-filename", filename_ext.c_str()); modified = true; } temp_string = repr->attribute("inkscape:export-xdpi"); @@ -1091,18 +1087,22 @@ void Export::onExport () reprlst = sp_desktop_selection(SP_ACTIVE_DESKTOP)->reprList(); for(; reprlst != NULL; reprlst = reprlst->next) { - Inkscape::XML::Node * repr = (Inkscape::XML::Node *)reprlst->data; + Inkscape::XML::Node * repr = static_cast(reprlst->data); const gchar * temp_string; - gchar *dir = g_path_get_dirname(filename.c_str()); - gchar *docdir = g_path_get_dirname(SP_ACTIVE_DOCUMENT->getURI()); - + Glib::ustring dir = Glib::path_get_dirname(filename.c_str()); + const gchar* docURI=SP_ACTIVE_DOCUMENT->getURI(); + Glib::ustring docdir; + if (docURI) + { + docdir = Glib::path_get_dirname(docURI); + } if (repr->attribute("id") == NULL || - !(g_strrstr(filename_ext, repr->attribute("id")) != NULL && - ( !SP_ACTIVE_DOCUMENT->getURI() || - strcmp(dir, docdir) == 0))) { + !(filename_ext.find_last_of(repr->attribute("id")) && + ( !docURI || + (dir == docdir)))) { temp_string = repr->attribute("inkscape:export-filename"); - if (temp_string == NULL || strcmp(temp_string, filename_ext)) { - repr->setAttribute("inkscape:export-filename", filename_ext); + if (temp_string == NULL || (filename_ext != temp_string)) { + repr->setAttribute("inkscape:export-filename", filename_ext.c_str()); modified = true; } } @@ -1116,8 +1116,6 @@ void Export::onExport () sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi); modified = true; } - g_free(dir); - g_free(docdir); } DocumentUndo::setUndoSensitive(doc, saved); @@ -1129,10 +1127,7 @@ void Export::onExport () default: break; } - - g_free (filename_ext); g_free (path); - } } // end of sp_export_export_clicked() @@ -1799,10 +1794,8 @@ void Export::onFilenameModified() { if (strcmp(original_name, filename_entry.get_text().c_str())==0) { filename_modified = false; -// g_message("Modified: FALSE\n"); } else { filename_modified = true; -// g_message("Modified: TRUE\n"); } return; diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h index 1277f06f5..348a3e0e3 100644 --- a/src/ui/dialog/export.h +++ b/src/ui/dialog/export.h @@ -190,7 +190,7 @@ private: /** * Progress dialog callbacks */ - GtkWidget * create_progress_dialog (gchar *progress_text); + GtkWidget * create_progress_dialog (Glib::ustring progress_text); static unsigned int onProgressCallback (float value, void *data); static void onProgressCancel ( GtkWidget *widget, GObject *base ); static gint onProgressDelete ( GtkWidget *widget, GdkEvent *event, GObject *base ); @@ -200,7 +200,7 @@ private: */ void set_default_filename (); gchar* create_filepath_from_id (const gchar *id, const gchar *file_entry_text); - gchar *filename_add_extension (const gchar *filename, const gchar *extension); + Glib::ustring filename_add_extension (Glib::ustring filename, Glib::ustring extension); gchar *absolutize_path_from_document_location (SPDocument *doc, const gchar *filename); /* -- cgit v1.2.3 From ad33db6e13cd1aab4b26a4a4732607899323cadd Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 14 Apr 2012 16:10:45 +0200 Subject: export dialog: type fix (bzr r11246) --- src/ui/dialog/export.cpp | 4 ++-- src/ui/dialog/export.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index f28757734..060a10f63 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -351,7 +351,7 @@ void Export::setTargetDesktop(SPDesktop *desktop) subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &Export::onSelectionChanged))); //// Must check flags, so can't call widget_setup() directly. - selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &Export::onSelectioModified))); + selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &Export::onSelectionModified))); } //widget_setup(); } @@ -607,7 +607,7 @@ void Export::onSelectionChanged() updateCheckbuttons (); } -void Export::onSelectioModified ( guint /*flags*/ ) +void Export::onSelectionModified ( guint /*flags*/ ) { switch (current_key) { case SELECTION_DRAWING: diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h index 348a3e0e3..51b969b5e 100644 --- a/src/ui/dialog/export.h +++ b/src/ui/dialog/export.h @@ -170,7 +170,7 @@ private: * Inkscape selection change callback */ void onSelectionChanged (); - void onSelectioModified (guint flags); + void onSelectionModified (guint flags); /** * Filename modified callback -- cgit v1.2.3 From 10cd24ae4da25d86677622f847e6962cecf718d0 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 14 Apr 2012 17:22:15 +0200 Subject: powerstroke: more robust method of determining parameters at joins. should fix some bugs. (may introduce new ones...) (bzr r11247) --- src/live_effects/lpe-powerstroke.cpp | 89 ++++++++---------------------------- 1 file changed, 18 insertions(+), 71 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 281376cde..a9cf22f6a 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -205,47 +205,8 @@ static bool compare_offsets (Geom::Point first, Geom::Point second) return first[Geom::X] < second[Geom::X]; } -// find discontinuities in input path -struct discontinuity_data { - Geom::Point der0; // unit derivative of 'left' side of join - Geom::Point der1; // unit derivative of 'right' side of join - double width; // intended stroke width at join -}; -std::vector find_discontinuities( Geom::Piecewise > const & der, - Geom::Piecewise const & x, - Geom::Piecewise const & y, - double eps=Geom::EPSILON ) -{ - std::vector vect; - for(unsigned i = 1; i < der.size(); i++) { - if ( ! are_near(der[i-1].at1(), der[i].at0(), eps) ) { - discontinuity_data data; - - data.der0 = der[i-1].at1(); - data.der1 = der[i].at0(); - if ( Geom::are_near(data.der0.length(), 0) ) { - data.der0 = -unitTangentAt(reverse(der[i-1]),0.,2); // == unitTangentAt(der[i-1], 1, 2); - } - if ( Geom::are_near(data.der1.length(), 0) ) { - data.der1 = unitTangentAt(der[i], 0, 2); - } - - double t = der.cuts[i]; - std::vector< double > rts = roots (x - t); /// @todo this has multiple solutions for general strokewidth paths (generated by spiro interpolator...), ignore for now - if (!rts.empty()) { - data.width = y(rts.front()); - } else { - data.width = 1; - } - vect.push_back(data); - } - } - return vect; -} - - Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise > const & B, - std::vector const & cusps, + Geom::Piecewise const & y, // width path LineJoinType jointype, double miter_limit, bool forward_direction, @@ -258,9 +219,6 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise return pb.peek().front(); } - double sign = forward_direction ? 1. : -1.; - - unsigned int cusp_i = forward_direction ? 0 : cusps.size()-1; Geom::Point start = B[0].at0(); pb.moveTo(start); build_from_sbasis(pb, B[0], tol, false); @@ -273,9 +231,12 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise } if (!are_near(B[prev_i].at1(), B[i].at0(), tol) ) { // discontinuity found, so fix it :-) - discontinuity_data cusp = cusps[cusp_i]; + double width = y( B.cuts[i] ); - bool on_outside = ( sign*cusp.width*angle_between(cusp.der0, cusp.der1) < 0. ); + Geom::Point tang1 = -unitTangentAt(reverse(B[prev_i]),0.); // = unitTangentAt(B[prev_i],1); + Geom::Point tang2 = unitTangentAt(B[i],0); + Geom::Point discontinuity_vec = B[i].at0() - B[prev_i].at1(); + bool on_outside = ( dot(tang1, discontinuity_vec) >= 0. ); switch (jointype) { case LINEJOIN_ROUND: { @@ -289,8 +250,6 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise A 2Geom method was created to do exactly this :) */ - Geom::Point tang1 = -unitTangentAt(reverse(B[prev_i]),0.); // = unitTangentAt(B[prev_i],1); - Geom::Point tang2 = unitTangentAt(B[i],0); boost::optional O = intersection_point( B[prev_i].at1(), tang1, B[i].at0(), tang2 ); if (!O) { @@ -301,7 +260,7 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise Geom::Ellipse ellipse = find_ellipse(B[prev_i].at1(), B[i].at0(), *O); pb.arcTo( ellipse.ray(Geom::X), ellipse.ray(Geom::Y), ellipse.rot_angle(), - false, cusp.width < 0, B[i].at0() ); + false, width < 0, B[i].at0() ); } else { // we are on the inside, do a simple bevel to connect the paths pb.lineTo(B[i].at0()); // default to bevel for too shallow cusp angles @@ -311,8 +270,7 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise /* case LINEJOIN_NONE: { if ( on_outside ) { // we are on the outside - Geom::Point der1 = -unitTangentAt(reverse(B[prev_i]),0.); // = unitTangentAt(B[prev_i],1); - Geom::Point point_on_path = B[prev_i].at1() - rot90(der1) * cusp.width; + Geom::Point point_on_path = B[prev_i].at1() - rot90(tang1) * width; pb.lineTo(point_on_path); pb.lineTo(B[i].at0()); } else { @@ -324,13 +282,10 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise if (on_outside) { // we are on the outside, do something complicated to make it look good ;) - Geom::Point der1 = -unitTangentAt(reverse(B[prev_i]),0.); // = unitTangentAt(B[prev_i],1); - Geom::Point der2 = unitTangentAt(B[i],0); - - Geom::D2 newcurve1 = B[prev_i] * Geom::reflection(rot90(der1), B[prev_i].at1()); + Geom::D2 newcurve1 = B[prev_i] * Geom::reflection(rot90(tang1), B[prev_i].at1()); Geom::CubicBezier bzr1 = sbasis_to_cubicbezier( reverse(newcurve1) ); - Geom::D2 newcurve2 = B[i] * Geom::reflection(rot90(der2), B[i].at0()); + Geom::D2 newcurve2 = B[i] * Geom::reflection(rot90(tang2), B[i].at0()); Geom::CubicBezier bzr2 = sbasis_to_cubicbezier( reverse(newcurve2) ); Geom::Crossings cross = crossings(bzr1, bzr2); @@ -339,9 +294,9 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise pb.lineTo(B[i].at0()); } else { // check size of miter - Geom::Point point_on_path = B[prev_i].at1() - rot90(der1) * cusp.width; + Geom::Point point_on_path = B[prev_i].at1() - rot90(tang1) * width; Geom::Coord len = distance(bzr1.pointAt(cross[0].ta), point_on_path); - if (len > fabs(cusp.width) * miter_limit) { + if (len > fabs(width) * miter_limit) { // miter too big: default to bevel pb.lineTo(B[i].at0()); } else { @@ -362,15 +317,13 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise if (on_outside) { // we are on the outside, do something complicated to make it look good ;) - Geom::Point der1 = -unitTangentAt(reverse(B[prev_i]),0.); // = unitTangentAt(B[prev_i],1); - Geom::Point der2 = unitTangentAt(B[i],0); - boost::optional p = intersection_point( B[prev_i].at1(), der1, - B[i].at0(), der2 ); + boost::optional p = intersection_point( B[prev_i].at1(), tang1, + B[i].at0(), tang2 ); if (p) { // check size of miter - Geom::Point point_on_path = B[prev_i].at1() - rot90(der1) * cusp.width; + Geom::Point point_on_path = B[prev_i].at1() - rot90(tang1) * width; Geom::Coord len = distance(*p, point_on_path); - if (len <= fabs(cusp.width) * miter_limit) { + if (len <= fabs(width) * miter_limit) { // miter OK pb.lineTo(*p); } @@ -384,9 +337,6 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise } case LINEJOIN_SPIRO: { if (on_outside) { - Geom::Point tang1 = -unitTangentAt(reverse(B[prev_i]),0.); // = unitTangentAt(B[prev_i],1); - Geom::Point tang2 = unitTangentAt(B[i],0); - Geom::Point direction = B[i].at0() - B[prev_i].at1(); double tang1_sign = dot(direction,tang1); double tang2_sign = dot(direction,tang2); @@ -419,8 +369,6 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise pb.lineTo(B[i].at0()); break; } - - cusp_i += forward_direction ? 1 : -1; } build_from_sbasis(pb, B[i], tol, false); prev_i = i; @@ -491,14 +439,13 @@ LPEPowerStroke::doEffect_path (std::vector const & path_in) y = portion(y, rtsmin.at(0), rtsmax.at(0)); } - std::vector cusps = find_discontinuities(der, x, y); LineJoinType jointype = static_cast(linejoin_type.get_value()); Piecewise > pwd2_out = compose(pwd2_in,x) + y*compose(n,x); Piecewise > mirrorpath = reverse(compose(pwd2_in,x) - y*compose(n,x)); - Geom::Path fixed_path = path_from_piecewise_fix_cusps( pwd2_out, cusps, jointype, miter_limit, true, LPE_CONVERSION_TOLERANCE); - Geom::Path fixed_mirrorpath = path_from_piecewise_fix_cusps( mirrorpath, cusps, jointype, miter_limit, false, LPE_CONVERSION_TOLERANCE); + Geom::Path fixed_path = path_from_piecewise_fix_cusps( pwd2_out, y, jointype, miter_limit, LPE_CONVERSION_TOLERANCE); + Geom::Path fixed_mirrorpath = path_from_piecewise_fix_cusps( mirrorpath, reverse(y), jointype, miter_limit, LPE_CONVERSION_TOLERANCE); if (path_in[0].closed()) { fixed_path.close(true); -- cgit v1.2.3 From d7d0b532bab6acd4d9ebf3480257de7945a26626 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 14 Apr 2012 21:12:19 +0100 Subject: Migrate align & dist dialog to Gtk::Grid API (bzr r11248) --- src/ui/dialog/align-and-distribute.cpp | 45 ++++++++++++++++++++++++++++++++-- src/ui/dialog/align-and-distribute.h | 25 +++++++++++++++++-- 2 files changed, 66 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 062384b52..f8d63aade 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -50,6 +50,7 @@ #include + namespace Inkscape { namespace UI { namespace Dialog { @@ -61,7 +62,11 @@ public : Action(const Glib::ustring &id, const Glib::ustring &tiptext, guint row, guint column, - Gtk::Table &parent, +#if WITH_GTKMM_3_0 + Gtk::Grid &parent, +#else + Gtk::Table &parent, +#endif AlignAndDistribute &dialog): _dialog(dialog), _id(id), @@ -77,7 +82,11 @@ public : pButton->signal_clicked() .connect(sigc::mem_fun(*this, &Action::on_button_click)); pButton->set_tooltip_text(tiptext); +#if WITH_GTKMM_3_0 + parent.attach(*pButton, column, row, 1, 1); +#else parent.attach(*pButton, column, column+1, row, row+1, Gtk::FILL, Gtk::FILL); +#endif } virtual ~Action(){} @@ -87,7 +96,12 @@ private : virtual void on_button_click(){} Glib::ustring _id; + +#if WITH_GTKMM_3_0 + Gtk::Grid &_parent; +#else Gtk::Table &_parent; +#endif }; @@ -462,7 +476,11 @@ public: Action(id, tiptext, row, column + 4, dialog.removeOverlap_table(), dialog) { +#if WITH_GTKMM_3_0 + dialog.removeOverlap_table().set_column_spacing(3); +#else dialog.removeOverlap_table().set_col_spacings(3); +#endif removeOverlapXGap.set_digits(1); removeOverlapXGap.set_size_request(60, -1); @@ -484,11 +502,17 @@ public: removeOverlapYGapLabel.set_text_with_mnemonic(C_("Gap", "_V:")); removeOverlapYGapLabel.set_mnemonic_widget(removeOverlapYGap); +#if WITH_GTKMM_3_0 + dialog.removeOverlap_table().attach(removeOverlapXGapLabel, column, row, 1, 1); + dialog.removeOverlap_table().attach(removeOverlapXGap, column+1, row, 1, 1); + dialog.removeOverlap_table().attach(removeOverlapYGapLabel, column+2, row, 1, 1); + dialog.removeOverlap_table().attach(removeOverlapYGap, column+3, row, 1, 1); +#else dialog.removeOverlap_table().attach(removeOverlapXGapLabel, column, column+1, row, row+1, Gtk::FILL, Gtk::FILL); dialog.removeOverlap_table().attach(removeOverlapXGap, column+1, column+2, row, row+1, Gtk::FILL, Gtk::FILL); dialog.removeOverlap_table().attach(removeOverlapYGapLabel, column+2, column+3, row, row+1, Gtk::FILL, Gtk::FILL); dialog.removeOverlap_table().attach(removeOverlapYGap, column+3, column+4, row, row+1, Gtk::FILL, Gtk::FILL); - +#endif } private : @@ -769,7 +793,11 @@ public : guint row, guint column, AlignAndDistribute &dialog, +#if WITH_GTKMM_3_0 + Gtk::Grid &table, +#else Gtk::Table &table, +#endif Geom::Dim2 orientation, bool distribute): Action(id, tiptext, row, column, table, dialog), @@ -896,11 +924,19 @@ AlignAndDistribute::AlignAndDistribute() _rearrangeFrame(_("Rearrange")), _removeOverlapFrame(_("Remove overlaps")), _nodesFrame(_("Nodes")), +#if WITH_GTKMM_3_0 + _alignTable(), + _distributeTable(), + _rearrangeTable(), + _removeOverlapTable(), + _nodesTable(), +#else _alignTable(2, 6, true), _distributeTable(2, 6, true), _rearrangeTable(1, 5, false), _removeOverlapTable(1, 5, false), _nodesTable(1, 4, true), +#endif _anchorLabel(_("Relative to: ")), _selgrpLabel(_("_Treat selection as group: "), 1) { @@ -1238,8 +1274,13 @@ void AlignAndDistribute::addRandomizeButton(const Glib::ustring &id, const Glib: ); } +#if WITH_GTKMM_3_0 +void AlignAndDistribute::addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, + guint row, guint col, Gtk::Grid &table, Geom::Dim2 orientation, bool distribute) +#else void AlignAndDistribute::addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col, Gtk::Table &table, Geom::Dim2 orientation, bool distribute) +#endif { _actionList.push_back( new ActionBaseline( diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index 8cbd48f28..7edf9c30c 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -19,11 +19,15 @@ #include "ui/widget/panel.h" #include #include -#include #include - #include "2geom/rect.h" +#if WITH_GTKMM_3_0 +#include +#include +#else +#include +#endif class SPItem; @@ -45,11 +49,19 @@ public: AlignTarget getAlignTarget() const; +#if WITH_GTKMM_3_0 + Gtk::Grid &align_table(){return _alignTable;} + Gtk::Grid &distribute_table(){return _distributeTable;} + Gtk::Grid &rearrange_table(){return _rearrangeTable;} + Gtk::Grid &removeOverlap_table(){return _removeOverlapTable;} + Gtk::Grid &nodes_table(){return _nodesTable;} +#else Gtk::Table &align_table(){return _alignTable;} Gtk::Table &distribute_table(){return _distributeTable;} Gtk::Table &rearrange_table(){return _rearrangeTable;} Gtk::Table &removeOverlap_table(){return _removeOverlapTable;} Gtk::Table &nodes_table(){return _nodesTable;} +#endif std::list::iterator find_master(std::list &list, bool horizontal); void setMode(bool nodeEdit); @@ -86,12 +98,21 @@ protected: guint row, guint col); void addRandomizeButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col); +#if WITH_GTKMM_3_0 + void addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, + guint row, guint col, Gtk::Grid &table, Geom::Dim2 orientation, bool distribute); +#else void addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col, Gtk::Table &table, Geom::Dim2 orientation, bool distribute); +#endif std::list _actionList; Gtk::Frame _alignFrame, _distributeFrame, _rearrangeFrame, _removeOverlapFrame, _nodesFrame; +#if WITH_GTKMM_3_0 + Gtk::Grid _alignTable, _distributeTable, _rearrangeTable, _removeOverlapTable, _nodesTable; +#else Gtk::Table _alignTable, _distributeTable, _rearrangeTable, _removeOverlapTable, _nodesTable; +#endif Gtk::HBox _anchorBox; Gtk::HBox _selgrpBox; Gtk::VBox _alignBox; -- cgit v1.2.3 From 0024197c76bca50d557edc2824646a636d695c4d Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 15 Apr 2012 01:17:25 +0100 Subject: Get rid of remaining deprecated GDK Key symbols (bzr r11250) --- src/desktop-events.cpp | 80 ++++++++++-- src/dialogs/dialog-events.cpp | 107 +++++++++++++++- src/draw-context.cpp | 78 +++++++++++- src/ege-adjustment-action.cpp | 100 ++++++++++++--- src/event-context.cpp | 157 +++++++++++++++++------ src/flood-context.cpp | 95 +++++++++++++- src/inkview.cpp | 143 ++++++++++++++++++--- src/interface.cpp | 98 ++++++++++++++- src/interface.h | 4 + src/main.cpp | 13 +- src/pencil-context.cpp | 8 +- src/shortcuts.cpp | 10 +- src/spray-context.cpp | 148 +++++++++++++++++----- src/text-context.cpp | 217 +++++++++++++++++++++++--------- src/ui/dialog/xml-tree.cpp | 9 +- src/ui/tool/control-point-selection.cpp | 147 ++++++++++++++++++---- src/ui/tool/control-point.cpp | 12 +- src/ui/tool/multi-path-manipulator.cpp | 179 ++++++++++++++++++++------ src/ui/tool/node-tool.cpp | 18 ++- src/ui/tool/node.cpp | 17 ++- src/ui/tool/selector.cpp | 6 +- src/ui/widget/spinbutton.cpp | 12 +- src/verbs.cpp | 9 +- src/widgets/toolbox.cpp | 6 +- 24 files changed, 1407 insertions(+), 266 deletions(-) (limited to 'src') diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index b16cebee2..68b372d99 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -47,6 +47,72 @@ #include "widgets/desktop-widget.h" #include "xml/repr.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#endif + using Inkscape::DocumentUndo; static void snoop_extended(GdkEvent* event, SPDesktop *desktop); @@ -478,9 +544,9 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) break; case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_Delete: - case GDK_KP_Delete: - case GDK_BackSpace: + case GDK_KEY_Delete: + case GDK_KEY_KP_Delete: + case GDK_KEY_BackSpace: { SPDocument *doc = guide->document; sp_guide_remove(guide); @@ -489,8 +555,8 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) sp_event_context_discard_delayed_snap_event(desktop->event_context); break; } - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: if (drag_type != SP_DRAG_MOVE_ORIGIN) { GdkCursor *guide_cursor; guide_cursor = gdk_cursor_new (GDK_EXCHANGE); @@ -511,8 +577,8 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) break; case GDK_KEY_RELEASE: switch (get_group0_keyval (&event->key)) { - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: GdkCursor *guide_cursor; guide_cursor = gdk_cursor_new (GDK_EXCHANGE); gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor); diff --git a/src/dialogs/dialog-events.cpp b/src/dialogs/dialog-events.cpp index f8fce8bd7..70899d4d7 100644 --- a/src/dialogs/dialog-events.cpp +++ b/src/dialogs/dialog-events.cpp @@ -27,6 +27,105 @@ #include "dialog-events.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_VoidSymbol 0xffffff +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Page_Up 0xff55 +#define GDK_KEY_KP_Page_Up 0xff9a +#define GDK_KEY_Page_Down 0xff56 +#define GDK_KEY_KP_Page_Down 0xff9b +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_b 0x062 +#define GDK_KEY_B 0x042 +#define GDK_KEY_d 0x064 +#define GDK_KEY_D 0x044 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_i 0x069 +#define GDK_KEY_I 0x049 +#define GDK_KEY_j 0x06a +#define GDK_KEY_J 0x04a +#define GDK_KEY_k 0x06b +#define GDK_KEY_K 0x04b +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_q 0x071 +#define GDK_KEY_Q 0x051 +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_w 0x077 +#define GDK_KEY_W 0x057 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_F1 0xffbe +#define GDK_KEY_F2 0xffbf +#define GDK_KEY_F3 0xffc0 +#define GDK_KEY_F4 0xffc1 +#define GDK_KEY_F5 0xffc2 +#define GDK_KEY_F6 0xffc3 +#define GDK_KEY_F7 0xffc4 +#define GDK_KEY_F8 0xffc5 +#define GDK_KEY_F9 0xffc6 +#define GDK_KEY_F10 0xffc7 +#define GDK_KEY_F11 0xffc8 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_KP_Space 0xff80 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#define GDK_KEY_KP_Add 0xffab +#define GDK_KEY_KP_Subtract 0xffad +#endif + /** * Remove focus from window to whoever it is transient for. @@ -105,13 +204,13 @@ sp_dialog_event_handler (GtkWindow *win, GdkEvent *event, gpointer data) case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_Escape: + case GDK_KEY_Escape: sp_dialog_defocus (win); ret = TRUE; break; - case GDK_F4: - case GDK_w: - case GDK_W: + case GDK_KEY_F4: + case GDK_KEY_w: + case GDK_KEY_W: // close dialog if (MOD__CTRL_ONLY) { diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 36d7eb8de..d8ce2729d 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -45,6 +45,76 @@ #include +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Page_Up 0xff55 +#define GDK_KEY_KP_Page_Up 0xff9a +#define GDK_KEY_Page_Down 0xff56 +#define GDK_KEY_KP_Page_Down 0xff9b +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#endif + using Inkscape::DocumentUndo; static void sp_draw_context_class_init(SPDrawContextClass *klass); @@ -240,10 +310,10 @@ sp_draw_context_root_handler(SPEventContext *ec, GdkEvent *event) switch (event->type) { case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: // prevent the zoom field from activation if (!MOD__CTRL_ONLY) { ret = TRUE; diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 47500c8c4..181d63d8f 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -48,6 +48,76 @@ #include "icon-size.h" #include "ege-adjustment-action.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Page_Up 0xff55 +#define GDK_KEY_KP_Page_Up 0xff9a +#define GDK_KEY_Page_Down 0xff56 +#define GDK_KEY_KP_Page_Down 0xff9b +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#endif + static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass ); static void ege_adjustment_action_init( EgeAdjustmentAction* action ); @@ -1025,7 +1095,7 @@ gboolean keypress_cb( GtkWidget *widget, GdkEventKey *event, gpointer data ) 0, &key, 0, 0, 0 ); switch ( key ) { - case GDK_Escape: + case GDK_KEY_Escape: { action->private_data->transferFocus = TRUE; gtk_spin_button_set_value( GTK_SPIN_BUTTON(widget), action->private_data->lastVal ); @@ -1034,8 +1104,8 @@ gboolean keypress_cb( GtkWidget *widget, GdkEventKey *event, gpointer data ) } break; - case GDK_Return: - case GDK_KP_Enter: + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: { action->private_data->transferFocus = TRUE; ege_adjustment_action_defocus( action ); @@ -1043,22 +1113,22 @@ gboolean keypress_cb( GtkWidget *widget, GdkEventKey *event, gpointer data ) } break; - case GDK_Tab: + case GDK_KEY_Tab: { action->private_data->transferFocus = FALSE; wasConsumed = process_tab( widget, 1 ); } break; - case GDK_ISO_Left_Tab: + case GDK_KEY_ISO_Left_Tab: { action->private_data->transferFocus = FALSE; wasConsumed = process_tab( widget, -1 ); } break; - case GDK_Up: - case GDK_KP_Up: + case GDK_KEY_Up: + case GDK_KEY_KP_Up: { action->private_data->transferFocus = FALSE; gdouble val = gtk_spin_button_get_value( GTK_SPIN_BUTTON(widget) ); @@ -1067,8 +1137,8 @@ gboolean keypress_cb( GtkWidget *widget, GdkEventKey *event, gpointer data ) } break; - case GDK_Down: - case GDK_KP_Down: + case GDK_KEY_Down: + case GDK_KEY_KP_Down: { action->private_data->transferFocus = FALSE; gdouble val = gtk_spin_button_get_value( GTK_SPIN_BUTTON(widget) ); @@ -1077,8 +1147,8 @@ gboolean keypress_cb( GtkWidget *widget, GdkEventKey *event, gpointer data ) } break; - case GDK_Page_Up: - case GDK_KP_Page_Up: + case GDK_KEY_Page_Up: + case GDK_KEY_KP_Page_Up: { action->private_data->transferFocus = FALSE; gdouble val = gtk_spin_button_get_value( GTK_SPIN_BUTTON(widget) ); @@ -1087,8 +1157,8 @@ gboolean keypress_cb( GtkWidget *widget, GdkEventKey *event, gpointer data ) } break; - case GDK_Page_Down: - case GDK_KP_Page_Down: + case GDK_KEY_Page_Down: + case GDK_KEY_KP_Page_Down: { action->private_data->transferFocus = FALSE; gdouble val = gtk_spin_button_get_value( GTK_SPIN_BUTTON(widget) ); @@ -1097,8 +1167,8 @@ gboolean keypress_cb( GtkWidget *widget, GdkEventKey *event, gpointer data ) } break; - case GDK_z: - case GDK_Z: + case GDK_KEY_z: + case GDK_KEY_Z: { action->private_data->transferFocus = FALSE; gtk_spin_button_set_value( GTK_SPIN_BUTTON(widget), action->private_data->lastVal ); diff --git a/src/event-context.cpp b/src/event-context.cpp index 3bf1179c8..db7b29640 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -64,6 +64,93 @@ #include "sp-guide.h" #include "color.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Page_Up 0xff55 +#define GDK_KEY_KP_Page_Up 0xff9a +#define GDK_KEY_Page_Down 0xff56 +#define GDK_KEY_KP_Page_Down 0xff9b +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_d 0x064 +#define GDK_KEY_D 0x044 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_q 0x071 +#define GDK_KEY_Q 0x051 +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_w 0x077 +#define GDK_KEY_W 0x057 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_F1 0xffbe +#define GDK_KEY_F2 0xffbf +#define GDK_KEY_F3 0xffc0 +#define GDK_KEY_F4 0xffc1 +#define GDK_KEY_F5 0xffc2 +#define GDK_KEY_F6 0xffc3 +#define GDK_KEY_F7 0xffc4 +#define GDK_KEY_F8 0xffc5 +#define GDK_KEY_F9 0xffc6 +#define GDK_KEY_F10 0xffc7 +#define GDK_KEY_F11 0xffc8 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#endif + static void sp_event_context_class_init(SPEventContextClass *klass); static void sp_event_context_init(SPEventContext *event_context); static void sp_event_context_dispose(GObject *object); @@ -558,9 +645,9 @@ static gint sp_event_context_private_root_handler( // in the editing window). So we resteal them back and run our regular shortcut // invoker on them. unsigned int shortcut; - case GDK_Tab: - case GDK_ISO_Left_Tab: - case GDK_F1: + case GDK_KEY_Tab: + case GDK_KEY_ISO_Left_Tab: + case GDK_KEY_F1: shortcut = get_group0_keyval(&event->key); if (event->key.state & GDK_SHIFT_MASK) shortcut |= SP_SHORTCUT_SHIFT_MASK; @@ -571,15 +658,15 @@ static gint sp_event_context_private_root_handler( ret = sp_shortcut_invoke(shortcut, desktop); break; - case GDK_D: - case GDK_d: + case GDK_KEY_D: + case GDK_KEY_d: if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) { sp_toggle_dropper(desktop); ret = TRUE; } break; - case GDK_Q: - case GDK_q: + case GDK_KEY_Q: + case GDK_KEY_q: if (desktop->quick_zoomed()) { ret = TRUE; } @@ -588,18 +675,18 @@ static gint sp_event_context_private_root_handler( ret = TRUE; } break; - case GDK_W: - case GDK_w: - case GDK_F4: + case GDK_KEY_W: + case GDK_KEY_w: + case GDK_KEY_F4: /* Close view */ if (MOD__CTRL_ONLY) { sp_ui_close_view(NULL); ret = TRUE; } break; - case GDK_Left: // Ctrl Left - case GDK_KP_Left: - case GDK_KP_4: + case GDK_KEY_Left: // Ctrl Left + case GDK_KEY_KP_Left: + case GDK_KEY_KP_4: if (MOD__CTRL_ONLY) { int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop))); @@ -608,9 +695,9 @@ static gint sp_event_context_private_root_handler( ret = TRUE; } break; - case GDK_Up: // Ctrl Up - case GDK_KP_Up: - case GDK_KP_8: + case GDK_KEY_Up: // Ctrl Up + case GDK_KEY_KP_Up: + case GDK_KEY_KP_8: if (MOD__CTRL_ONLY) { int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop))); @@ -619,9 +706,9 @@ static gint sp_event_context_private_root_handler( ret = TRUE; } break; - case GDK_Right: // Ctrl Right - case GDK_KP_Right: - case GDK_KP_6: + case GDK_KEY_Right: // Ctrl Right + case GDK_KEY_KP_Right: + case GDK_KEY_KP_6: if (MOD__CTRL_ONLY) { int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop))); @@ -630,9 +717,9 @@ static gint sp_event_context_private_root_handler( ret = TRUE; } break; - case GDK_Down: // Ctrl Down - case GDK_KP_Down: - case GDK_KP_2: + case GDK_KEY_Down: // Ctrl Down + case GDK_KEY_KP_Down: + case GDK_KEY_KP_2: if (MOD__CTRL_ONLY) { int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop))); @@ -641,13 +728,13 @@ static gint sp_event_context_private_root_handler( ret = TRUE; } break; - case GDK_F10: + case GDK_KEY_F10: if (MOD__SHIFT_ONLY) { sp_event_root_menu_popup(desktop, NULL, event); ret = TRUE; } break; - case GDK_space: + case GDK_KEY_space: if (prefs->getBool("/options/spacepans/value")) { event_context->space_panning = true; event_context->_message_context->set(Inkscape::INFORMATION_MESSAGE, @@ -658,8 +745,8 @@ static gint sp_event_context_private_root_handler( ret = TRUE; } break; - case GDK_z: - case GDK_Z: + case GDK_KEY_z: + case GDK_KEY_Z: if (MOD__ALT_ONLY) { desktop->zoom_grab_focus(); ret = TRUE; @@ -672,7 +759,7 @@ static gint sp_event_context_private_root_handler( break; case GDK_KEY_RELEASE: switch (get_group0_keyval(&event->key)) { - case GDK_space: + case GDK_KEY_space: if (event_context->space_panning) { event_context->space_panning = false; event_context->_message_context->clear(); @@ -685,8 +772,8 @@ static gint sp_event_context_private_root_handler( ret = TRUE; } break; - case GDK_Q: - case GDK_q: + case GDK_KEY_Q: + case GDK_KEY_q: if (desktop->quick_zoomed()) { desktop->zoom_quick(false); ret = TRUE; @@ -1074,12 +1161,12 @@ void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context, gchar const *alt_tip) { guint keyval = get_group0_keyval(&event->key); - bool ctrl = ctrl_tip && (MOD__CTRL || (keyval == GDK_Control_L) || (keyval - == GDK_Control_R)); - bool shift = shift_tip && (MOD__SHIFT || (keyval == GDK_Shift_L) || (keyval - == GDK_Shift_R)); - bool alt = alt_tip && (MOD__ALT || (keyval == GDK_Alt_L) || (keyval - == GDK_Alt_R) || (keyval == GDK_Meta_L) || (keyval == GDK_Meta_R)); + bool ctrl = ctrl_tip && (MOD__CTRL || (keyval == GDK_KEY_Control_L) || (keyval + == GDK_KEY_Control_R)); + bool shift = shift_tip && (MOD__SHIFT || (keyval == GDK_KEY_Shift_L) || (keyval + == GDK_KEY_Shift_R)); + bool alt = alt_tip && (MOD__ALT || (keyval == GDK_KEY_Alt_L) || (keyval + == GDK_KEY_Alt_R) || (keyval == GDK_KEY_Meta_L) || (keyval == GDK_KEY_Meta_R)); gchar *tip = g_strdup_printf("%s%s%s%s%s", (ctrl ? ctrl_tip : ""), (ctrl && (shift || alt) ? "; " : ""), (shift ? shift_tip : ""), ((ctrl diff --git a/src/flood-context.cpp b/src/flood-context.cpp index c9f4a0097..7d798a93e 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -70,6 +70,93 @@ #include "pixmaps/cursor-paintbucket.xpm" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Page_Up 0xff55 +#define GDK_KEY_KP_Page_Up 0xff9a +#define GDK_KEY_Page_Down 0xff56 +#define GDK_KEY_KP_Page_Down 0xff9b +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_d 0x064 +#define GDK_KEY_D 0x044 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_q 0x071 +#define GDK_KEY_Q 0x051 +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_w 0x077 +#define GDK_KEY_W 0x057 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_F1 0xffbe +#define GDK_KEY_F2 0xffbf +#define GDK_KEY_F3 0xffc0 +#define GDK_KEY_F4 0xffc1 +#define GDK_KEY_F5 0xffc2 +#define GDK_KEY_F6 0xffc3 +#define GDK_KEY_F7 0xffc4 +#define GDK_KEY_F8 0xffc5 +#define GDK_KEY_F9 0xffc6 +#define GDK_KEY_F10 0xffc7 +#define GDK_KEY_F11 0xffc8 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#endif + using Inkscape::DocumentUndo; using Inkscape::Display::ExtractARGB32; @@ -1239,10 +1326,10 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven break; case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: // prevent the zoom field from activation if (!MOD__CTRL_ONLY) ret = TRUE; diff --git a/src/inkview.cpp b/src/inkview.cpp index 57963577c..76d12aa46 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -70,6 +70,115 @@ Inkscape::Application *inkscape; #define bind_textdomain_codeset(p,c) #endif +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_VoidSymbol 0xffffff +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Page_Up 0xff55 +#define GDK_KEY_KP_Page_Up 0xff9a +#define GDK_KEY_Page_Down 0xff56 +#define GDK_KEY_KP_Page_Down 0xff9b +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_b 0x062 +#define GDK_KEY_B 0x042 +#define GDK_KEY_c 0x063 +#define GDK_KEY_C 0x043 +#define GDK_KEY_d 0x064 +#define GDK_KEY_D 0x044 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_h 0x068 +#define GDK_KEY_H 0x048 +#define GDK_KEY_i 0x069 +#define GDK_KEY_I 0x049 +#define GDK_KEY_j 0x06a +#define GDK_KEY_J 0x04a +#define GDK_KEY_k 0x06b +#define GDK_KEY_K 0x04b +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_q 0x071 +#define GDK_KEY_Q 0x051 +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_v 0x076 +#define GDK_KEY_V 0x056 +#define GDK_KEY_w 0x077 +#define GDK_KEY_W 0x057 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_y 0x079 +#define GDK_KEY_Y 0x059 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_F1 0xffbe +#define GDK_KEY_F2 0xffbf +#define GDK_KEY_F3 0xffc0 +#define GDK_KEY_F4 0xffc1 +#define GDK_KEY_F5 0xffc2 +#define GDK_KEY_F6 0xffc3 +#define GDK_KEY_F7 0xffc4 +#define GDK_KEY_F8 0xffc5 +#define GDK_KEY_F9 0xffc6 +#define GDK_KEY_F10 0xffc7 +#define GDK_KEY_F11 0xffc8 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_KP_Space 0xff80 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_braceleft 0x07b +#define GDK_KEY_braceright 0x07d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#define GDK_KEY_KP_Add 0xffab +#define GDK_KEY_KP_Subtract 0xffad +#endif + extern char *optarg; extern int optind, opterr; @@ -117,15 +226,15 @@ static int sp_svgview_main_key_press (GtkWidget */*widget*/, GdkEventKey *event, struct SPSlideShow *ss) { switch (event->keyval) { - case GDK_Up: - case GDK_Home: + case GDK_KEY_Up: + case GDK_KEY_Home: sp_svgview_goto_first(ss); break; - case GDK_Down: - case GDK_End: + case GDK_KEY_Down: + case GDK_KEY_End: sp_svgview_goto_last(ss); break; - case GDK_F11: + case GDK_KEY_F11: #ifdef HAVE_GTK_WINDOW_FULLSCREEN if (ss->fullscreen) { gtk_window_unfullscreen (GTK_WINDOW(ss->window)); @@ -138,24 +247,24 @@ sp_svgview_main_key_press (GtkWidget */*widget*/, GdkEventKey *event, struct SPS std::cout<<"Your GTK+ does not support fullscreen mode. Upgrade to 2.2."< #include +#include +#include #include "inkscape-private.h" #include "extension/db.h" @@ -81,6 +83,94 @@ #include #include +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_VoidSymbol 0xffffff +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Page_Up 0xff55 +#define GDK_KEY_KP_Page_Up 0xff9a +#define GDK_KEY_Page_Down 0xff56 +#define GDK_KEY_KP_Page_Down 0xff9b +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_d 0x064 +#define GDK_KEY_D 0x044 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_q 0x071 +#define GDK_KEY_Q 0x051 +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_w 0x077 +#define GDK_KEY_W 0x057 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_F1 0xffbe +#define GDK_KEY_F2 0xffbf +#define GDK_KEY_F3 0xffc0 +#define GDK_KEY_F4 0xffc1 +#define GDK_KEY_F5 0xffc2 +#define GDK_KEY_F6 0xffc3 +#define GDK_KEY_F7 0xffc4 +#define GDK_KEY_F8 0xffc5 +#define GDK_KEY_F9 0xffc6 +#define GDK_KEY_F10 0xffc7 +#define GDK_KEY_F11 0xffc8 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#endif + using Inkscape::DocumentUndo; /* Drag and Drop */ @@ -415,7 +505,7 @@ sp_ui_dialog_title_string(Inkscape::Verb *verb, gchar *c) g_free(atitle); shortcut = sp_shortcut_get_primary(verb); - if (shortcut!=GDK_VoidSymbol) { + if (shortcut!=GDK_KEY_VoidSymbol) { gchar* key = sp_shortcut_get_label(shortcut); s = g_stpcpy(s, " ("); s = g_stpcpy(s, key); @@ -446,7 +536,7 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb if (!action) return NULL; shortcut = sp_shortcut_get_primary(verb); - if (shortcut!=GDK_VoidSymbol) { + if (shortcut!=GDK_KEY_VoidSymbol) { gchar* c = sp_shortcut_get_label(shortcut); #if GTK_CHECK_VERSION(3,0,0) GtkWidget *const hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 16); @@ -634,7 +724,7 @@ sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View * SPAction *action = (verb) ? verb->get_action(view) : 0; GtkWidget *item = gtk_check_menu_item_new(); - if (verb && shortcut!=GDK_VoidSymbol) { + if (verb && shortcut!=GDK_KEY_VoidSymbol) { gchar* c = sp_shortcut_get_label(shortcut); #if GTK_CHECK_VERSION(3,0,0) @@ -1601,7 +1691,7 @@ void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)// Gtk::ImageMenuItem *item = NULL; unsigned int shortcut = sp_shortcut_get_primary(verb); - if (shortcut!=GDK_VoidSymbol) { + if (shortcut!=GDK_KEY_VoidSymbol) { gchar* c = sp_shortcut_get_label(shortcut); Gtk::HBox *const hb = new Gtk::HBox (FALSE, 16); Gtk::Label *const name_lbl = new Gtk::Label(action->name, true); diff --git a/src/interface.h b/src/interface.h index 0751171e2..1ea13f639 100644 --- a/src/interface.h +++ b/src/interface.h @@ -24,6 +24,10 @@ class SPObject; class SPDesktop; class SPViewWidget; +namespace Gtk { +class SeparatorMenuItem; +} + namespace Inkscape { class Verb; diff --git a/src/main.cpp b/src/main.cpp index 4bf327284..7a5d15cb7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -117,6 +117,11 @@ #include +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#endif + enum { SP_ARG_NONE, SP_ARG_NOGUI, @@ -889,8 +894,8 @@ snooper(GdkEvent *event, gpointer /*data*/) { break; case GDK_KEY_PRESS: keyval = get_group0_keyval(&event->key); - if (keyval == GDK_Alt_L) altL_pressed = TRUE; - if (keyval == GDK_Alt_R) altR_pressed = TRUE; + if (keyval == GDK_KEY_Alt_L) altL_pressed = TRUE; + if (keyval == GDK_KEY_Alt_R) altR_pressed = TRUE; alt_pressed = alt_pressed || altL_pressed || altR_pressed; alt_pressed = alt_pressed || (event->button.state & GDK_MOD1_MASK); if (alt_pressed) @@ -900,8 +905,8 @@ snooper(GdkEvent *event, gpointer /*data*/) { break; case GDK_KEY_RELEASE: keyval = get_group0_keyval(&event->key); - if (keyval == GDK_Alt_L) altL_pressed = FALSE; - if (keyval == GDK_Alt_R) altR_pressed = FALSE; + if (keyval == GDK_KEY_Alt_L) altL_pressed = FALSE; + if (keyval == GDK_KEY_Alt_R) altR_pressed = FALSE; if (!altL_pressed && !altR_pressed) alt_pressed = FALSE; break; diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 03fa507de..6db7c8ae2 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -673,10 +673,10 @@ pencil_handle_key_release(SPPencilContext *const pc, guint const keyval, guint c { gint ret = FALSE; switch (keyval) { - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Meta_L: - case GDK_Meta_R: + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + case GDK_KEY_Meta_L: + case GDK_KEY_Meta_R: if (pc->state == SP_PENCIL_CONTEXT_SKETCH) { spdc_concat_colors_and_flush(pc, FALSE); pc->sketch_n = 0; diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index aab55327d..57fc59614 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -39,6 +39,10 @@ #include "xml/node-iterators.h" #include "xml/repr.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_VoidSymbol 0xffffff +#endif + using namespace Inkscape; static void sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool const is_primary); @@ -127,7 +131,7 @@ static void read_shortcuts_file(char const *filename) { } guint keyval=gdk_keyval_from_name(keyval_name); - if (keyval == GDK_VoidSymbol || keyval == 0) { + if (keyval == GDK_KEY_VoidSymbol || keyval == 0) { g_warning("Unknown keyval %s for %s", keyval_name, verb_name); continue; } @@ -202,7 +206,7 @@ sp_shortcut_get_verb(unsigned int shortcut) unsigned int sp_shortcut_get_primary(Inkscape::Verb *verb) { - unsigned int result = GDK_VoidSymbol; + unsigned int result = GDK_KEY_VoidSymbol; if (!primary_shortcuts) { sp_shortcut_init(); } @@ -225,7 +229,7 @@ gchar *sp_shortcut_get_label(unsigned int shortcut) * gtk_label_set_text_with_mnemonic(lbl, str). */ gchar *result = 0; - if (shortcut != GDK_VoidSymbol) { + if (shortcut != GDK_KEY_VoidSymbol) { result = gtk_accelerator_get_label( shortcut & (~SP_SHORTCUT_MODIFIER_MASK), static_cast( ((shortcut & SP_SHORTCUT_SHIFT_MASK) ? GDK_SHIFT_MASK : 0) | diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 89da66b8f..b10c486c7 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -72,6 +72,98 @@ #include #include +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_VoidSymbol 0xffffff +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Page_Up 0xff55 +#define GDK_KEY_KP_Page_Up 0xff9a +#define GDK_KEY_Page_Down 0xff56 +#define GDK_KEY_KP_Page_Down 0xff9b +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_d 0x064 +#define GDK_KEY_D 0x044 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_j 0x06a +#define GDK_KEY_J 0x04a +#define GDK_KEY_k 0x06b +#define GDK_KEY_K 0x04b +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_q 0x071 +#define GDK_KEY_Q 0x051 +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_w 0x077 +#define GDK_KEY_W 0x057 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_F1 0xffbe +#define GDK_KEY_F2 0xffbf +#define GDK_KEY_F3 0xffc0 +#define GDK_KEY_F4 0xffc1 +#define GDK_KEY_F5 0xffc2 +#define GDK_KEY_F6 0xffc3 +#define GDK_KEY_F7 0xffc4 +#define GDK_KEY_F8 0xffc5 +#define GDK_KEY_F9 0xffc6 +#define GDK_KEY_F10 0xffc7 +#define GDK_KEY_F11 0xffc8 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#endif + using Inkscape::DocumentUndo; using namespace std; @@ -796,29 +888,29 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_j: - case GDK_J: + case GDK_KEY_j: + case GDK_KEY_J: if (MOD__SHIFT_ONLY) { sp_spray_switch_mode(tc, SPRAY_MODE_COPY, MOD__SHIFT); ret = TRUE; } break; - case GDK_k: - case GDK_K: + case GDK_KEY_k: + case GDK_KEY_K: if (MOD__SHIFT_ONLY) { sp_spray_switch_mode(tc, SPRAY_MODE_CLONE, MOD__SHIFT); ret = TRUE; } break; - case GDK_l: - case GDK_L: + case GDK_KEY_l: + case GDK_KEY_L: if (MOD__SHIFT_ONLY) { sp_spray_switch_mode(tc, SPRAY_MODE_SINGLE_PATH, MOD__SHIFT); ret = TRUE; } break; - case GDK_Up: - case GDK_KP_Up: + case GDK_KEY_Up: + case GDK_KEY_KP_Up: if (!MOD__CTRL_ONLY) { tc->population += 0.01; if (tc->population > 1.0) { @@ -828,8 +920,8 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even ret = TRUE; } break; - case GDK_Down: - case GDK_KP_Down: + case GDK_KEY_Down: + case GDK_KEY_KP_Down: if (!MOD__CTRL_ONLY) { tc->population -= 0.01; if (tc->population < 0.0) { @@ -839,8 +931,8 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even ret = TRUE; } break; - case GDK_Right: - case GDK_KP_Right: + case GDK_KEY_Right: + case GDK_KEY_KP_Right: if (!MOD__CTRL_ONLY) { tc->width += 0.01; if (tc->width > 1.0) { @@ -852,8 +944,8 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even ret = TRUE; } break; - case GDK_Left: - case GDK_KP_Left: + case GDK_KEY_Left: + case GDK_KEY_KP_Left: if (!MOD__CTRL_ONLY) { tc->width -= 0.01; if (tc->width < 0.01) { @@ -864,33 +956,33 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even ret = TRUE; } break; - case GDK_Home: - case GDK_KP_Home: + case GDK_KEY_Home: + case GDK_KEY_KP_Home: tc->width = 0.01; desktop->setToolboxAdjustmentValue("altx-spray", tc->width * 100); sp_spray_update_area(tc); ret = TRUE; break; - case GDK_End: - case GDK_KP_End: + case GDK_KEY_End: + case GDK_KEY_KP_End: tc->width = 1.0; desktop->setToolboxAdjustmentValue("altx-spray", tc->width * 100); sp_spray_update_area(tc); ret = TRUE; break; - case GDK_x: - case GDK_X: + case GDK_KEY_x: + case GDK_KEY_X: if (MOD__ALT_ONLY) { desktop->setToolboxFocusTo("altx-spray"); ret = TRUE; } break; - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: sp_spray_update_cursor(tc, true); break; - case GDK_Control_L: - case GDK_Control_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: break; default: break; @@ -900,12 +992,12 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even case GDK_KEY_RELEASE: { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); switch (get_group0_keyval(&event->key)) { - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: sp_spray_update_cursor(tc, false); break; - case GDK_Control_L: - case GDK_Control_R: + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT); tc->_message_context->clear(); break; diff --git a/src/text-context.cpp b/src/text-context.cpp index 724c40aa8..c2a9b6a24 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -54,6 +54,105 @@ #include "xml/repr.h" #include +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_VoidSymbol 0xffffff +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Page_Up 0xff55 +#define GDK_KEY_KP_Page_Up 0xff9a +#define GDK_KEY_Page_Down 0xff56 +#define GDK_KEY_KP_Page_Down 0xff9b +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_b 0x062 +#define GDK_KEY_B 0x042 +#define GDK_KEY_d 0x064 +#define GDK_KEY_D 0x044 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_i 0x069 +#define GDK_KEY_I 0x049 +#define GDK_KEY_j 0x06a +#define GDK_KEY_J 0x04a +#define GDK_KEY_k 0x06b +#define GDK_KEY_K 0x04b +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_q 0x071 +#define GDK_KEY_Q 0x051 +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_w 0x077 +#define GDK_KEY_W 0x057 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_F1 0xffbe +#define GDK_KEY_F2 0xffbf +#define GDK_KEY_F3 0xffc0 +#define GDK_KEY_F4 0xffc1 +#define GDK_KEY_F5 0xffc2 +#define GDK_KEY_F6 0xffc3 +#define GDK_KEY_F7 0xffc4 +#define GDK_KEY_F8 0xffc5 +#define GDK_KEY_F9 0xffc6 +#define GDK_KEY_F10 0xffc7 +#define GDK_KEY_F11 0xffc8 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_KP_Space 0xff80 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#define GDK_KEY_KP_Add 0xffab +#define GDK_KEY_KP_Subtract 0xffad +#endif + using Inkscape::DocumentUndo; static void sp_text_context_class_init(SPTextContextClass *klass); @@ -741,8 +840,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd case GDK_KEY_PRESS: { guint const group0_keyval = get_group0_keyval(&event->key); - if (group0_keyval == GDK_KP_Add || - group0_keyval == GDK_KP_Subtract) { + if (group0_keyval == GDK_KEY_KP_Add || + group0_keyval == GDK_KEY_KP_Subtract) { if (!(event->key.state & GDK_MOD2_MASK)) // mod2 is NumLock; if on, type +/- keys break; // otherwise pass on keypad +/- so they can zoom } @@ -765,8 +864,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd keyboard shortcuts), but differs from the ISO 14755 recommendation. */ switch (group0_keyval) { - case GDK_space: - case GDK_KP_Space: { + case GDK_KEY_space: + case GDK_KEY_KP_Space: { if (tc->unipos) { insert_uni_char(tc); } @@ -775,7 +874,7 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd return TRUE; } - case GDK_BackSpace: { + case GDK_KEY_BackSpace: { g_return_val_if_fail(tc->unipos < sizeof(tc->uni), TRUE); if (tc->unipos) { tc->uni[--tc->unipos] = '\0'; @@ -784,8 +883,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd return TRUE; } - case GDK_Return: - case GDK_KP_Enter: { + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: { if (tc->unipos) { insert_uni_char(tc); } @@ -795,7 +894,7 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd return TRUE; } - case GDK_Escape: { + case GDK_KEY_Escape: { // Cancel unimode. tc->unimode = false; gtk_im_context_reset(tc->imc); @@ -803,8 +902,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd return TRUE; } - case GDK_Shift_L: - case GDK_Shift_R: + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: break; default: { @@ -850,14 +949,14 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd /* Neither unimode nor IM consumed key; process text tool shortcuts */ switch (group0_keyval) { - case GDK_x: - case GDK_X: + case GDK_KEY_x: + case GDK_KEY_X: if (MOD__ALT_ONLY) { desktop->setToolboxFocusTo ("altx-text"); return TRUE; } break; - case GDK_space: + case GDK_KEY_space: if (MOD__CTRL_ONLY) { /* No-break space */ if (!tc->text) { // printable key; create text if none (i.e. if nascent_object) @@ -873,8 +972,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd return TRUE; } break; - case GDK_U: - case GDK_u: + case GDK_KEY_U: + case GDK_KEY_u: if (MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT)) { if (tc->unimode) { tc->unimode = false; @@ -890,8 +989,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd return TRUE; } break; - case GDK_B: - case GDK_b: + case GDK_KEY_B: + case GDK_KEY_b: if (MOD__CTRL_ONLY && tc->text) { SPStyle const *style = sp_te_style_at_position(tc->text, std::min(tc->text_sel_start, tc->text_sel_end)); SPCSSAttr *css = sp_repr_css_attr_new(); @@ -912,8 +1011,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd return TRUE; } break; - case GDK_I: - case GDK_i: + case GDK_KEY_I: + case GDK_KEY_i: if (MOD__CTRL_ONLY && tc->text) { SPStyle const *style = sp_te_style_at_position(tc->text, std::min(tc->text_sel_start, tc->text_sel_end)); SPCSSAttr *css = sp_repr_css_attr_new(); @@ -931,8 +1030,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } break; - case GDK_A: - case GDK_a: + case GDK_KEY_A: + case GDK_KEY_a: if (MOD__CTRL_ONLY && tc->text) { Inkscape::Text::Layout const *layout = te_get_layout(tc->text); if (layout) { @@ -945,8 +1044,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } break; - case GDK_Return: - case GDK_KP_Enter: + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: { if (!tc->text) { // printable key; create text if none (i.e. if nascent_object) sp_text_context_setup_text(tc); @@ -966,7 +1065,7 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd _("New line")); return TRUE; } - case GDK_BackSpace: + case GDK_KEY_BackSpace: if (tc->text) { // if nascent_object, do nothing, but return TRUE; same for all other delete and move keys bool noSelection = false; @@ -1000,8 +1099,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd _("Backspace")); } return TRUE; - case GDK_Delete: - case GDK_KP_Delete: + case GDK_KEY_Delete: + case GDK_KEY_KP_Delete: if (tc->text) { bool noSelection = false; @@ -1031,9 +1130,9 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd _("Delete")); } return TRUE; - case GDK_Left: - case GDK_KP_Left: - case GDK_KP_4: + case GDK_KEY_Left: + case GDK_KEY_KP_Left: + case GDK_KEY_KP_4: if (tc->text) { if (MOD__ALT) { gint mul = 1 + gobble_key_events( @@ -1056,9 +1155,9 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } } return TRUE; - case GDK_Right: - case GDK_KP_Right: - case GDK_KP_6: + case GDK_KEY_Right: + case GDK_KEY_KP_Right: + case GDK_KEY_KP_6: if (tc->text) { if (MOD__ALT) { gint mul = 1 + gobble_key_events( @@ -1081,9 +1180,9 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } } return TRUE; - case GDK_Up: - case GDK_KP_Up: - case GDK_KP_8: + case GDK_KEY_Up: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_8: if (tc->text) { if (MOD__ALT) { gint mul = 1 + gobble_key_events( @@ -1106,9 +1205,9 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } } return TRUE; - case GDK_Down: - case GDK_KP_Down: - case GDK_KP_2: + case GDK_KEY_Down: + case GDK_KEY_KP_Down: + case GDK_KEY_KP_2: if (tc->text) { if (MOD__ALT) { gint mul = 1 + gobble_key_events( @@ -1131,8 +1230,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } } return TRUE; - case GDK_Home: - case GDK_KP_Home: + case GDK_KEY_Home: + case GDK_KEY_KP_Home: if (tc->text) { if (MOD__CTRL) tc->text_sel_end.thisStartOfShape(); @@ -1142,8 +1241,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd break; } return TRUE; - case GDK_End: - case GDK_KP_End: + case GDK_KEY_End: + case GDK_KEY_KP_End: if (tc->text) { if (MOD__CTRL) tc->text_sel_end.nextStartOfShape(); @@ -1153,23 +1252,23 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd break; } return TRUE; - case GDK_Page_Down: - case GDK_KP_Page_Down: + case GDK_KEY_Page_Down: + case GDK_KEY_KP_Page_Down: if (tc->text) { tc->text_sel_end.cursorDown(screenlines); cursor_moved = true; break; } return TRUE; - case GDK_Page_Up: - case GDK_KP_Page_Up: + case GDK_KEY_Page_Up: + case GDK_KEY_KP_Page_Up: if (tc->text) { tc->text_sel_end.cursorUp(screenlines); cursor_moved = true; break; } return TRUE; - case GDK_Escape: + case GDK_KEY_Escape: if (tc->creating) { tc->creating = 0; if (tc->grabbed) { @@ -1182,7 +1281,7 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } tc->nascent_object = FALSE; return TRUE; - case GDK_bracketleft: + case GDK_KEY_bracketleft: if (tc->text) { if (MOD__ALT || MOD__CTRL) { if (MOD__ALT) { @@ -1203,7 +1302,7 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } } break; - case GDK_bracketright: + case GDK_KEY_bracketright: if (tc->text) { if (MOD__ALT || MOD__CTRL) { if (MOD__ALT) { @@ -1224,8 +1323,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } } break; - case GDK_less: - case GDK_comma: + case GDK_KEY_less: + case GDK_KEY_comma: if (tc->text) { if (MOD__ALT) { if (MOD__CTRL) { @@ -1249,8 +1348,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } } break; - case GDK_greater: - case GDK_period: + case GDK_KEY_greater: + case GDK_KEY_period: if (tc->text) { if (MOD__ALT) { if (MOD__CTRL) { @@ -1291,13 +1390,13 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } else return TRUE; // return the "I took care of it" value if it was consumed by the IM } else { // do nothing if there's no object to type in - the key will be sent to parent context, // except up/down that are swallowed to prevent the zoom field from activation - if ((group0_keyval == GDK_Up || - group0_keyval == GDK_Down || - group0_keyval == GDK_KP_Up || - group0_keyval == GDK_KP_Down ) + if ((group0_keyval == GDK_KEY_Up || + group0_keyval == GDK_KEY_Down || + group0_keyval == GDK_KEY_KP_Up || + group0_keyval == GDK_KEY_KP_Down ) && !MOD__CTRL_ONLY) { return TRUE; - } else if (group0_keyval == GDK_Escape) { // cancel rubberband + } else if (group0_keyval == GDK_KEY_Escape) { // cancel rubberband if (tc->creating) { tc->creating = 0; if (tc->grabbed) { @@ -1306,7 +1405,7 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } Inkscape::Rubberband::get(desktop)->stop(); } - } else if ((group0_keyval == GDK_x || group0_keyval == GDK_X) && MOD__ALT_ONLY) { + } else if ((group0_keyval == GDK_KEY_x || group0_keyval == GDK_KEY_X) && MOD__ALT_ONLY) { desktop->setToolboxFocusTo ("altx-text"); return TRUE; } diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 20460474b..5c39a2b22 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -48,6 +48,11 @@ #include "widgets/sp-xmlview-content.h" #include "widgets/sp-xmlview-tree.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Return 0xff0d +#endif + namespace Inkscape { namespace UI { namespace Dialog { @@ -334,7 +339,7 @@ bool XmlTree::sp_xml_tree_key_press(GdkEventKey *event) /* fixme: if you need to add more xml-tree-specific callbacks, you should probably upgrade * the sp_shortcut mechanism to take into account windows. */ - if (shortcut == (SP_SHORTCUT_CONTROL_MASK | GDK_Return)) { + if (shortcut == (SP_SHORTCUT_CONTROL_MASK | GDK_KEY_Return)) { cmd_set_attr(); return true; } @@ -839,7 +844,7 @@ void XmlTree::on_document_uri_set(gchar const * /*uri*/, SPDocument * /*document gboolean XmlTree::quit_on_esc (GtkWidget *w, GdkEventKey *event, GObject */*tbl*/) { switch (get_group0_keyval (event)) { - case GDK_Escape: // defocus + case GDK_KEY_Escape: // defocus gtk_widget_destroy(w); return TRUE; } diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index a44fde3be..e4899691a 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -21,6 +21,109 @@ #include +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_VoidSymbol 0xffffff +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Page_Up 0xff55 +#define GDK_KEY_KP_Page_Up 0xff9a +#define GDK_KEY_Page_Down 0xff56 +#define GDK_KEY_KP_Page_Down 0xff9b +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_b 0x062 +#define GDK_KEY_B 0x042 +#define GDK_KEY_d 0x064 +#define GDK_KEY_D 0x044 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_h 0x068 +#define GDK_KEY_H 0x048 +#define GDK_KEY_i 0x069 +#define GDK_KEY_I 0x049 +#define GDK_KEY_j 0x06a +#define GDK_KEY_J 0x04a +#define GDK_KEY_k 0x06b +#define GDK_KEY_K 0x04b +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_q 0x071 +#define GDK_KEY_Q 0x051 +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_v 0x076 +#define GDK_KEY_V 0x056 +#define GDK_KEY_w 0x077 +#define GDK_KEY_W 0x057 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_F1 0xffbe +#define GDK_KEY_F2 0xffbf +#define GDK_KEY_F3 0xffc0 +#define GDK_KEY_F4 0xffc1 +#define GDK_KEY_F5 0xffc2 +#define GDK_KEY_F6 0xffc3 +#define GDK_KEY_F7 0xffc4 +#define GDK_KEY_F8 0xffc5 +#define GDK_KEY_F9 0xffc6 +#define GDK_KEY_F10 0xffc7 +#define GDK_KEY_F11 0xffc8 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_KP_Space 0xff80 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#define GDK_KEY_KP_Add 0xffab +#define GDK_KEY_KP_Subtract 0xffad +#endif + namespace Inkscape { namespace UI { @@ -593,43 +696,43 @@ bool ControlPointSelection::event(SPEventContext * /*event_context*/, GdkEvent * switch(shortcut_key(event->key)) { // moves - case GDK_Up: - case GDK_KP_Up: - case GDK_KP_8: + case GDK_KEY_Up: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_8: return _keyboardMove(event->key, Geom::Point(0, 1)); - case GDK_Down: - case GDK_KP_Down: - case GDK_KP_2: + case GDK_KEY_Down: + case GDK_KEY_KP_Down: + case GDK_KEY_KP_2: return _keyboardMove(event->key, Geom::Point(0, -1)); - case GDK_Right: - case GDK_KP_Right: - case GDK_KP_6: + case GDK_KEY_Right: + case GDK_KEY_KP_Right: + case GDK_KEY_KP_6: return _keyboardMove(event->key, Geom::Point(1, 0)); - case GDK_Left: - case GDK_KP_Left: - case GDK_KP_4: + case GDK_KEY_Left: + case GDK_KEY_KP_Left: + case GDK_KEY_KP_4: return _keyboardMove(event->key, Geom::Point(-1, 0)); // rotates - case GDK_bracketleft: + case GDK_KEY_bracketleft: return _keyboardRotate(event->key, 1); - case GDK_bracketright: + case GDK_KEY_bracketright: return _keyboardRotate(event->key, -1); // scaling - case GDK_less: - case GDK_comma: + case GDK_KEY_less: + case GDK_KEY_comma: return _keyboardScale(event->key, -1); - case GDK_greater: - case GDK_period: + case GDK_KEY_greater: + case GDK_KEY_period: return _keyboardScale(event->key, 1); // TODO: skewing // flipping // NOTE: H is horizontal flip, while Shift+H switches transform handle mode! - case GDK_h: - case GDK_H: + case GDK_KEY_h: + case GDK_KEY_H: if (held_shift(event->key)) { toggleTransformHandlesMode(); return true; @@ -637,8 +740,8 @@ bool ControlPointSelection::event(SPEventContext * /*event_context*/, GdkEvent * // any modifiers except shift should cause no action if (held_any_modifiers(event->key)) break; return _keyboardFlip(Geom::X); - case GDK_v: - case GDK_V: + case GDK_KEY_v: + case GDK_KEY_V: if (held_any_modifiers(event->key)) break; return _keyboardFlip(Geom::Y); default: break; diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp index a5509655f..15af21777 100644 --- a/src/ui/tool/control-point.cpp +++ b/src/ui/tool/control-point.cpp @@ -27,6 +27,12 @@ #include "ui/tool/event-utils.h" #include "ui/tool/transform-handle-set.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#endif + namespace Inkscape { namespace UI { @@ -440,7 +446,7 @@ bool ControlPoint::_eventHandler(SPEventContext *event_context, GdkEvent *event) case GDK_KEY_PRESS: switch (get_group0_keyval(&event->key)) { - case GDK_Escape: { + case GDK_KEY_Escape: { // ignore Escape if this is not a drag if (!_drag_initiated) break; @@ -480,7 +486,7 @@ bool ControlPoint::_eventHandler(SPEventContext *event_context, GdkEvent *event) ungrabbed(NULL); // ungrabbed handlers can handle a NULL event snapprefs.setSnapEnabledGlobally(snap_save); } return true; - case GDK_Tab: + case GDK_KEY_Tab: {// Downcast from ControlPoint to TransformHandle, if possible // This is an ugly hack; we should have the transform handle intercept the keystrokes itself TransformHandle *th = dynamic_cast(this); @@ -490,7 +496,7 @@ bool ControlPoint::_eventHandler(SPEventContext *event_context, GdkEvent *event) } break; } - case GDK_ISO_Left_Tab: + case GDK_KEY_ISO_Left_Tab: {// Downcast from ControlPoint to TransformHandle, if possible // This is an ugly hack; we should have the transform handle intercept the keystrokes itself TransformHandle *th = dynamic_cast(this); diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 597a151c0..2be96afad 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -31,6 +31,115 @@ #include +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_VoidSymbol 0xffffff +#define GDK_KEY_Up 0xff52 +#define GDK_KEY_KP_Up 0xff97 +#define GDK_KEY_Down 0xff54 +#define GDK_KEY_KP_Down 0xff99 +#define GDK_KEY_Left 0xff51 +#define GDK_KEY_KP_Left 0xff96 +#define GDK_KEY_Right 0xff53 +#define GDK_KEY_KP_Right 0xff98 +#define GDK_KEY_Page_Up 0xff55 +#define GDK_KEY_KP_Page_Up 0xff9a +#define GDK_KEY_Page_Down 0xff56 +#define GDK_KEY_KP_Page_Down 0xff9b +#define GDK_KEY_Home 0xff50 +#define GDK_KEY_KP_Home 0xff95 +#define GDK_KEY_End 0xff57 +#define GDK_KEY_KP_End 0xff9c +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_b 0x062 +#define GDK_KEY_B 0x042 +#define GDK_KEY_c 0x063 +#define GDK_KEY_C 0x043 +#define GDK_KEY_d 0x064 +#define GDK_KEY_D 0x044 +#define GDK_KEY_g 0x067 +#define GDK_KEY_G 0x047 +#define GDK_KEY_h 0x068 +#define GDK_KEY_H 0x048 +#define GDK_KEY_i 0x069 +#define GDK_KEY_I 0x049 +#define GDK_KEY_j 0x06a +#define GDK_KEY_J 0x04a +#define GDK_KEY_k 0x06b +#define GDK_KEY_K 0x04b +#define GDK_KEY_l 0x06c +#define GDK_KEY_L 0x04c +#define GDK_KEY_q 0x071 +#define GDK_KEY_Q 0x051 +#define GDK_KEY_r 0x072 +#define GDK_KEY_R 0x052 +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_u 0x075 +#define GDK_KEY_U 0x055 +#define GDK_KEY_v 0x076 +#define GDK_KEY_V 0x056 +#define GDK_KEY_w 0x077 +#define GDK_KEY_W 0x057 +#define GDK_KEY_x 0x078 +#define GDK_KEY_X 0x058 +#define GDK_KEY_y 0x079 +#define GDK_KEY_Y 0x059 +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_Control_L 0xffe3 +#define GDK_KEY_Control_R 0xffe4 +#define GDK_KEY_Alt_L 0xffe9 +#define GDK_KEY_Alt_R 0xffea +#define GDK_KEY_Shift_L 0xffe1 +#define GDK_KEY_Shift_R 0xffe2 +#define GDK_KEY_Meta_L 0xffe7 +#define GDK_KEY_Meta_R 0xffe8 +#define GDK_KEY_KP_0 0xffb0 +#define GDK_KEY_KP_1 0xffb1 +#define GDK_KEY_KP_2 0xffb2 +#define GDK_KEY_KP_3 0xffb3 +#define GDK_KEY_KP_4 0xffb4 +#define GDK_KEY_KP_5 0xffb5 +#define GDK_KEY_KP_6 0xffb6 +#define GDK_KEY_KP_7 0xffb7 +#define GDK_KEY_KP_8 0xffb8 +#define GDK_KEY_KP_9 0xffb9 +#define GDK_KEY_F1 0xffbe +#define GDK_KEY_F2 0xffbf +#define GDK_KEY_F3 0xffc0 +#define GDK_KEY_F4 0xffc1 +#define GDK_KEY_F5 0xffc2 +#define GDK_KEY_F6 0xffc3 +#define GDK_KEY_F7 0xffc4 +#define GDK_KEY_F8 0xffc5 +#define GDK_KEY_F9 0xffc6 +#define GDK_KEY_F10 0xffc7 +#define GDK_KEY_F11 0xffc8 +#define GDK_KEY_Insert 0xff63 +#define GDK_KEY_KP_Insert 0xff9e +#define GDK_KEY_Delete 0xffff +#define GDK_KEY_KP_Delete 0xff9f +#define GDK_KEY_BackSpace 0xff08 +#define GDK_KEY_Return 0xff0d +#define GDK_KEY_KP_Enter 0xff8d +#define GDK_KEY_space 0x020 +#define GDK_KEY_KP_Space 0xff80 +#define GDK_KEY_Tab 0xff09 +#define GDK_KEY_ISO_Left_Tab 0xfe20 +#define GDK_KEY_bracketleft 0x05b +#define GDK_KEY_bracketright 0x05d +#define GDK_KEY_braceleft 0x07b +#define GDK_KEY_braceright 0x07d +#define GDK_KEY_less 0x03c +#define GDK_KEY_greater 0x03e +#define GDK_KEY_comma 0x02c +#define GDK_KEY_period 0x02e +#define GDK_KEY_KP_Add 0xffab +#define GDK_KEY_KP_Subtract 0xffad +#endif + #ifdef USE_GNU_HASHES namespace __gnu_cxx { template<> @@ -581,21 +690,21 @@ bool MultiPathManipulator::event(SPEventContext *event_context, GdkEvent *event) switch (key) { // single handle functions // rotation - case GDK_bracketleft: - case GDK_braceleft: + case GDK_KEY_bracketleft: + case GDK_KEY_braceleft: pm.rotateHandle(n, which, 1, one_pixel); break; - case GDK_bracketright: - case GDK_braceright: + case GDK_KEY_bracketright: + case GDK_KEY_braceright: pm.rotateHandle(n, which, -1, one_pixel); break; // adjust length - case GDK_period: - case GDK_greater: + case GDK_KEY_period: + case GDK_KEY_greater: pm.scaleHandle(n, which, 1, one_pixel); break; - case GDK_comma: - case GDK_less: + case GDK_KEY_comma: + case GDK_KEY_less: pm.scaleHandle(n, which, -1, one_pixel); break; default: @@ -611,13 +720,13 @@ bool MultiPathManipulator::event(SPEventContext *event_context, GdkEvent *event) switch (event->type) { case GDK_KEY_PRESS: switch (key) { - case GDK_Insert: - case GDK_KP_Insert: + case GDK_KEY_Insert: + case GDK_KEY_KP_Insert: // Insert - insert nodes in the middle of selected segments insertNodes(); return true; - case GDK_i: - case GDK_I: + case GDK_KEY_i: + case GDK_KEY_I: if (held_only_shift(event->key)) { // Shift+I - insert nodes (alternate keybinding for Mac keyboards // that don't have the Insert key) @@ -625,14 +734,14 @@ bool MultiPathManipulator::event(SPEventContext *event_context, GdkEvent *event) return true; } break; - case GDK_d: - case GDK_D: + case GDK_KEY_d: + case GDK_KEY_D: if (held_only_shift(event->key)) { duplicateNodes(); return true; } - case GDK_j: - case GDK_J: + case GDK_KEY_j: + case GDK_KEY_J: if (held_only_shift(event->key)) { // Shift+J - join nodes joinNodes(); @@ -644,17 +753,17 @@ bool MultiPathManipulator::event(SPEventContext *event_context, GdkEvent *event) return true; } break; - case GDK_b: - case GDK_B: + case GDK_KEY_b: + case GDK_KEY_B: if (held_only_shift(event->key)) { // Shift+B - break nodes breakNodes(); return true; } break; - case GDK_Delete: - case GDK_KP_Delete: - case GDK_BackSpace: + case GDK_KEY_Delete: + case GDK_KEY_KP_Delete: + case GDK_KEY_BackSpace: if (held_shift(event->key)) break; if (held_alt(event->key)) { // Alt+Delete - delete segments @@ -669,55 +778,55 @@ bool MultiPathManipulator::event(SPEventContext *event_context, GdkEvent *event) deleteNodes(del_preserves_shape ^ held_control(event->key)); } return true; - case GDK_c: - case GDK_C: + case GDK_KEY_c: + case GDK_KEY_C: if (held_only_shift(event->key)) { // Shift+C - make nodes cusp setNodeType(NODE_CUSP); return true; } break; - case GDK_s: - case GDK_S: + case GDK_KEY_s: + case GDK_KEY_S: if (held_only_shift(event->key)) { // Shift+S - make nodes smooth setNodeType(NODE_SMOOTH); return true; } break; - case GDK_a: - case GDK_A: + case GDK_KEY_a: + case GDK_KEY_A: if (held_only_shift(event->key)) { // Shift+A - make nodes auto-smooth setNodeType(NODE_AUTO); return true; } break; - case GDK_y: - case GDK_Y: + case GDK_KEY_y: + case GDK_KEY_Y: if (held_only_shift(event->key)) { // Shift+Y - make nodes symmetric setNodeType(NODE_SYMMETRIC); return true; } break; - case GDK_r: - case GDK_R: + case GDK_KEY_r: + case GDK_KEY_R: if (held_only_shift(event->key)) { // Shift+R - reverse subpaths reverseSubpaths(); return true; } break; - case GDK_l: - case GDK_L: + case GDK_KEY_l: + case GDK_KEY_L: if (held_only_shift(event->key)) { // Shift+L - make segments linear setSegmentType(SEGMENT_STRAIGHT); return true; } - case GDK_u: - case GDK_U: + case GDK_KEY_u: + case GDK_KEY_U: if (held_only_shift(event->key)) { // Shift+L - make segments curves setSegmentType(SEGMENT_CUBIC_BEZIER); diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 3c1e7de71..95cf7aebb 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -43,6 +43,14 @@ #include +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_a 0x061 +#define GDK_KEY_A 0x041 +#define GDK_KEY_h 0x068 +#define GDK_KEY_H 0x048 +#endif + /** @struct InkNodeTool * * Node tool event context. @@ -503,7 +511,7 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KEY_PRESS: switch (get_group0_keyval(&event->key)) { - case GDK_Escape: // deselect everything + case GDK_KEY_Escape: // deselect everything if (nt->_selected_nodes->empty()) { selection->clear(); } else { @@ -511,8 +519,8 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) } ink_node_tool_update_tip(nt, event); return TRUE; - case GDK_a: - case GDK_A: + case GDK_KEY_a: + case GDK_KEY_A: if (held_control(event->key) && held_alt(event->key)) { nt->_selected_nodes->selectAll(); // Ctrl+A is handled in selection-chemistry.cpp via verb @@ -520,8 +528,8 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) return TRUE; } break; - case GDK_h: - case GDK_H: + case GDK_KEY_h: + case GDK_KEY_H: if (held_only_control(event->key)) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool("/tools/nodes/show_handles", !nt->show_handles); diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index ff644b4e3..1d3acb4a5 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -33,6 +33,15 @@ #include "ui/tool/path-manipulator.h" #include +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_s 0x073 +#define GDK_KEY_S 0x053 +#define GDK_KEY_Page_Up 0xff55 +#define GDK_KEY_KP_Page_Up 0xff9a +#define GDK_KEY_Page_Down 0xff56 +#define GDK_KEY_KP_Page_Down 0xff9b +#endif + namespace Inkscape { namespace UI { @@ -232,8 +241,8 @@ bool Handle::_eventHandler(SPEventContext *event_context, GdkEvent *event) case GDK_KEY_PRESS: switch (shortcut_key(event->key)) { - case GDK_s: - case GDK_S: + case GDK_KEY_s: + case GDK_KEY_S: if (held_only_shift(event->key) && _parent->_type == NODE_CUSP) { // when Shift+S is pressed when hovering over a handle belonging to a cusp node, // hold this handle in place; otherwise process normally @@ -803,10 +812,10 @@ bool Node::_eventHandler(SPEventContext *event_context, GdkEvent *event) case GDK_KEY_PRESS: switch (shortcut_key(event->key)) { - case GDK_Page_Up: + case GDK_KEY_Page_Up: dir = 1; break; - case GDK_Page_Down: + case GDK_KEY_Page_Down: dir = -1; break; default: goto bail_out; diff --git a/src/ui/tool/selector.cpp b/src/ui/tool/selector.cpp index 86ad05515..6820b7635 100644 --- a/src/ui/tool/selector.cpp +++ b/src/ui/tool/selector.cpp @@ -19,6 +19,10 @@ #include +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Escape 0xff1b +#endif + namespace Inkscape { namespace UI { @@ -49,7 +53,7 @@ public: protected: virtual bool _eventHandler(SPEventContext *event_context, GdkEvent *event) { - if (event->type == GDK_KEY_PRESS && shortcut_key(event->key) == GDK_Escape && + if (event->type == GDK_KEY_PRESS && shortcut_key(event->key) == GDK_KEY_Escape && sp_canvas_item_is_visible(_rubber)) { _cancel = true; diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 60b7856f6..8ba8d413d 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -17,6 +17,12 @@ #include "util/expression-evaluator.h" #include "event-context.h" +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_Escape 0xff1b +#define GDK_KEY_z 0x07a +#define GDK_KEY_Z 0x05a +#endif + namespace Inkscape { namespace UI { namespace Widget { @@ -64,12 +70,12 @@ bool SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/) bool SpinButton::on_my_key_press_event(GdkEventKey* event) { switch (get_group0_keyval (event)) { - case GDK_Escape: + case GDK_KEY_Escape: undo(); return true; // I consumed the event break; - case GDK_z: - case GDK_Z: + case GDK_KEY_z: + case GDK_KEY_Z: if (event->state & GDK_CONTROL_MASK) { undo(); return true; // I consumed the event diff --git a/src/verbs.cpp b/src/verbs.cpp index d4ac35b33..1b57ad4ff 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -84,6 +84,11 @@ #include +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_KP_Add 0xffab +#define GDK_KEY_KP_Subtract 0xffad +#endif + using Inkscape::DocumentUndo; //#ifdef WITH_INKBOARD @@ -1656,7 +1661,7 @@ void ZoomVerb::perform(SPAction *action, void *data) case SP_VERB_ZOOM_IN: { gint mul = 1 + gobble_key_events( - GDK_KP_Add, 0); // with any mask + GDK_KEY_KP_Add, 0); // with any mask // While drawing with the pen/pencil tool, zoom towards the end of the unfinished path if (tools_isactive(dt, TOOLS_FREEHAND_PENCIL) || tools_isactive(dt, TOOLS_FREEHAND_PEN)) { SPCurve *rc = SP_DRAW_CONTEXT(ec)->red_curve; @@ -1674,7 +1679,7 @@ void ZoomVerb::perform(SPAction *action, void *data) case SP_VERB_ZOOM_OUT: { gint mul = 1 + gobble_key_events( - GDK_KP_Subtract, 0); // with any mask + GDK_KEY_KP_Subtract, 0); // with any mask // While drawing with the pen/pencil tool, zoom away from the end of the unfinished path if (tools_isactive(dt, TOOLS_FREEHAND_PENCIL) || tools_isactive(dt, TOOLS_FREEHAND_PEN)) { SPCurve *rc = SP_DRAW_CONTEXT(ec)->red_curve; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index aa87fb873..58c7958ba 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -113,6 +113,10 @@ #include "toolbox.h" #include +#if !GTK_CHECK_VERSION(2,22,0) +#define GDK_KEY_VoidSymbol 0xffffff +#endif + //#define DEBUG_TEXT using Inkscape::UnitTracker; @@ -860,7 +864,7 @@ GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick(GtkWidget *t, Inksc unsigned int shortcut = sp_shortcut_get_primary(verb); - if (shortcut != GDK_VoidSymbol) { + if (shortcut != GDK_KEY_VoidSymbol) { gchar *key = sp_shortcut_get_label(shortcut); gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key); if ( t ) { -- cgit v1.2.3 From 1bf18c5a808d3abbd810d642e9a2c41ec8ef9125 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 15 Apr 2012 13:47:41 +0200 Subject: i18n. Fix for Bug #980518 (Please use c-format). Fixed bugs: - https://launchpad.net/bugs/980518 (bzr r11251) --- src/ui/dialog/ocaldialogs.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index a08e80f8d..4c9245f5c 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -1075,12 +1075,14 @@ void ImportDialog::update_label_no_search_results() { Glib::ustring keywords = Glib::Markup::escape_text(entry_search->get_text()); Gdk::Color grey = entry_search->get_style()->get_text_aa(entry_search->get_state()); - + Glib::ustring msg_one = Glib::ustring::compose( + _("No clipart named %1 was found."), + keywords); + Glib::ustring msg_two = _("Please make sure all keywords are spelled correctly," + " or try again with different keywords."); Glib::ustring markup = Glib::ustring::compose( - "%1 %2 %3\n%5", - _("No clipart named"), keywords, _("was found."), grey.to_string(), - _("Please make sure all keywords are spelled correctly, or try again with different keywords.")); - + "%1\n%3", + msg_one, grey.to_string(), msg_two); label_not_found->set_markup(markup); } -- cgit v1.2.3