mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-29 20:44:17 +00:00
placessidebar: Get location directly from slot
Instead of having NautilusWindow relay the change, have the sidebar talking directly with the window slot. This prepares the sidebar to be reused in the upcoming FileChooser dialog which is not going to be a NautilusWindow. Part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3431
This commit is contained in:
parent
ccf81c1b0d
commit
d4a066da31
|
@ -45,6 +45,7 @@
|
|||
#include "nautilus-properties-window.h"
|
||||
#include "nautilus-scheme.h"
|
||||
#include "nautilus-trash-monitor.h"
|
||||
#include "nautilus-window-slot.h"
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/x11/gdkx.h>
|
||||
|
@ -106,6 +107,9 @@ typedef enum {
|
|||
struct _NautilusGtkPlacesSidebar {
|
||||
GtkWidget parent;
|
||||
|
||||
NautilusWindowSlot *window_slot;
|
||||
GSignalGroup *slot_signal_group;
|
||||
|
||||
GtkWidget *swin;
|
||||
GtkWidget *list_box;
|
||||
GtkWidget *new_bookmark_row;
|
||||
|
@ -199,6 +203,7 @@ enum {
|
|||
enum {
|
||||
PROP_LOCATION = 1,
|
||||
PROP_OPEN_FLAGS,
|
||||
PROP_WINDOW_SLOT,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
|
@ -3371,6 +3376,20 @@ shell_shows_desktop_changed (GtkSettings *settings,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_location (NautilusGtkPlacesSidebar *self)
|
||||
{
|
||||
GFile *location = NULL;
|
||||
|
||||
if (self->window_slot != NULL &&
|
||||
!nautilus_window_slot_get_search_global (self->window_slot))
|
||||
{
|
||||
location = nautilus_window_slot_get_location (self->window_slot);
|
||||
}
|
||||
|
||||
nautilus_gtk_places_sidebar_set_location (self, location);
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_gtk_places_sidebar_init (NautilusGtkPlacesSidebar *sidebar)
|
||||
{
|
||||
|
@ -3383,6 +3402,14 @@ nautilus_gtk_places_sidebar_init (NautilusGtkPlacesSidebar *sidebar)
|
|||
|
||||
create_volume_monitor (sidebar);
|
||||
|
||||
sidebar->slot_signal_group = g_signal_group_new (NAUTILUS_TYPE_WINDOW_SLOT);
|
||||
g_signal_group_connect_object (sidebar->slot_signal_group, "notify::location",
|
||||
G_CALLBACK (update_location), sidebar,
|
||||
G_CONNECT_SWAPPED);
|
||||
g_signal_group_connect_object (sidebar->slot_signal_group, "notify::search-global",
|
||||
G_CALLBACK (update_location), sidebar,
|
||||
G_CONNECT_SWAPPED);
|
||||
|
||||
sidebar->open_flags = NAUTILUS_GTK_PLACES_OPEN_NORMAL;
|
||||
|
||||
NautilusApplication *app = NAUTILUS_APPLICATION (g_application_get_default ());
|
||||
|
@ -3504,6 +3531,14 @@ nautilus_gtk_places_sidebar_set_property (GObject *obj,
|
|||
nautilus_gtk_places_sidebar_set_open_flags (sidebar, g_value_get_flags (value));
|
||||
break;
|
||||
|
||||
case PROP_WINDOW_SLOT:
|
||||
if (g_set_object (&sidebar->window_slot, g_value_get_object (value)))
|
||||
{
|
||||
g_signal_group_set_target (sidebar->slot_signal_group, sidebar->window_slot);
|
||||
update_location (sidebar);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
|
||||
break;
|
||||
|
@ -3544,6 +3579,9 @@ nautilus_gtk_places_sidebar_dispose (GObject *object)
|
|||
|
||||
sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (object);
|
||||
|
||||
g_clear_object (&sidebar->window_slot);
|
||||
g_clear_object (&sidebar->slot_signal_group);
|
||||
|
||||
if (sidebar->cancellable)
|
||||
{
|
||||
g_cancellable_cancel (sidebar->cancellable);
|
||||
|
@ -3862,6 +3900,10 @@ nautilus_gtk_places_sidebar_class_init (NautilusGtkPlacesSidebarClass *class)
|
|||
NAUTILUS_TYPE_OPEN_FLAGS,
|
||||
NAUTILUS_GTK_PLACES_OPEN_NORMAL,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
|
||||
properties[PROP_WINDOW_SLOT] =
|
||||
g_param_spec_object ("window-slot", NULL, NULL,
|
||||
NAUTILUS_TYPE_WINDOW_SLOT,
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties);
|
||||
|
||||
|
|
|
@ -402,8 +402,6 @@ static void
|
|||
on_location_changed (NautilusWindow *window)
|
||||
{
|
||||
nautilus_window_sync_location_widgets (window);
|
||||
nautilus_gtk_places_sidebar_set_location (NAUTILUS_GTK_PLACES_SIDEBAR (window->places_sidebar),
|
||||
nautilus_window_slot_get_location (nautilus_window_get_active_slot (window)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -417,28 +415,6 @@ on_slot_location_changed (NautilusWindowSlot *slot,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_slot_search_global_changed (NautilusWindowSlot *slot,
|
||||
GParamSpec *pspec,
|
||||
NautilusWindow *self)
|
||||
{
|
||||
NautilusGtkPlacesSidebar *sidebar = NAUTILUS_GTK_PLACES_SIDEBAR (self->places_sidebar);
|
||||
|
||||
if (nautilus_window_get_active_slot (self) != slot)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (nautilus_window_slot_get_search_global (slot))
|
||||
{
|
||||
nautilus_gtk_places_sidebar_set_location (sidebar, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
nautilus_gtk_places_sidebar_set_location (sidebar, nautilus_window_slot_get_location (slot));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tab_view_setup_menu_cb (AdwTabView *tab_view,
|
||||
AdwTabPage *page,
|
||||
|
@ -503,8 +479,6 @@ connect_slot (NautilusWindow *window,
|
|||
G_CALLBACK (update_cursor), window);
|
||||
g_signal_connect (slot, "notify::location",
|
||||
G_CALLBACK (on_slot_location_changed), window);
|
||||
g_signal_connect (slot, "notify::search-global",
|
||||
G_CALLBACK (on_slot_search_global_changed), window);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -188,6 +188,7 @@
|
|||
<property name="content">
|
||||
<object class="NautilusGtkPlacesSidebar" id="places_sidebar">
|
||||
<property name="vexpand">True</property>
|
||||
<property name="window-slot" bind-source="NautilusWindow" bind-property="active-slot" bind-flags="sync-create"/>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
|
|
Loading…
Reference in a new issue