2004-12-07 00:55:26 +00:00
|
|
|
/*
|
|
|
|
* option.h
|
|
|
|
*
|
|
|
|
* 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
|
COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c, src/entry.c,
2005-04-25 Glynn Foster <glynn.foster@sun.com>
* 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.
2005-04-25 03:20:45 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2004-12-07 00:55:26 +00:00
|
|
|
*
|
|
|
|
* Authors: Glynn Foster <glynn.foster@sun.com>
|
|
|
|
* Lucas Rocha <lucasr@im.ufba.br>
|
|
|
|
*/
|
|
|
|
|
2005-07-06 20:13:11 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2004-12-07 00:55:26 +00:00
|
|
|
#include "option.h"
|
2005-01-07 01:55:11 +00:00
|
|
|
#include <time.h>
|
2005-07-06 20:13:11 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* General Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gchar *zenity_general_dialog_title;
|
|
|
|
static gchar *zenity_general_window_icon;
|
|
|
|
static int zenity_general_width;
|
|
|
|
static int zenity_general_height;
|
|
|
|
static gchar *zenity_general_dialog_text;
|
|
|
|
static gchar *zenity_general_separator;
|
|
|
|
static gboolean zenity_general_multiple;
|
|
|
|
static gboolean zenity_general_editable;
|
|
|
|
static gchar *zenity_general_uri;
|
|
|
|
static gboolean zenity_general_dialog_no_wrap;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* Calendar Dialog Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean zenity_calendar_active;
|
|
|
|
static int zenity_calendar_day;
|
|
|
|
static int zenity_calendar_month;
|
|
|
|
static int zenity_calendar_year;
|
|
|
|
static gchar *zenity_calendar_date_format;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* Entry Dialog Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean zenity_entry_active;
|
|
|
|
static gchar *zenity_entry_entry_text;
|
|
|
|
static gboolean zenity_entry_hide_text;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* Error Dialog Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean zenity_error_active;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* Info Dialog Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean zenity_info_active;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* File Selection Dialog Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean zenity_file_active;
|
|
|
|
static gboolean zenity_file_directory;
|
|
|
|
static gboolean zenity_file_save;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* List Dialog Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean zenity_list_active;
|
|
|
|
static gchar **zenity_list_columns;
|
|
|
|
static gboolean zenity_list_checklist;
|
|
|
|
static gboolean zenity_list_radiolist;
|
|
|
|
static gchar *zenity_list_print_column;
|
|
|
|
static gchar *zenity_list_hide_column;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* Notification Dialog Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean zenity_notification_active;
|
|
|
|
static gboolean zenity_notification_listen;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* Progress Dialog Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean zenity_progress_active;
|
|
|
|
static int zenity_progress_percentage;
|
|
|
|
static gboolean zenity_progress_pulsate;
|
|
|
|
static gboolean zenity_progress_auto_close;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* Question Dialog Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean zenity_question_active;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* Text Dialog Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean zenity_text_active;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* Warning Dialog Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean zenity_warning_active;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
/* Miscelaneus Options */
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean zenity_misc_about;
|
|
|
|
static gboolean zenity_misc_version;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry general_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"title",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_general_dialog_title,
|
|
|
|
N_("Set the dialog title"),
|
|
|
|
N_("TITLE")
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"window-icon",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_FILENAME,
|
|
|
|
&zenity_general_window_icon,
|
|
|
|
N_("Set the window icon"),
|
|
|
|
N_("ICONPATH")
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"width",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_INT,
|
|
|
|
&zenity_general_width,
|
|
|
|
N_("Set the width"),
|
|
|
|
N_("WIDTH")
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"height",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_INT,
|
|
|
|
&zenity_general_height,
|
|
|
|
N_("Set the height"),
|
|
|
|
N_("HEIGHT")
|
|
|
|
},
|
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry calendar_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"calendar",
|
|
|
|
'\0',
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_calendar_active,
|
|
|
|
N_("Display calendar dialog"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"text",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_general_dialog_text,
|
|
|
|
N_("Set the dialog text"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"day",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_INT,
|
|
|
|
&zenity_calendar_day,
|
|
|
|
N_("Set the calendar day"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"month",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_INT,
|
|
|
|
&zenity_calendar_month,
|
|
|
|
N_("Set the calendar month"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"year",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_INT,
|
|
|
|
&zenity_calendar_year,
|
|
|
|
N_("Set the calendar year"),
|
|
|
|
NULL
|
|
|
|
},
|
2004-12-07 01:19:45 +00:00
|
|
|
{
|
|
|
|
"date-format",
|
2004-12-07 00:55:26 +00:00
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_calendar_date_format,
|
|
|
|
N_("Set the format for the returned date"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry entry_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"entry",
|
|
|
|
'\0',
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_entry_active,
|
|
|
|
N_("Display text entry dialog"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"text",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2005-09-24 15:04:02 +00:00
|
|
|
G_OPTION_ARG_STRING | G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
&zenity_general_dialog_text,
|
|
|
|
N_("Set the dialog text"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"entry-text",
|
|
|
|
'\0',
|
|
|
|
0,
|
2005-09-24 15:04:02 +00:00
|
|
|
G_OPTION_ARG_STRING,
|
2004-12-07 00:55:26 +00:00
|
|
|
&zenity_entry_entry_text,
|
|
|
|
N_("Set the entry text"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"hide-text",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_NONE,
|
2005-04-20 03:00:57 +00:00
|
|
|
&zenity_entry_hide_text,
|
2004-12-07 00:55:26 +00:00
|
|
|
N_("Hide the entry text"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry error_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"error",
|
|
|
|
'\0',
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_error_active,
|
|
|
|
N_("Display error dialog"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"text",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_general_dialog_text,
|
|
|
|
N_("Set the dialog text"),
|
|
|
|
NULL
|
|
|
|
},
|
2005-04-20 01:59:42 +00:00
|
|
|
{
|
|
|
|
"no-wrap",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2005-04-20 01:59:42 +00:00
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_general_dialog_no_wrap,
|
|
|
|
N_("Do not enable text wrapping"),
|
|
|
|
NULL
|
|
|
|
},
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry info_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"info",
|
|
|
|
'\0',
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_info_active,
|
|
|
|
N_("Display info dialog"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"text",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_general_dialog_text,
|
|
|
|
N_("Set the dialog text"),
|
|
|
|
NULL
|
|
|
|
},
|
2005-04-20 01:59:42 +00:00
|
|
|
{
|
|
|
|
"no-wrap",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2005-04-20 01:59:42 +00:00
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_general_dialog_no_wrap,
|
|
|
|
N_("Do not enable text wrapping"),
|
|
|
|
NULL
|
|
|
|
},
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry file_selection_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"file-selection",
|
|
|
|
'\0',
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_file_active,
|
|
|
|
N_("Display file selection dialog"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"filename",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_FILENAME,
|
|
|
|
&zenity_general_uri,
|
|
|
|
N_("Set the filename"),
|
|
|
|
N_("FILENAME")
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"multiple",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_NONE,
|
2005-06-27 03:13:37 +00:00
|
|
|
&zenity_general_multiple,
|
2004-12-07 00:55:26 +00:00
|
|
|
N_("Allow multiple files to be selected"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"directory",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_file_directory,
|
|
|
|
N_("Activate directory-only selection"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"save",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_file_save,
|
|
|
|
N_("Activate save mode"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"separator",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_general_separator,
|
|
|
|
N_("Set output separator character"),
|
|
|
|
N_("SEPARATOR")
|
|
|
|
},
|
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry list_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"list",
|
|
|
|
'\0',
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_list_active,
|
|
|
|
N_("Display list dialog"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"text",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_general_dialog_text,
|
|
|
|
N_("Set the dialog text"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"column",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_STRING_ARRAY,
|
|
|
|
&zenity_list_columns,
|
|
|
|
N_("Set the column header"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"checklist",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_list_checklist,
|
|
|
|
N_("Use check boxes for first column"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"radiolist",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_list_radiolist,
|
|
|
|
N_("Use radio buttons for first column"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"separator",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_general_separator,
|
|
|
|
N_("Set output separator character"),
|
|
|
|
N_("SEPARATOR")
|
|
|
|
},
|
2005-06-27 03:13:37 +00:00
|
|
|
{
|
|
|
|
"multiple",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2005-06-27 03:13:37 +00:00
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_general_multiple,
|
|
|
|
N_("Allow multiple rows to be selected"),
|
|
|
|
NULL
|
|
|
|
},
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"editable",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_general_editable,
|
|
|
|
N_("Allow changes to text"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"print-column",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_list_print_column,
|
|
|
|
N_("Print a specific column (Default is 1. 'ALL' can be used to print all columns)"),
|
|
|
|
NULL
|
|
|
|
},
|
2005-07-01 21:28:36 +00:00
|
|
|
{
|
|
|
|
"hide-column",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_list_hide_column,
|
|
|
|
N_("Hide a specific column"),
|
|
|
|
NULL
|
|
|
|
},
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry notification_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"notification",
|
|
|
|
'\0',
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_notification_active,
|
|
|
|
N_("Display notification"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"text",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_general_dialog_text,
|
|
|
|
N_("Set the notification text"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"listen",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_notification_listen,
|
|
|
|
N_("Listen for commands on stdin"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry progress_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"progress",
|
|
|
|
'\0',
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_progress_active,
|
|
|
|
N_("Display progress indication dialog"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"text",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_general_dialog_text,
|
|
|
|
N_("Set the dialog text"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"percentage",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_INT,
|
|
|
|
&zenity_progress_percentage,
|
|
|
|
N_("Set initial percentage"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"pulsate",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_progress_pulsate,
|
|
|
|
N_("Pulsate progress bar"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"auto-close",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_progress_auto_close,
|
|
|
|
/* xgettext: no-c-format */
|
|
|
|
N_("Dismiss the dialog when 100% has been reached"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry question_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"question",
|
|
|
|
'\0',
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_question_active,
|
|
|
|
N_("Display question dialog"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"text",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_general_dialog_text,
|
|
|
|
N_("Set the dialog text"),
|
|
|
|
NULL
|
|
|
|
},
|
2005-04-20 01:59:42 +00:00
|
|
|
{
|
|
|
|
"no-wrap",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2005-04-20 01:59:42 +00:00
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_general_dialog_no_wrap,
|
|
|
|
N_("Do not enable text wrapping"),
|
|
|
|
NULL
|
|
|
|
},
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry text_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"text-info",
|
|
|
|
'\0',
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_text_active,
|
|
|
|
N_("Display text information dialog"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"filename",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_FILENAME,
|
|
|
|
&zenity_general_uri,
|
|
|
|
N_("Open file"),
|
|
|
|
N_("FILENAME")
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"editable",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_general_editable,
|
|
|
|
N_("Allow changes to text"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry warning_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"warning",
|
|
|
|
'\0',
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_warning_active,
|
|
|
|
N_("Display warning dialog"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"text",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2004-12-07 00:55:26 +00:00
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&zenity_general_dialog_text,
|
|
|
|
N_("Set the dialog text"),
|
|
|
|
NULL
|
|
|
|
},
|
2005-04-20 01:59:42 +00:00
|
|
|
{
|
|
|
|
"no-wrap",
|
|
|
|
'\0',
|
2005-07-13 03:28:15 +00:00
|
|
|
G_OPTION_FLAG_NOALIAS,
|
2005-04-20 01:59:42 +00:00
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_general_dialog_no_wrap,
|
|
|
|
N_("Do not enable text wrapping"),
|
|
|
|
NULL
|
|
|
|
},
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionEntry miscellaneous_options[] = {
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
"about",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_misc_about,
|
|
|
|
N_("About zenity"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"version",
|
|
|
|
'\0',
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_NONE,
|
|
|
|
&zenity_misc_version,
|
|
|
|
N_("Print version"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static ZenityParsingOptions *results;
|
|
|
|
static GOptionContext *ctx;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static void
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_option_init (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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
zenity_option_free (void) {
|
|
|
|
if (zenity_general_dialog_title)
|
|
|
|
g_free (zenity_general_dialog_title);
|
|
|
|
if (zenity_general_window_icon)
|
|
|
|
g_free (zenity_general_window_icon);
|
|
|
|
if (zenity_general_dialog_text)
|
|
|
|
g_free (zenity_general_dialog_text);
|
|
|
|
if (zenity_general_uri)
|
|
|
|
g_free (zenity_general_uri);
|
|
|
|
g_free (zenity_general_separator);
|
|
|
|
|
|
|
|
if (zenity_calendar_date_format)
|
|
|
|
g_free (zenity_calendar_date_format);
|
|
|
|
|
|
|
|
if (zenity_entry_entry_text)
|
|
|
|
g_free (zenity_entry_entry_text);
|
|
|
|
|
|
|
|
if (zenity_list_columns)
|
|
|
|
g_strfreev (zenity_list_columns);
|
|
|
|
if (zenity_list_print_column)
|
|
|
|
g_free (zenity_list_print_column);
|
2005-07-01 21:28:36 +00:00
|
|
|
if (zenity_list_hide_column)
|
|
|
|
g_free (zenity_list_hide_column);
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
g_option_context_free (ctx);
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static void
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_option_set_dialog_mode (gboolean is_active, ZenityDialogMode mode)
|
|
|
|
{
|
|
|
|
if (is_active == TRUE) {
|
|
|
|
if (results->mode == MODE_LAST)
|
|
|
|
results->mode = mode;
|
|
|
|
else
|
|
|
|
zenity_option_error (NULL, ERROR_DIALOG);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gchar *
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_option_get_name (GOptionEntry *entries, gpointer arg_data)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 1; entries[i].long_name != NULL; i++) {
|
|
|
|
if (entries[i].arg_data == arg_data)
|
|
|
|
return (gchar *) entries[i].long_name;
|
2005-01-31 22:17:38 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
2004-12-07 00:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Error callback */
|
2005-07-08 13:39:27 +00:00
|
|
|
static void
|
|
|
|
zenity_option_error_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
2004-12-07 00:55:26 +00:00
|
|
|
{
|
|
|
|
zenity_option_error (NULL, ERROR_SYNTAX);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pre parse callbacks set the default option values */
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_general_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_general_dialog_title = NULL;
|
|
|
|
zenity_general_window_icon = NULL;
|
|
|
|
zenity_general_width = -1;
|
|
|
|
zenity_general_height = -1;
|
|
|
|
zenity_general_dialog_text = NULL;
|
|
|
|
zenity_general_separator = g_strdup ("|");
|
2005-06-27 03:13:37 +00:00
|
|
|
zenity_general_multiple = FALSE;
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_general_editable = FALSE;
|
|
|
|
zenity_general_uri = NULL;
|
2005-04-20 01:59:42 +00:00
|
|
|
zenity_general_dialog_no_wrap = FALSE;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_calendar_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_calendar_active = FALSE;
|
|
|
|
zenity_calendar_date_format = NULL;
|
2005-01-09 20:04:30 +00:00
|
|
|
zenity_calendar_day = -1;
|
|
|
|
zenity_calendar_month = -1;
|
|
|
|
zenity_calendar_year = -1;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_entry_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_entry_active = FALSE;
|
|
|
|
zenity_entry_entry_text = NULL;
|
2005-04-20 03:00:57 +00:00
|
|
|
zenity_entry_hide_text = FALSE;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_error_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_error_active = FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_info_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_info_active = FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_file_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_file_active = FALSE;
|
|
|
|
zenity_file_directory = FALSE;
|
|
|
|
zenity_file_save = FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_list_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_list_active = FALSE;
|
|
|
|
zenity_list_columns = NULL;
|
|
|
|
zenity_list_checklist = FALSE;
|
|
|
|
zenity_list_radiolist = FALSE;
|
|
|
|
zenity_list_print_column = NULL;
|
2005-07-01 21:28:36 +00:00
|
|
|
zenity_list_hide_column = NULL;
|
2004-12-07 00:55:26 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_notification_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_notification_active = FALSE;
|
|
|
|
zenity_notification_listen = FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_progress_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_progress_active = FALSE;
|
|
|
|
zenity_progress_percentage = 0;
|
|
|
|
zenity_progress_pulsate = FALSE;
|
|
|
|
zenity_progress_auto_close = FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_question_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_question_active = FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_text_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_text_active = FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_warning_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_warning_active = FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_misc_pre_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_misc_about = FALSE;
|
|
|
|
zenity_misc_version = FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Post parse callbacks assign the option values to
|
|
|
|
parsing result and makes some post condition tests */
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_general_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
results->data->dialog_title = zenity_general_dialog_title;
|
|
|
|
results->data->window_icon = zenity_general_window_icon;
|
|
|
|
results->data->width = zenity_general_width;
|
|
|
|
results->data->height = zenity_general_height;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_calendar_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_option_set_dialog_mode (zenity_calendar_active, MODE_CALENDAR);
|
|
|
|
|
|
|
|
if (results->mode == MODE_CALENDAR) {
|
2005-01-09 20:04:30 +00:00
|
|
|
struct tm *t;
|
|
|
|
time_t current_time;
|
|
|
|
|
|
|
|
time (¤t_time);
|
|
|
|
t = localtime (¤t_time);
|
|
|
|
|
|
|
|
if (zenity_calendar_day < 0)
|
|
|
|
zenity_calendar_day = t->tm_mday;
|
|
|
|
if (zenity_calendar_month < 0)
|
|
|
|
zenity_calendar_month = t->tm_mon + 1;
|
|
|
|
if (zenity_calendar_year < 0)
|
|
|
|
zenity_calendar_year = t->tm_year + 1900;
|
|
|
|
|
2004-12-07 00:55:26 +00:00
|
|
|
results->calendar_data->dialog_text = zenity_general_dialog_text;
|
|
|
|
results->calendar_data->day = zenity_calendar_day;
|
|
|
|
results->calendar_data->month = zenity_calendar_month;
|
|
|
|
results->calendar_data->year = zenity_calendar_year;
|
|
|
|
if (zenity_calendar_date_format)
|
|
|
|
results->calendar_data->date_format = zenity_calendar_date_format;
|
|
|
|
else
|
|
|
|
results->calendar_data->date_format = g_locale_to_utf8 (nl_langinfo (D_FMT), -1, NULL, NULL, NULL);
|
2005-01-09 20:04:30 +00:00
|
|
|
|
2004-12-07 00:55:26 +00:00
|
|
|
} else {
|
2005-01-09 20:04:30 +00:00
|
|
|
if (zenity_calendar_day > -1)
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_day),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
|
2005-01-09 20:04:30 +00:00
|
|
|
if (zenity_calendar_month > -1)
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_month),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
|
2005-01-09 20:04:30 +00:00
|
|
|
if (zenity_calendar_year > -1)
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_year),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
|
|
|
|
if (zenity_calendar_date_format)
|
|
|
|
zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_date_format),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_entry_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_option_set_dialog_mode (zenity_entry_active, MODE_ENTRY);
|
|
|
|
|
|
|
|
if (results->mode == MODE_ENTRY) {
|
|
|
|
results->entry_data->dialog_text = zenity_general_dialog_text;
|
|
|
|
results->entry_data->entry_text = zenity_entry_entry_text;
|
2005-04-20 03:00:57 +00:00
|
|
|
results->entry_data->hide_text= zenity_entry_hide_text;
|
2004-12-07 00:55:26 +00:00
|
|
|
} else {
|
|
|
|
if (zenity_entry_entry_text)
|
|
|
|
zenity_option_error (zenity_option_get_name (entry_options, &zenity_entry_entry_text),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
|
2005-04-20 03:00:57 +00:00
|
|
|
if (zenity_entry_hide_text)
|
|
|
|
zenity_option_error (zenity_option_get_name (entry_options, &zenity_entry_hide_text),
|
2004-12-07 00:55:26 +00:00
|
|
|
ERROR_SUPPORT);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_error_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_option_set_dialog_mode (zenity_error_active, MODE_ERROR);
|
|
|
|
|
|
|
|
if (results->mode == MODE_ERROR) {
|
|
|
|
results->msg_data->dialog_text = zenity_general_dialog_text;
|
|
|
|
results->msg_data->mode = ZENITY_MSG_ERROR;
|
2005-04-20 01:59:42 +00:00
|
|
|
results->msg_data->no_wrap = zenity_general_dialog_no_wrap;
|
2004-12-07 00:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_info_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_option_set_dialog_mode (zenity_info_active, MODE_INFO);
|
|
|
|
|
|
|
|
if (results->mode == MODE_INFO) {
|
|
|
|
results->msg_data->dialog_text = zenity_general_dialog_text;
|
|
|
|
results->msg_data->mode = ZENITY_MSG_INFO;
|
2005-04-20 01:59:42 +00:00
|
|
|
results->msg_data->no_wrap = zenity_general_dialog_no_wrap;
|
2004-12-07 00:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_file_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_option_set_dialog_mode (zenity_file_active, MODE_FILE);
|
|
|
|
|
|
|
|
if (results->mode == MODE_FILE) {
|
|
|
|
results->file_data->uri = zenity_general_uri;
|
2005-06-27 03:13:37 +00:00
|
|
|
results->file_data->multi = zenity_general_multiple;
|
2004-12-07 00:55:26 +00:00
|
|
|
results->file_data->directory = zenity_file_directory;
|
|
|
|
results->file_data->save = zenity_file_save;
|
|
|
|
results->file_data->separator = zenity_general_separator;
|
|
|
|
} else {
|
|
|
|
if (zenity_file_directory)
|
|
|
|
zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_directory),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
|
|
|
|
if (zenity_file_save)
|
|
|
|
zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_save),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_list_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
gchar *column;
|
|
|
|
|
|
|
|
zenity_option_set_dialog_mode (zenity_list_active, MODE_LIST);
|
|
|
|
|
|
|
|
if (results->mode == MODE_LIST) {
|
|
|
|
results->tree_data->dialog_text = zenity_general_dialog_text;
|
|
|
|
|
|
|
|
if (zenity_list_columns) {
|
|
|
|
column = zenity_list_columns[0];
|
|
|
|
while (column != NULL) {
|
|
|
|
results->tree_data->columns = g_slist_append (results->tree_data->columns, column);
|
|
|
|
column = zenity_list_columns[++i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
results->tree_data->checkbox = zenity_list_checklist;
|
|
|
|
results->tree_data->radiobox = zenity_list_radiolist;
|
2005-06-27 03:13:37 +00:00
|
|
|
results->tree_data->multi = zenity_general_multiple;
|
2004-12-07 00:55:26 +00:00
|
|
|
results->tree_data->editable = zenity_general_editable;
|
|
|
|
results->tree_data->print_column = zenity_list_print_column;
|
2005-07-01 21:28:36 +00:00
|
|
|
results->tree_data->hide_column = zenity_list_hide_column;
|
2004-12-07 00:55:26 +00:00
|
|
|
results->tree_data->separator = zenity_general_separator;
|
|
|
|
} else {
|
|
|
|
if (zenity_list_columns)
|
|
|
|
zenity_option_error (zenity_option_get_name (list_options, &zenity_list_columns),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
|
|
|
|
if (zenity_list_checklist)
|
|
|
|
zenity_option_error (zenity_option_get_name (list_options, &zenity_list_checklist),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
|
|
|
|
if (zenity_list_radiolist)
|
|
|
|
zenity_option_error (zenity_option_get_name (list_options, &zenity_list_radiolist),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
|
|
|
|
if (zenity_list_print_column)
|
|
|
|
zenity_option_error (zenity_option_get_name (list_options, &zenity_list_print_column),
|
|
|
|
ERROR_SUPPORT);
|
2005-07-01 21:28:36 +00:00
|
|
|
|
|
|
|
if (zenity_list_hide_column)
|
|
|
|
zenity_option_error (zenity_option_get_name (list_options, &zenity_list_hide_column),
|
|
|
|
ERROR_SUPPORT);
|
2004-12-07 00:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_notification_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_option_set_dialog_mode (zenity_notification_active, MODE_NOTIFICATION);
|
|
|
|
|
|
|
|
if (results->mode == MODE_NOTIFICATION) {
|
|
|
|
results->notification_data->notification_text = zenity_general_dialog_text;
|
|
|
|
results->notification_data->listen = zenity_notification_listen;
|
|
|
|
} else {
|
|
|
|
if (zenity_notification_listen)
|
|
|
|
zenity_option_error (zenity_option_get_name (notification_options, &zenity_notification_listen),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_progress_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_option_set_dialog_mode (zenity_progress_active, MODE_PROGRESS);
|
|
|
|
|
|
|
|
if (results->mode == MODE_PROGRESS) {
|
|
|
|
results->progress_data->dialog_text = zenity_general_dialog_text;
|
|
|
|
results->progress_data->pulsate = zenity_progress_pulsate;
|
|
|
|
results->progress_data->autoclose = zenity_progress_auto_close;
|
|
|
|
results->progress_data->percentage = zenity_progress_percentage;
|
|
|
|
} else {
|
|
|
|
if (zenity_progress_pulsate)
|
|
|
|
zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_pulsate),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
|
|
|
|
if (zenity_progress_percentage)
|
|
|
|
zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_percentage),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
|
|
|
|
if (zenity_progress_auto_close)
|
|
|
|
zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_auto_close),
|
|
|
|
ERROR_SUPPORT);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_question_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_option_set_dialog_mode (zenity_question_active, MODE_QUESTION);
|
|
|
|
|
|
|
|
|
|
|
|
if (results->mode == MODE_QUESTION) {
|
|
|
|
results->msg_data->dialog_text = zenity_general_dialog_text;
|
|
|
|
results->msg_data->mode = ZENITY_MSG_QUESTION;
|
2005-04-20 01:59:42 +00:00
|
|
|
results->msg_data->no_wrap = zenity_general_dialog_no_wrap;
|
2004-12-07 00:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_text_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_option_set_dialog_mode (zenity_text_active, MODE_TEXTINFO);
|
|
|
|
|
|
|
|
if (results->mode == MODE_TEXTINFO) {
|
|
|
|
results->text_data->uri = zenity_general_uri;
|
|
|
|
results->text_data->editable = zenity_general_editable;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_warning_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_option_set_dialog_mode (zenity_warning_active, MODE_WARNING);
|
|
|
|
|
|
|
|
if (results->mode == MODE_WARNING) {
|
|
|
|
results->msg_data->dialog_text = zenity_general_dialog_text;
|
|
|
|
results->msg_data->mode = ZENITY_MSG_WARNING;
|
2005-04-20 01:59:42 +00:00
|
|
|
results->msg_data->no_wrap = zenity_general_dialog_no_wrap;
|
2004-12-07 00:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static gboolean
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_misc_post_callback (GOptionContext *context,
|
|
|
|
GOptionGroup *group,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
zenity_option_set_dialog_mode (zenity_misc_about, MODE_ABOUT);
|
|
|
|
zenity_option_set_dialog_mode (zenity_misc_version, MODE_VERSION);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-08 13:39:27 +00:00
|
|
|
static GOptionContext *
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_create_context (void)
|
|
|
|
{
|
|
|
|
GOptionContext *tmp_ctx;
|
|
|
|
GOptionGroup *a_group;
|
|
|
|
|
|
|
|
tmp_ctx = g_option_context_new(NULL);
|
|
|
|
|
|
|
|
/* Adds general option entries */
|
|
|
|
a_group = g_option_group_new("general",
|
|
|
|
N_("General options"),
|
|
|
|
N_("Show general options"), NULL, 0);
|
|
|
|
g_option_group_add_entries(a_group, general_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_general_pre_callback, zenity_general_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds calendar option entries */
|
|
|
|
a_group = g_option_group_new("calendar",
|
|
|
|
N_("Calendar options"),
|
|
|
|
N_("Show calendar options"), NULL, 0);
|
|
|
|
g_option_group_add_entries(a_group, calendar_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_calendar_pre_callback, zenity_calendar_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds entry option entries */
|
|
|
|
a_group = g_option_group_new("entry",
|
|
|
|
N_("Text entry options"),
|
|
|
|
N_("Show text entry options"), NULL, 0);
|
|
|
|
g_option_group_add_entries(a_group, entry_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_entry_pre_callback, zenity_entry_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds error option entries */
|
|
|
|
a_group = g_option_group_new("error",
|
|
|
|
N_("Error options"),
|
|
|
|
N_("Show error options"), NULL, 0);
|
|
|
|
g_option_group_add_entries(a_group, error_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_error_pre_callback, zenity_error_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds info option entries */
|
|
|
|
a_group = g_option_group_new("info",
|
|
|
|
N_("Info options"),
|
|
|
|
N_("Show info options"), NULL, 0);
|
|
|
|
g_option_group_add_entries(a_group, info_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_info_pre_callback, zenity_info_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds file selection option entries */
|
|
|
|
a_group = g_option_group_new("file-selection",
|
|
|
|
N_("File selection options"),
|
|
|
|
N_("Show file selection options"), NULL, 0);
|
|
|
|
g_option_group_add_entries(a_group, file_selection_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_file_pre_callback, zenity_file_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds list option entries */
|
|
|
|
a_group = g_option_group_new("list",
|
|
|
|
N_("List options"),
|
|
|
|
N_("Show list options"), NULL, 0);
|
|
|
|
g_option_group_add_entries(a_group, list_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_list_pre_callback, zenity_list_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds notification option entries */
|
|
|
|
a_group = g_option_group_new("notification",
|
2005-02-06 23:13:16 +00:00
|
|
|
N_("Notification icon options"),
|
|
|
|
N_("Show notification icon options"), NULL, 0);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_group_add_entries(a_group, notification_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_notification_pre_callback, zenity_notification_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds progress option entries */
|
|
|
|
a_group = g_option_group_new("progress",
|
|
|
|
N_("Progress options"),
|
|
|
|
N_("Show progress options"), NULL, 0);
|
|
|
|
g_option_group_add_entries(a_group, progress_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_progress_pre_callback, zenity_progress_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds question option entries */
|
|
|
|
a_group = g_option_group_new("question",
|
|
|
|
N_("Question options"),
|
|
|
|
N_("Show question options"), NULL, 0);
|
|
|
|
g_option_group_add_entries(a_group, question_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_question_pre_callback, zenity_question_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds warning option entries */
|
|
|
|
a_group = g_option_group_new("warning",
|
|
|
|
N_("Warning options"),
|
|
|
|
N_("Show warning options"), NULL, 0);
|
|
|
|
g_option_group_add_entries(a_group, warning_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_warning_pre_callback, zenity_warning_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds text option entries */
|
2005-02-06 23:13:16 +00:00
|
|
|
a_group = g_option_group_new("text-info",
|
|
|
|
N_("Text information options"),
|
|
|
|
N_("Show text information options"), NULL, 0);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_group_add_entries(a_group, text_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_text_pre_callback, zenity_text_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds misc option entries */
|
|
|
|
a_group = g_option_group_new("misc",
|
|
|
|
N_("Miscellaneous options"),
|
|
|
|
N_("Show miscellaneous options"), NULL, 0);
|
|
|
|
g_option_group_add_entries(a_group, miscellaneous_options);
|
|
|
|
g_option_group_set_parse_hooks (a_group,
|
|
|
|
zenity_misc_pre_callback, zenity_misc_post_callback);
|
|
|
|
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Adds gtk option entries */
|
|
|
|
a_group = gtk_get_option_group(TRUE);
|
2005-07-12 13:46:50 +00:00
|
|
|
g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE);
|
2004-12-07 00:55:26 +00:00
|
|
|
g_option_context_add_group(tmp_ctx, a_group);
|
|
|
|
|
|
|
|
/* Enable help options */
|
|
|
|
g_option_context_set_help_enabled (tmp_ctx, TRUE);
|
|
|
|
g_option_context_set_ignore_unknown_options (tmp_ctx, FALSE);
|
|
|
|
|
|
|
|
return tmp_ctx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
zenity_option_error (gchar *string, ZenityError error)
|
|
|
|
{
|
|
|
|
switch (error) {
|
|
|
|
case ERROR_SYNTAX:
|
2005-04-20 03:00:57 +00:00
|
|
|
g_printerr (_("This option is not available. Please see --help for all possible usages.\n"));
|
2004-12-07 00:55:26 +00:00
|
|
|
zenity_option_free ();
|
|
|
|
exit (-1);
|
|
|
|
case ERROR_SUPPORT:
|
|
|
|
g_printerr (_("--%s is not supported for this dialog\n"), string);
|
|
|
|
zenity_option_free ();
|
|
|
|
exit (-1);
|
|
|
|
case ERROR_DIALOG:
|
|
|
|
g_printerr (_("Two or more dialog options specified\n"));
|
|
|
|
zenity_option_free ();
|
|
|
|
exit (-1);
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ZenityParsingOptions *
|
|
|
|
zenity_option_parse (gint argc, gchar **argv)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
zenity_option_init ();
|
|
|
|
|
|
|
|
ctx = zenity_create_context ();
|
|
|
|
|
|
|
|
g_option_context_parse (ctx, &argc, &argv, &error);
|
|
|
|
|
|
|
|
/* Some option pointer a shared among more than one group and don't
|
|
|
|
have their post condition tested. This test is done here. */
|
|
|
|
|
|
|
|
if (zenity_general_dialog_text)
|
|
|
|
if (results->mode == MODE_ABOUT || results->mode == MODE_VERSION)
|
|
|
|
zenity_option_error (zenity_option_get_name (calendar_options, &zenity_general_dialog_text), ERROR_SUPPORT);
|
|
|
|
|
|
|
|
if (strcmp (zenity_general_separator, "|") != 0)
|
|
|
|
if (results->mode != MODE_LIST && results->mode != MODE_FILE)
|
|
|
|
zenity_option_error (zenity_option_get_name (list_options, &zenity_general_separator), ERROR_SUPPORT);
|
|
|
|
|
2005-06-27 03:13:37 +00:00
|
|
|
if (zenity_general_multiple)
|
|
|
|
if (results->mode != MODE_FILE && results->mode != MODE_LIST)
|
|
|
|
zenity_option_error (zenity_option_get_name (list_options, &zenity_general_multiple), ERROR_SUPPORT);
|
|
|
|
|
2004-12-07 00:55:26 +00:00
|
|
|
if (zenity_general_editable)
|
|
|
|
if (results->mode != MODE_TEXTINFO && results->mode != MODE_LIST)
|
|
|
|
zenity_option_error (zenity_option_get_name (list_options, &zenity_general_editable), ERROR_SUPPORT);
|
|
|
|
|
|
|
|
if (zenity_general_uri)
|
|
|
|
if (results->mode != MODE_FILE && results->mode != MODE_TEXTINFO)
|
|
|
|
zenity_option_error (zenity_option_get_name (text_options, &zenity_general_uri), ERROR_SUPPORT);
|
|
|
|
|
2005-04-20 01:59:42 +00:00
|
|
|
if (zenity_general_dialog_no_wrap)
|
|
|
|
if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING)
|
|
|
|
zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_no_wrap), ERROR_SUPPORT);
|
|
|
|
|
2004-12-07 00:55:26 +00:00
|
|
|
return results;
|
|
|
|
}
|