[gtk/file-chooser-api-cleanups: 32/34] filechooser: Add a readonly :filters property
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/file-chooser-api-cleanups: 32/34] filechooser: Add a readonly :filters property
- Date: Mon, 6 Jul 2020 15:04:58 +0000 (UTC)
commit ea07a9236633ef055e66c742b115b546bcf30d68
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jul 6 10:34:33 2020 -0400
filechooser: Add a readonly :filters property
This makes the filters list accessible in the
the inspector.
gtk/gtkfilechooser.c | 16 ++++++++++++++++
gtk/gtkfilechooserbutton.c | 1 +
gtk/gtkfilechooserutils.c | 19 +++++++++++--------
gtk/gtkfilechooserutils.h | 3 ++-
gtk/gtkfilechooserwidget.c | 8 ++++++++
5 files changed, 38 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkfilechooser.c b/gtk/gtkfilechooser.c
index 93dbf91549..0ce214feec 100644
--- a/gtk/gtkfilechooser.c
+++ b/gtk/gtkfilechooser.c
@@ -168,6 +168,22 @@ gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
FALSE,
GTK_PARAM_READWRITE));
+ /**
+ * GtkFileChooser:filters:
+ *
+ * A #GListModel containing the filters that have been
+ * added with gtk_file_chooser_add_filter().
+ *
+ * The returned object should not be modified. It may
+ * or may not be updated for later changes.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_object ("filters",
+ P_("Filters"),
+ P_("List model of filters"),
+ G_TYPE_LIST_MODEL,
+ GTK_PARAM_READABLE));
+
/**
* GtkFileChooser:create-folders:
*
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index 575079b8da..b735699a75 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -1035,6 +1035,7 @@ gtk_file_chooser_button_get_property (GObject *object,
case GTK_FILE_CHOOSER_PROP_FILTER:
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
+ case GTK_FILE_CHOOSER_PROP_FILTERS:
g_object_get_property (G_OBJECT (button->chooser), pspec->name, value);
break;
diff --git a/gtk/gtkfilechooserutils.c b/gtk/gtkfilechooserutils.c
index 71713a49ff..91da4cfd36 100644
--- a/gtk/gtkfilechooserutils.c
+++ b/gtk/gtkfilechooserutils.c
@@ -92,17 +92,20 @@ void
_gtk_file_chooser_install_properties (GObjectClass *klass)
{
g_object_class_override_property (klass,
- GTK_FILE_CHOOSER_PROP_ACTION,
- "action");
+ GTK_FILE_CHOOSER_PROP_ACTION,
+ "action");
g_object_class_override_property (klass,
- GTK_FILE_CHOOSER_PROP_FILTER,
- "filter");
+ GTK_FILE_CHOOSER_PROP_FILTER,
+ "filter");
g_object_class_override_property (klass,
- GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE,
- "select-multiple");
+ GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE,
+ "select-multiple");
g_object_class_override_property (klass,
- GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS,
- "create-folders");
+ GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS,
+ "create-folders");
+ g_object_class_override_property (klass,
+ GTK_FILE_CHOOSER_PROP_FILTERS,
+ "filters");
}
/**
diff --git a/gtk/gtkfilechooserutils.h b/gtk/gtkfilechooserutils.h
index 96f6658d6f..5c5494a0ce 100644
--- a/gtk/gtkfilechooserutils.h
+++ b/gtk/gtkfilechooserutils.h
@@ -32,7 +32,8 @@ typedef enum {
GTK_FILE_CHOOSER_PROP_FILTER,
GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE,
GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS,
- GTK_FILE_CHOOSER_PROP_LAST = GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS
+ GTK_FILE_CHOOSER_PROP_FILTERS,
+ GTK_FILE_CHOOSER_PROP_LAST = GTK_FILE_CHOOSER_PROP_FILTERS
} GtkFileChooserProp;
void _gtk_file_chooser_install_properties (GObjectClass *klass);
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 1c2d2619ed..48991021a8 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -3072,6 +3072,10 @@ gtk_file_chooser_widget_get_property (GObject *object,
g_value_set_boolean (value, impl->create_folders);
break;
+ case GTK_FILE_CHOOSER_PROP_FILTERS:
+ g_value_set_object (value, impl->filters);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -5564,6 +5568,8 @@ gtk_file_chooser_widget_add_filter (GtkFileChooser *chooser,
set_current_filter (impl, filter);
show_filters (impl, TRUE);
+
+ g_object_notify (G_OBJECT (chooser), "filters");
}
static void
@@ -5597,6 +5603,8 @@ gtk_file_chooser_widget_remove_filter (GtkFileChooser *chooser,
if (!impl->filters)
show_filters (impl, FALSE);
+
+ g_object_notify (G_OBJECT (chooser), "filters");
}
static GListModel *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]