r22278 - gnucash/trunk/src/gnome - Double click on parent account expands/collapses child account list

Geert Janssens gjanssens at code.gnucash.org
Thu Aug 2 09:31:57 EDT 2012


Author: gjanssens
Date: 2012-08-02 09:31:57 -0400 (Thu, 02 Aug 2012)
New Revision: 22278
Trac: http://svn.gnucash.org/trac/changeset/22278

Modified:
   gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c
Log:
Double click on parent account expands/collapses child account list
instead of opening the account's register. The account's register can
still be opened normally using the menu option or right-click popup
menu.

Modified: gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c	2012-08-01 13:54:32 UTC (rev 22277)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c	2012-08-02 13:31:57 UTC (rev 22278)
@@ -777,15 +777,35 @@
 
 static void
 gnc_plugin_page_account_tree_double_click_cb (GtkTreeView        *treeview,
-        GtkTreePath        *path,
-        GtkTreeViewColumn  *col,
-        GncPluginPageAccountTree *page)
+                                              GtkTreePath        *path,
+                                              GtkTreeViewColumn  *col,
+                                              GncPluginPageAccountTree *page)
 {
-    Account *account;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
 
     g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (page));
-    account = gnc_tree_view_account_get_account_from_path (GNC_TREE_VIEW_ACCOUNT(treeview), path);
-    gppat_open_account_common (page, account, FALSE);
+    g_return_if_fail (treeview);
+
+    model = gtk_tree_view_get_model(treeview);
+    if (gtk_tree_model_get_iter(model, &iter, path))
+    {
+        if (gtk_tree_model_iter_has_child(model, &iter))
+        {
+            /* There are children,
+             * just expand or collapse the row. */
+            if (gtk_tree_view_row_expanded(treeview, path))
+                gtk_tree_view_collapse_row(treeview, path);
+            else
+                gtk_tree_view_expand_row(treeview, path, FALSE);
+        }
+        else
+        {
+            /* It's an account without any children, so open its register */
+            Account *account = gnc_tree_view_account_get_account_from_path (GNC_TREE_VIEW_ACCOUNT(treeview), path);
+            gppat_open_account_common (page, account, FALSE);
+        }
+    }
 }
 
 static void



More information about the gnucash-changes mailing list