[gthumb: 16/22] automatically pulse the statusbar if a pulse message is received
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb: 16/22] automatically pulse the statusbar if a pulse message is received
- Date: Sat, 30 Jan 2010 23:20:36 +0000 (UTC)
commit 58254a16b3e5352fa69f10cfef3c7ad14e753543
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Jan 28 22:26:53 2010 +0100
automatically pulse the statusbar if a pulse message is received
gthumb/gth-progress-dialog.c | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/gthumb/gth-progress-dialog.c b/gthumb/gth-progress-dialog.c
index 315b9c3..919e57e 100644
--- a/gthumb/gth-progress-dialog.c
+++ b/gthumb/gth-progress-dialog.c
@@ -27,6 +27,7 @@
#define DIALOG_WIDTH 450
#define SHOW_DELAY 500
+#define PULSE_INTERVAL 500
/* -- gth_task_progress -- */
@@ -51,6 +52,7 @@ struct _GthTaskProgress {
GtkWidget *cancel_button;
gulong task_progress;
gulong task_completed;
+ guint pulse_event;
};
struct _GthTaskProgressClass {
@@ -65,6 +67,8 @@ gth_task_progress_finalize (GObject *base)
{
GthTaskProgress *self = (GthTaskProgress *) base;
+ if (self->pulse_event != 0)
+ g_source_remove (self->pulse_event);
g_signal_handler_disconnect (self->task, self->task_progress);
g_signal_handler_disconnect (self->task, self->task_completed);
gth_task_cancel (self->task);
@@ -98,6 +102,7 @@ gth_task_progress_init (GthTaskProgress *self)
GtkWidget *image;
self->task = NULL;
+ self->pulse_event = 0;
vbox = gtk_vbox_new (FALSE, 3);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
@@ -168,6 +173,17 @@ gth_task_progress_get_type (void)
}
+static gboolean
+task_pulse_cb (gpointer user_data)
+{
+ GthTaskProgress *self = user_data;
+
+ gtk_progress_bar_pulse (GTK_PROGRESS_BAR (self->fraction_progressbar));
+
+ return (self->pulse_event != 0);
+}
+
+
static void
task_progress_cb (GthTask *task,
const char *description,
@@ -182,10 +198,18 @@ task_progress_cb (GthTask *task,
gtk_label_set_text (GTK_LABEL (self->description_label), description);
if (details != NULL)
gtk_label_set_text (GTK_LABEL (self->details_label), details);
- if (pulse)
+ if (pulse) {
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (self->fraction_progressbar));
- else
+ if (self->pulse_event == 0)
+ self->pulse_event = gdk_threads_add_timeout (PULSE_INTERVAL, task_pulse_cb, self);
+ }
+ else {
+ if (self->pulse_event != 0) {
+ g_source_remove (self->pulse_event);
+ self->pulse_event = 0;
+ }
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (self->fraction_progressbar), fraction);
+ }
}
@@ -199,6 +223,10 @@ task_completed_cb (GthTask *task,
{
GthTaskProgress *self = user_data;
+ if (self->pulse_event != 0) {
+ g_source_remove (self->pulse_event);
+ self->pulse_event = 0;
+ }
gth_progress_dialog_remove_child (GTH_PROGRESS_DIALOG (gtk_widget_get_toplevel (GTK_WIDGET (self))), GTK_WIDGET (self));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]