[Gnucash-changes] r13086 - gnucash/trunk - Andreas Köhler's patch to allow explicit specification of which
David Hampton
hampton at cvs.gnucash.org
Fri Feb 3 01:26:51 EST 2006
Author: hampton
Date: 2006-02-03 01:26:50 -0500 (Fri, 03 Feb 2006)
New Revision: 13086
Trac: http://svn.gnucash.org/trac/changeset/13086
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/gnome-utils/gnc-tree-view.c
gnucash/trunk/src/gnome-utils/gnc-tree-view.h
gnucash/trunk/src/gnome/glade/account.glade
Log:
Andreas Köhler's patch to allow explicit specification of which
columns in a tree view expand. Updated to automatically mark a column
as expandable if it is the only visible column.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-02-03 04:38:01 UTC (rev 13085)
+++ gnucash/trunk/ChangeLog 2006-02-03 06:26:50 UTC (rev 13086)
@@ -1,5 +1,10 @@
2006-02-02 David Hampton <hampton at employees.org>
+ * src/gnome-utils/gnc-tree-view.[ch]: Andreas Köhler's patch to
+ allow explicit specification of which columns in a tree view
+ expand. Updated to automatically mark a column as expandable if
+ it is the only visible column.
+
* src/business/dialog-tax-table/dialog-tax-table.c:
* src/gnome-utils/gnc-tree-view-account.c:
* src/gnome-utils/dialog-account.c:
Modified: gnucash/trunk/src/gnome/glade/account.glade
===================================================================
--- gnucash/trunk/src/gnome/glade/account.glade 2006-02-03 04:38:01 UTC (rev 13085)
+++ gnucash/trunk/src/gnome/glade/account.glade 2006-02-03 06:26:50 UTC (rev 13086)
@@ -576,7 +576,7 @@
</widget>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
@@ -715,7 +715,7 @@
<widget class="GtkScrolledWindow" id="parent_scroll">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view.c 2006-02-03 04:38:01 UTC (rev 13085)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view.c 2006-02-03 06:26:50 UTC (rev 13086)
@@ -121,6 +121,10 @@
GtkTooltips *title_tips;
GSList *default_visible;
+ /* Spacer column */
+ GtkTreeViewColumn *spacer_column;
+ GtkTreeViewColumn *selection_column;
+
/* Column selection menu related values */
GtkTreeViewColumn *column_menu_column;
GtkWidget *column_menu;
@@ -271,6 +275,7 @@
"fixed-width", 1,
"expand", TRUE,
(gchar *)NULL);
+ priv->spacer_column = column;
/* Create the last column which contains the column selection
* widget. gnc_tree_view_add_text_column will do most of the
@@ -286,6 +291,7 @@
"widget", icon,
"fixed-width", requisition.width + 10,
(gchar *)NULL);
+ priv->selection_column = column;
g_signal_connect(G_OBJECT(column), "clicked",
G_CALLBACK (gnc_tree_view_select_column_cb),
view);
@@ -1518,6 +1524,52 @@
NULL, NULL, 0, gtk_get_current_event_time());
}
+
+void gnc_tree_view_expand_columns (GncTreeView *view,
+ gchar *first_column_name,
+ ...)
+{
+ GncTreeViewPrivate *priv;
+ GtkTreeViewColumn *column;
+ gboolean hide_spacer;
+ GList *columns, *tmp;
+ gchar *name, *pref_name;
+ va_list args;
+
+ g_return_if_fail (GNC_IS_TREE_VIEW (view));
+ ENTER(" ");
+ va_start (args, first_column_name);
+ priv = GNC_TREE_VIEW_GET_PRIVATE (view);
+ name = first_column_name;
+ hide_spacer = FALSE;
+
+ /* First disable the expand property on all (non-infrastructure) columns. */
+ columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(view));
+ for (tmp = columns; tmp; tmp = g_list_next(tmp)) {
+ column = tmp->data;
+ pref_name = g_object_get_data(G_OBJECT(column), PREF_NAME);
+ if (pref_name != NULL)
+ gtk_tree_view_column_set_expand(column, FALSE);
+ }
+ g_list_free(columns);
+
+ /* Now enable it on the requested columns. */
+ while (name != NULL) {
+ column = view_column_find_by_name (view, name);
+ if (column != NULL) {
+ gtk_tree_view_column_set_expand(column, TRUE);
+ hide_spacer = TRUE;
+ }
+ name = va_arg (args, gchar*);
+ }
+ va_end (args);
+
+ gtk_tree_view_column_set_visible (priv->spacer_column, !hide_spacer);
+ gtk_tree_view_column_set_visible (priv->selection_column, !hide_spacer);
+
+ LEAVE(" ");
+}
+
/** This function is called to set the "show-column-menu" property on
* this view. This function has no visible effect if the
* "gconf-section" property has not been set.
@@ -1611,9 +1663,11 @@
...)
{
GncTreeViewPrivate *priv;
+ GtkTreeViewColumn *column;
GSList *slist;
GList *columns;
gchar *name;
+ gboolean hide_spacer;
va_list args;
g_return_if_fail(GNC_IS_TREE_VIEW(view));
@@ -1645,6 +1699,15 @@
if (priv->gconf_section)
priv->seen_gconf_visibility = TRUE;
+
+ /* If only the first column is visible, hide the spacer and make that
+ * column expand. */
+ hide_spacer = (first_column_name == NULL);
+ column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), 0);
+ gtk_tree_view_column_set_expand(column, hide_spacer);
+ gtk_tree_view_column_set_visible(priv->spacer_column, !hide_spacer);
+ gtk_tree_view_column_set_visible(priv->selection_column, !hide_spacer);
+
LEAVE(" ");
}
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view.h 2006-02-03 04:38:01 UTC (rev 13085)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view.h 2006-02-03 06:26:50 UTC (rev 13086)
@@ -336,6 +336,10 @@
*/
const gchar *gnc_tree_view_get_gconf_section (GncTreeView *view);
+void gnc_tree_view_expand_columns (GncTreeView *view,
+ gchar *first_column_name,
+ ...);
+
/** This function is called to set the "show-column-menu" property on
* this view. This function has no visible effect if the
* "gconf-section" property has not been set.
More information about the gnucash-changes
mailing list