[Xfce4-commits] [apps/xfburn] 31/42: updated creation of progress bars
noreply at xfce.org
noreply at xfce.org
Tue Oct 15 02:22:14 CEST 2019
This is an automated email from the git hooks/post-receive script.
k a t a n a s t e e l p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfburn.
commit a90152b23ce69c0697fa90272c78949e60019a2c
Author: Rene Kjellerup <rk.katana.steel at gmail.com>
Date: Thu Dec 27 17:18:53 2018 -0800
updated creation of progress bars
---
.gitignore | 1 +
xfburn/xfburn-adding-progress.c | 2 +-
xfburn/xfburn-disc-usage.c | 3 +--
xfburn/xfburn-progress-dialog.c | 8 +++-----
xfburn/xfburn-utils.c | 11 +++++++++++
xfburn/xfburn-utils.h | 1 +
6 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
index 5400799..70a7e40 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,3 +51,4 @@ docs/xfburn.1
core
core.*
.vscode
+tests
\ No newline at end of file
diff --git a/xfburn/xfburn-adding-progress.c b/xfburn/xfburn-adding-progress.c
index 7da07b3..83ab871 100644
--- a/xfburn/xfburn-adding-progress.c
+++ b/xfburn/xfburn-adding-progress.c
@@ -115,7 +115,7 @@ xfburn_adding_progress_init (XfburnAddingProgress * win)
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (win), vbox);
- priv->progress_bar = gtk_progress_bar_new ();
+ priv->progress_bar = xfburn_create_progress_bar (NULL);
gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (priv->progress_bar), 0.01);
gtk_widget_show (priv->progress_bar);
gtk_box_pack_start (GTK_BOX (vbox), priv->progress_bar, TRUE, TRUE, BORDER);
diff --git a/xfburn/xfburn-disc-usage.c b/xfburn/xfburn-disc-usage.c
index cf4062d..e235275 100644
--- a/xfburn/xfburn-disc-usage.c
+++ b/xfburn/xfburn-disc-usage.c
@@ -147,8 +147,7 @@ xfburn_disc_usage_constructor (GType type, guint n_construct_properties, GObject
disc_usage->size = 0;
- disc_usage->progress_bar = gtk_progress_bar_new ();
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (disc_usage->progress_bar), "0");
+ disc_usage->progress_bar = xfburn_create_progress_bar ("0");
gtk_box_pack_start (GTK_BOX (disc_usage), disc_usage->progress_bar, TRUE, TRUE, BORDER);
gtk_widget_show (disc_usage->progress_bar);
diff --git a/xfburn/xfburn-progress-dialog.c b/xfburn/xfburn-progress-dialog.c
index 53a4a4f..67b8b1a 100644
--- a/xfburn/xfburn-progress-dialog.c
+++ b/xfburn/xfburn-progress-dialog.c
@@ -201,7 +201,7 @@ xfburn_progress_dialog_init (XfburnProgressDialog * obj)
gtk_box_pack_start (box, priv->label_action, FALSE, TRUE, BORDER);
/* progress bar */
- priv->progress_bar = gtk_progress_bar_new ();
+ priv->progress_bar = xfburn_create_progress_bar (NULL);;
gtk_widget_show (priv->progress_bar);
gtk_box_pack_start (box, priv->progress_bar, FALSE, FALSE, BORDER);
gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (priv->progress_bar), 0.05);
@@ -230,8 +230,7 @@ xfburn_progress_dialog_init (XfburnProgressDialog * obj)
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
gtk_widget_show (label);
- priv->fifo_bar = gtk_progress_bar_new ();
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->fifo_bar), _("unknown"));
+ priv->fifo_bar = xfburn_create_progress_bar (_("unknown"));
gtk_grid_attach (GTK_GRID (table), priv->fifo_bar, 1, 0, 1, 1);
gtk_widget_show (priv->fifo_bar);
@@ -240,8 +239,7 @@ xfburn_progress_dialog_init (XfburnProgressDialog * obj)
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);
gtk_widget_show (label);
- priv->buffer_bar = gtk_progress_bar_new ();
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->buffer_bar), _("unknown"));
+ priv->buffer_bar = xfburn_create_progress_bar (_("unknown"));
gtk_grid_attach (GTK_GRID (table), priv->buffer_bar, 1, 1, 1, 1);
gtk_widget_show (priv->buffer_bar);
diff --git a/xfburn/xfburn-utils.c b/xfburn/xfburn-utils.c
index c726d9e..750d9bb 100644
--- a/xfburn/xfburn-utils.c
+++ b/xfburn/xfburn-utils.c
@@ -297,3 +297,14 @@ xfburn_add_button_to_toolbar(GtkToolbar *toolbar, const gchar *stock, const gcha
gtk_toolbar_insert(toolbar, item, -1);
gtk_actionable_set_action_name (GTK_ACTIONABLE (item), action);
}
+
+/* creates a progress bar with the initial label set to text and with the label visible */
+GtkWidget *
+xfburn_create_progress_bar (const gchar *text)
+{
+ GtkProgressBar *pbar = GTK_PROGRESS_BAR (gtk_progress_bar_new ());
+ gtk_progress_bar_set_show_text (pbar, TRUE);
+ if (text != NULL && *text != '\0')
+ gtk_progress_bar_set_text (pbar, text);
+ return pbar;
+}
diff --git a/xfburn/xfburn-utils.h b/xfburn/xfburn-utils.h
index 83845f2..5dc7acb 100644
--- a/xfburn/xfburn-utils.h
+++ b/xfburn/xfburn-utils.h
@@ -49,5 +49,6 @@ void xfburn_console_libburn_messages (void);
int xfburn_media_profile_to_kb (int media_no);
void xfburn_add_button_to_toolbar(GtkToolbar *toolbar, const gchar *stock, const gchar *text, const gchar *action, const gchar *tooltip);
+GtkWidget * xfburn_create_progress_bar(const gchar *);
#endif
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list