summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2010-11-25 20:51:17 +0000
committerKrzysztof Kosiński <tweenk.pl@gmail.com>2010-11-25 20:51:17 +0000
commit0bd9f7e209d522dbcebe0449a91397fdd9e38977 (patch)
tree834c7d02456658b57625ab68cc28f7854a5a85dc /src/widgets
parentFix handling of x and y attributes of patterns (diff)
parentFix ruler redraw issue on GTK 2.22 (diff)
downloadinkscape-0bd9f7e209d522dbcebe0449a91397fdd9e38977.tar.gz
inkscape-0bd9f7e209d522dbcebe0449a91397fdd9e38977.zip
Merge from trunk
(bzr r9508.1.70)
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/button.cpp44
-rw-r--r--src/widgets/dash-selector.cpp2
-rw-r--r--src/widgets/dash-selector.h2
-rw-r--r--src/widgets/desktop-widget.cpp39
-rw-r--r--src/widgets/eek-preview.cpp2
-rw-r--r--src/widgets/eek-preview.h2
-rw-r--r--src/widgets/ege-paint-def.cpp2
-rw-r--r--src/widgets/ege-paint-def.h2
-rw-r--r--src/widgets/fill-n-stroke-factory.h2
-rw-r--r--src/widgets/fill-style.cpp2
-rw-r--r--src/widgets/fill-style.h2
-rw-r--r--src/widgets/font-selector.cpp4
-rw-r--r--src/widgets/font-selector.h2
-rw-r--r--src/widgets/gradient-vector.cpp29
-rw-r--r--src/widgets/gradient-vector.h2
-rw-r--r--src/widgets/icon.cpp2
-rw-r--r--src/widgets/paint-selector.cpp2
-rw-r--r--src/widgets/paint-selector.h2
-rw-r--r--src/widgets/ruler.cpp682
-rw-r--r--src/widgets/ruler.h2
-rw-r--r--src/widgets/select-toolbar.cpp16
-rw-r--r--src/widgets/select-toolbar.h2
-rw-r--r--src/widgets/shrink-wrap-button.cpp2
-rw-r--r--src/widgets/shrink-wrap-button.h2
-rw-r--r--src/widgets/sp-attribute-widget.cpp2
-rw-r--r--src/widgets/sp-attribute-widget.h2
-rw-r--r--src/widgets/sp-color-icc-selector.cpp16
-rw-r--r--src/widgets/sp-color-icc-selector.h2
-rw-r--r--src/widgets/sp-color-notebook.cpp2
-rw-r--r--src/widgets/sp-color-notebook.h2
-rw-r--r--src/widgets/sp-color-scales.cpp26
-rw-r--r--src/widgets/sp-color-selector.cpp6
-rw-r--r--src/widgets/sp-color-selector.h2
-rw-r--r--src/widgets/sp-color-wheel-selector.cpp4
-rw-r--r--src/widgets/sp-color-wheel-selector.h2
-rw-r--r--src/widgets/sp-color-wheel.cpp2
-rw-r--r--src/widgets/sp-color-wheel.h2
-rw-r--r--src/widgets/spinbutton-events.h2
-rw-r--r--src/widgets/spw-utilities.cpp2
-rw-r--r--src/widgets/spw-utilities.h2
-rw-r--r--src/widgets/stroke-style.cpp7
-rw-r--r--src/widgets/stroke-style.h2
-rw-r--r--src/widgets/swatch-selector.cpp2
-rw-r--r--src/widgets/swatch-selector.h2
-rw-r--r--src/widgets/toolbox.cpp26
-rw-r--r--src/widgets/toolbox.h2
-rw-r--r--src/widgets/widget-sizes.h2
47 files changed, 330 insertions, 639 deletions
diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp
index 6769fa389..dc830d096 100644
--- a/src/widgets/button.cpp
+++ b/src/widgets/button.cpp
@@ -27,6 +27,8 @@
#include "shortcuts.h"
#include "interface.h"
+#include <gdk/gdkkeysyms.h>
+
#include "icon.h"
#include "button.h"
@@ -286,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) {
- // there's both action and shortcut
-
- gchar key[256];
- sp_ui_shortcut_string (shortcut, key);
-
- gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key);
- gtk_tooltips_set_tip (tooltips, widget, tip, NULL);
- g_free (tip);
-
- } 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/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/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 <extension/db.h>
#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<UnitTracker*>( 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);
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.cpp b/src/widgets/font-selector.cpp
index cac4caee0..965910ba2 100644
--- a/src/widgets/font-selector.cpp
+++ b/src/widgets/font-selector.cpp
@@ -177,10 +177,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/font-selector.h b/src/widgets/font-selector.h
index 2c4e26610..febd4a34a 100644
--- a/src/widgets/font-selector.h
+++ b/src/widgets/font-selector.h
@@ -49,4 +49,4 @@ double sp_font_selector_get_size (SPFontSelector *fsel);
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 f37158eec..06ba7b908 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -649,25 +649,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<GtkOptionMenu *>(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<GtkOptionMenu *>(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)
@@ -1204,4 +1201,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 d8f451ed7..d039dd2de 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -1450,4 +1450,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.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*’
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.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/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 6bd1957a8..4b565d1a3 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);
@@ -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-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-selector.cpp b/src/widgets/sp-color-selector.cpp
index 203bc3c2a..c6f13b391 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++;
@@ -357,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 6012f4e20..5ba2c347b 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);
@@ -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 5e1547e10..ade226c0f 100644
--- a/src/widgets/sp-color-wheel.cpp
+++ b/src/widgets/sp-color-wheel.cpp
@@ -1158,4 +1158,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 3e628c2cf..43bc5fc07 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);
@@ -1474,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 08e463ea4..0c94f5d68 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -303,7 +303,7 @@ static gchar const * ui_descr =
" <separator />"
" <toolitem action='ObjectEditClipPathAction' />"
" <toolitem action='ObjectEditMaskPathAction' />"
- " <toolitem action='EditNextLPEParameterAction' />"
+ " <toolitem action='EditNextPathEffectParameter' />"
" <separator />"
" <toolitem action='NodesShowTransformHandlesAction' />"
" <toolitem action='NodesShowHandlesAction' />"
@@ -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 );
@@ -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 ) );
@@ -8461,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 :