[nautilus/wip/antoniof/make-window-slot-final: 1/3] window-slot: Make back_or_forward() a slot method
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/make-window-slot-final: 1/3] window-slot: Make back_or_forward() a slot method
- Date: Thu, 8 Jul 2021 19:45:30 +0000 (UTC)
commit ba93a0d9cbf438c6e5e52d82a90208d359286eee
Author: António Fernandes <antoniof gnome org>
Date: Wed Jan 13 13:31:05 2021 +0000
window-slot: Make back_or_forward() a slot method
We define a NautilusWindow method in nauitlus-window-slot.c. That's
just wrong.
Also, there is no reason for this to be a NautilusWindow method,
rather than a slot one.
The only consumers are NautilusWindow and NautilusToolbar, and both
have a pointer to the current slot, so let's make this a slot method.
For convenience, also add a private NautilusWindow wrapper method.
src/nautilus-toolbar.c | 12 ++++++------
src/nautilus-window-slot.c | 8 +++-----
src/nautilus-window-slot.h | 4 ++++
src/nautilus-window.c | 18 ++++++++++++++++++
src/nautilus-window.h | 3 ---
5 files changed, 31 insertions(+), 14 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 42de3efc5..995f868b7 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -159,9 +159,9 @@ toolbar_update_appearance (NautilusToolbar *self)
}
static void
-activate_back_or_forward_menu_item (GtkMenuItem *menu_item,
- NautilusWindow *window,
- gboolean back)
+activate_back_or_forward_menu_item (GtkMenuItem *menu_item,
+ NautilusWindowSlot *window_slot,
+ gboolean back)
{
int index;
@@ -169,21 +169,21 @@ activate_back_or_forward_menu_item (GtkMenuItem *menu_item,
index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "user_data"));
- nautilus_window_back_or_forward (window, back, index);
+ nautilus_window_slot_back_or_forward (window_slot, back, index);
}
static void
activate_back_menu_item_callback (GtkMenuItem *menu_item,
NautilusToolbar *self)
{
- activate_back_or_forward_menu_item (menu_item, self->window, TRUE);
+ activate_back_or_forward_menu_item (menu_item, self->window_slot, TRUE);
}
static void
activate_forward_menu_item_callback (GtkMenuItem *menu_item,
NautilusToolbar *self)
{
- activate_back_or_forward_menu_item (menu_item, self->window, FALSE);
+ activate_back_or_forward_menu_item (menu_item, self->window_slot, FALSE);
}
static void
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 15c040c19..2113a3d3e 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -2150,11 +2150,10 @@ nautilus_window_slot_set_content_view (NautilusWindowSlot *self,
}
void
-nautilus_window_back_or_forward (NautilusWindow *window,
- gboolean back,
- guint distance)
+nautilus_window_slot_back_or_forward (NautilusWindowSlot *self,
+ gboolean back,
+ guint distance)
{
- NautilusWindowSlot *self;
GList *list;
guint len;
NautilusBookmark *bookmark;
@@ -2162,7 +2161,6 @@ nautilus_window_back_or_forward (NautilusWindow *window,
GFile *old_location;
g_autofree char *scroll_pos = NULL;
- self = nautilus_window_get_active_slot (window);
list = back ? self->back_list : self->forward_list;
len = g_list_length (list);
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index b41545c66..268578789 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -111,4 +111,8 @@ NautilusQueryEditor *nautilus_window_slot_get_query_editor (NautilusWindowSlot *
/* Only used by slot-dnd */
NautilusView* nautilus_window_slot_get_current_view (NautilusWindowSlot *slot);
+void nautilus_window_slot_back_or_forward (NautilusWindowSlot *slot,
+ gboolean back,
+ guint distance);
+
void free_navigation_state (gpointer data);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index df3c8d109..c3245a752 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -80,6 +80,9 @@ static void mouse_forward_button_changed (gpointer callback_data);
static void use_extra_mouse_buttons_changed (gpointer callback_data);
static void nautilus_window_initialize_actions (NautilusWindow *window);
static GtkWidget *nautilus_window_ensure_location_entry (NautilusWindow *window);
+static void nautilus_window_back_or_forward (NautilusWindow *window,
+ gboolean back,
+ guint distance);
/* 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
@@ -2610,6 +2613,21 @@ nautilus_window_delete_event (GtkWidget *widget,
return FALSE;
}
+static void
+nautilus_window_back_or_forward (NautilusWindow *window,
+ gboolean back,
+ guint distance)
+{
+ NautilusWindowSlot *slot;
+
+ slot = nautilus_window_get_active_slot (window);
+
+ if (slot != NULL)
+ {
+ nautilus_window_slot_back_or_forward (slot, back, distance);
+ }
+}
+
static void
on_multi_press_gesture_pressed (GtkGestureMultiPress *gesture,
gint n_press,
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 27dd89f9d..cd967bd3a 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -77,9 +77,6 @@ void nautilus_window_sync_location_widgets (NautilusWindow *wind
void nautilus_window_hide_sidebar (NautilusWindow *window);
void nautilus_window_show_sidebar (NautilusWindow *window);
-void nautilus_window_back_or_forward (NautilusWindow *window,
- gboolean back,
- guint distance);
void nautilus_window_reset_menus (NautilusWindow *window);
GtkWidget * nautilus_window_get_notebook (NautilusWindow *window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]