From a66e4df5d1c0ebb485d5f3f8a24129366d2ff598 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 8 Aug 2009 18:15:42 +0100 Subject: [PATCH] =?UTF-8?q?Bug=20556198=20=E2=80=93=20Support=20toggling?= =?UTF-8?q?=20pulsate=20in=20progressbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/progress.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/progress.c b/src/progress.c index 8a6e10f..a0868ea 100644 --- a/src/progress.c +++ b/src/progress.c @@ -123,6 +123,33 @@ zenity_progress_handle_stdin (GIOChannel *channel, match = g_strstr_len (string->str, strlen (string->str), "#"); match++; gtk_label_set_text (GTK_LABEL (progress_label), g_strcompress(g_strchomp (g_strchug (match)))); + + } else if (g_str_has_prefix (string->str, "pulsate")) { + gchar *colon, *command, *value; + + zenity_util_strip_newline (string->str); + + colon = strchr(string->str, ':'); + if (colon == NULL) { + continue; + } + + /* split off the command and value */ + command = g_strstrip (g_strndup (string->str, colon - string->str)); + + value = colon + 1; + while (*value && g_ascii_isspace (*value)) value++; + + if (!g_ascii_strcasecmp (value, "false")) { + zenity_progress_pulsate_stop (); + + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), + progress_data->percentage / 100.0); + } else { + zenity_progress_pulsate_start (progress_bar); + } + + g_free (command); } else { if (!g_ascii_isdigit (*(string->str))) @@ -134,14 +161,17 @@ zenity_progress_handle_stdin (GIOChannel *channel, GObject *button; button = gtk_builder_get_object(builder, "zenity_progress_ok_button"); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); + progress_data->percentage = 100; gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE); gtk_widget_grab_focus(GTK_WIDGET (button)); if (progress_data->autoclose) { zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit(); } - } else + } else { gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), percentage / 100.0); + progress_data->percentage = percentage; + } } } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN);