[gnome-commander: 1/2] Replace deprecated widget GtkProgress with GtkProgressBar




commit 2cd601ebeb2809355f72bf50c001eaabd77318b6
Author: Roman Pauer <roman pauer gmail com>
Date:   Fri Aug 5 17:51:37 2022 +0200

    Replace deprecated widget GtkProgress with GtkProgressBar

 libgcmd/libgcmd-widget-factory.cc      | 12 +-----------
 libgcmd/libgcmd-widget-factory.h       | 10 ++++++++--
 src/dialogs/gnome-cmd-delete-dialog.cc |  2 +-
 src/dirlist.cc                         |  2 +-
 src/gnome-cmd-dir.cc                   |  5 ++---
 src/gnome-cmd-file-list.cc             |  7 +++----
 src/gnome-cmd-xfer-progress-win.cc     |  4 ++--
 7 files changed, 18 insertions(+), 24 deletions(-)
---
diff --git a/libgcmd/libgcmd-widget-factory.cc b/libgcmd/libgcmd-widget-factory.cc
index b1e4a478..9cd4e525 100644
--- a/libgcmd/libgcmd-widget-factory.cc
+++ b/libgcmd/libgcmd-widget-factory.cc
@@ -563,7 +563,7 @@ GtkWidget *create_progress_bar (GtkWidget *parent)
     g_object_ref (w);
     g_object_set_data_full (G_OBJECT (parent), "progress_bar", w, g_object_unref);
     gtk_widget_show (w);
-    gtk_progress_set_show_text (GTK_PROGRESS (w), TRUE);
+    gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (w), TRUE);
     return w;
 }
 
@@ -579,16 +579,6 @@ GtkWidget *create_sw (GtkWidget *parent)
 }
 
 
-void progress_bar_update (GtkWidget *pbar, gint max)
-{
-    gint value = (gint)gtk_progress_get_value (GTK_PROGRESS (pbar)) + 1;
-
-    if (value >= max) value = 0;
-
-    gtk_progress_set_value (GTK_PROGRESS (pbar), (gfloat)value);
-}
-
-
 const char *get_entry_text (GtkWidget *parent, const gchar *entry_name)
 {
     GtkWidget *entry = lookup_widget (parent, entry_name);
diff --git a/libgcmd/libgcmd-widget-factory.h b/libgcmd/libgcmd-widget-factory.h
index 9eae63cc..698a52d3 100644
--- a/libgcmd/libgcmd-widget-factory.h
+++ b/libgcmd/libgcmd-widget-factory.h
@@ -157,8 +157,6 @@ GtkWidget *create_progress_bar (GtkWidget *parent);
 
 GtkWidget *create_sw (GtkWidget *parent);
 
-void progress_bar_update (GtkWidget *pbar, gint max);
-
 const char *get_entry_text (GtkWidget *parent, const gchar *entry_name);
 
 #ifdef __GNUC__
@@ -166,3 +164,11 @@ const char *get_entry_text (GtkWidget *parent, const gchar *entry_name);
 #else
     void create_error_dialog (const gchar *msg, ...);
 #endif
+
+#if !GTK_CHECK_VERSION(3,0,0)
+inline void gtk_progress_bar_set_show_text (GtkProgressBar *pbar, gboolean show_text)
+{
+    gtk_progress_bar_set_text (pbar, nullptr);
+    pbar->progress.show_text = show_text;
+}
+#endif
diff --git a/src/dialogs/gnome-cmd-delete-dialog.cc b/src/dialogs/gnome-cmd-delete-dialog.cc
index 82c29a58..4f5de785 100644
--- a/src/dialogs/gnome-cmd-delete-dialog.cc
+++ b/src/dialogs/gnome-cmd-delete-dialog.cc
@@ -273,7 +273,7 @@ static gboolean update_delete_status_widgets (DeleteData *deleteData)
     if (deleteData->progwin)
     {
         gtk_label_set_text (GTK_LABEL (deleteData->proglabel), deleteData->msg);
-        gtk_progress_set_percentage (GTK_PROGRESS (deleteData->progbar), deleteData->progress);
+        gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (deleteData->progbar), deleteData->progress);
     }
 
     if (deleteData->problem)
