master
TheBrokenRail 11 months ago
parent 6cf0447c3b
commit dc72103c6a

@ -55,8 +55,8 @@ main (gint argc, gchar **argv) {
zenity_tree (results->data, results->tree_data);
break;
case MODE_LAST:
g_printerr ("You must specify a dialog type. See 'zenity "
"--help' for details\n");
g_printerr ("You must specify a dialog type. See 'zenity "
"--help' for details\n");
zenity_option_free ();
exit (-1);
default:

@ -67,72 +67,72 @@ static GOptionEntry general_options[] = {{"title",
0,
G_OPTION_ARG_STRING,
&zenity_general_dialog_title,
"Set the dialog title",
"TITLE"},
"Set the dialog title",
"TITLE"},
{"window-icon",
'\0',
0,
G_OPTION_ARG_FILENAME,
&zenity_general_window_icon,
"Set the window icon",
"ICONPATH"},
"Set the window icon",
"ICONPATH"},
{"width",
'\0',
0,
G_OPTION_ARG_INT,
&zenity_general_width,
"Set the width",
"WIDTH"},
"Set the width",
"WIDTH"},
{"height",
'\0',
0,
G_OPTION_ARG_INT,
&zenity_general_height,
"Set the height",
"HEIGHT"},
"Set the height",
"HEIGHT"},
{"timeout",
'\0',
0,
G_OPTION_ARG_INT,
&zenity_general_timeout_delay,
"Set dialog timeout in seconds",
"Set dialog timeout in seconds",
/* Timeout for closing the dialog */
"TIMEOUT"},
"TIMEOUT"},
{"ok-label",
'\0',
G_OPTION_FLAG_NOALIAS,
G_OPTION_ARG_STRING,
&zenity_general_ok_button,
"Set the label of the OK button",
"TEXT"},
"Set the label of the OK button",
"TEXT"},
{"cancel-label",
'\0',
G_OPTION_FLAG_NOALIAS,
G_OPTION_ARG_STRING,
&zenity_general_cancel_button,
"Set the label of the Cancel button",
"TEXT"},
"Set the label of the Cancel button",
"TEXT"},
{"extra-button",
'\0',
0,
G_OPTION_ARG_STRING_ARRAY,
&zenity_general_extra_buttons,
"Add an extra button",
"TEXT"},
"Add an extra button",
"TEXT"},
{"modal",
'\0',
G_OPTION_FLAG_NOALIAS,
G_OPTION_ARG_NONE,
&zenity_general_modal,
"Set the modal hint",
"Set the modal hint",
NULL},
{"attach",
'\0',
G_OPTION_FLAG_NOALIAS,
G_OPTION_ARG_INT,
&zenity_general_attach,
"Set the parent window to attach to",
"WINDOW"},
"Set the parent window to attach to",
"WINDOW"},
{NULL}};
static GOptionEntry entry_options[] = {{"entry",
@ -140,28 +140,28 @@ static GOptionEntry entry_options[] = {{"entry",
G_OPTION_FLAG_IN_MAIN,
G_OPTION_ARG_NONE,
&zenity_entry_active,
"Display text entry dialog",
"Display text entry dialog",
NULL},
{"text",
'\0',
G_OPTION_FLAG_NOALIAS,
G_OPTION_ARG_STRING,
&zenity_general_dialog_text,
"Set the dialog text",
"TEXT"},
"Set the dialog text",
"TEXT"},
{"entry-text",
'\0',
0,
G_OPTION_ARG_STRING,
&zenity_entry_entry_text,
"Set the entry text",
"TEXT"},
"Set the entry text",
"TEXT"},
{"hide-text",
'\0',
0,
G_OPTION_ARG_NONE,
&zenity_entry_hide_text,
"Hide the entry text",
"Hide the entry text",
NULL},
{NULL}};
@ -170,94 +170,94 @@ static GOptionEntry list_options[] = {{"list",
G_OPTION_FLAG_IN_MAIN,
G_OPTION_ARG_NONE,
&zenity_list_active,
"Display list dialog",
"Display list dialog",
NULL},
{"text",
'\0',
G_OPTION_FLAG_NOALIAS,
G_OPTION_ARG_STRING,
&zenity_general_dialog_text,
"Set the dialog text",
"TEXT"},
"Set the dialog text",
"TEXT"},
{"column",
'\0',
0,
G_OPTION_ARG_STRING_ARRAY,
&zenity_list_columns,
"Set the column header",
"COLUMN"},
"Set the column header",
"COLUMN"},
{"checklist",
'\0',
0,
G_OPTION_ARG_NONE,
&zenity_list_checklist,
"Use check boxes for the first column",
"Use check boxes for the first column",
NULL},
{"radiolist",
'\0',
0,
G_OPTION_ARG_NONE,
&zenity_list_radiolist,
"Use radio buttons for the first column",
"Use radio buttons for the first column",
NULL},
{"imagelist",
'\0',
0,
G_OPTION_ARG_NONE,
&zenity_list_imagelist,
"Use an image for the first column",
"Use an image for the first column",
NULL},
{"separator",
'\0',
G_OPTION_FLAG_NOALIAS,
G_OPTION_ARG_STRING,
&zenity_general_separator,
"Set output separator character",
"SEPARATOR"},
"Set output separator character",
"SEPARATOR"},
{"multiple",
'\0',
G_OPTION_FLAG_NOALIAS,
G_OPTION_ARG_NONE,
&zenity_general_multiple,
"Allow multiple rows to be selected",
"Allow multiple rows to be selected",
NULL},
{"editable",
'\0',
G_OPTION_FLAG_NOALIAS,
G_OPTION_ARG_NONE,
&zenity_general_editable,
"Allow changes to text",
"Allow changes to text",
NULL},
{"print-column",
'\0',
0,
G_OPTION_ARG_STRING,
&zenity_list_print_column,
"Print a specific column (Default is 1. 'ALL' can be used to print "
"all columns)",
"Print a specific column (Default is 1. 'ALL' can be used to print "
"all columns)",
/* Column index number to print out on a list dialog */
"NUMBER"},
"NUMBER"},
{"hide-column",
'\0',
0,
G_OPTION_ARG_STRING,
&zenity_list_hide_column,
"Hide a specific column",
"NUMBER"},
"Hide a specific column",
"NUMBER"},
{"hide-header",
'\0',
G_OPTION_FLAG_NOALIAS,
G_OPTION_ARG_NONE,
&zenity_list_hide_header,
"Hide the column headers",
"Hide the column headers",
NULL},
{"mid-search",
'\0',
G_OPTION_FLAG_NOALIAS,
G_OPTION_ARG_NONE,
&zenity_list_mid_search,
"Change list default search function searching for text in the "
"middle, not on the beginning",
"Change list default search function searching for text in the "
"middle, not on the beginning",
NULL},
{NULL}};
@ -271,9 +271,9 @@ zenity_option_init (void) {
/* Initialize the various dialog structures */
results->mode = MODE_LAST;
results->data = g_new0 (ZenityData, 1);
results->entry_data = g_new0 (ZenityEntryData, 1);
results->tree_data = g_new0 (ZenityTreeData, 1);
results->data = g_new0 (ZenityData, 1);
results->entry_data = g_new0 (ZenityEntryData, 1);
results->tree_data = g_new0 (ZenityTreeData, 1);
}
void
@ -295,14 +295,14 @@ zenity_option_free (void) {
g_strfreev (zenity_general_extra_buttons);
if (zenity_entry_entry_text)
g_free (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);
if (zenity_list_hide_column)
g_free (zenity_list_hide_column);
g_free (zenity_list_hide_column);
g_option_context_free (ctx);
}
@ -513,40 +513,34 @@ zenity_create_context (void) {
tmp_ctx = g_option_context_new (NULL);
/* Adds general option entries */
a_group = g_option_group_new ("general",
"General options",
"Show general options",
NULL,
NULL);
a_group = g_option_group_new (
"general", "General options", "Show general options", NULL, NULL);
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);
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
g_option_context_add_group (tmp_ctx, a_group);
/* Adds entry option entries */
a_group = g_option_group_new ("entry",
"Text entry options",
"Show text entry options",
NULL,
NULL);
a_group = g_option_group_new (
"entry", "Text entry options", "Show text entry options", NULL, NULL);
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);
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
g_option_context_add_group (tmp_ctx, a_group);
/* Adds list option entries */
a_group = g_option_group_new (
"list", "List options", "Show list options", NULL, NULL);
"list", "List options", "Show list options", NULL, NULL);
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);
g_option_group_set_error_hook (a_group, zenity_option_error_callback);
g_option_context_add_group (tmp_ctx, a_group);
/* Adds gtk option entries */
a_group = gtk_get_option_group (TRUE);
a_group = gtk_get_option_group (TRUE);
g_option_context_add_group (tmp_ctx, a_group);
/* Enable help options */
@ -560,16 +554,16 @@ void
zenity_option_error (gchar *string, ZenityError error) {
switch (error) {
case ERROR_SYNTAX:
g_printerr ("This option is not available. Please see --help "
"for all possible usages.\n");
g_printerr ("This option is not available. Please see --help "
"for all possible usages.\n");
zenity_option_free ();
exit (-1);
case ERROR_SUPPORT:
g_printerr ("--%s is not supported for this dialog\n", string);
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");
g_printerr ("Two or more dialog options specified\n");
zenity_option_free ();
exit (-1);
default:
@ -591,19 +585,19 @@ zenity_option_parse (gint argc, gchar **argv) {
have their post condition tested. This test is done here. */
if (strcmp (zenity_general_separator, "|") != 0)
if (results->mode != MODE_LIST)
if (results->mode != MODE_LIST)
zenity_option_error (zenity_option_get_name (
list_options, &zenity_general_separator),
ERROR_SUPPORT);
if (zenity_general_multiple)
if (results->mode != MODE_LIST)
if (results->mode != MODE_LIST)
zenity_option_error (
zenity_option_get_name (list_options, &zenity_general_multiple),
ERROR_SUPPORT);
if (zenity_general_editable)
if (results->mode != MODE_LIST)
if (results->mode != MODE_LIST)
zenity_option_error (
zenity_option_get_name (list_options, &zenity_general_editable),
ERROR_SUPPORT);

@ -30,11 +30,7 @@
#include <locale.h>
#endif
typedef enum {
MODE_ENTRY,
MODE_LIST,
MODE_LAST
} ZenityDialogMode;
typedef enum { MODE_ENTRY, MODE_LIST, MODE_LAST } ZenityDialogMode;
typedef enum {
ERROR_SYNTAX,
@ -47,8 +43,8 @@ typedef struct {
ZenityDialogMode mode;
ZenityData *data;
ZenityEntryData *entry_data;
ZenityTreeData *tree_data;
ZenityEntryData *entry_data;
ZenityTreeData *tree_data;
} ZenityParsingOptions;
void zenity_option_error (gchar *string, ZenityError error);

@ -61,11 +61,8 @@ zenity_tree_dialog_untoggle (
}
static void
check_or_radio_label_activated_cb (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer user_data)
{
check_or_radio_label_activated_cb (GtkTreeView *tree_view, GtkTreePath *path,
GtkTreeViewColumn *column, gpointer user_data) {
GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
GtkTreeIter iter;
gboolean value;
@ -384,13 +381,13 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) {
tree_data->hide_column, n_columns);
if (n_columns == 0) {
g_printerr ("No column titles specified for List dialog.\n");
g_printerr ("No column titles specified for List dialog.\n");
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
return;
}
if (tree_data->checkbox + tree_data->radiobox + tree_data->imagebox > 1) {
g_printerr ("You should use only one List dialog type.\n");
g_printerr ("You should use only one List dialog type.\n");
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
return;
}
@ -444,18 +441,15 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) {
tree_view = gtk_builder_get_object (builder, "zenity_tree_view");
if (tree_data->radiobox || tree_data->checkbox)
{
gtk_tree_view_set_activate_on_single_click (GTK_TREE_VIEW(tree_view),
TRUE);
if (tree_data->radiobox || tree_data->checkbox) {
gtk_tree_view_set_activate_on_single_click (
GTK_TREE_VIEW (tree_view), TRUE);
g_signal_connect (tree_view,
"row-activated",
G_CALLBACK (check_or_radio_label_activated_cb),
data);
}
else
{
} else {
g_signal_connect (tree_view,
"row-activated",
G_CALLBACK (zenity_tree_row_activated),
@ -489,14 +483,11 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) {
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model));
if (tree_data->radiobox || tree_data->checkbox)
{
if (tree_data->radiobox || tree_data->checkbox) {
gtk_tree_selection_set_mode (
gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
GTK_SELECTION_SINGLE);
}
else
{
} else {
if (tree_data->multi)
gtk_tree_selection_set_mode (
gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
@ -641,8 +632,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) {
* despite it not containing any user readable text.
* Set it to second column instead if it exists. */
if (tree_data->imagebox && n_columns > 1) {
gtk_tree_view_set_search_column (GTK_TREE_VIEW (tree_view),
1);
gtk_tree_view_set_search_column (GTK_TREE_VIEW (tree_view), 1);
}
zenity_util_show_dialog (dialog, data->attach);
@ -769,7 +759,7 @@ zenity_tree_dialog_output (void) {
g_free (print_columns);
g_free (hide_columns);
g_free (separator);
g_slist_foreach (selected, (GFunc) (void *) g_free, NULL);
g_slist_foreach (selected, (GFunc) (void *) g_free, NULL);
selected = NULL;
}

@ -75,14 +75,13 @@ zenity_util_load_ui_file (const gchar *root_widget, ...) {
g_ptr_array_add (ptrarray, NULL);
objects = (gchar **) g_ptr_array_free (ptrarray, FALSE);
result = gtk_builder_add_objects_from_resource (
builder, "/zenity.ui", objects, &error);
result = gtk_builder_add_objects_from_resource (
builder, "/zenity.ui", objects, &error);
g_strfreev (objects);
if (result == 0) {
g_warning ("Could not load ui data: %s",
error->message);
g_warning ("Could not load ui data: %s", error->message);
g_error_free (error);
g_object_unref (builder);
return NULL;

Loading…
Cancel
Save