summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c17
-rw-r--r--src/progress.c10
-rw-r--r--src/zenity.h1
3 files changed, 25 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 0a2d312b..9f990712 100644
--- a/src/main.c
+++ b/src/main.c
@@ -97,6 +97,7 @@ enum {
OPTION_PROGRESSTEXT,
OPTION_PERCENTAGE,
OPTION_PULSATE,
+ OPTION_AUTOCLOSE,
OPTION_QUESTIONTEXT,
OPTION_WARNINGTEXT,
OPTION_ABOUT,
@@ -520,6 +521,15 @@ struct poptOption progress_options[] = {
N_("Pulsate progress bar"),
NULL
},
+ {
+ "auto-close",
+ '\0',
+ POPT_ARG_NONE,
+ NULL,
+ OPTION_AUTOCLOSE,
+ N_("Dismiss the dialog when 100% has been reached"),
+ NULL
+ },
POPT_TABLEEND
};
@@ -917,6 +927,7 @@ zenity_init_parsing_options (void) {
results->tree_data->separator = g_strdup ("/");
results->progress_data->percentage = -1;
results->progress_data->pulsate = FALSE;
+ results->progress_data->autoclose = FALSE;
results->entry_data->visible = TRUE;
results->tree_data->checkbox = FALSE;
results->tree_data->radiobox = FALSE;
@@ -1373,6 +1384,12 @@ zenity_parse_options_callback (poptContext ctx,
results->progress_data->pulsate = TRUE;
break;
+ case OPTION_AUTOCLOSE:
+ if (results->mode != MODE_PROGRESS)
+ zenity_error ("--auto-close", ERROR_SUPPORT);
+
+ results->progress_data->autoclose = TRUE;
+ break;
case OPTION_ABOUT:
if (results->mode != MODE_LAST)
zenity_error (NULL, ERROR_DIALOG);
diff --git a/src/progress.c b/src/progress.c
index aa06e7d4..dc0d74b3 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -28,7 +28,7 @@
static guint timer;
static GladeXML *glade_dialog;
-
+static ZenityData *zen_data;
static GIOChannel *channel;
gint zenity_progress_timeout (gpointer data);
@@ -111,6 +111,11 @@ zenity_progress_handle_stdin (GIOChannel *channel,
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0);
gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE);
gtk_widget_grab_focus(GTK_WIDGET (button));
+ if (progress_data->autoclose) {
+ zen_data->exit_code = 0;
+ gtk_main_quit();
+
+ }
} else
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), percentage / 100.0);
}
@@ -165,6 +170,7 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
GtkWidget *progress_bar;
guint input;
+ zen_data = data;
glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog");
if (glade_dialog == NULL) {
@@ -207,8 +213,6 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
static void
zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data)
{
- ZenityData *zen_data = data;
-
switch (response) {
case GTK_RESPONSE_OK:
zen_data->exit_code = 0;
diff --git a/src/zenity.h b/src/zenity.h
index 95f477ca..e96f5285 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -65,6 +65,7 @@ typedef struct {
gchar *dialog_text;
gchar *entry_text;
gboolean pulsate;
+ gboolean autoclose;
gdouble percentage;
} ZenityProgressData;
bgstack15