summaryrefslogtreecommitdiff
path: root/src/Page.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/Page.vala')
-rw-r--r--src/Page.vala36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/Page.vala b/src/Page.vala
index a65a1e2..06454d8 100644
--- a/src/Page.vala
+++ b/src/Page.vala
@@ -97,8 +97,6 @@ public abstract class Page : Gtk.ScrolledWindow {
popup_menu.connect(on_context_keypress);
- init_ui();
-
realize.connect(attach_view_signals);
}
@@ -270,6 +268,7 @@ public abstract class Page : Gtk.ScrolledWindow {
public virtual void switching_from() {
in_view = false;
+ remove_actions(AppWindow.get_instance());
if (toolbar_path != null)
toolbar = null;
}
@@ -277,6 +276,11 @@ public abstract class Page : Gtk.ScrolledWindow {
public virtual void switched_to() {
in_view = true;
add_ui();
+ add_actions(AppWindow.get_instance());
+ int selected_count = get_view().get_selected_count();
+ int count = get_view().get_count();
+ init_actions(selected_count, count);
+ update_actions(selected_count, count);
update_modifiers();
}
@@ -288,16 +292,24 @@ public abstract class Page : Gtk.ScrolledWindow {
}
public virtual void switching_to_fullscreen(FullscreenWindow fsw) {
+ add_actions(fsw);
}
public virtual void returning_from_fullscreen(FullscreenWindow fsw) {
+ remove_actions(fsw);
+ switched_to();
}
public GLib.Action? get_action (string name) {
- var aw = AppWindow.get_instance ();
+ GLib.ActionMap? map = null;
+ if (container is FullscreenWindow) {
+ map = container as GLib.ActionMap;
+ } else {
+ map = AppWindow.get_instance () as GLib.ActionMap;
+ }
- if (aw != null) {
- return aw.lookup_action (name);
+ if (map != null) {
+ return map.lookup_action(name);
}
return null;
@@ -468,7 +480,8 @@ public abstract class Page : Gtk.ScrolledWindow {
return AppWindow.get_command_manager();
}
- protected virtual void add_actions () { }
+ protected virtual void add_actions (GLib.ActionMap map) { }
+ protected virtual void remove_actions (GLib.ActionMap map) { }
protected void on_action_toggle (GLib.Action action, Variant? value) {
Variant new_state = ! (bool) action.get_state ();
@@ -479,10 +492,6 @@ public abstract class Page : Gtk.ScrolledWindow {
action.change_state (value);
}
- private void init_ui() {
- add_actions ();
- }
-
private void add_ui() {
// Collect all UI filenames and load them into the UI manager
Gee.List<string> ui_filenames = new Gee.ArrayList<string>();
@@ -546,6 +555,9 @@ public abstract class Page : Gtk.ScrolledWindow {
private void on_update_actions_on_idle() {
if (is_destroyed)
return;
+
+ if (!this.in_view)
+ return;
update_actions(get_view().get_selected_count(), get_view().get_count());
}
@@ -562,13 +574,13 @@ public abstract class Page : Gtk.ScrolledWindow {
}
}
- // This is called during init_ui() to collect all the UI files to be loaded into the UI
+ // This is called during add_ui() to collect all the UI files to be loaded into the UI
// manager. Because order is important here, call the base method *first*, then add the
// classes' filename.
protected virtual void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
}
- // This is called during init_ui() to collect all Page.InjectedUIElements for the page. They
+ // This is called during add_ui() to collect all Page.InjectedUIElements for the page. They
// should be added to the MultiSet using the injection path as the key.
protected virtual InjectionGroup[] init_collect_injection_groups() {
return new InjectionGroup[0];