diff options
author | Lucas Rocha <lucasr@gnome.org> | 2009-08-08 19:16:49 +0100 |
---|---|---|
committer | Lucas Rocha <lucasr@gnome.org> | 2009-08-10 03:08:46 +0100 |
commit | fa0349545d65df0ce1c8b4de2cedc5824c7a5866 (patch) | |
tree | 88dce2d60779639d3f03c8f1abd783d63c68a410 /src | |
parent | [progress] coding style fixes (diff) | |
download | zenity-fa0349545d65df0ce1c8b4de2cedc5824c7a5866.tar.gz zenity-fa0349545d65df0ce1c8b4de2cedc5824c7a5866.tar.bz2 zenity-fa0349545d65df0ce1c8b4de2cedc5824c7a5866.zip |
[progress] Factor out function to control pulsate
Diffstat (limited to 'src')
-rw-r--r-- | src/progress.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/progress.c b/src/progress.c index 9d6e8bb3..8a6e10fc 100644 --- a/src/progress.c +++ b/src/progress.c @@ -36,6 +36,7 @@ static GtkBuilder *builder; static ZenityData *zen_data; static GIOChannel *channel; +static gint pulsate_timeout = -1; static gboolean autokill; gint zenity_progress_timeout (gpointer data); @@ -50,6 +51,25 @@ zenity_progress_pulsate_progress_bar (gpointer user_data) return TRUE; } +static void +zenity_progress_pulsate_stop () +{ + if (pulsate_timeout > 0) { + g_source_remove (pulsate_timeout); + pulsate_timeout = -1; + } +} + +static void +zenity_progress_pulsate_start (GObject *progress_bar) +{ + if (pulsate_timeout == -1) { + pulsate_timeout = g_timeout_add (100, + zenity_progress_pulsate_progress_bar, + progress_bar); + } +} + static gboolean zenity_progress_handle_stdin (GIOChannel *channel, GIOCondition condition, @@ -58,7 +78,6 @@ zenity_progress_handle_stdin (GIOChannel *channel, static ZenityProgressData *progress_data; static GObject *progress_bar; static GObject *progress_label; - static gint pulsate_timeout = -1; float percentage = 0.0; progress_data = (ZenityProgressData *) data; @@ -72,8 +91,7 @@ zenity_progress_handle_stdin (GIOChannel *channel, string = g_string_new (NULL); if (progress_data->pulsate) { - if (pulsate_timeout == -1) - pulsate_timeout = g_timeout_add (100, zenity_progress_pulsate_progress_bar, progress_bar); + zenity_progress_pulsate_start (progress_bar); } while (channel->is_readable != TRUE) @@ -146,10 +164,7 @@ zenity_progress_handle_stdin (GIOChannel *channel, gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); - if (progress_data->pulsate) { - g_source_remove (pulsate_timeout); - pulsate_timeout = -1; - } + zenity_progress_pulsate_stop (); g_object_unref (builder); |