Bug fix: Download web file
authorColin Clark <cclark@carbon>
Tue, 3 Dec 2019 11:26:00 +0000 (11:26 +0000)
committerColin Clark <cclark@carbon>
Tue, 3 Dec 2019 11:26:00 +0000 (11:26 +0000)
Correct name of cancel callback.
Additional parameter to start "Downloading..." dialog minimized (for use
e.g. when running a slide show of web files - [use the --remote
--File:<file> option] ).

src/layout.c
src/layout_image.c
src/main.c
src/remote.c
src/ui_fileops.c
src/ui_fileops.h

index b844689..8f6c51a 100644 (file)
@@ -263,7 +263,7 @@ static void layout_path_entry_cb(const gchar *path, gpointer data)
 
        buf = g_strdup(path);
 
-       if (!download_web_file(buf, lw))
+       if (!download_web_file(buf, FALSE, lw))
                {
                parse_out_relatives(buf);
 
index a87e9f8..aaf7956 100644 (file)
@@ -878,7 +878,7 @@ static void layout_image_dnd_receive(GtkWidget *widget, GdkDragContext *context,
        if (info == TARGET_TEXT_PLAIN)
                {
                url = g_strdup((gchar *)gtk_selection_data_get_data(selection_data));
-               download_web_file(url, lw);
+               download_web_file(url, FALSE, lw);
                g_free(url);
                }
        else if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER)
index cb1652c..c414bc8 100644 (file)
@@ -259,7 +259,7 @@ static void parse_command_line(gint argc, gchar *argv[])
                                parse_command_line_process_file(cmd_all, &command_line->path, &command_line->file,
                                                                &list, &command_line->collection_list, &first_dir);
                                }
-                       else if (download_web_file(cmd_line, NULL))
+                       else if (download_web_file(cmd_line, FALSE, NULL))
                                {
                                }
                        else if (is_collection(cmd_line))
index ad4b121..17a64d5 100644 (file)
@@ -674,7 +674,7 @@ static void gr_file_load_no_raise(const gchar *text, GIOChannel *channel, gpoint
        gchar *filename;
        gchar *tilde_filename;
 
-       if (!download_web_file(text, NULL))
+       if (!download_web_file(text, TRUE, NULL))
                {
                tilde_filename = expand_tilde(text);
                filename = set_pwd(tilde_filename);
index 722fdf8..0d8de3b 100644 (file)
@@ -1042,7 +1042,7 @@ static void web_file_progress_cb(goffset current_num_bytes, goffset total_num_by
                }
 }
 
-static void timezone_cancel_button_cb(GenericDialog *gd, gpointer data)
+static void download_web_file_cancel_button_cb(GenericDialog *gd, gpointer data)
 {
        WebData* web = data;
        GError *error = NULL;
@@ -1050,7 +1050,7 @@ static void timezone_cancel_button_cb(GenericDialog *gd, gpointer data)
        g_cancellable_cancel(web->cancellable);
 }
 
-gboolean download_web_file(const gchar *text, gpointer data)
+gboolean download_web_file(const gchar *text, gboolean minimized, gpointer data)
 {
        gchar *scheme;
        LayoutWindow *lw = data;
@@ -1087,7 +1087,7 @@ gboolean download_web_file(const gchar *text, gpointer data)
                                base = g_strdup(g_file_get_basename(web->web_file));
                                web->tmp_g_file = g_file_new_for_path(g_build_filename(tmp_dir, base, NULL));
 
-                               web->gd = generic_dialog_new(_("Download web file"), "download_web_file", NULL, TRUE, timezone_cancel_button_cb, web);
+                               web->gd = generic_dialog_new(_("Download web file"), "download_web_file", NULL, TRUE, download_web_file_cancel_button_cb, web);
 
                                message = g_strconcat(_("Downloading "), base, NULL);
                                generic_dialog_add_message(web->gd, GTK_STOCK_DIALOG_INFO, message, NULL, FALSE);
@@ -1095,6 +1095,10 @@ gboolean download_web_file(const gchar *text, gpointer data)
                                web->progress = gtk_progress_bar_new();
                                gtk_box_pack_start(GTK_BOX(web->gd->vbox), web->progress, FALSE, FALSE, 0);
                                gtk_widget_show(web->progress);
+                               if (minimized)
+                                       {
+                                       gtk_window_iconify(GTK_WINDOW(web->gd->dialog));
+                                       }
 
                                gtk_widget_show(web->gd->dialog);
                                web->cancellable = g_cancellable_new();
@@ -1113,5 +1117,6 @@ gboolean download_web_file(const gchar *text, gpointer data)
 
        g_free(scheme);
        return ret;
+
 }
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
index c2acbf9..d680255 100644 (file)
@@ -109,6 +109,6 @@ gboolean recursive_mkdir_if_not_exists(const gchar *path, mode_t mode);
 gchar *md5_text_from_file_utf8(const gchar *path, const gchar *error_text);
 gboolean md5_get_digest_from_file_utf8(const gchar *path, guchar digest[16]);
 
-gboolean download_web_file(const gchar *text, gpointer data);
+gboolean download_web_file(const gchar *text, gboolean minimized, gpointer data);
 #endif
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */