diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-01-02 11:25:40 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-01-02 11:25:40 +0100 |
commit | cd16e7b4a394b6ce885a618d8a96eccd662208bb (patch) | |
tree | c9bcd713dbea9467783f8d82c63218af91192da1 /src/Page.vala | |
parent | b1cb72d29fa13b3b6f9f5fe66083dd60930a2b71 (diff) | |
parent | 66f6a7bd3f7e00022191f16cb0e82a39e7333a76 (diff) |
Merge tag 'upstream/0.25.2'
Upstream version 0.25.2
Diffstat (limited to 'src/Page.vala')
-rw-r--r-- | src/Page.vala | 50 |
1 files changed, 6 insertions, 44 deletions
diff --git a/src/Page.vala b/src/Page.vala index 13caae6..a65a1e2 100644 --- a/src/Page.vala +++ b/src/Page.vala @@ -40,8 +40,7 @@ public class InjectionGroup { return elements; } - public void add_menu_item(string name, string? action = null, string? - accellerator = null) { + public void add_menu_item(string name, string? action = null, string? accellerator = null) { elements.add(new Element(name, action, accellerator, Element.ItemType.MENUITEM)); } @@ -208,6 +207,9 @@ public abstract class Page : Gtk.ScrolledWindow { private bool menubar_injected = false; public GLib.MenuModel get_menubar() { var model = builder.get_object ("MenuBar") as GLib.Menu; + if (model == null) { + return new GLib.Menu(); + } if (!menubar_injected) { // Collect injected UI elements and add them to the UI manager @@ -1148,48 +1150,8 @@ public abstract class Page : Gtk.ScrolledWindow { } protected void update_menu_item_label (string id, - string new_label) { - var bar = this.builder.get_object ("MenuBar") as GLib.Menu; - - if (bar == null) { - return; - } - - var items = bar.get_n_items (); - for (var i = 0; i< items; i++) { - var model = bar.get_item_link (i, GLib.Menu.LINK_SUBMENU); - if (bar == null) { - continue; - } - - var model_items = model.get_n_items (); - for (var j = 0; j < model_items; j++) { - var subsection = model.get_item_link (j, GLib.Menu.LINK_SECTION); - - if (subsection == null) - continue; - - // Recurse into submenus - var sub_items = subsection.get_n_items (); - for (var k = 0; k < sub_items; k++) { - var it = subsection.iterate_item_attributes (k); - while (it.next ()) { - if (it.get_name () == "id") { - if (it.get_value ().get_string () == id) { - var md = subsection as GLib.Menu; - var m = new GLib.MenuItem.from_model - (subsection, k); - m.set_label (new_label); - md.remove (k); - md.insert_item (k, m); - - return; - } - } - } - } - } - } + string new_label) { + AppWindow.get_instance().update_menu_item_label (id, new_label); } protected GLib.MenuModel? find_extension_point (GLib.MenuModel model, |