diff --git a/src/dirlist.cc b/src/dirlist.cc
index 9784084c..c77ace21 100644
--- a/src/dirlist.cc
+++ b/src/dirlist.cc
@@ -47,7 +47,7 @@ static gboolean update_list_progress (GnomeCmdDir *dir)
     {
         gchar *msg = g_strdup_printf (ngettext ("%d file listed", "%d files listed", dir->list_counter), 
dir->list_counter);
         gtk_label_set_text (GTK_LABEL (dir->label), msg);
-        progress_bar_update (dir->pbar, 50);
+        gtk_progress_bar_pulse (GTK_PROGRESS_BAR (dir->pbar));
         DEBUG('l', "%s\n", msg);
         g_free (msg);
         return TRUE;
diff --git a/src/gnome-cmd-dir.cc b/src/gnome-cmd-dir.cc
index c3aeaee1..89a554b9 100644
--- a/src/gnome-cmd-dir.cc
+++ b/src/gnome-cmd-dir.cc
@@ -540,9 +540,8 @@ static void create_list_progress_dialog (GnomeCmdDir *dir)
     dir->label = create_label (dir->dialog, _("Waiting for file list"));
 
     dir->pbar = create_progress_bar (dir->dialog);
-    gtk_progress_set_show_text (GTK_PROGRESS (dir->pbar), FALSE);
-    gtk_progress_set_activity_mode (GTK_PROGRESS (dir->pbar), TRUE);
-    gtk_progress_configure (GTK_PROGRESS (dir->pbar), 0, 0, DIR_PBAR_MAX);
+    gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (dir->pbar), FALSE);
+    gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (dir->pbar), 1.0 / (gdouble) DIR_PBAR_MAX);
 
     gtk_box_pack_start (GTK_BOX (vbox), dir->label, TRUE, TRUE, 0);
     gtk_box_pack_start (GTK_BOX (vbox), dir->pbar, FALSE, TRUE, 0);
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index b49af293..98c4e2d2 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -1769,7 +1769,7 @@ static gboolean update_con_open_progress (GnomeCmdFileList *fl)
 
     const gchar *msg = gnome_cmd_con_get_open_msg (fl->priv->con_opening);
     gtk_label_set_text (GTK_LABEL (fl->priv->con_open_dialog_label), msg);
-    progress_bar_update (fl->priv->con_open_dialog_pbar, FL_PBAR_MAX);
+    gtk_progress_bar_pulse (GTK_PROGRESS_BAR (fl->priv->con_open_dialog_pbar));
 
     return TRUE;
 }
@@ -1791,9 +1791,8 @@ static void create_con_open_progress_dialog (GnomeCmdFileList *fl)
     fl->priv->con_open_dialog_label = create_label (fl->priv->con_open_dialog, "");
 
     fl->priv->con_open_dialog_pbar = create_progress_bar (fl->priv->con_open_dialog);
-    gtk_progress_set_show_text (GTK_PROGRESS (fl->priv->con_open_dialog_pbar), FALSE);
-    gtk_progress_set_activity_mode (GTK_PROGRESS (fl->priv->con_open_dialog_pbar), TRUE);
-    gtk_progress_configure (GTK_PROGRESS (fl->priv->con_open_dialog_pbar), 0, 0, FL_PBAR_MAX);
+    gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (fl->priv->con_open_dialog_pbar), FALSE);
+    gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (fl->priv->con_open_dialog_pbar), 1.0 / (gdouble) 
FL_PBAR_MAX);
 
     gtk_box_pack_start (GTK_BOX (vbox), fl->priv->con_open_dialog_label, TRUE, TRUE, 0);
     gtk_box_pack_start (GTK_BOX (vbox), fl->priv->con_open_dialog_pbar, FALSE, TRUE, 0);
diff --git a/src/gnome-cmd-xfer-progress-win.cc b/src/gnome-cmd-xfer-progress-win.cc
index 27dabb8b..7d1e5569 100644
--- a/src/gnome-cmd-xfer-progress-win.cc
+++ b/src/gnome-cmd-xfer-progress-win.cc
@@ -163,12 +163,12 @@ void gnome_cmd_xfer_progress_win_set_total_progress (GnomeCmdXferProgressWin *wi
                                                      guint64 bytes_total)
 {
     gfloat total_prog = bytes_total>0 ? (gdouble) bytes_copied/(gdouble) bytes_total : -1.0f;
-    gtk_progress_set_percentage (GTK_PROGRESS (win->totalprog), total_prog);
+    gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (win->totalprog), total_prog);
 
     if (win->fileprog && file_size > 0)
     {
         gfloat file_prog = (gdouble) file_bytes_copied/(gdouble) file_size;
-        gtk_progress_set_percentage (GTK_PROGRESS (win->fileprog), file_prog);
+        gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (win->fileprog), file_prog);
     }
 
     gchar *bytes_total_str = g_strdup (size2string (bytes_total, gnome_cmd_data.options.size_disp_mode));


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