diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-28 18:58:08 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-28 18:58:08 (EDT) |
commit | b265016b7504bc7b7dbb4bae10e38c50b89d7cb7 (patch) | |
tree | 98278a944f2148ded385820740db64a115fab4c4 | |
parent | 681956be894e38e5c4515c80a9a4a626ef4d4c9f (diff) | |
download | marquee-b265016b7504bc7b7dbb4bae10e38c50b89d7cb7.zip marquee-b265016b7504bc7b7dbb4bae10e38c50b89d7cb7.tar.gz marquee-b265016b7504bc7b7dbb4bae10e38c50b89d7cb7.tar.bz2 |
mq_web_view_open(), mq_web_view_save(): Don't save NULL chooser folder
Also free the return value of gtk_file_chooser_get_current_folder() and
save the configuration in mq_web_view_open()'s callback.
-rw-r--r-- | src/web-view.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/web-view.c b/src/web-view.c index b0c99a2..af69929 100644 --- a/src/web-view.c +++ b/src/web-view.c @@ -801,13 +801,19 @@ mq_web_view_zoom_reset(MqWebView *web_view) static void open_response_cb(GtkWidget *dialog, gint response_id, MqWebView *web_view) { + gchar *dir; gchar *filename; gchar *uri; if (response_id == GTK_RESPONSE_ACCEPT) { - mq_config_set_string(web_view->config, "directories.open-file", - gtk_file_chooser_get_current_folder( - GTK_FILE_CHOOSER(dialog))); + dir = gtk_file_chooser_get_current_folder( + GTK_FILE_CHOOSER(dialog)); + if (dir) { + mq_config_set_string(web_view->config, + "directories.open-file", dir); + g_free(dir); + mq_config_save(web_view->config); + } filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog)); uri = g_strconcat("file://", filename, NULL); @@ -867,14 +873,19 @@ get_clean_title(MqWebView *web_view) static void save_response_cb(GtkWidget *dialog, gint response_id, MqWebView *web_view) { + gchar *dir; gchar *filename; GFile *file; if (response_id == GTK_RESPONSE_ACCEPT) { - mq_config_set_string(web_view->config, "directories.downloads", - gtk_file_chooser_get_current_folder( - GTK_FILE_CHOOSER(dialog))); - mq_config_save(web_view->config); + dir = gtk_file_chooser_get_current_folder( + GTK_FILE_CHOOSER(dialog)); + if (dir) { + mq_config_set_string(web_view->config, + "directories.downloads", dir); + g_free(dir); + mq_config_save(web_view->config); + } filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog)); file = g_file_new_for_path(filename); |