[Goodies-commits] r4786 - xfburn/trunk/xfburn
David Mohr
squisher at xfce.org
Mon May 12 08:29:24 CEST 2008
Author: squisher
Date: 2008-05-12 06:29:24 +0000 (Mon, 12 May 2008)
New Revision: 4786
Modified:
xfburn/trunk/xfburn/xfburn-progress-dialog.c
Log:
Adding a simple animation option to the progress dialog
Modified: xfburn/trunk/xfburn/xfburn-progress-dialog.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-progress-dialog.c 2008-05-11 22:09:04 UTC (rev 4785)
+++ xfburn/trunk/xfburn/xfburn-progress-dialog.c 2008-05-12 06:29:24 UTC (rev 4786)
@@ -43,6 +43,8 @@
{
XfburnProgressDialogStatus status;
int fd_stdin;
+ gboolean animate;
+ int ani_index;
GtkWidget *label_action;
GtkWidget *progress_bar;
@@ -74,8 +76,11 @@
PROP_0,
PROP_STATUS,
PROP_SHOW_BUFFERS,
+ PROP_ANIMATE,
};
+static gchar animation[] = { '-', '\\', '|', '/' };
+
/* */
/* enumeration type for dialog status */
/* */
@@ -144,6 +149,9 @@
g_object_class_install_property (object_class, PROP_SHOW_BUFFERS,
g_param_spec_boolean ("show-buffers", "Show buffers", "Show buffers",
TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_ANIMATE,
+ g_param_spec_boolean ("animate", "Show an animation", "Show an animation",
+ FALSE, G_PARAM_READWRITE));
}
static void
@@ -242,6 +250,9 @@
g_object_get (G_OBJECT (priv->hbox_buffers), "visible", &show_buffers, NULL);
g_value_set_boolean (value, show_buffers);
break;
+ case PROP_ANIMATE:
+ g_value_set_boolean (value, priv->animate);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -252,6 +263,7 @@
xfburn_progress_dialog_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
{
XfburnProgressDialog *dialog = XFBURN_PROGRESS_DIALOG (object);
+ XfburnProgressDialogPrivate *priv = XFBURN_PROGRESS_DIALOG_GET_PRIVATE (dialog);
switch (prop_id) {
case PROP_STATUS:
@@ -260,6 +272,11 @@
case PROP_SHOW_BUFFERS:
xfburn_progress_dialog_show_buffers (dialog, g_value_get_boolean (value));
break;
+ case PROP_ANIMATE:
+ priv->animate = g_value_get_boolean (value);
+ priv->ani_index = 0;
+ DBG ("Set animate to %d", priv->animate);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -454,7 +471,12 @@
text = g_strdup ("0%");
}
else if (priv->status == XFBURN_PROGRESS_DIALOG_STATUS_RUNNING && fraction >= cur_fraction) {
- text = g_strdup_printf ("%d%%", (int) (fraction * 100));
+ if (priv->animate) {
+ text = g_strdup_printf ("%2d%% %c", (int) (fraction * 100), animation[priv->ani_index]);
+ priv->ani_index = (priv->ani_index + 1) % 4;
+ } else {
+ text = g_strdup_printf ("%d%% ", (int) (fraction * 100));
+ }
}
else if (fraction < cur_fraction) {
return;
More information about the Goodies-commits
mailing list