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

window: Bind title to expression

We rely on the slots calling sync_title() on the window, which is
wasteful (if the slot is not active), fragile, and a layer violation.

We already have properties for all of these pieces, so let's use
expressions. This also helps with preparation for FileChooser window,
as we need NautilusWindowSlot to stop calling NautilusWindow method,
as part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
This commit is contained in:
António Fernandes 2024-04-27 23:01:33 +01:00
parent 30194a1fdc
commit 22d214e818
4 changed files with 6 additions and 23 deletions

View File

@ -2999,10 +2999,7 @@ nautilus_window_slot_set_window (NautilusWindowSlot *self,
void
nautilus_window_slot_update_title (NautilusWindowSlot *self)
{
NautilusWindow *window;
g_autofree char *title = NULL;
title = nautilus_compute_title_for_location (self->location);
window = nautilus_window_slot_get_window (self);
g_autofree char *title = nautilus_compute_title_for_location (self->location);
if (g_strcmp0 (title, self->title) != 0)
{
@ -3010,8 +3007,6 @@ nautilus_window_slot_update_title (NautilusWindowSlot *self)
self->title = g_steal_pointer (&title);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
nautilus_window_sync_title (window, self);
}
}
@ -3238,7 +3233,6 @@ nautilus_window_slot_set_active (NautilusWindowSlot *self,
/* sync window to new slot */
nautilus_window_sync_allow_stop (window, self);
nautilus_window_sync_title (window, self);
nautilus_window_sync_location_widgets (window);
nautilus_window_slot_sync_actions (self);

View File

@ -2073,19 +2073,6 @@ nautilus_window_key_bubble (GtkEventControllerKey *controller,
return GDK_EVENT_PROPAGATE;
}
void
nautilus_window_sync_title (NautilusWindow *window,
NautilusWindowSlot *slot)
{
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot));
if (slot == nautilus_window_get_active_slot (window))
{
gtk_window_set_title (GTK_WINDOW (window), nautilus_window_slot_get_title (slot));
}
}
#ifdef GDK_WINDOWING_WAYLAND
typedef struct
{

View File

@ -92,8 +92,6 @@ void nautilus_window_show_about_dialog (NautilusWindow *window);
*/
void nautilus_window_sync_allow_stop (NautilusWindow *window,
NautilusWindowSlot *slot);
void nautilus_window_sync_title (NautilusWindow *window,
NautilusWindowSlot *slot);
void nautilus_window_show_operation_notification (NautilusWindow *window,
gchar *main_label,

View File

@ -102,7 +102,11 @@
<property name="width-request">360</property>
<property name="height-request">380</property>
<property name="show-menubar">False</property>
<property name="title" translatable="yes">_Files</property>
<binding name="title">
<lookup name="title">
<lookup name="active-slot">NautilusWindow</lookup>
</lookup>
</binding>
<signal name="direction-changed" handler="window_set_back_forward_accelerators"/>
<style>
<class name="view"/>