forked from AuroraMiddleware/gtk
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
This commit is contained in:
parent
f10bfcc638
commit
2139b7642b
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user