Code

Mnemonics in fill and stroke dialog and menu
[inkscape.git] / src / ui / widget / object-composite-settings.cpp
index f2fa9bcd3c2bae4b9b04021cbeb5ea7f20b09f88..997c2f0dc87acf371af7715e3536de0ae38059f0 100644 (file)
@@ -5,6 +5,7 @@
  *   Bryce W. Harrington <bryce@bryceharrington.org>
  *   Gustav Broberg <broberg@kth.se>
  *   Niko Kiirala <niko@kiirala.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004--2008 Authors
  *
@@ -18,7 +19,6 @@
 #include "document.h"
 #include "filter-chemistry.h"
 #include "inkscape.h"
-#include "inkscape-stock.h"
 #include "selection.h"
 #include "style.h"
 #include "sp-item.h"
@@ -26,6 +26,7 @@
 #include "verbs.h"
 #include "xml/repr.h"
 #include "widgets/icon.h"
+#include "ui/icon-names.h"
 #include "ui/widget/object-composite-settings.h"
 #include "display/sp-canvas.h"
 
@@ -33,7 +34,7 @@ namespace Inkscape {
 namespace UI {
 namespace Widget {
 
-void ObjectCompositeSettings::_on_desktop_switch(
+void ObjectCompositeSettings::_on_desktop_activate(
     Inkscape::Application */*application*/,
     SPDesktop *desktop,
     ObjectCompositeSettings *w
@@ -43,13 +44,23 @@ void ObjectCompositeSettings::_on_desktop_switch(
     }
 }
 
+void ObjectCompositeSettings::_on_desktop_deactivate(
+    Inkscape::Application */*application*/,
+    SPDesktop */*desktop*/,
+    ObjectCompositeSettings *w
+) {
+    if (w->_subject) {
+        w->_subject->setDesktop(NULL);
+    }
+}
+
 ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char const *history_prefix, int flags)
 : _verb_code(verb_code),
   _blur_tag(Glib::ustring(history_prefix) + ":blur"),
   _opacity_tag(Glib::ustring(history_prefix) + ":opacity"),
   _opacity_vbox(false, 0),
   _opacity_label_box(false, 0),
-  _opacity_label(_("Opacity, %"), 0.0, 1.0, true),
+  _opacity_label(_("_Opacity (%):"), 0.0, 1.0, true),
   _opacity_adjustment(100.0, 0.0, 100.0, 1.0, 1.0, 0.0),
   _opacity_hscale(_opacity_adjustment),
   _opacity_spin_button(_opacity_adjustment, 0.01, 1),
@@ -73,11 +84,14 @@ ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char co
     _opacity_hbox.pack_start(_opacity_hscale, true, true, 4);
     _opacity_hbox.pack_start(_opacity_spin_button, false, false, 0);
     _opacity_hscale.set_draw_value(false);
+    _opacity_hscale.set_update_policy(Gtk::UPDATE_DELAYED);
     _opacity_adjustment.signal_value_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged));
+       _opacity_label.set_mnemonic_widget(_opacity_hscale);
 
     show_all_children();
 
-    _desktop_activated = g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (&ObjectCompositeSettings::_on_desktop_switch), this );
+    _desktop_activated = g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (&ObjectCompositeSettings::_on_desktop_activate), this );
+    _desktop_activated = g_signal_connect ( G_OBJECT (INKSCAPE), "deactivate_desktop", G_CALLBACK (&ObjectCompositeSettings::_on_desktop_deactivate), this );
 }
 
 ObjectCompositeSettings::~ObjectCompositeSettings() {
@@ -112,9 +126,9 @@ ObjectCompositeSettings::_blendBlurValueChanged()
     _blocked = true;
 
     // FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
-    sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
+    //sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
 
-    boost::optional<Geom::Rect> bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX);
+    Geom::OptRect bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX);
     double radius;
     if (bbox) {
         double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y];   // fixme: this is only half the perimeter, is that correct?
@@ -138,6 +152,8 @@ ObjectCompositeSettings::_blendBlurValueChanged()
         if (blendmode != "normal") {
             SPFilter *filter = new_filter_simple_from_item(document, item, blendmode.c_str(), radius);
             sp_style_set_property_url(item, "filter", filter, false);
+        } else {
+            sp_style_set_property_url(item, "filter", NULL, false);
         }
 
         if (radius == 0 && item->style->filter.set
@@ -154,11 +170,11 @@ ObjectCompositeSettings::_blendBlurValueChanged()
                                      SP_OBJECT_STYLE_MODIFIED_FLAG ));
     }
 
-    sp_document_maybe_done (document, _blur_tag.c_str(), _verb_code,
+    DocumentUndo::maybeDone(document, _blur_tag.c_str(), _verb_code,
                             _("Change blur"));
 
     // resume interruptibility
-    sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
+    //sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
 
     _blocked = false;
 }
@@ -182,7 +198,7 @@ ObjectCompositeSettings::_opacityValueChanged()
     // FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
     // UPDATE: crash fixed in GTK+ 2.10.7 (bug 374378), remove this as soon as it's reasonably common
     // (though this only fixes the crash, not the multiple change events)
-    sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
+    //sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
 
     SPCSSAttr *css = sp_repr_css_attr_new ();
 
@@ -194,11 +210,11 @@ ObjectCompositeSettings::_opacityValueChanged()
 
     sp_repr_css_attr_unref (css);
 
-    sp_document_maybe_done (sp_desktop_document (desktop), _opacity_tag.c_str(), _verb_code,
+    DocumentUndo::maybeDone(sp_desktop_document (desktop), _opacity_tag.c_str(), _verb_code,
                             _("Change opacity"));
 
     // resume interruptibility
-    sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
+    //sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
 
     _blocked = false;
 }
@@ -260,7 +276,7 @@ ObjectCompositeSettings::_subjectChanged() {
             case QUERY_STYLE_SINGLE:
             case QUERY_STYLE_MULTIPLE_AVERAGED:
             case QUERY_STYLE_MULTIPLE_SAME:
-                boost::optional<Geom::Rect> bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX);
+                Geom::OptRect bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX);
                 if (bbox) {
                     double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y];   // fixme: this is only half the perimeter, is that correct?
                     _fe_cb.set_blur_sensitive(true);
@@ -291,4 +307,4 @@ ObjectCompositeSettings::_subjectChanged() {
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :