Fix up the date string, although I guess this should be localized.
2003-01-09 Glynn Foster <glynn.foster@sun.com> * src/calendar.c: Fix up the date string, although I guess this should be localized. * src/main.c: Add a new --pulsate option, which reads from stdin and pulsates the progress bar until we reach EOF. * src/progress.c: Rewrite to actually work. Don't really need GIOChannels here. * TODO: Updated accordingly.
This commit is contained in:
parent
6a65d75921
commit
cd4e438bfb
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2003-01-09 Glynn Foster <glynn.foster@sun.com>
|
||||||
|
|
||||||
|
* src/calendar.c: Fix up the date string, although I guess
|
||||||
|
this should be localized.
|
||||||
|
|
||||||
|
* src/main.c: Add a new --pulsate option, which reads from
|
||||||
|
stdin and pulsates the progress bar until we reach EOF.
|
||||||
|
* src/progress.c: Rewrite to actually work. Don't really need
|
||||||
|
GIOChannels here.
|
||||||
|
|
||||||
|
* TODO: Updated accordingly.
|
||||||
|
|
||||||
2003-01-07 Glynn Foster <glynn.foster@sun.com>
|
2003-01-07 Glynn Foster <glynn.foster@sun.com>
|
||||||
|
|
||||||
* src/calendar.c, src/entry.c, src/fileselection.c,
|
* src/calendar.c, src/entry.c, src/fileselection.c,
|
||||||
|
1
TODO
1
TODO
@ -1,4 +1,3 @@
|
|||||||
* Finish off support for progress dialog
|
|
||||||
* Implement return values for all dialogs
|
* Implement return values for all dialogs
|
||||||
* All done, except for list view
|
* All done, except for list view
|
||||||
* Add some accessibility I guess
|
* Add some accessibility I guess
|
||||||
|
@ -86,7 +86,7 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data)
|
|||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year);
|
gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year);
|
||||||
g_printerr ("%02d/%02d/%02d\n", day, month + 1, year);
|
g_printerr ("%02d/%02d/%02d\n", year, month + 1, day);
|
||||||
zen_data->exit_code = 0;
|
zen_data->exit_code = 0;
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
19
src/main.c
19
src/main.c
@ -80,6 +80,7 @@ enum {
|
|||||||
OPTION_RADIOLIST,
|
OPTION_RADIOLIST,
|
||||||
OPTION_PROGRESSTEXT,
|
OPTION_PROGRESSTEXT,
|
||||||
OPTION_PERCENTAGE,
|
OPTION_PERCENTAGE,
|
||||||
|
OPTION_PULSATE,
|
||||||
OPTION_QUESTIONTEXT,
|
OPTION_QUESTIONTEXT,
|
||||||
OPTION_TEXTFILE,
|
OPTION_TEXTFILE,
|
||||||
OPTION_WARNINGTEXT,
|
OPTION_WARNINGTEXT,
|
||||||
@ -451,6 +452,15 @@ struct poptOption progress_options[] = {
|
|||||||
N_("Set initial percentage"),
|
N_("Set initial percentage"),
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"pulsate",
|
||||||
|
'\0',
|
||||||
|
POPT_ARG_NONE,
|
||||||
|
NULL,
|
||||||
|
OPTION_PULSATE,
|
||||||
|
N_("Pulsate progress bar"),
|
||||||
|
NULL
|
||||||
|
},
|
||||||
POPT_TABLEEND
|
POPT_TABLEEND
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -696,6 +706,7 @@ zenity_init_parsing_options (void) {
|
|||||||
results->calendar_data->year = 0;
|
results->calendar_data->year = 0;
|
||||||
results->calendar_data->dialog_text = NULL;
|
results->calendar_data->dialog_text = NULL;
|
||||||
results->progress_data->percentage = -1;
|
results->progress_data->percentage = -1;
|
||||||
|
results->progress_data->pulsate = 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;
|
||||||
@ -1094,6 +1105,14 @@ void zenity_parse_options_callback (poptContext ctx,
|
|||||||
}
|
}
|
||||||
results->progress_data->percentage = atoi (arg);
|
results->progress_data->percentage = atoi (arg);
|
||||||
break;
|
break;
|
||||||
|
case OPTION_PULSATE:
|
||||||
|
if (results->mode != MODE_PROGRESS) {
|
||||||
|
g_printerr (_("--pulsate is not supported for this dialog\n"));
|
||||||
|
zenity_free_parsing_options ();
|
||||||
|
exit (-1);
|
||||||
|
}
|
||||||
|
results->progress_data->pulsate = TRUE;
|
||||||
|
break;
|
||||||
case OPTION_ABOUT:
|
case OPTION_ABOUT:
|
||||||
if (results->mode != MODE_LAST) {
|
if (results->mode != MODE_LAST) {
|
||||||
g_printerr (_("Two or more dialog options specified\n"));
|
g_printerr (_("Two or more dialog options specified\n"));
|
||||||
|
104
src/progress.c
104
src/progress.c
@ -29,25 +29,17 @@
|
|||||||
static guint timer;
|
static guint timer;
|
||||||
static GladeXML *glade_dialog;
|
static GladeXML *glade_dialog;
|
||||||
|
|
||||||
static gboolean zenity_progress_pulsate_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data);
|
gint zenity_progress_timeout (gpointer data);
|
||||||
static gboolean zenity_progress_increment_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data);
|
gint zenity_progress_pulsate_timeout (gpointer data);
|
||||||
|
|
||||||
static void zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data);
|
||||||
|
|
||||||
gint
|
|
||||||
zenity_progress_timeout (gpointer data)
|
|
||||||
{
|
|
||||||
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
|
zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *text;
|
GtkWidget *text;
|
||||||
GtkWidget *progress_bar;
|
GtkWidget *progress_bar;
|
||||||
GIOChannel *giochannel;
|
|
||||||
guint input;
|
guint input;
|
||||||
|
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog");
|
||||||
@ -78,49 +70,89 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
|
|||||||
|
|
||||||
progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar");
|
progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar");
|
||||||
|
|
||||||
if (glade_dialog)
|
if (progress_data->percentage > -1)
|
||||||
g_object_unref (glade_dialog);
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar),
|
||||||
|
progress_data->percentage/100.0);
|
||||||
|
|
||||||
giochannel = g_io_channel_unix_new (0);
|
|
||||||
|
|
||||||
if (progress_data->pulsate != TRUE && progress_data->percentage > -1) {
|
|
||||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), progress_data->percentage/100.0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
input = g_io_add_watch (giochannel, G_IO_IN | G_IO_HUP, zenity_progress_pulsate_bar, NULL);
|
|
||||||
timer = gtk_timeout_add (100, zenity_progress_timeout, progress_bar);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_io_channel_unref (giochannel);
|
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (dialog);
|
||||||
|
if (progress_data->pulsate != TRUE)
|
||||||
|
timer = gtk_timeout_add (100, zenity_progress_timeout, progress_bar);
|
||||||
|
else
|
||||||
|
timer = gtk_timeout_add (100, zenity_progress_pulsate_timeout, progress_bar);
|
||||||
|
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
gint
|
||||||
zenity_progress_pulsate_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data)
|
zenity_progress_timeout (gpointer data)
|
||||||
{
|
{
|
||||||
gchar buf[1024];
|
gchar buffer[256];
|
||||||
|
float percentage;
|
||||||
|
|
||||||
if (!feof (stdin)) {
|
while(gtk_events_pending()) {
|
||||||
|
gtk_main_iteration();
|
||||||
|
|
||||||
|
if (timer == 0)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scanf ("%255s", buffer) == EOF) {
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
gtk_timeout_remove (timer);
|
|
||||||
g_io_channel_shutdown (giochannel, 0, NULL);
|
|
||||||
button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button");
|
button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button");
|
||||||
gtk_widget_set_sensitive (button, TRUE);
|
gtk_widget_set_sensitive (button, TRUE);
|
||||||
gtk_widget_grab_focus (button);
|
gtk_widget_grab_focus (button);
|
||||||
|
|
||||||
button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button");
|
button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button");
|
||||||
gtk_widget_set_sensitive (button, FALSE);
|
gtk_widget_set_sensitive (button, FALSE);
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
fgets (buf, sizeof (buf)-1, stdin);
|
if (glade_dialog)
|
||||||
return TRUE;
|
g_object_unref (glade_dialog);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
percentage = atoi (buffer);
|
||||||
|
|
||||||
|
if (percentage > 100)
|
||||||
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0);
|
||||||
|
else
|
||||||
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), percentage / 100.0);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
gint
|
||||||
zenity_progress_increment_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data)
|
zenity_progress_pulsate_timeout (gpointer data)
|
||||||
{
|
{
|
||||||
/* FIXME: Do nothing at the moment */
|
|
||||||
|
while(gtk_events_pending()) {
|
||||||
|
gtk_main_iteration();
|
||||||
|
|
||||||
|
if (timer == 0)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (feof (stdin)) {
|
||||||
|
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
GtkWidget *button;
|
||||||
|
|
||||||
|
/* We stop the pulsating and switch the focus on the dialog buttons */
|
||||||
|
|
||||||
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0);
|
||||||
|
|
||||||
|
button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button");
|
||||||
|
gtk_widget_set_sensitive (button, TRUE);
|
||||||
|
gtk_widget_grab_focus (button);
|
||||||
|
|
||||||
|
button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button");
|
||||||
|
gtk_widget_set_sensitive (button, FALSE);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user