diff options
author | Mike Newman <MikeGTN@src.gnome.org> | 2003-01-13 17:35:57 +0000 |
---|---|---|
committer | Mike Newman <MikeGTN@src.gnome.org> | 2003-01-13 17:35:57 +0000 |
commit | 9a77e41fecb3489b069aa7b1bb52ba56f1052819 (patch) | |
tree | 375f81fad95ab0e83802d6805e0953de00794da1 /src/main.c | |
parent | Improve error handling. Make --list actually return something useful, (diff) | |
download | zenity-9a77e41fecb3489b069aa7b1bb52ba56f1052819.tar.gz zenity-9a77e41fecb3489b069aa7b1bb52ba56f1052819.tar.bz2 zenity-9a77e41fecb3489b069aa7b1bb52ba56f1052819.zip |
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.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -24,6 +24,7 @@ #include "config.h" #include "zenity.h" #include <popt.h> +#include <langinfo.h> 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")); |