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

window-slot: Don't manually sync allow-stop

We do so in two cases: active slot change, or :allow-stop change.

Have the window handle both cases: it is the one who changes active
slot already, and listening to NautilusWindowSlot:allow-stop changes
is trivial.

This resolves a layer violation and is one fewer NautilusWindow
method being called by NautilusWindowSlot, preparing the later for
reuse in the FileChooser portal dialog window.

Part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
This commit is contained in:
António Fernandes 2024-04-28 00:33:02 +01:00
parent 0f52276179
commit 13e0bba7ff
3 changed files with 11 additions and 21 deletions

View File

@ -3021,7 +3021,6 @@ nautilus_window_slot_set_allow_stop (NautilusWindowSlot *self,
self->allow_stop = allow;
window = nautilus_window_slot_get_window (self);
nautilus_window_sync_allow_stop (window, self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ALLOW_STOP]);
}
@ -3227,7 +3226,6 @@ nautilus_window_slot_set_active (NautilusWindowSlot *self,
window = self->window;
/* sync window to new slot */
nautilus_window_sync_allow_stop (window, self);
nautilus_window_slot_sync_actions (self);
gtk_widget_insert_action_group (GTK_WIDGET (window), "slot", self->slot_action_group);

View File

@ -82,6 +82,7 @@ static void nautilus_window_back_or_forward (NautilusWindow *window,
gboolean back,
guint distance);
static void nautilus_window_sync_location_widgets (NautilusWindow *window);
static void nautilus_window_sync_allow_stop (NautilusWindow *window);
/* Sanity check: highest mouse button value I could find was 14. 5 is our
* lower threshold (well-documented to be the one of the button events for the
@ -613,6 +614,8 @@ static void
connect_slot (NautilusWindow *window,
NautilusWindowSlot *slot)
{
g_signal_connect_swapped (slot, "notify::allow-stop",
G_CALLBACK (nautilus_window_sync_allow_stop), window);
g_signal_connect (slot, "notify::location",
G_CALLBACK (on_slot_location_changed), window);
g_signal_connect (slot, "notify::search-global",
@ -860,13 +863,13 @@ update_cursor (NautilusWindow *window)
}
}
void
nautilus_window_sync_allow_stop (NautilusWindow *window,
NautilusWindowSlot *slot)
static void
nautilus_window_sync_allow_stop (NautilusWindow *window)
{
NautilusWindowSlot *slot = nautilus_window_get_active_slot (window);
GAction *stop_action;
GAction *reload_action;
gboolean allow_stop, slot_is_active, slot_allow_stop;
gboolean allow_stop, slot_allow_stop;
stop_action = g_action_map_lookup_action (G_ACTION_MAP (window),
"stop");
@ -875,17 +878,11 @@ nautilus_window_sync_allow_stop (NautilusWindow *window,
allow_stop = g_action_get_enabled (stop_action);
slot_allow_stop = nautilus_window_slot_get_allow_stop (slot);
slot_is_active = (slot == nautilus_window_get_active_slot (window));
if (!slot_is_active ||
allow_stop != slot_allow_stop)
if (allow_stop != slot_allow_stop)
{
if (slot_is_active)
{
g_simple_action_set_enabled (G_SIMPLE_ACTION (stop_action), slot_allow_stop);
g_simple_action_set_enabled (G_SIMPLE_ACTION (reload_action), !slot_allow_stop);
}
g_simple_action_set_enabled (G_SIMPLE_ACTION (stop_action), slot_allow_stop);
g_simple_action_set_enabled (G_SIMPLE_ACTION (reload_action), !slot_allow_stop);
if (gtk_widget_get_realized (GTK_WIDGET (window)))
{
update_cursor (window);
@ -2008,6 +2005,7 @@ nautilus_window_set_active_slot (NautilusWindow *window,
nautilus_window_slot_set_active (new_slot, TRUE);
on_location_changed (window);
nautilus_window_sync_allow_stop (window);
}
g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_ACTIVE_SLOT]);

View File

@ -83,12 +83,6 @@ void nautilus_window_slot_close (NautilusWindow *wind
void nautilus_window_show_about_dialog (NautilusWindow *window);
/* sync window GUI with current slot. Used when changing slots,
* and when updating the slot state.
*/
void nautilus_window_sync_allow_stop (NautilusWindow *window,
NautilusWindowSlot *slot);
void nautilus_window_show_operation_notification (NautilusWindow *window,
gchar *main_label,
GFile *folder_to_open,