Code

ok, fix another crash caused by GTK's broken spinbuttons
[inkscape.git] / src / widgets / select-toolbar.cpp
1 /*
2  * Selector aux toolbar
3  *
4  * Authors:
5  *   Lauris Kaplinski <lauris@kaplinski.com>
6  *   bulia byak <buliabyak@users.sf.net>
7  *
8  * Copyright (C) 2003-2005 authors
9  *
10  * Released under GNU GPL, read the file 'COPYING' for more information
11  */
13 #ifdef HAVE_CONFIG_H
14 # include "config.h"
15 #endif
17 #include <gtk/gtk.h>
19 #include "widgets/button.h"
20 #include "widgets/spw-utilities.h"
21 #include "widgets/widget-sizes.h"
22 #include "widgets/spinbutton-events.h"
23 #include "widgets/icon.h"
24 #include "widgets/sp-widget.h"
26 #include "prefs-utils.h"
27 #include "selection-chemistry.h"
28 #include "document.h"
29 #include "inkscape.h"
30 #include "desktop-style.h"
31 #include "desktop.h"
32 #include "desktop-handles.h"
33 #include "sp-namedview.h"
34 #include "toolbox.h"
35 #include <glibmm/i18n.h>
36 #include "helper/unit-menu.h"
37 #include "helper/units.h"
38 #include "inkscape.h"
39 #include "verbs.h"
40 #include "prefs-utils.h"
41 #include "selection.h"
42 #include "selection-chemistry.h"
43 #include "sp-item-transform.h"
44 #include "message-stack.h"
45 #include "display/sp-canvas.h"
47 static void
48 sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel)
49 {
50     if (gtk_object_get_data(GTK_OBJECT(spw), "update")) {
51         return;
52     }
54     gtk_object_set_data(GTK_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
56     GtkWidget *f = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(spw), "frame");
58     using NR::X;
59     using NR::Y;
60     if ( sel && !sel->isEmpty() ) {
61         NR::Rect const bbox(sel->bounds());
62         NR::Point const dimensions(bbox.dimensions());
63         if ((dimensions[X] > 1e-6) || (dimensions[Y] > 1e-6)) {
64             GtkWidget *us = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(spw), "units");
65             SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(us));
67             if (unit.base == SP_UNIT_DIMENSIONLESS) {
68                 char const * const keys[] = {"X", "Y", "width", "height"};
69                 double const val = 1. / unit.unittobase;
70                 for (unsigned i = 0; i < G_N_ELEMENTS(keys); ++i) {
71                     GtkAdjustment *a = (GtkAdjustment *) gtk_object_get_data(GTK_OBJECT(spw), keys[i]);
72                     gtk_adjustment_set_value(a, val);
73                 }
74             } else {
75                 struct { char const *key; double val; } const keyval[] = {
76                     { "X", bbox.min()[X] },
77                     { "Y", bbox.min()[Y] },
78                     { "width", dimensions[X] },
79                     { "height", dimensions[Y] }
80                 };
81                 for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) {
82                     GtkAdjustment *a = (GtkAdjustment *) gtk_object_get_data(GTK_OBJECT(spw), keyval[i].key);
83                     gtk_adjustment_set_value(a, sp_pixels_get_units(keyval[i].val, unit));
84                 }
85             }
87             gtk_widget_set_sensitive(f, TRUE);
88         } else {
89             gtk_widget_set_sensitive(f, FALSE);
90         }
91     } else {
92         gtk_widget_set_sensitive(f, FALSE);
93     }
95     gtk_object_set_data(GTK_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
96 }
99 static void
100 sp_selection_layout_widget_modify_selection(SPWidget *spw, Inkscape::Selection *selection, guint flags, gpointer data)
102     SPDesktop *desktop = (SPDesktop *) data;
103     if ((sp_desktop_selection(desktop) == selection) // only respond to changes in our desktop
104         && (flags & (SP_OBJECT_MODIFIED_FLAG        |
105                      SP_OBJECT_PARENT_MODIFIED_FLAG |
106                      SP_OBJECT_CHILD_MODIFIED_FLAG   )))
107     {
108         sp_selection_layout_widget_update(spw, selection);
109     }
112 static void
113 sp_selection_layout_widget_change_selection(SPWidget *spw, Inkscape::Selection *selection, gpointer data)
115     SPDesktop *desktop = (SPDesktop *) data;
116     if (sp_desktop_selection(desktop) == selection) // only respond to changes in our desktop
117         sp_selection_layout_widget_update(spw, selection);
120 static void
121 sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
123     if (gtk_object_get_data(GTK_OBJECT(spw), "update")) {
124         return;
125     }
127     GtkWidget *us = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(spw), "units");
128     SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(us));
129     if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(us))) {
130         /*
131          * When only units are being changed, don't treat changes
132          * to adjuster values as object changes.
133          */
134         return;
135     }
136     gtk_object_set_data(GTK_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
138     SPDesktop *desktop = SP_ACTIVE_DESKTOP;
139     Inkscape::Selection *selection = sp_desktop_selection(desktop);
140     SPDocument *document = sp_desktop_document(desktop);
142     sp_document_ensure_up_to_date (document);
143     NR::Rect bbox = selection->bounds();
145     if (!((bbox.max()[NR::X] - bbox.min()[NR::X] > 1e-6) || (bbox.max()[NR::Y] - bbox.min()[NR::Y] > 1e-6))) {
146         return;
147     }
149     gdouble x0, y0, x1, y1, xrel, yrel;
150     GtkAdjustment *a_w;
151     GtkAdjustment *a_h;
153     if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) {
154         GtkAdjustment *a;
155         a = (GtkAdjustment *) gtk_object_get_data(GTK_OBJECT(spw), "X");
156         x0 = sp_units_get_pixels (a->value, unit);
157         a = (GtkAdjustment *) gtk_object_get_data(GTK_OBJECT(spw), "Y");
158         y0 = sp_units_get_pixels (a->value, unit);
159         a_w = (GtkAdjustment *) gtk_object_get_data(GTK_OBJECT(spw), "width");
160         x1 = x0 + sp_units_get_pixels (a_w->value, unit);
161         xrel = sp_units_get_pixels (a_w->value, unit) / bbox.extent(NR::X);
162         a_h = (GtkAdjustment *) gtk_object_get_data(GTK_OBJECT(spw), "height");
163         y1 = y0 + sp_units_get_pixels (a_h->value, unit);
164         yrel = sp_units_get_pixels (a_h->value, unit) / bbox.extent(NR::Y);
165     } else {
166         GtkAdjustment *a;
167         a = (GtkAdjustment *) gtk_object_get_data(GTK_OBJECT(spw), "X");
168         double const x0_propn = a->value * unit.unittobase;
169         x0 = bbox.min()[NR::X] * x0_propn;
170         a = (GtkAdjustment *) gtk_object_get_data(GTK_OBJECT(spw), "Y");
171         double const y0_propn = a->value * unit.unittobase;
172         y0 = y0_propn * bbox.min()[NR::Y];
173         a_w = (GtkAdjustment *) gtk_object_get_data(GTK_OBJECT(spw), "width");
174         xrel = a_w->value * unit.unittobase;
175         x1 = x0 + xrel * bbox.extent(NR::X);
176         a_h = (GtkAdjustment *) gtk_object_get_data(GTK_OBJECT(spw), "height");
177         yrel = a_h->value * unit.unittobase;
178         y1 = y0 + yrel * bbox.extent(NR::Y);
179     }
181     // Keep proportions if lock is on
182     GtkWidget *lock = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "lock"));
183     if (SP_BUTTON_IS_DOWN(lock)) {
184         if (adj == a_h) {
185             x1 = x0 + yrel * bbox.extent(NR::X);
186         } else if (adj == a_w) {
187             y1 = y0 + xrel * bbox.extent(NR::Y);
188         }
189     }
191     // scales and moves, in px
192     double mh = fabs(x0 - bbox.min()[NR::X]);
193     double sh = fabs(x1 - bbox.max()[NR::X]);
194     double mv = fabs(y0 - bbox.min()[NR::Y]);
195     double sv = fabs(y1 - bbox.max()[NR::Y]);
197     // unless the unit is %, convert the scales and moves to the unit
198     if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) {
199         mh = sp_pixels_get_units (mh, unit);
200         sh = sp_pixels_get_units (sh, unit);
201         mv = sp_pixels_get_units (mv, unit);
202         sv = sp_pixels_get_units (sv, unit);
203     }
205     // do the action only if one of the scales/moves is greater than half the last significant
206     // digit in the spinbox (currently spinboxes have 3 fractional digits, so that makes 0.0005). If
207     // the value was changed by the user, the difference will be at least that much; otherwise it's
208     // just rounding difference between the spinbox value and actual value, so no action is
209     // performed
210     char const * const actionkey = ( mh > 5e-4 ? "selector:toolbar:move:horizontal" : 
211                                      sh > 5e-4 ? "selector:toolbar:scale:horizontal" : 
212                                      mv > 5e-4 ? "selector:toolbar:move:vertical" : 
213                                      sv > 5e-4 ? "selector:toolbar:scale:vertical" : NULL );
215     if (actionkey != NULL) {
217         // FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed
218         sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
220         gdouble strokewidth = stroke_average_width (selection->itemList());
221         int transform_stroke = prefs_get_int_attribute ("options.transform", "stroke", 1);
223         NR::Matrix scaler = get_scale_transform_with_stroke (bbox, strokewidth, transform_stroke, x0, y0, x1, y1);
225         sp_selection_apply_affine(selection, scaler);
226         sp_document_maybe_done (document, actionkey, SP_VERB_CONTEXT_SELECT, 
227                                 _("Transform by toolbar"));
229         // defocus spinbuttons by moving focus to the canvas, unless "stay" is on
230         spinbutton_defocus(GTK_OBJECT(spw));
232         // resume interruptibility
233         sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
234     }
236     gtk_object_set_data(GTK_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
239 GtkWidget *
240 sp_select_toolbox_spinbutton(gchar *label, gchar *data, float lower_limit, GtkWidget *us, GtkWidget *spw, gchar *tooltip, gboolean altx)
242     GtkTooltips *tt = gtk_tooltips_new();
244     GtkWidget *hb = gtk_hbox_new(FALSE, 1);
245     GtkWidget *l = gtk_label_new(Q_(label));
246     gtk_tooltips_set_tip(tt, l, tooltip, NULL);
247     gtk_widget_show(l);
248     gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5);
249     gtk_container_add(GTK_CONTAINER(hb), l);
251     GtkObject *a = gtk_adjustment_new(0.0, lower_limit, 1e6, SPIN_STEP, SPIN_PAGE_STEP, SPIN_PAGE_STEP);
252     sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(us), GTK_ADJUSTMENT(a));
253     gtk_object_set_data(GTK_OBJECT(spw), data, a);
255     GtkWidget *sb = gtk_spin_button_new(GTK_ADJUSTMENT(a), SPIN_STEP, 3);
256     gtk_tooltips_set_tip(tt, sb, tooltip, NULL);
257     gtk_widget_set_size_request(sb, AUX_SPINBUTTON_WIDTH, AUX_SPINBUTTON_HEIGHT);
258     gtk_widget_show(sb);
259     gtk_signal_connect(GTK_OBJECT(sb), "focus-in-event", GTK_SIGNAL_FUNC(spinbutton_focus_in), spw);
260     gtk_signal_connect(GTK_OBJECT(sb), "key-press-event", GTK_SIGNAL_FUNC(spinbutton_keypress), spw);
262     gtk_container_add(GTK_CONTAINER(hb), sb);
263     gtk_signal_connect(GTK_OBJECT(a), "value_changed", GTK_SIGNAL_FUNC(sp_object_layout_any_value_changed), spw);
265     if (altx) { // this spinbutton will be activated by alt-x
266         gtk_object_set_data(GTK_OBJECT(sb), "altx", sb);
267     }
269     return hb;
272 static gboolean aux_set_unit(SPUnitSelector *,
273                              SPUnit const *old,
274                              SPUnit const *new_units,
275                              GObject *dlg)
277     SPDesktop *desktop = SP_ACTIVE_DESKTOP;
279     if (!desktop) {
280         return FALSE;
281     }
283     Inkscape::Selection *selection = sp_desktop_selection(desktop);
285     if (selection->isEmpty())
286         return FALSE;
288     if ((old->base == SP_UNIT_ABSOLUTE || old->base == SP_UNIT_DEVICE)
289         && (new_units->base == SP_UNIT_DIMENSIONLESS))
290     {
292         /* Absolute to percentage */
293         g_object_set_data(dlg, "update", GUINT_TO_POINTER(TRUE));
295         GtkAdjustment *ax = GTK_ADJUSTMENT(g_object_get_data(dlg, "X"));
296         GtkAdjustment *ay = GTK_ADJUSTMENT(g_object_get_data(dlg, "Y"));
297         GtkAdjustment *aw = GTK_ADJUSTMENT(g_object_get_data(dlg, "width"));
298         GtkAdjustment *ah = GTK_ADJUSTMENT(g_object_get_data(dlg, "height"));
300         double const x = sp_units_get_pixels (ax->value, *old);
301         double const y = sp_units_get_pixels (ay->value, *old);
302         double const w = sp_units_get_pixels (aw->value, *old);
303         double const h = sp_units_get_pixels (ah->value, *old);
305         NR::Rect bbox = selection->bounds();
307         gtk_adjustment_set_value(ax, fabs(bbox.min()[NR::X]) > 1e-6? 100.0 * x / bbox.min()[NR::X] : 100.0);
308         gtk_adjustment_set_value(ay, fabs(bbox.min()[NR::Y]) > 1e-6? 100.0 * y / bbox.min()[NR::Y] : 100.0);
309         gtk_adjustment_set_value(aw, fabs(bbox.extent(NR::X)) > 1e-6? 100.0 * w / bbox.extent(NR::X) : 100.0);
310         gtk_adjustment_set_value(ah, fabs(bbox.extent(NR::Y)) > 1e-6? 100.0 * h / bbox.extent(NR::Y) : 100.0);
312         g_object_set_data(dlg, "update", GUINT_TO_POINTER(FALSE));
313         return TRUE;
314     } else if ((old->base == SP_UNIT_DIMENSIONLESS)
315                && (new_units->base == SP_UNIT_ABSOLUTE || new_units->base == SP_UNIT_DEVICE)) {
317         /* Percentage to absolute */
318         g_object_set_data(dlg, "update", GUINT_TO_POINTER(TRUE));
320         GtkAdjustment *ax = GTK_ADJUSTMENT(g_object_get_data(dlg, "X"));
321         GtkAdjustment *ay = GTK_ADJUSTMENT(g_object_get_data(dlg, "Y"));
322         GtkAdjustment *aw = GTK_ADJUSTMENT(g_object_get_data(dlg, "width"));
323         GtkAdjustment *ah = GTK_ADJUSTMENT(g_object_get_data(dlg, "height"));
325         NR::Rect bbox = selection->bounds();
327         gtk_adjustment_set_value(ax, sp_pixels_get_units(0.01 * ax->value * bbox.min()[NR::X], *new_units));
328         gtk_adjustment_set_value(ay, sp_pixels_get_units(0.01 * ay->value * bbox.min()[NR::Y], *new_units));
329         gtk_adjustment_set_value(aw, sp_pixels_get_units(0.01 * aw->value * bbox.extent(NR::X), *new_units));
330         gtk_adjustment_set_value(ah, sp_pixels_get_units(0.01 * ah->value * bbox.extent(NR::Y), *new_units));
332         g_object_set_data(dlg, "update", GUINT_TO_POINTER(FALSE));
333         return TRUE;
334     }
336     return FALSE;
339 // toggle button callbacks and updaters
341 static void toggle_stroke (GtkWidget *button, gpointer data) {
342     prefs_set_int_attribute ("options.transform", "stroke", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 1 : 0);
343     SPDesktop *desktop = (SPDesktop *)data;
344     if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
345         desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>stroke width</b> is <b>scaled</b> when objects are scaled."));
346     } else {
347         desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>stroke width</b> is <b>not scaled</b> when objects are scaled."));
348     }
351 static void toggle_corners (GtkWidget *button, gpointer data) {
352     prefs_set_int_attribute ("options.transform", "rectcorners", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 1 : 0);
353     SPDesktop *desktop = (SPDesktop *)data;
354     if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
355         desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>rounded rectangle corners</b> are <b>scaled</b> when rectangles are scaled."));
356     } else {
357         desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>rounded rectangle corners</b> are <b>not scaled</b> when rectangles are scaled."));
358     }
361 static void toggle_gradient (GtkWidget *button, gpointer data) {
362     prefs_set_int_attribute ("options.transform", "gradient", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 1 : 0);
363     SPDesktop *desktop = (SPDesktop *)data;
364     if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
365         desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>gradients</b> are <b>transformed</b> along with their objects when those are transformed (moved, scaled, rotated, or skewed)."));
366     } else {
367         desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>gradients</b> remain <b>fixed</b> when objects are transformed (moved, scaled, rotated, or skewed)."));
368     }
371 static void toggle_pattern (GtkWidget *button, gpointer data) {
372     prefs_set_int_attribute ("options.transform", "pattern", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 1 : 0);
373     SPDesktop *desktop = (SPDesktop *)data;
374     if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
375         desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>patterns</b> are <b>transformed</b> along with their objects when those are transformed (moved, scaled, rotated, or skewed)."));
376     } else {
377         desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>patterns</b> remain <b>fixed</b> when objects are transformed (moved, scaled, rotated, or skewed)."));
378     }
381 static void toggle_lock (GtkWidget *button, gpointer data) {
383     GtkWidget *old_child = gtk_bin_get_child(GTK_BIN(button));
384     gtk_container_remove (GTK_CONTAINER(button), old_child);
386     if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
387         GtkWidget *child = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, "width_height_lock");
388         gtk_widget_show (child);
389         gtk_container_add (GTK_CONTAINER (button), child);
390     } else {
391         GtkWidget *child = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, "lock_unlocked");
392         gtk_widget_show (child);
393         gtk_container_add (GTK_CONTAINER (button), child);
394     }
397 GtkWidget *
398 sp_select_toolbox_new(SPDesktop *desktop)
400     Inkscape::UI::View::View *view = desktop;
402     GtkTooltips *tt = gtk_tooltips_new();
403     GtkWidget *tb = gtk_hbox_new(FALSE, 0);
405     sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_OBJECT_ROTATE_90_CCW), view, tt);
406     sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_OBJECT_ROTATE_90_CW), view, tt);
407     sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_OBJECT_FLIP_HORIZONTAL), view, tt);
408     sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_OBJECT_FLIP_VERTICAL), view, tt);
410     aux_toolbox_space(tb, AUX_BETWEEN_BUTTON_GROUPS);
412     sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_SELECTION_TO_BACK), view, tt);
413     sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_SELECTION_LOWER), view, tt);
414     sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_SELECTION_RAISE), view, tt);
415     sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_SELECTION_TO_FRONT), view, tt);
417     // Create the parent widget for x y w h tracker.
418     GtkWidget *spw = sp_widget_new_global(INKSCAPE);
420     // Remember the desktop's canvas widget, to be used for defocusing.
421     gtk_object_set_data(GTK_OBJECT(spw), "dtw", sp_desktop_canvas(desktop));
423     // The vb frame holds all other widgets and is used to set sensitivity depending on selection state.
424     GtkWidget *vb = gtk_hbox_new(FALSE, 0);
425     gtk_widget_show(vb);
426     gtk_container_add(GTK_CONTAINER(spw), vb);
427     gtk_object_set_data(GTK_OBJECT(spw), "frame", vb);
429     // Create the units menu.
430     GtkWidget *us = sp_unit_selector_new(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE);
431     sp_unit_selector_setsize(us, AUX_OPTION_MENU_WIDTH, AUX_OPTION_MENU_HEIGHT);
432     sp_unit_selector_add_unit(SP_UNIT_SELECTOR(us), &sp_unit_get_by_id(SP_UNIT_PERCENT), 0);
433     sp_unit_selector_set_unit (SP_UNIT_SELECTOR(us), sp_desktop_namedview(desktop)->doc_units);
434     g_signal_connect(G_OBJECT(us), "set_unit", G_CALLBACK(aux_set_unit), spw);
436     // four spinbuttons
438     gtk_container_add(GTK_CONTAINER(vb),
439                       //TRANSLATORS: only translate "string" in "context|string". 
440                       // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
441                       sp_select_toolbox_spinbutton(_("select_toolbar|X"), "X", -1e6, us, spw, _("Horizontal coordinate of selection"), TRUE));
442     aux_toolbox_space(vb, AUX_BETWEEN_SPINBUTTONS);
443     gtk_container_add(GTK_CONTAINER(vb),
444                       //TRANSLATORS: only translate "string" in "context|string". 
445                       // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
446                       sp_select_toolbox_spinbutton(_("select_toolbar|Y"), "Y", -1e6, us, spw, _("Vertical coordinate of selection"), FALSE));
447     aux_toolbox_space(vb, AUX_BETWEEN_BUTTON_GROUPS);
449     gtk_container_add(GTK_CONTAINER(vb),
450                       //TRANSLATORS: only translate "string" in "context|string". 
451                       // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
452                       sp_select_toolbox_spinbutton(_("select_toolbar|W"), "width", 1e-3, us, spw, _("Width of selection"), FALSE));
454     // lock toggle
455     GtkWidget *lockbox = gtk_vbox_new(TRUE, 0);
456     GtkWidget *lock = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
457                                               SP_BUTTON_TYPE_TOGGLE,
458                                               NULL,
459                                               "lock_unlocked",
460                                               _("When locked, change both width and height by the same proportion"),
461                                               tt);
462     gtk_box_pack_start(GTK_BOX(lockbox), lock, TRUE, FALSE, 0);
463     gtk_box_pack_start(GTK_BOX(vb), lockbox, FALSE, FALSE, 0);
464     gtk_object_set_data(GTK_OBJECT(spw), "lock", lock);
465     g_signal_connect_after (G_OBJECT (lock), "clicked", G_CALLBACK (toggle_lock), desktop);
467     gtk_container_add(GTK_CONTAINER(vb),
468                       //TRANSLATORS: only translate "string" in "context|string". 
469                       // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
470                       sp_select_toolbox_spinbutton(_("select_toolbar|H"), "height", 1e-3, us, spw, _("Height of selection"), FALSE));
472     aux_toolbox_space(vb, 2);
474     // Add the units menu.
475     gtk_widget_show(us);
476     gtk_container_add(GTK_CONTAINER(vb), us);
477     gtk_object_set_data(GTK_OBJECT(spw), "units", us);
479     // Set font size.
480     sp_set_font_size_smaller (vb);
482     // Force update when selection changes.
483     gtk_signal_connect(GTK_OBJECT(spw), "modify_selection", GTK_SIGNAL_FUNC(sp_selection_layout_widget_modify_selection), desktop);
484     gtk_signal_connect(GTK_OBJECT(spw), "change_selection", GTK_SIGNAL_FUNC(sp_selection_layout_widget_change_selection), desktop);
486     // Update now.
487     sp_selection_layout_widget_update(SP_WIDGET(spw), SP_ACTIVE_DESKTOP ? sp_desktop_selection(SP_ACTIVE_DESKTOP) : NULL);
489     // Insert spw into the toolbar.
490     gtk_box_pack_start(GTK_BOX(tb), spw, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
492     aux_toolbox_space(tb, AUX_BETWEEN_BUTTON_GROUPS);
494     // "Transform with object" buttons
496     GtkWidget *cvbox = gtk_vbox_new (FALSE, 0);
497     GtkWidget *cbox = gtk_hbox_new (FALSE, 0);
499     {
500     GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
501                                               SP_BUTTON_TYPE_TOGGLE,
502                                               NULL,
503                                               "transform_stroke",
504                                               _("When scaling objects, scale the stroke width by the same proportion"),
505                                               tt);
506     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), prefs_get_int_attribute ("options.transform", "stroke", 1));
507     g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (toggle_stroke), desktop);
508     gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
509     }
511     {
512     GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
513                                               SP_BUTTON_TYPE_TOGGLE,
514                                               NULL,
515                                               "transform_corners",
516                                               _("When scaling rectangles, scale the radii of rounded corners"),
517                                               tt);
518     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), prefs_get_int_attribute ("options.transform", "rectcorners", 1));
519     g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (toggle_corners), desktop);
520     gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
521     }
523     {
524     GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
525                                               SP_BUTTON_TYPE_TOGGLE,
526                                               NULL,
527                                               "transform_gradient",
528                                               _("Transform gradients (in fill or stroke) along with the objects"),
529                                               tt);
530     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), prefs_get_int_attribute ("options.transform", "gradient", 1));
531     g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (toggle_gradient), desktop);
532     gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
533     }
535     {
536     GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
537                                               SP_BUTTON_TYPE_TOGGLE,
538                                               NULL,
539                                               "transform_pattern",
540                                               _("Transform patterns (in fill or stroke) along with the objects"),
541                                               tt);
542     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), prefs_get_int_attribute ("options.transform", "pattern", 1));
543     g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (toggle_pattern), desktop);
544     gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
545     }
547     gtk_box_pack_start(GTK_BOX(cvbox), cbox, TRUE, FALSE, 0);
548     gtk_box_pack_start(GTK_BOX(tb), cvbox, FALSE, FALSE, 0);
550     gtk_widget_show_all(tb);
552     return tb;
556 /*
557   Local Variables:
558   mode:c++
559   c-file-style:"stroustrup"
560   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
561   indent-tabs-mode:nil
562   fill-column:99
563   End:
564 */
565 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :