[gnome-bluetooth] properties: Implement properties and visibility
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] properties: Implement properties and visibility
- Date: Mon, 21 Feb 2011 22:24:29 +0000 (UTC)
commit a9910af65956486fb68cf2478a7019a08923d0b2
Author: Bastien Nocera <hadess hadess net>
Date: Mon Feb 21 22:21:47 2011 +0000
properties: Implement properties and visibility
The buttons still don't work, but we can update the properties
when switching devices, and set the discoverability on startup.
properties/bluetooth.ui | 67 +++++++++++++++++++++++------
properties/cc-bluetooth-panel.c | 90 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 142 insertions(+), 15 deletions(-)
---
diff --git a/properties/bluetooth.ui b/properties/bluetooth.ui
index 5e246e6..f86331d 100644
--- a/properties/bluetooth.ui
+++ b/properties/bluetooth.ui
@@ -47,7 +47,7 @@
<placeholder/>
</child>
<child>
- <object class="GtkLabel" id="label19">
+ <object class="GtkLabel" id="visible_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
@@ -98,17 +98,18 @@
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
- <object class="GtkVBox" id="vbox1">
+ <object class="GtkVBox" id="properties_vbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkTable" id="table1">
+ <object class="GtkTable" id="properties_table">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="n_rows">3</property>
+ <property name="n_rows">4</property>
<property name="n_columns">4</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
+ <property name="homogeneous">True</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
@@ -119,7 +120,7 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="y_options"></property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -134,11 +135,11 @@
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
- <property name="y_options"></property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label3">
+ <object class="GtkLabel" id="paired_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -149,7 +150,7 @@
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
- <property name="y_options"></property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -164,11 +165,11 @@
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
- <property name="y_options"></property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label5">
+ <object class="GtkLabel" id="type_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -179,7 +180,7 @@
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
- <property name="y_options"></property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -187,7 +188,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkSwitch" id="switch_discoverable1">
+ <object class="GtkSwitch" id="switch_connection">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="use_action_appearance">False</property>
@@ -226,6 +227,43 @@
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Address</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="address_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">00:00:00:00:00</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -264,11 +302,11 @@
<placeholder/>
</child>
<child>
- <object class="GtkButton" id="button1">
+ <object class="GtkButton" id="keyboard_button">
<property name="label" translatable="yes">Keyboard Settings</property>
- <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="no_show_all">True</property>
<property name="use_action_appearance">False</property>
</object>
<packing>
@@ -339,6 +377,7 @@
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_SHRINK | GTK_FILL</property>
</packing>
</child>
diff --git a/properties/cc-bluetooth-panel.c b/properties/cc-bluetooth-panel.c
index b5d20b2..6a79102 100644
--- a/properties/cc-bluetooth-panel.c
+++ b/properties/cc-bluetooth-panel.c
@@ -93,6 +93,86 @@ cc_bluetooth_panel_finalize (GObject *object)
}
static void
+cc_bluetooth_panel_update_properties (CcBluetoothPanel *self)
+{
+ char *bdaddr;
+
+ bdaddr = bluetooth_chooser_get_selected_device (BLUETOOTH_CHOOSER (self->priv->chooser));
+ if (bdaddr == NULL) {
+ //FIXME for loop with other buttons
+ gtk_widget_hide (WID ("keyboard_button"));
+ gtk_widget_set_sensitive (WID ("properties_vbox"), FALSE);
+ gtk_switch_set_active (GTK_SWITCH (WID ("switch_connection")), FALSE);
+ gtk_label_set_text (GTK_LABEL (WID ("paired_label")), "");
+ gtk_label_set_text (GTK_LABEL (WID ("type_label")), "");
+ gtk_label_set_text (GTK_LABEL (WID ("address_label")), "");
+ } else {
+ BluetoothType type;
+ gboolean connected;
+ GValue value = { 0 };
+
+ gtk_widget_set_sensitive (WID ("properties_vbox"), TRUE);
+
+ connected = bluetooth_chooser_get_selected_device_is_connected (BLUETOOTH_CHOOSER (self->priv->chooser));
+ gtk_switch_set_active (GTK_SWITCH (WID ("switch_connection")), connected);
+
+ bluetooth_chooser_get_selected_device_info (BLUETOOTH_CHOOSER (self->priv->chooser),
+ "paired", &value);
+ gtk_label_set_text (GTK_LABEL (WID ("paired_label")),
+ g_value_get_boolean (&value) ? _("Yes") : _("No"));
+
+ type = bluetooth_chooser_get_selected_device_type (BLUETOOTH_CHOOSER (self->priv->chooser));
+ gtk_label_set_text (GTK_LABEL (WID ("type_label")), bluetooth_type_to_string (type));
+ switch (type) {
+ case BLUETOOTH_TYPE_KEYBOARD:
+ gtk_widget_show (WID ("keyboard_button"));
+ break;
+ default:
+ /* FIXME add others */
+ ;
+ }
+
+ gtk_label_set_text (GTK_LABEL (WID ("address_label")), bdaddr);
+ g_free (bdaddr);
+ }
+}
+
+static void
+cc_bluetooth_panel_update_visibility (CcBluetoothPanel *self)
+{
+ gboolean discoverable;
+ char *name;
+
+ discoverable = bluetooth_client_get_discoverable (self->priv->client);
+ gtk_switch_set_active (GTK_SWITCH (WID ("switch_discoverable")), discoverable);
+
+ name = bluetooth_client_get_name (self->priv->client);
+ if (name == NULL) {
+ gtk_widget_set_sensitive (WID ("switch_discoverable"), FALSE);
+ gtk_widget_set_sensitive (WID ("visible_label"), FALSE);
+ gtk_label_set_text (GTK_LABEL (WID ("visible_label")), _("Visibility"));
+ } else {
+ char *label;
+
+ label = g_strdup_printf (_("Visibility of â??%sâ??"), name);
+ g_free (name);
+ gtk_label_set_text (GTK_LABEL (WID ("visible_label")), label);
+ g_free (label);
+
+ gtk_widget_set_sensitive (WID ("switch_discoverable"), TRUE);
+ gtk_widget_set_sensitive (WID ("visible_label"), TRUE);
+ }
+}
+
+static void
+device_selected_changed (BluetoothChooser *chooser,
+ GParamSpec *spec,
+ CcBluetoothPanel *self)
+{
+ cc_bluetooth_panel_update_properties (self);
+}
+
+static void
cc_bluetooth_panel_init (CcBluetoothPanel *self)
{
GtkWidget *widget;
@@ -119,6 +199,9 @@ cc_bluetooth_panel_init (CcBluetoothPanel *self)
widget = WID ("vbox");
gtk_widget_reparent (widget, GTK_WIDGET (self));
+ /* The discoverable button */
+ cc_bluetooth_panel_update_visibility (self);
+
/* The known devices */
widget = WID ("devices_table");
@@ -141,7 +224,7 @@ cc_bluetooth_panel_init (CcBluetoothPanel *self)
g_object_set (G_OBJECT (widget), "headers-visible", FALSE, NULL);
/* Join treeview and buttons */
- widget = bluetooth_chooser_get_scrolled_window (BLUETOOTH_CHOOSER (self->priv->chooser));;
+ widget = bluetooth_chooser_get_scrolled_window (BLUETOOTH_CHOOSER (self->priv->chooser));
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (widget), 250);
context = gtk_widget_get_style_context (widget);
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
@@ -149,6 +232,11 @@ cc_bluetooth_panel_init (CcBluetoothPanel *self)
context = gtk_widget_get_style_context (widget);
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
+ g_signal_connect (G_OBJECT (self->priv->chooser), "notify::device-selected",
+ G_CALLBACK (device_selected_changed), self);
+
+ /* Set the initial state of the dialogue */
+ cc_bluetooth_panel_update_properties (self);
gtk_widget_show_all (GTK_WIDGET (self));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]