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"
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)
101 {
102 SPDesktop *desktop = (SPDesktop *) data;
103 if ((SP_DT_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 }
110 }
112 static void
113 sp_selection_layout_widget_change_selection(SPWidget *spw, Inkscape::Selection *selection, gpointer data)
114 {
115 SPDesktop *desktop = (SPDesktop *) data;
116 if (SP_DT_SELECTION(desktop) == selection) // only respond to changes in our desktop
117 sp_selection_layout_widget_update(spw, selection);
118 }
120 static void
121 sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
122 {
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_DT_SELECTION(desktop);
140 SPDocument *document = SP_DT_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) {
216 gdouble strokewidth = stroke_average_width (selection->itemList());
217 int transform_stroke = prefs_get_int_attribute ("options.transform", "stroke", 1);
219 NR::Matrix scaler = get_scale_transform_with_stroke (bbox, strokewidth, transform_stroke, x0, y0, x1, y1);
221 sp_selection_apply_affine(selection, scaler);
222 sp_document_maybe_done (document, actionkey);
224 // defocus spinbuttons by moving focus to the canvas, unless "stay" is on
225 spinbutton_defocus(GTK_OBJECT(spw));
226 }
228 gtk_object_set_data(GTK_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
229 }
231 GtkWidget *
232 sp_select_toolbox_spinbutton(gchar *label, gchar *data, float lower_limit, GtkWidget *us, GtkWidget *spw, gchar *tooltip, gboolean altx)
233 {
234 GtkTooltips *tt = gtk_tooltips_new();
236 GtkWidget *hb = gtk_hbox_new(FALSE, 1);
237 GtkWidget *l = gtk_label_new(Q_(label));
238 gtk_tooltips_set_tip(tt, l, tooltip, NULL);
239 gtk_widget_show(l);
240 gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5);
241 gtk_container_add(GTK_CONTAINER(hb), l);
243 GtkObject *a = gtk_adjustment_new(0.0, lower_limit, 1e6, SPIN_STEP, SPIN_PAGE_STEP, SPIN_PAGE_STEP);
244 sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(us), GTK_ADJUSTMENT(a));
245 gtk_object_set_data(GTK_OBJECT(spw), data, a);
247 GtkWidget *sb = gtk_spin_button_new(GTK_ADJUSTMENT(a), SPIN_STEP, 3);
248 gtk_tooltips_set_tip(tt, sb, tooltip, NULL);
249 gtk_widget_set_size_request(sb, AUX_SPINBUTTON_WIDTH, AUX_SPINBUTTON_HEIGHT);
250 gtk_widget_show(sb);
251 gtk_signal_connect(GTK_OBJECT(sb), "focus-in-event", GTK_SIGNAL_FUNC(spinbutton_focus_in), spw);
252 gtk_signal_connect(GTK_OBJECT(sb), "key-press-event", GTK_SIGNAL_FUNC(spinbutton_keypress), spw);
254 gtk_container_add(GTK_CONTAINER(hb), sb);
255 gtk_signal_connect(GTK_OBJECT(a), "value_changed", GTK_SIGNAL_FUNC(sp_object_layout_any_value_changed), spw);
257 if (altx) { // this spinbutton will be activated by alt-x
258 gtk_object_set_data(GTK_OBJECT(sb), "altx", sb);
259 }
261 return hb;
262 }
264 static gboolean aux_set_unit(SPUnitSelector *,
265 SPUnit const *old,
266 SPUnit const *new_units,
267 GObject *dlg)
268 {
269 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
271 if (!desktop) {
272 return FALSE;
273 }
275 Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
277 if (selection->isEmpty())
278 return FALSE;
280 if ((old->base == SP_UNIT_ABSOLUTE || old->base == SP_UNIT_DEVICE)
281 && (new_units->base == SP_UNIT_DIMENSIONLESS))
282 {
284 /* Absolute to percentage */
285 g_object_set_data(dlg, "update", GUINT_TO_POINTER(TRUE));
287 GtkAdjustment *ax = GTK_ADJUSTMENT(g_object_get_data(dlg, "X"));
288 GtkAdjustment *ay = GTK_ADJUSTMENT(g_object_get_data(dlg, "Y"));
289 GtkAdjustment *aw = GTK_ADJUSTMENT(g_object_get_data(dlg, "width"));
290 GtkAdjustment *ah = GTK_ADJUSTMENT(g_object_get_data(dlg, "height"));
292 double const x = sp_units_get_pixels (ax->value, *old);
293 double const y = sp_units_get_pixels (ay->value, *old);
294 double const w = sp_units_get_pixels (aw->value, *old);
295 double const h = sp_units_get_pixels (ah->value, *old);
297 NR::Rect bbox = selection->bounds();
299 gtk_adjustment_set_value(ax, fabs(bbox.min()[NR::X]) > 1e-6? 100.0 * x / bbox.min()[NR::X] : 100.0);
300 gtk_adjustment_set_value(ay, fabs(bbox.min()[NR::Y]) > 1e-6? 100.0 * y / bbox.min()[NR::Y] : 100.0);
301 gtk_adjustment_set_value(aw, fabs(bbox.extent(NR::X)) > 1e-6? 100.0 * w / bbox.extent(NR::X) : 100.0);
302 gtk_adjustment_set_value(ah, fabs(bbox.extent(NR::Y)) > 1e-6? 100.0 * h / bbox.extent(NR::Y) : 100.0);
304 g_object_set_data(dlg, "update", GUINT_TO_POINTER(FALSE));
305 return TRUE;
306 } else if ((old->base == SP_UNIT_DIMENSIONLESS)
307 && (new_units->base == SP_UNIT_ABSOLUTE || new_units->base == SP_UNIT_DEVICE)) {
309 /* Percentage to absolute */
310 g_object_set_data(dlg, "update", GUINT_TO_POINTER(TRUE));
312 GtkAdjustment *ax = GTK_ADJUSTMENT(g_object_get_data(dlg, "X"));
313 GtkAdjustment *ay = GTK_ADJUSTMENT(g_object_get_data(dlg, "Y"));
314 GtkAdjustment *aw = GTK_ADJUSTMENT(g_object_get_data(dlg, "width"));
315 GtkAdjustment *ah = GTK_ADJUSTMENT(g_object_get_data(dlg, "height"));
317 NR::Rect bbox = selection->bounds();
319 gtk_adjustment_set_value(ax, sp_pixels_get_units(0.01 * ax->value * bbox.min()[NR::X], *new_units));
320 gtk_adjustment_set_value(ay, sp_pixels_get_units(0.01 * ay->value * bbox.min()[NR::Y], *new_units));
321 gtk_adjustment_set_value(aw, sp_pixels_get_units(0.01 * aw->value * bbox.extent(NR::X), *new_units));
322 gtk_adjustment_set_value(ah, sp_pixels_get_units(0.01 * ah->value * bbox.extent(NR::Y), *new_units));
324 g_object_set_data(dlg, "update", GUINT_TO_POINTER(FALSE));
325 return TRUE;
326 }
328 return FALSE;
329 }
331 // toggle button callbacks and updaters
333 static void toggle_stroke (GtkWidget *button, gpointer data) {
334 prefs_set_int_attribute ("options.transform", "stroke", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 1 : 0);
335 SPDesktop *desktop = (SPDesktop *)data;
336 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
337 desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>stroke width</b> is <b>scaled</b> when objects are scaled."));
338 } else {
339 desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>stroke width</b> is <b>not scaled</b> when objects are scaled."));
340 }
341 }
343 static void toggle_corners (GtkWidget *button, gpointer data) {
344 prefs_set_int_attribute ("options.transform", "rectcorners", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 1 : 0);
345 SPDesktop *desktop = (SPDesktop *)data;
346 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
347 desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>rounded rectangle corners</b> are <b>scaled</b> when rectangles are scaled."));
348 } else {
349 desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>rounded rectangle corners</b> are <b>not scaled</b> when rectangles are scaled."));
350 }
351 }
353 static void toggle_gradient (GtkWidget *button, gpointer data) {
354 prefs_set_int_attribute ("options.transform", "gradient", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 1 : 0);
355 SPDesktop *desktop = (SPDesktop *)data;
356 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
357 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)."));
358 } else {
359 desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>gradients</b> remain <b>fixed</b> when objects are transformed (moved, scaled, rotated, or skewed)."));
360 }
361 }
363 static void toggle_pattern (GtkWidget *button, gpointer data) {
364 prefs_set_int_attribute ("options.transform", "pattern", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 1 : 0);
365 SPDesktop *desktop = (SPDesktop *)data;
366 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
367 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)."));
368 } else {
369 desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>patterns</b> remain <b>fixed</b> when objects are transformed (moved, scaled, rotated, or skewed)."));
370 }
371 }
373 static void toggle_lock (GtkWidget *button, gpointer data) {
375 GtkWidget *old_child = gtk_bin_get_child(GTK_BIN(button));
376 gtk_container_remove (GTK_CONTAINER(button), old_child);
378 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
379 GtkWidget *child = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, "width_height_lock");
380 gtk_widget_show (child);
381 gtk_container_add (GTK_CONTAINER (button), child);
382 } else {
383 GtkWidget *child = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, "lock_unlocked");
384 gtk_widget_show (child);
385 gtk_container_add (GTK_CONTAINER (button), child);
386 }
387 }
389 GtkWidget *
390 sp_select_toolbox_new(SPDesktop *desktop)
391 {
392 Inkscape::UI::View::View *view = desktop;
394 GtkTooltips *tt = gtk_tooltips_new();
395 GtkWidget *tb = gtk_hbox_new(FALSE, 0);
397 sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_OBJECT_ROTATE_90_CCW), view, tt);
398 sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_OBJECT_ROTATE_90_CW), view, tt);
399 sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_OBJECT_FLIP_HORIZONTAL), view, tt);
400 sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_OBJECT_FLIP_VERTICAL), view, tt);
402 aux_toolbox_space(tb, AUX_BETWEEN_BUTTON_GROUPS);
404 sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_SELECTION_TO_BACK), view, tt);
405 sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_SELECTION_LOWER), view, tt);
406 sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_SELECTION_RAISE), view, tt);
407 sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_SELECTION_TO_FRONT), view, tt);
409 // Create the parent widget for x y w h tracker.
410 GtkWidget *spw = sp_widget_new_global(INKSCAPE);
412 // Remember the desktop's canvas widget, to be used for defocusing.
413 gtk_object_set_data(GTK_OBJECT(spw), "dtw", SP_DT_CANVAS(desktop));
415 // The vb frame holds all other widgets and is used to set sensitivity depending on selection state.
416 GtkWidget *vb = gtk_hbox_new(FALSE, 0);
417 gtk_widget_show(vb);
418 gtk_container_add(GTK_CONTAINER(spw), vb);
419 gtk_object_set_data(GTK_OBJECT(spw), "frame", vb);
421 // Create the units menu.
422 GtkWidget *us = sp_unit_selector_new(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE);
423 sp_unit_selector_setsize(us, AUX_OPTION_MENU_WIDTH, AUX_OPTION_MENU_HEIGHT);
424 sp_unit_selector_add_unit(SP_UNIT_SELECTOR(us), &sp_unit_get_by_id(SP_UNIT_PERCENT), 0);
425 sp_unit_selector_set_unit (SP_UNIT_SELECTOR(us), SP_DT_NAMEDVIEW(desktop)->doc_units);
426 g_signal_connect(G_OBJECT(us), "set_unit", G_CALLBACK(aux_set_unit), spw);
428 // four spinbuttons
430 gtk_container_add(GTK_CONTAINER(vb),
431 //TRANSLATORS: only translate "string" in "context|string".
432 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
433 sp_select_toolbox_spinbutton(_("select_toolbar|X"), "X", -1e6, us, spw, _("Horizontal coordinate of selection"), TRUE));
434 aux_toolbox_space(vb, AUX_BETWEEN_SPINBUTTONS);
435 gtk_container_add(GTK_CONTAINER(vb),
436 //TRANSLATORS: only translate "string" in "context|string".
437 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
438 sp_select_toolbox_spinbutton(_("select_toolbar|Y"), "Y", -1e6, us, spw, _("Vertical coordinate of selection"), FALSE));
439 aux_toolbox_space(vb, AUX_BETWEEN_BUTTON_GROUPS);
441 gtk_container_add(GTK_CONTAINER(vb),
442 //TRANSLATORS: only translate "string" in "context|string".
443 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
444 sp_select_toolbox_spinbutton(_("select_toolbar|W"), "width", 1e-3, us, spw, _("Width of selection"), FALSE));
446 // lock toggle
447 GtkWidget *lockbox = gtk_vbox_new(TRUE, 0);
448 GtkWidget *lock = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
449 SP_BUTTON_TYPE_TOGGLE,
450 NULL,
451 "lock_unlocked",
452 _("When locked, change both width and height by the same proportion"),
453 tt);
454 gtk_box_pack_start(GTK_BOX(lockbox), lock, TRUE, FALSE, 0);
455 gtk_box_pack_start(GTK_BOX(vb), lockbox, FALSE, FALSE, 0);
456 gtk_object_set_data(GTK_OBJECT(spw), "lock", lock);
457 g_signal_connect_after (G_OBJECT (lock), "clicked", G_CALLBACK (toggle_lock), desktop);
459 gtk_container_add(GTK_CONTAINER(vb),
460 //TRANSLATORS: only translate "string" in "context|string".
461 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
462 sp_select_toolbox_spinbutton(_("select_toolbar|H"), "height", 1e-3, us, spw, _("Height of selection"), FALSE));
464 aux_toolbox_space(vb, 2);
466 // Add the units menu.
467 gtk_widget_show(us);
468 gtk_container_add(GTK_CONTAINER(vb), us);
469 gtk_object_set_data(GTK_OBJECT(spw), "units", us);
471 // Set font size.
472 sp_set_font_size_smaller (vb);
474 // Force update when selection changes.
475 gtk_signal_connect(GTK_OBJECT(spw), "modify_selection", GTK_SIGNAL_FUNC(sp_selection_layout_widget_modify_selection), desktop);
476 gtk_signal_connect(GTK_OBJECT(spw), "change_selection", GTK_SIGNAL_FUNC(sp_selection_layout_widget_change_selection), desktop);
478 // Update now.
479 sp_selection_layout_widget_update(SP_WIDGET(spw), SP_ACTIVE_DESKTOP ? SP_DT_SELECTION(SP_ACTIVE_DESKTOP) : NULL);
481 // Insert spw into the toolbar.
482 gtk_box_pack_start(GTK_BOX(tb), spw, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
484 aux_toolbox_space(tb, AUX_BETWEEN_BUTTON_GROUPS);
486 // "Transform with object" buttons
488 GtkWidget *cvbox = gtk_vbox_new (FALSE, 0);
489 GtkWidget *cbox = gtk_hbox_new (FALSE, 0);
491 {
492 GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
493 SP_BUTTON_TYPE_TOGGLE,
494 NULL,
495 "transform_stroke",
496 _("When scaling objects, scale the stroke width by the same proportion"),
497 tt);
498 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), prefs_get_int_attribute ("options.transform", "stroke", 1));
499 g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (toggle_stroke), desktop);
500 gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
501 }
503 {
504 GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
505 SP_BUTTON_TYPE_TOGGLE,
506 NULL,
507 "transform_corners",
508 _("When scaling rectangles, scale the radii of rounded corners"),
509 tt);
510 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), prefs_get_int_attribute ("options.transform", "rectcorners", 1));
511 g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (toggle_corners), desktop);
512 gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
513 }
515 {
516 GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
517 SP_BUTTON_TYPE_TOGGLE,
518 NULL,
519 "transform_gradient",
520 _("Transform gradients (in fill or stroke) along with the objects"),
521 tt);
522 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), prefs_get_int_attribute ("options.transform", "gradient", 1));
523 g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (toggle_gradient), desktop);
524 gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
525 }
527 {
528 GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
529 SP_BUTTON_TYPE_TOGGLE,
530 NULL,
531 "transform_pattern",
532 _("Transform patterns (in fill or stroke) along with the objects"),
533 tt);
534 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), prefs_get_int_attribute ("options.transform", "pattern", 1));
535 g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (toggle_pattern), desktop);
536 gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
537 }
539 gtk_box_pack_start(GTK_BOX(cvbox), cbox, TRUE, FALSE, 0);
540 gtk_box_pack_start(GTK_BOX(tb), cvbox, FALSE, FALSE, 0);
542 gtk_widget_show_all(tb);
544 return tb;
545 }
548 /*
549 Local Variables:
550 mode:c++
551 c-file-style:"stroustrup"
552 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
553 indent-tabs-mode:nil
554 fill-column:99
555 End:
556 */
557 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :