1
0
mirror of https://gitlab.gnome.org/GNOME/nautilus synced 2024-06-30 23:46:35 +00:00

toolbar: Update internals on location change

Instead of the window, it makes more sense to have the toolbar update
its own children. The role of the window should be only to connect
the active slot with the toolbar, then let them talk among themselves.

This makes it easier to reuse the toolbar in the upcoming FileChooser.

(While touching nautilus_toolbar_set_window_slot_real(), also remove
unused variable.)

Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3431
This commit is contained in:
António Fernandes 2024-05-12 18:34:22 +01:00
parent 02c67b8879
commit 85c44aa42b
2 changed files with 20 additions and 12 deletions

View File

@ -407,6 +407,22 @@ box_remove_all_children (GtkBox *box)
}
}
static void
on_slot_location_changed (NautilusToolbar *self)
{
g_assert (self->window_slot != NULL);
GFile *location = nautilus_window_slot_get_location (self->window_slot);
if (location == NULL)
{
return;
}
nautilus_location_entry_set_location (NAUTILUS_LOCATION_ENTRY (self->location_entry), location);
nautilus_path_bar_set_path (NAUTILUS_PATH_BAR (self->path_bar), location);
}
static void
slot_on_extensions_background_menu_changed (NautilusToolbar *self,
GParamSpec *param,
@ -438,8 +454,6 @@ static void
nautilus_toolbar_set_window_slot_real (NautilusToolbar *self,
NautilusWindowSlot *slot)
{
g_autoptr (GList) children = NULL;
self->window_slot = slot;
if (self->window_slot != NULL)
@ -448,6 +462,10 @@ nautilus_toolbar_set_window_slot_real (NautilusToolbar *self,
on_window_slot_destroyed,
self);
on_slot_location_changed (self);
g_signal_connect_swapped (self->window_slot, "notify::location",
G_CALLBACK (on_slot_location_changed), self);
g_signal_connect_swapped (self->window_slot, "notify::extensions-background-menu",
G_CALLBACK (slot_on_extensions_background_menu_changed), self);
g_signal_connect_swapped (self->window_slot, "notify::templates-menu",

View File

@ -1065,18 +1065,8 @@ nautilus_window_sync_location_widgets (NautilusWindow *window)
location = nautilus_window_slot_get_location (slot);
/* Change the location bar and path bar to match the current location. */
if (location != NULL)
{
GtkWidget *location_entry;
GtkWidget *path_bar;
location_entry = nautilus_toolbar_get_location_entry (NAUTILUS_TOOLBAR (window->toolbar));
nautilus_location_entry_set_location (NAUTILUS_LOCATION_ENTRY (location_entry), location);
path_bar = nautilus_toolbar_get_path_bar (NAUTILUS_TOOLBAR (window->toolbar));
nautilus_path_bar_set_path (NAUTILUS_PATH_BAR (path_bar), location);
gtk_widget_set_visible (window->network_address_bar,
g_file_has_uri_scheme (location, SCHEME_NETWORK_VIEW));
}