From aacf0decdb47a27d05b4701517a0e36e68491f66 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 9 Aug 2013 18:22:31 -0500 Subject: create Profile.root_action in Profile's constructor. --- src/desktop.vala | 2 +- src/phone.vala | 2 +- src/profile.vala | 22 ++++++---------------- 3 files changed, 8 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/desktop.vala b/src/desktop.vala index 588a584..4a10db8 100644 --- a/src/desktop.vala +++ b/src/desktop.vala @@ -51,7 +51,7 @@ class Desktop: Profile // build the static actions Action[] actions = {}; - actions += get_root_action (profile_name); + actions += root_action; actions += create_enabled_action (bluetooth); actions += create_discoverable_action (bluetooth); actions += create_wizard_action (); diff --git a/src/phone.vala b/src/phone.vala index 8adc111..43ca554 100644 --- a/src/phone.vala +++ b/src/phone.vala @@ -31,7 +31,7 @@ class Phone: Profile // build the static actions Action[] actions = {}; - actions += get_root_action (profile_name); + actions += root_action; actions += create_enabled_action (bluetooth); actions += create_settings_action (); foreach (var a in actions) diff --git a/src/profile.vala b/src/profile.vala index f89490b..c288b4e 100644 --- a/src/profile.vala +++ b/src/profile.vala @@ -24,6 +24,7 @@ class Profile: Object protected Menu root; protected Menu menu; private uint menu_export_id; + protected SimpleAction root_action; protected bool visible { get; set; default = true; } @@ -32,6 +33,11 @@ class Profile: Object this.bluetooth = bluetooth; this.profile_name = profile_name; + root_action = new SimpleAction.stateful (@"root-$profile_name", + null, + action_state_for_root()); + notify["visible"].connect (() => update_root_action_state()); + menu = new Menu (); var item = create_root_menuitem (); @@ -119,22 +125,6 @@ class Profile: Object return action; } - protected SimpleAction root_action = null; - - protected SimpleAction get_root_action (string profile) - { - if (root_action == null) - { - root_action = new SimpleAction.stateful (@"root-$profile", - null, - action_state_for_root()); - - notify["visible"].connect (() => update_root_action_state()); - } - - return root_action; - } - protected void update_root_action_state () { root_action.set_state (action_state_for_root ()); -- cgit v1.2.3