Finish off the indentation cleanup. Add new '--width' and '--height'
2003-04-13 Glynn Foster <glynn.foster@sun.com> * src/calendar.c, src/entry.c, src/fileselection.c, src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c, src/zenity.h: Finish off the indentation cleanup. Add new '--width' and '--height' options to the general options. Fix up the radio list view, so that we can now act like a radio button group. * TODO: Update
This commit is contained in:
parent
58ed174842
commit
965c2a9149
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2003-04-13 Glynn Foster <glynn.foster@sun.com>
|
||||||
|
|
||||||
|
* src/calendar.c, src/entry.c, src/fileselection.c,
|
||||||
|
src/main.c, src/msg.c, src/progress.c, src/text.c,
|
||||||
|
src/tree.c, src/zenity.h: Finish off the indentation cleanup.
|
||||||
|
Add new '--width' and '--height' options to the general options.
|
||||||
|
Fix up the radio list view, so that we can now act like a radio
|
||||||
|
button group.
|
||||||
|
|
||||||
|
* TODO: Update
|
||||||
|
|
||||||
2003-04-08 Alessio Frusciante <algol@firenze.linux.it>
|
2003-04-08 Alessio Frusciante <algol@firenze.linux.it>
|
||||||
|
|
||||||
* configure.in: Added "it" (Italian) to ALL_LINGUAS.
|
* configure.in: Added "it" (Italian) to ALL_LINGUAS.
|
||||||
|
2
TODO
2
TODO
@ -1 +1,3 @@
|
|||||||
|
* List dialog should read data from stdin
|
||||||
|
* Fix up progress dialog so that it actually works
|
||||||
* Add some accessibility I guess
|
* Add some accessibility I guess
|
||||||
|
@ -63,6 +63,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
|
|||||||
else
|
else
|
||||||
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png"));
|
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png"));
|
||||||
|
|
||||||
|
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
||||||
|
|
||||||
text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text");
|
text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text");
|
||||||
|
|
||||||
if (cal_data->dialog_text)
|
if (cal_data->dialog_text)
|
||||||
|
@ -59,6 +59,8 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
|
|||||||
else
|
else
|
||||||
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png"));
|
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png"));
|
||||||
|
|
||||||
|
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
||||||
|
|
||||||
text = glade_xml_get_widget (glade_dialog, "zenity_entry_text");
|
text = glade_xml_get_widget (glade_dialog, "zenity_entry_text");
|
||||||
|
|
||||||
if (entry_data->dialog_text)
|
if (entry_data->dialog_text)
|
||||||
|
@ -57,6 +57,8 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data)
|
|||||||
else
|
else
|
||||||
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png"));
|
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png"));
|
||||||
|
|
||||||
|
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
||||||
|
|
||||||
if (file_data->uri)
|
if (file_data->uri)
|
||||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri);
|
gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri);
|
||||||
|
|
||||||
|
519
src/main.c
519
src/main.c
@ -76,6 +76,8 @@ enum {
|
|||||||
OPTION_WARNING,
|
OPTION_WARNING,
|
||||||
OPTION_TITLE,
|
OPTION_TITLE,
|
||||||
OPTION_ICON,
|
OPTION_ICON,
|
||||||
|
OPTION_WIDTH,
|
||||||
|
OPTION_HEIGHT,
|
||||||
OPTION_CALENDARTEXT,
|
OPTION_CALENDARTEXT,
|
||||||
OPTION_DAY,
|
OPTION_DAY,
|
||||||
OPTION_MONTH,
|
OPTION_MONTH,
|
||||||
@ -86,6 +88,7 @@ enum {
|
|||||||
OPTION_ERRORTEXT,
|
OPTION_ERRORTEXT,
|
||||||
OPTION_INFOTEXT,
|
OPTION_INFOTEXT,
|
||||||
OPTION_FILENAME,
|
OPTION_FILENAME,
|
||||||
|
OPTION_TEXTFILENAME,
|
||||||
OPTION_COLUMN,
|
OPTION_COLUMN,
|
||||||
OPTION_SEPERATOR,
|
OPTION_SEPERATOR,
|
||||||
OPTION_LISTEDIT,
|
OPTION_LISTEDIT,
|
||||||
@ -95,7 +98,6 @@ enum {
|
|||||||
OPTION_PERCENTAGE,
|
OPTION_PERCENTAGE,
|
||||||
OPTION_PULSATE,
|
OPTION_PULSATE,
|
||||||
OPTION_QUESTIONTEXT,
|
OPTION_QUESTIONTEXT,
|
||||||
OPTION_TEXTFILE,
|
|
||||||
OPTION_WARNINGTEXT,
|
OPTION_WARNINGTEXT,
|
||||||
OPTION_ABOUT,
|
OPTION_ABOUT,
|
||||||
OPTION_VERSION,
|
OPTION_VERSION,
|
||||||
@ -239,6 +241,24 @@ struct poptOption general_options[] = {
|
|||||||
N_("Set the window icon"),
|
N_("Set the window icon"),
|
||||||
N_("ICONPATH")
|
N_("ICONPATH")
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"width",
|
||||||
|
'\0',
|
||||||
|
POPT_ARG_STRING,
|
||||||
|
NULL,
|
||||||
|
OPTION_WIDTH,
|
||||||
|
N_("Set the width"),
|
||||||
|
N_("WIDTH")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height",
|
||||||
|
'\0',
|
||||||
|
POPT_ARG_STRING,
|
||||||
|
NULL,
|
||||||
|
OPTION_HEIGHT,
|
||||||
|
N_("Set the height"),
|
||||||
|
N_("HEIGHT")
|
||||||
|
},
|
||||||
POPT_TABLEEND
|
POPT_TABLEEND
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -531,7 +551,7 @@ struct poptOption text_options[] = {
|
|||||||
'\0',
|
'\0',
|
||||||
POPT_ARG_STRING,
|
POPT_ARG_STRING,
|
||||||
NULL,
|
NULL,
|
||||||
OPTION_TEXTFILE,
|
OPTION_TEXTFILENAME,
|
||||||
N_("Open file"),
|
N_("Open file"),
|
||||||
N_("FILENAME")
|
N_("FILENAME")
|
||||||
},
|
},
|
||||||
@ -886,6 +906,8 @@ zenity_init_parsing_options (void) {
|
|||||||
results->tree_data = g_new0 (ZenityTreeData, 1);
|
results->tree_data = g_new0 (ZenityTreeData, 1);
|
||||||
|
|
||||||
/* Give some sensible defaults */
|
/* Give some sensible defaults */
|
||||||
|
results->data->width = -1;
|
||||||
|
results->data->height = -1;
|
||||||
results->calendar_data->date_format = g_strdup (nl_langinfo (D_FMT));
|
results->calendar_data->date_format = g_strdup (nl_langinfo (D_FMT));
|
||||||
results->calendar_data->day = 0;
|
results->calendar_data->day = 0;
|
||||||
results->calendar_data->month = 0;
|
results->calendar_data->month = 0;
|
||||||
@ -979,7 +1001,7 @@ main (gint argc, gchar **argv) {
|
|||||||
|
|
||||||
if (nextopt != -1) {
|
if (nextopt != -1) {
|
||||||
g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"),
|
g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"),
|
||||||
poptBadOption (ctx, 0));
|
poptBadOption (ctx, 0));
|
||||||
zenity_free_parsing_options ();
|
zenity_free_parsing_options ();
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
@ -1070,290 +1092,303 @@ zenity_parse_options_callback (poptContext ctx,
|
|||||||
static gint parse_option_file = 0;
|
static gint parse_option_file = 0;
|
||||||
static gint parse_option_editable = 0;
|
static gint parse_option_editable = 0;
|
||||||
|
|
||||||
if (reason == POPT_CALLBACK_REASON_POST) {
|
if (reason == POPT_CALLBACK_REASON_POST)
|
||||||
return;
|
return;
|
||||||
}
|
else if (reason != POPT_CALLBACK_REASON_OPTION)
|
||||||
else if (reason != POPT_CALLBACK_REASON_OPTION)
|
return;
|
||||||
return;
|
|
||||||
|
|
||||||
switch (opt->val & POPT_ARG_MASK) {
|
switch (opt->val & POPT_ARG_MASK) {
|
||||||
|
|
||||||
case OPTION_CALENDAR:
|
case OPTION_CALENDAR:
|
||||||
if (results->mode != MODE_LAST)
|
if (results->mode != MODE_LAST)
|
||||||
zenity_error (NULL, ERROR_DIALOG);
|
zenity_error (NULL, ERROR_DIALOG);
|
||||||
|
|
||||||
results->mode = MODE_CALENDAR;
|
results->mode = MODE_CALENDAR;
|
||||||
break;
|
break;
|
||||||
case OPTION_ENTRY:
|
case OPTION_ENTRY:
|
||||||
if (results->mode != MODE_LAST)
|
if (results->mode != MODE_LAST)
|
||||||
zenity_error (NULL, ERROR_DIALOG);
|
zenity_error (NULL, ERROR_DIALOG);
|
||||||
|
|
||||||
results->mode = MODE_ENTRY;
|
results->mode = MODE_ENTRY;
|
||||||
break;
|
break;
|
||||||
case OPTION_ERROR:
|
case OPTION_ERROR:
|
||||||
if (results->mode != MODE_LAST)
|
if (results->mode != MODE_LAST)
|
||||||
zenity_error (NULL, ERROR_DIALOG);
|
zenity_error (NULL, ERROR_DIALOG);
|
||||||
|
|
||||||
results->mode = MODE_ERROR;
|
results->mode = MODE_ERROR;
|
||||||
results->msg_data->mode = ZENITY_MSG_ERROR;
|
results->msg_data->mode = ZENITY_MSG_ERROR;
|
||||||
break;
|
break;
|
||||||
case OPTION_INFO:
|
case OPTION_INFO:
|
||||||
if (results->mode != MODE_LAST)
|
if (results->mode != MODE_LAST)
|
||||||
zenity_error (NULL, ERROR_DIALOG);
|
zenity_error (NULL, ERROR_DIALOG);
|
||||||
|
|
||||||
results->mode = MODE_INFO;
|
results->mode = MODE_INFO;
|
||||||
results->msg_data->mode = ZENITY_MSG_INFO;
|
results->msg_data->mode = ZENITY_MSG_INFO;
|
||||||
break;
|
break;
|
||||||
case OPTION_FILE:
|
case OPTION_FILE:
|
||||||
if (results->mode != MODE_LAST)
|
if (results->mode != MODE_LAST)
|
||||||
zenity_error (NULL, ERROR_DIALOG);
|
zenity_error (NULL, ERROR_DIALOG);
|
||||||
|
|
||||||
results->mode = MODE_FILE;
|
results->mode = MODE_FILE;
|
||||||
break;
|
break;
|
||||||
case OPTION_LIST:
|
case OPTION_LIST:
|
||||||
if (results->mode != MODE_LAST)
|
if (results->mode != MODE_LAST)
|
||||||
zenity_error (NULL, ERROR_DIALOG);
|
zenity_error (NULL, ERROR_DIALOG);
|
||||||
|
|
||||||
results->mode = MODE_LIST;
|
results->mode = MODE_LIST;
|
||||||
break;
|
break;
|
||||||
case OPTION_PROGRESS:
|
case OPTION_PROGRESS:
|
||||||
if (results->mode != MODE_LAST)
|
if (results->mode != MODE_LAST)
|
||||||
zenity_error (NULL, ERROR_DIALOG);
|
zenity_error (NULL, ERROR_DIALOG);
|
||||||
|
|
||||||
results->mode = MODE_PROGRESS;
|
results->mode = MODE_PROGRESS;
|
||||||
break;
|
break;
|
||||||
case OPTION_QUESTION:
|
case OPTION_QUESTION:
|
||||||
if (results->mode != MODE_LAST)
|
if (results->mode != MODE_LAST)
|
||||||
zenity_error (NULL, ERROR_DIALOG);
|
zenity_error (NULL, ERROR_DIALOG);
|
||||||
|
|
||||||
results->mode = MODE_QUESTION;
|
results->mode = MODE_QUESTION;
|
||||||
results->msg_data->mode = ZENITY_MSG_QUESTION;
|
results->msg_data->mode = ZENITY_MSG_QUESTION;
|
||||||
break;
|
break;
|
||||||
case OPTION_TEXTINFO:
|
case OPTION_TEXTINFO:
|
||||||
if (results->mode != MODE_LAST)
|
if (results->mode != MODE_LAST)
|
||||||
zenity_error (NULL, ERROR_DIALOG);
|
zenity_error (NULL, ERROR_DIALOG);
|
||||||
|
|
||||||
results->mode = MODE_TEXTINFO;
|
results->mode = MODE_TEXTINFO;
|
||||||
break;
|
break;
|
||||||
case OPTION_WARNING:
|
case OPTION_WARNING:
|
||||||
if (results->mode != MODE_LAST)
|
if (results->mode != MODE_LAST)
|
||||||
zenity_error (NULL, ERROR_DIALOG);
|
zenity_error (NULL, ERROR_DIALOG);
|
||||||
|
|
||||||
results->mode = MODE_WARNING;
|
results->mode = MODE_WARNING;
|
||||||
results->msg_data->mode = ZENITY_MSG_WARNING;
|
results->msg_data->mode = ZENITY_MSG_WARNING;
|
||||||
break;
|
break;
|
||||||
case OPTION_TITLE:
|
case OPTION_TITLE:
|
||||||
if (results->data->dialog_title != NULL)
|
if (results->data->dialog_title != NULL)
|
||||||
zenity_error ("--title", ERROR_DUPLICATE);
|
zenity_error ("--title", ERROR_DUPLICATE);
|
||||||
|
|
||||||
results->data->dialog_title = g_strdup (arg);
|
results->data->dialog_title = g_strdup (arg);
|
||||||
break;
|
break;
|
||||||
case OPTION_ICON:
|
case OPTION_ICON:
|
||||||
if (results->data->window_icon != NULL)
|
if (results->data->window_icon != NULL)
|
||||||
zenity_error ("--window-icon", ERROR_DUPLICATE);
|
zenity_error ("--window-icon", ERROR_DUPLICATE);
|
||||||
|
|
||||||
results->data->window_icon = g_strdup (arg);
|
results->data->window_icon = g_strdup (arg);
|
||||||
break;
|
break;
|
||||||
case OPTION_CALENDARTEXT:
|
case OPTION_WIDTH:
|
||||||
case OPTION_ENTRYTEXT:
|
if (results->data->width != -1)
|
||||||
case OPTION_ERRORTEXT:
|
zenity_error ("--width", ERROR_DUPLICATE);
|
||||||
case OPTION_QUESTIONTEXT:
|
|
||||||
case OPTION_PROGRESSTEXT:
|
|
||||||
case OPTION_WARNINGTEXT:
|
|
||||||
|
|
||||||
/* FIXME: This is an ugly hack because of the way the poptOptions are
|
results->data->width = atoi (arg);
|
||||||
* ordered above. When you try and use an --option more than once
|
break;
|
||||||
* parse_options_callback gets called for each option. Suckage
|
case OPTION_HEIGHT:
|
||||||
*/
|
if (results->data->height != -1)
|
||||||
|
zenity_error ("--height", ERROR_DUPLICATE);
|
||||||
|
|
||||||
if (parse_option_text > 6)
|
results->data->height = atoi (arg);
|
||||||
zenity_error ("--text", ERROR_DUPLICATE);
|
break;
|
||||||
|
case OPTION_CALENDARTEXT:
|
||||||
|
case OPTION_ENTRYTEXT:
|
||||||
|
case OPTION_ERRORTEXT:
|
||||||
|
case OPTION_QUESTIONTEXT:
|
||||||
|
case OPTION_PROGRESSTEXT:
|
||||||
|
case OPTION_WARNINGTEXT:
|
||||||
|
|
||||||
switch (results->mode) {
|
/* FIXME: This is an ugly hack because of the way the poptOptions are
|
||||||
case MODE_CALENDAR:
|
* ordered above. When you try and use an --option more than once
|
||||||
results->calendar_data->dialog_text = g_strdup (arg);
|
* parse_options_callback gets called for each option. Suckage
|
||||||
break;
|
*/
|
||||||
case MODE_ENTRY:
|
|
||||||
results->entry_data->dialog_text = g_strdup (arg);
|
|
||||||
break;
|
|
||||||
case MODE_ERROR:
|
|
||||||
case MODE_QUESTION:
|
|
||||||
case MODE_WARNING:
|
|
||||||
case MODE_INFO:
|
|
||||||
results->msg_data->dialog_text = g_strdup (arg);
|
|
||||||
break;
|
|
||||||
case MODE_PROGRESS:
|
|
||||||
results->progress_data->dialog_text = g_strdup (arg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
zenity_error ("--text", ERROR_SUPPORT);
|
|
||||||
}
|
|
||||||
parse_option_text++;
|
|
||||||
break;
|
|
||||||
case OPTION_DAY:
|
|
||||||
if (results->mode != MODE_CALENDAR)
|
|
||||||
zenity_error ("--day", ERROR_SUPPORT);
|
|
||||||
|
|
||||||
if (results->calendar_data->day > 0)
|
if (parse_option_text > 6)
|
||||||
zenity_error ("--day", ERROR_DUPLICATE);
|
zenity_error ("--text", ERROR_DUPLICATE);
|
||||||
|
|
||||||
results->calendar_data->day = atoi (arg);
|
switch (results->mode) {
|
||||||
break;
|
case MODE_CALENDAR:
|
||||||
case OPTION_MONTH:
|
results->calendar_data->dialog_text = g_strdup (arg);
|
||||||
if (results->mode != MODE_CALENDAR)
|
break;
|
||||||
zenity_error ("--month", ERROR_SUPPORT);
|
case MODE_ENTRY:
|
||||||
|
results->entry_data->dialog_text = g_strdup (arg);
|
||||||
|
break;
|
||||||
|
case MODE_ERROR:
|
||||||
|
case MODE_QUESTION:
|
||||||
|
case MODE_WARNING:
|
||||||
|
case MODE_INFO:
|
||||||
|
results->msg_data->dialog_text = g_strdup (arg);
|
||||||
|
break;
|
||||||
|
case MODE_PROGRESS:
|
||||||
|
results->progress_data->dialog_text = g_strdup (arg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
zenity_error ("--text", ERROR_SUPPORT);
|
||||||
|
}
|
||||||
|
parse_option_text++;
|
||||||
|
break;
|
||||||
|
case OPTION_DAY:
|
||||||
|
if (results->mode != MODE_CALENDAR)
|
||||||
|
zenity_error ("--day", ERROR_SUPPORT);
|
||||||
|
|
||||||
if (results->calendar_data->month > 0)
|
if (results->calendar_data->day > 0)
|
||||||
zenity_error ("--day", ERROR_DUPLICATE);
|
zenity_error ("--day", ERROR_DUPLICATE);
|
||||||
|
|
||||||
results->calendar_data->month = atoi (arg);
|
results->calendar_data->day = atoi (arg);
|
||||||
break;
|
break;
|
||||||
case OPTION_YEAR:
|
case OPTION_MONTH:
|
||||||
if (results->mode != MODE_CALENDAR)
|
if (results->mode != MODE_CALENDAR)
|
||||||
zenity_error ("--year", ERROR_SUPPORT);
|
zenity_error ("--month", ERROR_SUPPORT);
|
||||||
|
|
||||||
if (results->calendar_data->year > 0)
|
if (results->calendar_data->month > 0)
|
||||||
zenity_error ("--year", ERROR_DUPLICATE);
|
zenity_error ("--day", ERROR_DUPLICATE);
|
||||||
|
|
||||||
results->calendar_data->year = atoi (arg);
|
results->calendar_data->month = atoi (arg);
|
||||||
break;
|
break;
|
||||||
case OPTION_DATEFORMAT:
|
case OPTION_YEAR:
|
||||||
if (results->mode != MODE_CALENDAR)
|
if (results->mode != MODE_CALENDAR)
|
||||||
zenity_error ("--date-format", ERROR_SUPPORT);
|
zenity_error ("--year", ERROR_SUPPORT);
|
||||||
|
|
||||||
if (parse_option_dateformat)
|
if (results->calendar_data->year > 0)
|
||||||
zenity_error ("--date-format", ERROR_DUPLICATE);
|
zenity_error ("--year", ERROR_DUPLICATE);
|
||||||
|
|
||||||
results->calendar_data->date_format = g_strdup (arg);
|
results->calendar_data->year = atoi (arg);
|
||||||
parse_option_dateformat = TRUE;
|
break;
|
||||||
break;
|
case OPTION_DATEFORMAT:
|
||||||
case OPTION_INPUTTEXT:
|
if (results->mode != MODE_CALENDAR)
|
||||||
if (results->mode != MODE_ENTRY)
|
zenity_error ("--date-format", ERROR_SUPPORT);
|
||||||
zenity_error ("--entry-text", ERROR_SUPPORT);
|
|
||||||
|
|
||||||
if (results->entry_data->entry_text != NULL)
|
if (parse_option_dateformat)
|
||||||
zenity_error ("--entry-text", ERROR_DUPLICATE);
|
zenity_error ("--date-format", ERROR_DUPLICATE);
|
||||||
|
|
||||||
results->entry_data->entry_text = g_strdup (arg);
|
results->calendar_data->date_format = g_strdup (arg);
|
||||||
break;
|
parse_option_dateformat = TRUE;
|
||||||
case OPTION_HIDETEXT:
|
break;
|
||||||
if (results->mode != MODE_ENTRY)
|
case OPTION_INPUTTEXT:
|
||||||
zenity_error ("--hide-text", ERROR_SUPPORT);
|
if (results->mode != MODE_ENTRY)
|
||||||
|
zenity_error ("--entry-text", ERROR_SUPPORT);
|
||||||
|
|
||||||
if (!results->entry_data->visible)
|
if (results->entry_data->entry_text != NULL)
|
||||||
zenity_error ("--hide-text", ERROR_DUPLICATE);
|
zenity_error ("--entry-text", ERROR_DUPLICATE);
|
||||||
|
|
||||||
results->entry_data->visible = FALSE;
|
results->entry_data->entry_text = g_strdup (arg);
|
||||||
break;
|
break;
|
||||||
case OPTION_LISTEDIT:
|
case OPTION_HIDETEXT:
|
||||||
case OPTION_TEXTEDIT:
|
if (results->mode != MODE_ENTRY)
|
||||||
|
zenity_error ("--hide-text", ERROR_SUPPORT);
|
||||||
|
|
||||||
/* FIXME: This is an ugly hack because of the way the poptOptions are
|
if (!results->entry_data->visible)
|
||||||
* ordered above. When you try and use an --option more than once
|
zenity_error ("--hide-text", ERROR_DUPLICATE);
|
||||||
* parse_options_callback gets called for each option. Suckage
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (parse_option_file > 2)
|
results->entry_data->visible = FALSE;
|
||||||
zenity_error ("--editable", ERROR_DUPLICATE);
|
break;
|
||||||
|
case OPTION_LISTEDIT:
|
||||||
|
case OPTION_TEXTEDIT:
|
||||||
|
|
||||||
switch (results->mode) {
|
/* FIXME: This is an ugly hack because of the way the poptOptions are
|
||||||
case MODE_TEXTINFO:
|
* ordered above. When you try and use an --option more than once
|
||||||
results->text_data->editable = TRUE;
|
* parse_options_callback gets called for each option. Suckage
|
||||||
break;
|
*/
|
||||||
case MODE_LIST:
|
|
||||||
results->tree_data->editable = TRUE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
zenity_error ("--editable", ERROR_SUPPORT);
|
|
||||||
}
|
|
||||||
parse_option_editable++;
|
|
||||||
break;
|
|
||||||
case OPTION_FILENAME:
|
|
||||||
case OPTION_TEXTFILE:
|
|
||||||
|
|
||||||
/* FIXME: This is an ugly hack because of the way the poptOptions are
|
if (parse_option_file > 2)
|
||||||
* ordered above. When you try and use an --option more than once
|
zenity_error ("--editable", ERROR_DUPLICATE);
|
||||||
* parse_options_callback gets called for each option. Suckage
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (parse_option_file > 2)
|
switch (results->mode) {
|
||||||
zenity_error ("--filename", ERROR_DUPLICATE);
|
case MODE_TEXTINFO:
|
||||||
|
results->text_data->editable = TRUE;
|
||||||
|
break;
|
||||||
|
case MODE_LIST:
|
||||||
|
results->tree_data->editable = TRUE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
zenity_error ("--editable", ERROR_SUPPORT);
|
||||||
|
}
|
||||||
|
parse_option_editable++;
|
||||||
|
break;
|
||||||
|
case OPTION_FILENAME:
|
||||||
|
case OPTION_TEXTFILENAME:
|
||||||
|
|
||||||
switch (results->mode) {
|
/* FIXME: This is an ugly hack because of the way the poptOptions are
|
||||||
case MODE_FILE:
|
* ordered above. When you try and use an --option more than once
|
||||||
results->file_data->uri = g_strdup (arg);
|
* parse_options_callback gets called for each option. Suckage
|
||||||
break;
|
*/
|
||||||
case MODE_TEXTINFO:
|
|
||||||
results->text_data->uri = g_strdup (arg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
zenity_error ("--filename", ERROR_SUPPORT);
|
|
||||||
}
|
|
||||||
parse_option_file++;
|
|
||||||
break;
|
|
||||||
case OPTION_COLUMN:
|
|
||||||
if (results->mode != MODE_LIST)
|
|
||||||
zenity_error ("--column", ERROR_SUPPORT);
|
|
||||||
|
|
||||||
results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg));
|
if (parse_option_file > 2)
|
||||||
break;
|
zenity_error ("--filename", ERROR_DUPLICATE);
|
||||||
case OPTION_CHECKLIST:
|
|
||||||
if (results->mode != MODE_LIST)
|
|
||||||
zenity_error ("--checkbox", ERROR_SUPPORT);
|
|
||||||
|
|
||||||
if (results->tree_data->checkbox)
|
switch (results->mode) {
|
||||||
zenity_error ("--checkbox", ERROR_DUPLICATE);
|
case MODE_FILE:
|
||||||
|
results->file_data->uri = g_strdup (arg);
|
||||||
|
break;
|
||||||
|
case MODE_TEXTINFO:
|
||||||
|
results->text_data->uri = g_strdup (arg);
|
||||||
|
break;
|
||||||
|
case MODE_LIST:
|
||||||
|
results->tree_data->uri = g_strdup (arg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
zenity_error ("--filename", ERROR_SUPPORT);
|
||||||
|
}
|
||||||
|
parse_option_file++;
|
||||||
|
break;
|
||||||
|
case OPTION_COLUMN:
|
||||||
|
if (results->mode != MODE_LIST)
|
||||||
|
zenity_error ("--column", ERROR_SUPPORT);
|
||||||
|
|
||||||
results->tree_data->checkbox = TRUE;
|
results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg));
|
||||||
break;
|
break;
|
||||||
case OPTION_RADIOLIST:
|
case OPTION_CHECKLIST:
|
||||||
if (results->mode != MODE_LIST)
|
if (results->mode != MODE_LIST)
|
||||||
zenity_error ("--radiobox", ERROR_SUPPORT);
|
zenity_error ("--checkbox", ERROR_SUPPORT);
|
||||||
|
|
||||||
if (results->tree_data->radiobox)
|
if (results->tree_data->checkbox)
|
||||||
zenity_error ("--radiobox", ERROR_DUPLICATE);
|
zenity_error ("--checkbox", ERROR_DUPLICATE);
|
||||||
|
|
||||||
results->tree_data->radiobox = TRUE;
|
results->tree_data->checkbox = TRUE;
|
||||||
break;
|
break;
|
||||||
case OPTION_SEPERATOR:
|
case OPTION_RADIOLIST:
|
||||||
if (results->mode != MODE_LIST)
|
if (results->mode != MODE_LIST)
|
||||||
zenity_error ("--separator", ERROR_SUPPORT);
|
zenity_error ("--radiobox", ERROR_SUPPORT);
|
||||||
|
if (results->tree_data->radiobox)
|
||||||
|
zenity_error ("--radiobox", ERROR_DUPLICATE);
|
||||||
|
|
||||||
if (parse_option_separator)
|
results->tree_data->radiobox = TRUE;
|
||||||
zenity_error ("--separator", ERROR_DUPLICATE);
|
break;
|
||||||
|
case OPTION_SEPERATOR:
|
||||||
|
if (results->mode != MODE_LIST)
|
||||||
|
zenity_error ("--separator", ERROR_SUPPORT);
|
||||||
|
|
||||||
results->tree_data->separator = g_strdup (arg);
|
if (parse_option_separator)
|
||||||
parse_option_separator = TRUE;
|
zenity_error ("--separator", ERROR_DUPLICATE);
|
||||||
break;
|
|
||||||
case OPTION_PERCENTAGE:
|
|
||||||
if (results->mode != MODE_PROGRESS)
|
|
||||||
zenity_error ("--percentage", ERROR_SUPPORT);
|
|
||||||
|
|
||||||
if (results->progress_data->percentage > -1)
|
results->tree_data->separator = g_strdup (arg);
|
||||||
zenity_error ("--percentage", ERROR_DUPLICATE);
|
parse_option_separator = TRUE;
|
||||||
|
break;
|
||||||
|
case OPTION_PERCENTAGE:
|
||||||
|
if (results->mode != MODE_PROGRESS)
|
||||||
|
zenity_error ("--percentage", ERROR_SUPPORT);
|
||||||
|
|
||||||
results->progress_data->percentage = atoi (arg);
|
if (results->progress_data->percentage > -1)
|
||||||
break;
|
zenity_error ("--percentage", ERROR_DUPLICATE);
|
||||||
case OPTION_PULSATE:
|
|
||||||
if (results->mode != MODE_PROGRESS)
|
|
||||||
zenity_error ("--pulsate", ERROR_SUPPORT);
|
|
||||||
|
|
||||||
results->progress_data->pulsate = TRUE;
|
results->progress_data->percentage = atoi (arg);
|
||||||
break;
|
break;
|
||||||
case OPTION_ABOUT:
|
case OPTION_PULSATE:
|
||||||
if (results->mode != MODE_LAST)
|
if (results->mode != MODE_PROGRESS)
|
||||||
zenity_error (NULL, ERROR_DIALOG);
|
zenity_error ("--pulsate", ERROR_SUPPORT);
|
||||||
|
|
||||||
results->mode = MODE_ABOUT;
|
results->progress_data->pulsate = TRUE;
|
||||||
break;
|
break;
|
||||||
case OPTION_VERSION:
|
case OPTION_ABOUT:
|
||||||
if (results->mode != MODE_LAST)
|
if (results->mode != MODE_LAST)
|
||||||
zenity_error (NULL, ERROR_DIALOG);
|
zenity_error (NULL, ERROR_DIALOG);
|
||||||
|
|
||||||
g_print ("%s\n", VERSION);
|
results->mode = MODE_ABOUT;
|
||||||
exit (0);
|
break;
|
||||||
break;
|
case OPTION_VERSION:
|
||||||
default:
|
if (results->mode != MODE_LAST)
|
||||||
break;
|
zenity_error (NULL, ERROR_DIALOG);
|
||||||
}
|
zenity_free_parsing_options ();
|
||||||
|
g_print ("%s\n", VERSION);
|
||||||
|
exit (0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,8 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
||||||
|
|
||||||
if (msg_data->dialog_text)
|
if (msg_data->dialog_text)
|
||||||
gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text);
|
gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text);
|
||||||
|
|
||||||
|
@ -61,9 +61,10 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
|
|||||||
|
|
||||||
if (data->window_icon)
|
if (data->window_icon)
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon);
|
zenity_util_set_window_icon (dialog, data->window_icon);
|
||||||
else {
|
else
|
||||||
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-progress.png"));
|
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-progress.png"));
|
||||||
}
|
|
||||||
|
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
||||||
|
|
||||||
text = glade_xml_get_widget (glade_dialog, "zenity_progress_text");
|
text = glade_xml_get_widget (glade_dialog, "zenity_progress_text");
|
||||||
gtk_label_set_text (GTK_LABEL (text), progress_data->dialog_text);
|
gtk_label_set_text (GTK_LABEL (text), progress_data->dialog_text);
|
||||||
|
@ -60,6 +60,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
|
|||||||
else
|
else
|
||||||
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-text.png"));
|
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-text.png"));
|
||||||
|
|
||||||
|
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
|
||||||
|
|
||||||
text_buffer = gtk_text_buffer_new (NULL);
|
text_buffer = gtk_text_buffer_new (NULL);
|
||||||
|
27
src/tree.c
27
src/tree.c
@ -36,6 +36,17 @@ static gchar *separator;
|
|||||||
|
|
||||||
static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data);
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
zenity_tree_dialog_untoggle (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
||||||
|
{
|
||||||
|
GValue toggle_value = {0, };
|
||||||
|
|
||||||
|
gtk_tree_model_get_value (model, iter, 0, &toggle_value);
|
||||||
|
|
||||||
|
if (g_value_get_boolean (&toggle_value))
|
||||||
|
gtk_list_store_set (GTK_LIST_STORE (model), iter, 0, FALSE, -1);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer data)
|
zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer data)
|
||||||
{
|
{
|
||||||
@ -45,8 +56,16 @@ zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, g
|
|||||||
gboolean value;
|
gboolean value;
|
||||||
|
|
||||||
model = GTK_TREE_MODEL (data);
|
model = GTK_TREE_MODEL (data);
|
||||||
path = gtk_tree_path_new_from_string (path_string);
|
|
||||||
|
|
||||||
|
/* Because this is a radio list, we should untoggle the previous toggle so that
|
||||||
|
* we only have one selection at any given time
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "radio")) == 1) {
|
||||||
|
gtk_tree_model_foreach (model, zenity_tree_dialog_untoggle, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
path = gtk_tree_path_new_from_string (path_string);
|
||||||
gtk_tree_model_get_iter (model, &iter, path);
|
gtk_tree_model_get_iter (model, &iter, path);
|
||||||
gtk_tree_model_get (model, &iter, 0, &value, -1);
|
gtk_tree_model_get (model, &iter, 0, &value, -1);
|
||||||
|
|
||||||
@ -176,6 +195,8 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
|||||||
else
|
else
|
||||||
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-list.png"));
|
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-list.png"));
|
||||||
|
|
||||||
|
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
||||||
|
|
||||||
tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view");
|
tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view");
|
||||||
|
|
||||||
/* Create an empty list store */
|
/* Create an empty list store */
|
||||||
@ -216,8 +237,10 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
|||||||
|
|
||||||
cell_renderer = gtk_cell_renderer_toggle_new ();
|
cell_renderer = gtk_cell_renderer_toggle_new ();
|
||||||
|
|
||||||
if (tree_data->radiobox)
|
if (tree_data->radiobox) {
|
||||||
g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL);
|
g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL);
|
||||||
|
g_object_set_data (G_OBJECT (model), "radio", (gint *) 1);
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_connect (cell_renderer, "toggled",
|
g_signal_connect (cell_renderer, "toggled",
|
||||||
G_CALLBACK (zenity_tree_toggled_callback), model);
|
G_CALLBACK (zenity_tree_toggled_callback), model);
|
||||||
|
@ -26,6 +26,8 @@ G_BEGIN_DECLS
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_title;
|
gchar *dialog_title;
|
||||||
gchar *window_icon;
|
gchar *window_icon;
|
||||||
|
gint width;
|
||||||
|
gint height;
|
||||||
gint exit_code;
|
gint exit_code;
|
||||||
} ZenityData;
|
} ZenityData;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user