From 152cbaf340412b1753c6ddf8345a35c2982520db Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sat, 28 Oct 2017 22:05:17 -0400 Subject: mq_web_view_open(), mq_web_view_save(): Add file filters to file choosers --- diff --git a/src/web-view.c b/src/web-view.c index 1f71e32..e9e25ad 100644 --- a/src/web-view.c +++ b/src/web-view.c @@ -799,6 +799,40 @@ mq_web_view_zoom_reset(MqWebView *web_view) } static void +add_chooser_filters(GtkFileChooser *chooser) +{ + GtkFileFilter *filter; + + filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter, "All files"); + gtk_file_filter_add_pattern(filter, "*"); + gtk_file_chooser_add_filter(chooser, filter); + + filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter, "All Web pages"); + gtk_file_filter_add_pattern(filter, "*.htm"); + gtk_file_filter_add_pattern(filter, "*.html"); + gtk_file_filter_add_pattern(filter, "*.mht"); + gtk_file_filter_add_pattern(filter, "*.mhtm"); + gtk_file_filter_add_pattern(filter, "*.mhtml"); + gtk_file_chooser_add_filter(chooser, filter); + + filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter, "HTML documents (*.htm, *.html)"); + gtk_file_filter_add_pattern(filter, "*.htm"); + gtk_file_filter_add_pattern(filter, "*.html"); + gtk_file_chooser_add_filter(chooser, filter); + + filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter, + "MHTML documents (*.mht, *.mhtm, *.mhtml)"); + gtk_file_filter_add_pattern(filter, "*.mht"); + gtk_file_filter_add_pattern(filter, "*.mhtm"); + gtk_file_filter_add_pattern(filter, "*.mhtml"); + gtk_file_chooser_add_filter(chooser, filter); +} + +static void open_response_cb(GtkWidget *dialog, gint response_id, MqWebView *web_view) { gchar *dir; @@ -850,6 +884,8 @@ mq_web_view_open(MqWebView *web_view) /* TODO: Consider setting chooser's folder from current file-scheme URI, * if any. */ g_free(dir); + + add_chooser_filters(chooser); } static void @@ -933,4 +969,6 @@ mq_web_view_save(MqWebView *web_view) g_free(title); gtk_file_chooser_set_current_name(chooser, filename); g_free(filename); + + add_chooser_filters(chooser); } -- cgit v0.9.1