diff options
author | Philip Langdale <philipl@overt.org> | 2018-05-16 12:50:02 -0700 |
---|---|---|
committer | Philip Langdale <philipl@overt.org> | 2018-05-19 07:26:20 -0700 |
commit | a1751d3d870c6cdc092f893755623c4ff20e1ef3 (patch) | |
tree | 9034cdd5a35be7ead6088915c242b065941ab279 /src/nautilus-application.c | |
parent | f7460fb0043db70fe82921883bf3141f1ed3bbaf (diff) | |
download | nautilus-a1751d3d870c6cdc092f893755623c4ff20e1ef3.tar.gz |
nautilus-application: Publish window->location mappings
This is a reworking of a long standing Ubuntu patch that publishes
the set of locations open in each Nautilus window. The motivation
for this change is that a desktop environment providing special
icons for things like removable devices and the trash can match
windows to those icons for highlighting purposes.
In the original incarnation, Unity provided these icons. In today's
world, I'm maintaining a set of patches for dash-to-dock/ubunut-dock
that provide these icons too.
The original implementation uses Xids to identify windows, but Xids
aren't a thing in Wayland so this mechanism is a dead end. Instead,
we can use the 'gtk application window object paths' which are
published over dbus by GtkApplications, including Nautilus.
Mutter already detects these, and makes them available on MetaWindows.
The original patch added the mapping property to the fileManager1
interface, and I have left that part as-is, but it's likely not to
be the right place to put it. fileManager1 is a generic interface
and a property that assumes a GTK behaviour doesn't seem right.
We could obviously add it to a new interface under org.gnome.Nautilus,
but this would be Nautilus specific - although there isn't a huge
scope for other file managers to implement this property, so perhaps
that's just fine.
dash-to-dock discussion is readable here:
https://github.com/micheleg/dash-to-dock/pull/677
Diffstat (limited to 'src/nautilus-application.c')
-rw-r--r-- | src/nautilus-application.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/nautilus-application.c b/src/nautilus-application.c index 9f0542288..cdf034cb3 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -1400,6 +1400,10 @@ update_dbus_opened_locations (NautilusApplication *self) gchar **locations_array; NautilusWindow *window; GFile *location; + const gchar *dbus_object_path = NULL; + + g_autoptr (GVariant) windows_to_locations = NULL; + GVariantBuilder windows_to_locations_builder; g_return_if_fail (NAUTILUS_IS_APPLICATION (self)); @@ -1412,10 +1416,22 @@ update_dbus_opened_locations (NautilusApplication *self) return; } + dbus_object_path = g_application_get_dbus_object_path (G_APPLICATION (self)); + + g_return_if_fail (dbus_object_path); + + g_variant_builder_init (&windows_to_locations_builder, G_VARIANT_TYPE ("a{sas}")); + for (l = priv->windows; l != NULL; l = l->next) { + guint32 id; + g_autofree gchar *path = NULL; + GVariantBuilder locations_in_window_builder; + window = l->data; + g_variant_builder_init (&locations_in_window_builder, G_VARIANT_TYPE ("as")); + for (sl = nautilus_window_get_slots (window); sl; sl = sl->next) { NautilusWindowSlot *slot = sl->data; @@ -1426,6 +1442,8 @@ update_dbus_opened_locations (NautilusApplication *self) gchar *uri = g_file_get_uri (location); GList *found = g_list_find_custom (locations, uri, (GCompareFunc) g_strcmp0); + g_variant_builder_add (&locations_in_window_builder, "s", uri); + if (!found) { locations = g_list_prepend (locations, uri); @@ -1437,6 +1455,11 @@ update_dbus_opened_locations (NautilusApplication *self) } } } + + id = gtk_application_window_get_id (GTK_APPLICATION_WINDOW (window)); + path = g_strdup_printf ("%s/window/%u", dbus_object_path, id); + g_variant_builder_add (&windows_to_locations_builder, "{sas}", path, &locations_in_window_builder); + g_variant_builder_clear (&locations_in_window_builder); } locations_array = g_new (gchar *, locations_size + 1); @@ -1452,6 +1475,10 @@ update_dbus_opened_locations (NautilusApplication *self) nautilus_freedesktop_dbus_set_open_locations (priv->fdb_manager, (const gchar **) locations_array); + windows_to_locations = g_variant_ref_sink (g_variant_builder_end (&windows_to_locations_builder)); + nautilus_freedesktop_dbus_set_open_windows_with_locations (priv->fdb_manager, + windows_to_locations); + g_free (locations_array); g_list_free_full (locations, g_free); } |