Add --auto-close option to progress dialog. Closes dialog when 100% has been reached. Also update docs for new option. Fixes #114125.

This commit is contained in:
Mike Newman 2003-06-03 21:52:16 +00:00
parent 6a498549f7
commit 626d95b752
6 changed files with 46 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2003-06-03 Mike Newman <mikegtn@gnome.org>
* data/zenity.1: Update docs for --auto-close progress dialog
* help/C/zenity.xml: option.
2003-06-03 Mike Newman <mikegtn@gnome.org> 2003-06-03 Mike Newman <mikegtn@gnome.org>
* src/gdialog.in: add a --help option, pointing to * src/gdialog.in: add a --help option, pointing to
@ -7,6 +12,12 @@
* configure.in: Added "ko" to ALL_LINGUAS. * configure.in: Added "ko" to ALL_LINGUAS.
2003-06-01 Mike Newman <mikegtn@gnome.org>
* src/main.c: Implement --auto-close for --progress, which
* src/progress.c: behaves as if OK was clicked when reaching 100%
* src/zenity.h: Fixes #114125
2003-05-29 Glynn Foster <glynn.foster@sun.com> 2003-05-29 Glynn Foster <glynn.foster@sun.com>
* configure.in: release 1.3 * configure.in: release 1.3

View File

@ -149,6 +149,9 @@ Set the dialog text
.B \-\-percentage=INT .B \-\-percentage=INT
Set initial percentage Set initial percentage
.TP .TP
.B \-\-auto\-close
Close dialog when 100% has been reached
.TP
.B \-\-pulsate .B \-\-pulsate
Pulsate progress bar Pulsate progress bar

View File

@ -709,6 +709,13 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><varname>--auto-close</varname></term>
<listitem>
<para>Closes the progress dialog when 100% has been reached.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><varname>--pulsate</varname></term> <term><varname>--pulsate</varname></term>
<listitem> <listitem>

View File

@ -97,6 +97,7 @@ enum {
OPTION_PROGRESSTEXT, OPTION_PROGRESSTEXT,
OPTION_PERCENTAGE, OPTION_PERCENTAGE,
OPTION_PULSATE, OPTION_PULSATE,
OPTION_AUTOCLOSE,
OPTION_QUESTIONTEXT, OPTION_QUESTIONTEXT,
OPTION_WARNINGTEXT, OPTION_WARNINGTEXT,
OPTION_ABOUT, OPTION_ABOUT,
@ -520,6 +521,15 @@ struct poptOption progress_options[] = {
N_("Pulsate progress bar"), N_("Pulsate progress bar"),
NULL NULL
}, },
{
"auto-close",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_AUTOCLOSE,
N_("Dismiss the dialog when 100% has been reached"),
NULL
},
POPT_TABLEEND POPT_TABLEEND
}; };
@ -917,6 +927,7 @@ zenity_init_parsing_options (void) {
results->tree_data->separator = g_strdup ("/"); results->tree_data->separator = g_strdup ("/");
results->progress_data->percentage = -1; results->progress_data->percentage = -1;
results->progress_data->pulsate = FALSE; results->progress_data->pulsate = FALSE;
results->progress_data->autoclose = FALSE;
results->entry_data->visible = TRUE; results->entry_data->visible = TRUE;
results->tree_data->checkbox = FALSE; results->tree_data->checkbox = FALSE;
results->tree_data->radiobox = FALSE; results->tree_data->radiobox = FALSE;
@ -1373,6 +1384,12 @@ zenity_parse_options_callback (poptContext ctx,
results->progress_data->pulsate = TRUE; results->progress_data->pulsate = TRUE;
break; break;
case OPTION_AUTOCLOSE:
if (results->mode != MODE_PROGRESS)
zenity_error ("--auto-close", ERROR_SUPPORT);
results->progress_data->autoclose = TRUE;
break;
case OPTION_ABOUT: case OPTION_ABOUT:
if (results->mode != MODE_LAST) if (results->mode != MODE_LAST)
zenity_error (NULL, ERROR_DIALOG); zenity_error (NULL, ERROR_DIALOG);

View File

@ -28,7 +28,7 @@
static guint timer; static guint timer;
static GladeXML *glade_dialog; static GladeXML *glade_dialog;
static ZenityData *zen_data;
static GIOChannel *channel; static GIOChannel *channel;
gint zenity_progress_timeout (gpointer data); 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_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0);
gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE); gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE);
gtk_widget_grab_focus(GTK_WIDGET (button)); gtk_widget_grab_focus(GTK_WIDGET (button));
if (progress_data->autoclose) {
zen_data->exit_code = 0;
gtk_main_quit();
}
} else } else
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), percentage / 100.0); 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; GtkWidget *progress_bar;
guint input; guint input;
zen_data = data;
glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog"); glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog");
if (glade_dialog == NULL) { if (glade_dialog == NULL) {
@ -207,8 +213,6 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
static void static void
zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data)
{ {
ZenityData *zen_data = data;
switch (response) { switch (response) {
case GTK_RESPONSE_OK: case GTK_RESPONSE_OK:
zen_data->exit_code = 0; zen_data->exit_code = 0;

View File

@ -65,6 +65,7 @@ typedef struct {
gchar *dialog_text; gchar *dialog_text;
gchar *entry_text; gchar *entry_text;
gboolean pulsate; gboolean pulsate;
gboolean autoclose;
gdouble percentage; gdouble percentage;
} ZenityProgressData; } ZenityProgressData;