# HG changeset patch # User Sadrul Habib Chowdhury # Date 1184880875 0 # Node ID 36257cac2b11517ad3fed6e58100e8d964ba1cfc # Parent dba4edbde4a793f640fdaa56c313737b2e98caec Anoter patch from Javeed Shaikh to introduce a utility function for a tree. I changed it a bit, but hopefully I didn't break the patch in the process. diff -r dba4edbde4a7 -r 36257cac2b11 finch/libgnt/gnttree.c --- a/finch/libgnt/gnttree.c Thu Jul 19 21:11:37 2007 +0000 +++ b/finch/libgnt/gnttree.c Thu Jul 19 21:34:35 2007 +0000 @@ -1363,24 +1363,30 @@ return NULL; } -GList *gnt_tree_get_selection_text_list(GntTree *tree) +GList *gnt_tree_get_row_text_list(GntTree *tree, gpointer key) { GList *list = NULL, *iter; + GntTreeRow *row = key ? g_hash_table_lookup(tree->hash, key) : tree->current; int i; - if (!tree->current) + if (!row) return NULL; - for (i = 0, iter = tree->current->columns; i < tree->ncol && iter; + for (i = 0, iter = row->columns; i < tree->ncol && iter; i++, iter = iter->next) { GntTreeCol *col = iter->data; - list = g_list_append(list, g_strdup(col->text)); + list = g_list_append(list, BINARY_DATA(tree, i) ? col->text : g_strdup(col->text)); } return list; } +GList *gnt_tree_get_selection_text_list(GntTree *tree) +{ + return gnt_tree_get_row_text_list(tree, NULL); +} + void gnt_tree_remove(GntTree *tree, gpointer key) { GntTreeRow *row = g_hash_table_lookup(tree->hash, key); diff -r dba4edbde4a7 -r 36257cac2b11 finch/libgnt/gnttree.h --- a/finch/libgnt/gnttree.h Thu Jul 19 21:11:37 2007 +0000 +++ b/finch/libgnt/gnttree.h Thu Jul 19 21:34:35 2007 +0000 @@ -200,16 +200,38 @@ * @param tree The tree * * @return The text, which needs to be freed by the caller + * @see gnt_tree_get_row_text_list + * @see gnt_tree_get_selection_text_list */ char * gnt_tree_get_selection_text(GntTree *tree); /** + * Get a list of text for a row. + * + * @param tree The tree + * @param key A key corresponding to the row in question. If key + * is @c NULL, the text list for the selected row will + * be returned. + * + * @return A list of texts of a row. The list and its data should be + * freed by the caller. The caller should make sure that if + * any column of the tree contains binary data, it's not freed. + * @see gnt_tree_get_selection_text_list + * @see gnt_tree_get_selection_text + */ +GList * gnt_tree_get_row_text_list(GntTree *tree, gpointer key); + +/** * Get a list of text of the current row. * * @param tree The tree * * @return A list of texts of the currently selected row. The list - * and its data should be freed by the caller. + * and its data should be freed by the caller. The caller + * should make sure that if any column of the tree contains + * binary data, it's not freed. + * @see gnt_tree_get_row_text_list + * @see gnt_tree_get_selection_text */ GList * gnt_tree_get_selection_text_list(GntTree *tree);