Code

90efd2da5741259e7aeb5451eec10ecdf7a8b80a
[inkscape.git] / src / ui / widget / selected-style.cpp
1 /**
2  * \brief Selected style indicator (fill, stroke, opacity)
3  *
4  * Author:
5  *   buliabyak@gmail.com
6  *
7  * Copyright (C) 2005 author
8  *
9  * Released under GNU GPL.  Read the file 'COPYING' for more information.
10  */
12 #ifdef HAVE_CONFIG_H
13 # include <config.h>
14 #endif
16 #include <gtk/gtkdnd.h>
18 #include "selected-style.h"
20 #include "widgets/spw-utilities.h"
21 #include "ui/widget/color-preview.h"
23 #include "selection.h"
24 #include "desktop-handles.h"
25 #include "style.h"
26 #include "desktop-style.h"
27 #include "sp-linear-gradient-fns.h"
28 #include "sp-radial-gradient-fns.h"
29 #include "sp-pattern.h"
30 #include "dialogs/object-properties.h"
31 #include "xml/repr.h"
32 #include "document.h"
33 #include "widgets/widget-sizes.h"
34 #include "widgets/spinbutton-events.h"
35 #include "svg/svg-color.h"
36 #include "svg/css-ostringstream.h"
37 #include "helper/units.h"
38 #include "verbs.h"
40 static gdouble const _sw_presets[]     = { 32 ,  16 ,  10 ,  8 ,  6 ,  4 ,  3 ,  2 ,  1.5 ,  1 ,  0.75 ,  0.5 ,  0.25 ,  0.1 };
41 static gchar* const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"};
43 static void 
44 ss_selection_changed (Inkscape::Selection *, gpointer data)
45 {
46     Inkscape::UI::Widget::SelectedStyle *ss = (Inkscape::UI::Widget::SelectedStyle *) data;
47     ss->update();
48 }
50 static void
51 ss_selection_modified (Inkscape::Selection *selection, guint flags, gpointer data)
52 {
53     ss_selection_changed (selection, data);
54 }
56 static void
57 ss_subselection_changed (gpointer dragger, gpointer data)
58 {
59     ss_selection_changed (NULL, data);
60 }
62 namespace Inkscape {
63 namespace UI {
64 namespace Widget {
67 typedef struct {
68     SelectedStyle* parent;
69     int item;
70 } DropTracker;
72 /* Drag and Drop */
73 typedef enum {
74     APP_X_COLOR
75 } ui_drop_target_info;
77 static GtkTargetEntry ui_drop_target_entries [] = {
78     {"application/x-color", 0, APP_X_COLOR}
79 };
81 #define ENTRIES_SIZE(n) sizeof(n)/sizeof(n[0])
82 static guint nui_drop_target_entries = ENTRIES_SIZE(ui_drop_target_entries);
85 SelectedStyle::SelectedStyle(bool layout)
86     : _desktop (NULL),
88       _table(2, 6),
89       _fill_label (_("F:")),
90       _stroke_label (_("S:")),
91       _opacity_label (_("O:")),
92       _fill_place (),
93       _stroke_place (),
95       _fill_flag_place (),
96       _stroke_flag_place (),
98       _opacity_place (),
99       _opacity_adjustment (1.0, 0.0, 1.0, 0.01, 0.1),
100       _opacity_sb (0.02, 2),
102       _stroke (),
103       _stroke_width (""),
105       _opacity_blocked (false),
107       _popup_px(_sw_group),
108       _popup_pt(_sw_group),
109       _popup_mm(_sw_group),
111       _sw_unit(NULL),
113       _tooltips ()
116     _drop[0] = _drop[1] = 0;
117     _dropEnabled[0] = _dropEnabled[1] = false;
118     
119     _fill_label.set_alignment(0.0, 0.5);
120     _fill_label.set_padding(0, 0);
121     _stroke_label.set_alignment(0.0, 0.5);
122     _stroke_label.set_padding(0, 0);
123     _opacity_label.set_alignment(0.0, 0.5);
124     _opacity_label.set_padding(0, 0);
126     _table.set_col_spacings (2);
127     _table.set_row_spacings (0);
129     for (int i = SS_FILL; i <= SS_STROKE; i++) {
131         _na[i].set_markup (_("N/A"));
132         sp_set_font_size_smaller (GTK_WIDGET(_na[i].gobj()));
133         _na[i].show_all();
134         __na[i] = (_("Nothing selected"));
136         _none[i].set_markup (_("None"));
137         sp_set_font_size_smaller (GTK_WIDGET(_none[i].gobj()));
138         _none[i].show_all();
139         __none[i] = (i == SS_FILL)? (_("No fill")) : (_("No stroke"));
141         _pattern[i].set_markup (_("Pattern"));
142         sp_set_font_size_smaller (GTK_WIDGET(_pattern[i].gobj()));
143         _pattern[i].show_all();
144         __pattern[i] = (i == SS_FILL)? (_("Pattern fill")) : (_("Pattern stroke"));
146         _lgradient[i].set_markup (_("L Gradient"));
147         sp_set_font_size_smaller (GTK_WIDGET(_lgradient[i].gobj()));
148         _lgradient[i].show_all();
149         __lgradient[i] = (i == SS_FILL)? (_("Linear gradient fill")) : (_("Linear gradient stroke"));
151         _rgradient[i].set_markup (_("R Gradient"));
152         sp_set_font_size_smaller (GTK_WIDGET(_rgradient[i].gobj()));
153         _rgradient[i].show_all();
154         __rgradient[i] = (i == SS_FILL)? (_("Radial gradient fill")) : (_("Radial gradient stroke"));
156         _many[i].set_markup (_("Different"));
157         sp_set_font_size_smaller (GTK_WIDGET(_many[i].gobj()));
158         _many[i].show_all();
159         __many[i] = (i == SS_FILL)? (_("Different fills")) : (_("Different strokes"));
161         _unset[i].set_markup (_("Unset"));
162         sp_set_font_size_smaller (GTK_WIDGET(_unset[i].gobj()));
163         _unset[i].show_all();
164         __unset[i] = (i == SS_FILL)? (_("Unset fill")) : (_("Unset stroke"));
166         _color_preview[i] = new Inkscape::UI::Widget::ColorPreview (0);
167         __color[i] = (i == SS_FILL)? (_("Flat color fill")) : (_("Flat color stroke"));
169         // TRANSLATOR COMMENT: A means "Averaged"
170         _averaged[i].set_markup (_("<b>a</b>"));
171         sp_set_font_size_smaller (GTK_WIDGET(_averaged[i].gobj()));
172         _averaged[i].show_all();
173         __averaged[i] = (i == SS_FILL)? (_("Fill is averaged over selected objects")) : (_("Stroke is averaged over selected objects"));
175         // TRANSLATOR COMMENT: M means "Multiple"
176         _multiple[i].set_markup (_("<b>m</b>"));
177         sp_set_font_size_smaller (GTK_WIDGET(_multiple[i].gobj()));
178         _multiple[i].show_all();
179         __multiple[i] = (i == SS_FILL)? (_("Multiple selected objects have the same fill")) : (_("Multiple selected objects have the same stroke"));
181         _popup_edit[i].add(*(new Gtk::Label((i == SS_FILL)? _("Edit fill...") : _("Edit stroke..."), 0.0, 0.5)));
182         _popup_edit[i].signal_activate().connect(sigc::mem_fun(*this, 
183                                (i == SS_FILL)? &SelectedStyle::on_fill_edit : &SelectedStyle::on_stroke_edit ));
185         _popup_lastused[i].add(*(new Gtk::Label(_("Last set color"), 0.0, 0.5)));
186         _popup_lastused[i].signal_activate().connect(sigc::mem_fun(*this, 
187                                (i == SS_FILL)? &SelectedStyle::on_fill_lastused : &SelectedStyle::on_stroke_lastused ));
189         _popup_lastselected[i].add(*(new Gtk::Label(_("Last selected color"), 0.0, 0.5)));
190         _popup_lastselected[i].signal_activate().connect(sigc::mem_fun(*this, 
191                                (i == SS_FILL)? &SelectedStyle::on_fill_lastselected : &SelectedStyle::on_stroke_lastselected ));
193         _popup_invert[i].add(*(new Gtk::Label(_("Invert"), 0.0, 0.5)));
194         _popup_invert[i].signal_activate().connect(sigc::mem_fun(*this, 
195                                (i == SS_FILL)? &SelectedStyle::on_fill_invert : &SelectedStyle::on_stroke_invert ));
197         _popup_white[i].add(*(new Gtk::Label(_("White"), 0.0, 0.5)));
198         _popup_white[i].signal_activate().connect(sigc::mem_fun(*this, 
199                                (i == SS_FILL)? &SelectedStyle::on_fill_white : &SelectedStyle::on_stroke_white ));
201         _popup_black[i].add(*(new Gtk::Label(_("Black"), 0.0, 0.5)));
202         _popup_black[i].signal_activate().connect(sigc::mem_fun(*this, 
203                                (i == SS_FILL)? &SelectedStyle::on_fill_black : &SelectedStyle::on_stroke_black ));
205         _popup_copy[i].add(*(new Gtk::Label(_("Copy color"), 0.0, 0.5)));
206         _popup_copy[i].signal_activate().connect(sigc::mem_fun(*this, 
207                                (i == SS_FILL)? &SelectedStyle::on_fill_copy : &SelectedStyle::on_stroke_copy ));
209         _popup_paste[i].add(*(new Gtk::Label(_("Paste color"), 0.0, 0.5)));
210         _popup_paste[i].signal_activate().connect(sigc::mem_fun(*this, 
211                                (i == SS_FILL)? &SelectedStyle::on_fill_paste : &SelectedStyle::on_stroke_paste ));
213         _popup_swap[i].add(*(new Gtk::Label(_("Swap fill and stroke"), 0.0, 0.5)));
214         _popup_swap[i].signal_activate().connect(sigc::mem_fun(*this, 
215                                &SelectedStyle::on_fillstroke_swap));
217         _popup_opaque[i].add(*(new Gtk::Label((i == SS_FILL)? _("Make fill opaque") : _("Make stroke opaque"), 0.0, 0.5)));
218         _popup_opaque[i].signal_activate().connect(sigc::mem_fun(*this, 
219                                (i == SS_FILL)? &SelectedStyle::on_fill_opaque : &SelectedStyle::on_stroke_opaque ));
221         //TRANSLATORS COMMENT: unset is a verb here
222         _popup_unset[i].add(*(new Gtk::Label((i == SS_FILL)? _("Unset fill") : _("Unset stroke"), 0.0, 0.5)));
223         _popup_unset[i].signal_activate().connect(sigc::mem_fun(*this, 
224                                (i == SS_FILL)? &SelectedStyle::on_fill_unset : &SelectedStyle::on_stroke_unset ));
226         _popup_remove[i].add(*(new Gtk::Label((i == SS_FILL)? _("Remove fill") : _("Remove stroke"), 0.0, 0.5)));
227         _popup_remove[i].signal_activate().connect(sigc::mem_fun(*this, 
228                                (i == SS_FILL)? &SelectedStyle::on_fill_remove : &SelectedStyle::on_stroke_remove ));
230         _popup[i].attach(_popup_edit[i], 0,1, 0,1);
231           _popup[i].attach(*(new Gtk::SeparatorMenuItem()), 0,1, 1,2);
232         _popup[i].attach(_popup_lastused[i], 0,1, 2,3);
233         _popup[i].attach(_popup_lastselected[i], 0,1, 3,4);
234           _popup[i].attach(*(new Gtk::SeparatorMenuItem()), 0,1, 4,5);
235         _popup[i].attach(_popup_invert[i], 0,1, 5,6);
236           _popup[i].attach(*(new Gtk::SeparatorMenuItem()), 0,1, 6,7);
237         _popup[i].attach(_popup_white[i], 0,1, 7,8);
238         _popup[i].attach(_popup_black[i], 0,1, 8,9);
239           _popup[i].attach(*(new Gtk::SeparatorMenuItem()), 0,1, 9,10);
240         _popup[i].attach(_popup_copy[i], 0,1, 10,11);
241         _popup_copy[i].set_sensitive(false);
242         _popup[i].attach(_popup_paste[i], 0,1, 11,12);
243         _popup[i].attach(_popup_swap[i], 0,1, 12,13);
244           _popup[i].attach(*(new Gtk::SeparatorMenuItem()), 0,1, 13,14); 
245         _popup[i].attach(_popup_opaque[i], 0,1, 14,15);
246         _popup[i].attach(_popup_unset[i], 0,1, 15,16);
247         _popup[i].attach(_popup_remove[i], 0,1, 16,17);
248         _popup[i].show_all();
250         _mode[i] = SS_NA;
251     }
253     {
254         _popup_px.add(*(new Gtk::Label(_("px"), 0.0, 0.5)));
255         _popup_px.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_px));
256         _popup_sw.attach(_popup_px, 0,1, 0,1);
258         _popup_pt.add(*(new Gtk::Label(_("pt"), 0.0, 0.5)));
259         _popup_pt.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_pt));
260         _popup_sw.attach(_popup_pt, 0,1, 1,2);
262         _popup_mm.add(*(new Gtk::Label(_("mm"), 0.0, 0.5)));
263         _popup_mm.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_mm));
264         _popup_sw.attach(_popup_mm, 0,1, 2,3);
266         _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, 3,4);
268         for (guint i = 0; i < G_N_ELEMENTS(_sw_presets_str); ++i) {
269             Gtk::MenuItem *mi = Gtk::manage(new Gtk::MenuItem());
270             mi->add(*(new Gtk::Label(_sw_presets_str[i], 0.0, 0.5)));
271             mi->signal_activate().connect(sigc::bind<int>(sigc::mem_fun(*this, &SelectedStyle::on_popup_preset), i));
272             _popup_sw.attach(*mi, 0,1, 4+i, 5+i);
273         }
275         guint i = G_N_ELEMENTS(_sw_presets_str) + 5;
277         _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, i,i+1);
279         _popup_sw_remove.add(*(new Gtk::Label(_("Remove"), 0.0, 0.5)));
280         _popup_sw_remove.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_remove));
281         _popup_sw.attach(_popup_sw_remove, 0,1, i+1,i+2);
283         _popup_sw.show_all();
284     }
286     _fill_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_fill_click));
287     _stroke_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_click));
288     _opacity_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_click));
289     _stroke_width_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
291     _opacity_sb.signal_populate_popup().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_menu));
292     _opacity_sb.signal_value_changed().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_changed));
294     _fill_place.add(_na[SS_FILL]);
295     _tooltips.set_tip(_fill_place, __na[SS_FILL]);
297     _stroke_place.add(_na[SS_STROKE]);
298     _tooltips.set_tip(_stroke_place, __na[SS_STROKE]);
300     _stroke.pack_start(_stroke_place);
301     _stroke_width_place.add(_stroke_width);
302     _stroke.pack_start(_stroke_width_place, Gtk::PACK_SHRINK);
304     _opacity_sb.set_adjustment(_opacity_adjustment);
305     sp_set_font_size_smaller (GTK_WIDGET(_opacity_sb.gobj()));
306     _opacity_sb.set_size_request (SELECTED_STYLE_SB_WIDTH, -1);
307     _opacity_sb.set_sensitive (false);
309     _table.attach(_fill_label, 0,1, 0,1, Gtk::SHRINK, Gtk::SHRINK);
310     _table.attach(_stroke_label, 0,1, 1,2, Gtk::SHRINK, Gtk::SHRINK);
312     _table.attach(_fill_flag_place, 1,2, 0,1, Gtk::SHRINK, Gtk::SHRINK);
313     _table.attach(_stroke_flag_place, 1,2, 1,2, Gtk::SHRINK, Gtk::SHRINK);
315     _table.attach(_fill_place, 2,3, 0,1);
316     _table.attach(_stroke, 2,3, 1,2);
318     _opacity_place.add(_opacity_label);
319     _table.attach(_opacity_place, 4,5, 0,2, Gtk::SHRINK, Gtk::SHRINK);
320     _table.attach(_opacity_sb, 5,6, 0,2, Gtk::SHRINK, Gtk::SHRINK);
322     pack_start(_table, true, true, 2);
324     set_size_request (SELECTED_STYLE_WIDTH, -1);
326     sp_set_font_size_smaller (GTK_WIDGET(_opacity_label.gobj()));
327     sp_set_font_size_smaller (GTK_WIDGET(_opacity_sb.gobj()));
328     sp_set_font_size_smaller (GTK_WIDGET(_fill_place.gobj()));
329     sp_set_font_size_smaller (GTK_WIDGET(_fill_flag_place.gobj()));
330     sp_set_font_size_smaller (GTK_WIDGET(_stroke_place.gobj()));
331     sp_set_font_size_smaller (GTK_WIDGET(_stroke_flag_place.gobj()));
332     sp_set_font_size_smaller (GTK_WIDGET(_stroke_width.gobj()));
333     sp_set_font_size_smaller (GTK_WIDGET(_fill_label.gobj()));
334     sp_set_font_size_smaller (GTK_WIDGET(_stroke_label.gobj()));
336     _drop[SS_FILL] = new DropTracker();
337     ((DropTracker*)_drop[SS_FILL])->parent = this;
338     ((DropTracker*)_drop[SS_FILL])->item = SS_FILL;
340     _drop[SS_STROKE] = new DropTracker();
341     ((DropTracker*)_drop[SS_STROKE])->parent = this;
342     ((DropTracker*)_drop[SS_STROKE])->item = SS_STROKE;
344     g_signal_connect(_stroke_place.gobj(),
345                      "drag_data_received",
346                      G_CALLBACK(dragDataReceived),
347                      _drop[SS_STROKE]);
349     g_signal_connect(_fill_place.gobj(),
350                      "drag_data_received",
351                      G_CALLBACK(dragDataReceived),
352                      _drop[SS_FILL]);
355 SelectedStyle::~SelectedStyle()
357     selection_changed_connection->disconnect();
358     delete selection_changed_connection;
359     selection_modified_connection->disconnect();
360     delete selection_modified_connection;
361     subselection_changed_connection->disconnect();
362     delete subselection_changed_connection;
364     for (int i = SS_FILL; i <= SS_STROKE; i++) {
365         delete _color_preview[i];
366     }
368     delete (DropTracker*)_drop[SS_FILL];
369     delete (DropTracker*)_drop[SS_STROKE];
372 void
373 SelectedStyle::setDesktop(SPDesktop *desktop)
375     _desktop = desktop;
376     gtk_object_set_data (GTK_OBJECT(_opacity_sb.gobj()), "dtw", _desktop->canvas);
378     Inkscape::Selection *selection = sp_desktop_selection (desktop);
380     selection_changed_connection = new sigc::connection (selection->connectChanged(
381         sigc::bind (
382             sigc::ptr_fun(&ss_selection_changed),
383             this )
384     ));
385     selection_modified_connection = new sigc::connection (selection->connectModified(
386         sigc::bind (
387             sigc::ptr_fun(&ss_selection_modified),
388             this )
389     ));
390     subselection_changed_connection = new sigc::connection (desktop->connectToolSubselectionChanged(
391         sigc::bind (
392             sigc::ptr_fun(&ss_subselection_changed),
393             this )
394     ));
396     //_sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_units;
399 void SelectedStyle::dragDataReceived( GtkWidget *widget,
400                                       GdkDragContext *drag_context,
401                                       gint x, gint y,
402                                       GtkSelectionData *data,
403                                       guint info,
404                                       guint event_time,
405                                       gpointer user_data )
407     DropTracker* tracker = (DropTracker*)user_data;
409     switch ( (int)tracker->item ) {
410         case SS_FILL:
411         case SS_STROKE:
412         {
413             if ( data->length == 8 ) {
414                 gchar c[64];
415                 // Careful about endian issues.
416                 guint16* dataVals = (guint16*)data->data;
417                 sp_svg_write_color( c, 64,
418                                     SP_RGBA32_U_COMPOSE(
419                                         0x0ff & (dataVals[0] >> 8),
420                                         0x0ff & (dataVals[1] >> 8),
421                                         0x0ff & (dataVals[2] >> 8),
422                                         0xff // can't have transparency in the color itself
423                                         //0x0ff & (data->data[3] >> 8),
424                                         ));
425                 SPCSSAttr *css = sp_repr_css_attr_new();
426                 sp_repr_css_set_property( css, (tracker->item == SS_FILL) ? "fill":"stroke", c );
427                 sp_desktop_set_style( tracker->parent->_desktop, css );
428                 sp_repr_css_attr_unref( css );
429                 sp_document_done( sp_desktop_document(tracker->parent->_desktop) , SP_VERB_NONE, 
430                                   _("Drop color"));
431             }
432         }
433         break;
434     }
437 void SelectedStyle::on_fill_remove() {
438     SPCSSAttr *css = sp_repr_css_attr_new ();
439     sp_repr_css_set_property (css, "fill", "none");
440     sp_desktop_set_style (_desktop, css, true, true); 
441     sp_repr_css_attr_unref (css);
442     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
443                       _("Remove fill"));
446 void SelectedStyle::on_stroke_remove() {
447     SPCSSAttr *css = sp_repr_css_attr_new ();
448     sp_repr_css_set_property (css, "stroke", "none");
449     sp_desktop_set_style (_desktop, css, true, true); 
450     sp_repr_css_attr_unref (css);
451     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
452                       _("Remove stroke"));
455 void SelectedStyle::on_fill_unset() {
456     SPCSSAttr *css = sp_repr_css_attr_new ();
457     sp_repr_css_unset_property (css, "fill");
458     sp_desktop_set_style (_desktop, css, true, true); 
459     sp_repr_css_attr_unref (css);
460     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
461                       _("Unset fill"));
464 void SelectedStyle::on_stroke_unset() {
465     SPCSSAttr *css = sp_repr_css_attr_new ();
466     sp_repr_css_unset_property (css, "stroke");
467     sp_desktop_set_style (_desktop, css, true, true);
468     sp_repr_css_attr_unref (css);
469     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
470                       _("Unset stroke"));
473 void SelectedStyle::on_fill_opaque() {
474     SPCSSAttr *css = sp_repr_css_attr_new ();
475     sp_repr_css_set_property (css, "fill-opacity", "1");
476     sp_desktop_set_style (_desktop, css, true);
477     sp_repr_css_attr_unref (css);
478     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
479                       _("Make fill opaque"));
482 void SelectedStyle::on_stroke_opaque() {
483     SPCSSAttr *css = sp_repr_css_attr_new ();
484     sp_repr_css_set_property (css, "stroke-opacity", "1");
485     sp_desktop_set_style (_desktop, css, true);
486     sp_repr_css_attr_unref (css);
487     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
488                       _("Make fill opaque"));
491 void SelectedStyle::on_fill_lastused() {
492     SPCSSAttr *css = sp_repr_css_attr_new ();
493     guint32 color = sp_desktop_get_color(_desktop, true);
494     gchar c[64];
495     sp_svg_write_color (c, 64, color);
496     sp_repr_css_set_property (css, "fill", c);
497     sp_desktop_set_style (_desktop, css);
498     sp_repr_css_attr_unref (css);
499     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, 
500                       _("Apply last set color to fill"));
503 void SelectedStyle::on_stroke_lastused() {
504     SPCSSAttr *css = sp_repr_css_attr_new ();
505     guint32 color = sp_desktop_get_color(_desktop, false);
506     gchar c[64];
507     sp_svg_write_color (c, 64, color);
508     sp_repr_css_set_property (css, "stroke", c);
509     sp_desktop_set_style (_desktop, css);
510     sp_repr_css_attr_unref (css);
511     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, 
512                       _("Apply last set color to stroke"));
515 void SelectedStyle::on_fill_lastselected() {
516     SPCSSAttr *css = sp_repr_css_attr_new ();
517     gchar c[64];
518     sp_svg_write_color (c, 64, _lastselected[SS_FILL]);
519     sp_repr_css_set_property (css, "fill", c);
520     sp_desktop_set_style (_desktop, css);
521     sp_repr_css_attr_unref (css);
522     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
523                       _("Apply last selected color to fill"));
526 void SelectedStyle::on_stroke_lastselected() {
527     SPCSSAttr *css = sp_repr_css_attr_new ();
528     gchar c[64];
529     sp_svg_write_color (c, 64, _lastselected[SS_STROKE]);
530     sp_repr_css_set_property (css, "stroke", c);
531     sp_desktop_set_style (_desktop, css);
532     sp_repr_css_attr_unref (css);
533     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, 
534                       _("Apply last selected color to stroke"));
537 void SelectedStyle::on_fill_invert() {
538     SPCSSAttr *css = sp_repr_css_attr_new ();
539     guint32 color = _thisselected[SS_FILL];
540     gchar c[64];
541     if (_mode[SS_FILL] != SS_COLOR) return;
542     sp_svg_write_color (c, 64,
543         SP_RGBA32_U_COMPOSE(
544                 (255 - SP_RGBA32_R_U(color)),
545                 (255 - SP_RGBA32_G_U(color)),
546                 (255 - SP_RGBA32_B_U(color)),
547                 SP_RGBA32_A_U(color)
548         )
549     );
550     sp_repr_css_set_property (css, "fill", c);
551     sp_desktop_set_style (_desktop, css);
552     sp_repr_css_attr_unref (css);
553     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
554                       _("Invert fill"));
557 void SelectedStyle::on_stroke_invert() {
558     SPCSSAttr *css = sp_repr_css_attr_new ();
559     guint32 color = _thisselected[SS_STROKE];
560     gchar c[64];
561     if (_mode[SS_STROKE] != SS_COLOR) return;
562     sp_svg_write_color (c, 64,
563         SP_RGBA32_U_COMPOSE(
564                 (255 - SP_RGBA32_R_U(color)),
565                 (255 - SP_RGBA32_G_U(color)),
566                 (255 - SP_RGBA32_B_U(color)),
567                 SP_RGBA32_A_U(color)
568         )
569     );
570     sp_repr_css_set_property (css, "stroke", c);
571     sp_desktop_set_style (_desktop, css);
572     sp_repr_css_attr_unref (css);
573     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
574                       _("Invert stroke"));
575
577 void SelectedStyle::on_fill_white() {
578     SPCSSAttr *css = sp_repr_css_attr_new ();
579     gchar c[64];
580     sp_svg_write_color (c, 64, 0xffffffff);
581     sp_repr_css_set_property (css, "fill", c);
582     sp_repr_css_set_property (css, "fill-opacity", "1");
583     sp_desktop_set_style (_desktop, css);
584     sp_repr_css_attr_unref (css);
585     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
586                       _("White fill"));
589 void SelectedStyle::on_stroke_white() {
590     SPCSSAttr *css = sp_repr_css_attr_new ();
591     gchar c[64];
592     sp_svg_write_color (c, 64, 0xffffffff);
593     sp_repr_css_set_property (css, "stroke", c);
594     sp_repr_css_set_property (css, "stroke-opacity", "1");
595     sp_desktop_set_style (_desktop, css);
596     sp_repr_css_attr_unref (css);
597     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, 
598                       _("White stroke"));
601 void SelectedStyle::on_fill_black() {
602     SPCSSAttr *css = sp_repr_css_attr_new ();
603     gchar c[64];
604     sp_svg_write_color (c, 64, 0x000000ff);
605     sp_repr_css_set_property (css, "fill", c);
606     sp_repr_css_set_property (css, "fill-opacity", "1.0");
607     sp_desktop_set_style (_desktop, css);
608     sp_repr_css_attr_unref (css);
609     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, 
610                       _("Black fill"));
613 void SelectedStyle::on_stroke_black() {
614     SPCSSAttr *css = sp_repr_css_attr_new ();
615     gchar c[64];
616     sp_svg_write_color (c, 64, 0x000000ff);
617     sp_repr_css_set_property (css, "stroke", c);
618     sp_repr_css_set_property (css, "stroke-opacity", "1.0");
619     sp_desktop_set_style (_desktop, css);
620     sp_repr_css_attr_unref (css);
621     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, 
622                       _("Black stroke"));
625 void SelectedStyle::on_fill_copy() {
626     if (_mode[SS_FILL] == SS_COLOR) {
627         gchar c[64];
628         sp_svg_write_color (c, 64, _thisselected[SS_FILL]);
629         Glib::ustring text;
630         text += c;
631         if (!text.empty()) {
632             Glib::RefPtr<Gtk::Clipboard> refClipboard = Gtk::Clipboard::get();
633             refClipboard->set_text(text);
634         }
635     }
638 void SelectedStyle::on_stroke_copy() {
639     if (_mode[SS_STROKE] == SS_COLOR) {
640         gchar c[64];
641         sp_svg_write_color (c, 64, _thisselected[SS_STROKE]);
642         Glib::ustring text;
643         text += c;
644         if (!text.empty()) {
645             Glib::RefPtr<Gtk::Clipboard> refClipboard = Gtk::Clipboard::get();
646             refClipboard->set_text(text);
647         }
648     }
651 void SelectedStyle::on_fill_paste() {
652     Glib::RefPtr<Gtk::Clipboard> refClipboard = Gtk::Clipboard::get();
653     Glib::ustring const text = refClipboard->wait_for_text();
655     if (!text.empty()) {
656         guint32 color = sp_svg_read_color(text.c_str(), 0x000000ff); // impossible value, as SVG color cannot have opacity
657         if (color == 0x000000ff) // failed to parse color string
658             return;
660         SPCSSAttr *css = sp_repr_css_attr_new ();
661         sp_repr_css_set_property (css, "fill", text.c_str());
662         sp_desktop_set_style (_desktop, css);
663         sp_repr_css_attr_unref (css);
664         sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, 
665                       _("Paste fill"));
666     }
669 void SelectedStyle::on_stroke_paste() {
670     Glib::RefPtr<Gtk::Clipboard> refClipboard = Gtk::Clipboard::get();
671     Glib::ustring const text = refClipboard->wait_for_text();
673     if (!text.empty()) {
674         guint32 color = sp_svg_read_color(text.c_str(), 0x000000ff); // impossible value, as SVG color cannot have opacity
675         if (color == 0x000000ff) // failed to parse color string
676             return;
678         SPCSSAttr *css = sp_repr_css_attr_new ();
679         sp_repr_css_set_property (css, "stroke", text.c_str());
680         sp_desktop_set_style (_desktop, css);
681         sp_repr_css_attr_unref (css);
682         sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
683                       _("Paste stroke"));
684     }
687 void SelectedStyle::on_fillstroke_swap() {
688     SPCSSAttr *css = sp_repr_css_attr_new ();
690     switch (_mode[SS_FILL]) {
691     case SS_NA:
692     case SS_MANY:
693         break;
694     case SS_NONE:
695         sp_repr_css_set_property (css, "stroke", "none");
696         break;
697     case SS_UNSET:
698         sp_repr_css_unset_property (css, "stroke");
699         break;
700     case SS_COLOR:
701         gchar c[64];
702         sp_svg_write_color (c, 64, _thisselected[SS_FILL]);
703         sp_repr_css_set_property (css, "stroke", c);
704         break;
705     case SS_LGRADIENT:
706     case SS_RGRADIENT:
707     case SS_PATTERN:
708         sp_repr_css_set_property (css, "stroke", _paintserver_id[SS_FILL].c_str());
709         break;
710     }
712     switch (_mode[SS_STROKE]) {
713     case SS_NA:
714     case SS_MANY:
715         break;
716     case SS_NONE:
717         sp_repr_css_set_property (css, "fill", "none");
718         break;
719     case SS_UNSET:
720         sp_repr_css_unset_property (css, "fill");
721         break;
722     case SS_COLOR:
723         gchar c[64];
724         sp_svg_write_color (c, 64, _thisselected[SS_STROKE]);
725         sp_repr_css_set_property (css, "fill", c);
726         break;
727     case SS_LGRADIENT:
728     case SS_RGRADIENT:
729     case SS_PATTERN:
730         sp_repr_css_set_property (css, "fill", _paintserver_id[SS_STROKE].c_str());
731         break;
732     }
734     sp_desktop_set_style (_desktop, css);
735     sp_repr_css_attr_unref (css);
736     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, 
737                       _("Swap fill and stroke"));
740 void SelectedStyle::on_fill_edit() {
741     sp_object_properties_fill();
744 void SelectedStyle::on_stroke_edit() {
745     sp_object_properties_stroke();
748 bool 
749 SelectedStyle::on_fill_click(GdkEventButton *event)
751     if (event->button == 1) { // click, open fill&stroke
752         sp_object_properties_fill();
753     } else if (event->button == 3) { // right-click, popup menu
754         _popup[SS_FILL].popup(event->button, event->time);
755     } else if (event->button == 2) { // middle click, toggle none/lastcolor
756         if (_mode[SS_FILL] == SS_NONE) {
757             on_fill_lastused();
758         } else {
759             on_fill_remove();
760         }
761     }
762     return true;
765 bool 
766 SelectedStyle::on_stroke_click(GdkEventButton *event)
768     if (event->button == 1) { // click, open fill&stroke
769         sp_object_properties_stroke();
770     } else if (event->button == 3) { // right-click, popup menu
771         _popup[SS_STROKE].popup(event->button, event->time);
772     } else if (event->button == 2) { // middle click, toggle none/lastcolor
773         if (_mode[SS_STROKE] == SS_NONE) {
774             on_stroke_lastused();
775         } else {
776             on_stroke_remove();
777         }
778     }
779     return true;
782 bool 
783 SelectedStyle::on_sw_click(GdkEventButton *event)
785     if (event->button == 1) { // click, open fill&stroke
786         sp_object_properties_stroke_style ();
787     } else if (event->button == 3) { // right-click, popup menu
788         _popup_sw.popup(event->button, event->time);
789     } else if (event->button == 2) { // middle click, toggle none/lastwidth?
790         //
791     }
792     return true;
795 bool 
796 SelectedStyle::on_opacity_click(GdkEventButton *event)
798     if (event->button == 2) { // middle click
799         const char* opacity = _opacity_sb.get_value() < 0.5? "0.5" : (_opacity_sb.get_value() == 1? "0" : "1");
800         SPCSSAttr *css = sp_repr_css_attr_new ();
801         sp_repr_css_set_property (css, "opacity", opacity);
802         sp_desktop_set_style (_desktop, css);
803         sp_repr_css_attr_unref (css);
804         sp_document_done (sp_desktop_document (_desktop), SP_VERB_DIALOG_FILL_STROKE,
805                       _("Change opacity"));
806         return true;
807     }
809     return false;
812 void SelectedStyle::on_popup_px() {
813     _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_PX));
814     update();
816 void SelectedStyle::on_popup_pt() {
817     _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_PT));
818     update();
820 void SelectedStyle::on_popup_mm() {
821     _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_MM));
822     update();
825 void SelectedStyle::on_popup_preset(int i) {
826     SPCSSAttr *css = sp_repr_css_attr_new ();
827     gdouble w;
828     if (_sw_unit) {
829         w = sp_units_get_pixels (_sw_presets[i], *_sw_unit);
830     } else {
831         w = _sw_presets[i];
832     }
833     Inkscape::CSSOStringStream os;
834     os << w;
835     sp_repr_css_set_property (css, "stroke-width", os.str().c_str());
836     sp_desktop_set_style (_desktop, css, true);
837     sp_repr_css_attr_unref (css);
838     sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_SWATCHES,
839                       _("Change opacity"));
842 void
843 SelectedStyle::update()
845     if (_desktop == NULL)
846         return;
848     // create temporary style
849     SPStyle *query = sp_style_new ();
851     for (int i = SS_FILL; i <= SS_STROKE; i++) {
852         Gtk::EventBox *place = (i == SS_FILL)? &_fill_place : &_stroke_place;
853         Gtk::EventBox *flag_place = (i == SS_FILL)? &_fill_flag_place : &_stroke_flag_place;
855         place->remove();
856         flag_place->remove();
858         _tooltips.unset_tip(*place);
859         _tooltips.unset_tip(*flag_place);
861         _mode[i] = SS_NA;
862         _paintserver_id[i].clear();
864         _popup_copy[i].set_sensitive(false);
866         // query style from desktop. This returns a result flag and fills query with the style of subselection, if any, or selection
867         int result = sp_desktop_query_style (_desktop, query, 
868                                              (i == SS_FILL)? QUERY_STYLE_PROPERTY_FILL : QUERY_STYLE_PROPERTY_STROKE);
869         switch (result) {
870         case QUERY_STYLE_NOTHING:
871             place->add(_na[i]);
872             _tooltips.set_tip(*place, __na[i]);
873             _mode[i] = SS_NA;
874             if ( _dropEnabled[i] ) {
875                 gtk_drag_dest_unset( GTK_WIDGET((i==SS_FILL) ? _fill_place.gobj():_stroke_place.gobj()) );
876                 _dropEnabled[i] = false;
877             }
878             break;
879         case QUERY_STYLE_SINGLE:
880         case QUERY_STYLE_MULTIPLE_AVERAGED:
881         case QUERY_STYLE_MULTIPLE_SAME: 
882             if ( !_dropEnabled[i] ) {
883                 gtk_drag_dest_set( GTK_WIDGET( (i==SS_FILL) ? _fill_place.gobj():_stroke_place.gobj()),
884                                    GTK_DEST_DEFAULT_ALL,
885                                    ui_drop_target_entries,
886                                    nui_drop_target_entries,
887                                    GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE) );
888                 _dropEnabled[i] = true;
889             }
890             SPIPaint *paint;
891             if (i == SS_FILL) {
892                 paint = &(query->fill);
893             } else {
894                 paint = &(query->stroke);
895             }
896             if (paint->set && paint->type == SP_PAINT_TYPE_COLOR) {
897                 guint32 color = sp_color_get_rgba32_falpha (&(paint->value.color), 
898                                      SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query->fill_opacity.value : query->stroke_opacity.value));
899                 _lastselected[i] = _thisselected[i];
900                 _thisselected[i] = color | 0xff; // only color, opacity === 1
901                 ((Inkscape::UI::Widget::ColorPreview*)_color_preview[i])->setRgba32 (color);
902                 _color_preview[i]->show_all();
903                 place->add(*_color_preview[i]);
904                 gchar c_string[64];
905                 g_snprintf (c_string, 64, "%06x/%.3g", color >> 8, SP_RGBA32_A_F(color));
906                 _tooltips.set_tip(*place, __color[i] + ": " + c_string);
907                 _mode[i] = SS_COLOR;
908                 _popup_copy[i].set_sensitive(true);
910             } else if (paint->set && paint->type == SP_PAINT_TYPE_PAINTSERVER) {
911                 SPPaintServer *server = (i == SS_FILL)? SP_STYLE_FILL_SERVER (query) : SP_STYLE_STROKE_SERVER (query);
912                 if ( server ) {
913                     Inkscape::XML::Node *srepr = SP_OBJECT_REPR(server);
914                     _paintserver_id[i] += "url(#";
915                     _paintserver_id[i] += srepr->attribute("id");
916                     _paintserver_id[i] += ")";
918                     if (SP_IS_LINEARGRADIENT (server)) {
919                         place->add(_lgradient[i]);
920                         _tooltips.set_tip(*place, __lgradient[i]);
921                         _mode[i] = SS_LGRADIENT;
922                     } else if (SP_IS_RADIALGRADIENT (server)) {
923                         place->add(_rgradient[i]);
924                         _tooltips.set_tip(*place, __rgradient[i]);
925                         _mode[i] = SS_RGRADIENT;
926                     } else if (SP_IS_PATTERN (server)) {
927                         place->add(_pattern[i]);
928                         _tooltips.set_tip(*place, __pattern[i]);
929                         _mode[i] = SS_PATTERN;
930                     }
931                 } else {
932                     g_warning ("file %s: line %d: Unknown paint server", __FILE__, __LINE__);
933                 }
935             } else if (paint->set && paint->type == SP_PAINT_TYPE_NONE) {
936                 place->add(_none[i]);
937                 _tooltips.set_tip(*place, __none[i]);
938                 _mode[i] = SS_NONE;
939             } else if (!paint->set) {
940                 place->add(_unset[i]);
941                 _tooltips.set_tip(*place, __unset[i]);
942                 _mode[i] = SS_UNSET;
943             }
944             if (result == QUERY_STYLE_MULTIPLE_AVERAGED) {
945                 flag_place->add(_averaged[i]);
946                 _tooltips.set_tip(*flag_place, __averaged[i]);
947             } else if (result == QUERY_STYLE_MULTIPLE_SAME) {
948                 flag_place->add(_multiple[i]);
949                 _tooltips.set_tip(*flag_place, __multiple[i]);
950             }
951             break;
952         case QUERY_STYLE_MULTIPLE_DIFFERENT:
953             place->add(_many[i]);
954             _tooltips.set_tip(*place, __many[i]);
955             _mode[i] = SS_MANY;
956             break;
957         default:
958             break;
959         }
960     }
962 // Now query opacity
963     _tooltips.unset_tip(_opacity_place);
965     int result = sp_desktop_query_style (_desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
967     switch (result) {
968     case QUERY_STYLE_NOTHING:
969         _tooltips.set_tip(_opacity_place, _("Nothing selected"));
970         _opacity_sb.set_sensitive(false);
971         break;
972     case QUERY_STYLE_SINGLE:
973     case QUERY_STYLE_MULTIPLE_AVERAGED:
974     case QUERY_STYLE_MULTIPLE_SAME:
975         _tooltips.set_tip(_opacity_place, _("Master opacity"));
976         _opacity_blocked = true;
977         _opacity_sb.set_sensitive(true);
978         _opacity_adjustment.set_value(SP_SCALE24_TO_FLOAT(query->opacity.value));
979         _opacity_blocked = false;
980         break;
981     }
983 // Now query stroke_width
984     int result_sw = sp_desktop_query_style (_desktop, query, QUERY_STYLE_PROPERTY_STROKEWIDTH);
985     switch (result_sw) {
986     case QUERY_STYLE_NOTHING:
987         _stroke_width.set_markup("");
988         break;
989     case QUERY_STYLE_SINGLE:
990     case QUERY_STYLE_MULTIPLE_AVERAGED:
991     case QUERY_STYLE_MULTIPLE_SAME: 
992     {
993         double w;
994         if (_sw_unit) {
995             w = sp_pixels_get_units(query->stroke_width.computed, *_sw_unit);
996         } else {
997             w = query->stroke_width.computed;
998         }
999         {
1000             gchar *str = g_strdup_printf(" %.3g", w);
1001             _stroke_width.set_markup(str);
1002             g_free (str);
1003         }
1004         {
1005             gchar *str = g_strdup_printf(_("Stroke width: %.5g%s%s"), 
1006                                          w, 
1007                                          _sw_unit? sp_unit_get_abbreviation(_sw_unit) : "px", 
1008                                          (result_sw == QUERY_STYLE_MULTIPLE_AVERAGED)?
1009                                          _(" (averaged)") : "");
1010             _tooltips.set_tip(_stroke_width_place, str);
1011             g_free (str);
1012         }
1013         break;
1014     }
1015     default:
1016         break;
1017     }
1019     g_free (query);
1022 void SelectedStyle::opacity_0(void) {_opacity_sb.set_value(0);}
1023 void SelectedStyle::opacity_025(void) {_opacity_sb.set_value(0.25);}
1024 void SelectedStyle::opacity_05(void) {_opacity_sb.set_value(0.5);}
1025 void SelectedStyle::opacity_075(void) {_opacity_sb.set_value(0.75);}
1026 void SelectedStyle::opacity_1(void) {_opacity_sb.set_value(1.0);}
1028 void SelectedStyle::on_opacity_menu (Gtk::Menu *menu) {
1030     Glib::ListHandle<Gtk::Widget *> children = menu->get_children();
1031     for (Glib::ListHandle<Gtk::Widget *>::iterator iter = children.begin(); iter != children.end(); iter++) {
1032         menu->remove(*(*iter));
1033     }
1035     {
1036         Gtk::MenuItem *item = new Gtk::MenuItem;
1037         item->add(*(new Gtk::Label(_("0 (transparent)"), 0, 0)));
1038         item->signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::opacity_0 ));
1039         menu->add(*item);
1040     }
1041     {
1042         Gtk::MenuItem *item = new Gtk::MenuItem;
1043         item->add(*(new Gtk::Label("0.25", 0, 0)));
1044         item->signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::opacity_025 ));
1045         menu->add(*item);
1046     }
1047     {
1048         Gtk::MenuItem *item = new Gtk::MenuItem;
1049         item->add(*(new Gtk::Label("0.5", 0, 0)));
1050         item->signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::opacity_05 ));
1051         menu->add(*item);
1052     }
1053     {
1054         Gtk::MenuItem *item = new Gtk::MenuItem;
1055         item->add(*(new Gtk::Label("0.75", 0, 0)));
1056         item->signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::opacity_075 ));
1057         menu->add(*item);
1058     }
1059     {
1060         Gtk::MenuItem *item = new Gtk::MenuItem;
1061         item->add(*(new Gtk::Label(_("1.0 (opaque)"), 0, 0)));
1062         item->signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::opacity_1 ));
1063         menu->add(*item);
1064     }
1066     menu->show_all();
1069 void SelectedStyle::on_opacity_changed () {
1070     if (_opacity_blocked)
1071         return;
1072     _opacity_blocked = true;
1073     SPCSSAttr *css = sp_repr_css_attr_new ();
1074     Inkscape::CSSOStringStream os;
1075     os << CLAMP (_opacity_adjustment.get_value(), 0.0, 1.0);
1076     sp_repr_css_set_property (css, "opacity", os.str().c_str());
1077     sp_desktop_set_style (_desktop, css);
1078     sp_repr_css_attr_unref (css);
1079     sp_document_maybe_done (sp_desktop_document (_desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE,
1080                       _("Change opacity"));
1081     spinbutton_defocus(GTK_OBJECT(_opacity_sb.gobj()));
1082     _opacity_blocked = false;
1085 } // namespace Widget
1086 } // namespace UI
1087 } // namespace Inkscape
1089 /* 
1090   Local Variables:
1091   mode:c++
1092   c-file-style:"stroustrup"
1093   c-file-offsets:((innamespace . 0)(inline-open . 0))
1094   indent-tabs-mode:nil
1095   fill-column:99
1096   End:
1097 */
1098 // vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :