From ac40d1226ad4b0170dc3df567074c54ca20d9469 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 22 Aug 2010 21:33:18 +0200 Subject: i18n. Context cleanup (context|string replaced with C_). (bzr r9722) --- src/widgets/font-selector.cpp | 4 +--- src/widgets/select-toolbar.cpp | 16 ++++------------ src/widgets/stroke-style.cpp | 5 +---- 3 files changed, 6 insertions(+), 19 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index ce0893430..1972ea046 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -184,10 +184,8 @@ static void sp_font_selector_init(SPFontSelector *fsel) g_object_set_data (G_OBJECT(fsel), "family-treeview", fsel->family_treeview); - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS /* Style frame */ - f = gtk_frame_new(Q_("fontselector|Style")); + f = gtk_frame_new(C_("Font selector", "Style")); gtk_widget_show(f); gtk_box_pack_start(GTK_BOX (fsel), f, TRUE, TRUE, 0); diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index e2ad61e2d..ed54857f8 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -455,25 +455,19 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb // four spinbuttons - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS - eact = create_adjustment_action( "XAction", _("select toolbar|X position"), _("select toolbar|X"), "X", + eact = create_adjustment_action( "XAction", C_("Select toolbar", "X position"), C_("Select toolbar", "X:"), "X", -1e6, GTK_WIDGET(desktop->canvas), tracker, spw, _("Horizontal coordinate of selection"), TRUE ); gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) ); contextActions->push_back( GTK_ACTION(eact) ); - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS - eact = create_adjustment_action( "YAction", _("select toolbar|Y position"), _("select toolbar|Y"), "Y", + eact = create_adjustment_action( "YAction", C_("Select toolbar", "Y position"), C_("Select toolbar", "Y:"), "Y", -1e6, GTK_WIDGET(desktop->canvas), tracker, spw, _("Vertical coordinate of selection"), FALSE ); gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) ); contextActions->push_back( GTK_ACTION(eact) ); - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS - eact = create_adjustment_action( "WidthAction", _("select toolbar|Width"), _("select toolbar|W"), "width", + eact = create_adjustment_action( "WidthAction", C_("Select toolbar", "Width"), C_("Select toolbar", "W:"), "width", 1e-3, GTK_WIDGET(desktop->canvas), tracker, spw, _("Width of selection"), FALSE ); gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) ); @@ -492,9 +486,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb gtk_action_group_add_action( mainActions, GTK_ACTION(itact) ); } - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS - eact = create_adjustment_action( "HeightAction", _("select toolbar|Height"), _("select toolbar|H"), "height", + eact = create_adjustment_action( "HeightAction", C_("Select toolbar", "Height"), C_("Select toolbar", "H:"), "height", 1e-3, GTK_WIDGET(desktop->canvas), tracker, spw, _("Height of selection"), FALSE ); gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) ); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index f020b0c3a..642d4c453 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -671,10 +671,7 @@ sp_stroke_style_line_widget_new(void) gint i = 0; - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS - /* Stroke width */ - spw_label(t, Q_("StrokeWidth|Width:"), 0, i); + spw_label(t, C_("Stroke width", "Width:"), 0, i); hb = spw_hbox(t, 3, 1, i); -- cgit v1.2.3 From be519f62404daf6dff2449a2eb5280d998298868 Mon Sep 17 00:00:00 2001 From: Jasper van de Gronde Date: Mon, 6 Sep 2010 19:32:05 +0200 Subject: Automatically add shortcuts to tooltips (bzr r9745) --- src/widgets/button.cpp | 8 +++++--- src/widgets/toolbox.cpp | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 6769fa389..aa32a9d91 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -27,6 +27,8 @@ #include "shortcuts.h" #include "interface.h" +#include + #include "icon.h" #include "button.h" @@ -291,15 +293,15 @@ sp_button_set_composed_tooltip (GtkTooltips *tooltips, GtkWidget *widget, SPActi { if (action) { unsigned int shortcut = sp_shortcut_get_primary (action->verb); - if (shortcut) { + if (shortcut!=GDK_VoidSymbol) { // there's both action and shortcut - gchar key[256]; - sp_ui_shortcut_string (shortcut, key); + gchar* key = sp_shortcut_get_label(shortcut); gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key); gtk_tooltips_set_tip (tooltips, widget, tip, NULL); g_free (tip); + g_free (key); } else { // action has no shortcut diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index bdf1e6ff2..f6a6735e9 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -827,14 +827,14 @@ GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick(GtkWidget *t, Inksc unsigned int shortcut = sp_shortcut_get_primary(verb); - if (shortcut) { - gchar key[256]; - sp_ui_shortcut_string(shortcut, key); + if (shortcut!=GDK_VoidSymbol) { + gchar* key = sp_shortcut_get_label(shortcut); gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key); if ( t ) { gtk_toolbar_append_widget( GTK_TOOLBAR(t), b, tip, 0 ); } g_free(tip); + g_free(key); } else { if ( t ) { gtk_toolbar_append_widget( GTK_TOOLBAR(t), b, action->tip, 0 ); -- cgit v1.2.3 From 7f08f1569225671ff9c4ef4dc04edc405bf0d5bf Mon Sep 17 00:00:00 2001 From: Jasper van de Gronde Date: Tue, 7 Sep 2010 10:35:34 +0200 Subject: Connected two toolbar buttons with the associated verbs (bzr r9747) --- src/widgets/toolbox.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f6a6735e9..f6af1ca55 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -303,7 +303,7 @@ static gchar const * ui_descr = " " " " " " - " " + " " " " " " " " @@ -1500,9 +1500,10 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions } { - InkAction* inky = ink_action_new( "EditNextLPEParameterAction", - _("Next path effect parameter"), - _("Show next editable path effect parameter"), + Inkscape::Verb* verb = Inkscape::Verb::get(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER); + InkAction* inky = ink_action_new( verb->get_id(), + verb->get_name(), + verb->get_tip(), INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT, secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_nextLPEparam), desktop ); @@ -2175,8 +2176,13 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); { - InkToggleAction* act = ink_toggle_action_new("ToggleSnapGlobal", - _("Snap"), _("Enable snapping"), INKSCAPE_ICON_SNAP, secondarySize, + // TODO: This is a cludge. On the one hand we have verbs+actions, + // on the other we have all these explicit callbacks specified here. + // We should really unify these (should save some lines of code as well). + // For example, this action could be based on the verb(+action) + PrefsPusher. + Inkscape::Verb* verb = Inkscape::Verb::get(SP_VERB_TOGGLE_SNAPPING); + InkToggleAction* act = ink_toggle_action_new(verb->get_id(), + verb->get_name(), verb->get_tip(), INKSCAPE_ICON_SNAP, secondarySize, SP_ATTR_INKSCAPE_SNAP_GLOBAL); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); -- cgit v1.2.3 From 8f5e0a489aa98d01e053194f01c583482d6ba9ac Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 11 Sep 2010 23:48:43 -0700 Subject: Stop overrun. (bzr r9756) --- src/widgets/sp-color-selector.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/sp-color-selector.cpp b/src/widgets/sp-color-selector.cpp index 203bc3c2a..b879dab5a 100644 --- a/src/widgets/sp-color-selector.cpp +++ b/src/widgets/sp-color-selector.cpp @@ -338,10 +338,6 @@ void ColorSelector::getColorAlpha( SPColor &color, gfloat &alpha ) const { i++; } - if ( color.v.c[3] ) - { - i++; - } if ( alpha ) { i++; -- cgit v1.2.3 From 9ced034c5571093e4622d60e06fc680777936e77 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 15 Sep 2010 00:43:40 -0700 Subject: Prevent opacity slider changes from going into undo as separate items. Fixes bug #629300. Fixed bugs: - https://launchpad.net/bugs/629300 (bzr r9762) --- src/widgets/gradient-vector.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 7f0256665..1c1e8173b 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -648,25 +648,22 @@ static void sp_grad_edit_select(GtkOptionMenu *mnu, GtkWidget *tbl) static void offadjustmentChanged( GtkAdjustment *adjustment, GtkWidget *vb) { - if (blocked) { - return; - } + if (!blocked) { + blocked = TRUE; - blocked = TRUE; + GtkOptionMenu *mnu = static_cast(g_object_get_data(G_OBJECT(vb), "stopmenu")); + if ( g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop") ) { + SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")); - GtkOptionMenu *mnu = static_cast(g_object_get_data(G_OBJECT(vb), "stopmenu")); - if (!g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")) { - return; - } - SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")); - - stop->offset = adjustment->value; - sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", stop->offset); + stop->offset = adjustment->value; + sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", stop->offset); - sp_document_done(SP_OBJECT_DOCUMENT(stop), SP_VERB_CONTEXT_GRADIENT, - _("Change gradient stop offset")); + sp_document_maybe_done(SP_OBJECT_DOCUMENT(stop), "gradient:stop:offset", SP_VERB_CONTEXT_GRADIENT, + _("Change gradient stop offset")); - blocked = FALSE; + blocked = FALSE; + } + } } guint32 sp_average_color(guint32 c1, guint32 c2, gdouble p = 0.5) -- cgit v1.2.3 From 9c374cb1fa9fd947a158100fa4597a445fa4ae5c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 24 Sep 2010 13:59:02 +0200 Subject: Fix for bug #362995 (Default Units in Document Properties ignored). (bzr r9780) --- src/widgets/desktop-widget.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 36047e81b..d447abf2e 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -41,6 +41,7 @@ #include #include "file.h" #include "helper/units.h" +#include "helper/unit-tracker.h" #include "inkscape-private.h" #include "interface.h" #include "macros.h" @@ -69,7 +70,7 @@ using Inkscape::round; #endif - +using Inkscape::UnitTracker; using Inkscape::UI::UXManager; using Inkscape::UI::ToolboxFactory; @@ -325,7 +326,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_end( GTK_BOX (dtw->vbox), dtw->hbox, TRUE, TRUE, 0 ); gtk_widget_show(dtw->hbox); - + dtw->aux_toolbox = ToolboxFactory::createAuxToolbox(); gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->aux_toolbox, FALSE, TRUE, 0); @@ -1510,6 +1511,40 @@ void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags) sp_ruler_set_metric(GTK_RULER (this->vruler), nv->getDefaultMetric()); sp_ruler_set_metric(GTK_RULER (this->hruler), nv->getDefaultMetric()); + /* This loops through all the grandchildren of aux toolbox, + * and for each that it finds, it performs an sp_search_by_data_recursive(), + * looking for widgets that hold some "tracker" data (this is used by + * all toolboxes to refer to the unit selector). The default document units + * is then selected within these unit selectors. + * + * Of course it would be nice to be able to refer to the toolbox and the + * unit selector directly by name, but I don't yet see a way to do that. + * + * This should solve: https://bugs.launchpad.net/inkscape/+bug/362995 + */ + if (GTK_IS_CONTAINER(aux_toolbox)) { + GList *ch = gtk_container_get_children (GTK_CONTAINER(aux_toolbox)); + for (GList *i = ch; i != NULL; i = i->next) { + if (GTK_IS_CONTAINER(i->data)) { + GList *grch = gtk_container_get_children (GTK_CONTAINER(i->data)); + for (GList *j = grch; j != NULL; j = j->next) { + if (!GTK_IS_WIDGET(j->data)) // wasn't a widget + continue; + + gpointer t = sp_search_by_data_recursive(GTK_WIDGET(j->data), (gpointer) "tracker"); + if (t == NULL) // didn't find any tracker data + continue; + + UnitTracker *tracker = reinterpret_cast( t ); + if (tracker == NULL) // it's null when inkscape is first opened + continue; + + tracker->setActiveUnit( nv->doc_units ); + } // grandchildren + } // if child is a container + } // children + } // if aux_toolbox is a container + gtk_tooltips_set_tip(this->tt, this->hruler_box, gettext(sp_unit_get_plural (nv->doc_units)), NULL); gtk_tooltips_set_tip(this->tt, this->vruler_box, gettext(sp_unit_get_plural (nv->doc_units)), NULL); -- cgit v1.2.3 From 2e76284350f91635e7d82e4e5b300f4cb4da71ca Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 25 Oct 2010 10:10:59 +0200 Subject: UI fixes (punctuation, units, accelerator keys) (a. o. Bug #560751 ) (bzr r9851) --- src/widgets/sp-color-icc-selector.cpp | 14 +++++++------- src/widgets/sp-color-scales.cpp | 26 +++++++++++++------------- src/widgets/sp-color-wheel-selector.cpp | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 6bd1957a8..f5b4d925e 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -217,12 +217,12 @@ void getThings( DWORD space, gchar const**& namers, gchar const**& tippies, guin // {"_Y", "C_b", "C_r", "", "", ""}, {"_Y", "_x", "y", "", "", ""}, - {_("_R"), _("_G"), _("_B"), "", "", ""}, - {_("_G"), "", "", "", "", ""}, - {_("_H"), _("_S"), "_V", "", "", ""}, - {_("_H"), _("_L"), _("_S"), "", "", ""}, - {_("_C"), _("_M"), _("_Y"), _("_K"), "", ""}, - {_("_C"), _("_M"), _("_Y"), "", "", ""}, + {_("_R:"), _("_G:"), _("_B:"), "", "", ""}, + {_("_G:"), "", "", "", "", ""}, + {_("_H:"), _("_S:"), "_V:", "", "", ""}, + {_("_H:"), _("_L:"), _("_S:"), "", "", ""}, + {_("_C:"), _("_M:"), _("_Y:"), _("_K:"), "", ""}, + {_("_C:"), _("_M:"), _("_Y:"), "", "", ""}, }; static gchar const *tips[][6] = { @@ -377,7 +377,7 @@ void ColorICCSelector::init() } /* Label */ - _label = gtk_label_new_with_mnemonic (_("_A")); + _label = gtk_label_new_with_mnemonic (_("_A:")); gtk_misc_set_alignment (GTK_MISC (_label), 1.0, 0.5); gtk_widget_show (_label); gtk_table_attach (GTK_TABLE (t), _label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp index d20cf65ef..fb8bb0795 100644 --- a/src/widgets/sp-color-scales.cpp +++ b/src/widgets/sp-color-scales.cpp @@ -401,16 +401,16 @@ void ColorScales::setMode(SPColorScalesMode mode) switch (mode) { case SP_COLOR_SCALES_MODE_RGB: _setRangeLimit(255.0); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[0]), _("_R")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[0]), _("_R:")); gtk_tooltips_set_tip (_tt, _s[0], _("Red"), NULL); gtk_tooltips_set_tip (_tt, _b[0], _("Red"), NULL); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[1]), _("_G")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[1]), _("_G:")); gtk_tooltips_set_tip (_tt, _s[1], _("Green"), NULL); gtk_tooltips_set_tip (_tt, _b[1], _("Green"), NULL); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[2]), _("_B")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[2]), _("_B:")); gtk_tooltips_set_tip (_tt, _s[2], _("Blue"), NULL); gtk_tooltips_set_tip (_tt, _b[2], _("Blue"), NULL); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[3]), _("_A")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[3]), _("_A:")); gtk_tooltips_set_tip (_tt, _s[3], _("Alpha (opacity)"), NULL); gtk_tooltips_set_tip (_tt, _b[3], _("Alpha (opacity)"), NULL); sp_color_slider_set_map (SP_COLOR_SLIDER (_s[0]), NULL); @@ -427,16 +427,16 @@ void ColorScales::setMode(SPColorScalesMode mode) break; case SP_COLOR_SCALES_MODE_HSV: _setRangeLimit(255.0); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[0]), _("_H")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[0]), _("_H:")); gtk_tooltips_set_tip (_tt, _s[0], _("Hue"), NULL); gtk_tooltips_set_tip (_tt, _b[0], _("Hue"), NULL); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[1]), _("_S")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[1]), _("_S:")); gtk_tooltips_set_tip (_tt, _s[1], _("Saturation"), NULL); gtk_tooltips_set_tip (_tt, _b[1], _("Saturation"), NULL); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[2]), _("_L")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[2]), _("_L:")); gtk_tooltips_set_tip (_tt, _s[2], _("Lightness"), NULL); gtk_tooltips_set_tip (_tt, _b[2], _("Lightness"), NULL); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[3]), _("_A")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[3]), _("_A:")); gtk_tooltips_set_tip (_tt, _s[3], _("Alpha (opacity)"), NULL); gtk_tooltips_set_tip (_tt, _b[3], _("Alpha (opacity)"), NULL); sp_color_slider_set_map (SP_COLOR_SLIDER (_s[0]), (guchar*)sp_color_scales_hue_map ()); @@ -455,19 +455,19 @@ void ColorScales::setMode(SPColorScalesMode mode) break; case SP_COLOR_SCALES_MODE_CMYK: _setRangeLimit(100.0); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[0]), _("_C")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[0]), _("_C:")); gtk_tooltips_set_tip (_tt, _s[0], _("Cyan"), NULL); gtk_tooltips_set_tip (_tt, _b[0], _("Cyan"), NULL); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[1]), _("_M")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[1]), _("_M:")); gtk_tooltips_set_tip (_tt, _s[1], _("Magenta"), NULL); gtk_tooltips_set_tip (_tt, _b[1], _("Magenta"), NULL); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[2]), _("_Y")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[2]), _("_Y:")); gtk_tooltips_set_tip (_tt, _s[2], _("Yellow"), NULL); gtk_tooltips_set_tip (_tt, _b[2], _("Yellow"), NULL); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[3]), _("_K")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[3]), _("_K:")); gtk_tooltips_set_tip (_tt, _s[3], _("Black"), NULL); gtk_tooltips_set_tip (_tt, _b[3], _("Black"), NULL); - gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[4]), _("_A")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[4]), _("_A:")); gtk_tooltips_set_tip (_tt, _s[4], _("Alpha (opacity)"), NULL); gtk_tooltips_set_tip (_tt, _b[4], _("Alpha (opacity)"), NULL); sp_color_slider_set_map (SP_COLOR_SLIDER (_s[0]), NULL); diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 6012f4e20..04a2fec79 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -132,7 +132,7 @@ void ColorWheelSelector::init() row++; /* Label */ - _label = gtk_label_new_with_mnemonic (_("_A")); + _label = gtk_label_new_with_mnemonic (_("_A:")); gtk_misc_set_alignment (GTK_MISC (_label), 1.0, 0.5); gtk_widget_show (_label); gtk_table_attach (GTK_TABLE (t), _label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); -- cgit v1.2.3 From 43910107bd13f3968d48d955a81bb787942af865 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 29 Oct 2010 00:49:37 -0700 Subject: Cleanups from backports. (bzr r9863) --- src/widgets/button.cpp | 42 ++++++++++++++++++++---------------------- src/widgets/toolbox.cpp | 4 ++-- 2 files changed, 22 insertions(+), 24 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index aa32a9d91..dc830d096 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -288,29 +288,27 @@ sp_button_action_set_shortcut (SPAction *action, unsigned int /*shortcut*/, void } } -static void -sp_button_set_composed_tooltip (GtkTooltips *tooltips, GtkWidget *widget, SPAction *action) +static void sp_button_set_composed_tooltip(GtkTooltips *tooltips, GtkWidget *widget, SPAction *action) { - if (action) { - unsigned int shortcut = sp_shortcut_get_primary (action->verb); - if (shortcut!=GDK_VoidSymbol) { - // there's both action and shortcut - - gchar* key = sp_shortcut_get_label(shortcut); - - gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key); - gtk_tooltips_set_tip (tooltips, widget, tip, NULL); - g_free (tip); - g_free (key); - - } else { - // action has no shortcut - gtk_tooltips_set_tip (tooltips, widget, action->tip, NULL); - } - } else { - // no action - gtk_tooltips_set_tip (tooltips, widget, NULL, NULL); - } + if (action) { + unsigned int shortcut = sp_shortcut_get_primary (action->verb); + if (shortcut != GDK_VoidSymbol) { + // there's both action and shortcut + + gchar *key = sp_shortcut_get_label(shortcut); + + gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key); + gtk_tooltips_set_tip(tooltips, widget, tip, NULL); + g_free(tip); + g_free(key); + } else { + // action has no shortcut + gtk_tooltips_set_tip(tooltips, widget, action->tip, NULL); + } + } else { + // no action + gtk_tooltips_set_tip(tooltips, widget, NULL, NULL); + } } GtkWidget * diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f6af1ca55..f7c493915 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -827,8 +827,8 @@ GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick(GtkWidget *t, Inksc unsigned int shortcut = sp_shortcut_get_primary(verb); - if (shortcut!=GDK_VoidSymbol) { - gchar* key = sp_shortcut_get_label(shortcut); + if (shortcut != GDK_VoidSymbol) { + gchar *key = sp_shortcut_get_label(shortcut); gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key); if ( t ) { gtk_toolbar_append_widget( GTK_TOOLBAR(t), b, tip, 0 ); -- cgit v1.2.3 From 144819c918dc761641c3cb5a490205fb73194ee3 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 17 Nov 2010 13:12:56 +1100 Subject: Super duper mega (fun!) commit: replaced encoding=utf-8 with fileencoding=utf-8 in all 1074 Vim modelines. The reason for this is that (a) setting the encoding isn't nice, and (b) Vim 7.3 (with modeline enabled) disallows it and pops up an error whenever you open any file with it ("invalid modeline"). Also corrected five deviant modestrings: * src/ui/widget/dock.cpp and src/ui/widget/dock.h: missing colon at the end * src/ui/dialog/tile.cpp: removed gratuitous second colon at the end * src/helper/units-test.h: removed gratuitous space before a colon * share/extensions/export_gimp_palette.py: missing textwidth=99 That's my geekiest commit yet. (bzr r9900) --- src/widgets/dash-selector.cpp | 2 +- src/widgets/dash-selector.h | 2 +- src/widgets/eek-preview.cpp | 2 +- src/widgets/eek-preview.h | 2 +- src/widgets/ege-paint-def.cpp | 2 +- src/widgets/ege-paint-def.h | 2 +- src/widgets/fill-n-stroke-factory.h | 2 +- src/widgets/fill-style.cpp | 2 +- src/widgets/fill-style.h | 2 +- src/widgets/font-selector.h | 2 +- src/widgets/gradient-vector.cpp | 2 +- src/widgets/gradient-vector.h | 2 +- src/widgets/icon.cpp | 2 +- src/widgets/paint-selector.cpp | 2 +- src/widgets/paint-selector.h | 2 +- src/widgets/ruler.h | 2 +- src/widgets/select-toolbar.h | 2 +- src/widgets/shrink-wrap-button.cpp | 2 +- src/widgets/shrink-wrap-button.h | 2 +- src/widgets/sp-attribute-widget.cpp | 2 +- src/widgets/sp-attribute-widget.h | 2 +- src/widgets/sp-color-icc-selector.cpp | 2 +- src/widgets/sp-color-icc-selector.h | 2 +- src/widgets/sp-color-notebook.cpp | 2 +- src/widgets/sp-color-notebook.h | 2 +- src/widgets/sp-color-preview.cpp | 2 +- src/widgets/sp-color-preview.h | 2 +- src/widgets/sp-color-selector.cpp | 2 +- src/widgets/sp-color-selector.h | 2 +- src/widgets/sp-color-wheel-selector.cpp | 2 +- src/widgets/sp-color-wheel-selector.h | 2 +- src/widgets/sp-color-wheel.cpp | 2 +- src/widgets/sp-color-wheel.h | 2 +- src/widgets/spinbutton-events.h | 2 +- src/widgets/spw-utilities.cpp | 2 +- src/widgets/spw-utilities.h | 2 +- src/widgets/stroke-style.cpp | 2 +- src/widgets/stroke-style.h | 2 +- src/widgets/swatch-selector.cpp | 2 +- src/widgets/swatch-selector.h | 2 +- src/widgets/toolbox.cpp | 2 +- src/widgets/toolbox.h | 2 +- src/widgets/widget-sizes.h | 2 +- 43 files changed, 43 insertions(+), 43 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dash-selector.cpp b/src/widgets/dash-selector.cpp index 3ac2bd4af..e7e029334 100644 --- a/src/widgets/dash-selector.cpp +++ b/src/widgets/dash-selector.cpp @@ -347,4 +347,4 @@ SPDashSelector::offset_value_changed() fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/dash-selector.h b/src/widgets/dash-selector.h index 25417285a..6db66f805 100644 --- a/src/widgets/dash-selector.h +++ b/src/widgets/dash-selector.h @@ -58,4 +58,4 @@ private: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index 7d408c689..8fefbe75c 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -771,4 +771,4 @@ GtkWidget* eek_preview_new(void) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/eek-preview.h b/src/widgets/eek-preview.h index 86481e548..49fe8e660 100644 --- a/src/widgets/eek-preview.h +++ b/src/widgets/eek-preview.h @@ -151,4 +151,4 @@ G_END_DECLS fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/ege-paint-def.cpp b/src/widgets/ege-paint-def.cpp index f7a46cfbb..cab675b29 100644 --- a/src/widgets/ege-paint-def.cpp +++ b/src/widgets/ege-paint-def.cpp @@ -326,4 +326,4 @@ static std::string doubleToStr(double d) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/ege-paint-def.h b/src/widgets/ege-paint-def.h index b47aec8aa..32f92ac3d 100644 --- a/src/widgets/ege-paint-def.h +++ b/src/widgets/ege-paint-def.h @@ -108,4 +108,4 @@ private: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/fill-n-stroke-factory.h b/src/widgets/fill-n-stroke-factory.h index 74339a07f..c671842fc 100644 --- a/src/widgets/fill-n-stroke-factory.h +++ b/src/widgets/fill-n-stroke-factory.h @@ -33,4 +33,4 @@ Gtk::Widget *createStyleWidget( FillOrStroke kind ); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index a0e343b58..b70c8f47d 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -705,4 +705,4 @@ void FillNStroke::updateFromPaint() fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/fill-style.h b/src/widgets/fill-style.h index ef19d7788..28a3f4f46 100644 --- a/src/widgets/fill-style.h +++ b/src/widgets/fill-style.h @@ -35,4 +35,4 @@ void sp_fill_style_widget_set_desktop(Gtk::Widget *widget, SPDesktop *desktop); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/font-selector.h b/src/widgets/font-selector.h index 094db0343..6ab2a1a12 100644 --- a/src/widgets/font-selector.h +++ b/src/widgets/font-selector.h @@ -64,4 +64,4 @@ void sp_font_preview_set_phrase (SPFontPreview *fprev, const gchar *phrase); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 1c1e8173b..76bb9b8e1 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -1200,4 +1200,4 @@ static void sp_gradient_vector_color_changed(SPColorSelector *csel, GtkObject *o fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index ceca9158c..9147f9cc1 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -80,4 +80,4 @@ GtkWidget *sp_gradient_vector_editor_new (SPGradient *gradient, SPStop *stop = N fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 5d91d3532..f9d01113e 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -1440,4 +1440,4 @@ static void imageMapNamedCB(GtkWidget* widget, gpointer user_data) { fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index cf6a04a3c..a7bed9e94 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -1186,4 +1186,4 @@ SPPaintSelector::Mode SPPaintSelector::getModeForStyle(SPStyle const & style, Fi fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h index 84209d1da..f3aff5a68 100644 --- a/src/widgets/paint-selector.h +++ b/src/widgets/paint-selector.h @@ -131,4 +131,4 @@ SPPaintSelector *sp_paint_selector_new(FillOrStroke kind); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/ruler.h b/src/widgets/ruler.h index 9e685771b..7a3509325 100644 --- a/src/widgets/ruler.h +++ b/src/widgets/ruler.h @@ -80,4 +80,4 @@ GtkWidget* sp_vruler_new (void); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/select-toolbar.h b/src/widgets/select-toolbar.h index fe5a0b8da..dbab1975a 100644 --- a/src/widgets/select-toolbar.h +++ b/src/widgets/select-toolbar.h @@ -32,4 +32,4 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/shrink-wrap-button.cpp b/src/widgets/shrink-wrap-button.cpp index c1775005c..d73f972d9 100644 --- a/src/widgets/shrink-wrap-button.cpp +++ b/src/widgets/shrink-wrap-button.cpp @@ -52,4 +52,4 @@ void shrink_wrap_button(Gtk::Button &button) { fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/shrink-wrap-button.h b/src/widgets/shrink-wrap-button.h index ce615960f..ca9153aea 100644 --- a/src/widgets/shrink-wrap-button.h +++ b/src/widgets/shrink-wrap-button.h @@ -32,4 +32,4 @@ void shrink_wrap_button(Gtk::Button &button); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index de14fc173..3473d8f31 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -787,4 +787,4 @@ sp_attribute_table_entry_changed ( GtkEditable *editable, fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index 01da29bed..2703bd98a 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -127,4 +127,4 @@ void sp_attribute_table_set_repr ( SPAttributeTable *spw, fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index f5b4d925e..4b565d1a3 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -933,4 +933,4 @@ void ColorICCSelector::_sliderChanged( SPColorSlider */*slider*/, SPColorICCSele fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-icc-selector.h b/src/widgets/sp-color-icc-selector.h index dfba71a09..9fd80c04a 100644 --- a/src/widgets/sp-color-icc-selector.h +++ b/src/widgets/sp-color-icc-selector.h @@ -115,4 +115,4 @@ GtkWidget *sp_color_icc_selector_new (void); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 6c5113084..8429434a6 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -725,4 +725,4 @@ void ColorNotebook::removePage( GType page_type, guint submode ) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-notebook.h b/src/widgets/sp-color-notebook.h index 5eb29ac73..0b9b2ed87 100644 --- a/src/widgets/sp-color-notebook.h +++ b/src/widgets/sp-color-notebook.h @@ -116,5 +116,5 @@ GtkWidget *sp_color_notebook_new (void); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-preview.cpp b/src/widgets/sp-color-preview.cpp index ddeb5d123..5c8154709 100644 --- a/src/widgets/sp-color-preview.cpp +++ b/src/widgets/sp-color-preview.cpp @@ -208,4 +208,4 @@ sp_color_preview_paint (SPColorPreview *cp, GdkRectangle *area) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-preview.h b/src/widgets/sp-color-preview.h index 873e59d80..32572e915 100644 --- a/src/widgets/sp-color-preview.h +++ b/src/widgets/sp-color-preview.h @@ -52,4 +52,4 @@ void sp_color_preview_set_rgba32(SPColorPreview *cp, guint32 color); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-selector.cpp b/src/widgets/sp-color-selector.cpp index b879dab5a..c6f13b391 100644 --- a/src/widgets/sp-color-selector.cpp +++ b/src/widgets/sp-color-selector.cpp @@ -353,4 +353,4 @@ void ColorSelector::getColorAlpha( SPColor &color, gfloat &alpha ) const fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-selector.h b/src/widgets/sp-color-selector.h index a2ad87dd5..3b35140ed 100644 --- a/src/widgets/sp-color-selector.h +++ b/src/widgets/sp-color-selector.h @@ -99,4 +99,4 @@ GtkWidget *sp_color_selector_new( GType selector_type ); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 04a2fec79..5ba2c347b 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -311,4 +311,4 @@ void ColorWheelSelector::_wheelChanged( SPColorWheel *wheel, SPColorWheelSelecto fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-wheel-selector.h b/src/widgets/sp-color-wheel-selector.h index df8819bc9..1adbb65a7 100644 --- a/src/widgets/sp-color-wheel-selector.h +++ b/src/widgets/sp-color-wheel-selector.h @@ -87,4 +87,4 @@ GtkWidget *sp_color_wheel_selector_new (void); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-wheel.cpp b/src/widgets/sp-color-wheel.cpp index b565bd485..25cfb8dbd 100644 --- a/src/widgets/sp-color-wheel.cpp +++ b/src/widgets/sp-color-wheel.cpp @@ -1159,4 +1159,4 @@ static void sp_color_wheel_process_in_triangle( SPColorWheel *wheel, gdouble x, fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-wheel.h b/src/widgets/sp-color-wheel.h index 699750bed..d62c26782 100644 --- a/src/widgets/sp-color-wheel.h +++ b/src/widgets/sp-color-wheel.h @@ -77,4 +77,4 @@ gboolean sp_color_wheel_is_adjusting( SPColorWheel *wheel ); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/spinbutton-events.h b/src/widgets/spinbutton-events.h index 868bc195a..683748d0a 100644 --- a/src/widgets/spinbutton-events.h +++ b/src/widgets/spinbutton-events.h @@ -27,4 +27,4 @@ void spinbutton_defocus (GtkObject *container); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index 0e191b002..7c2956c65 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -278,4 +278,4 @@ sp_search_by_value_recursive (GtkWidget *w, gchar *key, gchar *value) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/spw-utilities.h b/src/widgets/spw-utilities.h index 5c4018199..d17762811 100644 --- a/src/widgets/spw-utilities.h +++ b/src/widgets/spw-utilities.h @@ -72,4 +72,4 @@ GtkWidget *sp_search_by_value_recursive(GtkWidget *w, gchar *key, gchar *value); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 642d4c453..2c5506273 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -1471,4 +1471,4 @@ ink_extract_marker_name(gchar const *n, SPDocument *doc) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h index 72dc5449a..b8ab05810 100644 --- a/src/widgets/stroke-style.h +++ b/src/widgets/stroke-style.h @@ -35,4 +35,4 @@ void sp_stroke_style_widget_set_desktop(Gtk::Widget *widget, SPDesktop *desktop) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/swatch-selector.cpp b/src/widgets/swatch-selector.cpp index 88abca358..3c209a45d 100644 --- a/src/widgets/swatch-selector.cpp +++ b/src/widgets/swatch-selector.cpp @@ -202,4 +202,4 @@ void SwatchSelector::setVector(SPDocument */*doc*/, SPGradient *vector) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/swatch-selector.h b/src/widgets/swatch-selector.h index 83acf9fda..b97aac4f1 100644 --- a/src/widgets/swatch-selector.h +++ b/src/widgets/swatch-selector.h @@ -55,5 +55,5 @@ private: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f7c493915..9a2fc8dd2 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -8467,4 +8467,4 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h index 2e4b2958a..a25705536 100644 --- a/src/widgets/toolbox.h +++ b/src/widgets/toolbox.h @@ -68,4 +68,4 @@ void sp_toolbox_add_label(GtkWidget *tbl, gchar const *title, bool wide = true); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/widget-sizes.h b/src/widgets/widget-sizes.h index c63890bd0..644740637 100644 --- a/src/widgets/widget-sizes.h +++ b/src/widgets/widget-sizes.h @@ -49,4 +49,4 @@ fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 5c2728c43852f49a021960963b87249e956de03a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 18 Nov 2010 22:25:01 +0100 Subject: Fix ruler redraw issue on GTK 2.22 Fixed bugs: - https://launchpad.net/bugs/627134 (bzr r9905) --- src/widgets/ruler.cpp | 682 +++++++++++++------------------------------------- 1 file changed, 176 insertions(+), 506 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp index c70d96991..dd0336413 100644 --- a/src/widgets/ruler.cpp +++ b/src/widgets/ruler.cpp @@ -29,12 +29,11 @@ #define MAXIMUM_SCALES 10 #define UNUSED_PIXELS 2 // There appear to be two pixels that are not being used at each end of the ruler +static void sp_ruler_common_draw_ticks (GtkRuler *ruler); + static void sp_hruler_class_init (SPHRulerClass *klass); static void sp_hruler_init (SPHRuler *hruler); static gint sp_hruler_motion_notify (GtkWidget *widget, GdkEventMotion *event); -static void sp_hruler_draw_ticks (GtkRuler *ruler); -static void sp_hruler_draw_pos (GtkRuler *ruler); -static void sp_hruler_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static GtkWidgetClass *hruler_parent_class; @@ -79,10 +78,8 @@ sp_hruler_class_init (SPHRulerClass *klass) ruler_class = (GtkRulerClass*) klass; widget_class->motion_notify_event = sp_hruler_motion_notify; - widget_class->size_allocate = sp_hruler_size_allocate; - ruler_class->draw_ticks = sp_hruler_draw_ticks; - ruler_class->draw_pos = sp_hruler_draw_pos; + ruler_class->draw_ticks = sp_ruler_common_draw_ticks; } static void @@ -114,269 +111,20 @@ sp_hruler_motion_notify (GtkWidget *widget, ruler = GTK_RULER (widget); double x = event->x; //Although event->x is double according to the docs, it only appears to return integers - ruler->position = ruler->lower + (ruler->upper - ruler->lower) * (x + UNUSED_PIXELS) / (widget->allocation.width + 2*UNUSED_PIXELS); - - /* Make sure the ruler has been allocated already */ - if (ruler->backing_store != NULL) - gtk_ruler_draw_pos (ruler); - - return FALSE; -} - -static void -sp_hruler_draw_ticks (GtkRuler *ruler) -{ - GtkWidget *widget; - GdkGC *gc, *bg_gc; - PangoFontDescription *pango_desc; - PangoContext *pango_context; - PangoLayout *pango_layout; - gint i, tick_index; - gint width, height; - gint xthickness; - gint ythickness; - gint length, ideal_length; - double lower, upper; /* Upper and lower limits, in ruler units */ - double increment; /* Number of pixels per unit */ - gint scale; /* Number of units per major unit */ - double subd_incr; - double start, end, cur; - gchar unit_str[32]; - gint digit_height; - gint text_width; - gint pos; - - g_return_if_fail (ruler != NULL); - g_return_if_fail (SP_IS_HRULER (ruler)); - - if (!GTK_WIDGET_DRAWABLE (ruler)) - return; - - widget = GTK_WIDGET (ruler); - - gc = widget->style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = widget->style->bg_gc[GTK_STATE_NORMAL]; - - pango_desc = widget->style->font_desc; - - // Create the pango layout - pango_context = gtk_widget_get_pango_context (widget); - - pango_layout = pango_layout_new (pango_context); - - PangoFontDescription *fs = pango_font_description_new (); - pango_font_description_set_size (fs, RULER_FONT_SIZE); - pango_layout_set_font_description (pango_layout, fs); - pango_font_description_free (fs); - - digit_height = (int) floor (RULER_FONT_SIZE * RULER_FONT_VERTICAL_SPACING / PANGO_SCALE + 0.5); - - xthickness = widget->style->xthickness; - ythickness = widget->style->ythickness; - - width = widget->allocation.width; // in pixels; is apparently 2 pixels shorter than the canvas at each end - height = widget->allocation.height;// - ythickness * 2; - - gtk_paint_box (widget->style, ruler->backing_store, - GTK_STATE_NORMAL, GTK_SHADOW_NONE, - NULL, widget, "hruler", - 0, 0, - widget->allocation.width, widget->allocation.height); - - upper = ruler->upper / ruler->metric->pixels_per_unit; // upper and lower are expressed in ruler units - lower = ruler->lower / ruler->metric->pixels_per_unit; - /* "pixels_per_unit" should be "points_per_unit". This is the size of the unit - * in 1/72nd's of an inch and has nothing to do with screen pixels */ - - if ((upper - lower) == 0) - return; - increment = (double) (width + 2*UNUSED_PIXELS) / (upper - lower); // screen pixels per ruler unit - - /* determine the scale - * We calculate the text size as for the vruler instead of using - * text_width = gdk_string_width(font, unit_str), so that the result - * for the scale looks consistent with an accompanying vruler - */ - scale = (int)(ceil (ruler->max_size / ruler->metric->pixels_per_unit)); - sprintf (unit_str, "%d", scale); - text_width = strlen (unit_str) * digit_height + 1; - - for (scale = 0; scale < MAXIMUM_SCALES; scale++) - if (ruler->metric->ruler_scale[scale] * fabs(increment) > 2 * text_width) - break; - - if (scale == MAXIMUM_SCALES) - scale = MAXIMUM_SCALES - 1; - - /* drawing starts here */ - length = 0; - for (i = MAXIMUM_SUBDIVIDE - 1; i >= 0; i--) - { - subd_incr = ruler->metric->ruler_scale[scale] / - ruler->metric->subdivide[i]; - if (subd_incr * fabs(increment) <= MINIMUM_INCR) - continue; - - /* Calculate the length of the tickmarks. Make sure that - * this length increases for each set of ticks - */ - ideal_length = height / (i + 1) - 1; - if (ideal_length > ++length) - length = ideal_length; - - if (lower < upper) - { - start = floor (lower / subd_incr) * subd_incr; - end = ceil (upper / subd_incr) * subd_incr; - } - else - { - start = floor (upper / subd_incr) * subd_incr; - end = ceil (lower / subd_incr) * subd_incr; - } - - tick_index = 0; - cur = start; // location (in ruler units) of the first invisible tick at the left side of the canvas - - while (cur <= end) - { - // due to the typical values for cur, lower and increment, pos will often end up to - // be e.g. 641.50000000000; rounding behaviour is not defined in such a case (see round.h) - // and jitter will be apparent (upon redrawing some of the lines on the ruler might jump a - // by a pixel, and jump back on the next redraw). This is suppressed by adding 1e-9 (that's only one nanopixel ;-)) - pos = int(Inkscape::round((cur - lower) * increment + 1e-12)) - UNUSED_PIXELS; - gdk_draw_line (ruler->backing_store, gc, - pos, height + ythickness, - pos, height - length + ythickness); - - /* draw label */ - double label_spacing_px = (increment*(double)ruler->metric->ruler_scale[scale])/ruler->metric->subdivide[i]; - if (i == 0 && - (label_spacing_px > 6*digit_height || tick_index%2 == 0 || cur == 0) && - (label_spacing_px > 3*digit_height || tick_index%4 == 0 || cur == 0)) - { - if (fabs((int)cur) >= 2000 && (((int) cur)/1000)*1000 == ((int) cur)) - sprintf (unit_str, "%dk", ((int) cur)/1000); - else - sprintf (unit_str, "%d", (int) cur); - - pango_layout_set_text (pango_layout, unit_str, -1); - - gdk_draw_layout (ruler->backing_store, gc, - pos + 2, 0, pango_layout); - } - - /* Calculate cur from start rather than incrementing by subd_incr - * in each iteration. This is to avoid propagation of floating point - * errors in subd_incr. - */ - ++tick_index; - cur = start + tick_index * subd_incr; - } - } -} - -static void -sp_hruler_draw_pos (GtkRuler *ruler) -{ - GtkWidget *widget; - GdkGC *gc; - int i; - gint x, y; - gint width, height; - gint bs_width, bs_height; - gint xthickness; - gint ythickness; - gfloat increment; + double pos = ruler->lower + (ruler->upper - ruler->lower) * (x + UNUSED_PIXELS) / (widget->allocation.width + 2*UNUSED_PIXELS); - g_return_if_fail (ruler != NULL); - g_return_if_fail (SP_IS_HRULER (ruler)); - - if (GTK_WIDGET_DRAWABLE (ruler)) - { - widget = GTK_WIDGET (ruler); - - gc = widget->style->fg_gc[GTK_STATE_NORMAL]; - xthickness = widget->style->xthickness; - ythickness = widget->style->ythickness; - width = widget->allocation.width; // in pixels; is apparently 2 pixels shorter than the canvas at each end - height = widget->allocation.height - ythickness * 2; - - bs_width = height / 2; - bs_width |= 1; /* make sure it's odd */ - bs_height = bs_width / 2 + 1; - - if ((bs_width > 0) && (bs_height > 0)) - { - /* If a backing store exists, restore the ruler */ - if (ruler->backing_store && ruler->non_gr_exp_gc) - gdk_draw_pixmap (ruler->widget.window, - ruler->non_gr_exp_gc, - ruler->backing_store, - ruler->xsrc, ruler->ysrc, - ruler->xsrc, ruler->ysrc, - bs_width, bs_height); - - increment = (gfloat) (width + 2*UNUSED_PIXELS) / (ruler->upper - ruler->lower); - - // Calculate the coordinates (x, y, in pixels) of the tip of the triangle - x = int(Inkscape::round((ruler->position - ruler->lower) * increment + double(xthickness - bs_width) / 2.0) - UNUSED_PIXELS); - y = (height + bs_height) / 2 + ythickness; - - for (i = 0; i < bs_height; i++) - gdk_draw_line (widget->window, gc, - x + i, y + i, - x + bs_width - 1 - i, y + i); - - - ruler->xsrc = x; - ruler->ysrc = y; - } - } -} + gtk_ruler_set_range(ruler, ruler->lower, ruler->upper, pos, ruler->max_size); -/** - * The hruler widget's size_allocate callback. - */ -static void -sp_hruler_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - g_assert (widget != NULL); - g_assert (SP_IS_HRULER (widget)); - - // First call the default gtk_widget_size_allocate() method (which is being overridden here) - if (GTK_WIDGET_CLASS (hruler_parent_class)->size_allocate) - (* GTK_WIDGET_CLASS (hruler_parent_class)->size_allocate) (widget, allocation); - - // Now the size of the ruler has changed, the ruler bounds (upper & lower) need to be updated - // For this we first need to obtain a pointer to the desktop, by walking up the tree of ancestors - GtkWidget *parent = gtk_widget_get_parent(widget); - do { - if (SP_IS_DESKTOP_WIDGET(parent)) { - // Now we've found the desktop widget we can have the ruler boundaries updated - sp_desktop_widget_update_hruler(SP_DESKTOP_WIDGET(parent)); - // If the size of the ruler has increased, then a blank part is uncovered; therefore - // it must be redrawn - sp_hruler_draw_ticks(GTK_RULER(widget)); - break; - } - parent = gtk_widget_get_parent(parent); - } while (parent != NULL); + return FALSE; } - - - // vruler static void sp_vruler_class_init (SPVRulerClass *klass); static void sp_vruler_init (SPVRuler *vruler); static gint sp_vruler_motion_notify (GtkWidget *widget, GdkEventMotion *event); -static void sp_vruler_draw_ticks (GtkRuler *ruler); -static void sp_vruler_draw_pos (GtkRuler *ruler); static void sp_vruler_size_request (GtkWidget *widget, GtkRequisition *requisition); -static void sp_vruler_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static GtkWidgetClass *vruler_parent_class; @@ -421,11 +169,9 @@ sp_vruler_class_init (SPVRulerClass *klass) ruler_class = (GtkRulerClass*) klass; widget_class->motion_notify_event = sp_vruler_motion_notify; - widget_class->size_allocate = sp_vruler_size_allocate; widget_class->size_request = sp_vruler_size_request; - ruler_class->draw_ticks = sp_vruler_draw_ticks; - ruler_class->draw_pos = sp_vruler_draw_pos; + ruler_class->draw_ticks = sp_ruler_common_draw_ticks; } static void @@ -436,6 +182,8 @@ sp_vruler_init (SPVRuler *vruler) widget = GTK_WIDGET (vruler); widget->requisition.width = widget->style->xthickness * 2 + RULER_WIDTH; widget->requisition.height = widget->style->ythickness * 2 + 1; + + g_object_set(G_OBJECT(vruler), "orientation", GTK_ORIENTATION_VERTICAL, NULL); } GtkWidget* @@ -457,267 +205,189 @@ sp_vruler_motion_notify (GtkWidget *widget, ruler = GTK_RULER (widget); double y = event->y; //Although event->y is double according to the docs, it only appears to return integers - ruler->position = ruler->lower + (ruler->upper - ruler->lower) * (y + UNUSED_PIXELS) / (widget->allocation.height + 2*UNUSED_PIXELS); + double pos = ruler->lower + (ruler->upper - ruler->lower) * (y + UNUSED_PIXELS) / (widget->allocation.height + 2*UNUSED_PIXELS); - /* Make sure the ruler has been allocated already */ - if (ruler->backing_store != NULL) - gtk_ruler_draw_pos (ruler); + gtk_ruler_set_range(ruler, ruler->lower, ruler->upper, pos, ruler->max_size); return FALSE; } static void -sp_vruler_draw_ticks (GtkRuler *ruler) +sp_vruler_size_request (GtkWidget *widget, GtkRequisition *requisition) { - GtkWidget *widget; - GdkGC *gc, *bg_gc; - PangoFontDescription *pango_desc; - PangoContext *pango_context; - PangoLayout *pango_layout; - gint i, j, tick_index; - gint width, height; - gint xthickness; - gint ythickness; - gint length, ideal_length; - double lower, upper; /* Upper and lower limits, in ruler units */ - double increment; /* Number of pixels per unit */ - gint scale; /* Number of units per major unit */ - double subd_incr; - double start, end, cur; - gchar unit_str[32]; - gchar digit_str[2] = { '\0', '\0' }; - gint digit_height; - gint text_height; - gint pos; - - g_return_if_fail (ruler != NULL); - g_return_if_fail (SP_IS_VRULER (ruler)); - - if (!GTK_WIDGET_DRAWABLE (ruler)) - return; - - widget = GTK_WIDGET (ruler); - - gc = widget->style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = widget->style->bg_gc[GTK_STATE_NORMAL]; - - pango_desc = widget->style->font_desc; - - // Create the pango layout - pango_context = gtk_widget_get_pango_context (widget); - - pango_layout = pango_layout_new (pango_context); - - PangoFontDescription *fs = pango_font_description_new (); - pango_font_description_set_size (fs, RULER_FONT_SIZE); - pango_layout_set_font_description (pango_layout, fs); - pango_font_description_free (fs); - - digit_height = (int) floor (RULER_FONT_SIZE * RULER_FONT_VERTICAL_SPACING / PANGO_SCALE + 0.5); - - xthickness = widget->style->xthickness; - ythickness = widget->style->ythickness; - - width = widget->allocation.height; //in pixels; is apparently 2 pixels shorter than the canvas at each end - height = widget->allocation.width;// - ythickness * 2; - - gtk_paint_box (widget->style, ruler->backing_store, - GTK_STATE_NORMAL, GTK_SHADOW_NONE, - NULL, widget, "vruler", - 0, 0, - widget->allocation.width, widget->allocation.height); - - upper = ruler->upper / ruler->metric->pixels_per_unit; // upper and lower are expressed in ruler units - lower = ruler->lower / ruler->metric->pixels_per_unit; - /* "pixels_per_unit" should be "points_per_unit". This is the size of the unit - * in 1/72nd's of an inch and has nothing to do with screen pixels */ - - if ((upper - lower) == 0) - return; - increment = (double) (width + 2*UNUSED_PIXELS) / (upper - lower); // screen pixels per ruler unit - - /* determine the scale - * use the maximum extents of the ruler to determine the largest - * possible number to be displayed. Calculate the height in pixels - * of this displayed text. Use this height to find a scale which - * leaves sufficient room for drawing the ruler. - */ - scale = (int)ceil (ruler->max_size / ruler->metric->pixels_per_unit); - sprintf (unit_str, "%d", scale); - text_height = strlen (unit_str) * digit_height + 1; - - for (scale = 0; scale < MAXIMUM_SCALES; scale++) - if (ruler->metric->ruler_scale[scale] * fabs(increment) > 2 * text_height) - break; - - if (scale == MAXIMUM_SCALES) - scale = MAXIMUM_SCALES - 1; - - /* drawing starts here */ - length = 0; - for (i = MAXIMUM_SUBDIVIDE - 1; i >= 0; i--) { - subd_incr = (double) ruler->metric->ruler_scale[scale] / - (double) ruler->metric->subdivide[i]; - if (subd_incr * fabs(increment) <= MINIMUM_INCR) - continue; - - /* Calculate the length of the tickmarks. Make sure that - * this length increases for each set of ticks - */ - ideal_length = height / (i + 1) - 1; - if (ideal_length > ++length) - length = ideal_length; - - if (lower < upper) - { - start = floor (lower / subd_incr) * subd_incr; - end = ceil (upper / subd_incr) * subd_incr; - } - else - { - start = floor (upper / subd_incr) * subd_incr; - end = ceil (lower / subd_incr) * subd_incr; - } - - tick_index = 0; - cur = start; // location (in ruler units) of the first invisible tick at the top side of the canvas - - while (cur < end) { - // due to the typical values for cur, lower and increment, pos will often end up to - // be e.g. 641.50000000000; rounding behaviour is not defined in such a case (see round.h) - // and jitter will be apparent (upon redrawing some of the lines on the ruler might jump a - // by a pixel, and jump back on the next redraw). This is suppressed by adding 1e-9 (that's only one nanopixel ;-)) - pos = int(Inkscape::round((cur - lower) * increment + 1e-12)) - UNUSED_PIXELS; - - gdk_draw_line (ruler->backing_store, gc, - height + xthickness - length, pos, - height + xthickness, pos); - - /* draw label */ - double label_spacing_px = fabs((increment*(double)ruler->metric->ruler_scale[scale])/ruler->metric->subdivide[i]); - if (i == 0 && - (label_spacing_px > 6*digit_height || tick_index%2 == 0 || cur == 0) && - (label_spacing_px > 3*digit_height || tick_index%4 == 0 || cur == 0)) - { - if (fabs((int)cur) >= 2000 && (((int) cur)/1000)*1000 == ((int) cur)) - sprintf (unit_str, "%dk", ((int) cur)/1000); - else - sprintf (unit_str, "%d", (int) cur); - for (j = 0; j < (int) strlen (unit_str); j++) - { - digit_str[0] = unit_str[j]; - - pango_layout_set_text (pango_layout, digit_str, 1); - - gdk_draw_layout (ruler->backing_store, gc, - xthickness + 1, - pos + digit_height * (j) + 1, - pango_layout); - } - } - - /* Calculate cur from start rather than incrementing by subd_incr - * in each iteration. This is to avoid propagation of floating point - * errors in subd_incr. - */ - ++tick_index; - cur = start + tick_index * subd_incr; - } - } + requisition->width = widget->style->xthickness * 2 + RULER_WIDTH; } static void -sp_vruler_draw_pos (GtkRuler *ruler) +sp_ruler_common_draw_ticks (GtkRuler *ruler) { - GtkWidget *widget; - GdkGC *gc; - int i; - gint x, y; - gint width, height; - gint bs_width, bs_height; - gint xthickness; - gint ythickness; - gfloat increment; - - g_return_if_fail (ruler != NULL); - g_return_if_fail (SP_IS_VRULER (ruler)); - - if (GTK_WIDGET_DRAWABLE (ruler)) - { - widget = GTK_WIDGET (ruler); - - gc = widget->style->fg_gc[GTK_STATE_NORMAL]; - xthickness = widget->style->xthickness; - ythickness = widget->style->ythickness; - width = widget->allocation.width - xthickness * 2; - height = widget->allocation.height; // in pixels; is apparently 2 pixels shorter than the canvas at each end - - bs_height = width / 2; - bs_height |= 1; /* make sure it's odd */ - bs_width = bs_height / 2 + 1; - - if ((bs_width > 0) && (bs_height > 0)) - { - /* If a backing store exists, restore the ruler */ - if (ruler->backing_store && ruler->non_gr_exp_gc) - gdk_draw_pixmap (ruler->widget.window, - ruler->non_gr_exp_gc, - ruler->backing_store, - ruler->xsrc, ruler->ysrc, - ruler->xsrc, ruler->ysrc, - bs_width, bs_height); - - increment = (gfloat) (height + 2*UNUSED_PIXELS) / (ruler->upper - ruler->lower); - - // Calculate the coordinates (x, y, in pixels) of the tip of the triangle - x = (width + bs_width) / 2 + xthickness; - y = int(Inkscape::round((ruler->position - ruler->lower) * increment + double(ythickness - bs_height) / 2.0) - UNUSED_PIXELS); - - for (i = 0; i < bs_width; i++) - gdk_draw_line (widget->window, gc, - x + i, y + i, - x + i, y + bs_height - 1 - i); - - ruler->xsrc = x; - ruler->ysrc = y; - } + GtkWidget *widget; + GdkGC *gc, *bg_gc; + PangoFontDescription *pango_desc; + PangoContext *pango_context; + PangoLayout *pango_layout; + gint i, j, tick_index; + gint width, height; + gint xthickness; + gint ythickness; + gint length, ideal_length; + double lower, upper; /* Upper and lower limits, in ruler units */ + double increment; /* Number of pixels per unit */ + gint scale; /* Number of units per major unit */ + double subd_incr; + double start, end, cur; + gchar unit_str[32]; + gchar digit_str[2] = { '\0', '\0' }; + gint digit_height; + //gint text_width, text_height; + gint text_dimension; + gint pos; + GtkOrientation orientation; + + g_return_if_fail (ruler != NULL); + + if (!GTK_WIDGET_DRAWABLE (ruler)) + return; + + g_object_get(G_OBJECT(ruler), "orientation", &orientation, NULL); + widget = GTK_WIDGET (ruler); + gc = widget->style->fg_gc[GTK_STATE_NORMAL]; + bg_gc = widget->style->bg_gc[GTK_STATE_NORMAL]; + + pango_desc = widget->style->font_desc; + pango_context = gtk_widget_get_pango_context (widget); + pango_layout = pango_layout_new (pango_context); + PangoFontDescription *fs = pango_font_description_new (); + pango_font_description_set_size (fs, RULER_FONT_SIZE); + pango_layout_set_font_description (pango_layout, fs); + pango_font_description_free (fs); + + digit_height = (int) floor (RULER_FONT_SIZE * RULER_FONT_VERTICAL_SPACING / PANGO_SCALE + 0.5); + xthickness = widget->style->xthickness; + ythickness = widget->style->ythickness; + + if (orientation == GTK_ORIENTATION_HORIZONTAL) { + width = widget->allocation.width; // in pixels; is apparently 2 pixels shorter than the canvas at each end + height = widget->allocation.height; + } else { + width = widget->allocation.height; + height = widget->allocation.width; } -} -static void -sp_vruler_size_request (GtkWidget *widget, GtkRequisition *requisition) -{ - requisition->width = widget->style->xthickness * 2 + RULER_WIDTH; -} + gtk_paint_box (widget->style, ruler->backing_store, + GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, widget, + orientation == GTK_ORIENTATION_HORIZONTAL ? "hruler" : "vruler", + 0, 0, + widget->allocation.width, widget->allocation.height); + + upper = ruler->upper / ruler->metric->pixels_per_unit; // upper and lower are expressed in ruler units + lower = ruler->lower / ruler->metric->pixels_per_unit; + /* "pixels_per_unit" should be "points_per_unit". This is the size of the unit + * in 1/72nd's of an inch and has nothing to do with screen pixels */ + + if ((upper - lower) == 0) + return; + + increment = (double) (width + 2*UNUSED_PIXELS) / (upper - lower); // screen pixels per ruler unit + + /* determine the scale + * For vruler, use the maximum extents of the ruler to determine the largest + * possible number to be displayed. Calculate the height in pixels + * of this displayed text. Use this height to find a scale which + * leaves sufficient room for drawing the ruler. + * For hruler, we calculate the text size as for the vruler instead of using + * text_width = gdk_string_width(font, unit_str), so that the result + * for the scale looks consistent with an accompanying vruler + */ + scale = (int)(ceil (ruler->max_size / ruler->metric->pixels_per_unit)); + sprintf (unit_str, "%d", scale); + text_dimension = strlen (unit_str) * digit_height + 1; + + for (scale = 0; scale < MAXIMUM_SCALES; scale++) + if (ruler->metric->ruler_scale[scale] * fabs(increment) > 2 * text_dimension) + break; + + if (scale == MAXIMUM_SCALES) + scale = MAXIMUM_SCALES - 1; + + /* drawing starts here */ + length = 0; + for (i = MAXIMUM_SUBDIVIDE - 1; i >= 0; i--) { + subd_incr = ruler->metric->ruler_scale[scale] / + ruler->metric->subdivide[i]; + if (subd_incr * fabs(increment) <= MINIMUM_INCR) + continue; + + /* Calculate the length of the tickmarks. Make sure that + * this length increases for each set of ticks + */ + ideal_length = height / (i + 1) - 1; + if (ideal_length > ++length) + length = ideal_length; + + if (lower < upper) { + start = floor (lower / subd_incr) * subd_incr; + end = ceil (upper / subd_incr) * subd_incr; + } else { + start = floor (upper / subd_incr) * subd_incr; + end = ceil (lower / subd_incr) * subd_incr; + } + tick_index = 0; + cur = start; // location (in ruler units) of the first invisible tick at the left side of the canvas -/** - * The vruler widget's size_allocate callback. - */ -static void -sp_vruler_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - g_assert (widget != NULL); - g_assert (SP_IS_VRULER (widget)); - - // First call the default gtk_widget_size_allocate() method (which is being overridden here) - if (GTK_WIDGET_CLASS (vruler_parent_class)->size_allocate) - (* GTK_WIDGET_CLASS (vruler_parent_class)->size_allocate) (widget, allocation); - - // Now the size of the ruler has changed, the ruler bounds (upper & lower) need to be updated - // For this we first need to obtain a pointer to the desktop, by walking up the tree of ancestors - GtkWidget *parent = gtk_widget_get_parent(widget); - do { - if (SP_IS_DESKTOP_WIDGET(parent)) { - // Now we've found the desktop widget we can have the ruler boundaries updated - sp_desktop_widget_update_vruler(SP_DESKTOP_WIDGET(parent)); - // If the size of the ruler has increased, then a blank part is uncovered; therefore - // it must be redrawn - sp_vruler_draw_ticks(GTK_RULER(widget)); - break; + while (cur <= end) { + // due to the typical values for cur, lower and increment, pos will often end up to + // be e.g. 641.50000000000; rounding behaviour is not defined in such a case (see round.h) + // and jitter will be apparent (upon redrawing some of the lines on the ruler might jump a + // by a pixel, and jump back on the next redraw). This is suppressed by adding 1e-9 (that's only one nanopixel ;-)) + pos = int(Inkscape::round((cur - lower) * increment + 1e-12)) - UNUSED_PIXELS; + + if (orientation == GTK_ORIENTATION_HORIZONTAL) { + gdk_draw_line (ruler->backing_store, gc, + pos, height + ythickness, + pos, height - length + ythickness); + } else { + gdk_draw_line (ruler->backing_store, gc, + height + xthickness - length, pos, + height + xthickness, pos); + } + + /* draw label */ + double label_spacing_px = fabs((increment*(double)ruler->metric->ruler_scale[scale])/ruler->metric->subdivide[i]); + if (i == 0 && + (label_spacing_px > 6*digit_height || tick_index%2 == 0 || cur == 0) && + (label_spacing_px > 3*digit_height || tick_index%4 == 0 || cur == 0)) + { + if (fabs((int)cur) >= 2000 && (((int) cur)/1000)*1000 == ((int) cur)) + sprintf (unit_str, "%dk", ((int) cur)/1000); + else + sprintf (unit_str, "%d", (int) cur); + + if (orientation == GTK_ORIENTATION_HORIZONTAL) { + pango_layout_set_text (pango_layout, unit_str, -1); + gdk_draw_layout (ruler->backing_store, gc, + pos + 2, 0, pango_layout); + } else { + for (j = 0; j < (int) strlen (unit_str); j++) { + digit_str[0] = unit_str[j]; + pango_layout_set_text (pango_layout, digit_str, 1); + + gdk_draw_layout (ruler->backing_store, gc, + xthickness + 1, + pos + digit_height * (j) + 1, + pango_layout); + } + } + } + /* Calculate cur from start rather than incrementing by subd_incr + * in each iteration. This is to avoid propagation of floating point + * errors in subd_incr. + */ + ++tick_index; + cur = start + tick_index * subd_incr; } - parent = gtk_widget_get_parent(parent); - } while (parent != NULL); + } } //TODO: warning: deprecated conversion from string constant to ‘gchar*’ -- cgit v1.2.3