summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kellner <christian@kellner.me>2019-02-01 18:05:18 +0100
committerChristian Kellner <christian@kellner.me>2019-02-04 14:30:42 +0100
commit2932243db138d710d11d25b62ad4ed619cd8cc79 (patch)
treefa1c3e2509eed2d19ed8fa787640913057778387
parent077f16912980a39fc0cb91e69fe4a664ee48a52e (diff)
downloadgnome-control-center-2932243db138d710d11d25b62ad4ed619cd8cc79.tar.gz
thunderbolt: show parent devices in device dialog
Collect all the parent of a given device and pass that to the device dialog, so we can show and potentially authorize/enroll all the parent devices too.
-rw-r--r--panels/thunderbolt/cc-bolt-panel.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/panels/thunderbolt/cc-bolt-panel.c b/panels/thunderbolt/cc-bolt-panel.c
index 0db263943..dfc82bd4a 100644
--- a/panels/thunderbolt/cc-bolt-panel.c
+++ b/panels/thunderbolt/cc-bolt-panel.c
@@ -29,6 +29,7 @@
#include "cc-bolt-device-entry.h"
#include "bolt-client.h"
+#include "bolt-names.h"
#include "bolt-str.h"
#include "cc-bolt-panel.h"
@@ -657,8 +658,11 @@ static void
on_device_entry_row_activated_cb (CcBoltPanel *panel,
GtkListBoxRow *row)
{
+ g_autoptr(GPtrArray) parents = NULL;
CcBoltDeviceEntry *entry;
BoltDevice *device;
+ BoltDevice *iter;
+ const char *parent;
if (!CC_IS_BOLT_DEVICE_ENTRY (row))
return;
@@ -666,7 +670,35 @@ on_device_entry_row_activated_cb (CcBoltPanel *panel,
entry = CC_BOLT_DEVICE_ENTRY (row);
device = cc_bolt_device_entry_get_device (entry);
- cc_bolt_device_dialog_set_device (panel->device_dialog, device, NULL);
+ /* walk up the chain and collect all parents */
+ parents = g_ptr_array_new_with_free_func (g_object_unref);
+ iter = device;
+
+ parent = bolt_device_get_parent (iter);
+ while (parent != NULL)
+ {
+ g_autofree char *path = NULL;
+ CcBoltDeviceEntry *child;
+ BoltDevice *dev;
+
+ path = bolt_gen_object_path (BOLT_DBUS_PATH_DEVICES, parent);
+
+ /* NB: the host device is not a peripheral and thus not
+ * in the hash table; therefore when get a NULL back, we
+ * should have reached the end of the chain */
+ child = g_hash_table_lookup (panel->devices, path);
+ if (!child)
+ break;
+
+ dev = cc_bolt_device_entry_get_device (child);
+ g_ptr_array_add (parents, g_object_ref (dev));
+ iter = dev;
+
+ parent = bolt_device_get_parent (iter);
+ }
+
+ cc_bolt_device_dialog_set_device (panel->device_dialog, device, parents);
+
gtk_window_resize (GTK_WINDOW (panel->device_dialog), 1, 1);
gtk_widget_show (GTK_WIDGET (panel->device_dialog));
}