Revision 1370ba94afc8d4c4413b3887e5f31622dd02e8be

sadrul at pidgin.im sadrul at pidgin.im
Fri Mar 30 01:33:28 EDT 2007


o   -----------------------------------------------------------------
|   Revision: 1370ba94afc8d4c4413b3887e5f31622dd02e8be
|   Ancestor: 1df24d2f7f47c7f4d296b0d684428dbefa6d943a
|   Author: sadrul at pidgin.im
|   Date: 2007-03-30T05:32:40
|   Branch: im.pidgin.pidgin
|   
|   Modified files:
|           finch/libgnt/gntbutton.c finch/libgnt/gnttree.c
|           finch/libgnt/gnttree.h
|   
|   ChangeLog: 
|   
|   Allow making some columns invisible.
|   
|   ============================================================
|   --- finch/libgnt/gntbutton.c	2e1ed3e24f0710a798a276596d5de89e599e4d96
|   +++ finch/libgnt/gntbutton.c	4d14743e020c672d9bc031daa08d67adab7b576c
|   @@ -87,8 +87,6 @@ gnt_button_init(GTypeInstance *instance,
|    	GntButton *button = GNT_BUTTON(instance);
|    	button->priv = g_new0(GntButtonPriv, 1);
|    
|   -	GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_X);
|   -
|    	widget->priv.minw = 4;
|    	widget->priv.minh = 3;
|    	GNTDEBUG;
|   ============================================================
|   --- finch/libgnt/gnttree.c	b597bc06f70382e7fbf4c2096c20a22a27ed6f81
|   +++ finch/libgnt/gnttree.c	51c46e82f4470a67b577a42df252f182ee1fffd2
|   @@ -222,6 +222,7 @@ update_row_text(GntTree *tree, GntTreeRo
|    	GString *string = g_string_new(NULL);
|    	GList *iter;
|    	int i;
|   +	gboolean notfirst = FALSE;
|    
|    	for (i = 0, iter = row->columns; i < tree->ncol && iter; i++, iter = iter->next)
|    	{
|   @@ -231,6 +232,9 @@ update_row_text(GntTree *tree, GntTreeRo
|    		int fl = 0;
|    		gboolean cut = FALSE;
|    
|   +		if (tree->columns[i].invisible)
|   +			continue;
|   +
|    		if (i == 0)
|    		{
|    			if (row->choice)
|   @@ -258,9 +262,13 @@ update_row_text(GntTree *tree, GntTreeRo
|    			}
|    			len += fl;
|    		}
|   +		else if (notfirst)
|   +			g_string_append_c(string, '|');
|    		else
|   -			g_string_append_c(string, '|');
|   +			g_string_append_c(string, ' ');
|    
|   +		notfirst = TRUE;
|   +
|    		if (len > tree->columns[i].width) {
|    			len = tree->columns[i].width - 1;
|    			cut = TRUE;
|   @@ -281,17 +289,24 @@ update_row_text(GntTree *tree, GntTreeRo
|    	return g_string_free(string, FALSE);
|    }
|    
|   +#define NEXT_X x += tree->columns[i].width + (i > 0 ? 1 : 0)
|   +
|    static void
|    tree_mark_columns(GntTree *tree, int pos, int y, chtype type)
|    {
|    	GntWidget *widget = GNT_WIDGET(tree);
|    	int i;
|    	int x = pos;
|   +	gboolean notfirst = FALSE;
|    
|    	for (i = 0; i < tree->ncol - 1; i++)
|    	{
|   -		x += tree->columns[i].width;
|   -		mvwaddch(widget->window, y, x + i, type);
|   +		if (!tree->columns[i].invisible) {
|   +			notfirst = TRUE;
|   +			NEXT_X;
|   +		}
|   +		if (!tree->columns[i+1].invisible && notfirst)
|   +			mvwaddch(widget->window, y, x, type);
|    	}
|    }
|    
|   @@ -327,11 +342,16 @@ redraw_tree(GntTree *tree)
|    
|    		mvwhline(widget->window, pos + 1, pos, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL),
|    				widget->priv.width - pos - 1);
|   -		
|   +		mvwhline(widget->window, pos, pos, ' ' | COLOR_PAIR(GNT_COLOR_NORMAL),
|   +				widget->priv.width - pos - 1);
|   +
|    		for (i = 0; i < tree->ncol; i++)
|    		{
|   -			mvwaddstr(widget->window, pos, x + i, tree->columns[i].title);
|   -			x += tree->columns[i].width;
|   +			if (tree->columns[i].invisible) {
|   +				continue;
|   +			}
|   +			mvwaddstr(widget->window, pos, x + 1, tree->columns[i].title);
|   +			NEXT_X;
|    		}
|    		if (pos)
|    		{
|   @@ -491,8 +511,9 @@ gnt_tree_size_request(GntWidget *widget)
|    		GntTree *tree = GNT_TREE(widget);
|    		int i, width = 0;
|    		for (i = 0; i < tree->ncol; i++)
|   -			width += tree->columns[i].width;
|   -		widget->priv.width = width + i;
|   +			if (!tree->columns[i].invisible)
|   +				width += tree->columns[i].width + 1;
|   +		widget->priv.width = width;
|    	}
|    }
|    
|   @@ -1484,7 +1505,8 @@ void gnt_tree_adjust_columns(GntTree *tr
|    	twidth = 1 + 2 * (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER));
|    	for (i = 0; i < tree->ncol; i++) {
|    		gnt_tree_set_col_width(tree, i, widths[i]);
|   -		twidth += widths[i] + (tree->show_separator ? 1 : 0) + 1;
|   +		if (!tree->columns[i].invisible)
|   +			twidth += widths[i] + (tree->show_separator ? 1 : 0) + 1;
|    	}
|    	g_free(widths);
|    
|   @@ -1499,3 +1521,9 @@ void gnt_tree_set_hash_fns(GntTree *tree
|    	tree->hash = g_hash_table_new_full(hash, eq, kd, free_tree_row);
|    }
|    
|   +void gnt_tree_set_column_visible(GntTree *tree, int col, gboolean vis)
|   +{
|   +	g_return_if_fail(col < tree->ncol);
|   +	tree->columns[col].invisible = !vis;
|   +}
|   +
|   ============================================================
|   --- finch/libgnt/gnttree.h	eaadb3047ebef4d84308ece63d87509985a16727
|   +++ finch/libgnt/gnttree.h	d634cf7a4282e66c7aa5e8fad0cd9e05c79a676f
|   @@ -48,6 +48,7 @@ struct _GntTree
|    	{
|    		int width;
|    		char *title;
|   +		gboolean invisible;
|    	} *columns;             /* Would a GList be better? */
|    	gboolean show_title;
|    	gboolean show_separator; /* Whether to show column separators */
|   @@ -140,6 +141,10 @@ void gnt_tree_set_hash_fns(GntTree *tree
|    
|    void gnt_tree_set_hash_fns(GntTree *tree, gpointer hash, gpointer eq, gpointer kd);
|    
|   +/* This can be useful when, for example, we want to store some data
|   + * which we don't want/need to display. */
|   +void gnt_tree_set_column_visible(GntTree *tree, int col, gboolean vis);
|   +
|    G_END_DECLS
|    
|    /* The following functions should NOT be used by applications. */

To get the patch for this revision, please do this:
mtn log --last 1 --diffs --from 1370ba94afc8d4c4413b3887e5f31622dd02e8be


More information about the Commits mailing list