[gnome-bluetooth] lib: Add signal when device is double-clicked
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] lib: Add signal when device is double-clicked
- Date: Tue, 22 Feb 2011 15:55:52 +0000 (UTC)
commit 0a9416dce4ce9bceaf1667895fa3730ac3f09bfa
Author: Bastien Nocera <hadess hadess net>
Date: Tue Feb 22 15:51:59 2011 +0000
lib: Add signal when device is double-clicked
lib/bluetooth-chooser.c | 35 +++++++++++++++++++++++++++++++++++
lib/bluetooth-chooser.h | 1 +
lib/test-deviceselection.c | 12 ++++++++++++
3 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/lib/bluetooth-chooser.c b/lib/bluetooth-chooser.c
index 5efa1c7..0bc988b 100644
--- a/lib/bluetooth-chooser.c
+++ b/lib/bluetooth-chooser.c
@@ -48,6 +48,7 @@
enum {
SELECTED_DEVICE_CHANGED,
+ SELECTED_DEVICE_ACTIVATED,
LAST_SIGNAL
};
@@ -560,6 +561,21 @@ select_browse_device_callback (GtkTreeSelection *selection, gpointer user_data)
g_free (address);
}
+static void
+row_activated_cb (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ BluetoothChooser *self)
+{
+ char *address;
+
+ address = bluetooth_chooser_get_selected_device (self);
+ g_signal_emit (G_OBJECT (self),
+ selection_table_signals[SELECTED_DEVICE_ACTIVATED],
+ 0, address);
+ g_free (address);
+}
+
static gboolean
filter_type_func (GtkTreeModel *model, GtkTreeIter *iter, BluetoothChooserPrivate *priv)
{
@@ -759,6 +775,9 @@ create_treeview (BluetoothChooser *self)
g_object_set (tree, "show-expanders", FALSE, NULL);
+ g_signal_connect (G_OBJECT (tree), "row-activated",
+ G_CALLBACK (row_activated_cb), self);
+
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (column, _("Device"));
@@ -1163,6 +1182,22 @@ bluetooth_chooser_class_init (BluetoothChooserClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
+ /**
+ * BluetoothChooser::selected-device-activated:
+ * @chooser: a #BluetoothChooser widget which received the signal
+ * @address: the Bluetooth address for the currently selected device, or %NULL
+ *
+ * The #BluetoothChooser:selected-device-activated signal is launched when a
+ * device is double-clicked in the chooser.
+ **/
+ selection_table_signals[SELECTED_DEVICE_ACTIVATED] =
+ g_signal_new ("selected-device-activated",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BluetoothChooserClass, selected_device_activated),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
g_object_class_install_property (G_OBJECT_CLASS(klass),
PROP_TITLE, g_param_spec_string ("title",
diff --git a/lib/bluetooth-chooser.h b/lib/bluetooth-chooser.h
index 3d721ad..b89105a 100644
--- a/lib/bluetooth-chooser.h
+++ b/lib/bluetooth-chooser.h
@@ -53,6 +53,7 @@ struct _BluetoothChooserClass {
GtkVBoxClass parent_class;
void (*selected_device_changed) (BluetoothChooser *chooser, const char *address);
+ void (*selected_device_activated) (BluetoothChooser *chooser, const char *address);
};
GType bluetooth_chooser_get_type (void);
diff --git a/lib/test-deviceselection.c b/lib/test-deviceselection.c
index 00747fe..a0142fd 100644
--- a/lib/test-deviceselection.c
+++ b/lib/test-deviceselection.c
@@ -79,6 +79,14 @@ static void select_device_changed(BluetoothChooser *sel,
g_free (name);
}
+static void selected_device_activated(BluetoothChooser *sel,
+ gchar *address, gpointer user_data)
+{
+ GtkDialog *dialog = user_data;
+
+ gtk_dialog_response(dialog, GTK_RESPONSE_ACCEPT);
+}
+
static void device_selected_cb(GObject *object,
GParamSpec *spec, gpointer user_data)
{
@@ -218,6 +226,8 @@ create_wizard_dialogue (void)
G_CALLBACK(device_type_filter_selected_cb), dialog);
g_signal_connect(selector, "notify::device-category-filter",
G_CALLBACK(device_category_filter_selected_cb), dialog);
+ g_signal_connect(selector, "selected-device-activated",
+ G_CALLBACK(selected_device_activated), dialog);
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG(dialog))), selector);
bluetooth_chooser_start_discovery (BLUETOOTH_CHOOSER (selector));
@@ -254,6 +264,8 @@ create_props_dialogue (void)
G_CALLBACK(device_type_filter_selected_cb), dialog);
g_signal_connect(selector, "notify::device-category-filter",
G_CALLBACK(device_category_filter_selected_cb), dialog);
+ g_signal_connect(selector, "selected-device-activated",
+ G_CALLBACK(selected_device_activated), dialog);
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG(dialog))), selector);
g_signal_connect (G_OBJECT (dialog), "response",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]