From 48c1564ac5ef431e9111606e40488d04a96f3059 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Fri, 3 Jan 2003 13:26:04 +0000 Subject: Initial revision --- src/main.c | 834 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 834 insertions(+) create mode 100644 src/main.c (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c new file mode 100644 index 00000000..cf17d7dd --- /dev/null +++ b/src/main.c @@ -0,0 +1,834 @@ +/* + * main.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + */ + +#include "config.h" +#include "zenity.h" +#include + +typedef enum { + MODE_CALENDAR, + MODE_ENTRY, + MODE_ERROR, + MODE_FILE, + MODE_LIST, + MODE_PROGRESS, + MODE_QUESTION, + MODE_TEXTINFO, + MODE_WARNING, + MODE_LAST +} ZenityDialogMode; + +typedef struct { + ZenityDialogMode mode; + ZenityData *data; + + ZenityCalendarData *calendar_data; + ZenityMsgData *msg_data; + ZenityFileData *file_data; + ZenityEntryData *entry_data; + ZenityProgressData *progress_data; + ZenityTextData *text_data; + ZenityTreeData *tree_data; +} ZenityParsingOptions; + +enum { + OPTION_CALENDAR = 1, + OPTION_ENTRY, + OPTION_ERROR, + OPTION_FILE, + OPTION_LIST, + OPTION_PROGRESS, + OPTION_QUESTION, + OPTION_TEXTINFO, + OPTION_WARNING, + OPTION_TITLE, + OPTION_ICON, + OPTION_CALENDARTEXT, + OPTION_DAY, + OPTION_MONTH, + OPTION_YEAR, + OPTION_ENTRYTEXT, + OPTION_INPUTTEXT, + OPTION_HIDETEXT, + OPTION_ERRORTEXT, + OPTION_FILENAME, + OPTION_COLUMN, + OPTION_CHECKLIST, + OPTION_RADIOLIST, + OPTION_PROGRESSTEXT, + OPTION_PERCENTAGE, + OPTION_QUESTIONTEXT, + OPTION_TEXTFILE, + OPTION_WARNINGTEXT, + OPTION_ABOUT, + OPTION_VERSION, + OPTION_LAST, +}; + +static void zenity_parse_options_callback (poptContext ctx, + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, + void *data); + +struct poptOption options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "calendar", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_CALENDAR, + N_("Display calendar dialog"), + NULL + }, + { + "entry", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_ENTRY, + N_("Display text entry dialog"), + NULL + }, + { + "error", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_ERROR, + N_("Display error dialog"), + NULL + }, + { + "file-selection", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_FILE, + N_("Display file selection dialog"), + NULL + }, + { + "list", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_LIST, + N_("Display list dialog"), + NULL + }, + { + "progress", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_PROGRESS, + N_("Display progress indication dialog"), + NULL + }, + { + "question", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_QUESTION, + N_("Display question dialog"), + NULL + }, + { + "text-info", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_TEXTINFO, + N_("Display text information dialog"), + NULL + }, + { + "warning", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_WARNING, + N_("Display warning dialog"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption general_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "title", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_TITLE, + N_("Set the dialog title"), + N_("TITLE") + }, + { + "window-icon", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_ICON, + N_("Set the window icon"), + N_("ICONPATH") + }, + POPT_TABLEEND +}; + +struct poptOption calendar_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_CALENDARTEXT, + N_("Set the dialog text"), + NULL + }, + { + "day", + '\0', + POPT_ARG_INT, + NULL, + OPTION_DAY, + N_("Set the calendar day"), + NULL + }, + { + "month", + '\0', + POPT_ARG_INT, + NULL, + OPTION_MONTH, + N_("Set the calendar month"), + NULL + }, + { + "year", + '\0', + POPT_ARG_INT, + NULL, + OPTION_YEAR, + N_("Set the calendar year"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption entry_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_ENTRYTEXT, + N_("Set the dialog text"), + NULL + }, + { + "entry-text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_INPUTTEXT, + N_("Set the entry text"), + NULL + }, + { + "hide-text", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_HIDETEXT, + N_("Hide the entry text"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption error_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_ERRORTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption file_selection_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "filename", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_FILENAME, + N_("Set the filename"), + N_("FILENAME") + }, + POPT_TABLEEND +}; + +struct poptOption list_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "column", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_COLUMN, + N_("Set the column header"), + NULL + }, + { + "checklist", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_CHECKLIST, + N_("Use check boxes for first column"), + NULL + }, + { + "radiolist", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_RADIOLIST, + N_("Use radio buttons for first column"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption progress_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_PROGRESSTEXT, + N_("Set the dialog text"), + NULL + }, + { + "percentage", + '\0', + POPT_ARG_INT, + NULL, + OPTION_PERCENTAGE, + N_("Set initial percentage"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption question_options[] = { + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_QUESTIONTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption text_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "filename", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_TEXTFILE, + N_("Open file"), + N_("FILENAME") + }, + POPT_TABLEEND +}; + +struct poptOption warning_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_WARNINGTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption miscellaneous_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "about", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_ABOUT, + N_("About zenity"), + NULL + }, + { + "version", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_VERSION, + N_("Print version"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption application_options[] = { + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + options, + 0, + N_("Dialog options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + general_options, + 0, + N_("General options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + calendar_options, + 0, + N_("Calendar options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + entry_options, + 0, + N_("Text entry options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + error_options, + 0, + N_("Error options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + file_selection_options, + 0, + N_("File selection options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + list_options, + 0, + N_("List options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + progress_options, + 0, + N_("Progress options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + question_options, + 0, + N_("Question options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + text_options, + 0, + N_("Text options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + warning_options, + 0, + N_("Warning options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + miscellaneous_options, + 0, + N_("Miscellaneous options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + poptHelpOptions, + 0, + N_("Help options"), + NULL + }, + POPT_TABLEEND +}; + +ZenityParsingOptions *results; + +gint +main (gint argc, gchar **argv) { + poptContext ctx; + int nextopt; + ZenityData *general; + ZenityCalendarData *cal_data; + + bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); + + results = g_new0 (ZenityParsingOptions, 1); + results->data = g_new0 (ZenityData, 1); + results->calendar_data = g_new0 (ZenityCalendarData, 1); + results->msg_data = g_new0 (ZenityMsgData, 1); + results->file_data = g_new0 (ZenityFileData, 1); + results->entry_data = g_new0 (ZenityEntryData, 1); + results->entry_data->visible = TRUE; + results->progress_data = g_new0 (ZenityProgressData, 1); + results->text_data = g_new0 (ZenityTextData, 1); + results->tree_data = g_new0 (ZenityTreeData, 1); + results->tree_data->checkbox = FALSE; + results->tree_data->radiobox = FALSE; + + /* FIXME: popt doesn't like passing stuff through data + * but it doesn't seem to cope with the data that I try + * to pass in, not quite sure why though. If someone knows + * what I'm doing wrong, we could probably put this back: + * options[0].descrip = (void*) results; + */ + + ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0); + poptSetOtherOptionHelp(ctx, "[OPTIONS] ..."); + poptReadDefaultConfig(ctx, TRUE); + while((nextopt = poptGetNextOpt(ctx)) > 0) + /*nothing*/; + + gtk_init (&argc, &argv); + + if (argc < 2) + exit (1); + + switch (results->mode) { + case MODE_CALENDAR: + zenity_calendar (results->data, results->calendar_data); + break; + case MODE_ENTRY: + zenity_entry (results->data, results->entry_data); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + zenity_msg (results->data, results->msg_data); + break; + case MODE_FILE: + zenity_fileselection (results->data, results->file_data); + break; + case MODE_LIST: + zenity_tree (results->data, results->tree_data); + break; + case MODE_PROGRESS: + zenity_progress (results->data, results->progress_data); + break; + case MODE_TEXTINFO: + zenity_text (results->data, results->text_data); + break; + default: + break; + } + + poptFreeContext(ctx); + exit (0); +} + +static +void zenity_parse_options_callback (poptContext ctx, + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, + void *data) +{ + gint i = 0; + if (reason == POPT_CALLBACK_REASON_POST) { + return; + } + else if (reason != POPT_CALLBACK_REASON_OPTION) + return; + + switch (opt->val & POPT_ARG_MASK) { + + case OPTION_CALENDAR: + results->mode = MODE_CALENDAR; + break; + case OPTION_ENTRY: + results->mode = MODE_ENTRY; + break; + case OPTION_ERROR: + results->mode = MODE_ERROR; + results->msg_data->mode = ZENITY_MSG_ERROR; + break; + case OPTION_FILE: + results->mode = MODE_FILE; + break; + case OPTION_LIST: + results->mode = MODE_LIST; + break; + case OPTION_PROGRESS: + results->mode = MODE_PROGRESS; + break; + case OPTION_QUESTION: + results->mode = MODE_QUESTION; + results->msg_data->mode = ZENITY_MSG_QUESTION; + break; + case OPTION_TEXTINFO: + results->mode = MODE_TEXTINFO; + break; + case OPTION_WARNING: + results->mode = MODE_WARNING; + results->msg_data->mode = ZENITY_MSG_WARNING; + break; + case OPTION_TITLE: + results->data->dialog_title = g_strdup (arg); + break; + case OPTION_ICON: + results->data->window_icon = g_strdup (arg); + break; + case OPTION_CALENDARTEXT: + case OPTION_ENTRYTEXT: + case OPTION_ERRORTEXT: + case OPTION_QUESTIONTEXT: + case OPTION_PROGRESSTEXT: + case OPTION_WARNINGTEXT: + switch (results->mode) { + case MODE_CALENDAR: + results->calendar_data->dialog_text = g_strdup (arg); + break; + case MODE_ENTRY: + results->entry_data->dialog_text = g_strdup (arg); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + results->msg_data->dialog_text = g_strdup (arg); + break; + case MODE_PROGRESS: + results->progress_data->dialog_text = g_strdup (arg); + break; + default: + break; + } + break; + case OPTION_DAY: + results->calendar_data->day = atoi (arg); + break; + case OPTION_MONTH: + results->calendar_data->month = atoi (arg); + break; + case OPTION_YEAR: + results->calendar_data->year = atoi (arg); + break; + case OPTION_INPUTTEXT: + results->entry_data->entry_text = g_strdup (arg); + break; + case OPTION_HIDETEXT: + results->entry_data->visible = FALSE; + break; + case OPTION_FILENAME: + case OPTION_TEXTFILE: + switch (results->mode) { + case MODE_FILE: + results->file_data->uri = g_strdup (arg); + break; + case MODE_TEXTINFO: + results->text_data->uri = g_strdup (arg); + break; + default: + break; + } + break; + case OPTION_COLUMN: + break; + case OPTION_CHECKLIST: + results->tree_data->checkbox = TRUE; + break; + case OPTION_RADIOLIST: + results->tree_data->radiobox = TRUE; + break; + case OPTION_PERCENTAGE: + results->progress_data->percentage = atoi (arg); + break; + case OPTION_ABOUT: + results->mode = MODE_LAST; + break; + case OPTION_VERSION: + results->mode = MODE_LAST; + g_print ("%s\n", VERSION); + break; + default: + break; + } +} -- cgit From 344345d9aa262940fedfb8beed9dc0c9bb163a10 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 6 Jan 2003 15:06:17 +0000 Subject: Add functions to init and free the parsing options. Still not terribly 2003-01-06 Glynn Foster * src/main.c: Add functions to init and free the parsing options. Still not terribly pretty though. * src/tree.c, src/zenity.h: Handle --column argument. * TODO: Update accordingly. --- src/main.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 11 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index cf17d7dd..a1faf681 100644 --- a/src/main.c +++ b/src/main.c @@ -631,29 +631,76 @@ struct poptOption application_options[] = { ZenityParsingOptions *results; -gint -main (gint argc, gchar **argv) { - poptContext ctx; - int nextopt; - ZenityData *general; - ZenityCalendarData *cal_data; - - bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - textdomain(GETTEXT_PACKAGE); +static void +zenity_init_parsing_options (void) { results = g_new0 (ZenityParsingOptions, 1); + + /* Initialize the various dialog structures */ results->data = g_new0 (ZenityData, 1); results->calendar_data = g_new0 (ZenityCalendarData, 1); results->msg_data = g_new0 (ZenityMsgData, 1); results->file_data = g_new0 (ZenityFileData, 1); results->entry_data = g_new0 (ZenityEntryData, 1); - results->entry_data->visible = TRUE; results->progress_data = g_new0 (ZenityProgressData, 1); results->text_data = g_new0 (ZenityTextData, 1); results->tree_data = g_new0 (ZenityTreeData, 1); + + /* Give some sensible defaults */ + results->entry_data->visible = TRUE; results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; +} + +static void +zenity_free_parsing_options (void) { + + /* General options */ + if (results->data->dialog_title) + g_free (results->data->dialog_title); + if (results->data->window_icon) + g_free (results->data->window_icon); + + /* Dialog options */ + switch (results->mode) { + case MODE_CALENDAR: + g_free (results->calendar_data->dialog_text); + break; + case MODE_ENTRY: + g_free (results->entry_data->dialog_text); + g_free (results->entry_data->entry_text); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + g_free (results->msg_data->dialog_text); + break; + case MODE_FILE: + g_free (results->file_data->uri); + break; + case MODE_TEXTINFO: + g_free (results->text_data->uri); + break; + case MODE_LIST: + g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); + break; + default: + break; + } +} + +gint +main (gint argc, gchar **argv) { + poptContext ctx; + int nextopt; + ZenityData *general; + ZenityCalendarData *cal_data; + + bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); + + zenity_init_parsing_options (); /* FIXME: popt doesn't like passing stuff through data * but it doesn't seem to cope with the data that I try @@ -702,6 +749,7 @@ main (gint argc, gchar **argv) { } poptFreeContext(ctx); + zenity_free_parsing_options (); exit (0); } @@ -811,6 +859,7 @@ void zenity_parse_options_callback (poptContext ctx, } break; case OPTION_COLUMN: + results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); break; case OPTION_CHECKLIST: results->tree_data->checkbox = TRUE; -- cgit From 8924d5c401829efc59380fda8823bedca5994bcb Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 6 Jan 2003 21:09:22 +0000 Subject: I love featuritis. Instead of fixing stuff so it actually works, I add 2003-01-06 Glynn Foster * src/main.c, src/msg.c, src/zenity.glade, src/zenity.h: I love featuritis. Instead of fixing stuff so it actually works, I add more stuff. Add support for info dialog. --- src/main.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index a1faf681..334c20df 100644 --- a/src/main.c +++ b/src/main.c @@ -35,6 +35,7 @@ typedef enum { MODE_QUESTION, MODE_TEXTINFO, MODE_WARNING, + MODE_INFO, MODE_LAST } ZenityDialogMode; @@ -55,6 +56,7 @@ enum { OPTION_CALENDAR = 1, OPTION_ENTRY, OPTION_ERROR, + OPTION_INFO, OPTION_FILE, OPTION_LIST, OPTION_PROGRESS, @@ -71,6 +73,7 @@ enum { OPTION_INPUTTEXT, OPTION_HIDETEXT, OPTION_ERRORTEXT, + OPTION_INFOTEXT, OPTION_FILENAME, OPTION_COLUMN, OPTION_CHECKLIST, @@ -128,6 +131,15 @@ struct poptOption options[] = { N_("Display error dialog"), NULL }, + { + "info", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_INFO, + N_("Display info dialog"), + NULL + }, { "file-selection", '\0', @@ -327,6 +339,28 @@ struct poptOption error_options[] = { POPT_TABLEEND }; +struct poptOption info_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_INFOTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND +}; + struct poptOption file_selection_options[] = { { NULL, @@ -545,6 +579,15 @@ struct poptOption application_options[] = { N_("Text entry options"), NULL }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + info_options, + 0, + N_("Info options"), + NULL + }, { NULL, '\0', @@ -673,6 +716,7 @@ zenity_free_parsing_options (void) { case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: + case MODE_INFO: g_free (results->msg_data->dialog_text); break; case MODE_FILE: @@ -730,6 +774,7 @@ main (gint argc, gchar **argv) { case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: + case MODE_INFO: zenity_msg (results->data, results->msg_data); break; case MODE_FILE: @@ -779,6 +824,10 @@ void zenity_parse_options_callback (poptContext ctx, results->mode = MODE_ERROR; results->msg_data->mode = ZENITY_MSG_ERROR; break; + case OPTION_INFO: + results->mode = MODE_INFO; + results->msg_data->mode = ZENITY_MSG_INFO; + break; case OPTION_FILE: results->mode = MODE_FILE; break; @@ -821,6 +870,7 @@ void zenity_parse_options_callback (poptContext ctx, case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: + case MODE_INFO: results->msg_data->dialog_text = g_strdup (arg); break; case MODE_PROGRESS: -- cgit From d88a32f1f5418e97b5840087a21652f68ac938c8 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 6 Jan 2003 21:58:21 +0000 Subject: Finish off commandline parsing for the list dialog. Wow, this is almost 2003-01-06 Glynn Foster * src/main.c, src/tree.c, src/zenity.h: Finish off commandline parsing for the list dialog. Wow, this is almost approaching usable ;) * TODO: Update accordingly --- src/main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 334c20df..86f4aaa7 100644 --- a/src/main.c +++ b/src/main.c @@ -735,6 +735,7 @@ zenity_free_parsing_options (void) { gint main (gint argc, gchar **argv) { + char **args; poptContext ctx; int nextopt; ZenityData *general; @@ -781,6 +782,7 @@ main (gint argc, gchar **argv) { zenity_fileselection (results->data, results->file_data); break; case MODE_LIST: + results->tree_data->data = poptGetArgs (ctx); zenity_tree (results->data, results->tree_data); break; case MODE_PROGRESS: -- cgit From a8c3006035a068069ed9199400472332db540bb5 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Jan 2003 00:01:00 +0000 Subject: Improve error handling... a lot. 2003-01-06 Glynn Foster * src/calendar.c, src/main.c, src/progress.c, src/tree.c, src/zenity.h: Improve error handling... a lot. --- src/main.c | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 164 insertions(+), 6 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 86f4aaa7..aad777e4 100644 --- a/src/main.c +++ b/src/main.c @@ -680,6 +680,7 @@ zenity_init_parsing_options (void) { results = g_new0 (ZenityParsingOptions, 1); /* Initialize the various dialog structures */ + results->mode = MODE_LAST; results->data = g_new0 (ZenityData, 1); results->calendar_data = g_new0 (ZenityCalendarData, 1); results->msg_data = g_new0 (ZenityMsgData, 1); @@ -690,6 +691,10 @@ zenity_init_parsing_options (void) { results->tree_data = g_new0 (ZenityTreeData, 1); /* Give some sensible defaults */ + results->calendar_data->day = 0; + results->calendar_data->month = 0; + results->calendar_data->year = 0; + results->progress_data->percentage = -1; results->entry_data->visible = TRUE; results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; @@ -760,6 +765,11 @@ main (gint argc, gchar **argv) { while((nextopt = poptGetNextOpt(ctx)) > 0) /*nothing*/; + if (nextopt != -1) { + g_printerr (_("%s in an invalid option for this dialog\n"), poptBadOption (ctx, 0)); + exit (1); + } + gtk_init (&argc, &argv); if (argc < 2) @@ -807,7 +817,6 @@ void zenity_parse_options_callback (poptContext ctx, const char *arg, void *data) { - gint i = 0; if (reason == POPT_CALLBACK_REASON_POST) { return; } @@ -817,43 +826,91 @@ void zenity_parse_options_callback (poptContext ctx, switch (opt->val & POPT_ARG_MASK) { case OPTION_CALENDAR: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_CALENDAR; break; case OPTION_ENTRY: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_ENTRY; break; case OPTION_ERROR: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_ERROR; results->msg_data->mode = ZENITY_MSG_ERROR; break; case OPTION_INFO: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_INFO; results->msg_data->mode = ZENITY_MSG_INFO; break; case OPTION_FILE: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_FILE; break; case OPTION_LIST: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_LIST; break; case OPTION_PROGRESS: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_PROGRESS; break; case OPTION_QUESTION: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_QUESTION; results->msg_data->mode = ZENITY_MSG_QUESTION; break; case OPTION_TEXTINFO: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_TEXTINFO; break; case OPTION_WARNING: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_WARNING; results->msg_data->mode = ZENITY_MSG_WARNING; break; case OPTION_TITLE: + if (results->data->dialog_title != NULL) { + g_printerr (_("--title given twice for the same dialog\n")); + exit (1); + } results->data->dialog_title = g_strdup (arg); break; case OPTION_ICON: + if (results->data->window_icon != NULL) { + g_printerr (_("--window-icon given twice for the same dialog\n")); + exit (1); + } results->data->window_icon = g_strdup (arg); break; case OPTION_CALENDARTEXT: @@ -864,72 +921,173 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_WARNINGTEXT: switch (results->mode) { case MODE_CALENDAR: + if (results->calendar_data->dialog_text != NULL) { + g_printerr (_("--text given twice for the same dialog\n")); + exit (1); + } results->calendar_data->dialog_text = g_strdup (arg); break; case MODE_ENTRY: + if (results->entry_data->dialog_text != NULL) { + g_printerr (_("--text given twice for the same dialog\n")); + exit (1); + } results->entry_data->dialog_text = g_strdup (arg); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: + if (results->msg_data->dialog_text != NULL) { + g_printerr (_("--text given twice for the same dialog\n")); + exit (1); + } results->msg_data->dialog_text = g_strdup (arg); break; case MODE_PROGRESS: + if (results->progress_data->dialog_text != NULL) { + g_printerr (_("--text given twice for the same dialog\n")); + exit (1); + } results->progress_data->dialog_text = g_strdup (arg); break; default: - break; + g_printerr (_("--text is not supported for this dialog\n")); + exit (1); } break; case OPTION_DAY: + if (results->mode != MODE_CALENDAR) { + g_printerr (_("--day is not supported for this dialog\n")); + exit (1); + } + if (results->calendar_data->day > 0) { + g_printerr (_("--day given twice for the same dialog\n")); + exit (1); + } results->calendar_data->day = atoi (arg); break; case OPTION_MONTH: + if (results->mode != MODE_CALENDAR) { + g_printerr (_("--month is not supported for this dialog\n")); + exit (1); + } + if (results->calendar_data->month > 0) { + g_printerr (_("--month given twice for the same dialog\n")); + exit (1); + } results->calendar_data->month = atoi (arg); break; case OPTION_YEAR: + if (results->mode != MODE_CALENDAR) { + g_printerr (_("--year is not supported for this dialog\n")); + exit (1); + } + if (results->calendar_data->year > 0) { + g_printerr (_("--year given twice for the same dialog\n")); + exit (1); + } results->calendar_data->year = atoi (arg); break; case OPTION_INPUTTEXT: + if (results->mode != MODE_ENTRY) { + g_printerr (_("--entry-text is not supported for this dialog\n")); + exit (1); + } + if (results->entry_data->entry_text != NULL) { + g_printerr (_("--entry-text given twice for the same dialog\n")); + exit (1); + } results->entry_data->entry_text = g_strdup (arg); break; case OPTION_HIDETEXT: + if (results->mode != MODE_ENTRY) { + g_printerr (_("--hide-text is not supported for this dialog\n")); + exit (1); + } + if (results->entry_data->visible == FALSE) { + g_printerr (_("--hide-text given twice for the same dialog\n")); + exit (1); + } results->entry_data->visible = FALSE; break; case OPTION_FILENAME: case OPTION_TEXTFILE: switch (results->mode) { case MODE_FILE: + if (results->file_data->uri != NULL) { + g_printerr (_("--filename given twice for the same dialog\n")); + exit (1); + } results->file_data->uri = g_strdup (arg); break; case MODE_TEXTINFO: + if (results->text_data->uri != NULL) { + g_printerr (_("--filename given twice for the same dialog\n")); + exit (1); + } results->text_data->uri = g_strdup (arg); break; default: - break; + g_printerr (_("--filename is not supported for this dialog\n")); + exit (1); } break; case OPTION_COLUMN: + if (results->mode != MODE_LIST) { + g_printerr (_("--column is not supported for this dialog\n")); + exit (1); + } results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); break; case OPTION_CHECKLIST: + if (results->mode != MODE_LIST) { + g_printerr (_("--checkbox is not supported for this dialog\n")); + exit (1); + } + if (results->tree_data->checkbox == TRUE) { + g_printerr (_("--checkbox given twice for the same dialog\n")); + exit (1); + } results->tree_data->checkbox = TRUE; break; case OPTION_RADIOLIST: + if (results->mode != MODE_LIST) { + g_printerr (_("--radiobox is not supported for this dialog\n")); + exit (1); + } + if (results->tree_data->radiobox == TRUE) { + g_printerr (_("--radiobox given twice for the same dialog\n")); + exit (1); + } results->tree_data->radiobox = TRUE; break; case OPTION_PERCENTAGE: + if (results->mode != MODE_PROGRESS) { + g_printerr (_("--percentage is not supported for this dialog\n")); + exit (1); + } + if (results->progress_data->percentage > -1) { + g_printerr (_("--percentage given twice for the same dialog\n")); + exit (1); + } results->progress_data->percentage = atoi (arg); break; case OPTION_ABOUT: - results->mode = MODE_LAST; + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } break; case OPTION_VERSION: - results->mode = MODE_LAST; + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } g_print ("%s\n", VERSION); break; default: - break; + g_warning ("Invalid option %s", arg); + exit (1); } } -- cgit From 952fc14e7b0178d035de38106711953485aa9490 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Jan 2003 00:30:03 +0000 Subject: Fix up the error returns. 2003-01-07 Glynn Foster * src/main.c: Fix up the error returns. * TODO: Update accordingly. --- src/main.c | 176 +++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 114 insertions(+), 62 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index aad777e4..dc341c42 100644 --- a/src/main.c +++ b/src/main.c @@ -712,26 +712,33 @@ zenity_free_parsing_options (void) { /* Dialog options */ switch (results->mode) { case MODE_CALENDAR: - g_free (results->calendar_data->dialog_text); + if (results->calendar_data->dialog_text) + g_free (results->calendar_data->dialog_text); break; case MODE_ENTRY: - g_free (results->entry_data->dialog_text); - g_free (results->entry_data->entry_text); + if (results->entry_data->dialog_text) + g_free (results->entry_data->dialog_text); + if (results->entry_data->entry_text) + g_free (results->entry_data->entry_text); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: - g_free (results->msg_data->dialog_text); + if (results->msg_data->dialog_text) + g_free (results->msg_data->dialog_text); break; case MODE_FILE: - g_free (results->file_data->uri); + if (results->file_data->uri) + g_free (results->file_data->uri); break; case MODE_TEXTINFO: - g_free (results->text_data->uri); + if (results->text_data->uri) + g_free (results->text_data->uri); break; case MODE_LIST: - g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); + if (results->tree_data->columns) + g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); break; default: break; @@ -740,11 +747,11 @@ zenity_free_parsing_options (void) { gint main (gint argc, gchar **argv) { - char **args; - poptContext ctx; - int nextopt; ZenityData *general; ZenityCalendarData *cal_data; + poptContext ctx; + char **args; + int nextopt, retval; bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); @@ -760,49 +767,54 @@ main (gint argc, gchar **argv) { */ ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0); - poptSetOtherOptionHelp(ctx, "[OPTIONS] ..."); + poptReadDefaultConfig(ctx, TRUE); while((nextopt = poptGetNextOpt(ctx)) > 0) /*nothing*/; if (nextopt != -1) { g_printerr (_("%s in an invalid option for this dialog\n"), poptBadOption (ctx, 0)); - exit (1); + zenity_free_parsing_options (); + exit (-1); } gtk_init (&argc, &argv); - if (argc < 2) - exit (1); + if (argc < 2) { + zenity_free_parsing_options (); + exit (-1); + } switch (results->mode) { case MODE_CALENDAR: - zenity_calendar (results->data, results->calendar_data); + retval = zenity_calendar (results->data, results->calendar_data); break; case MODE_ENTRY: - zenity_entry (results->data, results->entry_data); + retval = zenity_entry (results->data, results->entry_data); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: - zenity_msg (results->data, results->msg_data); + retval = zenity_msg (results->data, results->msg_data); break; case MODE_FILE: - zenity_fileselection (results->data, results->file_data); + retval = zenity_fileselection (results->data, results->file_data); break; case MODE_LIST: results->tree_data->data = poptGetArgs (ctx); - zenity_tree (results->data, results->tree_data); + retval = zenity_tree (results->data, results->tree_data); break; case MODE_PROGRESS: - zenity_progress (results->data, results->progress_data); + retval = zenity_progress (results->data, results->progress_data); break; case MODE_TEXTINFO: - zenity_text (results->data, results->text_data); + retval = zenity_text (results->data, results->text_data); break; default: - break; + g_assert_not_reached (); + zenity_free_parsing_options (); + exit (-1); } poptFreeContext(ctx); @@ -828,21 +840,24 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_CALENDAR: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_CALENDAR; break; case OPTION_ENTRY: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_ENTRY; break; case OPTION_ERROR: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_ERROR; results->msg_data->mode = ZENITY_MSG_ERROR; @@ -850,7 +865,8 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_INFO: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_INFO; results->msg_data->mode = ZENITY_MSG_INFO; @@ -858,28 +874,32 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_FILE: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_FILE; break; case OPTION_LIST: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_LIST; break; case OPTION_PROGRESS: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_PROGRESS; break; case OPTION_QUESTION: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_QUESTION; results->msg_data->mode = ZENITY_MSG_QUESTION; @@ -887,14 +907,16 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_TEXTINFO: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_TEXTINFO; break; case OPTION_WARNING: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_WARNING; results->msg_data->mode = ZENITY_MSG_WARNING; @@ -902,14 +924,16 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_TITLE: if (results->data->dialog_title != NULL) { g_printerr (_("--title given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->data->dialog_title = g_strdup (arg); break; case OPTION_ICON: if (results->data->window_icon != NULL) { g_printerr (_("--window-icon given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->data->window_icon = g_strdup (arg); break; @@ -923,14 +947,16 @@ void zenity_parse_options_callback (poptContext ctx, case MODE_CALENDAR: if (results->calendar_data->dialog_text != NULL) { g_printerr (_("--text given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->calendar_data->dialog_text = g_strdup (arg); break; case MODE_ENTRY: if (results->entry_data->dialog_text != NULL) { g_printerr (_("--text given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->entry_data->dialog_text = g_strdup (arg); break; @@ -940,74 +966,87 @@ void zenity_parse_options_callback (poptContext ctx, case MODE_INFO: if (results->msg_data->dialog_text != NULL) { g_printerr (_("--text given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->msg_data->dialog_text = g_strdup (arg); break; case MODE_PROGRESS: if (results->progress_data->dialog_text != NULL) { g_printerr (_("--text given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->progress_data->dialog_text = g_strdup (arg); break; default: g_printerr (_("--text is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } break; case OPTION_DAY: if (results->mode != MODE_CALENDAR) { g_printerr (_("--day is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->calendar_data->day > 0) { g_printerr (_("--day given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->calendar_data->day = atoi (arg); break; case OPTION_MONTH: if (results->mode != MODE_CALENDAR) { g_printerr (_("--month is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->calendar_data->month > 0) { g_printerr (_("--month given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->calendar_data->month = atoi (arg); break; case OPTION_YEAR: if (results->mode != MODE_CALENDAR) { g_printerr (_("--year is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->calendar_data->year > 0) { g_printerr (_("--year given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->calendar_data->year = atoi (arg); break; case OPTION_INPUTTEXT: if (results->mode != MODE_ENTRY) { g_printerr (_("--entry-text is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->entry_data->entry_text != NULL) { g_printerr (_("--entry-text given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->entry_data->entry_text = g_strdup (arg); break; case OPTION_HIDETEXT: if (results->mode != MODE_ENTRY) { g_printerr (_("--hide-text is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->entry_data->visible == FALSE) { g_printerr (_("--hide-text given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->entry_data->visible = FALSE; break; @@ -1017,77 +1056,90 @@ void zenity_parse_options_callback (poptContext ctx, case MODE_FILE: if (results->file_data->uri != NULL) { g_printerr (_("--filename given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->file_data->uri = g_strdup (arg); break; case MODE_TEXTINFO: if (results->text_data->uri != NULL) { g_printerr (_("--filename given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->text_data->uri = g_strdup (arg); break; default: g_printerr (_("--filename is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } break; case OPTION_COLUMN: if (results->mode != MODE_LIST) { g_printerr (_("--column is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); break; case OPTION_CHECKLIST: if (results->mode != MODE_LIST) { g_printerr (_("--checkbox is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->tree_data->checkbox == TRUE) { g_printerr (_("--checkbox given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->tree_data->checkbox = TRUE; break; case OPTION_RADIOLIST: if (results->mode != MODE_LIST) { g_printerr (_("--radiobox is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->tree_data->radiobox == TRUE) { g_printerr (_("--radiobox given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->tree_data->radiobox = TRUE; break; case OPTION_PERCENTAGE: if (results->mode != MODE_PROGRESS) { g_printerr (_("--percentage is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->progress_data->percentage > -1) { g_printerr (_("--percentage given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->progress_data->percentage = atoi (arg); break; case OPTION_ABOUT: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } break; case OPTION_VERSION: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } g_print ("%s\n", VERSION); break; default: g_warning ("Invalid option %s", arg); - exit (1); + zenity_free_parsing_options (); + exit (-1); } } -- cgit From 6a65d75921d352323277f770f357ca3065436133 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Jan 2003 13:22:57 +0000 Subject: Fix up the response signal handlers. Use returns of 0 for 'Ok' and 2003-01-07 Glynn Foster * 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.glade, src/zenity.h: Fix up the response signal handlers. Use returns of 0 for 'Ok' and 'Close', 1 for 'Cancel' and 'Escape' and -1 for 'Uh Oh'. Get stuff printing to stderr. Fix up the error handling that I thought was improved, although still have issues with popt callback getting called numerous times because of more than one instance of the same kind is being used in poptOption. * TODO: Update accordingly. --- src/main.c | 55 +++++++++++++++---------------------------------------- 1 file changed, 15 insertions(+), 40 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index dc341c42..f60eb7f0 100644 --- a/src/main.c +++ b/src/main.c @@ -694,6 +694,7 @@ zenity_init_parsing_options (void) { results->calendar_data->day = 0; results->calendar_data->month = 0; results->calendar_data->year = 0; + results->calendar_data->dialog_text = NULL; results->progress_data->percentage = -1; results->entry_data->visible = TRUE; results->tree_data->checkbox = FALSE; @@ -750,8 +751,8 @@ main (gint argc, gchar **argv) { ZenityData *general; ZenityCalendarData *cal_data; poptContext ctx; - char **args; - int nextopt, retval; + gchar **args; + gint nextopt, retval; bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); @@ -787,29 +788,29 @@ main (gint argc, gchar **argv) { switch (results->mode) { case MODE_CALENDAR: - retval = zenity_calendar (results->data, results->calendar_data); + zenity_calendar (results->data, results->calendar_data); break; case MODE_ENTRY: - retval = zenity_entry (results->data, results->entry_data); + zenity_entry (results->data, results->entry_data); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: - retval = zenity_msg (results->data, results->msg_data); + zenity_msg (results->data, results->msg_data); break; case MODE_FILE: - retval = zenity_fileselection (results->data, results->file_data); + zenity_fileselection (results->data, results->file_data); break; case MODE_LIST: results->tree_data->data = poptGetArgs (ctx); - retval = zenity_tree (results->data, results->tree_data); + zenity_tree (results->data, results->tree_data); break; case MODE_PROGRESS: - retval = zenity_progress (results->data, results->progress_data); + zenity_progress (results->data, results->progress_data); break; case MODE_TEXTINFO: - retval = zenity_text (results->data, results->text_data); + zenity_text (results->data, results->text_data); break; default: g_assert_not_reached (); @@ -817,9 +818,10 @@ main (gint argc, gchar **argv) { exit (-1); } + retval = results->data->exit_code; poptFreeContext(ctx); zenity_free_parsing_options (); - exit (0); + exit (retval); } static @@ -945,38 +947,18 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_WARNINGTEXT: switch (results->mode) { case MODE_CALENDAR: - if (results->calendar_data->dialog_text != NULL) { - g_printerr (_("--text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } results->calendar_data->dialog_text = g_strdup (arg); break; case MODE_ENTRY: - if (results->entry_data->dialog_text != NULL) { - g_printerr (_("--text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } results->entry_data->dialog_text = g_strdup (arg); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: - if (results->msg_data->dialog_text != NULL) { - g_printerr (_("--text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } results->msg_data->dialog_text = g_strdup (arg); break; case MODE_PROGRESS: - if (results->progress_data->dialog_text != NULL) { - g_printerr (_("--text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } results->progress_data->dialog_text = g_strdup (arg); break; default: @@ -1054,19 +1036,9 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_TEXTFILE: switch (results->mode) { case MODE_FILE: - if (results->file_data->uri != NULL) { - g_printerr (_("--filename given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } results->file_data->uri = g_strdup (arg); break; case MODE_TEXTINFO: - if (results->text_data->uri != NULL) { - g_printerr (_("--filename given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } results->text_data->uri = g_strdup (arg); break; default: @@ -1128,6 +1100,8 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } + g_print ("This does nothing at the moment\n"); + exit (0); break; case OPTION_VERSION: if (results->mode != MODE_LAST) { @@ -1136,6 +1110,7 @@ void zenity_parse_options_callback (poptContext ctx, exit (-1); } g_print ("%s\n", VERSION); + exit (0); break; default: g_warning ("Invalid option %s", arg); -- cgit From cd4e438bfb3ebfd3cc872e203e343a50acc02a15 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Thu, 9 Jan 2003 18:07:04 +0000 Subject: Fix up the date string, although I guess this should be localized. 2003-01-09 Glynn Foster * 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. --- src/main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index f60eb7f0..53cfc992 100644 --- a/src/main.c +++ b/src/main.c @@ -80,6 +80,7 @@ enum { OPTION_RADIOLIST, OPTION_PROGRESSTEXT, OPTION_PERCENTAGE, + OPTION_PULSATE, OPTION_QUESTIONTEXT, OPTION_TEXTFILE, OPTION_WARNINGTEXT, @@ -451,6 +452,15 @@ struct poptOption progress_options[] = { N_("Set initial percentage"), NULL }, + { + "pulsate", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_PULSATE, + N_("Pulsate progress bar"), + NULL + }, POPT_TABLEEND }; @@ -696,6 +706,7 @@ zenity_init_parsing_options (void) { results->calendar_data->year = 0; results->calendar_data->dialog_text = NULL; results->progress_data->percentage = -1; + results->progress_data->pulsate = FALSE; results->entry_data->visible = TRUE; results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; @@ -1094,6 +1105,14 @@ void zenity_parse_options_callback (poptContext ctx, } results->progress_data->percentage = atoi (arg); 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: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); -- cgit From 69636459e1faf1ce41685550cf7aec59acfbac39 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Jan 2003 16:48:45 +0000 Subject: Improve error handling. Make --list actually return something useful, 2003-01-13 Glynn Foster * src/main.c: Improve error handling. * src/tree.c: Make --list actually return something useful, although I still need to actually seperate things out so it's actually decipherable. * TODO: Update accordingly. --- src/main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 53cfc992..03f6d4c6 100644 --- a/src/main.c +++ b/src/main.c @@ -842,6 +842,9 @@ void zenity_parse_options_callback (poptContext ctx, const char *arg, void *data) { + static gboolean parse_option_text = FALSE; + static gboolean parse_option_file = FALSE; + if (reason == POPT_CALLBACK_REASON_POST) { return; } @@ -956,6 +959,12 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_QUESTIONTEXT: case OPTION_PROGRESSTEXT: case OPTION_WARNINGTEXT: + if (parse_option_text == TRUE) { + g_printerr (_("--text given twice for the same dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + switch (results->mode) { case MODE_CALENDAR: results->calendar_data->dialog_text = g_strdup (arg); @@ -977,6 +986,7 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } + parse_option_text = TRUE; break; case OPTION_DAY: if (results->mode != MODE_CALENDAR) { @@ -1045,6 +1055,12 @@ void zenity_parse_options_callback (poptContext ctx, break; case OPTION_FILENAME: case OPTION_TEXTFILE: + if (parse_option_file == TRUE) { + g_printerr (_("--filename given twice for the same dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + switch (results->mode) { case MODE_FILE: results->file_data->uri = g_strdup (arg); @@ -1057,6 +1073,7 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } + parse_option_file = TRUE; break; case OPTION_COLUMN: if (results->mode != MODE_LIST) { -- cgit From 9a77e41fecb3489b069aa7b1bb52ba56f1052819 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Mon, 13 Jan 2003 17:35:57 +0000 Subject: Localise output of --calendar dialog by default (using nl_langinfo), and provide a --date-format option to provide a strftime-style format for the returned date. --- src/main.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 03f6d4c6..5b023112 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ #include "config.h" #include "zenity.h" #include +#include typedef enum { MODE_CALENDAR, @@ -54,6 +55,7 @@ typedef struct { enum { OPTION_CALENDAR = 1, + OPTION_DATEFORMAT, OPTION_ENTRY, OPTION_ERROR, OPTION_INFO, @@ -275,6 +277,14 @@ struct poptOption calendar_options[] = { N_("Set the calendar year"), NULL }, + { "date-format", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_DATEFORMAT, + N_("Set the format for the returned date"), + NULL + }, POPT_TABLEEND }; @@ -701,6 +711,7 @@ zenity_init_parsing_options (void) { results->tree_data = g_new0 (ZenityTreeData, 1); /* Give some sensible defaults */ + results->calendar_data->date_format = g_strdup (nl_langinfo (D_FMT)); results->calendar_data->day = 0; results->calendar_data->month = 0; results->calendar_data->year = 0; @@ -726,6 +737,8 @@ zenity_free_parsing_options (void) { case MODE_CALENDAR: if (results->calendar_data->dialog_text) g_free (results->calendar_data->dialog_text); + if (results->calendar_data->date_format) + g_free (results->calendar_data->date_format); break; case MODE_ENTRY: if (results->entry_data->dialog_text) @@ -1027,6 +1040,14 @@ void zenity_parse_options_callback (poptContext ctx, } results->calendar_data->year = atoi (arg); break; + case OPTION_DATEFORMAT: + if (results->mode != MODE_CALENDAR) { + g_printerr (_("--date-format is not supported for this dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + results->calendar_data->date_format = g_strdup (arg); + break; case OPTION_INPUTTEXT: if (results->mode != MODE_ENTRY) { g_printerr (_("--entry-text is not supported for this dialog\n")); -- cgit From 1e0ff80be4b1fe6f2e6def15bfc02b2d09312061 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Jan 2003 18:16:50 +0000 Subject: Re-structure the code to pass in the ZenityData structure into the 2003-01-13 Glynn Foster * src/calendar.c: Re-structure the code to pass in the ZenityData structure into the response_callback instead. * src/main.c: Fix the screwups in the commandline parser due to popt being teh suck. * src/msg.c: Don't unref the GladeXML before you use it. * THANKS: New file. --- src/main.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 5b023112..3e58bd49 100644 --- a/src/main.c +++ b/src/main.c @@ -855,8 +855,9 @@ void zenity_parse_options_callback (poptContext ctx, const char *arg, void *data) { - static gboolean parse_option_text = FALSE; - static gboolean parse_option_file = FALSE; + static gboolean parse_option_dateformat = FALSE; + static gint parse_option_text = 0; + static gint parse_option_file = 0; if (reason == POPT_CALLBACK_REASON_POST) { return; @@ -972,7 +973,13 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_QUESTIONTEXT: case OPTION_PROGRESSTEXT: case OPTION_WARNINGTEXT: - if (parse_option_text == TRUE) { + + /* FIXME: This is an ugly hack because of the way the poptOptions are + * ordered above. When you try and use an --option more than once + * parse_options_callback gets called for each option. Suckage + */ + + if (parse_option_text > 6) { g_printerr (_("--text given twice for the same dialog\n")); zenity_free_parsing_options (); exit (-1); @@ -999,7 +1006,7 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } - parse_option_text = TRUE; + parse_option_text++; break; case OPTION_DAY: if (results->mode != MODE_CALENDAR) { @@ -1046,7 +1053,13 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } + if (parse_option_dateformat == TRUE) { + g_printerr (_("--date-format given twice for the same dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } results->calendar_data->date_format = g_strdup (arg); + parse_option_dateformat = TRUE; break; case OPTION_INPUTTEXT: if (results->mode != MODE_ENTRY) { @@ -1076,7 +1089,13 @@ void zenity_parse_options_callback (poptContext ctx, break; case OPTION_FILENAME: case OPTION_TEXTFILE: - if (parse_option_file == TRUE) { + + /* FIXME: This is an ugly hack because of the way the poptOptions are + * ordered above. When you try and use an --option more than once + * parse_options_callback gets called for each option. Suckage + */ + + if (parse_option_file > 2) { g_printerr (_("--filename given twice for the same dialog\n")); zenity_free_parsing_options (); exit (-1); @@ -1094,7 +1113,7 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } - parse_option_file = TRUE; + parse_option_file++; break; case OPTION_COLUMN: if (results->mode != MODE_LIST) { -- cgit From f00eb34c0604dcf68457ab09278295f647c622b8 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 14 Jan 2003 01:52:23 +0000 Subject: Add support to separate the selected rows output with a character with '/' 2003-01-14 Glynn Foster * src/tree.c, src/zenity.h, src/main.c: Add support to separate the selected rows output with a character with '/' used by default. --- src/main.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 3e58bd49..26232327 100644 --- a/src/main.c +++ b/src/main.c @@ -78,6 +78,7 @@ enum { OPTION_INFOTEXT, OPTION_FILENAME, OPTION_COLUMN, + OPTION_SEPERATOR, OPTION_CHECKLIST, OPTION_RADIOLIST, OPTION_PROGRESSTEXT, @@ -431,6 +432,15 @@ struct poptOption list_options[] = { N_("Use radio buttons for first column"), NULL }, + { + "separator", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_SEPERATOR, + N_("Set output separator character"), + NULL + }, POPT_TABLEEND }; @@ -716,6 +726,7 @@ zenity_init_parsing_options (void) { results->calendar_data->month = 0; results->calendar_data->year = 0; results->calendar_data->dialog_text = NULL; + results->tree_data->separator = g_strdup ("/"); results->progress_data->percentage = -1; results->progress_data->pulsate = FALSE; results->entry_data->visible = TRUE; @@ -764,6 +775,8 @@ zenity_free_parsing_options (void) { case MODE_LIST: if (results->tree_data->columns) g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); + if (results->tree_data->separator) + g_free (results->tree_data->separator); break; default: break; @@ -856,6 +869,7 @@ void zenity_parse_options_callback (poptContext ctx, void *data) { static gboolean parse_option_dateformat = FALSE; + static gboolean parse_option_separator = FALSE; static gint parse_option_text = 0; static gint parse_option_file = 0; @@ -1149,6 +1163,20 @@ void zenity_parse_options_callback (poptContext ctx, } results->tree_data->radiobox = TRUE; break; + case OPTION_SEPERATOR: + if (results->mode != MODE_LIST) { + g_printerr (_("--separator is not supported for this dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + if (parse_option_separator == TRUE) { + g_printerr (_("--separator given twice for the same dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + results->tree_data->separator = g_strdup (arg); + parse_option_separator = TRUE; + break; case OPTION_PERCENTAGE: if (results->mode != MODE_PROGRESS) { g_printerr (_("--percentage is not supported for this dialog\n")); -- cgit From 15538e120d8d184962d406fee5d7bd6600d2463d Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 14 Jan 2003 03:16:47 +0000 Subject: Add an about box. Still need to add an icon, and implement the callbacks 2003-01-14 Glynn Foster * src/Makefile.am, src/about.c, src/main.c, src/zenity.glade: Add an about box. Still need to add an icon, and implement the callbacks for Help and Credits. Extra hassle for not linking against libgnomeui. Sigh. --- src/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 26232327..bcd3208d 100644 --- a/src/main.c +++ b/src/main.c @@ -37,6 +37,7 @@ typedef enum { MODE_TEXTINFO, MODE_WARNING, MODE_INFO, + MODE_ABOUT, MODE_LAST } ZenityDialogMode; @@ -849,6 +850,9 @@ main (gint argc, gchar **argv) { case MODE_TEXTINFO: zenity_text (results->data, results->text_data); break; + case MODE_ABOUT: + zenity_about (results->data); + break; default: g_assert_not_reached (); zenity_free_parsing_options (); @@ -1204,8 +1208,7 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } - g_print ("This does nothing at the moment\n"); - exit (0); + results->mode = MODE_ABOUT; break; case OPTION_VERSION: if (results->mode != MODE_LAST) { -- cgit From f182d9f7fce8e9a57c03eb71f4467894394d0104 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 18 Jan 2003 13:35:13 +0000 Subject: Some new window icons. 2003-01-18 Glynn Foster * data/Makefile.am, data/zenity-calendar.png, data/zenity-entry.png, data/zenity-progress.png, data/zenity-text.png: Some new window icons. * src/text.c: Fix crash where the GladeXML ref was getting unref'd before we wanted to use it. * src/main.c: Fix up commandline parsing a little, although we should really add the parsing options for gtk+. * src/zenity.glade: Give some saner defaults. * THANKS, src/about.c: Update for all the people I stole icons and code from. * TODO: Update accordingly. --- src/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index bcd3208d..58bb13e7 100644 --- a/src/main.c +++ b/src/main.c @@ -812,6 +812,9 @@ main (gint argc, gchar **argv) { /*nothing*/; if (nextopt != -1) { + /* FIXME : We should probably handle --display, or at least maybe load some of the gtk+ + * commandline options + */ g_printerr (_("%s in an invalid option for this dialog\n"), poptBadOption (ctx, 0)); zenity_free_parsing_options (); exit (-1); @@ -1220,8 +1223,6 @@ void zenity_parse_options_callback (poptContext ctx, exit (0); break; default: - g_warning ("Invalid option %s", arg); - zenity_free_parsing_options (); - exit (-1); + break; } } -- cgit From 18760d406d64f71f7ca6fec5a7a01978418fa8f5 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 18 Jan 2003 18:02:14 +0000 Subject: Only some examples and some screenshots and we're mostly done for a first 2003-01-18 Glynn Foster * help/C/zenity.xml: Only some examples and some screenshots and we're mostly done for a first draft. * src/calendar.c: Don't set the text if it's NULL. * src/main.c: Swap the order of the commandline dialogs so that we're alphabetical. * src/zenity.glade: Add some default strings. --- src/main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 58bb13e7..0e762473 100644 --- a/src/main.c +++ b/src/main.c @@ -137,21 +137,21 @@ struct poptOption options[] = { NULL }, { - "info", + "file-selection", '\0', POPT_ARG_NONE, NULL, - OPTION_INFO, - N_("Display info dialog"), + OPTION_FILE, + N_("Display file selection dialog"), NULL }, { - "file-selection", + "info", '\0', POPT_ARG_NONE, NULL, - OPTION_FILE, - N_("Display file selection dialog"), + OPTION_INFO, + N_("Display info dialog"), NULL }, { @@ -614,27 +614,27 @@ struct poptOption application_options[] = { NULL, '\0', POPT_ARG_INCLUDE_TABLE, - info_options, + error_options, 0, - N_("Info options"), + N_("Error options"), NULL }, { NULL, '\0', POPT_ARG_INCLUDE_TABLE, - error_options, + file_selection_options, 0, - N_("Error options"), + N_("File selection options"), NULL }, { NULL, '\0', POPT_ARG_INCLUDE_TABLE, - file_selection_options, + info_options, 0, - N_("File selection options"), + N_("Info options"), NULL }, { -- cgit From 1e1dfef56ec71f732941398529cb1d8c79190c41 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Sun, 19 Jan 2003 12:13:08 +0000 Subject: Add --editable option to --text-info, and return edited textbuffer contents on dialog close. --- src/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 0e762473..a8e1e0e4 100644 --- a/src/main.c +++ b/src/main.c @@ -65,6 +65,7 @@ enum { OPTION_PROGRESS, OPTION_QUESTION, OPTION_TEXTINFO, + OPTION_TEXTEDIT, OPTION_WARNING, OPTION_TITLE, OPTION_ICON, @@ -517,6 +518,15 @@ struct poptOption text_options[] = { N_("Open file"), N_("FILENAME") }, + { + "editable", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_TEXTEDIT, + N_("Allow changes to text"), + NULL + }, POPT_TABLEEND }; @@ -727,6 +737,7 @@ zenity_init_parsing_options (void) { results->calendar_data->month = 0; results->calendar_data->year = 0; results->calendar_data->dialog_text = NULL; + results->text_data->editable = FALSE; results->tree_data->separator = g_strdup ("/"); results->progress_data->percentage = -1; results->progress_data->pulsate = FALSE; @@ -1108,6 +1119,19 @@ void zenity_parse_options_callback (poptContext ctx, } results->entry_data->visible = FALSE; break; + case OPTION_TEXTEDIT: + if (results->mode != MODE_TEXTINFO) { + g_printerr (_("--editable is not supported for this dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + if (results->text_data->editable == TRUE) { + g_printerr (_("--editable given twice for the same dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + results->text_data->editable = TRUE; + break; case OPTION_FILENAME: case OPTION_TEXTFILE: -- cgit From 3a90fe71679d726ffe39ad2a7ee9104485d53005 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 19 Jan 2003 12:48:57 +0000 Subject: Attempt to make things work after 2 bottles of wine last night. Harmless 2003-01-19 Glynn Foster * src/about.c: Attempt to make things work after 2 bottles of wine last night. Harmless changes though, so I'll commit them for posterity. * src/main.c: Add a new helper function for the error reporting that makes the translators life easier. Thanks to Ole for spotting this. * src/text.c, src/zenity.h: Lame white spacing hacking. * xmldocs.make: Put the docs in $(datadir)/help - not quite sure yet if yelp is going to like this or not. --- src/main.c | 366 ++++++++++++++++++++++++++----------------------------------- 1 file changed, 154 insertions(+), 212 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index a8e1e0e4..c2155f15 100644 --- a/src/main.c +++ b/src/main.c @@ -41,6 +41,13 @@ typedef enum { MODE_LAST } ZenityDialogMode; +typedef enum { + ERROR_DUPLICATE, + ERROR_SUPPORT, + ERROR_DIALOG, + ERROR_LAST +} ZenityError; + typedef struct { ZenityDialogMode mode; ZenityData *data; @@ -879,12 +886,33 @@ main (gint argc, gchar **argv) { exit (retval); } -static -void zenity_parse_options_callback (poptContext ctx, - enum poptCallbackReason reason, - const struct poptOption *opt, - const char *arg, - void *data) +static void +zenity_error (gchar *string, ZenityError error) +{ + switch (error) { + case ERROR_DUPLICATE: + g_printerr (_("%s given twice for the same dialog\n"), string); + zenity_free_parsing_options (); + exit (-1); + case ERROR_SUPPORT: + g_printerr (_("%s is not supported for this dialog\n"), string); + zenity_free_parsing_options (); + exit (-1); + case ERROR_DIALOG: + g_printerr (_("Two or more dialog options specified\n")); + zenity_free_parsing_options (); + exit (-1); + default: + return; + } +} + +static void +zenity_parse_options_callback (poptContext ctx, + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, + void *data) { static gboolean parse_option_dateformat = FALSE; static gboolean parse_option_separator = FALSE; @@ -900,103 +928,79 @@ void zenity_parse_options_callback (poptContext ctx, switch (opt->val & POPT_ARG_MASK) { case OPTION_CALENDAR: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_CALENDAR; break; case OPTION_ENTRY: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_ENTRY; break; case OPTION_ERROR: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_ERROR; results->msg_data->mode = ZENITY_MSG_ERROR; break; case OPTION_INFO: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_INFO; results->msg_data->mode = ZENITY_MSG_INFO; break; case OPTION_FILE: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_FILE; break; case OPTION_LIST: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_LIST; break; case OPTION_PROGRESS: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_PROGRESS; break; case OPTION_QUESTION: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_QUESTION; results->msg_data->mode = ZENITY_MSG_QUESTION; break; case OPTION_TEXTINFO: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_TEXTINFO; break; case OPTION_WARNING: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_WARNING; results->msg_data->mode = ZENITY_MSG_WARNING; break; case OPTION_TITLE: - if (results->data->dialog_title != NULL) { - g_printerr (_("--title given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->data->dialog_title != NULL) + zenity_error ("--title", ERROR_DUPLICATE); + results->data->dialog_title = g_strdup (arg); break; case OPTION_ICON: - if (results->data->window_icon != NULL) { - g_printerr (_("--window-icon given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->data->window_icon != NULL) + zenity_error ("--window-icon", ERROR_DUPLICATE); + results->data->window_icon = g_strdup (arg); break; case OPTION_CALENDARTEXT: @@ -1011,11 +1015,8 @@ void zenity_parse_options_callback (poptContext ctx, * parse_options_callback gets called for each option. Suckage */ - if (parse_option_text > 6) { - g_printerr (_("--text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (parse_option_text > 6) + zenity_error ("--text", ERROR_DUPLICATE); switch (results->mode) { case MODE_CALENDAR: @@ -1034,102 +1035,72 @@ void zenity_parse_options_callback (poptContext ctx, results->progress_data->dialog_text = g_strdup (arg); break; default: - g_printerr (_("--text is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); + zenity_error ("--text", ERROR_SUPPORT); } parse_option_text++; break; case OPTION_DAY: - if (results->mode != MODE_CALENDAR) { - g_printerr (_("--day is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->calendar_data->day > 0) { - g_printerr (_("--day given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_CALENDAR) + zenity_error ("--day", ERROR_SUPPORT); + + if (results->calendar_data->day > 0) + zenity_error ("--day", ERROR_DUPLICATE); + results->calendar_data->day = atoi (arg); break; case OPTION_MONTH: - if (results->mode != MODE_CALENDAR) { - g_printerr (_("--month is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->calendar_data->month > 0) { - g_printerr (_("--month given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_CALENDAR) + zenity_error ("--month", ERROR_SUPPORT); + + if (results->calendar_data->month > 0) + zenity_error ("--day", ERROR_DUPLICATE); + results->calendar_data->month = atoi (arg); break; case OPTION_YEAR: - if (results->mode != MODE_CALENDAR) { - g_printerr (_("--year is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->calendar_data->year > 0) { - g_printerr (_("--year given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_CALENDAR) + zenity_error ("--year", ERROR_SUPPORT); + + if (results->calendar_data->year > 0) + zenity_error ("--year", ERROR_DUPLICATE); + results->calendar_data->year = atoi (arg); break; case OPTION_DATEFORMAT: - if (results->mode != MODE_CALENDAR) { - g_printerr (_("--date-format is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (parse_option_dateformat == TRUE) { - g_printerr (_("--date-format given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_CALENDAR) + zenity_error ("--date-format", ERROR_SUPPORT); + + if (parse_option_dateformat == TRUE) + zenity_error ("--date-format", ERROR_DUPLICATE); + results->calendar_data->date_format = g_strdup (arg); parse_option_dateformat = TRUE; break; case OPTION_INPUTTEXT: - if (results->mode != MODE_ENTRY) { - g_printerr (_("--entry-text is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->entry_data->entry_text != NULL) { - g_printerr (_("--entry-text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_ENTRY) + zenity_error ("--entry-text", ERROR_SUPPORT); + + if (results->entry_data->entry_text != NULL) + zenity_error ("--entry-text", ERROR_DUPLICATE); + results->entry_data->entry_text = g_strdup (arg); break; case OPTION_HIDETEXT: - if (results->mode != MODE_ENTRY) { - g_printerr (_("--hide-text is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->entry_data->visible == FALSE) { - g_printerr (_("--hide-text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_ENTRY) + zenity_error ("--hide-text", ERROR_SUPPORT); + + if (results->entry_data->visible == FALSE) + zenity_error ("--hide-text", ERROR_DUPLICATE); + results->entry_data->visible = FALSE; break; case OPTION_TEXTEDIT: - if (results->mode != MODE_TEXTINFO) { - g_printerr (_("--editable is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->text_data->editable == TRUE) { - g_printerr (_("--editable given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_TEXTINFO) + zenity_error ("--editable", ERROR_SUPPORT); + + if (results->text_data->editable == TRUE) + zenity_error ("--editable", ERROR_DUPLICATE); + results->text_data->editable = TRUE; break; case OPTION_FILENAME: @@ -1140,11 +1111,8 @@ void zenity_parse_options_callback (poptContext ctx, * parse_options_callback gets called for each option. Suckage */ - if (parse_option_file > 2) { - g_printerr (_("--filename given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (parse_option_file > 2) + zenity_error ("--filename", ERROR_DUPLICATE); switch (results->mode) { case MODE_FILE: @@ -1154,95 +1122,69 @@ void zenity_parse_options_callback (poptContext ctx, results->text_data->uri = g_strdup (arg); break; default: - g_printerr (_("--filename is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); + zenity_error ("--filename", ERROR_SUPPORT); } parse_option_file++; break; case OPTION_COLUMN: - if (results->mode != MODE_LIST) { - g_printerr (_("--column is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LIST) + zenity_error ("--column", ERROR_SUPPORT); + results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); break; case OPTION_CHECKLIST: - if (results->mode != MODE_LIST) { - g_printerr (_("--checkbox is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->tree_data->checkbox == TRUE) { - g_printerr (_("--checkbox given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LIST) + zenity_error ("--checkbox", ERROR_SUPPORT); + + if (results->tree_data->checkbox == TRUE) + zenity_error ("--checkbox", ERROR_DUPLICATE); + results->tree_data->checkbox = TRUE; break; case OPTION_RADIOLIST: - if (results->mode != MODE_LIST) { - g_printerr (_("--radiobox is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->tree_data->radiobox == TRUE) { - g_printerr (_("--radiobox given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LIST) + zenity_error ("--radiobox", ERROR_SUPPORT); + + if (results->tree_data->radiobox == TRUE) + zenity_error ("--radiobox", ERROR_DUPLICATE); + results->tree_data->radiobox = TRUE; break; case OPTION_SEPERATOR: - if (results->mode != MODE_LIST) { - g_printerr (_("--separator is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (parse_option_separator == TRUE) { - g_printerr (_("--separator given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LIST) + zenity_error ("--separator", ERROR_SUPPORT); + + if (parse_option_separator == TRUE) + zenity_error ("--separator", ERROR_DUPLICATE); + results->tree_data->separator = g_strdup (arg); parse_option_separator = TRUE; break; case OPTION_PERCENTAGE: - if (results->mode != MODE_PROGRESS) { - g_printerr (_("--percentage is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->progress_data->percentage > -1) { - g_printerr (_("--percentage given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_PROGRESS) + zenity_error ("--percentage", ERROR_SUPPORT); + + if (results->progress_data->percentage > -1) + zenity_error ("--percentage", ERROR_DUPLICATE); + results->progress_data->percentage = atoi (arg); 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); - } + if (results->mode != MODE_PROGRESS) + zenity_error ("--pulsate", ERROR_SUPPORT); + results->progress_data->pulsate = TRUE; break; case OPTION_ABOUT: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_ABOUT; break; case OPTION_VERSION: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + g_print ("%s\n", VERSION); exit (0); break; -- cgit From 525e0dbe64d049602becadb3e6571fdce7f8687b Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 22 Jan 2003 02:03:09 +0000 Subject: Print out warning when we have no arguments to the commandline. 2003-01-22 Glynn Foster * src/main.c: Print out warning when we have no arguments to the commandline. * TODO: Add another item --- src/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index c2155f15..43502141 100644 --- a/src/main.c +++ b/src/main.c @@ -833,7 +833,8 @@ main (gint argc, gchar **argv) { /* FIXME : We should probably handle --display, or at least maybe load some of the gtk+ * commandline options */ - g_printerr (_("%s in an invalid option for this dialog\n"), poptBadOption (ctx, 0)); + g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"), + poptBadOption (ctx, 0)); zenity_free_parsing_options (); exit (-1); } @@ -841,6 +842,7 @@ main (gint argc, gchar **argv) { gtk_init (&argc, &argv); if (argc < 2) { + g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); zenity_free_parsing_options (); exit (-1); } -- cgit From 22625f8b16e1dc38be50cc2e869780b74e7f6891 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 28 Jan 2003 14:58:30 +0000 Subject: Don't display the translators tab unless there is stuff to show. 2003-01-28 Glynn Foster * src/about.c: Don't display the translators tab unless there is stuff to show. * src/entry.c: Add sanity NULL checking. * src/tree.c, src/zenity.h: Add support for a new --editable option. * src/main.c: Add support for new --editable option for the List dialog. Merge in the list of Gtk+ options into the popt table - ripped this from libbonoboui, thanks to James for pointing this out. * src/zenity.glade: Make the translatable strings less arse. * TODO: Update accordingly. --- src/main.c | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 174 insertions(+), 15 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 43502141..13399236 100644 --- a/src/main.c +++ b/src/main.c @@ -88,6 +88,7 @@ enum { OPTION_FILENAME, OPTION_COLUMN, OPTION_SEPERATOR, + OPTION_LISTEDIT, OPTION_CHECKLIST, OPTION_RADIOLIST, OPTION_PROGRESSTEXT, @@ -450,6 +451,15 @@ struct poptOption list_options[] = { N_("Set output separator character"), NULL }, + { + "editable", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_LISTEDIT, + N_("Allow changes to text"), + NULL + }, POPT_TABLEEND }; @@ -559,6 +569,134 @@ struct poptOption warning_options[] = { POPT_TABLEEND }; +struct poptOption gtk_options[] = { + { + "gdk-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gdk debugging flags to set"), + N_("FLAGS") + }, + { + "gdk-no-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gdk debugging flags to unset"), + N_("FLAGS") + }, + /* X11 only */ + { + "display", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("X display to use"), + N_("DISPLAY") + }, +#ifdef HAVE_GTK_MULTIHEAD + /* X11 & multi-head only */ + { + "screen", + '\0', + POPT_ARG_INT, + NULL, + 0, + N_("X screen to use"), + N_("SCREEN") + }, +#endif + /* X11 only */ + { + "sync", + '\0', + POPT_ARG_NONE, + NULL, + 0, + N_("Make X calls synchronous"), + NULL + }, + { + "name", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Program name as used by the window manager"), + N_("NAME") + }, + { + "class", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Program class as used by the window manager"), + N_("CLASS") + }, + /* X11 only */ + { + "gxid-host", + '\0', + POPT_ARG_STRING, + NULL, + 0, + NULL, + N_("HOST") + }, + /* X11 only */ + { + "gxid-port", + '\0', + POPT_ARG_STRING, + NULL, + 0, + NULL, + N_("PORT") + }, + { + "gtk-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gtk+ debugging flags to set"), + N_("FLAGS") + }, + { + "gtk-no-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gtk+ debugging flags to unset"), + N_("FLAGS") + }, + { + "g-fatal-warnings", + '\0', + POPT_ARG_NONE, + NULL, + 0, + N_("Make all warnings fatal"), + NULL + }, + { + "gtk-module", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Load an additional Gtk module"), + N_("MODULE") + }, + POPT_TABLEEND +}; + struct poptOption miscellaneous_options[] = { { NULL, @@ -699,6 +837,15 @@ struct poptOption application_options[] = { N_("Warning options"), NULL }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + gtk_options, + 0, + N_("GTK+ options"), + NULL + }, { NULL, '\0', @@ -751,6 +898,7 @@ zenity_init_parsing_options (void) { results->entry_data->visible = TRUE; results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; + results->tree_data->editable = FALSE; } static void @@ -825,21 +973,17 @@ main (gint argc, gchar **argv) { ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0); - poptReadDefaultConfig(ctx, TRUE); + poptReadDefaultConfig(ctx, TRUE); while((nextopt = poptGetNextOpt(ctx)) > 0) /*nothing*/; - if (nextopt != -1) { - /* FIXME : We should probably handle --display, or at least maybe load some of the gtk+ - * commandline options - */ - g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"), + if (nextopt != -1) { + g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"), poptBadOption (ctx, 0)); - zenity_free_parsing_options (); - exit (-1); - } - - gtk_init (&argc, &argv); + zenity_free_parsing_options (); + exit (-1); + } + gtk_init (&argc, &argv); if (argc < 2) { g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); @@ -920,6 +1064,7 @@ zenity_parse_options_callback (poptContext ctx, static gboolean parse_option_separator = FALSE; static gint parse_option_text = 0; static gint parse_option_file = 0; + static gint parse_option_editable = 0; if (reason == POPT_CALLBACK_REASON_POST) { return; @@ -1096,14 +1241,28 @@ zenity_parse_options_callback (poptContext ctx, results->entry_data->visible = FALSE; break; + case OPTION_LISTEDIT: case OPTION_TEXTEDIT: - if (results->mode != MODE_TEXTINFO) - zenity_error ("--editable", ERROR_SUPPORT); - if (results->text_data->editable == TRUE) + /* FIXME: This is an ugly hack because of the way the poptOptions are + * ordered above. When you try and use an --option more than once + * parse_options_callback gets called for each option. Suckage + */ + + if (parse_option_file > 2) zenity_error ("--editable", ERROR_DUPLICATE); - results->text_data->editable = TRUE; + switch (results->mode) { + 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_TEXTFILE: -- cgit From feef0396836668db950026ce637ce805900dc1d7 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 29 Jan 2003 02:20:02 +0000 Subject: Don't do a g_assert_not_reached () if we don't have any dialog types. 2003-01-29 Glynn Foster * src/main.c: Don't do a g_assert_not_reached () if we don't have any dialog types. --- src/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 13399236..233aba53 100644 --- a/src/main.c +++ b/src/main.c @@ -1020,6 +1020,10 @@ main (gint argc, gchar **argv) { case MODE_ABOUT: zenity_about (results->data); break; + case MODE_LAST: + g_printerr (_("You must specify a dialog type. See 'zenity --help' for details\n")); + zenity_free_parsing_options (); + exit (-1); default: g_assert_not_reached (); zenity_free_parsing_options (); -- cgit From 49f89795349a47ae4e061666d84a715bf24f5373 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 10 Mar 2003 17:11:18 +0000 Subject: Mass indentation cleanup. Make sure the glade dialogs aren't initially 2003-03-10 Glynn Foster * src/about.c, 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/util.c, src/util.h, src/zenity.glade, src/zenity.h: Mass indentation cleanup. Make sure the glade dialogs aren't initially visible because this avoids a visibility jump. Apparently == TRUE is bad mojo. Fix up. --- src/main.c | 1922 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 961 insertions(+), 961 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 233aba53..3985dfd3 100644 --- a/src/main.c +++ b/src/main.c @@ -27,844 +27,844 @@ #include typedef enum { - MODE_CALENDAR, - MODE_ENTRY, - MODE_ERROR, - MODE_FILE, - MODE_LIST, - MODE_PROGRESS, - MODE_QUESTION, - MODE_TEXTINFO, - MODE_WARNING, - MODE_INFO, - MODE_ABOUT, - MODE_LAST + MODE_CALENDAR, + MODE_ENTRY, + MODE_ERROR, + MODE_FILE, + MODE_LIST, + MODE_PROGRESS, + MODE_QUESTION, + MODE_TEXTINFO, + MODE_WARNING, + MODE_INFO, + MODE_ABOUT, + MODE_LAST } ZenityDialogMode; typedef enum { - ERROR_DUPLICATE, - ERROR_SUPPORT, - ERROR_DIALOG, - ERROR_LAST + ERROR_DUPLICATE, + ERROR_SUPPORT, + ERROR_DIALOG, + ERROR_LAST } ZenityError; typedef struct { - ZenityDialogMode mode; - ZenityData *data; - - ZenityCalendarData *calendar_data; - ZenityMsgData *msg_data; - ZenityFileData *file_data; - ZenityEntryData *entry_data; - ZenityProgressData *progress_data; - ZenityTextData *text_data; - ZenityTreeData *tree_data; + ZenityDialogMode mode; + ZenityData *data; + + ZenityCalendarData *calendar_data; + ZenityMsgData *msg_data; + ZenityFileData *file_data; + ZenityEntryData *entry_data; + ZenityProgressData *progress_data; + ZenityTextData *text_data; + ZenityTreeData *tree_data; } ZenityParsingOptions; enum { - OPTION_CALENDAR = 1, - OPTION_DATEFORMAT, - OPTION_ENTRY, - OPTION_ERROR, - OPTION_INFO, - OPTION_FILE, - OPTION_LIST, - OPTION_PROGRESS, - OPTION_QUESTION, - OPTION_TEXTINFO, - OPTION_TEXTEDIT, - OPTION_WARNING, - OPTION_TITLE, - OPTION_ICON, - OPTION_CALENDARTEXT, - OPTION_DAY, - OPTION_MONTH, - OPTION_YEAR, - OPTION_ENTRYTEXT, - OPTION_INPUTTEXT, - OPTION_HIDETEXT, - OPTION_ERRORTEXT, - OPTION_INFOTEXT, - OPTION_FILENAME, - OPTION_COLUMN, - OPTION_SEPERATOR, - OPTION_LISTEDIT, - OPTION_CHECKLIST, - OPTION_RADIOLIST, - OPTION_PROGRESSTEXT, - OPTION_PERCENTAGE, - OPTION_PULSATE, - OPTION_QUESTIONTEXT, - OPTION_TEXTFILE, - OPTION_WARNINGTEXT, - OPTION_ABOUT, - OPTION_VERSION, - OPTION_LAST, + OPTION_CALENDAR = 1, + OPTION_DATEFORMAT, + OPTION_ENTRY, + OPTION_ERROR, + OPTION_INFO, + OPTION_FILE, + OPTION_LIST, + OPTION_PROGRESS, + OPTION_QUESTION, + OPTION_TEXTINFO, + OPTION_TEXTEDIT, + OPTION_WARNING, + OPTION_TITLE, + OPTION_ICON, + OPTION_CALENDARTEXT, + OPTION_DAY, + OPTION_MONTH, + OPTION_YEAR, + OPTION_ENTRYTEXT, + OPTION_INPUTTEXT, + OPTION_HIDETEXT, + OPTION_ERRORTEXT, + OPTION_INFOTEXT, + OPTION_FILENAME, + OPTION_COLUMN, + OPTION_SEPERATOR, + OPTION_LISTEDIT, + OPTION_CHECKLIST, + OPTION_RADIOLIST, + OPTION_PROGRESSTEXT, + OPTION_PERCENTAGE, + OPTION_PULSATE, + OPTION_QUESTIONTEXT, + OPTION_TEXTFILE, + OPTION_WARNINGTEXT, + OPTION_ABOUT, + OPTION_VERSION, + OPTION_LAST, }; static void zenity_parse_options_callback (poptContext ctx, - enum poptCallbackReason reason, - const struct poptOption *opt, - const char *arg, - void *data); + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, + void *data); struct poptOption options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "calendar", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_CALENDAR, - N_("Display calendar dialog"), - NULL - }, - { - "entry", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_ENTRY, - N_("Display text entry dialog"), - NULL - }, - { - "error", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_ERROR, - N_("Display error dialog"), - NULL - }, - { - "file-selection", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_FILE, - N_("Display file selection dialog"), - NULL - }, - { - "info", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_INFO, - N_("Display info dialog"), - NULL - }, - { - "list", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_LIST, - N_("Display list dialog"), - NULL - }, - { - "progress", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_PROGRESS, - N_("Display progress indication dialog"), - NULL - }, - { - "question", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_QUESTION, - N_("Display question dialog"), - NULL - }, - { - "text-info", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_TEXTINFO, - N_("Display text information dialog"), - NULL - }, - { - "warning", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_WARNING, - N_("Display warning dialog"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "calendar", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_CALENDAR, + N_("Display calendar dialog"), + NULL + }, + { + "entry", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_ENTRY, + N_("Display text entry dialog"), + NULL + }, + { + "error", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_ERROR, + N_("Display error dialog"), + NULL + }, + { + "file-selection", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_FILE, + N_("Display file selection dialog"), + NULL + }, + { + "info", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_INFO, + N_("Display info dialog"), + NULL + }, + { + "list", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_LIST, + N_("Display list dialog"), + NULL + }, + { + "progress", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_PROGRESS, + N_("Display progress indication dialog"), + NULL + }, + { + "question", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_QUESTION, + N_("Display question dialog"), + NULL + }, + { + "text-info", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_TEXTINFO, + N_("Display text information dialog"), + NULL + }, + { + "warning", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_WARNING, + N_("Display warning dialog"), + NULL + }, + POPT_TABLEEND }; struct poptOption general_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "title", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_TITLE, - N_("Set the dialog title"), - N_("TITLE") - }, - { - "window-icon", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_ICON, - N_("Set the window icon"), - N_("ICONPATH") - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "title", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_TITLE, + N_("Set the dialog title"), + N_("TITLE") + }, + { + "window-icon", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_ICON, + N_("Set the window icon"), + N_("ICONPATH") + }, + POPT_TABLEEND }; struct poptOption calendar_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_CALENDARTEXT, - N_("Set the dialog text"), - NULL - }, - { - "day", - '\0', - POPT_ARG_INT, - NULL, - OPTION_DAY, - N_("Set the calendar day"), - NULL - }, - { - "month", - '\0', - POPT_ARG_INT, - NULL, - OPTION_MONTH, - N_("Set the calendar month"), - NULL - }, - { - "year", - '\0', - POPT_ARG_INT, - NULL, - OPTION_YEAR, - N_("Set the calendar year"), - NULL - }, - { "date-format", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_DATEFORMAT, - N_("Set the format for the returned date"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_CALENDARTEXT, + N_("Set the dialog text"), + NULL + }, + { + "day", + '\0', + POPT_ARG_INT, + NULL, + OPTION_DAY, + N_("Set the calendar day"), + NULL + }, + { + "month", + '\0', + POPT_ARG_INT, + NULL, + OPTION_MONTH, + N_("Set the calendar month"), + NULL + }, + { + "year", + '\0', + POPT_ARG_INT, + NULL, + OPTION_YEAR, + N_("Set the calendar year"), + NULL + }, + { "date-format", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_DATEFORMAT, + N_("Set the format for the returned date"), + NULL + }, + POPT_TABLEEND }; struct poptOption entry_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_ENTRYTEXT, - N_("Set the dialog text"), - NULL - }, - { - "entry-text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_INPUTTEXT, - N_("Set the entry text"), - NULL - }, - { - "hide-text", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_HIDETEXT, - N_("Hide the entry text"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_ENTRYTEXT, + N_("Set the dialog text"), + NULL + }, + { + "entry-text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_INPUTTEXT, + N_("Set the entry text"), + NULL + }, + { + "hide-text", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_HIDETEXT, + N_("Hide the entry text"), + NULL + }, + POPT_TABLEEND }; struct poptOption error_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_ERRORTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_ERRORTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND }; struct poptOption info_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_INFOTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_INFOTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND }; struct poptOption file_selection_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "filename", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_FILENAME, - N_("Set the filename"), - N_("FILENAME") - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "filename", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_FILENAME, + N_("Set the filename"), + N_("FILENAME") + }, + POPT_TABLEEND }; struct poptOption list_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "column", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_COLUMN, - N_("Set the column header"), - NULL - }, - { - "checklist", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_CHECKLIST, - N_("Use check boxes for first column"), - NULL - }, - { - "radiolist", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_RADIOLIST, - N_("Use radio buttons for first column"), - NULL - }, - { - "separator", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_SEPERATOR, - N_("Set output separator character"), - NULL - }, - { - "editable", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_LISTEDIT, - N_("Allow changes to text"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "column", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_COLUMN, + N_("Set the column header"), + NULL + }, + { + "checklist", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_CHECKLIST, + N_("Use check boxes for first column"), + NULL + }, + { + "radiolist", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_RADIOLIST, + N_("Use radio buttons for first column"), + NULL + }, + { + "separator", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_SEPERATOR, + N_("Set output separator character"), + NULL + }, + { + "editable", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_LISTEDIT, + N_("Allow changes to text"), + NULL + }, + POPT_TABLEEND }; struct poptOption progress_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_PROGRESSTEXT, - N_("Set the dialog text"), - NULL - }, - { - "percentage", - '\0', - POPT_ARG_INT, - NULL, - OPTION_PERCENTAGE, - N_("Set initial percentage"), - NULL - }, - { - "pulsate", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_PULSATE, - N_("Pulsate progress bar"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_PROGRESSTEXT, + N_("Set the dialog text"), + NULL + }, + { + "percentage", + '\0', + POPT_ARG_INT, + NULL, + OPTION_PERCENTAGE, + N_("Set initial percentage"), + NULL + }, + { + "pulsate", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_PULSATE, + N_("Pulsate progress bar"), + NULL + }, + POPT_TABLEEND }; - + struct poptOption question_options[] = { - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_QUESTIONTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_QUESTIONTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND }; struct poptOption text_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "filename", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_TEXTFILE, - N_("Open file"), - N_("FILENAME") - }, - { - "editable", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_TEXTEDIT, - N_("Allow changes to text"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "filename", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_TEXTFILE, + N_("Open file"), + N_("FILENAME") + }, + { + "editable", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_TEXTEDIT, + N_("Allow changes to text"), + NULL + }, + POPT_TABLEEND }; struct poptOption warning_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_WARNINGTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_WARNINGTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND }; struct poptOption gtk_options[] = { - { - "gdk-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gdk debugging flags to set"), - N_("FLAGS") - }, - { - "gdk-no-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gdk debugging flags to unset"), - N_("FLAGS") - }, - /* X11 only */ - { - "display", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("X display to use"), - N_("DISPLAY") - }, + { + "gdk-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gdk debugging flags to set"), + N_("FLAGS") + }, + { + "gdk-no-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gdk debugging flags to unset"), + N_("FLAGS") + }, + /* X11 only */ + { + "display", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("X display to use"), + N_("DISPLAY") + }, #ifdef HAVE_GTK_MULTIHEAD - /* X11 & multi-head only */ - { - "screen", - '\0', - POPT_ARG_INT, - NULL, - 0, - N_("X screen to use"), - N_("SCREEN") - }, + /* X11 & multi-head only */ + { + "screen", + '\0', + POPT_ARG_INT, + NULL, + 0, + N_("X screen to use"), + N_("SCREEN") + }, #endif - /* X11 only */ - { - "sync", - '\0', - POPT_ARG_NONE, - NULL, - 0, - N_("Make X calls synchronous"), - NULL - }, - { - "name", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Program name as used by the window manager"), - N_("NAME") - }, - { - "class", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Program class as used by the window manager"), - N_("CLASS") - }, - /* X11 only */ - { - "gxid-host", - '\0', - POPT_ARG_STRING, - NULL, - 0, - NULL, - N_("HOST") - }, - /* X11 only */ - { - "gxid-port", - '\0', - POPT_ARG_STRING, - NULL, - 0, - NULL, - N_("PORT") - }, - { - "gtk-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gtk+ debugging flags to set"), - N_("FLAGS") - }, - { - "gtk-no-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gtk+ debugging flags to unset"), - N_("FLAGS") - }, - { - "g-fatal-warnings", - '\0', - POPT_ARG_NONE, - NULL, - 0, - N_("Make all warnings fatal"), - NULL - }, - { - "gtk-module", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Load an additional Gtk module"), - N_("MODULE") - }, - POPT_TABLEEND + /* X11 only */ + { + "sync", + '\0', + POPT_ARG_NONE, + NULL, + 0, + N_("Make X calls synchronous"), + NULL + }, + { + "name", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Program name as used by the window manager"), + N_("NAME") + }, + { + "class", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Program class as used by the window manager"), + N_("CLASS") + }, + /* X11 only */ + { + "gxid-host", + '\0', + POPT_ARG_STRING, + NULL, + 0, + NULL, + N_("HOST") + }, + /* X11 only */ + { + "gxid-port", + '\0', + POPT_ARG_STRING, + NULL, + 0, + NULL, + N_("PORT") + }, + { + "gtk-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gtk+ debugging flags to set"), + N_("FLAGS") + }, + { + "gtk-no-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gtk+ debugging flags to unset"), + N_("FLAGS") + }, + { + "g-fatal-warnings", + '\0', + POPT_ARG_NONE, + NULL, + 0, + N_("Make all warnings fatal"), + NULL + }, + { + "gtk-module", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Load an additional Gtk module"), + N_("MODULE") + }, + POPT_TABLEEND }; struct poptOption miscellaneous_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "about", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_ABOUT, - N_("About zenity"), - NULL - }, - { - "version", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_VERSION, - N_("Print version"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "about", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_ABOUT, + N_("About zenity"), + NULL + }, + { + "version", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_VERSION, + N_("Print version"), + NULL + }, + POPT_TABLEEND }; struct poptOption application_options[] = { - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - options, - 0, - N_("Dialog options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - general_options, - 0, - N_("General options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - calendar_options, - 0, - N_("Calendar options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - entry_options, - 0, - N_("Text entry options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - error_options, - 0, - N_("Error options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - file_selection_options, - 0, - N_("File selection options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - info_options, - 0, - N_("Info options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - list_options, - 0, - N_("List options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - progress_options, - 0, - N_("Progress options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - question_options, - 0, - N_("Question options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - text_options, - 0, - N_("Text options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - warning_options, - 0, - N_("Warning options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - gtk_options, - 0, - N_("GTK+ options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - miscellaneous_options, - 0, - N_("Miscellaneous options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - poptHelpOptions, - 0, - N_("Help options"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + options, + 0, + N_("Dialog options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + general_options, + 0, + N_("General options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + calendar_options, + 0, + N_("Calendar options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + entry_options, + 0, + N_("Text entry options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + error_options, + 0, + N_("Error options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + file_selection_options, + 0, + N_("File selection options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + info_options, + 0, + N_("Info options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + list_options, + 0, + N_("List options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + progress_options, + 0, + N_("Progress options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + question_options, + 0, + N_("Question options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + text_options, + 0, + N_("Text options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + warning_options, + 0, + N_("Warning options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + gtk_options, + 0, + N_("GTK+ options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + miscellaneous_options, + 0, + N_("Miscellaneous options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + poptHelpOptions, + 0, + N_("Help options"), + NULL + }, + POPT_TABLEEND }; ZenityParsingOptions *results; @@ -872,189 +872,189 @@ ZenityParsingOptions *results; static void zenity_init_parsing_options (void) { - results = g_new0 (ZenityParsingOptions, 1); - - /* Initialize the various dialog structures */ - results->mode = MODE_LAST; - results->data = g_new0 (ZenityData, 1); - results->calendar_data = g_new0 (ZenityCalendarData, 1); - results->msg_data = g_new0 (ZenityMsgData, 1); - results->file_data = g_new0 (ZenityFileData, 1); - results->entry_data = g_new0 (ZenityEntryData, 1); - results->progress_data = g_new0 (ZenityProgressData, 1); - results->text_data = g_new0 (ZenityTextData, 1); - results->tree_data = g_new0 (ZenityTreeData, 1); - - /* Give some sensible defaults */ - results->calendar_data->date_format = g_strdup (nl_langinfo (D_FMT)); - results->calendar_data->day = 0; - results->calendar_data->month = 0; - results->calendar_data->year = 0; - results->calendar_data->dialog_text = NULL; - results->text_data->editable = FALSE; - results->tree_data->separator = g_strdup ("/"); - results->progress_data->percentage = -1; - results->progress_data->pulsate = FALSE; - results->entry_data->visible = TRUE; - results->tree_data->checkbox = FALSE; - results->tree_data->radiobox = FALSE; - results->tree_data->editable = FALSE; + results = g_new0 (ZenityParsingOptions, 1); + + /* Initialize the various dialog structures */ + results->mode = MODE_LAST; + results->data = g_new0 (ZenityData, 1); + results->calendar_data = g_new0 (ZenityCalendarData, 1); + results->msg_data = g_new0 (ZenityMsgData, 1); + results->file_data = g_new0 (ZenityFileData, 1); + results->entry_data = g_new0 (ZenityEntryData, 1); + results->progress_data = g_new0 (ZenityProgressData, 1); + results->text_data = g_new0 (ZenityTextData, 1); + results->tree_data = g_new0 (ZenityTreeData, 1); + + /* Give some sensible defaults */ + results->calendar_data->date_format = g_strdup (nl_langinfo (D_FMT)); + results->calendar_data->day = 0; + results->calendar_data->month = 0; + results->calendar_data->year = 0; + results->calendar_data->dialog_text = NULL; + results->text_data->editable = FALSE; + results->tree_data->separator = g_strdup ("/"); + results->progress_data->percentage = -1; + results->progress_data->pulsate = FALSE; + results->entry_data->visible = TRUE; + results->tree_data->checkbox = FALSE; + results->tree_data->radiobox = FALSE; + results->tree_data->editable = FALSE; } static void zenity_free_parsing_options (void) { - /* General options */ - if (results->data->dialog_title) - g_free (results->data->dialog_title); - if (results->data->window_icon) - g_free (results->data->window_icon); - - /* Dialog options */ - switch (results->mode) { - case MODE_CALENDAR: - if (results->calendar_data->dialog_text) - g_free (results->calendar_data->dialog_text); - if (results->calendar_data->date_format) - g_free (results->calendar_data->date_format); - break; - case MODE_ENTRY: - if (results->entry_data->dialog_text) - g_free (results->entry_data->dialog_text); - if (results->entry_data->entry_text) - g_free (results->entry_data->entry_text); - break; - case MODE_ERROR: - case MODE_QUESTION: - case MODE_WARNING: - case MODE_INFO: - if (results->msg_data->dialog_text) - g_free (results->msg_data->dialog_text); - break; - case MODE_FILE: - if (results->file_data->uri) - g_free (results->file_data->uri); - break; - case MODE_TEXTINFO: - if (results->text_data->uri) - g_free (results->text_data->uri); - break; - case MODE_LIST: - if (results->tree_data->columns) - g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); - if (results->tree_data->separator) - g_free (results->tree_data->separator); - break; - default: - break; - } + /* General options */ + if (results->data->dialog_title) + g_free (results->data->dialog_title); + if (results->data->window_icon) + g_free (results->data->window_icon); + + /* Dialog options */ + switch (results->mode) { + case MODE_CALENDAR: + if (results->calendar_data->dialog_text) + g_free (results->calendar_data->dialog_text); + if (results->calendar_data->date_format) + g_free (results->calendar_data->date_format); + break; + case MODE_ENTRY: + if (results->entry_data->dialog_text) + g_free (results->entry_data->dialog_text); + if (results->entry_data->entry_text) + g_free (results->entry_data->entry_text); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + case MODE_INFO: + if (results->msg_data->dialog_text) + g_free (results->msg_data->dialog_text); + break; + case MODE_FILE: + if (results->file_data->uri) + g_free (results->file_data->uri); + break; + case MODE_TEXTINFO: + if (results->text_data->uri) + g_free (results->text_data->uri); + break; + case MODE_LIST: + if (results->tree_data->columns) + g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); + if (results->tree_data->separator) + g_free (results->tree_data->separator); + break; + default: + break; + } } gint main (gint argc, gchar **argv) { - ZenityData *general; - ZenityCalendarData *cal_data; - poptContext ctx; - gchar **args; - gint nextopt, retval; - - bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - textdomain(GETTEXT_PACKAGE); - - zenity_init_parsing_options (); - - /* FIXME: popt doesn't like passing stuff through data - * but it doesn't seem to cope with the data that I try - * to pass in, not quite sure why though. If someone knows - * what I'm doing wrong, we could probably put this back: - * options[0].descrip = (void*) results; - */ - - ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0); - - poptReadDefaultConfig(ctx, TRUE); - while((nextopt = poptGetNextOpt(ctx)) > 0) - /*nothing*/; - - if (nextopt != -1) { - g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"), - poptBadOption (ctx, 0)); - zenity_free_parsing_options (); - exit (-1); - } - gtk_init (&argc, &argv); - - if (argc < 2) { - g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); - zenity_free_parsing_options (); - exit (-1); - } - - switch (results->mode) { - case MODE_CALENDAR: - zenity_calendar (results->data, results->calendar_data); - break; - case MODE_ENTRY: - zenity_entry (results->data, results->entry_data); - break; - case MODE_ERROR: - case MODE_QUESTION: - case MODE_WARNING: - case MODE_INFO: - zenity_msg (results->data, results->msg_data); - break; - case MODE_FILE: - zenity_fileselection (results->data, results->file_data); - break; - case MODE_LIST: - results->tree_data->data = poptGetArgs (ctx); - zenity_tree (results->data, results->tree_data); - break; - case MODE_PROGRESS: - zenity_progress (results->data, results->progress_data); - break; - case MODE_TEXTINFO: - zenity_text (results->data, results->text_data); - break; - case MODE_ABOUT: - zenity_about (results->data); - break; - case MODE_LAST: - g_printerr (_("You must specify a dialog type. See 'zenity --help' for details\n")); - zenity_free_parsing_options (); - exit (-1); - default: - g_assert_not_reached (); - zenity_free_parsing_options (); - exit (-1); - } - - retval = results->data->exit_code; - poptFreeContext(ctx); - zenity_free_parsing_options (); - exit (retval); + ZenityData *general; + ZenityCalendarData *cal_data; + poptContext ctx; + gchar **args; + gint nextopt, retval; + + bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); + + zenity_init_parsing_options (); + + /* FIXME: popt doesn't like passing stuff through data + * but it doesn't seem to cope with the data that I try + * to pass in, not quite sure why though. If someone knows + * what I'm doing wrong, we could probably put this back: + * options[0].descrip = (void*) results; + */ + + ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0); + + poptReadDefaultConfig(ctx, TRUE); + while((nextopt = poptGetNextOpt(ctx)) > 0) + /*nothing*/; + + if (nextopt != -1) { + g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"), + poptBadOption (ctx, 0)); + zenity_free_parsing_options (); + exit (-1); + } + gtk_init (&argc, &argv); + + if (argc < 2) { + g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); + zenity_free_parsing_options (); + exit (-1); + } + + switch (results->mode) { + case MODE_CALENDAR: + zenity_calendar (results->data, results->calendar_data); + break; + case MODE_ENTRY: + zenity_entry (results->data, results->entry_data); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + case MODE_INFO: + zenity_msg (results->data, results->msg_data); + break; + case MODE_FILE: + zenity_fileselection (results->data, results->file_data); + break; + case MODE_LIST: + results->tree_data->data = poptGetArgs (ctx); + zenity_tree (results->data, results->tree_data); + break; + case MODE_PROGRESS: + zenity_progress (results->data, results->progress_data); + break; + case MODE_TEXTINFO: + zenity_text (results->data, results->text_data); + break; + case MODE_ABOUT: + zenity_about (results->data); + break; + case MODE_LAST: + g_printerr (_("You must specify a dialog type. See 'zenity --help' for details\n")); + zenity_free_parsing_options (); + exit (-1); + default: + g_assert_not_reached (); + zenity_free_parsing_options (); + exit (-1); + } + + retval = results->data->exit_code; + poptFreeContext(ctx); + zenity_free_parsing_options (); + exit (retval); } static void zenity_error (gchar *string, ZenityError error) { - switch (error) { - case ERROR_DUPLICATE: - g_printerr (_("%s given twice for the same dialog\n"), string); - zenity_free_parsing_options (); - exit (-1); - case ERROR_SUPPORT: - g_printerr (_("%s is not supported for this dialog\n"), string); - zenity_free_parsing_options (); - exit (-1); - case ERROR_DIALOG: - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - default: - return; - } + switch (error) { + case ERROR_DUPLICATE: + g_printerr (_("%s given twice for the same dialog\n"), string); + zenity_free_parsing_options (); + exit (-1); + case ERROR_SUPPORT: + g_printerr (_("%s is not supported for this dialog\n"), string); + zenity_free_parsing_options (); + exit (-1); + case ERROR_DIALOG: + g_printerr (_("Two or more dialog options specified\n")); + zenity_free_parsing_options (); + exit (-1); + default: + return; + } } static void @@ -1064,13 +1064,13 @@ zenity_parse_options_callback (poptContext ctx, const char *arg, void *data) { - static gboolean parse_option_dateformat = FALSE; - static gboolean parse_option_separator = FALSE; - static gint parse_option_text = 0; - static gint parse_option_file = 0; - static gint parse_option_editable = 0; + static gboolean parse_option_dateformat = FALSE; + static gboolean parse_option_separator = FALSE; + static gint parse_option_text = 0; + static gint parse_option_file = 0; + static gint parse_option_editable = 0; - if (reason == POPT_CALLBACK_REASON_POST) { + if (reason == POPT_CALLBACK_REASON_POST) { return; } else if (reason != POPT_CALLBACK_REASON_OPTION) @@ -1221,7 +1221,7 @@ zenity_parse_options_callback (poptContext ctx, if (results->mode != MODE_CALENDAR) zenity_error ("--date-format", ERROR_SUPPORT); - if (parse_option_dateformat == TRUE) + if (parse_option_dateformat) zenity_error ("--date-format", ERROR_DUPLICATE); results->calendar_data->date_format = g_strdup (arg); @@ -1240,7 +1240,7 @@ zenity_parse_options_callback (poptContext ctx, if (results->mode != MODE_ENTRY) zenity_error ("--hide-text", ERROR_SUPPORT); - if (results->entry_data->visible == FALSE) + if (!results->entry_data->visible) zenity_error ("--hide-text", ERROR_DUPLICATE); results->entry_data->visible = FALSE; @@ -1301,7 +1301,7 @@ zenity_parse_options_callback (poptContext ctx, if (results->mode != MODE_LIST) zenity_error ("--checkbox", ERROR_SUPPORT); - if (results->tree_data->checkbox == TRUE) + if (results->tree_data->checkbox) zenity_error ("--checkbox", ERROR_DUPLICATE); results->tree_data->checkbox = TRUE; @@ -1310,7 +1310,7 @@ zenity_parse_options_callback (poptContext ctx, if (results->mode != MODE_LIST) zenity_error ("--radiobox", ERROR_SUPPORT); - if (results->tree_data->radiobox == TRUE) + if (results->tree_data->radiobox) zenity_error ("--radiobox", ERROR_DUPLICATE); results->tree_data->radiobox = TRUE; @@ -1319,7 +1319,7 @@ zenity_parse_options_callback (poptContext ctx, if (results->mode != MODE_LIST) zenity_error ("--separator", ERROR_SUPPORT); - if (parse_option_separator == TRUE) + if (parse_option_separator) zenity_error ("--separator", ERROR_DUPLICATE); results->tree_data->separator = g_strdup (arg); -- cgit From 965c2a91497fcf96c88c0029b18a6a1e9f5d46bd Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 13 Apr 2003 15:42:41 +0000 Subject: Finish off the indentation cleanup. Add new '--width' and '--height' 2003-04-13 Glynn Foster * 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 --- src/main.c | 589 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 312 insertions(+), 277 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 3985dfd3..7393aa9f 100644 --- a/src/main.c +++ b/src/main.c @@ -76,6 +76,8 @@ enum { OPTION_WARNING, OPTION_TITLE, OPTION_ICON, + OPTION_WIDTH, + OPTION_HEIGHT, OPTION_CALENDARTEXT, OPTION_DAY, OPTION_MONTH, @@ -86,6 +88,7 @@ enum { OPTION_ERRORTEXT, OPTION_INFOTEXT, OPTION_FILENAME, + OPTION_TEXTFILENAME, OPTION_COLUMN, OPTION_SEPERATOR, OPTION_LISTEDIT, @@ -95,7 +98,6 @@ enum { OPTION_PERCENTAGE, OPTION_PULSATE, OPTION_QUESTIONTEXT, - OPTION_TEXTFILE, OPTION_WARNINGTEXT, OPTION_ABOUT, OPTION_VERSION, @@ -239,6 +241,24 @@ struct poptOption general_options[] = { N_("Set the window icon"), 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 }; @@ -531,7 +551,7 @@ struct poptOption text_options[] = { '\0', POPT_ARG_STRING, NULL, - OPTION_TEXTFILE, + OPTION_TEXTFILENAME, N_("Open file"), N_("FILENAME") }, @@ -886,6 +906,8 @@ zenity_init_parsing_options (void) { results->tree_data = g_new0 (ZenityTreeData, 1); /* 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->day = 0; results->calendar_data->month = 0; @@ -979,7 +1001,7 @@ main (gint argc, gchar **argv) { if (nextopt != -1) { 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 (); exit (-1); } @@ -1070,290 +1092,303 @@ zenity_parse_options_callback (poptContext ctx, static gint parse_option_file = 0; static gint parse_option_editable = 0; - if (reason == POPT_CALLBACK_REASON_POST) { - return; - } - else if (reason != POPT_CALLBACK_REASON_OPTION) - return; - - switch (opt->val & POPT_ARG_MASK) { - - case OPTION_CALENDAR: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_CALENDAR; - break; - case OPTION_ENTRY: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_ENTRY; - break; - case OPTION_ERROR: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_ERROR; - results->msg_data->mode = ZENITY_MSG_ERROR; - break; - case OPTION_INFO: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_INFO; - results->msg_data->mode = ZENITY_MSG_INFO; - break; - case OPTION_FILE: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_FILE; - break; - case OPTION_LIST: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_LIST; - break; - case OPTION_PROGRESS: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_PROGRESS; - break; - case OPTION_QUESTION: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_QUESTION; - results->msg_data->mode = ZENITY_MSG_QUESTION; - break; - case OPTION_TEXTINFO: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_TEXTINFO; - break; - case OPTION_WARNING: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_WARNING; - results->msg_data->mode = ZENITY_MSG_WARNING; - break; - case OPTION_TITLE: - if (results->data->dialog_title != NULL) - zenity_error ("--title", ERROR_DUPLICATE); - - results->data->dialog_title = g_strdup (arg); - break; - case OPTION_ICON: - if (results->data->window_icon != NULL) - zenity_error ("--window-icon", ERROR_DUPLICATE); - - results->data->window_icon = g_strdup (arg); - break; - case OPTION_CALENDARTEXT: - case OPTION_ENTRYTEXT: - case OPTION_ERRORTEXT: - case OPTION_QUESTIONTEXT: - case OPTION_PROGRESSTEXT: - case OPTION_WARNINGTEXT: - - /* FIXME: This is an ugly hack because of the way the poptOptions are - * ordered above. When you try and use an --option more than once - * parse_options_callback gets called for each option. Suckage - */ - - if (parse_option_text > 6) - zenity_error ("--text", ERROR_DUPLICATE); - - switch (results->mode) { - case MODE_CALENDAR: - results->calendar_data->dialog_text = g_strdup (arg); - 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 (reason == POPT_CALLBACK_REASON_POST) + return; + else if (reason != POPT_CALLBACK_REASON_OPTION) + return; - if (results->calendar_data->day > 0) - zenity_error ("--day", ERROR_DUPLICATE); + switch (opt->val & POPT_ARG_MASK) { - results->calendar_data->day = atoi (arg); - break; - case OPTION_MONTH: - if (results->mode != MODE_CALENDAR) - zenity_error ("--month", ERROR_SUPPORT); + case OPTION_CALENDAR: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - if (results->calendar_data->month > 0) - zenity_error ("--day", ERROR_DUPLICATE); - - results->calendar_data->month = atoi (arg); - break; - case OPTION_YEAR: - if (results->mode != MODE_CALENDAR) - zenity_error ("--year", ERROR_SUPPORT); - - if (results->calendar_data->year > 0) - zenity_error ("--year", ERROR_DUPLICATE); - - results->calendar_data->year = atoi (arg); - break; - case OPTION_DATEFORMAT: - if (results->mode != MODE_CALENDAR) - zenity_error ("--date-format", ERROR_SUPPORT); - - if (parse_option_dateformat) - zenity_error ("--date-format", ERROR_DUPLICATE); - - results->calendar_data->date_format = g_strdup (arg); - parse_option_dateformat = TRUE; - break; - case OPTION_INPUTTEXT: - if (results->mode != MODE_ENTRY) - zenity_error ("--entry-text", ERROR_SUPPORT); - - if (results->entry_data->entry_text != NULL) - zenity_error ("--entry-text", ERROR_DUPLICATE); - - results->entry_data->entry_text = g_strdup (arg); - break; - case OPTION_HIDETEXT: - if (results->mode != MODE_ENTRY) - zenity_error ("--hide-text", ERROR_SUPPORT); - - if (!results->entry_data->visible) - zenity_error ("--hide-text", ERROR_DUPLICATE); - - results->entry_data->visible = FALSE; - break; - case OPTION_LISTEDIT: - case OPTION_TEXTEDIT: - - /* FIXME: This is an ugly hack because of the way the poptOptions are - * ordered above. When you try and use an --option more than once - * parse_options_callback gets called for each option. Suckage - */ - - if (parse_option_file > 2) - zenity_error ("--editable", ERROR_DUPLICATE); - - switch (results->mode) { - 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_TEXTFILE: - - /* FIXME: This is an ugly hack because of the way the poptOptions are - * ordered above. When you try and use an --option more than once - * parse_options_callback gets called for each option. Suckage - */ + results->mode = MODE_CALENDAR; + break; + case OPTION_ENTRY: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - if (parse_option_file > 2) - zenity_error ("--filename", ERROR_DUPLICATE); + results->mode = MODE_ENTRY; + break; + case OPTION_ERROR: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - switch (results->mode) { - case MODE_FILE: - results->file_data->uri = g_strdup (arg); - 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->mode = MODE_ERROR; + results->msg_data->mode = ZENITY_MSG_ERROR; + break; + case OPTION_INFO: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); - break; - case OPTION_CHECKLIST: - if (results->mode != MODE_LIST) - zenity_error ("--checkbox", ERROR_SUPPORT); + results->mode = MODE_INFO; + results->msg_data->mode = ZENITY_MSG_INFO; + break; + case OPTION_FILE: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - if (results->tree_data->checkbox) - zenity_error ("--checkbox", ERROR_DUPLICATE); + results->mode = MODE_FILE; + break; + case OPTION_LIST: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - results->tree_data->checkbox = TRUE; - break; - case OPTION_RADIOLIST: - if (results->mode != MODE_LIST) - zenity_error ("--radiobox", ERROR_SUPPORT); + results->mode = MODE_LIST; + break; + case OPTION_PROGRESS: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - if (results->tree_data->radiobox) - zenity_error ("--radiobox", ERROR_DUPLICATE); - - results->tree_data->radiobox = TRUE; - break; - case OPTION_SEPERATOR: - if (results->mode != MODE_LIST) - zenity_error ("--separator", ERROR_SUPPORT); - - if (parse_option_separator) - zenity_error ("--separator", ERROR_DUPLICATE); - - results->tree_data->separator = g_strdup (arg); - parse_option_separator = TRUE; - break; - case OPTION_PERCENTAGE: - if (results->mode != MODE_PROGRESS) - zenity_error ("--percentage", ERROR_SUPPORT); + results->mode = MODE_PROGRESS; + break; + case OPTION_QUESTION: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - if (results->progress_data->percentage > -1) - zenity_error ("--percentage", ERROR_DUPLICATE); - - results->progress_data->percentage = atoi (arg); - break; - case OPTION_PULSATE: - if (results->mode != MODE_PROGRESS) - zenity_error ("--pulsate", ERROR_SUPPORT); - - results->progress_data->pulsate = TRUE; - break; - case OPTION_ABOUT: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_QUESTION; + results->msg_data->mode = ZENITY_MSG_QUESTION; + break; + case OPTION_TEXTINFO: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - results->mode = MODE_ABOUT; - break; - case OPTION_VERSION: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_TEXTINFO; + break; + case OPTION_WARNING: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - g_print ("%s\n", VERSION); - exit (0); - break; - default: - break; - } + results->mode = MODE_WARNING; + results->msg_data->mode = ZENITY_MSG_WARNING; + break; + case OPTION_TITLE: + if (results->data->dialog_title != NULL) + zenity_error ("--title", ERROR_DUPLICATE); + + results->data->dialog_title = g_strdup (arg); + break; + case OPTION_ICON: + if (results->data->window_icon != NULL) + zenity_error ("--window-icon", ERROR_DUPLICATE); + + results->data->window_icon = g_strdup (arg); + break; + case OPTION_WIDTH: + if (results->data->width != -1) + zenity_error ("--width", ERROR_DUPLICATE); + + results->data->width = atoi (arg); + break; + case OPTION_HEIGHT: + if (results->data->height != -1) + zenity_error ("--height", ERROR_DUPLICATE); + + results->data->height = atoi (arg); + break; + case OPTION_CALENDARTEXT: + case OPTION_ENTRYTEXT: + case OPTION_ERRORTEXT: + case OPTION_QUESTIONTEXT: + case OPTION_PROGRESSTEXT: + case OPTION_WARNINGTEXT: + + /* FIXME: This is an ugly hack because of the way the poptOptions are + * ordered above. When you try and use an --option more than once + * parse_options_callback gets called for each option. Suckage + */ + + if (parse_option_text > 6) + zenity_error ("--text", ERROR_DUPLICATE); + + switch (results->mode) { + case MODE_CALENDAR: + results->calendar_data->dialog_text = g_strdup (arg); + 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) + zenity_error ("--day", ERROR_DUPLICATE); + + results->calendar_data->day = atoi (arg); + break; + case OPTION_MONTH: + if (results->mode != MODE_CALENDAR) + zenity_error ("--month", ERROR_SUPPORT); + + if (results->calendar_data->month > 0) + zenity_error ("--day", ERROR_DUPLICATE); + + results->calendar_data->month = atoi (arg); + break; + case OPTION_YEAR: + if (results->mode != MODE_CALENDAR) + zenity_error ("--year", ERROR_SUPPORT); + + if (results->calendar_data->year > 0) + zenity_error ("--year", ERROR_DUPLICATE); + + results->calendar_data->year = atoi (arg); + break; + case OPTION_DATEFORMAT: + if (results->mode != MODE_CALENDAR) + zenity_error ("--date-format", ERROR_SUPPORT); + + if (parse_option_dateformat) + zenity_error ("--date-format", ERROR_DUPLICATE); + + results->calendar_data->date_format = g_strdup (arg); + parse_option_dateformat = TRUE; + break; + case OPTION_INPUTTEXT: + if (results->mode != MODE_ENTRY) + zenity_error ("--entry-text", ERROR_SUPPORT); + + if (results->entry_data->entry_text != NULL) + zenity_error ("--entry-text", ERROR_DUPLICATE); + + results->entry_data->entry_text = g_strdup (arg); + break; + case OPTION_HIDETEXT: + if (results->mode != MODE_ENTRY) + zenity_error ("--hide-text", ERROR_SUPPORT); + + if (!results->entry_data->visible) + zenity_error ("--hide-text", ERROR_DUPLICATE); + + results->entry_data->visible = FALSE; + break; + case OPTION_LISTEDIT: + case OPTION_TEXTEDIT: + + /* FIXME: This is an ugly hack because of the way the poptOptions are + * ordered above. When you try and use an --option more than once + * parse_options_callback gets called for each option. Suckage + */ + + if (parse_option_file > 2) + zenity_error ("--editable", ERROR_DUPLICATE); + + switch (results->mode) { + 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: + + /* FIXME: This is an ugly hack because of the way the poptOptions are + * ordered above. When you try and use an --option more than once + * parse_options_callback gets called for each option. Suckage + */ + + if (parse_option_file > 2) + zenity_error ("--filename", ERROR_DUPLICATE); + + switch (results->mode) { + 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->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); + break; + case OPTION_CHECKLIST: + if (results->mode != MODE_LIST) + zenity_error ("--checkbox", ERROR_SUPPORT); + + if (results->tree_data->checkbox) + zenity_error ("--checkbox", ERROR_DUPLICATE); + + results->tree_data->checkbox = TRUE; + break; + case OPTION_RADIOLIST: + if (results->mode != MODE_LIST) + zenity_error ("--radiobox", ERROR_SUPPORT); + if (results->tree_data->radiobox) + zenity_error ("--radiobox", ERROR_DUPLICATE); + + results->tree_data->radiobox = TRUE; + break; + case OPTION_SEPERATOR: + if (results->mode != MODE_LIST) + zenity_error ("--separator", ERROR_SUPPORT); + + if (parse_option_separator) + zenity_error ("--separator", ERROR_DUPLICATE); + + results->tree_data->separator = g_strdup (arg); + parse_option_separator = TRUE; + break; + case OPTION_PERCENTAGE: + if (results->mode != MODE_PROGRESS) + zenity_error ("--percentage", ERROR_SUPPORT); + + if (results->progress_data->percentage > -1) + zenity_error ("--percentage", ERROR_DUPLICATE); + + results->progress_data->percentage = atoi (arg); + break; + case OPTION_PULSATE: + if (results->mode != MODE_PROGRESS) + zenity_error ("--pulsate", ERROR_SUPPORT); + + results->progress_data->pulsate = TRUE; + break; + case OPTION_ABOUT: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + + results->mode = MODE_ABOUT; + break; + case OPTION_VERSION: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + zenity_free_parsing_options (); + g_print ("%s\n", VERSION); + exit (0); + break; + default: + break; + } } -- cgit From 9da64526615991b0dc76949d6113d72779242aa5 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 13 Apr 2003 15:48:15 +0000 Subject: Ooops - fix build. --- src/main.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 7393aa9f..2f97d1ce 100644 --- a/src/main.c +++ b/src/main.c @@ -1319,9 +1319,6 @@ zenity_parse_options_callback (poptContext ctx, 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); } -- cgit From a08343daf90e9425c85c1138cf6eea90addafb11 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 7 May 2003 01:08:08 +0000 Subject: Update commandline error message, needs updating of translations. Remove 2003-05-06 Glynn Foster * src/main.c: Update commandline error message, needs updating of translations. * src/tree.c: Remove some commented out code. * src/zenity.glade: Updated error and info dialogs to do wrapping. --- src/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 2f97d1ce..0a2d312b 100644 --- a/src/main.c +++ b/src/main.c @@ -1000,18 +1000,19 @@ main (gint argc, gchar **argv) { /*nothing*/; 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. See zenity --help for more details\n"), poptBadOption (ctx, 0)); zenity_free_parsing_options (); exit (-1); } gtk_init (&argc, &argv); + /* if (argc < 2) { g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); zenity_free_parsing_options (); exit (-1); - } + } */ switch (results->mode) { case MODE_CALENDAR: -- cgit From 626d95b752159fdcec1e7c08271f3eaca1113ab7 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 3 Jun 2003 21:52:16 +0000 Subject: Add --auto-close option to progress dialog. Closes dialog when 100% has been reached. Also update docs for new option. Fixes #114125. --- src/main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/main.c') 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); -- cgit From 52b1f1c71e85be522b30d8f3c0d65a8ce1e8a1d9 Mon Sep 17 00:00:00 2001 From: Jordi Mallach Date: Wed, 4 Jun 2003 10:46:02 +0000 Subject: Add a "no-c-format" xgettext header to unbreak po files in the new 2003-06-04 Jordi Mallach * src/main.c: Add a "no-c-format" xgettext header to unbreak po files in the new auto-close string. --- src/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 9f990712..2792d539 100644 --- a/src/main.c +++ b/src/main.c @@ -527,6 +527,7 @@ struct poptOption progress_options[] = { POPT_ARG_NONE, NULL, OPTION_AUTOCLOSE, + /* xgettext: no-c-format */ N_("Dismiss the dialog when 100% has been reached"), NULL }, -- cgit From 65cb873430d7bfcdf0452c76bf07f2ebbb4a21af Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 4 Jun 2003 12:53:46 +0000 Subject: Fix up some build warnings as reported by Ross Burton and his amazing gcc 2003-06-04 Glynn Foster * src/about.c, src/main.c, src/msg.c, src/progress.c, src/tree.c, src/util.c: Fix up some build warnings as reported by Ross Burton and his amazing gcc 3.3 techno machine. --- src/main.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 2792d539..23c4721b 100644 --- a/src/main.c +++ b/src/main.c @@ -23,6 +23,7 @@ #include "config.h" #include "zenity.h" +#include #include #include @@ -986,10 +987,7 @@ zenity_free_parsing_options (void) { gint main (gint argc, gchar **argv) { - ZenityData *general; - ZenityCalendarData *cal_data; poptContext ctx; - gchar **args; gint nextopt, retval; bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); @@ -1020,11 +1018,12 @@ main (gint argc, gchar **argv) { gtk_init (&argc, &argv); /* - if (argc < 2) { - g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); - zenity_free_parsing_options (); - exit (-1); - } */ + * if (argc < 2) { + * g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); + * zenity_free_parsing_options (); + * exit (-1); + * } + */ switch (results->mode) { case MODE_CALENDAR: -- cgit From 0e4c879656dcb3a0f4ffbcc65e30b6120f65c05e Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Mon, 9 Jun 2003 18:57:01 +0000 Subject: Allow multiple file selections. --- src/main.c | 56 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 11 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 23c4721b..32c98a14 100644 --- a/src/main.c +++ b/src/main.c @@ -89,6 +89,7 @@ enum { OPTION_ERRORTEXT, OPTION_INFOTEXT, OPTION_FILENAME, + OPTION_MULTIFILE, OPTION_TEXTFILENAME, OPTION_COLUMN, OPTION_SEPERATOR, @@ -424,6 +425,24 @@ struct poptOption file_selection_options[] = { N_("Set the filename"), N_("FILENAME") }, + { + "multiple", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_MULTIFILE, + N_("Allow multiple files to be selected"), + NULL + }, + { + "separator", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_SEPERATOR, + N_("Set output separator character."), + N_("SEPARATOR") + }, POPT_TABLEEND }; @@ -471,7 +490,7 @@ struct poptOption list_options[] = { NULL, OPTION_SEPERATOR, N_("Set output separator character"), - NULL + N_("SEPARATOR") }, { "editable", @@ -925,8 +944,10 @@ zenity_init_parsing_options (void) { results->calendar_data->month = 0; results->calendar_data->year = 0; results->calendar_data->dialog_text = NULL; + results->file_data->multi = FALSE; + results->file_data->separator = g_strdup ("|"); results->text_data->editable = FALSE; - results->tree_data->separator = g_strdup ("/"); + results->tree_data->separator = g_strdup ("|"); results->progress_data->percentage = -1; results->progress_data->pulsate = FALSE; results->progress_data->autoclose = FALSE; @@ -969,6 +990,7 @@ zenity_free_parsing_options (void) { case MODE_FILE: if (results->file_data->uri) g_free (results->file_data->uri); + g_free (results->file_data->separator); break; case MODE_TEXTINFO: if (results->text_data->uri) @@ -1336,6 +1358,12 @@ zenity_parse_options_callback (poptContext ctx, } parse_option_file++; break; + case OPTION_MULTIFILE: + if (results->mode != MODE_FILE) + zenity_error ("--multiple", ERROR_SUPPORT); + + results->file_data->multi = TRUE; + break; case OPTION_COLUMN: if (results->mode != MODE_LIST) zenity_error ("--column", ERROR_SUPPORT); @@ -1360,15 +1388,21 @@ zenity_parse_options_callback (poptContext ctx, results->tree_data->radiobox = TRUE; break; case OPTION_SEPERATOR: - if (results->mode != MODE_LIST) - zenity_error ("--separator", ERROR_SUPPORT); - - if (parse_option_separator) - zenity_error ("--separator", ERROR_DUPLICATE); - - results->tree_data->separator = g_strdup (arg); - parse_option_separator = TRUE; - break; + if (parse_option_separator) + zenity_error ("--separator", ERROR_DUPLICATE); + switch (results->mode) { + case MODE_LIST: + results->tree_data->separator = g_strdup (arg); + parse_option_separator = TRUE; + break; + case MODE_FILE: + results->file_data->separator = g_strdup (arg); + parse_option_separator = TRUE; + break; + default: + zenity_error ("--separator", ERROR_SUPPORT); + } + break; case OPTION_PERCENTAGE: if (results->mode != MODE_PROGRESS) zenity_error ("--percentage", ERROR_SUPPORT); -- cgit From cfe29d9ad04761e7a97964af5e8f20fca7d22cfc Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 10 Jun 2003 21:30:22 +0000 Subject: Allow /t and /n in dialog text. Some code cleanup. --- src/main.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 32c98a14..5a111efa 100644 --- a/src/main.c +++ b/src/main.c @@ -1125,7 +1125,7 @@ zenity_parse_options_callback (poptContext ctx, static gint parse_option_text = 0; static gint parse_option_file = 0; static gint parse_option_editable = 0; - + if (reason == POPT_CALLBACK_REASON_POST) return; else if (reason != POPT_CALLBACK_REASON_OPTION) @@ -1235,22 +1235,22 @@ zenity_parse_options_callback (poptContext ctx, if (parse_option_text > 6) zenity_error ("--text", ERROR_DUPLICATE); - + switch (results->mode) { case MODE_CALENDAR: - results->calendar_data->dialog_text = g_strdup (arg); + results->calendar_data->dialog_text = g_strdup (g_strcompress (arg)); break; case MODE_ENTRY: - results->entry_data->dialog_text = g_strdup (arg); + results->entry_data->dialog_text = g_strdup (g_strcompress (arg)); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: - results->msg_data->dialog_text = g_strdup (arg); + results->msg_data->dialog_text = g_strdup (g_strcompress (arg)); break; case MODE_PROGRESS: - results->progress_data->dialog_text = g_strdup (arg); + results->progress_data->dialog_text = g_strdup (g_strcompress (arg)); break; default: zenity_error ("--text", ERROR_SUPPORT); @@ -1388,16 +1388,16 @@ zenity_parse_options_callback (poptContext ctx, results->tree_data->radiobox = TRUE; break; case OPTION_SEPERATOR: - if (parse_option_separator) + if (parse_option_separator > 2) zenity_error ("--separator", ERROR_DUPLICATE); switch (results->mode) { case MODE_LIST: - results->tree_data->separator = g_strdup (arg); - parse_option_separator = TRUE; + results->tree_data->separator = g_strdup (g_strcompress (arg)); + parse_option_separator++; break; case MODE_FILE: - results->file_data->separator = g_strdup (arg); - parse_option_separator = TRUE; + results->file_data->separator = g_strdup (g_strcompress (arg)); + parse_option_separator++; break; default: zenity_error ("--separator", ERROR_SUPPORT); -- cgit From 86a829f7c8ba7d02412932ecee5619ae82936d63 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Sat, 21 Jun 2003 15:33:39 +0000 Subject: Added en_GB translation and fixed a typo. --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 5a111efa..99954ab4 100644 --- a/src/main.c +++ b/src/main.c @@ -1032,7 +1032,7 @@ main (gint argc, gchar **argv) { /*nothing*/; if (nextopt != -1) { - g_printerr (_("%s in an invalid option. See zenity --help for more details\n"), + g_printerr (_("%s is an invalid option. See 'zenity --help' for more details\n"), poptBadOption (ctx, 0)); zenity_free_parsing_options (); exit (-1); -- cgit From 32cb0ef0f56cad183438ad3bdfacfc92829639ee Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Fri, 22 Aug 2003 08:30:15 +0000 Subject: Fixed i18n of help messages. --- src/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 99954ab4..02bc8188 100644 --- a/src/main.c +++ b/src/main.c @@ -1012,6 +1012,7 @@ main (gint argc, gchar **argv) { poptContext ctx; gint nextopt, retval; + setlocale(LC_ALL,""); bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); -- cgit From f3ea9c41a20b59a74a5d897a8f6b92ce2e07f052 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Thu, 4 Sep 2003 10:33:00 +0000 Subject: Update. Update. Patch from Toshi to fix encoding of passed text strings. 2003-09-04 Glynn Foster * THANKS: Update. * src/about.c: Update. * src/main.c: Patch from Toshi to fix encoding of passed text strings. Fixes #121389. --- src/main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 02bc8188..95eee262 100644 --- a/src/main.c +++ b/src/main.c @@ -939,7 +939,9 @@ zenity_init_parsing_options (void) { /* 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_locale_to_utf8 (nl_langinfo (D_FMT), + -1, + NULL, NULL, NULL); results->calendar_data->day = 0; results->calendar_data->month = 0; results->calendar_data->year = 0; @@ -1239,19 +1241,23 @@ zenity_parse_options_callback (poptContext ctx, switch (results->mode) { case MODE_CALENDAR: - results->calendar_data->dialog_text = g_strdup (g_strcompress (arg)); + results->calendar_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), + -1, NULL, NULL, NULL); break; case MODE_ENTRY: - results->entry_data->dialog_text = g_strdup (g_strcompress (arg)); + results->entry_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), + -1, NULL, NULL, NULL); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: - results->msg_data->dialog_text = g_strdup (g_strcompress (arg)); + results->msg_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), + -1, NULL, NULL, NULL); break; case MODE_PROGRESS: - results->progress_data->dialog_text = g_strdup (g_strcompress (arg)); + results->progress_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), + -1, NULL, NULL, NULL); break; default: zenity_error ("--text", ERROR_SUPPORT); -- cgit From 1fab4b4e6223acd59189b9a327d9fdee650ead27 Mon Sep 17 00:00:00 2001 From: Damien Carbery Date: Fri, 12 Sep 2003 08:40:48 +0000 Subject: Make zenity compile on solaris. Whoops :) 2003-09-12 Damien Carbery * src/main.c: Make zenity compile on solaris. Whoops :) --- src/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 95eee262..84d01fe1 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ #include "config.h" #include "zenity.h" #include +#include #include #include -- cgit From 2d67087ca0e60c7a8036ad2262af6fec9bd2d738 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 27 Oct 2003 02:48:32 +0000 Subject: Patch from Leonardo Boshell to add the locale.h header. 2003-10-27 Glynn Foster * src/main.c: Patch from Leonardo Boshell to add the locale.h header. --- src/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 84d01fe1..58fe37ac 100644 --- a/src/main.c +++ b/src/main.c @@ -21,12 +21,16 @@ * Authors: Glynn Foster */ -#include "config.h" +#include + #include "zenity.h" #include #include #include #include +#ifdef HAVE_LOCALE_H +#include +#endif typedef enum { MODE_CALENDAR, @@ -1015,7 +1019,10 @@ main (gint argc, gchar **argv) { poptContext ctx; gint nextopt, retval; +#ifdef HAVE_LOCALE_H setlocale(LC_ALL,""); +#endif + bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); -- cgit From 02955ce70f7fa58da88dc8d66e07520afb94f642 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 28 Apr 2004 12:06:02 +0000 Subject: Fix the list dialog not being able to handle --text to change the text. It 2004-04-29 Glynn Foster * src/main.c, src/tree.c: Fix the list dialog not being able to handle --text to change the text. It was also intentional but must have fallen through the gaps. * data/zenity.1: Update * help/C/zenity.xml: Update. --- src/main.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 58fe37ac..9b112c62 100644 --- a/src/main.c +++ b/src/main.c @@ -96,6 +96,7 @@ enum { OPTION_FILENAME, OPTION_MULTIFILE, OPTION_TEXTFILENAME, + OPTION_LISTTEXT, OPTION_COLUMN, OPTION_SEPERATOR, OPTION_LISTEDIT, @@ -461,6 +462,15 @@ struct poptOption list_options[] = { NULL, NULL }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_LISTTEXT, + N_("Set the dialog text"), + NULL + }, { "column", '\0', @@ -959,6 +969,7 @@ zenity_init_parsing_options (void) { results->progress_data->pulsate = FALSE; results->progress_data->autoclose = FALSE; results->entry_data->visible = TRUE; + results->tree_data->dialog_text = NULL; results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; results->tree_data->editable = FALSE; @@ -1004,6 +1015,8 @@ zenity_free_parsing_options (void) { g_free (results->text_data->uri); break; case MODE_LIST: + if (results->tree_data->dialog_text) + g_free (results->tree_data->dialog_text); if (results->tree_data->columns) g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); if (results->tree_data->separator) @@ -1237,6 +1250,7 @@ zenity_parse_options_callback (poptContext ctx, case OPTION_ERRORTEXT: case OPTION_QUESTIONTEXT: case OPTION_PROGRESSTEXT: + case OPTION_LISTTEXT: case OPTION_WARNINGTEXT: /* FIXME: This is an ugly hack because of the way the poptOptions are @@ -1244,7 +1258,7 @@ zenity_parse_options_callback (poptContext ctx, * parse_options_callback gets called for each option. Suckage */ - if (parse_option_text > 6) + if (parse_option_text > 7) zenity_error ("--text", ERROR_DUPLICATE); switch (results->mode) { @@ -1267,6 +1281,10 @@ zenity_parse_options_callback (poptContext ctx, results->progress_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), -1, NULL, NULL, NULL); break; + case MODE_LIST: + results->tree_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), + -1, NULL, NULL, NULL); + break; default: zenity_error ("--text", ERROR_SUPPORT); } -- cgit From c30c2f365fc8567cf1614388510c9d0e6b0aa764 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 9 Jun 2004 21:12:55 +0000 Subject: Add Paul. fix tyops in parsing. 2004-06-08 Glynn Foster * THANKS, src/about.c: Add Paul. * src/main.c: fix tyops in parsing. --- src/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 9b112c62..2baed7dc 100644 --- a/src/main.c +++ b/src/main.c @@ -1405,18 +1405,18 @@ zenity_parse_options_callback (poptContext ctx, break; case OPTION_CHECKLIST: if (results->mode != MODE_LIST) - zenity_error ("--checkbox", ERROR_SUPPORT); + zenity_error ("--checklist", ERROR_SUPPORT); if (results->tree_data->checkbox) - zenity_error ("--checkbox", ERROR_DUPLICATE); + zenity_error ("--checklist", ERROR_DUPLICATE); results->tree_data->checkbox = TRUE; break; case OPTION_RADIOLIST: if (results->mode != MODE_LIST) - zenity_error ("--radiobox", ERROR_SUPPORT); + zenity_error ("--radiolist", ERROR_SUPPORT); if (results->tree_data->radiobox) - zenity_error ("--radiobox", ERROR_DUPLICATE); + zenity_error ("--radiolist", ERROR_DUPLICATE); results->tree_data->radiobox = TRUE; break; -- cgit From c7ec5229bbf0328687ae1deef58c9fae906b34f2 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 16 Jun 2004 23:45:28 +0000 Subject: Fix parsing errors. Patch from Paull Bolle. Fixes #144501. 2004-06-17 Glynn Foster * src/main.c: Fix parsing errors. Patch from Paull Bolle. Fixes #144501. --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 2baed7dc..9e28a566 100644 --- a/src/main.c +++ b/src/main.c @@ -1353,7 +1353,7 @@ zenity_parse_options_callback (poptContext ctx, * parse_options_callback gets called for each option. Suckage */ - if (parse_option_file > 2) + if (parse_option_editable > 2) zenity_error ("--editable", ERROR_DUPLICATE); switch (results->mode) { -- cgit From b986224682b864b25125bf73ae38f47e0fe883b1 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 18 Jul 2004 23:52:07 +0000 Subject: Remove duplicate locale.h include. Patch from Leonardo Boshell. Partly 2004-07-19 Glynn Foster * src/main.c: Remove duplicate locale.h include. Patch from Leonardo Boshell. Partly fixes #137993. --- src/main.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 9e28a566..129dfa5c 100644 --- a/src/main.c +++ b/src/main.c @@ -25,7 +25,6 @@ #include "zenity.h" #include -#include #include #include #ifdef HAVE_LOCALE_H -- cgit From ffaed088561e8c0a085fd2797543aaef65419f0c Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 19 Jul 2004 01:01:28 +0000 Subject: Add new option for --print-column, based on a patch by Paul Bolle. Fixes 2004-07-19 Glynn Foster * src/main.c, src/tree.c, src/zenity.h, help/C/zenity.xml: Add new option for --print-column, based on a patch by Paul Bolle. Fixes #144496. --- src/main.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 129dfa5c..02a67f3f 100644 --- a/src/main.c +++ b/src/main.c @@ -105,6 +105,7 @@ enum { OPTION_PERCENTAGE, OPTION_PULSATE, OPTION_AUTOCLOSE, + OPTION_PRINTCOLUMN, OPTION_QUESTIONTEXT, OPTION_WARNINGTEXT, OPTION_ABOUT, @@ -113,10 +114,10 @@ enum { }; static void zenity_parse_options_callback (poptContext ctx, - enum poptCallbackReason reason, - const struct poptOption *opt, - const char *arg, - void *data); + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, + void *data); struct poptOption options[] = { { @@ -515,6 +516,15 @@ struct poptOption list_options[] = { N_("Allow changes to text"), NULL }, + { + "print-column", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_PRINTCOLUMN, + N_("Print a specific column (Default is 1. 'ALL' can be used to print all columns)"), + NULL + }, POPT_TABLEEND }; @@ -972,6 +982,7 @@ zenity_init_parsing_options (void) { results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; results->tree_data->editable = FALSE; + results->tree_data->print_column = NULL; } static void @@ -1020,6 +1031,8 @@ zenity_free_parsing_options (void) { g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); if (results->tree_data->separator) g_free (results->tree_data->separator); + if (results->tree_data->print_column) + g_free (results->tree_data->print_column); break; default: break; @@ -1456,6 +1469,12 @@ zenity_parse_options_callback (poptContext ctx, results->progress_data->autoclose = TRUE; break; + case OPTION_PRINTCOLUMN: + if (results->mode != MODE_LIST) + zenity_error ("--print-column", ERROR_SUPPORT); + + results->tree_data->print_column = g_strdup (arg); + break; case OPTION_ABOUT: if (results->mode != MODE_LAST) zenity_error (NULL, ERROR_DIALOG); -- cgit From 03f3e5b060977c9566bd66bc8e4eaac14c4ee781 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Sep 2004 04:56:26 +0000 Subject: Update Update. Patch from Lucas Rocha to implement save and directory 2004-09-13 Glynn Foster * THANKS: Update * src/about.c: Update. * src/fileselection.c, src/main.c, src/zenity.h: Patch from Lucas Rocha to implement save and directory selection in the file selection dialog. Fixes #138342. --- src/main.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 02a67f3f..09b1519c 100644 --- a/src/main.c +++ b/src/main.c @@ -94,6 +94,8 @@ enum { OPTION_INFOTEXT, OPTION_FILENAME, OPTION_MULTIFILE, + OPTION_DIR, + OPTION_SAVE, OPTION_TEXTFILENAME, OPTION_LISTTEXT, OPTION_COLUMN, @@ -440,6 +442,24 @@ struct poptOption file_selection_options[] = { N_("Allow multiple files to be selected"), NULL }, + { + "directory", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_DIR, + N_("Activate directory-only selection"), + NULL + }, + { + "save", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_SAVE, + N_("Activate save mode"), + NULL + }, { "separator", '\0', @@ -971,6 +991,8 @@ zenity_init_parsing_options (void) { results->calendar_data->year = 0; results->calendar_data->dialog_text = NULL; results->file_data->multi = FALSE; + results->file_data->directory = FALSE; + results->file_data->save = FALSE; results->file_data->separator = g_strdup ("|"); results->text_data->editable = FALSE; results->tree_data->separator = g_strdup ("|"); @@ -1409,6 +1431,18 @@ zenity_parse_options_callback (poptContext ctx, results->file_data->multi = TRUE; break; + case OPTION_DIR: + if (results->mode != MODE_FILE) + zenity_error ("--directory", ERROR_SUPPORT); + + results->file_data->directory = TRUE; + break; + case OPTION_SAVE: + if (results->mode != MODE_FILE) + zenity_error ("--save", ERROR_SUPPORT); + + results->file_data->save = TRUE; + break; case OPTION_COLUMN: if (results->mode != MODE_LIST) zenity_error ("--column", ERROR_SUPPORT); -- cgit From 3e05834b4c23a5d5951403719b8594ff3d9fe30b Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Sep 2004 07:51:51 +0000 Subject: Add new notification icon. Update for new files. Restructure code a little 2004-09-13 Glynn Foster * data/Makefile.am, data/zenity-notification.png: Add new notification icon. * src/Makefile.am: Update for new files. * src/about.c, src/calendar.c, src/entry.c, src/fileselection.c, src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a little bit for new utility functions for setting window icons. * src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area support. * src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h: Add support for notification area. * data/zenity.1, help/*: Update docs for notification and new file selection changes. --- src/main.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 09b1519c..4d8c6079 100644 --- a/src/main.c +++ b/src/main.c @@ -42,6 +42,7 @@ typedef enum { MODE_TEXTINFO, MODE_WARNING, MODE_INFO, + MODE_NOTIFICATION, MODE_ABOUT, MODE_LAST } ZenityDialogMode; @@ -64,6 +65,7 @@ typedef struct { ZenityProgressData *progress_data; ZenityTextData *text_data; ZenityTreeData *tree_data; + ZenityNotificationData *notification_data; } ZenityParsingOptions; enum { @@ -79,6 +81,7 @@ enum { OPTION_TEXTINFO, OPTION_TEXTEDIT, OPTION_WARNING, + OPTION_NOTIFICATION, OPTION_TITLE, OPTION_ICON, OPTION_WIDTH, @@ -110,6 +113,8 @@ enum { OPTION_PRINTCOLUMN, OPTION_QUESTIONTEXT, OPTION_WARNINGTEXT, + OPTION_NOTIFICATIONICON, + OPTION_NOTIFICATIONTEXT, OPTION_ABOUT, OPTION_VERSION, OPTION_LAST, @@ -185,6 +190,15 @@ struct poptOption options[] = { N_("Display list dialog"), NULL }, + { + "notification", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_NOTIFICATION, + N_("Display notification"), + NULL + }, { "progress", '\0', @@ -548,6 +562,28 @@ struct poptOption list_options[] = { POPT_TABLEEND }; +struct poptOption notification_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_NOTIFICATIONTEXT, + N_("Set the notification text"), + NULL + }, + POPT_TABLEEND +}; + struct poptOption progress_options[] = { { NULL, @@ -896,6 +932,15 @@ struct poptOption application_options[] = { N_("List options"), NULL }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + notification_options, + 0, + N_("Notication options"), + NULL + }, { NULL, '\0', @@ -979,6 +1024,7 @@ zenity_init_parsing_options (void) { results->progress_data = g_new0 (ZenityProgressData, 1); results->text_data = g_new0 (ZenityTextData, 1); results->tree_data = g_new0 (ZenityTreeData, 1); + results->notification_data = g_new0 (ZenityNotificationData, 1); /* Give some sensible defaults */ results->data->width = -1; @@ -1056,6 +1102,10 @@ zenity_free_parsing_options (void) { if (results->tree_data->print_column) g_free (results->tree_data->print_column); break; + case MODE_NOTIFICATION: + if (results->notification_data->notification_text) + g_free (results->notification_data->notification_text); + break; default: break; } @@ -1125,6 +1175,9 @@ main (gint argc, gchar **argv) { results->tree_data->data = poptGetArgs (ctx); zenity_tree (results->data, results->tree_data); break; + case MODE_NOTIFICATION: + zenity_notification (results->data, results->notification_data); + break; case MODE_PROGRESS: zenity_progress (results->data, results->progress_data); break; @@ -1229,6 +1282,12 @@ zenity_parse_options_callback (poptContext ctx, results->mode = MODE_LIST; break; + case OPTION_NOTIFICATION: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + + results->mode = MODE_NOTIFICATION; + break; case OPTION_PROGRESS: if (results->mode != MODE_LAST) zenity_error (NULL, ERROR_DIALOG); @@ -1286,13 +1345,13 @@ zenity_parse_options_callback (poptContext ctx, case OPTION_PROGRESSTEXT: case OPTION_LISTTEXT: case OPTION_WARNINGTEXT: - + case OPTION_NOTIFICATIONTEXT: /* FIXME: This is an ugly hack because of the way the poptOptions are * ordered above. When you try and use an --option more than once * parse_options_callback gets called for each option. Suckage */ - if (parse_option_text > 7) + if (parse_option_text > 8) zenity_error ("--text", ERROR_DUPLICATE); switch (results->mode) { @@ -1319,6 +1378,10 @@ zenity_parse_options_callback (poptContext ctx, results->tree_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), -1, NULL, NULL, NULL); break; + case MODE_NOTIFICATION: + results->notification_data->notification_text = g_locale_to_utf8 (g_strcompress (arg), + -1, NULL, NULL, NULL); + break; default: zenity_error ("--text", ERROR_SUPPORT); } -- cgit From 963241dd15b3046e97e526b1547fdd3543b18b14 Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Thu, 16 Sep 2004 09:28:09 +0000 Subject: add code to listen for commands on stdin when in listen mode. 2004-09-16 James Henstridge * src/notification.c: add code to listen for commands on stdin when in listen mode. * src/main.c: parse the --listen argument for --notification mode. * src/zenity.h (ZenityNotificationData): add a field for the "listen" argument. --- src/main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 4d8c6079..b4162cd0 100644 --- a/src/main.c +++ b/src/main.c @@ -115,6 +115,7 @@ enum { OPTION_WARNINGTEXT, OPTION_NOTIFICATIONICON, OPTION_NOTIFICATIONTEXT, + OPTION_NOTIFICATIONLISTEN, OPTION_ABOUT, OPTION_VERSION, OPTION_LAST, @@ -581,6 +582,15 @@ struct poptOption notification_options[] = { N_("Set the notification text"), NULL }, + { + "listen", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_NOTIFICATIONLISTEN, + N_("Listen for commands on stdin"), + NULL + }, POPT_TABLEEND }; @@ -1051,6 +1061,7 @@ zenity_init_parsing_options (void) { results->tree_data->radiobox = FALSE; results->tree_data->editable = FALSE; results->tree_data->print_column = NULL; + results->notification_data->listen = FALSE; } static void @@ -1572,6 +1583,12 @@ zenity_parse_options_callback (poptContext ctx, results->tree_data->print_column = g_strdup (arg); break; + case OPTION_NOTIFICATIONLISTEN: + if (results->mode != MODE_NOTIFICATION) + zenity_error ("--listen", ERROR_SUPPORT); + + results->notification_data->listen = TRUE; + break; case OPTION_ABOUT: if (results->mode != MODE_LAST) zenity_error (NULL, ERROR_DIALOG); -- cgit From 444ede57defebb326749a9ad173081866b0a1e28 Mon Sep 17 00:00:00 2001 From: "Francisco Javier F. Serrador" Date: Sat, 30 Oct 2004 14:13:02 +0000 Subject: Updated Spanish translation. Fixed typo 2004-10-30 Francisco Javier F. Serrador * po/es.po: Updated Spanish translation. * src/main.c: Fixed typo --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index b4162cd0..7d6ea9b7 100644 --- a/src/main.c +++ b/src/main.c @@ -948,7 +948,7 @@ struct poptOption application_options[] = { POPT_ARG_INCLUDE_TABLE, notification_options, 0, - N_("Notication options"), + N_("Notification options"), NULL }, { -- cgit From 530a4c04082242ea4740998ed4f50270c94e823a Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Dec 2004 00:17:16 +0000 Subject: Patch from Lucas Rocha to use the GOption API for the 2004-12-07 Glynn Foster Patch from Lucas Rocha to use the GOption API for the zenity parsing options, with some spacing fixes from Glynn. * configure.in: zenity now requires glib-2.0 >= 2.5.3 to build because now it uses GOption. popt requirement removed. * src/Makefile.am: update for new files * src/main.c: use GOption API * src/option.c, src/option.h: New files to implement the new functionality. * src/zenity.h: Fix spacing. 2004-12-07 Glynn Foster * POTFILES.in: Add new files. --- src/main.c | 1534 +----------------------------------------------------------- 1 file changed, 15 insertions(+), 1519 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 7d6ea9b7..10e75b8a 100644 --- a/src/main.c +++ b/src/main.c @@ -24,1108 +24,20 @@ #include #include "zenity.h" +#include "option.h" + #include -#include +#include +#include #include #ifdef HAVE_LOCALE_H #include #endif -typedef enum { - MODE_CALENDAR, - MODE_ENTRY, - MODE_ERROR, - MODE_FILE, - MODE_LIST, - MODE_PROGRESS, - MODE_QUESTION, - MODE_TEXTINFO, - MODE_WARNING, - MODE_INFO, - MODE_NOTIFICATION, - MODE_ABOUT, - MODE_LAST -} ZenityDialogMode; - -typedef enum { - ERROR_DUPLICATE, - ERROR_SUPPORT, - ERROR_DIALOG, - ERROR_LAST -} ZenityError; - -typedef struct { - ZenityDialogMode mode; - ZenityData *data; - - ZenityCalendarData *calendar_data; - ZenityMsgData *msg_data; - ZenityFileData *file_data; - ZenityEntryData *entry_data; - ZenityProgressData *progress_data; - ZenityTextData *text_data; - ZenityTreeData *tree_data; - ZenityNotificationData *notification_data; -} ZenityParsingOptions; - -enum { - OPTION_CALENDAR = 1, - OPTION_DATEFORMAT, - OPTION_ENTRY, - OPTION_ERROR, - OPTION_INFO, - OPTION_FILE, - OPTION_LIST, - OPTION_PROGRESS, - OPTION_QUESTION, - OPTION_TEXTINFO, - OPTION_TEXTEDIT, - OPTION_WARNING, - OPTION_NOTIFICATION, - OPTION_TITLE, - OPTION_ICON, - OPTION_WIDTH, - OPTION_HEIGHT, - OPTION_CALENDARTEXT, - OPTION_DAY, - OPTION_MONTH, - OPTION_YEAR, - OPTION_ENTRYTEXT, - OPTION_INPUTTEXT, - OPTION_HIDETEXT, - OPTION_ERRORTEXT, - OPTION_INFOTEXT, - OPTION_FILENAME, - OPTION_MULTIFILE, - OPTION_DIR, - OPTION_SAVE, - OPTION_TEXTFILENAME, - OPTION_LISTTEXT, - OPTION_COLUMN, - OPTION_SEPERATOR, - OPTION_LISTEDIT, - OPTION_CHECKLIST, - OPTION_RADIOLIST, - OPTION_PROGRESSTEXT, - OPTION_PERCENTAGE, - OPTION_PULSATE, - OPTION_AUTOCLOSE, - OPTION_PRINTCOLUMN, - OPTION_QUESTIONTEXT, - OPTION_WARNINGTEXT, - OPTION_NOTIFICATIONICON, - OPTION_NOTIFICATIONTEXT, - OPTION_NOTIFICATIONLISTEN, - OPTION_ABOUT, - OPTION_VERSION, - OPTION_LAST, -}; - -static void zenity_parse_options_callback (poptContext ctx, - enum poptCallbackReason reason, - const struct poptOption *opt, - const char *arg, - void *data); - -struct poptOption options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "calendar", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_CALENDAR, - N_("Display calendar dialog"), - NULL - }, - { - "entry", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_ENTRY, - N_("Display text entry dialog"), - NULL - }, - { - "error", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_ERROR, - N_("Display error dialog"), - NULL - }, - { - "file-selection", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_FILE, - N_("Display file selection dialog"), - NULL - }, - { - "info", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_INFO, - N_("Display info dialog"), - NULL - }, - { - "list", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_LIST, - N_("Display list dialog"), - NULL - }, - { - "notification", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_NOTIFICATION, - N_("Display notification"), - NULL - }, - { - "progress", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_PROGRESS, - N_("Display progress indication dialog"), - NULL - }, - { - "question", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_QUESTION, - N_("Display question dialog"), - NULL - }, - { - "text-info", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_TEXTINFO, - N_("Display text information dialog"), - NULL - }, - { - "warning", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_WARNING, - N_("Display warning dialog"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption general_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "title", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_TITLE, - N_("Set the dialog title"), - N_("TITLE") - }, - { - "window-icon", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_ICON, - N_("Set the window icon"), - 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 -}; - -struct poptOption calendar_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_CALENDARTEXT, - N_("Set the dialog text"), - NULL - }, - { - "day", - '\0', - POPT_ARG_INT, - NULL, - OPTION_DAY, - N_("Set the calendar day"), - NULL - }, - { - "month", - '\0', - POPT_ARG_INT, - NULL, - OPTION_MONTH, - N_("Set the calendar month"), - NULL - }, - { - "year", - '\0', - POPT_ARG_INT, - NULL, - OPTION_YEAR, - N_("Set the calendar year"), - NULL - }, - { "date-format", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_DATEFORMAT, - N_("Set the format for the returned date"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption entry_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_ENTRYTEXT, - N_("Set the dialog text"), - NULL - }, - { - "entry-text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_INPUTTEXT, - N_("Set the entry text"), - NULL - }, - { - "hide-text", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_HIDETEXT, - N_("Hide the entry text"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption error_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_ERRORTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption info_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_INFOTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption file_selection_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "filename", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_FILENAME, - N_("Set the filename"), - N_("FILENAME") - }, - { - "multiple", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_MULTIFILE, - N_("Allow multiple files to be selected"), - NULL - }, - { - "directory", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_DIR, - N_("Activate directory-only selection"), - NULL - }, - { - "save", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_SAVE, - N_("Activate save mode"), - NULL - }, - { - "separator", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_SEPERATOR, - N_("Set output separator character."), - N_("SEPARATOR") - }, - POPT_TABLEEND -}; - -struct poptOption list_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_LISTTEXT, - N_("Set the dialog text"), - NULL - }, - { - "column", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_COLUMN, - N_("Set the column header"), - NULL - }, - { - "checklist", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_CHECKLIST, - N_("Use check boxes for first column"), - NULL - }, - { - "radiolist", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_RADIOLIST, - N_("Use radio buttons for first column"), - NULL - }, - { - "separator", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_SEPERATOR, - N_("Set output separator character"), - N_("SEPARATOR") - }, - { - "editable", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_LISTEDIT, - N_("Allow changes to text"), - NULL - }, - { - "print-column", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_PRINTCOLUMN, - N_("Print a specific column (Default is 1. 'ALL' can be used to print all columns)"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption notification_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_NOTIFICATIONTEXT, - N_("Set the notification text"), - NULL - }, - { - "listen", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_NOTIFICATIONLISTEN, - N_("Listen for commands on stdin"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption progress_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_PROGRESSTEXT, - N_("Set the dialog text"), - NULL - }, - { - "percentage", - '\0', - POPT_ARG_INT, - NULL, - OPTION_PERCENTAGE, - N_("Set initial percentage"), - NULL - }, - { - "pulsate", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_PULSATE, - N_("Pulsate progress bar"), - NULL - }, - { - "auto-close", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_AUTOCLOSE, - /* xgettext: no-c-format */ - N_("Dismiss the dialog when 100% has been reached"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption question_options[] = { - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_QUESTIONTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption text_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "filename", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_TEXTFILENAME, - N_("Open file"), - N_("FILENAME") - }, - { - "editable", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_TEXTEDIT, - N_("Allow changes to text"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption warning_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_WARNINGTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption gtk_options[] = { - { - "gdk-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gdk debugging flags to set"), - N_("FLAGS") - }, - { - "gdk-no-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gdk debugging flags to unset"), - N_("FLAGS") - }, - /* X11 only */ - { - "display", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("X display to use"), - N_("DISPLAY") - }, -#ifdef HAVE_GTK_MULTIHEAD - /* X11 & multi-head only */ - { - "screen", - '\0', - POPT_ARG_INT, - NULL, - 0, - N_("X screen to use"), - N_("SCREEN") - }, -#endif - /* X11 only */ - { - "sync", - '\0', - POPT_ARG_NONE, - NULL, - 0, - N_("Make X calls synchronous"), - NULL - }, - { - "name", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Program name as used by the window manager"), - N_("NAME") - }, - { - "class", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Program class as used by the window manager"), - N_("CLASS") - }, - /* X11 only */ - { - "gxid-host", - '\0', - POPT_ARG_STRING, - NULL, - 0, - NULL, - N_("HOST") - }, - /* X11 only */ - { - "gxid-port", - '\0', - POPT_ARG_STRING, - NULL, - 0, - NULL, - N_("PORT") - }, - { - "gtk-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gtk+ debugging flags to set"), - N_("FLAGS") - }, - { - "gtk-no-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gtk+ debugging flags to unset"), - N_("FLAGS") - }, - { - "g-fatal-warnings", - '\0', - POPT_ARG_NONE, - NULL, - 0, - N_("Make all warnings fatal"), - NULL - }, - { - "gtk-module", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Load an additional Gtk module"), - N_("MODULE") - }, - POPT_TABLEEND -}; - -struct poptOption miscellaneous_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "about", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_ABOUT, - N_("About zenity"), - NULL - }, - { - "version", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_VERSION, - N_("Print version"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption application_options[] = { - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - options, - 0, - N_("Dialog options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - general_options, - 0, - N_("General options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - calendar_options, - 0, - N_("Calendar options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - entry_options, - 0, - N_("Text entry options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - error_options, - 0, - N_("Error options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - file_selection_options, - 0, - N_("File selection options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - info_options, - 0, - N_("Info options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - list_options, - 0, - N_("List options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - notification_options, - 0, - N_("Notification options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - progress_options, - 0, - N_("Progress options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - question_options, - 0, - N_("Question options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - text_options, - 0, - N_("Text options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - warning_options, - 0, - N_("Warning options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - gtk_options, - 0, - N_("GTK+ options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - miscellaneous_options, - 0, - N_("Miscellaneous options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - poptHelpOptions, - 0, - N_("Help options"), - NULL - }, - POPT_TABLEEND -}; - -ZenityParsingOptions *results; - -static void -zenity_init_parsing_options (void) { - - results = g_new0 (ZenityParsingOptions, 1); - - /* Initialize the various dialog structures */ - results->mode = MODE_LAST; - results->data = g_new0 (ZenityData, 1); - results->calendar_data = g_new0 (ZenityCalendarData, 1); - results->msg_data = g_new0 (ZenityMsgData, 1); - results->file_data = g_new0 (ZenityFileData, 1); - results->entry_data = g_new0 (ZenityEntryData, 1); - results->progress_data = g_new0 (ZenityProgressData, 1); - results->text_data = g_new0 (ZenityTextData, 1); - results->tree_data = g_new0 (ZenityTreeData, 1); - results->notification_data = g_new0 (ZenityNotificationData, 1); - - /* Give some sensible defaults */ - results->data->width = -1; - results->data->height = -1; - results->calendar_data->date_format = g_locale_to_utf8 (nl_langinfo (D_FMT), - -1, - NULL, NULL, NULL); - results->calendar_data->day = 0; - results->calendar_data->month = 0; - results->calendar_data->year = 0; - results->calendar_data->dialog_text = NULL; - results->file_data->multi = FALSE; - results->file_data->directory = FALSE; - results->file_data->save = FALSE; - results->file_data->separator = g_strdup ("|"); - results->text_data->editable = FALSE; - 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->dialog_text = NULL; - results->tree_data->checkbox = FALSE; - results->tree_data->radiobox = FALSE; - results->tree_data->editable = FALSE; - results->tree_data->print_column = NULL; - results->notification_data->listen = FALSE; -} - -static void -zenity_free_parsing_options (void) { - - /* General options */ - if (results->data->dialog_title) - g_free (results->data->dialog_title); - if (results->data->window_icon) - g_free (results->data->window_icon); - - /* Dialog options */ - switch (results->mode) { - case MODE_CALENDAR: - if (results->calendar_data->dialog_text) - g_free (results->calendar_data->dialog_text); - if (results->calendar_data->date_format) - g_free (results->calendar_data->date_format); - break; - case MODE_ENTRY: - if (results->entry_data->dialog_text) - g_free (results->entry_data->dialog_text); - if (results->entry_data->entry_text) - g_free (results->entry_data->entry_text); - break; - case MODE_ERROR: - case MODE_QUESTION: - case MODE_WARNING: - case MODE_INFO: - if (results->msg_data->dialog_text) - g_free (results->msg_data->dialog_text); - break; - case MODE_FILE: - if (results->file_data->uri) - g_free (results->file_data->uri); - g_free (results->file_data->separator); - break; - case MODE_TEXTINFO: - if (results->text_data->uri) - g_free (results->text_data->uri); - break; - case MODE_LIST: - if (results->tree_data->dialog_text) - g_free (results->tree_data->dialog_text); - if (results->tree_data->columns) - g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); - if (results->tree_data->separator) - g_free (results->tree_data->separator); - if (results->tree_data->print_column) - g_free (results->tree_data->print_column); - break; - case MODE_NOTIFICATION: - if (results->notification_data->notification_text) - g_free (results->notification_data->notification_text); - break; - default: - break; - } -} - gint main (gint argc, gchar **argv) { - poptContext ctx; - gint nextopt, retval; + ZenityParsingOptions *results; + gint retval; #ifdef HAVE_LOCALE_H setlocale(LC_ALL,""); @@ -1135,37 +47,10 @@ main (gint argc, gchar **argv) { bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); - zenity_init_parsing_options (); - - /* FIXME: popt doesn't like passing stuff through data - * but it doesn't seem to cope with the data that I try - * to pass in, not quite sure why though. If someone knows - * what I'm doing wrong, we could probably put this back: - * options[0].descrip = (void*) results; - */ + results = zenity_option_parse (argc, argv); - ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0); - - poptReadDefaultConfig(ctx, TRUE); - while((nextopt = poptGetNextOpt(ctx)) > 0) - /*nothing*/; - - if (nextopt != -1) { - g_printerr (_("%s is an invalid option. See 'zenity --help' for more details\n"), - poptBadOption (ctx, 0)); - zenity_free_parsing_options (); - exit (-1); - } gtk_init (&argc, &argv); - /* - * if (argc < 2) { - * g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); - * zenity_free_parsing_options (); - * exit (-1); - * } - */ - switch (results->mode) { case MODE_CALENDAR: zenity_calendar (results->data, results->calendar_data); @@ -1183,7 +68,7 @@ main (gint argc, gchar **argv) { zenity_fileselection (results->data, results->file_data); break; case MODE_LIST: - results->tree_data->data = poptGetArgs (ctx); + results->tree_data->data = (const gchar **) argv + 1; zenity_tree (results->data, results->tree_data); break; case MODE_NOTIFICATION: @@ -1198,411 +83,22 @@ main (gint argc, gchar **argv) { case MODE_ABOUT: zenity_about (results->data); break; + case MODE_VERSION: + g_print ("%s\n", VERSION); + break; case MODE_LAST: g_printerr (_("You must specify a dialog type. See 'zenity --help' for details\n")); - zenity_free_parsing_options (); + zenity_option_free (); exit (-1); default: g_assert_not_reached (); - zenity_free_parsing_options (); + zenity_option_free (); exit (-1); } retval = results->data->exit_code; - poptFreeContext(ctx); - zenity_free_parsing_options (); - exit (retval); -} - -static void -zenity_error (gchar *string, ZenityError error) -{ - switch (error) { - case ERROR_DUPLICATE: - g_printerr (_("%s given twice for the same dialog\n"), string); - zenity_free_parsing_options (); - exit (-1); - case ERROR_SUPPORT: - g_printerr (_("%s is not supported for this dialog\n"), string); - zenity_free_parsing_options (); - exit (-1); - case ERROR_DIALOG: - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - default: - return; - } -} - -static void -zenity_parse_options_callback (poptContext ctx, - enum poptCallbackReason reason, - const struct poptOption *opt, - const char *arg, - void *data) -{ - static gboolean parse_option_dateformat = FALSE; - static gboolean parse_option_separator = FALSE; - static gint parse_option_text = 0; - static gint parse_option_file = 0; - static gint parse_option_editable = 0; - if (reason == POPT_CALLBACK_REASON_POST) - return; - else if (reason != POPT_CALLBACK_REASON_OPTION) - return; - - switch (opt->val & POPT_ARG_MASK) { - - case OPTION_CALENDAR: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_CALENDAR; - break; - case OPTION_ENTRY: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_ENTRY; - break; - case OPTION_ERROR: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_ERROR; - results->msg_data->mode = ZENITY_MSG_ERROR; - break; - case OPTION_INFO: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_INFO; - results->msg_data->mode = ZENITY_MSG_INFO; - break; - case OPTION_FILE: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_FILE; - break; - case OPTION_LIST: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); + zenity_option_free (); - results->mode = MODE_LIST; - break; - case OPTION_NOTIFICATION: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_NOTIFICATION; - break; - case OPTION_PROGRESS: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_PROGRESS; - break; - case OPTION_QUESTION: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_QUESTION; - results->msg_data->mode = ZENITY_MSG_QUESTION; - break; - case OPTION_TEXTINFO: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_TEXTINFO; - break; - case OPTION_WARNING: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_WARNING; - results->msg_data->mode = ZENITY_MSG_WARNING; - break; - case OPTION_TITLE: - if (results->data->dialog_title != NULL) - zenity_error ("--title", ERROR_DUPLICATE); - - results->data->dialog_title = g_strdup (arg); - break; - case OPTION_ICON: - if (results->data->window_icon != NULL) - zenity_error ("--window-icon", ERROR_DUPLICATE); - - results->data->window_icon = g_strdup (arg); - break; - case OPTION_WIDTH: - if (results->data->width != -1) - zenity_error ("--width", ERROR_DUPLICATE); - - results->data->width = atoi (arg); - break; - case OPTION_HEIGHT: - if (results->data->height != -1) - zenity_error ("--height", ERROR_DUPLICATE); - - results->data->height = atoi (arg); - break; - case OPTION_CALENDARTEXT: - case OPTION_ENTRYTEXT: - case OPTION_ERRORTEXT: - case OPTION_QUESTIONTEXT: - case OPTION_PROGRESSTEXT: - case OPTION_LISTTEXT: - case OPTION_WARNINGTEXT: - case OPTION_NOTIFICATIONTEXT: - /* FIXME: This is an ugly hack because of the way the poptOptions are - * ordered above. When you try and use an --option more than once - * parse_options_callback gets called for each option. Suckage - */ - - if (parse_option_text > 8) - zenity_error ("--text", ERROR_DUPLICATE); - - switch (results->mode) { - case MODE_CALENDAR: - results->calendar_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), - -1, NULL, NULL, NULL); - break; - case MODE_ENTRY: - results->entry_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), - -1, NULL, NULL, NULL); - break; - case MODE_ERROR: - case MODE_QUESTION: - case MODE_WARNING: - case MODE_INFO: - results->msg_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), - -1, NULL, NULL, NULL); - break; - case MODE_PROGRESS: - results->progress_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), - -1, NULL, NULL, NULL); - break; - case MODE_LIST: - results->tree_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), - -1, NULL, NULL, NULL); - break; - case MODE_NOTIFICATION: - results->notification_data->notification_text = g_locale_to_utf8 (g_strcompress (arg), - -1, NULL, NULL, NULL); - 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) - zenity_error ("--day", ERROR_DUPLICATE); - - results->calendar_data->day = atoi (arg); - break; - case OPTION_MONTH: - if (results->mode != MODE_CALENDAR) - zenity_error ("--month", ERROR_SUPPORT); - - if (results->calendar_data->month > 0) - zenity_error ("--day", ERROR_DUPLICATE); - - results->calendar_data->month = atoi (arg); - break; - case OPTION_YEAR: - if (results->mode != MODE_CALENDAR) - zenity_error ("--year", ERROR_SUPPORT); - - if (results->calendar_data->year > 0) - zenity_error ("--year", ERROR_DUPLICATE); - - results->calendar_data->year = atoi (arg); - break; - case OPTION_DATEFORMAT: - if (results->mode != MODE_CALENDAR) - zenity_error ("--date-format", ERROR_SUPPORT); - - if (parse_option_dateformat) - zenity_error ("--date-format", ERROR_DUPLICATE); - - results->calendar_data->date_format = g_strdup (arg); - parse_option_dateformat = TRUE; - break; - case OPTION_INPUTTEXT: - if (results->mode != MODE_ENTRY) - zenity_error ("--entry-text", ERROR_SUPPORT); - - if (results->entry_data->entry_text != NULL) - zenity_error ("--entry-text", ERROR_DUPLICATE); - - results->entry_data->entry_text = g_strdup (arg); - break; - case OPTION_HIDETEXT: - if (results->mode != MODE_ENTRY) - zenity_error ("--hide-text", ERROR_SUPPORT); - - if (!results->entry_data->visible) - zenity_error ("--hide-text", ERROR_DUPLICATE); - - results->entry_data->visible = FALSE; - break; - case OPTION_LISTEDIT: - case OPTION_TEXTEDIT: - - /* FIXME: This is an ugly hack because of the way the poptOptions are - * ordered above. When you try and use an --option more than once - * parse_options_callback gets called for each option. Suckage - */ - - if (parse_option_editable > 2) - zenity_error ("--editable", ERROR_DUPLICATE); - - switch (results->mode) { - 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: - - /* FIXME: This is an ugly hack because of the way the poptOptions are - * ordered above. When you try and use an --option more than once - * parse_options_callback gets called for each option. Suckage - */ - - if (parse_option_file > 2) - zenity_error ("--filename", ERROR_DUPLICATE); - - switch (results->mode) { - case MODE_FILE: - results->file_data->uri = g_strdup (arg); - break; - case MODE_TEXTINFO: - results->text_data->uri = g_strdup (arg); - break; - default: - zenity_error ("--filename", ERROR_SUPPORT); - } - parse_option_file++; - break; - case OPTION_MULTIFILE: - if (results->mode != MODE_FILE) - zenity_error ("--multiple", ERROR_SUPPORT); - - results->file_data->multi = TRUE; - break; - case OPTION_DIR: - if (results->mode != MODE_FILE) - zenity_error ("--directory", ERROR_SUPPORT); - - results->file_data->directory = TRUE; - break; - case OPTION_SAVE: - if (results->mode != MODE_FILE) - zenity_error ("--save", ERROR_SUPPORT); - - results->file_data->save = TRUE; - 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)); - break; - case OPTION_CHECKLIST: - if (results->mode != MODE_LIST) - zenity_error ("--checklist", ERROR_SUPPORT); - - if (results->tree_data->checkbox) - zenity_error ("--checklist", ERROR_DUPLICATE); - - results->tree_data->checkbox = TRUE; - break; - case OPTION_RADIOLIST: - if (results->mode != MODE_LIST) - zenity_error ("--radiolist", ERROR_SUPPORT); - if (results->tree_data->radiobox) - zenity_error ("--radiolist", ERROR_DUPLICATE); - - results->tree_data->radiobox = TRUE; - break; - case OPTION_SEPERATOR: - if (parse_option_separator > 2) - zenity_error ("--separator", ERROR_DUPLICATE); - switch (results->mode) { - case MODE_LIST: - results->tree_data->separator = g_strdup (g_strcompress (arg)); - parse_option_separator++; - break; - case MODE_FILE: - results->file_data->separator = g_strdup (g_strcompress (arg)); - parse_option_separator++; - break; - default: - zenity_error ("--separator", ERROR_SUPPORT); - } - break; - case OPTION_PERCENTAGE: - if (results->mode != MODE_PROGRESS) - zenity_error ("--percentage", ERROR_SUPPORT); - - if (results->progress_data->percentage > -1) - zenity_error ("--percentage", ERROR_DUPLICATE); - - results->progress_data->percentage = atoi (arg); - break; - case OPTION_PULSATE: - if (results->mode != MODE_PROGRESS) - zenity_error ("--pulsate", ERROR_SUPPORT); - - 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_PRINTCOLUMN: - if (results->mode != MODE_LIST) - zenity_error ("--print-column", ERROR_SUPPORT); - - results->tree_data->print_column = g_strdup (arg); - break; - case OPTION_NOTIFICATIONLISTEN: - if (results->mode != MODE_NOTIFICATION) - zenity_error ("--listen", ERROR_SUPPORT); - - results->notification_data->listen = TRUE; - break; - case OPTION_ABOUT: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_ABOUT; - break; - case OPTION_VERSION: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - zenity_free_parsing_options (); - g_print ("%s\n", VERSION); - exit (0); - break; - default: - break; - } + exit (retval); } -- cgit From 69e094a4570bae10dab378e8c024c76fc7d0250a Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Dec 2004 01:26:00 +0000 Subject: Fix for #137993. There is a chance that we'll have to revert this fix, 2004-12-07 Glynn Foster * src/main.c: Fix for #137993. There is a chance that we'll have to revert this fix, given the comments in /etc/X11/gdm/Xsession: # Note that this should only go to zenity dialogs which always # expect utf8 gettextfunc () { if [ "x$gdmtranslate" != "x" ] ; then "$gdmtranslate" --utf8 "$1" else echo "$1" fi } So I guess we may be over a barrel with our original guarantee. Let's just change this in 2.9.x and see if anyone notices or cares enough. Patch from Leonardo Boshell . --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 10e75b8a..b79afc06 100644 --- a/src/main.c +++ b/src/main.c @@ -44,11 +44,11 @@ main (gint argc, gchar **argv) { #endif bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); results = zenity_option_parse (argc, argv); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); gtk_init (&argc, &argv); switch (results->mode) { -- cgit From 6abd93050f533752e47b75158e95431575c652ac Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 25 Apr 2005 03:20:45 +0000 Subject: COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c, src/entry.c, 2005-04-25 Glynn Foster * COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c, * src/entry.c, src/fileselection.c, src/main.c, src/msg.c, * src/notification.c, src/option.c, src/progress.c, * src/text.c, src/tree.c, src/util.c: Update the FSF address to point to 51 Franklin Street, Fifth Floor as per forwarded mail from Alvaro Lopez Ortega. --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index b79afc06..09330d55 100644 --- a/src/main.c +++ b/src/main.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster */ -- cgit From 285cb79bafd2616f2d2dd7eb2ae82527942ef4cc Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 13 Dec 2005 04:18:58 +0000 Subject: new scale dialog for selecting a value from a range (Fixes #322399). 2005-12-13 Lucas Rocha * data/Makefile.am, data/zenity-scale.png, src/Makefile.am, src/main.c, src/option.c, src/option.h, src/scale.c, src/zenity.glade, src/zenity.h: new scale dialog for selecting a value from a range (Fixes #322399). --- src/main.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 09330d55..7077af8a 100644 --- a/src/main.c +++ b/src/main.c @@ -64,6 +64,9 @@ main (gint argc, gchar **argv) { case MODE_INFO: zenity_msg (results->data, results->msg_data); break; + case MODE_SCALE: + zenity_scale (results->data, results->scale_data); + break; case MODE_FILE: zenity_fileselection (results->data, results->file_data); break; -- cgit From 07618f9daa007f7cabfee3b25845e9088330abcd Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Thu, 11 May 2006 01:31:35 +0000 Subject: add optional dropdown menu to entry dialog (Fixed bug #311038). Patch from 2006-05-10 Lucas Rocha * src/entry.c (zenity_entry_fill_entries, zenity_entry), src/main.c, src/option.c, src/zenity.glade, src/zenity.h: add optional dropdown menu to entry dialog (Fixed bug #311038). Patch from Diego Escalante Urrelo . --- src/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 7077af8a..7e83fd89 100644 --- a/src/main.c +++ b/src/main.c @@ -56,6 +56,7 @@ main (gint argc, gchar **argv) { zenity_calendar (results->data, results->calendar_data); break; case MODE_ENTRY: + results->entry_data->data = (const gchar **) argv + 1; zenity_entry (results->data, results->entry_data); break; case MODE_ERROR: -- cgit From b73e72bcfea040aaf4ea681068676de3ee013ac8 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 27 May 2007 20:09:27 +0000 Subject: initialize GTK+ before parsing command line options to better handle 2007-05-27 Lucas Rocha * src/main.c: initialize GTK+ before parsing command line options to better handle errors on display setting (Fixes bug #410055). svn path=/trunk/; revision=1217 --- src/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 7e83fd89..1c37de2c 100644 --- a/src/main.c +++ b/src/main.c @@ -44,13 +44,13 @@ main (gint argc, gchar **argv) { #endif bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); - results = zenity_option_parse (argc, argv); - - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); gtk_init (&argc, &argv); + results = zenity_option_parse (argc, argv); + switch (results->mode) { case MODE_CALENDAR: zenity_calendar (results->data, results->calendar_data); -- cgit From bd9e29d33ac1ed929ee09ccdffaf59d4db428fe9 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 9 Jan 2009 00:10:30 +0000 Subject: GNOME Goal: Clean up GLib and GTK+ includes (Fixes bug #563855). Patch 2009-01-09 Lucas Rocha * src/main.c: * src/option.h: GNOME Goal: Clean up GLib and GTK+ includes (Fixes bug #563855). Patch from Pedro Fragoso . svn path=/trunk/; revision=1462 --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 1c37de2c..4f87e6df 100644 --- a/src/main.c +++ b/src/main.c @@ -27,7 +27,7 @@ #include "option.h" #include -#include +#include #include #include #ifdef HAVE_LOCALE_H -- cgit From 4ccc7f6fac79a189e0c0c4896bb2f0f38d38d7c7 Mon Sep 17 00:00:00 2001 From: Berislav Kovacki Date: Tue, 23 Feb 2010 18:24:20 +0000 Subject: Bug 540169 - Zenity should offer color selection dialog --- src/main.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 4f87e6df..5e079707 100644 --- a/src/main.c +++ b/src/main.c @@ -84,6 +84,9 @@ main (gint argc, gchar **argv) { case MODE_TEXTINFO: zenity_text (results->data, results->text_data); break; + case MODE_COLOR: + zenity_colorselection (results->data, results->color_data); + break; case MODE_ABOUT: zenity_about (results->data); break; -- cgit From 10d038022014a8069495bd72ccf9ed47fdf9d14d Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Sat, 10 Jul 2010 16:13:40 -0300 Subject: Add new password dialog --- src/main.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 5e079707..ee8fc3bf 100644 --- a/src/main.c +++ b/src/main.c @@ -87,6 +87,9 @@ main (gint argc, gchar **argv) { case MODE_COLOR: zenity_colorselection (results->data, results->color_data); break; + case MODE_PASSWORD: + zenity_password_dialog (results->data, results->password_data); + break; case MODE_ABOUT: zenity_about (results->data); break; -- cgit From 079254bb48c28f62d15270028e64308347888a76 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 4 Nov 2010 17:12:52 -0200 Subject: Add libnotify as optional in zenity instalation --- src/main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index ee8fc3bf..05176158 100644 --- a/src/main.c +++ b/src/main.c @@ -75,9 +75,11 @@ main (gint argc, gchar **argv) { results->tree_data->data = (const gchar **) argv + 1; zenity_tree (results->data, results->tree_data); break; +#ifdef HAVE_LIBNOTIFY case MODE_NOTIFICATION: zenity_notification (results->data, results->notification_data); break; +#endif case MODE_PROGRESS: zenity_progress (results->data, results->progress_data); break; -- cgit From 9c32783a1442f95f77a6a997058baa8c720011c8 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Mon, 17 Jan 2011 12:20:21 -0200 Subject: Adding missed files and code for --forms option. --- src/main.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 05176158..e667ee1a 100644 --- a/src/main.c +++ b/src/main.c @@ -95,6 +95,9 @@ main (gint argc, gchar **argv) { case MODE_ABOUT: zenity_about (results->data); break; + case MODE_FORMS: + zenity_forms_dialog (results->data, results->forms_data); + break; case MODE_VERSION: g_print ("%s\n", VERSION); break; -- cgit From 4eddb202cafdcabc254aa941ad1348ff09372627 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 7 Apr 2017 14:00:42 +0200 Subject: Fix style Fixing style in all zenity code, removing useless spaces, empty lines, all code in 80 columns, etc. --- src/main.c | 145 +++++++++++++++++++++++++++++++------------------------------ 1 file changed, 73 insertions(+), 72 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index e667ee1a..7f0c2db7 100644 --- a/src/main.c +++ b/src/main.c @@ -23,97 +23,98 @@ #include -#include "zenity.h" #include "option.h" +#include "zenity.h" -#include #include #include #include +#include #ifdef HAVE_LOCALE_H #include #endif -gint +gint main (gint argc, gchar **argv) { - ZenityParsingOptions *results; - gint retval; + ZenityParsingOptions *results; + gint retval; #ifdef HAVE_LOCALE_H - setlocale(LC_ALL,""); + setlocale (LC_ALL, ""); #endif - bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - textdomain(GETTEXT_PACKAGE); + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); - gtk_init (&argc, &argv); + gtk_init (&argc, &argv); - results = zenity_option_parse (argc, argv); + results = zenity_option_parse (argc, argv); - switch (results->mode) { - case MODE_CALENDAR: - zenity_calendar (results->data, results->calendar_data); - break; - case MODE_ENTRY: - results->entry_data->data = (const gchar **) argv + 1; - zenity_entry (results->data, results->entry_data); - break; - case MODE_ERROR: - case MODE_QUESTION: - case MODE_WARNING: - case MODE_INFO: - zenity_msg (results->data, results->msg_data); - break; - case MODE_SCALE: - zenity_scale (results->data, results->scale_data); - break; - case MODE_FILE: - zenity_fileselection (results->data, results->file_data); - break; - case MODE_LIST: - results->tree_data->data = (const gchar **) argv + 1; - zenity_tree (results->data, results->tree_data); - break; + switch (results->mode) { + case MODE_CALENDAR: + zenity_calendar (results->data, results->calendar_data); + break; + case MODE_ENTRY: + results->entry_data->data = (const gchar **) argv + 1; + zenity_entry (results->data, results->entry_data); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + case MODE_INFO: + zenity_msg (results->data, results->msg_data); + break; + case MODE_SCALE: + zenity_scale (results->data, results->scale_data); + break; + case MODE_FILE: + zenity_fileselection (results->data, results->file_data); + break; + case MODE_LIST: + results->tree_data->data = (const gchar **) argv + 1; + zenity_tree (results->data, results->tree_data); + break; #ifdef HAVE_LIBNOTIFY - case MODE_NOTIFICATION: - zenity_notification (results->data, results->notification_data); - break; + case MODE_NOTIFICATION: + zenity_notification (results->data, results->notification_data); + break; #endif - case MODE_PROGRESS: - zenity_progress (results->data, results->progress_data); - break; - case MODE_TEXTINFO: - zenity_text (results->data, results->text_data); - break; - case MODE_COLOR: - zenity_colorselection (results->data, results->color_data); - break; - case MODE_PASSWORD: - zenity_password_dialog (results->data, results->password_data); - break; - case MODE_ABOUT: - zenity_about (results->data); - break; - case MODE_FORMS: - zenity_forms_dialog (results->data, results->forms_data); - break; - case MODE_VERSION: - g_print ("%s\n", VERSION); - break; - case MODE_LAST: - g_printerr (_("You must specify a dialog type. See 'zenity --help' for details\n")); - zenity_option_free (); - exit (-1); - default: - g_assert_not_reached (); - zenity_option_free (); - exit (-1); - } + case MODE_PROGRESS: + zenity_progress (results->data, results->progress_data); + break; + case MODE_TEXTINFO: + zenity_text (results->data, results->text_data); + break; + case MODE_COLOR: + zenity_colorselection (results->data, results->color_data); + break; + case MODE_PASSWORD: + zenity_password_dialog (results->data, results->password_data); + break; + case MODE_ABOUT: + zenity_about (results->data); + break; + case MODE_FORMS: + zenity_forms_dialog (results->data, results->forms_data); + break; + case MODE_VERSION: + g_print ("%s\n", VERSION); + break; + case MODE_LAST: + g_printerr (_ ("You must specify a dialog type. See 'zenity " + "--help' for details\n")); + zenity_option_free (); + exit (-1); + default: + g_assert_not_reached (); + zenity_option_free (); + exit (-1); + } + + retval = results->data->exit_code; - retval = results->data->exit_code; - - zenity_option_free (); + zenity_option_free (); - exit (retval); + exit (retval); } -- cgit