summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2012-01-18 14:05:17 +0000
committerBastien Nocera <hadess@hadess.net>2012-01-18 14:12:11 +0000
commit2f593300e22a295d8f6bf2c9670d4fbaa77ddfa2 (patch)
treebf5c1cdad6b111899c3624025721b480152ca278
parent2c99c578feffb464237a4b2e55c465bde9df6a53 (diff)
downloadgnome-bluetooth-2f593300e22a295d8f6bf2c9670d4fbaa77ddfa2.tar.gz
applet: Fix new pairings not appearing in menus
As documented now, the GtkTreeModelFilter that we use to filter per-adapter devices lacks the ability to tell us about row-changed signals (amongst others). So just monitor those signals on the child-model of the filtered model, and check whether those rows are in our view to trigger the "devices-changed" signal. https://bugzilla.gnome.org/show_bug.cgi?id=666127 Conflicts: applet/bluetooth-applet.c
-rw-r--r--applet/bluetooth-applet.c62
1 files changed, 44 insertions, 18 deletions
diff --git a/applet/bluetooth-applet.c b/applet/bluetooth-applet.c
index a0c24e6c..0457d522 100644
--- a/applet/bluetooth-applet.c
+++ b/applet/bluetooth-applet.c
@@ -460,22 +460,40 @@ cancel_request(DBusGMethodInvocation *context,
}
static void
-device_added_or_changed (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+device_added_or_changed (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *child_iter,
+ BluetoothApplet *self)
{
- BluetoothApplet *self = BLUETOOTH_APPLET (data);
+ GtkTreeIter iter;
+ /* The line that changed isn't in the filtered view */
+ if (gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (self->device_model),
+ &iter,
+ child_iter) == FALSE)
+ return;
g_signal_emit (self, signals[SIGNAL_DEVICES_CHANGED], 0);
}
static void
-device_removed (GtkTreeModel *model,
- GtkTreePath *path,
- gpointer user_data)
+device_removed (GtkTreeModel *model,
+ GtkTreePath *path,
+ BluetoothApplet *self)
{
- device_added_or_changed (model, path, NULL, user_data);
+ /* We cannot check whether the row still exists, because
+ * it's already gone */
+ g_signal_emit (self, signals[SIGNAL_DEVICES_CHANGED], 0);
+}
+
+static GtkTreeModel *
+get_child_model (GtkTreeModel *model)
+{
+ GtkTreeModel *child_model;
+
+ if (model == NULL)
+ return NULL;
+ g_object_get (model, "child-model", &child_model, NULL);
+ return child_model;
}
static void
@@ -484,28 +502,36 @@ default_adapter_changed (GObject *client,
gpointer data)
{
BluetoothApplet* self = BLUETOOTH_APPLET (data);
+ GtkTreeModel *child_model;
if (self->default_adapter)
g_object_unref (self->default_adapter);
self->default_adapter = bluetooth_client_get_default_adapter (self->client);
- if (self->device_model) {
- g_signal_handler_disconnect (self->device_model, self->signal_row_added);
- g_signal_handler_disconnect (self->device_model, self->signal_row_changed);
- g_signal_handler_disconnect (self->device_model, self->signal_row_deleted);
- g_object_unref (self->device_model);
+ /* The old model */
+ child_model = get_child_model (self->device_model);
+ if (child_model) {
+ g_signal_handler_disconnect (child_model, self->signal_row_added);
+ g_signal_handler_disconnect (child_model, self->signal_row_changed);
+ g_signal_handler_disconnect (child_model, self->signal_row_deleted);
+ g_object_unref (child_model);
}
+ if (self->device_model)
+ g_object_unref (self->device_model);
+
+ /* The new model */
if (self->default_adapter)
self->device_model = bluetooth_client_get_device_model (self->client, self->default_adapter);
else
self->device_model = NULL;
- if (self->device_model) {
- self->signal_row_added = g_signal_connect (self->device_model, "row-inserted",
+ child_model = get_child_model (self->device_model);
+ if (child_model) {
+ self->signal_row_added = g_signal_connect (child_model, "row-inserted",
G_CALLBACK(device_added_or_changed), self);
- self->signal_row_deleted = g_signal_connect (self->device_model, "row-deleted",
+ self->signal_row_deleted = g_signal_connect (child_model, "row-deleted",
G_CALLBACK(device_removed), self);
- self->signal_row_changed = g_signal_connect (self->device_model, "row-changed",
+ self->signal_row_changed = g_signal_connect (child_model, "row-changed",
G_CALLBACK (device_added_or_changed), self);
}