diff options
author | Owen Taylor <otaylor@redhat.com> | 2003-07-23 15:31:10 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2003-07-23 15:31:10 +0000 |
commit | 733f4489ade5b79227af871e1cbe694806ec367e (patch) | |
tree | cb11e44251dfd274d38a2ef88d2cd7f3bb8619f1 /tests | |
parent | 96ba7bb65e02858e08f78922f4d837ac7d1a65a0 (diff) | |
download | gdk-pixbuf-733f4489ade5b79227af871e1cbe694806ec367e.tar.gz |
File filter objects.
Wed Jul 23 11:23:43 2003 Owen Taylor <otaylor@redhat.com>
* gtkfilefilter.[ch]: File filter objects.
* gtkfilechooser.[ch] gtkfilechooserutils.[ch]: Add
file filtering to API.
* gtkfilechooserimpldefault.c: Implement file filters.
* testfilechooser.c: Try out the filter functionality.
* gtkfilesystemmodel.c: Add
_gtk_file_system_model_set_filter() to set a callback
function for filtering.
* gtkfilechooserutils.c: Propagate property notification
to the receiver.
* fnmatch.c: Copy this from GTK+ temporarily to get
UTF-8 pattern matching functionality.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testfilechooser.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c index 95696dbb8..51f91e918 100644 --- a/tests/testfilechooser.c +++ b/tests/testfilechooser.c @@ -1,3 +1,5 @@ +#include <string.h> + #include <gtk/gtk.h> #include "gtkfilechooserdialog.h" #include "gtkfilechooser.h" @@ -43,6 +45,17 @@ response_cb (GtkDialog *dialog, gtk_main_quit (); } +static gboolean +no_backup_files_filter (const GtkFileFilterInfo *filter_info, + gpointer data) +{ + gsize len = strlen (filter_info->display_name); + if (len > 0 && filter_info->display_name[len - 1] == '~') + return 0; + else + return 1; +} + int main (int argc, char **argv) { @@ -52,6 +65,7 @@ main (int argc, char **argv) GtkWidget *dialog; GtkWidget *prop_editor; GtkFileSystem *file_system; + GtkFileFilter *filter; gtk_init (&argc, &argv); @@ -79,9 +93,32 @@ main (int argc, char **argv) G_CALLBACK (print_current_folder), NULL); g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL); + + /* Filters */ + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, "All Files"); + gtk_file_filter_add_pattern (filter, "*"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, "No backup files"); + gtk_file_filter_add_custom (filter, GTK_FILE_FILTER_DISPLAY_NAME, + no_backup_files_filter, NULL, NULL); + gtk_file_filter_add_mime_type (filter, "image/png"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + + /* Make this filter the default */ + gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter); + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, "PNG and JPEG"); + gtk_file_filter_add_mime_type (filter, "image/jpeg"); + gtk_file_filter_add_mime_type (filter, "image/png"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 400); - gtk_widget_show (dialog); + /* show_all() to reveal bugs in composite widget handling */ + gtk_widget_show_all (dialog); prop_editor = create_prop_editor (G_OBJECT (dialog), GTK_TYPE_FILE_CHOOSER); |