New --print-column syntax. Now it's possible to pass a comma-separated list of column indexes.
This commit is contained in:
parent
cc3fc2be3e
commit
c9be8d0579
@ -1,3 +1,9 @@
|
||||
2005-06-28 Lucas Rocha <lucasr@cvs.gnome.org>
|
||||
|
||||
* src/tree.c: new --print-column option syntax.
|
||||
Now it's possible to pass a comma-separated list
|
||||
of column indexes (i.e. --print-column=1,3,4)
|
||||
|
||||
2005-06-28 Lucas Rocha <lucasr@cvs.gnome.org>
|
||||
|
||||
* src/tree.c: error handling when trying to
|
||||
|
32
src/tree.c
32
src/tree.c
@ -30,12 +30,13 @@
|
||||
#include "util.h"
|
||||
|
||||
#define MAX_ELEMENTS_BEFORE_SCROLLING 5
|
||||
#define PRINT_HIDE_COLUMN_SEPARATOR ","
|
||||
|
||||
static GladeXML *glade_dialog;
|
||||
static GSList *selected;
|
||||
static gchar *separator;
|
||||
static gboolean print_all_columns = FALSE;
|
||||
static gint print_column_n = 1;
|
||||
static char **print_columns = NULL;
|
||||
|
||||
static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data);
|
||||
static void zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path,
|
||||
@ -299,7 +300,13 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
||||
if (strcmp (g_strdown (tree_data->print_column), "all") == 0)
|
||||
print_all_columns = TRUE;
|
||||
else
|
||||
print_column_n = atoi (tree_data->print_column);
|
||||
print_columns = g_strsplit (tree_data->print_column,
|
||||
PRINT_HIDE_COLUMN_SEPARATOR, 0);
|
||||
}
|
||||
else {
|
||||
print_columns = (char **) g_new (char**, 2);
|
||||
print_columns[0] = g_strdup ("1");
|
||||
print_columns[1] = NULL;
|
||||
}
|
||||
|
||||
if (n_columns == 0) {
|
||||
@ -484,7 +491,7 @@ static void
|
||||
zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view)
|
||||
{
|
||||
GValue value = {0, };
|
||||
gint n_columns, i;
|
||||
gint n_columns, print_column, i;
|
||||
|
||||
n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns"));
|
||||
|
||||
@ -498,19 +505,23 @@ zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, Gtk
|
||||
return;
|
||||
}
|
||||
|
||||
if (print_column_n > 0 && print_column_n <= n_columns) {
|
||||
gtk_tree_model_get_value (model, iter, print_column_n - 1, &value);
|
||||
for (i = 0; print_columns[i] != NULL; i++) {
|
||||
print_column = atoi (print_columns[i]);
|
||||
|
||||
if (print_column > 0 && print_column <= n_columns) {
|
||||
gtk_tree_model_get_value (model, iter, print_column - 1, &value);
|
||||
|
||||
selected = g_slist_append (selected, g_strdup (g_value_get_string (&value)));
|
||||
g_value_unset (&value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GtkTreeView *tree_view)
|
||||
{
|
||||
GValue toggle_value = {0, };
|
||||
gint n_columns, i;
|
||||
gint n_columns, print_column, i;
|
||||
|
||||
n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns"));
|
||||
|
||||
@ -530,13 +541,17 @@ zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (print_column_n > 0 && print_column_n <= n_columns) {
|
||||
gtk_tree_model_get_value (model, iter, print_column_n, &value);
|
||||
for (i = 0; print_columns[i] != NULL; i++) {
|
||||
print_column = atoi (print_columns[i]);
|
||||
|
||||
if (print_column > 0 && print_column <= n_columns) {
|
||||
gtk_tree_model_get_value (model, iter, print_column, &value);
|
||||
|
||||
selected = g_slist_append (selected, g_strdup (g_value_get_string (&value)));
|
||||
g_value_unset (&value);
|
||||
}
|
||||
}
|
||||
}
|
||||
g_value_unset (&toggle_value);
|
||||
return FALSE;
|
||||
}
|
||||
@ -554,6 +569,7 @@ zenity_tree_dialog_output (void)
|
||||
g_print ("%s\n", (gchar *) tmp->data);
|
||||
}
|
||||
|
||||
g_strfreev (print_columns);
|
||||
g_free (separator);
|
||||
g_slist_foreach (selected, (GFunc) g_free, NULL);
|
||||
selected = NULL;
|
||||
|
Reference in New Issue
Block a user