diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-07-06 10:34:33 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-07-06 11:03:48 -0400 |
commit | ea07a9236633ef055e66c742b115b546bcf30d68 (patch) | |
tree | 4a0ae4d34529ba69767b67fb5728b1f3dbc24b65 | |
parent | 76290e8ddb7001165e9f245730346de84e773058 (diff) | |
download | gtk+-ea07a9236633ef055e66c742b115b546bcf30d68.tar.gz |
filechooser: Add a readonly :filters property
This makes the filters list accessible in the
the inspector.
-rw-r--r-- | gtk/gtkfilechooser.c | 16 | ||||
-rw-r--r-- | gtk/gtkfilechooserbutton.c | 1 | ||||
-rw-r--r-- | gtk/gtkfilechooserutils.c | 19 | ||||
-rw-r--r-- | gtk/gtkfilechooserutils.h | 3 | ||||
-rw-r--r-- | 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 @@ -169,6 +169,22 @@ gtk_file_chooser_default_init (GtkFileChooserInterface *iface) 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: * * Whether a file chooser not in %GTK_FILE_CHOOSER_ACTION_OPEN mode 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 * |