diff options
author | Lucas Almeida Rocha <lucasr@src.gnome.org> | 2005-07-01 21:28:36 +0000 |
---|---|---|
committer | Lucas Almeida Rocha <lucasr@src.gnome.org> | 2005-07-01 21:28:36 +0000 |
commit | 8ba040f33b37ef92976b75be79a1a342bceb91f9 (patch) | |
tree | 2e01ab7b8463e0a3324bba856397f0318a05c862 /src | |
parent | Data structure improvements on List dialogs. (diff) | |
download | zenity-8ba040f33b37ef92976b75be79a1a342bceb91f9.tar.gz zenity-8ba040f33b37ef92976b75be79a1a342bceb91f9.tar.bz2 zenity-8ba040f33b37ef92976b75be79a1a342bceb91f9.zip |
New --hide-column option.
Diffstat (limited to 'src')
-rw-r--r-- | src/option.c | 18 | ||||
-rw-r--r-- | src/tree.c | 40 | ||||
-rw-r--r-- | src/zenity.h | 1 |
3 files changed, 51 insertions, 8 deletions
diff --git a/src/option.c b/src/option.c index a1674883..b4d35bca 100644 --- a/src/option.c +++ b/src/option.c @@ -66,6 +66,7 @@ gchar **zenity_list_columns; gboolean zenity_list_checklist; gboolean zenity_list_radiolist; gchar *zenity_list_print_column; +gchar *zenity_list_hide_column; /* Notification Dialog Options */ gboolean zenity_notification_active; @@ -443,6 +444,15 @@ GOptionEntry list_options[] = { N_("Print a specific column (Default is 1. 'ALL' can be used to print all columns)"), NULL }, + { + "hide-column", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_list_hide_column, + N_("Hide a specific column"), + NULL + }, { NULL } @@ -699,6 +709,8 @@ zenity_option_free (void) { 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_option_context_free (ctx); } @@ -831,6 +843,7 @@ zenity_list_pre_callback (GOptionContext *context, zenity_list_checklist = FALSE; zenity_list_radiolist = FALSE; zenity_list_print_column = NULL; + zenity_list_hide_column = NULL; return TRUE; } @@ -1090,6 +1103,7 @@ zenity_list_post_callback (GOptionContext *context, 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->hide_column = zenity_list_hide_column; results->tree_data->separator = zenity_general_separator; } else { if (zenity_list_columns) @@ -1107,6 +1121,10 @@ zenity_list_post_callback (GOptionContext *context, if (zenity_list_print_column) zenity_option_error (zenity_option_get_name (list_options, &zenity_list_print_column), ERROR_SUPPORT); + + if (zenity_list_hide_column) + zenity_option_error (zenity_option_get_name (list_options, &zenity_list_hide_column), + ERROR_SUPPORT); } return TRUE; @@ -37,8 +37,10 @@ static GSList *selected; static gchar *separator; static gboolean print_all_columns = FALSE; static gint *print_columns = NULL; +static gint *hide_columns = NULL; static int *zenity_tree_extract_column_indexes (char *indexes, gint n_columns); +static gboolean zenity_tree_column_is_hidden (gint column_index); static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data); static void zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, GtkTreeViewColumn *tree_col, gpointer data); @@ -309,6 +311,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) print_columns[1] = 0; } + if (tree_data->hide_column) + hide_columns = zenity_tree_extract_column_indexes (tree_data->hide_column, n_columns); + if (n_columns == 0) { g_printerr (_("No column titles specified for List dialog.\n")); data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); @@ -421,18 +426,20 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) "text", column_index, "editable", n_columns, NULL); - } - else { - column = gtk_tree_view_column_new_with_attributes (tmp->data, - gtk_cell_renderer_text_new (), - "text", column_index, - NULL); - } + } + else { + column = gtk_tree_view_column_new_with_attributes (tmp->data, + gtk_cell_renderer_text_new (), + "text", column_index, + NULL); + } gtk_tree_view_column_set_sort_column_id (column, column_index); gtk_tree_view_column_set_resizable (column, TRUE); } - + if (zenity_tree_column_is_hidden (1)) + gtk_tree_view_column_set_visible (column, FALSE); + first_column = TRUE; } else { @@ -459,6 +466,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_tree_view_column_set_sort_column_id (column, column_index); gtk_tree_view_column_set_resizable (column, TRUE); + + if (zenity_tree_column_is_hidden (column_index + 1)) + gtk_tree_view_column_set_visible (column, FALSE); } gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); @@ -564,6 +574,7 @@ zenity_tree_dialog_output (void) } g_free (print_columns); + g_free (hide_columns); g_free (separator); g_slist_foreach (selected, (GFunc) g_free, NULL); selected = NULL; @@ -627,6 +638,19 @@ zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, gtk_main_quit (); } +static gboolean +zenity_tree_column_is_hidden (gint column_index) +{ + gint i; + + if (hide_columns != NULL) + for (i = 0; hide_columns[i] != 0; i++) + if (hide_columns[i] == column_index) + return TRUE; + + return FALSE; +} + static gint * zenity_tree_extract_column_indexes (char *indexes, int n_columns) { diff --git a/src/zenity.h b/src/zenity.h index 0e1dba1b..b224abd9 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -97,6 +97,7 @@ typedef struct { gboolean multi; gboolean editable; gchar *print_column; + gchar *hide_column; const gchar **data; } ZenityTreeData; |