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

window-slot: Introduce :filter property

This will allow the FileChooser window to indirectly set the filter
on the view model, through an internal binding.
This commit is contained in:
António Fernandes 2024-06-22 21:48:05 +01:00
parent 9d3813bf07
commit b60be36d01
3 changed files with 48 additions and 0 deletions

View File

@ -9572,6 +9572,9 @@ nautilus_files_view_constructed (GObject *object)
g_signal_connect_object (GTK_SELECTION_MODEL (priv->model), "selection-changed",
G_CALLBACK (nautilus_files_view_notify_selection_changed), self,
G_CONNECT_SWAPPED);
g_object_bind_property (priv->slot, "filter",
priv->model, "filter",
G_BINDING_SYNC_CREATE);
}
static void

View File

@ -56,6 +56,7 @@ enum
PROP_ICON_NAME,
PROP_TOOLBAR_MENU_SECTIONS,
PROP_EXTENSIONS_BACKGROUND_MENU,
PROP_FILTER,
PROP_TEMPLATES_MENU,
PROP_LOADING,
PROP_SEARCH_VISIBLE,
@ -93,6 +94,8 @@ struct _NautilusWindowSlot
GtkWidget *extra_location_widgets;
GtkFilter *filter;
/* Slot actions */
GActionGroup *slot_action_group;
GtkShortcutController *shortcuts;
@ -702,6 +705,12 @@ nautilus_window_slot_set_property (GObject *object,
}
break;
case PROP_FILTER:
{
nautilus_window_slot_set_filter (self, g_value_get_object (value));
}
break;
case PROP_LOCATION:
{
nautilus_window_slot_set_location (self, g_value_get_object (value));
@ -787,6 +796,12 @@ nautilus_window_slot_get_property (GObject *object,
}
break;
case PROP_FILTER:
{
g_value_set_object (value, nautilus_window_slot_get_filter (self));
}
break;
case PROP_MODE:
{
g_value_set_enum (value, nautilus_window_slot_get_mode (self));
@ -3061,6 +3076,11 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
FALSE,
G_PARAM_READABLE);
properties[PROP_FILTER] =
g_param_spec_object ("filter", NULL, NULL,
GTK_TYPE_FILTER,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
properties[PROP_MODE] =
g_param_spec_enum ("mode", NULL, NULL,
NAUTILUS_TYPE_MODE, NAUTILUS_MODE_BROWSE,
@ -3460,6 +3480,28 @@ nautilus_window_slot_get_mode (NautilusWindowSlot *self)
return self->mode;
}
GtkFilter *
nautilus_window_slot_get_filter (NautilusWindowSlot *self)
{
g_return_val_if_fail (NAUTILUS_IS_WINDOW_SLOT (self), NULL);
return self->filter;
}
void
nautilus_window_slot_set_filter (NautilusWindowSlot *self,
GtkFilter *filter)
{
g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (self));
if (!g_set_object (&self->filter, filter))
{
return;
}
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FILTER]);
}
gboolean
nautilus_window_slot_get_loading (NautilusWindowSlot *self)
{

View File

@ -54,6 +54,9 @@ void nautilus_window_slot_open_location_full (NautilusWindowSlot *
NautilusOpenFlags flags,
GList *new_selection);
GtkFilter *nautilus_window_slot_get_filter (NautilusWindowSlot *slot);
void nautilus_window_slot_set_filter (NautilusWindowSlot *slot,
GtkFilter *filter);
NautilusMode nautilus_window_slot_get_mode (NautilusWindowSlot *slot);
GFile * nautilus_window_slot_get_location (NautilusWindowSlot *slot);
GFile * nautilus_window_slot_get_pending_location (NautilusWindowSlot *slot);