New --hide-column option.
This commit is contained in:
parent
da0a2585b3
commit
8ba040f33b
@ -1,3 +1,9 @@
|
|||||||
|
2005-07-01 Lucas Rocha <lucasr@cvs.gnome.org>
|
||||||
|
|
||||||
|
* src/tree.c, src/option.c, src/zenity.h: new
|
||||||
|
--hide-column option. Uses the same syntax of
|
||||||
|
--print-column option.
|
||||||
|
|
||||||
2005-06-30 Lucas Rocha <lucasr@cvs.gnome.org>
|
2005-06-30 Lucas Rocha <lucasr@cvs.gnome.org>
|
||||||
|
|
||||||
* src/tree.c: some data structure improvements.
|
* src/tree.c: some data structure improvements.
|
||||||
|
18
src/option.c
18
src/option.c
@ -66,6 +66,7 @@ gchar **zenity_list_columns;
|
|||||||
gboolean zenity_list_checklist;
|
gboolean zenity_list_checklist;
|
||||||
gboolean zenity_list_radiolist;
|
gboolean zenity_list_radiolist;
|
||||||
gchar *zenity_list_print_column;
|
gchar *zenity_list_print_column;
|
||||||
|
gchar *zenity_list_hide_column;
|
||||||
|
|
||||||
/* Notification Dialog Options */
|
/* Notification Dialog Options */
|
||||||
gboolean zenity_notification_active;
|
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)"),
|
N_("Print a specific column (Default is 1. 'ALL' can be used to print all columns)"),
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"hide-column",
|
||||||
|
'\0',
|
||||||
|
0,
|
||||||
|
G_OPTION_ARG_STRING,
|
||||||
|
&zenity_list_hide_column,
|
||||||
|
N_("Hide a specific column"),
|
||||||
|
NULL
|
||||||
|
},
|
||||||
{
|
{
|
||||||
NULL
|
NULL
|
||||||
}
|
}
|
||||||
@ -699,6 +709,8 @@ zenity_option_free (void) {
|
|||||||
g_strfreev (zenity_list_columns);
|
g_strfreev (zenity_list_columns);
|
||||||
if (zenity_list_print_column)
|
if (zenity_list_print_column)
|
||||||
g_free (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);
|
g_option_context_free (ctx);
|
||||||
}
|
}
|
||||||
@ -831,6 +843,7 @@ zenity_list_pre_callback (GOptionContext *context,
|
|||||||
zenity_list_checklist = FALSE;
|
zenity_list_checklist = FALSE;
|
||||||
zenity_list_radiolist = FALSE;
|
zenity_list_radiolist = FALSE;
|
||||||
zenity_list_print_column = NULL;
|
zenity_list_print_column = NULL;
|
||||||
|
zenity_list_hide_column = NULL;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1090,6 +1103,7 @@ zenity_list_post_callback (GOptionContext *context,
|
|||||||
results->tree_data->multi = zenity_general_multiple;
|
results->tree_data->multi = zenity_general_multiple;
|
||||||
results->tree_data->editable = zenity_general_editable;
|
results->tree_data->editable = zenity_general_editable;
|
||||||
results->tree_data->print_column = zenity_list_print_column;
|
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;
|
results->tree_data->separator = zenity_general_separator;
|
||||||
} else {
|
} else {
|
||||||
if (zenity_list_columns)
|
if (zenity_list_columns)
|
||||||
@ -1107,6 +1121,10 @@ zenity_list_post_callback (GOptionContext *context,
|
|||||||
if (zenity_list_print_column)
|
if (zenity_list_print_column)
|
||||||
zenity_option_error (zenity_option_get_name (list_options, &zenity_list_print_column),
|
zenity_option_error (zenity_option_get_name (list_options, &zenity_list_print_column),
|
||||||
ERROR_SUPPORT);
|
ERROR_SUPPORT);
|
||||||
|
|
||||||
|
if (zenity_list_hide_column)
|
||||||
|
zenity_option_error (zenity_option_get_name (list_options, &zenity_list_hide_column),
|
||||||
|
ERROR_SUPPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
38
src/tree.c
38
src/tree.c
@ -37,8 +37,10 @@ static GSList *selected;
|
|||||||
static gchar *separator;
|
static gchar *separator;
|
||||||
static gboolean print_all_columns = FALSE;
|
static gboolean print_all_columns = FALSE;
|
||||||
static gint *print_columns = NULL;
|
static gint *print_columns = NULL;
|
||||||
|
static gint *hide_columns = NULL;
|
||||||
|
|
||||||
static int *zenity_tree_extract_column_indexes (char *indexes, gint n_columns);
|
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_dialog_response (GtkWidget *widget, int response, gpointer data);
|
||||||
static void zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path,
|
static void zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path,
|
||||||
GtkTreeViewColumn *tree_col, gpointer data);
|
GtkTreeViewColumn *tree_col, gpointer data);
|
||||||
@ -309,6 +311,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
|||||||
print_columns[1] = 0;
|
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) {
|
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);
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
||||||
@ -421,17 +426,19 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
|||||||
"text", column_index,
|
"text", column_index,
|
||||||
"editable", n_columns,
|
"editable", n_columns,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
||||||
gtk_cell_renderer_text_new (),
|
gtk_cell_renderer_text_new (),
|
||||||
"text", column_index,
|
"text", column_index,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_tree_view_column_set_sort_column_id (column, column_index);
|
gtk_tree_view_column_set_sort_column_id (column, column_index);
|
||||||
gtk_tree_view_column_set_resizable (column, TRUE);
|
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;
|
first_column = TRUE;
|
||||||
}
|
}
|
||||||
@ -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_sort_column_id (column, column_index);
|
||||||
gtk_tree_view_column_set_resizable (column, TRUE);
|
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);
|
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 (print_columns);
|
||||||
|
g_free (hide_columns);
|
||||||
g_free (separator);
|
g_free (separator);
|
||||||
g_slist_foreach (selected, (GFunc) g_free, NULL);
|
g_slist_foreach (selected, (GFunc) g_free, NULL);
|
||||||
selected = NULL;
|
selected = NULL;
|
||||||
@ -627,6 +638,19 @@ zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path,
|
|||||||
gtk_main_quit ();
|
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 *
|
static gint *
|
||||||
zenity_tree_extract_column_indexes (char *indexes, int n_columns)
|
zenity_tree_extract_column_indexes (char *indexes, int n_columns)
|
||||||
{
|
{
|
||||||
|
@ -97,6 +97,7 @@ typedef struct {
|
|||||||
gboolean multi;
|
gboolean multi;
|
||||||
gboolean editable;
|
gboolean editable;
|
||||||
gchar *print_column;
|
gchar *print_column;
|
||||||
|
gchar *hide_column;
|
||||||
const gchar **data;
|
const gchar **data;
|
||||||
} ZenityTreeData;
|
} ZenityTreeData;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user