summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJabiertxof <jabier.arraiza@marker.es>2019-07-28 16:59:09 +0000
committerJabiertxof <jabier.arraiza@marker.es>2019-07-29 07:20:15 +0000
commita7e562fc5b5f2c6a41548eaee85d9803cada7621 (patch)
tree1e36150108dac936157db57f01bd999c7be56c53 /src/ui
parentFix for bug https://gitlab.com/inkscape/inbox/issues/699 (diff)
downloadinkscape-a7e562fc5b5f2c6a41548eaee85d9803cada7621.tar.gz
inkscape-a7e562fc5b5f2c6a41548eaee85d9803cada7621.zip
Add Patrick improvements to verbs toggle menu items
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/desktop/menubar.cpp45
-rw-r--r--src/ui/desktop/menubar.h1
2 files changed, 25 insertions, 21 deletions
diff --git a/src/ui/desktop/menubar.cpp b/src/ui/desktop/menubar.cpp
index 0ada70284..79c3f5aaf 100644
--- a/src/ui/desktop/menubar.cpp
+++ b/src/ui/desktop/menubar.cpp
@@ -41,6 +41,9 @@
// ================= Common ====================
+std::vector<std::pair<unsigned int, Gtk::CheckMenuItem *> > checkmenuitems;
+unsigned int lastverb = 0;;
+
// Sets tip
static void
select_action(SPAction *action)
@@ -56,31 +59,31 @@ deselect_action(SPAction *action)
}
// Trigger action
-static void item_activate(Gtk::MenuItem *menuitem, SPAction *action)
+static void
+item_activate(Gtk::MenuItem *menuitem, SPAction *action)
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool freeze = prefs->getBool("/menu/freeze", false);
- if (!freeze) {
- prefs->setBool("/menu/freeze", true);
- sp_action_perform(action, nullptr);
- prefs->setBool("/menu/freeze", false);
+ if (action->verb->get_code() == lastverb) {
+ lastverb = 0;
+ return;
}
+ lastverb = action->verb->get_code();
+ sp_action_perform(action, nullptr);
+ lastverb = 0;
}
-void activate_checkmenu(unsigned int emited_verb, unsigned int recibe_verb, Gtk::CheckMenuItem *menuitem)
+static void
+toggle_checkmenu(unsigned int emitting_verb, bool value)
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool freeze = prefs->getBool("/menu/freeze", false);
- if (!freeze) {
- prefs->setBool("/menu/freeze", true);
- if (emited_verb == recibe_verb) {
- if (menuitem->get_active()) {
- menuitem->property_active() = false;
- } else {
- menuitem->property_active() = true;
+ for (auto menu : checkmenuitems) {
+ if (emitting_verb == menu.first) {
+ if (emitting_verb == lastverb) {
+ lastverb = 0;
+ return;
}
+ lastverb = emitting_verb;
+ menu.second->property_active() = value;
+ lastverb = 0;
}
- prefs->setBool("/menu/freeze", false);
}
}
@@ -180,7 +183,7 @@ build_menu_item_from_verb(SPAction* action,
// =============== CheckMenuItem ==================
-static bool
+bool
getStateFromPref(SPDesktop* dt, Glib::ustring item)
{
Glib::ustring pref_path;
@@ -449,8 +452,7 @@ build_menu(Gtk::MenuShell* menu, Inkscape::XML::Node* xml, Inkscape::UI::View::V
Gtk::CheckMenuItem* menuitem = build_menu_check_item_from_verb(action);
if (menuitem) {
- SP_ACTIVE_DESKTOP->_menu_update.connect(
- sigc::bind(sigc::ptr_fun(&activate_checkmenu), verb->get_code(), menuitem));
+ checkmenuitems.push_back(std::make_pair(verb->get_code(), menuitem));
menu->append(*menuitem);
}
@@ -530,6 +532,7 @@ build_menu(Gtk::MenuShell* menu, Inkscape::XML::Node* xml, Inkscape::UI::View::V
std::cerr << "build_menu: xml node has no name!" << std::endl;
}
}
+ SP_ACTIVE_DESKTOP->_menu_update.connect(sigc::ptr_fun(&toggle_checkmenu));
}
diff --git a/src/ui/desktop/menubar.h b/src/ui/desktop/menubar.h
index cf50c7f88..c04ff57d0 100644
--- a/src/ui/desktop/menubar.h
+++ b/src/ui/desktop/menubar.h
@@ -29,6 +29,7 @@ namespace View {
}
}
+bool getStateFromPref(SPDesktop* dt, Glib::ustring item);
Gtk::MenuBar* build_menubar(Inkscape::UI::View::View* view);
#endif // SEEN_DESKTOP_MENUBAR_H