]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Add a xml file filter to the file open dialog
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 26 Sep 2011 16:18:23 +0000 (09:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 26 Sep 2011 16:18:23 +0000 (09:18 -0700)
My home directory is a mess.  Don't show all the crap, just the stuff
that might be relevant.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
gtk-gui.c

index 7c8e36423660253958835d10f5f1775c34841171..7eb85cf806a1b5478429375eefd34d602d4c2dca 100644 (file)
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -87,6 +87,8 @@ void report_error(GError* error)
 static void file_open(GtkWidget *w, gpointer data)
 {
        GtkWidget *dialog;
+       GtkFileFilter *filter;
+
        dialog = gtk_file_chooser_dialog_new("Open File",
                GTK_WINDOW(main_window),
                GTK_FILE_CHOOSER_ACTION_OPEN,
@@ -95,6 +97,13 @@ static void file_open(GtkWidget *w, gpointer data)
                NULL);
        gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);
 
+       filter = gtk_file_filter_new();
+       gtk_file_filter_add_pattern(filter, "*.xml");
+       gtk_file_filter_add_pattern(filter, "*.XML");
+       gtk_file_filter_add_mime_type(filter, "text/xml");
+       gtk_file_filter_set_name(filter, "XML file");
+       gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
+
        if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
                GSList *filenames;
                char *filename;