| 154 | } |
| 155 | |
| 156 | void |
| 157 | PluginDeclaration::init_menu (lay::Dispatcher *dispatcher) |
| 158 | { |
| 159 | lay::AbstractMenu &menu = *dispatcher->menu (); |
| 160 | |
| 161 | mp_editable_mode_action.reset ((Action *) 0); |
| 162 | mp_mouse_mode_action.reset ((Action *) 0); |
| 163 | |
| 164 | std::string title; |
| 165 | |
| 166 | // make all plugins that return true on "implements_editable" into menu entries and |
| 167 | // set up the actions accordingly |
| 168 | |
| 169 | if (implements_editable (title) && menu.is_valid ("edit_menu.select_menu")) { |
| 170 | |
| 171 | // extract first part, which is the name, separated by a tab from the title. |
| 172 | std::string name = tl::sprintf ("pi_enable_%d", id ()); |
| 173 | std::string t (title); |
| 174 | const char *tab = strchr (t.c_str (), '\t'); |
| 175 | if (tab) { |
| 176 | name = std::string (t, 0, tab - t.c_str ()); |
| 177 | title = tab + 1; |
| 178 | } |
| 179 | |
| 180 | mp_editable_mode_action.reset (new Action (title)); |
| 181 | #if defined(HAVE_QT) |
| 182 | if (mp_editable_mode_action->qaction ()) { |
| 183 | gtf::action_connect (mp_editable_mode_action->qaction (), SIGNAL (triggered ()), this, SLOT (toggle_editable_enabled ())); |
| 184 | } |
| 185 | #endif |
| 186 | mp_editable_mode_action->set_checkable (true); |
| 187 | mp_editable_mode_action->set_checked (m_editable_enabled); |
| 188 | |
| 189 | menu.insert_item ("edit_menu.select_menu.end", name, mp_editable_mode_action.get ()); |
| 190 | |
| 191 | } |
| 192 | |
| 193 | // add all the custom menus from the plugins |
| 194 | std::vector<lay::MenuEntry> menu_entries; |
| 195 | get_menu_entries (menu_entries); |
| 196 | |
| 197 | for (std::vector<lay::MenuEntry>::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) { |
| 198 | |
| 199 | if (! m->copy_from.empty ()) { |
| 200 | |
| 201 | // As a general strategy for now we take primary ownership from the copy source as pass it to |
| 202 | // the copy. This is important for "next/prev_display_state" as the first registry is @toolbar |
| 203 | // (which is not accessible by Setup menu) and the second one is "zoom_menu" which should be |
| 204 | // the primary one. For later, we may want to make this configurable (move/leave primary flag). |
| 205 | menu.find_item_exact (m->copy_from)->set_primary (false); |
| 206 | |
| 207 | menu.insert_item (m->insert_pos, m->menu_name, menu.action (m->copy_from)); |
| 208 | |
| 209 | } else if (m->separator) { |
| 210 | |
| 211 | menu.insert_separator (m->insert_pos, m->menu_name); |
| 212 | |
| 213 | } else if (m->sub_menu) { |
nothing calls this directly
no test coverage detected