diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-09-14 09:55:45 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-09-19 21:05:29 +0000 |
| commit | a0d02c911c226677e833ede6c76825b2c12a3897 (patch) | |
| tree | 858f12d87f4889bea17d86fc3f4ec9ef368be1e4 /src/ui | |
| parent | Fix partialy issue 425 (the highlight part not new line one) https://gitlab.c... (diff) | |
| download | inkscape-a0d02c911c226677e833ede6c76825b2c12a3897.tar.gz inkscape-a0d02c911c226677e833ede6c76825b2c12a3897.zip | |
Fix issue in toggle menu items like display mode and color mode. Partialy fix https://gitlab.com/inkscape/inkscape/issues/157
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/desktop/menubar.cpp | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/ui/desktop/menubar.cpp b/src/ui/desktop/menubar.cpp index 8852f344b..75c2198bd 100644 --- a/src/ui/desktop/menubar.cpp +++ b/src/ui/desktop/menubar.cpp @@ -42,6 +42,7 @@ // ================= Common ==================== std::vector<std::pair<std::pair<unsigned int, Gtk::CheckMenuItem *>, Inkscape::UI::View::View *>> checkmenuitems; +std::vector<std::pair<std::pair<unsigned int, Gtk::RadioMenuItem *>, Inkscape::UI::View::View *>> radiomenuitems; unsigned int lastverb = -1; ; @@ -88,6 +89,23 @@ static void toggle_checkmenu(unsigned int emitting_verb, bool value) } } +static void toggle_radiomenu(unsigned int emitting_verb, bool value) +{ + for (auto menu : radiomenuitems) { + if (menu.second == SP_ACTIVE_DESKTOP) { + if (emitting_verb == menu.first.first) { + if (emitting_verb == lastverb) { + lastverb = -1; + return; + } + lastverb = emitting_verb; + menu.first.second->property_active() = value; + lastverb = -1; + } + } + } +} + // Change label name (used in the Undo/Redo menu items). static void set_name(Glib::ustring const &name, Gtk::MenuItem* menuitem) @@ -168,7 +186,6 @@ build_menu_item_from_verb(SPAction* action, } else { menuitem->add(*label); } - menuitem->signal_activate().connect( sigc::bind<Gtk::MenuItem*, SPAction*>(sigc::ptr_fun(&item_activate), menuitem, action)); menuitem->signal_select().connect( sigc::bind<SPAction*>(sigc::ptr_fun(&select_action), action)); @@ -461,20 +478,15 @@ build_menu(Gtk::MenuShell* menu, Inkscape::XML::Node* xml, Inkscape::UI::View::V } else if (menu_ptr->attribute("radio") != nullptr) { - Gtk::MenuItem* menuitem = build_menu_item_from_verb(action, show_icons_curr, true, &group); + Gtk::RadioMenuItem* menuitem = dynamic_cast<Gtk::RadioMenuItem *>(build_menu_item_from_verb(action, show_icons_curr, true, &group)); if (menuitem) { - // TODO: if necesary update a radio in the future we can follow the previus checkbutton - if (menu_ptr->attribute("default") != nullptr) { - auto radiomenuitem = dynamic_cast<Gtk::RadioMenuItem*>(menuitem); - if (radiomenuitem) { - radiomenuitem->set_active(true); - } - } + std::pair<std::pair<unsigned int, Gtk::RadioMenuItem *>, Inkscape::UI::View::View *> + checkitem = std::make_pair(std::make_pair(verb->get_code(), menuitem), view); + checkmenuitems.push_back(checkitem); menu->append(*menuitem); } } else { - Gtk::MenuItem* menuitem = build_menu_item_from_verb(action, show_icons_curr); if (menuitem) { menu->append(*menuitem); @@ -540,6 +552,7 @@ build_menu(Gtk::MenuShell* menu, Inkscape::XML::Node* xml, Inkscape::UI::View::V } } SP_ACTIVE_DESKTOP->_menu_update.connect(sigc::ptr_fun(&toggle_checkmenu)); + SP_ACTIVE_DESKTOP->_menu_update.connect(sigc::ptr_fun(&toggle_radiomenu)); } Gtk::MenuBar* |
