[gthumb] status bar: added button to show the progress dialog



commit 7c48a4d3f885a7a881f4aa05832295adc762d152
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Apr 21 12:54:01 2021 +0200

    status bar: added button to show the progress dialog
    
    The button is visible only when there are running tasks.

 gthumb/gth-browser-actions-callbacks.c |  9 +++++++++
 gthumb/gth-browser-actions-callbacks.h |  1 +
 gthumb/gth-browser-actions-entries.h   |  1 +
 gthumb/gth-browser.c                   | 22 ++++++++++++++++++++++
 gthumb/gth-browser.h                   |  1 +
 5 files changed, 34 insertions(+)
---
diff --git a/gthumb/gth-browser-actions-callbacks.c b/gthumb/gth-browser-actions-callbacks.c
index f4eda0ec..96197916 100644
--- a/gthumb/gth-browser-actions-callbacks.c
+++ b/gthumb/gth-browser-actions-callbacks.c
@@ -425,6 +425,15 @@ gth_browser_activate_open_folder_in_new_window (GSimpleAction *action,
 }
 
 
+void
+gth_browser_activate_show_progress_dialog (GSimpleAction *action,
+                                          GVariant      *parameter,
+                                          gpointer       user_data)
+{
+       gth_browser_show_progress_dialog (GTH_BROWSER (user_data));
+}
+
+
 void
 gth_browser_activate_show_hidden_files (GSimpleAction *action,
                                        GVariant      *state,
diff --git a/gthumb/gth-browser-actions-callbacks.h b/gthumb/gth-browser-actions-callbacks.h
index b632724c..f8467504 100644
--- a/gthumb/gth-browser-actions-callbacks.h
+++ b/gthumb/gth-browser-actions-callbacks.h
@@ -54,6 +54,7 @@ DEF_ACTION_CALLBACK (gth_browser_activate_viewer_edit_file)
 DEF_ACTION_CALLBACK (gth_browser_activate_viewer_properties)
 DEF_ACTION_CALLBACK (gth_browser_activate_unfullscreen)
 DEF_ACTION_CALLBACK (gth_browser_activate_open_folder_in_new_window)
+DEF_ACTION_CALLBACK (gth_browser_activate_show_progress_dialog)
 DEF_ACTION_CALLBACK (gth_browser_activate_show_hidden_files)
 DEF_ACTION_CALLBACK (gth_browser_activate_sort_by)
 DEF_ACTION_CALLBACK (gth_browser_activate_show_statusbar)
diff --git a/gthumb/gth-browser-actions-entries.h b/gthumb/gth-browser-actions-entries.h
index fd724528..791f7cda 100644
--- a/gthumb/gth-browser-actions-entries.h
+++ b/gthumb/gth-browser-actions-entries.h
@@ -60,6 +60,7 @@ static const GActionEntry gth_browser_actions[] = {
        { "viewer-properties", toggle_action_activated, NULL, "false", gth_browser_activate_viewer_properties 
},
        { "unfullscreen", gth_browser_activate_unfullscreen },
        { "open-folder-in-new-window", gth_browser_activate_open_folder_in_new_window },
+       { "show-progress-dialog", gth_browser_activate_show_progress_dialog },
 
        { "show-hidden-files", toggle_action_activated, NULL, "false", gth_browser_activate_show_hidden_files 
},
        { "sort-by", gth_browser_activate_sort_by },
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index f0fc5108..1d6efa73 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -117,6 +117,7 @@ struct _GthBrowserPrivate {
        GtkWidget         *header_sections[GTH_BROWSER_N_HEADER_SECTIONS];
        GtkWidget         *browser_status_commands;
        GtkWidget         *viewer_status_commands;
+       GtkWidget         *show_progress_dialog_button;
        GtkWidget         *menu_button;
        GHashTable        *menu_managers;
 
@@ -4708,6 +4709,16 @@ gth_browser_init (GthBrowser *browser)
        {
                GtkWidget *button;
 
+               /* statusbar commands available in all modes */
+
+               browser->priv->show_progress_dialog_button = button = gtk_button_new ();
+               gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name 
("system-run-symbolic", GTK_ICON_SIZE_MENU));
+               gtk_widget_set_tooltip_text (button, _("Operations"));
+               gtk_widget_show_all (button);
+               gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "win.show-progress-dialog");
+               gtk_box_pack_start (GTK_BOX (gth_statubar_get_action_area (GTH_STATUSBAR 
(browser->priv->statusbar))), button, FALSE, FALSE, 0);
+               gtk_widget_hide (button);
+
                /* statusbar commands in browser mode */
 
                browser->priv->browser_status_commands = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
@@ -5627,6 +5638,8 @@ background_task_completed_cb (GthTask  *task,
        g_signal_handler_disconnect (task, task_data->completed_event);
        task_data_free (task_data);
 
+       gtk_widget_set_visible (browser->priv->show_progress_dialog_button, (browser->priv->viewer_tasks != 
NULL) || (browser->priv->background_tasks != NULL));
+
        if (error == NULL)
                return;
 
@@ -5746,6 +5759,7 @@ gth_browser_exec_task (GthBrowser   *browser,
                        g_object_add_weak_pointer (G_OBJECT (browser->priv->progress_dialog), (gpointer*) 
&(browser->priv->progress_dialog));
                }
                gth_progress_dialog_add_task (GTH_PROGRESS_DIALOG (browser->priv->progress_dialog), task, 
flags);
+               gtk_widget_show (browser->priv->show_progress_dialog_button);
 
                return;
        }
@@ -7134,3 +7148,11 @@ gth_browser_show_menu (GthBrowser *browser)
 {
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (browser->priv->menu_button), TRUE);
 }
+
+
+void
+gth_browser_show_progress_dialog (GthBrowser *browser)
+{
+       if ((browser->priv->background_tasks != NULL) && (browser->priv->progress_dialog != NULL))
+               gtk_window_present (GTK_WINDOW (browser->priv->progress_dialog));
+}
diff --git a/gthumb/gth-browser.h b/gthumb/gth-browser.h
index 2e812c05..c7e918c1 100644
--- a/gthumb/gth-browser.h
+++ b/gthumb/gth-browser.h
@@ -291,6 +291,7 @@ GtkWidget *      gth_browser_get_fullscreen_headerbar
 void             gth_browser_keep_mouse_visible     (GthBrowser              *browser,
                                                     gboolean          value);
 void             gth_browser_show_menu              (GthBrowser              *browser);
+void             gth_browser_show_progress_dialog   (GthBrowser        *browser);
 
 /* utilities */
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]