add "auto-kill" option to progress dialog. Now the user can choose whether

2006-12-02  Lucas Rocha  <lucasr@gnome.org>

	* src/zenity.h, src/progress.c, src/option.c: add "auto-kill" option
	to progress dialog. Now the user can choose whether to kill parent
	process or not (Fixes bug #310824). Patch from Diego Escalante Urrelo
	<diego@aureal.com.pe>.
This commit is contained in:
Lucas Rocha 2006-12-02 10:54:45 +00:00 committed by Lucas Almeida Rocha
parent 4d9c0448f5
commit 09c4a49800
4 changed files with 41 additions and 7 deletions

View File

@ -1,8 +1,15 @@
2006-12-02 Lucas Rocha <lucasr@gnome.org>
* src/zenity.h, src/progress.c, src/option.c: add "auto-kill" option
to progress dialog. Now the user can choose whether to kill parent
process or not (Fixes bug #310824). Patch from Diego Escalante Urrelo
<diego@aureal.com.pe>.
2006-12-02 Lucas Rocha <lucasr@gnome.org> 2006-12-02 Lucas Rocha <lucasr@gnome.org>
* src/zenity.glade: don't show cancel button on warning dialog (Fixes * src/zenity.glade: don't show cancel button on warning dialog (Fixes
bug #324100). Patch from Claudio Saavedra bug #324100). Patch from Claudio Saavedra
<csaavedra@alumnos.utalca.cl> <csaavedra@alumnos.utalca.cl>.
2006-10-02 Guilherme de S. Pastore <gpastore@gnome.org> 2006-10-02 Guilherme de S. Pastore <gpastore@gnome.org>

View File

@ -82,6 +82,7 @@ static gboolean zenity_progress_active;
static int zenity_progress_percentage; static int zenity_progress_percentage;
static gboolean zenity_progress_pulsate; static gboolean zenity_progress_pulsate;
static gboolean zenity_progress_auto_close; static gboolean zenity_progress_auto_close;
static gboolean zenity_progress_auto_kill;
/* Question Dialog Options */ /* Question Dialog Options */
static gboolean zenity_question_active; static gboolean zenity_question_active;
@ -561,6 +562,16 @@ static GOptionEntry progress_options[] = {
N_("Dismiss the dialog when 100% has been reached"), N_("Dismiss the dialog when 100% has been reached"),
NULL NULL
}, },
{
"auto-kill",
'\0',
0,
G_OPTION_ARG_NONE,
&zenity_progress_auto_kill,
/* xgettext: no-c-format */
N_("Kill parent process if cancel button is pressed"),
NULL
},
{ {
NULL NULL
} }
@ -974,6 +985,7 @@ zenity_progress_pre_callback (GOptionContext *context,
zenity_progress_percentage = 0; zenity_progress_percentage = 0;
zenity_progress_pulsate = FALSE; zenity_progress_pulsate = FALSE;
zenity_progress_auto_close = FALSE; zenity_progress_auto_close = FALSE;
zenity_progress_auto_kill = FALSE;
return TRUE; return TRUE;
} }
@ -1282,6 +1294,7 @@ zenity_progress_post_callback (GOptionContext *context,
results->progress_data->dialog_text = zenity_general_dialog_text; results->progress_data->dialog_text = zenity_general_dialog_text;
results->progress_data->pulsate = zenity_progress_pulsate; results->progress_data->pulsate = zenity_progress_pulsate;
results->progress_data->autoclose = zenity_progress_auto_close; results->progress_data->autoclose = zenity_progress_auto_close;
results->progress_data->autokill = zenity_progress_auto_kill;
results->progress_data->percentage = zenity_progress_percentage; results->progress_data->percentage = zenity_progress_percentage;
} else { } else {
if (zenity_progress_pulsate) if (zenity_progress_pulsate)
@ -1295,6 +1308,10 @@ zenity_progress_post_callback (GOptionContext *context,
if (zenity_progress_auto_close) if (zenity_progress_auto_close)
zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_auto_close), zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_auto_close),
ERROR_SUPPORT); ERROR_SUPPORT);
if (zenity_progress_auto_kill)
zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_auto_kill),
ERROR_SUPPORT);
} }
return TRUE; return TRUE;

View File

@ -37,6 +37,8 @@ static GladeXML *glade_dialog;
static ZenityData *zen_data; static ZenityData *zen_data;
static GIOChannel *channel; static GIOChannel *channel;
static gboolean autokill;
gint zenity_progress_timeout (gpointer data); gint zenity_progress_timeout (gpointer data);
gint zenity_progress_pulsate_timeout (gpointer data); gint zenity_progress_pulsate_timeout (gpointer data);
@ -214,6 +216,8 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar),
progress_data->percentage/100.0); progress_data->percentage/100.0);
autokill = progress_data->autokill;
zenity_util_show_dialog (dialog); zenity_util_show_dialog (dialog);
zenity_progress_read_info (progress_data); zenity_progress_read_info (progress_data);
@ -229,11 +233,16 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data)
break; break;
case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_CANCEL:
/* FIXME: This should kill off the parent process nicely and return an error code /* We do not want to kill the parent process, in order to give the user
* I'm pretty sure there is a nice way to do this, but I'm clueless about this the ability to choose the action to be taken. See bug #310824.
* stuff. Should be using SIGHUP instead of 1 though. -- Monday 27, March 2006
*/ But we want to give people the option to choose this behavior.
kill (getppid (), 1); */
if (autokill) {
kill (getppid (), 1);
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
break;
}
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
break; break;

View File

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