diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-08-05 17:47:31 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2013-08-05 17:47:31 -0500 |
commit | 77e298f113541feacb27c1deca14ec953b6559b0 (patch) | |
tree | 8126f0e41a531fec3f60eaa58e04c5ae0a724b08 /src/desktop.vala | |
parent | fcf74c76f44201684dedd88e1fce39140c1a6235 (diff) | |
download | ayatana-indicator-bluetooth-77e298f113541feacb27c1deca14ec953b6559b0.tar.gz ayatana-indicator-bluetooth-77e298f113541feacb27c1deca14ec953b6559b0.tar.bz2 ayatana-indicator-bluetooth-77e298f113541feacb27c1deca14ec953b6559b0.zip |
pass the SimpleActionGroup handle into the profile object so that dynamically-added actions can get added/exported
Diffstat (limited to 'src/desktop.vala')
-rw-r--r-- | src/desktop.vala | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/desktop.vala b/src/desktop.vala index 31fe9ac..4432a3f 100644 --- a/src/desktop.vala +++ b/src/desktop.vala @@ -22,18 +22,12 @@ class Desktop: Profile private uint idle_rebuild_id = 0; private Settings settings; private Bluetooth bluetooth; + private SimpleActionGroup action_group; private SimpleAction root_action; - private Action[] all_actions; private Menu device_section; private HashTable<uint,SimpleAction> connect_actions; - public override void add_actions_to_group (SimpleActionGroup group) - { - for (var i=0; i<all_actions.length; i++) - group.insert (all_actions[i]); - } - protected override void dispose () { if (idle_rebuild_id != 0) @@ -45,11 +39,12 @@ class Desktop: Profile base.dispose (); } - public Desktop (Bluetooth bluetooth) + public Desktop (Bluetooth bluetooth, SimpleActionGroup action_group) { base ("desktop"); this.bluetooth = bluetooth; + this.action_group = action_group; connect_actions = new HashTable<uint,SimpleAction>(direct_hash, direct_equal); @@ -57,19 +52,24 @@ class Desktop: Profile root_action = create_root_action (); - all_actions = {}; - all_actions += root_action; - all_actions += create_enabled_action (bluetooth); - all_actions += create_discoverable_action (bluetooth); - all_actions += create_wizard_action (); - all_actions += create_browse_files_action (); - all_actions += create_send_file_action (); - all_actions += create_show_settings_action (); + // build the static actions + Action[] actions = {}; + actions += root_action; + actions += create_enabled_action (bluetooth); + actions += create_discoverable_action (bluetooth); + actions += create_wizard_action (); + actions += create_browse_files_action (); + actions += create_send_file_action (); + actions += create_show_settings_action (); + foreach (var a in actions) + action_group.insert (a); build_menu (); settings.changed["visible"].connect (()=> update_root_action_state()); bluetooth.notify.connect (() => update_root_action_state()); + + // when devices change, rebuild our device section bluetooth.devices_changed.connect (()=> { if (idle_rebuild_id == 0) idle_rebuild_id = Idle.add (() => { @@ -99,7 +99,7 @@ class Desktop: Profile action.activate.connect (() => action.set_state (!action.get_state().get_boolean())); action.notify["state"].connect (() => bluetooth.set_device_connected (device.id, action.get_state().get_boolean())); connect_actions.insert (device.id, action); - all_actions += action; + action_group.insert (action); } else { |