diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2013-02-11 20:25:30 +0000 |
---|---|---|
committer | Tarmac <> | 2013-02-11 20:25:30 +0000 |
commit | c3b9103a6e36220e11fbb55cc6849ee91fdf658d (patch) | |
tree | 1e801ad7456601423af6ed45f60f7478f4a976ff | |
parent | b4ead8b4ab91eeaa50393e92eeedb43cd08ec98b (diff) | |
parent | 5ab20c16591d13dff5cf3b41f98ae46bfd6e2fa2 (diff) | |
download | ayatana-indicator-bluetooth-c3b9103a6e36220e11fbb55cc6849ee91fdf658d.tar.gz ayatana-indicator-bluetooth-c3b9103a6e36220e11fbb55cc6849ee91fdf658d.tar.bz2 ayatana-indicator-bluetooth-c3b9103a6e36220e11fbb55cc6849ee91fdf658d.zip |
Support existing gsettings key to disable indicator. Fixes: https://bugs.launchpad.net/bugs/1115394.
Approved by Mathieu Trudel-Lapierre.
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | data/Makefile.am | 11 | ||||
-rw-r--r-- | data/com.canonical.indicator.bluetooth.gschema.xml.in | 9 | ||||
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | po/indicator-bluetooth.pot | 34 | ||||
-rw-r--r-- | src/indicator-bluetooth-service.vala | 63 | ||||
-rw-r--r-- | src/indicator-bluetooth.vala | 5 |
8 files changed, 111 insertions, 20 deletions
@@ -1,3 +1,9 @@ +Overview of changes in indicator-bluetooth 0.0.6 + + * Add "Set Up New Device" menu item + * Only show indicator if Bluetooth adapter present + * Support existing gsettings key to disable indicator + Overview of changes in indicator-bluetooth 0.0.5 * Add license file diff --git a/configure.ac b/configure.ac index 758c71a..2fe9bbe 100644 --- a/configure.ac +++ b/configure.ac @@ -7,6 +7,8 @@ AM_PROG_VALAC([0.16.0]) AM_PROG_CC_C_O LT_INIT +GLIB_GSETTINGS + dnl ########################################################################### dnl Dependencies dnl ########################################################################### diff --git a/data/Makefile.am b/data/Makefile.am index ac63ebc..6f16e85 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -4,7 +4,14 @@ dbus_services_DATA = indicator-bluetooth.service %.service: %.service.in sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ -EXTRA_DIST = indicator-bluetooth.service.in +gsettings_SCHEMAS = com.canonical.indicator.bluetooth.gschema.xml +@INTLTOOL_XML_NOMERGE_RULE@ +@GSETTINGS_RULES@ + +EXTRA_DIST = \ + indicator-bluetooth.service.in \ + com.canonical.indicator.bluetooth.gschema.xml.in CLEANFILES = \ - $(dbus_services_DATA) + $(dbus_services_DATA) \ + $(gsettings_SCHEMAS) diff --git a/data/com.canonical.indicator.bluetooth.gschema.xml.in b/data/com.canonical.indicator.bluetooth.gschema.xml.in new file mode 100644 index 0000000..cb60641 --- /dev/null +++ b/data/com.canonical.indicator.bluetooth.gschema.xml.in @@ -0,0 +1,9 @@ +<schemalist> + <schema id="com.canonical.indicator.bluetooth" path="/com/canonical/indicator/bluetooth/"> + <key name="visible" type="b"> + <default>true</default> + <_summary>Whether or not to show the bluetooth indicator in the menu bar.</_summary> + <_description>Whether or not to show the bluetooth indicator in the menu bar.</_description> + </key> + </schema> +</schemalist> diff --git a/po/POTFILES.in b/po/POTFILES.in index 366eae0..634553a 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,5 +1,6 @@ # List of source files containing translatable strings. # Please keep this file in alphabetical order. [encoding: UTF-8] +data/com.canonical.indicator.bluetooth.gschema.xml.in src/indicator-bluetooth.vala src/indicator-bluetooth-service.vala diff --git a/po/indicator-bluetooth.pot b/po/indicator-bluetooth.pot index bd60d88..9559462 100644 --- a/po/indicator-bluetooth.pot +++ b/po/indicator-bluetooth.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-01-31 12:34-0500\n" +"POT-Creation-Date: 2013-02-08 11:56+1300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -17,48 +17,56 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +#: ../data/com.canonical.indicator.bluetooth.gschema.xml.in.h:1 +msgid "Whether or not to show the bluetooth indicator in the menu bar." +msgstr "" + #: ../src/indicator-bluetooth.vala:17 -#: ../src/indicator-bluetooth-service.vala:195 +#: ../src/indicator-bluetooth-service.vala:231 msgid "Bluetooth: On" msgstr "" -#: ../src/indicator-bluetooth-service.vala:47 -#: ../src/indicator-bluetooth-service.vala:385 +#: ../src/indicator-bluetooth-service.vala:54 +#: ../src/indicator-bluetooth-service.vala:438 msgid "Bluetooth" msgstr "" -#: ../src/indicator-bluetooth-service.vala:61 +#: ../src/indicator-bluetooth-service.vala:68 msgid "Visible" msgstr "" -#: ../src/indicator-bluetooth-service.vala:110 +#: ../src/indicator-bluetooth-service.vala:117 +msgid "Set Up New Device…" +msgstr "" + +#: ../src/indicator-bluetooth-service.vala:122 msgid "Bluetooth Settings…" msgstr "" -#: ../src/indicator-bluetooth-service.vala:195 +#: ../src/indicator-bluetooth-service.vala:231 msgid "Bluetooth: Off" msgstr "" -#: ../src/indicator-bluetooth-service.vala:254 +#: ../src/indicator-bluetooth-service.vala:290 msgid "Connection" msgstr "" -#: ../src/indicator-bluetooth-service.vala:277 +#: ../src/indicator-bluetooth-service.vala:313 msgid "Send files…" msgstr "" -#: ../src/indicator-bluetooth-service.vala:285 +#: ../src/indicator-bluetooth-service.vala:321 msgid "Browse files…" msgstr "" -#: ../src/indicator-bluetooth-service.vala:294 +#: ../src/indicator-bluetooth-service.vala:330 msgid "Keyboard Settings…" msgstr "" -#: ../src/indicator-bluetooth-service.vala:302 +#: ../src/indicator-bluetooth-service.vala:338 msgid "Mouse and Touchpad Settings…" msgstr "" -#: ../src/indicator-bluetooth-service.vala:311 +#: ../src/indicator-bluetooth-service.vala:347 msgid "Sound Settings…" msgstr "" diff --git a/src/indicator-bluetooth-service.vala b/src/indicator-bluetooth-service.vala index 63e634d..ac84f33 100644 --- a/src/indicator-bluetooth-service.vala +++ b/src/indicator-bluetooth-service.vala @@ -10,6 +10,7 @@ public class BluetoothIndicator { + private Settings settings; private DBusConnection bus; private Indicator.Service indicator_service; private Dbusmenu.Server menu_server; @@ -22,11 +23,17 @@ public class BluetoothIndicator private bool updating_visible = false; private Dbusmenu.Menuitem devices_separator; private List<BluetoothMenuItem> device_items; - private Dbusmenu.Menuitem settings_item; private Dbusmenu.Menuitem menu; public BluetoothIndicator () throws Error { + settings = new Settings ("com.canonical.indicator.bluetooth"); + settings.changed.connect ((key) => + { + if (key == "visible") + update_visible (); + }); + bus = Bus.get_sync (BusType.SESSION); indicator_service = new Indicator.Service ("com.canonical.indicator.bluetooth"); @@ -106,12 +113,21 @@ public class BluetoothIndicator sep.property_set (Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR); menu.child_append (sep); - settings_item = new Dbusmenu.Menuitem (); - settings_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Bluetooth Settings…")); - settings_item.item_activated.connect (() => { show_control_center ("bluetooth"); }); - menu.child_append (settings_item); + var item = new Dbusmenu.Menuitem (); + item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Set Up New Device…")); + item.item_activated.connect (() => { set_up_new_device (); }); + menu.child_append (item); + + item = new Dbusmenu.Menuitem (); + item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Bluetooth Settings…")); + item.item_activated.connect (() => { show_control_center ("bluetooth"); }); + menu.child_append (item); killswitch_state_changed_cb (killswitch.state); + + client.adapter_model.row_inserted.connect (update_visible); + client.adapter_model.row_deleted.connect (update_visible); + update_visible (); } private BluetoothMenuItem? find_menu_item (string address) @@ -168,6 +184,26 @@ public class BluetoothIndicator item.update (type, proxy, alias, icon, connected, services, uuids); } + private void update_visible () + { + bluetooth_service._visible = client.adapter_model.iter_n_children (null) > 0 && settings.get_boolean ("visible"); + var builder = new VariantBuilder (VariantType.ARRAY); + builder.add ("{sv}", "Visible", new Variant.boolean (bluetooth_service._visible)); + try + { + var properties = new Variant ("(sa{sv}as)", "com.canonical.indicator.bluetooth.service", builder, null); + bus.emit_signal (null, + "/com/canonical/indicator/bluetooth/service", + "org.freedesktop.DBus.Properties", + "PropertiesChanged", + properties); + } + catch (Error e) + { + warning ("Failed to emit signal: %s", e.message); + } + } + private void device_removed_cb (Gtk.TreePath path) { Gtk.TreeIter iter; @@ -334,6 +370,18 @@ private class BluetoothMenuItem : Dbusmenu.Menuitem } } +private void set_up_new_device () +{ + try + { + Process.spawn_command_line_async ("bluetooth-wizard"); + } + catch (GLib.SpawnError e) + { + warning ("Failed to open bluetooth-wizard: %s", e.message); + } +} + private void show_control_center (string panel) { try @@ -377,6 +425,11 @@ public static int main (string[] args) [DBus (name = "com.canonical.indicator.bluetooth.service")] private class BluetoothService : Object { + internal bool _visible = false; + public bool visible + { + get { return _visible; } + } internal string _icon_name = "bluetooth-active"; public string icon_name { diff --git a/src/indicator-bluetooth.vala b/src/indicator-bluetooth.vala index 4f3aef8..bfbbc9f 100644 --- a/src/indicator-bluetooth.vala +++ b/src/indicator-bluetooth.vala @@ -26,6 +26,9 @@ public class BluetoothIndicator : Indicator.Object var menu_client = menu.get_client (); menu_client.add_type_handler_full ("x-canonical-switch", new_switch_cb); + + /* Hide until ready */ + set_visible (false); } private bool new_switch_cb (Dbusmenu.Menuitem newitem, Dbusmenu.Menuitem parent, Dbusmenu.Client client) @@ -80,6 +83,7 @@ public class BluetoothIndicator : Indicator.Object private void server_properties_changed_cb () { + set_visible (proxy.visible); Indicator.image_helper_update (image, proxy.icon_name); accessible_description = proxy.accessible_description; } @@ -122,6 +126,7 @@ public class Switch : Ido.SwitchMenuItem [DBus (name = "com.canonical.indicator.bluetooth.service")] public interface BluetoothService : DBusProxy { + public abstract bool visible { owned get; } public abstract string icon_name { owned get; } public abstract string accessible_description { owned get; } } |