[geary/wip/gtkactions: 3/4] Don't implement GAction, because it's broken
- From: Charles Lindsay <clindsay src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/gtkactions: 3/4] Don't implement GAction, because it's broken
- Date: Wed, 11 Dec 2013 02:20:56 +0000 (UTC)
commit 19e31870110500a97703bf29eba81ef9bad4199c
Author: Charles Lindsay <chaz yorba org>
Date: Tue Dec 10 14:08:20 2013 -0800
Don't implement GAction, because it's broken
bindings/vapi/gio-2.0.vapi | 3985 ----------------------
src/client/application/geary-action-adapter.vala | 36 +-
src/client/application/geary-application.vala | 3 +
src/client/application/geary-controller.vala | 7 +-
4 files changed, 21 insertions(+), 4010 deletions(-)
---
diff --git a/src/client/application/geary-action-adapter.vala
b/src/client/application/geary-action-adapter.vala
index 61669e0..b54cd92 100644
--- a/src/client/application/geary-action-adapter.vala
+++ b/src/client/application/geary-action-adapter.vala
@@ -10,36 +10,30 @@
* during its life.
*
* NOTE: this *should* be subclassing SimpleAction, but trying that causes
- * GCC to throw errors at compile time. See bug #720159.
+ * GCC to throw errors at compile time. See bug #720159. Also *should* be at
+ * least implementing Action, but trying that causes a whole different set of
+ * compile-time errors. :'(
*/
-public class Geary.ActionAdapter : Action, BaseObject {
+public class Geary.ActionAdapter : BaseObject {
private delegate void RecursionGuardFunc();
- private SimpleAction action;
+ public Action action { get { return _action; } }
+
+ private SimpleAction _action;
private Gtk.Action gtk_action;
private bool recursing = false;
public ActionAdapter(Gtk.Action gtk_action) {
- action = new SimpleAction(gtk_action.name, null);
+ _action = new SimpleAction(gtk_action.name, null);
this.gtk_action = gtk_action;
- action.activate.connect(on_activated);
- action.notify["enabled"].connect(on_enabled_changed);
+ _action.activate.connect(on_activated);
+ _action.notify["enabled"].connect(on_enabled_changed);
gtk_action.activate.connect(on_gtk_activated);
gtk_action.notify["sensitive"].connect(on_gtk_sensitive_changed);
}
- public virtual bool enabled { get { return action.enabled; } }
- public virtual string name { get { return action.name; } }
- public virtual VariantType parameter_type { get { return action.parameter_type; } }
- public virtual Variant state { owned get { return action.state; } }
- public virtual VariantType state_type { get { return action.state_type; } }
-
- public virtual void activate(Variant? parameter) { action.activate(parameter); }
- public virtual void change_state(Variant value) { action.change_state(value); }
- public virtual Variant get_state_hint() { return action.get_state_hint(); }
-
private void guard_recursion(RecursionGuardFunc f) {
if (recursing)
return;
@@ -55,19 +49,19 @@ public class Geary.ActionAdapter : Action, BaseObject {
private void on_enabled_changed() {
guard_recursion(() => {
- if (gtk_action.sensitive != action.enabled)
- gtk_action.sensitive = action.enabled;
+ if (gtk_action.sensitive != _action.enabled)
+ gtk_action.sensitive = _action.enabled;
});
}
private void on_gtk_activated() {
- guard_recursion(() => action.activate(null));
+ guard_recursion(() => _action.activate(null));
}
private void on_gtk_sensitive_changed() {
guard_recursion(() => {
- if (action.enabled != gtk_action.sensitive)
- action.set_enabled(gtk_action.sensitive);
+ if (_action.enabled != gtk_action.sensitive)
+ _action.set_enabled(gtk_action.sensitive);
});
}
}
diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala
index a43e3e0..ea40f01 100644
--- a/src/client/application/geary-application.vala
+++ b/src/client/application/geary-application.vala
@@ -94,6 +94,9 @@ along with Geary; if not, write to the Free Software Foundation, Inc.,
public Gtk.ActionGroup actions {
get; private set; default = new Gtk.ActionGroup("GearyActionGroup");
}
+ public Gee.Collection<Geary.ActionAdapter> action_adapters {
+ get; private set; default = new Gee.ArrayList<Geary.ActionAdapter>();
+ }
public Gtk.UIManager ui_manager {
get; private set; default = new Gtk.UIManager();
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 9db35a3..d667703 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -391,7 +391,6 @@ public class GearyController : Geary.BaseObject {
};
Gtk.ActionGroup action_group = GearyApplication.instance.actions;
- Gee.ArrayList<Action> actions = new Gee.ArrayList<Action>();
Gtk.ActionEntry[] action_entries = create_actions();
action_group.add_actions(action_entries, this);
@@ -401,15 +400,15 @@ public class GearyController : Geary.BaseObject {
if (e.name in important_actions)
action.is_important = true;
- actions.add(new Geary.ActionAdapter(action));
+ GearyApplication.instance.action_adapters.add(new Geary.ActionAdapter(action));
}
Gtk.ToggleActionEntry[] toggle_action_entries = create_toggle_actions();
action_group.add_toggle_actions(toggle_action_entries, this);
// Don't worry about toggle actions in our action list.
- foreach (Action a in actions)
- GearyApplication.instance.add_action(a);
+ foreach (Geary.ActionAdapter a in GearyApplication.instance.action_adapters)
+ GearyApplication.instance.add_action(a.action);
GearyApplication.instance.ui_manager.insert_action_group(action_group, 0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]