r21273 - gnucash/branches/2.4/src/gnome-utils - [21268] Bug #612562 - Transfer Funds dialog - 'Show Income/Expense'

Geert Janssens gjanssens at code.gnucash.org
Sun Sep 18 14:09:56 EDT 2011


Author: gjanssens
Date: 2011-09-18 14:09:56 -0400 (Sun, 18 Sep 2011)
New Revision: 21273
Trac: http://svn.gnucash.org/trac/changeset/21273

Modified:
   gnucash/branches/2.4/src/gnome-utils/dialog-transfer.c
Log:
[21268] Bug #612562 - Transfer Funds dialog - 'Show Income/Expense'
checkboxes are not working
Subaccounts of income and expense are not always shown.

Modified: gnucash/branches/2.4/src/gnome-utils/dialog-transfer.c
===================================================================
--- gnucash/branches/2.4/src/gnome-utils/dialog-transfer.c	2011-09-18 18:03:36 UTC (rev 21272)
+++ gnucash/branches/2.4/src/gnome-utils/dialog-transfer.c	2011-09-18 18:09:56 UTC (rev 21273)
@@ -141,6 +141,9 @@
     gboolean show_hidden;
 } AccountTreeFilterInfo;
 
+static AccountTreeFilterInfo *from_info = NULL;
+static AccountTreeFilterInfo *to_info   = NULL;
+
 struct _acct_list_item
 {
     char *acct_full_name;
@@ -160,7 +163,7 @@
         XferDirection direction);
 void gnc_xfer_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data);
 void gnc_xfer_dialog_close_cb(GtkDialog *dialog, gpointer data);
-static gboolean gnc_xfer_dialog_show_inc_exp_visible_cb (Account *account,
+static gboolean gnc_xfer_dialog_inc_exp_filter_func (Account *account,
         gpointer data);
 
 /** Implementations **********************************************/
@@ -231,15 +234,17 @@
 static void
 gnc_xfer_dialog_toggle_cb(GtkToggleButton *button, gpointer data)
 {
-    AccountTreeFilterInfo info;
+    AccountTreeFilterInfo *info;
+    GncTreeViewAccount* treeview = GNC_TREE_VIEW_ACCOUNT (data);
 
-    info.show_inc_exp = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
-    info.show_hidden = FALSE;
+    info = g_object_get_data (G_OBJECT(treeview), "filter-info");
+    if (info)
+    {
+        info->show_inc_exp = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+        info->show_hidden = FALSE;
 
-    gnc_tree_view_account_set_filter (GNC_TREE_VIEW_ACCOUNT (data),
-                                      gnc_xfer_dialog_show_inc_exp_visible_cb,
-                                      &info,  /* user data */
-                                      NULL    /* destroy callback */);
+        gnc_tree_view_account_refilter (treeview);
+    }
 }
 
 static gboolean
@@ -461,7 +466,7 @@
 }
 
 static gboolean
-gnc_xfer_dialog_show_inc_exp_visible_cb (Account *account,
+gnc_xfer_dialog_inc_exp_filter_func (Account *account,
         gpointer data)
 {
     AccountTreeFilterInfo* info;
@@ -493,7 +498,7 @@
     GtkWidget *button;
     GtkTreeSelection *selection;
     gboolean  use_accounting_labels;
-    AccountTreeFilterInfo info;
+    AccountTreeFilterInfo *info;
 
     use_accounting_labels = gnc_gconf_get_bool(GCONF_GENERAL,
                             KEY_ACCOUNTING_LABELS, NULL);
@@ -528,17 +533,22 @@
                                               "right_trans_window" : "left_trans_window");
     }
 
+
+    if (direction == XFER_DIALOG_TO)
+        info = to_info;
+    else
+        info = from_info;
+
     tree_view = GTK_TREE_VIEW(gnc_tree_view_account_new(FALSE));
     gtk_container_add(GTK_CONTAINER(scroll_win), GTK_WIDGET(tree_view));
-    info.show_inc_exp = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
-    info.show_hidden = FALSE;
+    info->show_inc_exp = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+    info->show_hidden = FALSE;
     gnc_tree_view_account_set_filter (GNC_TREE_VIEW_ACCOUNT (tree_view),
-                                      gnc_xfer_dialog_show_inc_exp_visible_cb,
-                                      &info,  /* user data */
+                                      gnc_xfer_dialog_inc_exp_filter_func,
+                                      info,  /* user data */
                                       NULL    /* destroy callback */);
+    g_object_set_data (G_OBJECT(tree_view), "filter-info", info);
 
-    /* Have to force the filter once. Alt is to show income/expense by default. */
-    gnc_tree_view_account_refilter (GNC_TREE_VIEW_ACCOUNT (tree_view));
     gtk_widget_show(GTK_WIDGET(tree_view));
     g_signal_connect (G_OBJECT (tree_view), "key-press-event",
                       G_CALLBACK (gnc_xfer_dialog_key_press_cb), NULL);
@@ -1759,6 +1769,9 @@
         GtkWidget *label;
         gchar *text;
 
+        to_info   = g_new0(AccountTreeFilterInfo, 1);
+        from_info = g_new0(AccountTreeFilterInfo, 1);
+
         gnc_xfer_dialog_fill_tree_view (xferData, XFER_DIALOG_TO);
         gnc_xfer_dialog_fill_tree_view (xferData, XFER_DIALOG_FROM);
 
@@ -1884,6 +1897,8 @@
     gtk_widget_hide (dialog);
     gnc_xfer_dialog_close_cb(GTK_DIALOG(dialog), xferData);
     gtk_widget_destroy (dialog);
+    g_free (to_info);
+    g_free (from_info);
     LEAVE(" ");
 }
 



More information about the gnucash-changes mailing list