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
|
||||
|
48
src/tree.c
48
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,
|
||||
@ -146,7 +147,7 @@ zenity_tree_handle_stdin (GIOChannel *channel,
|
||||
if (toggles && column_count == 0) {
|
||||
if (strcmp (g_strdown (zenity_util_strip_newline (string->str)), "true") == 0)
|
||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, TRUE, -1);
|
||||
else
|
||||
else
|
||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, FALSE, -1);
|
||||
}
|
||||
else {
|
||||
@ -224,7 +225,7 @@ zenity_tree_fill_entries (GtkTreeView *tree_view,
|
||||
if (toggles && j == 0) {
|
||||
if (strcmp (g_strdown ((gchar *) args[i+j]), "true") == 0)
|
||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1);
|
||||
else
|
||||
else
|
||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1);
|
||||
}
|
||||
else
|
||||
@ -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) {
|
||||
@ -327,7 +334,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
||||
text = glade_xml_get_widget (glade_dialog, "zenity_tree_text");
|
||||
|
||||
if (tree_data->dialog_text)
|
||||
gtk_label_set_text (GTK_LABEL (text), tree_data->dialog_text);
|
||||
gtk_label_set_text (GTK_LABEL (text), tree_data->dialog_text);
|
||||
|
||||
zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-list.png"));
|
||||
|
||||
@ -392,7 +399,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
||||
g_object_set_data (G_OBJECT (model), "radio", (gint *) 1);
|
||||
}
|
||||
|
||||
g_signal_connect (cell_renderer, "toggled",
|
||||
g_signal_connect (cell_renderer, "toggled",
|
||||
G_CALLBACK (zenity_tree_toggled_callback), model);
|
||||
|
||||
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
||||
@ -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,11 +505,15 @@ 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]);
|
||||
|
||||
selected = g_slist_append (selected, g_strdup (g_value_get_string (&value)));
|
||||
g_value_unset (&value);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -510,7 +521,7 @@ 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,11 +541,15 @@ 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]);
|
||||
|
||||
selected = g_slist_append (selected, g_strdup (g_value_get_string (&value)));
|
||||
g_value_unset (&value);
|
||||
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);
|
||||
@ -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