[gtk+] testgtk.c: native file chooser filter changes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] testgtk.c: native file chooser filter changes
- Date: Tue, 18 Jul 2017 17:36:32 +0000 (UTC)
commit 2139b7642b398d79b6d33dc39d5da38b49cae426
Author: Tom Schoonjans <Tom Schoonjans diamond ac uk>
Date: Thu Jul 13 20:03:55 2017 +0100
testgtk.c: native file chooser filter changes
Set the filter before showing the dialog
Afterwards, fetch the last active filter and display its name.
https://bugzilla.gnome.org/show_bug.cgi?id=784723
tests/testgtk.c | 28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 1c0097b..a7eb223 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -8174,8 +8174,11 @@ native_response (GtkNativeDialog *self,
GSList *uris, *l;
GString *s;
char *response;
+ GtkFileFilter *filter;
+ GSList *filter_list = gtk_file_chooser_list_filters (GTK_FILE_CHOOSER (self));
uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (self));
+ filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (self));
s = g_string_new ("");
for (l = uris; l != NULL; l = l->next)
{
@@ -8202,12 +8205,23 @@ native_response (GtkNativeDialog *self,
break;
}
- res = g_strdup_printf ("Response #%d: %s\n"
- "Files:\n"
- "%s",
- ++count,
- response,
- s->str);
+ if (filter)
+ res = g_strdup_printf ("Response #%d: %s\n"
+ "Filter: %s\n"
+ "Files:\n"
+ "%s",
+ ++count,
+ response,
+ gtk_file_filter_get_name (filter),
+ s->str);
+ else
+ res = g_strdup_printf ("Response #%d: %s\n"
+ "NO Filter\n"
+ "Files:\n"
+ "%s",
+ ++count,
+ response,
+ s->str);
gtk_label_set_text (GTK_LABEL (label), res);
g_free (response);
g_string_free (s, TRUE);
@@ -8375,6 +8389,7 @@ native_filter_changed (GtkWidget *combo,
gtk_file_filter_set_name (filter, "Images");
gtk_file_filter_add_pixbuf_formats (filter);
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (native), filter);
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (native), filter);
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, "All");
@@ -8392,6 +8407,7 @@ native_filter_changed (GtkWidget *combo,
gtk_file_filter_set_name (filter, "All");
gtk_file_filter_add_pattern (filter, "*");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (native), filter);
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (native), filter);
break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]