summaryrefslogtreecommitdiff
path: root/src/AppWindow.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/AppWindow.vala')
-rw-r--r--src/AppWindow.vala68
1 files changed, 57 insertions, 11 deletions
diff --git a/src/AppWindow.vala b/src/AppWindow.vala
index 41751e8..99f054d 100644
--- a/src/AppWindow.vala
+++ b/src/AppWindow.vala
@@ -447,6 +447,7 @@ public abstract class AppWindow : PageWindow {
}
private const GLib.ActionEntry[] common_actions = {
+ { "CommonAbout", on_about },
{ "CommonQuit", on_quit },
{ "CommonFullscreen", on_fullscreen },
{ "CommonHelpContents", on_help_contents },
@@ -782,6 +783,51 @@ public abstract class AppWindow : PageWindow {
if (page != null)
update_common_actions(page, page.get_view().get_selected_count(), page.get_view().get_count());
}
+
+ public void update_menu_item_label (string id,
+ string new_label) {
+ var bar = this.get_current_page().get_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" && it.get_value ().get_string () == id) ||
+ (it.get_name() == "action" && it.get_value().get_string().has_suffix("." + 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;
+ }
+ }
+ }
+ }
+ }
+ }
+
+
public static CommandManager get_command_manager() {
return command_manager;
@@ -794,21 +840,21 @@ public abstract class AppWindow : PageWindow {
private void decorate_command_manager_action(string name, string prefix,
string default_explanation, CommandDescription? desc) {
-#if 0
- Gtk.Action? action = get_common_action(name);
- if (action == null)
+ var action = get_common_action(name) as GLib.SimpleAction;
+ if (action == null) {
return;
-
+ }
+
+ string label = prefix;
+
if (desc != null) {
- action.label = "%s %s".printf(prefix, desc.get_name());
- action.tooltip = desc.get_explanation();
- action.sensitive = true;
+ label += " " + desc.get_name();
+ action.set_enabled(true);
} else {
- action.label = prefix;
- action.tooltip = default_explanation;
- action.sensitive = false;
+ label = prefix;
+ action.set_enabled(false);
}
-#endif
+ this.update_menu_item_label(name, label);
}
public void decorate_undo_action() {