From 9c792cb86a8d0422a07a716a3b024f25d9bca1bb Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Mon, 27 Jun 2005 03:13:37 +0000 Subject: Changed list dialog Selection behavior --- src/option.c | 26 ++++++++++++++++++-------- src/tree.c | 13 +++++++++++-- src/zenity.h | 1 + 3 files changed, 30 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 33a185f5..a1674883 100644 --- a/src/option.c +++ b/src/option.c @@ -32,6 +32,7 @@ int zenity_general_width; int zenity_general_height; gchar *zenity_general_dialog_text; gchar *zenity_general_separator; +gboolean zenity_general_multiple; gboolean zenity_general_editable; gchar *zenity_general_uri; gboolean zenity_general_dialog_no_wrap; @@ -56,7 +57,6 @@ gboolean zenity_info_active; /* File Selection Dialog Options */ gboolean zenity_file_active; -gboolean zenity_file_multiple; gboolean zenity_file_directory; gboolean zenity_file_save; @@ -325,7 +325,7 @@ GOptionEntry file_selection_options[] = { '\0', 0, G_OPTION_ARG_NONE, - &zenity_file_multiple, + &zenity_general_multiple, N_("Allow multiple files to be selected"), NULL }, @@ -416,6 +416,15 @@ GOptionEntry list_options[] = { N_("Set output separator character"), N_("SEPARATOR") }, + { + "multiple", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_general_multiple, + N_("Allow multiple rows to be selected"), + NULL + }, { "editable", '\0', @@ -740,6 +749,7 @@ zenity_general_pre_callback (GOptionContext *context, zenity_general_height = -1; zenity_general_dialog_text = NULL; zenity_general_separator = g_strdup ("|"); + zenity_general_multiple = FALSE; zenity_general_editable = FALSE; zenity_general_uri = NULL; zenity_general_dialog_no_wrap = FALSE; @@ -804,7 +814,6 @@ zenity_file_pre_callback (GOptionContext *context, GError **error) { zenity_file_active = FALSE; - zenity_file_multiple = FALSE; zenity_file_directory = FALSE; zenity_file_save = FALSE; @@ -1037,15 +1046,11 @@ zenity_file_post_callback (GOptionContext *context, if (results->mode == MODE_FILE) { results->file_data->uri = zenity_general_uri; - results->file_data->multi = zenity_file_multiple; + results->file_data->multi = zenity_general_multiple; 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_multiple) - zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_multiple), - ERROR_SUPPORT); - if (zenity_file_directory) zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_directory), ERROR_SUPPORT); @@ -1082,6 +1087,7 @@ zenity_list_post_callback (GOptionContext *context, results->tree_data->checkbox = zenity_list_checklist; results->tree_data->radiobox = zenity_list_radiolist; + results->tree_data->multi = zenity_general_multiple; results->tree_data->editable = zenity_general_editable; results->tree_data->print_column = zenity_list_print_column; results->tree_data->separator = zenity_general_separator; @@ -1411,6 +1417,10 @@ zenity_option_parse (gint argc, gchar **argv) if (results->mode != MODE_LIST && results->mode != MODE_FILE) zenity_option_error (zenity_option_get_name (list_options, &zenity_general_separator), ERROR_SUPPORT); + 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); + 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); diff --git a/src/tree.c b/src/tree.c index b50a755b..e60e262f 100644 --- a/src/tree.c +++ b/src/tree.c @@ -354,8 +354,17 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); - gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), - GTK_SELECTION_MULTIPLE); + if (!(tree_data->radiobox || tree_data->checkbox)) { + if (tree_data->multi) + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), + GTK_SELECTION_MULTIPLE); + else + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), + GTK_SELECTION_SINGLE); + } + else + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), + GTK_SELECTION_NONE); column_index = 0; diff --git a/src/zenity.h b/src/zenity.h index 7ab47cb4..0e1dba1b 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -94,6 +94,7 @@ typedef struct { gboolean checkbox; gboolean radiobox; gchar *separator; + gboolean multi; gboolean editable; gchar *print_column; const gchar **data; -- cgit