[gtk/file-filter2: 1/4] filefilter: Convert to a GtkFilter
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/file-filter2: 1/4] filefilter: Convert to a GtkFilter
- Date: Sun, 5 Jul 2020 16:52:57 +0000 (UTC)
commit 885da9eff6634b2ddef1d8c32866262e260090bd
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jul 4 10:57:07 2020 -0400
filefilter: Convert to a GtkFilter
Make GtkFileFilter implement GtkFilter.
gtk/gtkfilefilter.c | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkfilefilter.c b/gtk/gtkfilefilter.c
index 7f2560f477..aefec4f6c2 100644
--- a/gtk/gtkfilefilter.c
+++ b/gtk/gtkfilefilter.c
@@ -91,12 +91,12 @@ typedef enum {
struct _GtkFileFilterClass
{
- GObjectClass parent_class;
+ GtkFilterClass parent_class;
};
struct _GtkFileFilter
{
- GObject parent_instance;
+ GtkFilter parent_instance;
gchar *name;
GSList *rules;
@@ -157,8 +157,12 @@ static void gtk_file_filter_buildable_custom_tag_end (GtkBuildable
const gchar *tagname,
gpointer data);
+static gboolean gtk_file_filter_match (GtkFilter *filter,
+ gpointer item);
+static GtkFilterMatch gtk_file_filter_get_strictness (GtkFilter *filter);
-G_DEFINE_TYPE_WITH_CODE (GtkFileFilter, gtk_file_filter, G_TYPE_OBJECT,
+
+G_DEFINE_TYPE_WITH_CODE (GtkFileFilter, gtk_file_filter, GTK_TYPE_FILTER,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_file_filter_buildable_init))
@@ -171,11 +175,15 @@ static void
gtk_file_filter_class_init (GtkFileFilterClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ GtkFilterClass *filter_class = GTK_FILTER_CLASS (class);
gobject_class->set_property = gtk_file_filter_set_property;
gobject_class->get_property = gtk_file_filter_get_property;
gobject_class->finalize = gtk_file_filter_finalize;
+ filter_class->get_strictness = gtk_file_filter_get_strictness;
+ filter_class->match = gtk_file_filter_match;
+
/**
* GtkFileFilter:name:
*
@@ -509,6 +517,8 @@ file_filter_add_rule (GtkFileFilter *filter,
{
filter->needed |= rule->needed;
filter->rules = g_slist_append (filter->rules, rule);
+
+ gtk_filter_changed (GTK_FILTER (filter), GTK_FILTER_CHANGE_LESS_STRICT);
}
/**
@@ -766,6 +776,22 @@ _gtk_file_filter_get_as_patterns (GtkFileFilter *filter)
return (char **)g_ptr_array_free (array, FALSE);
}
+static GtkFilterMatch
+gtk_file_filter_get_strictness (GtkFilter *filter)
+{
+ return GTK_FILTER_MATCH_SOME;
+}
+
+static gboolean
+gtk_file_filter_match (GtkFilter *filter,
+ gpointer item)
+{
+ if (!G_IS_FILE_INFO (item))
+ return TRUE;
+
+ return gtk_file_filter_filter (GTK_FILE_FILTER (filter), G_FILE_INFO (item));
+}
+
/**
* gtk_file_filter_filter:
* @filter: a #GtkFileFilter
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]