[Gnucash-changes] r12205 - gnucash/trunk - Migrate the account page
options to a new "Filter By" dialog. Add a
David Hampton
hampton at cvs.gnucash.org
Fri Dec 30 01:25:04 EST 2005
Author: hampton
Date: 2005-12-30 01:25:03 -0500 (Fri, 30 Dec 2005)
New Revision: 12205
Trac: http://svn.gnucash.org/trac/changeset/12205
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/gnome/glade/account.glade
gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c
gnucash/trunk/src/gnome/ui/gnc-plugin-page-account-tree-ui.xml
gnucash/trunk/src/scm/main-window.scm
gnucash/trunk/src/scm/main.scm
Log:
Migrate the account page options to a new "Filter By" dialog. Add a
new option to filter out accounts with zero total balances. Remember
the current filter state across invocations of GnuCash.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2005-12-30 05:07:14 UTC (rev 12204)
+++ gnucash/trunk/ChangeLog 2005-12-30 06:25:03 UTC (rev 12205)
@@ -1,5 +1,14 @@
2005-12-29 David Hampton <hampton at employees.org>
+ * src/scm/main.scm:
+ * src/scm/main-window.scm:
+ * src/gnome/gnc-plugin-page-account-tree.c:
+ * src/gnome/glade/account.glade:
+ * src/gnome/ui/gnc-plugin-page-account-tree-ui.xml: Migrate the
+ account page options to a new "Filter By" dialog. Add a new
+ option to filter out accounts with zero total balances. Remember
+ the current filter state across invocations of GnuCash.
+
* src/gnome-utils/ui/gnc-main-window-ui.xml:
* src/gnome-utils/gnc-main-window.c:
* src/gnome/ui/gnc-plugin-page-register-ui.xml: Move the "Sort By"
Modified: gnucash/trunk/src/gnome/glade/account.glade
===================================================================
--- gnucash/trunk/src/gnome/glade/account.glade 2005-12-30 05:07:14 UTC (rev 12204)
+++ gnucash/trunk/src/gnome/glade/account.glade 2005-12-30 06:25:03 UTC (rev 12205)
@@ -2935,4 +2935,255 @@
</child>
</widget>
+<widget class="GtkDialog" id="Filter By">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Filter By...</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="has_separator">True</property>
+ <signal name="response" handler="gppat_filter_response_cb" last_modification_time="Fri, 30 Dec 2005 01:57:50 GMT"/>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox13">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area13">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="cancelbutton1">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="okbutton1">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-5</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkNotebook" id="notebook1">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="show_tabs">True</property>
+ <property name="show_border">True</property>
+ <property name="tab_pos">GTK_POS_TOP</property>
+ <property name="scrollable">False</property>
+ <property name="enable_popup">False</property>
+
+ <child>
+ <widget class="GtkTable" id="table10">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+
+ <child>
+ <widget class="GtkTreeView" id="types_tree_view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
+ <property name="hover_selection">False</property>
+ <property name="hover_expand">False</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVButtonBox" id="vbuttonbox1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkButton" id="select_all">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Select All</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="gppat_filter_select_all_cb" last_modification_time="Fri, 30 Dec 2005 01:59:01 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="clear_all">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">C_lear All</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="gppat_filter_clear_all_cb" last_modification_time="Fri, 30 Dec 2005 01:59:18 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="default_types">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Default</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="gppat_filter_select_default_cb" last_modification_time="Fri, 30 Dec 2005 02:12:27 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="tab_expand">False</property>
+ <property name="tab_fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label8477430">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Account Type</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox129">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="hide_zero">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Hide accounts which have a zero total value.</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Hide _zero totals</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="gppat_filter_hide_zero_toggled_cb" last_modification_time="Fri, 30 Dec 2005 01:58:04 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <placeholder/>
+ </child>
+
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="tab_expand">False</property>
+ <property name="tab_fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="Balance">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Balances</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
</glade-interface>
Modified: gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c 2005-12-30 05:07:14 UTC (rev 12204)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c 2005-12-30 06:25:03 UTC (rev 12205)
@@ -45,7 +45,6 @@
#include "Scrub.h"
#include "Transaction.h"
#include "dialog-account.h"
-#include "dialog-options.h"
#include "dialog-transfer.h"
#include "dialog-utils.h"
#include "druid-merge.h"
@@ -59,10 +58,10 @@
#include "gnc-session.h"
#include "gnc-split-reg.h"
#include "gnc-tree-view-account.h"
+#include "gnc-tree-model-account-types.h"
#include "gnc-ui.h"
#include "gnc-ui-util.h"
#include "lot-viewer.h"
-#include "option-util.h"
#include "window-reconcile.h"
#include "window-main-summarybar.h"
@@ -72,6 +71,8 @@
#define PLUGIN_PAGE_ACCT_TREE_CM_CLASS "plugin-page-acct-tree"
#define GCONF_SECTION "window/pages/account_tree"
+#define FILTER_TREE_VIEW "types_tree_view"
+
enum {
ACCOUNT_SELECTED,
LAST_SIGNAL
@@ -79,16 +80,20 @@
typedef struct GncPluginPageAccountTreePrivate
{
- GtkWidget *widget;
+ GtkWidget *widget;
GtkTreeView *tree_view;
+ gint component_id;
- GNCOptionDB * odb;
- SCM options;
- int options_id;
- GNCOptionWin * editor_dialog;
+ struct {
+ GtkWidget *dialog;
+ GtkTreeModel *model;
+ guint32 visible_types;
+ guint32 original_visible_types;
+ gboolean hide_zero_total;
+ gboolean original_hide_zero_total;
+ gulong selection_changed_cb_id;
+ } fd;
- GtkWidget *options_db;
- gint component_id;
} GncPluginPageAccountTreePrivate;
#define GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(o) \
@@ -123,6 +128,15 @@
void gppat_populate_tmas_list(GtkToggleButton *dmrb, gpointer tmas);
void gppat_set_insensitive_iff_rb_active(GtkToggleButton *b, GtkWidget *widget);
+/* "Filter By" dialog callbacks */
+gboolean gnc_plugin_page_account_tree_filter_accounts(Account *account, gpointer user_data);
+void gppat_filter_hide_zero_toggled_cb (GtkToggleButton *togglebutton, GncPluginPageAccountTree *page);
+void gppat_filter_clear_all_cb (GtkWidget *button, GncPluginPageAccountTree *page);
+void gppat_filter_select_all_cb (GtkWidget *button, GncPluginPageAccountTree *page);
+void gppat_filter_select_default_cb (GtkWidget *button, GncPluginPageAccountTree *page);
+void gppat_filter_response_cb (GtkWidget *dialog, gint response, GncPluginPageAccountTree *page);
+
+
/* Command callbacks */
static void gnc_plugin_page_account_tree_cmd_new_account (GtkAction *action, GncPluginPageAccountTree *plugin_page);
static void gnc_plugin_page_account_tree_cmd_file_hierarchy_merge (GtkAction *action, GncPluginPageAccountTree *plugin_page);
@@ -130,7 +144,7 @@
static void gnc_plugin_page_account_tree_cmd_open_subaccounts (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_edit_account (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_delete_account (GtkAction *action, GncPluginPageAccountTree *page);
-static void gnc_plugin_page_account_tree_cmd_view_options (GtkAction *action, GncPluginPageAccountTree *page);
+static void gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action, GncPluginPageAccountTree *plugin_page);
static void gnc_plugin_page_account_tree_cmd_reconcile (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_transfer (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_stock_split (GtkAction *action, GncPluginPageAccountTree *page);
@@ -140,9 +154,6 @@
static void gnc_plugin_page_account_tree_cmd_scrub_all (GtkAction *action, GncPluginPageAccountTree *page);
-static void gnc_plugin_page_acct_tree_options_new(GncPluginPageAccountTreePrivate *priv);
-
-
static guint plugin_page_signals[LAST_SIGNAL] = { 0 };
@@ -171,10 +182,11 @@
{ "EditDeleteAccountAction", GNC_STOCK_DELETE_ACCOUNT, N_("_Delete Account..."), NULL,
N_("Delete selected account"),
G_CALLBACK (gnc_plugin_page_account_tree_cmd_delete_account) },
- { "EditAccountViewOptionsAction", GTK_STOCK_PROPERTIES, N_("Account Tree _Options..."), NULL,
- N_("Edit the account view options"),
- G_CALLBACK (gnc_plugin_page_account_tree_cmd_view_options) },
+ /* View menu */
+ { "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL,
+ G_CALLBACK (gnc_plugin_page_account_tree_cmd_view_filter_by) },
+
/* Actions menu */
{ "ActionsReconcileAction", NULL, N_("_Reconcile..."), NULL,
N_("Reconcile the selected account"),
@@ -198,12 +210,6 @@
{ "ScrubAllAction", NULL, N_("Check & Repair A_ll"), NULL,
N_("Check for and repair unbalanced transactions and orphan splits " "in all accounts"),
G_CALLBACK (gnc_plugin_page_account_tree_cmd_scrub_all) },
-
- /* Popup menu */
-
- { "PopupOptionsAction", GTK_STOCK_PROPERTIES, N_("_Options"), NULL,
- N_("Edit the account view options"),
- G_CALLBACK (gnc_plugin_page_account_tree_cmd_view_options) },
};
/** The number of actions provided by this plugin. */
static guint gnc_plugin_page_account_tree_n_actions = G_N_ELEMENTS (gnc_plugin_page_account_tree_actions);
@@ -226,7 +232,6 @@
static action_toolbar_labels toolbar_labels[] = {
{ "FileOpenAccountAction", N_("Open") },
{ "EditEditAccountAction", N_("Edit") },
- { "EditAccountViewOptionsAction", N_("Options") },
{ "FileNewAccountAction", N_("New") },
{ "EditDeleteAccountAction", N_("Delete") },
{ NULL, NULL },
@@ -308,11 +313,6 @@
GtkActionGroup *action_group;
GncPluginPageAccountTreePrivate *priv;
GncPluginPage *parent;
- const gchar *url = NULL;
- int options_id;
- SCM find_options;
- SCM temp;
- URLType type;
ENTER("page %p", plugin_page);
priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(plugin_page);
@@ -338,47 +338,10 @@
plugin_page);
gnc_plugin_init_short_names (action_group, toolbar_labels);
+ /* Visisble types */
+ priv->fd.visible_types = -1; /* Start with all types */
+ priv->fd.hide_zero_total = FALSE;
- /* get the options and the window ID */
- priv->options = SCM_BOOL_F;
- scm_gc_protect_object(priv->options);
- priv->editor_dialog = NULL;
-
- if(!url) {
- gnc_plugin_page_acct_tree_options_new(priv);
- } else {
- char * location = NULL;
- char * label = NULL;
-
- /* if an URL is specified, it should look like
- * gnc-acct-tree:id=17 . We want to get the number out,
- * then look up the options in the global DB. */
- type = gnc_html_parse_url(NULL, url, &location, &label);
- if (!safe_strcmp (type, URL_TYPE_ACCTTREE) &&
- location && (strlen(location) > 3) &&
- !strncmp("id=", location, 3)) {
- sscanf(location+3, "%d", &options_id);
- find_options = scm_c_eval_string("gnc:find-acct-tree-window-options");
- temp = scm_call_1(find_options, scm_int2num(options_id));
-
- if(temp != SCM_BOOL_F) {
- scm_gc_unprotect_object(priv->options);
- priv->options = temp;
- scm_gc_protect_object(priv->options);
- priv->options_id = options_id;
- } else {
- gnc_plugin_page_acct_tree_options_new(priv);
- }
- } else {
- gnc_plugin_page_acct_tree_options_new(priv);
- }
-
- g_free (location);
- g_free (label);
- }
-
- priv->odb = gnc_option_db_new(priv->options);
-
LEAVE("page %p, priv %p, action group %p",
plugin_page, priv, action_group);
}
@@ -388,7 +351,6 @@
{
GncPluginPageAccountTree *page;
GncPluginPageAccountTreePrivate *priv;
- SCM free_tree;
ENTER("object %p", object);
page = GNC_PLUGIN_PAGE_ACCOUNT_TREE (object);
@@ -396,19 +358,6 @@
priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
g_return_if_fail (priv != NULL);
- if (priv->editor_dialog) {
- gnc_options_dialog_destroy(priv->editor_dialog);
- priv->editor_dialog = NULL;
- }
-
- gnc_option_db_destroy(priv->odb);
-
- free_tree = scm_c_eval_string("gnc:free-acct-tree-window");
- scm_call_1(free_tree, scm_int2num(priv->options_id));
- priv->options_id = 0;
-
- scm_gc_unprotect_object(priv->options);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
LEAVE(" ");
}
@@ -508,6 +457,10 @@
gtk_widget_show (GTK_WIDGET (tree_view));
gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(tree_view));
+ gnc_tree_view_account_set_filter (GNC_TREE_VIEW_ACCOUNT(tree_view),
+ gnc_plugin_page_account_tree_filter_accounts,
+ plugin_page, NULL);
+
priv->component_id =
gnc_register_gui_component(PLUGIN_PAGE_ACCT_TREE_CM_CLASS,
gnc_plugin_page_account_refresh_cb,
@@ -548,9 +501,11 @@
LEAVE("widget destroyed");
}
-#define ACCT_COUNT "Number of Open Accounts"
-#define ACCT_OPEN "Open Account %d"
-#define ACCT_SELECTED "Selected Account"
+#define ACCT_COUNT "Number of Open Accounts"
+#define ACCT_OPEN "Open Account %d"
+#define ACCT_SELECTED "Selected Account"
+#define HIDE_ZERO "Hide Zero Total"
+#define ACCT_TYPES "Account Types"
typedef struct foo {
GKeyFile *key_file;
@@ -655,6 +610,9 @@
account_page = GNC_PLUGIN_PAGE_ACCOUNT_TREE(plugin_page);
priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(account_page);
+ g_key_file_set_integer(key_file, group_name, ACCT_TYPES, priv->fd.visible_types);
+ g_key_file_set_boolean(key_file, group_name, HIDE_ZERO, priv->fd.hide_zero_total);
+
bar.key_file = key_file;
bar.group_name = group_name;
bar.count = 0;
@@ -736,6 +694,7 @@
GError *error = NULL;
gchar *key, *value;
gint i, count;
+ gboolean hide;
g_return_val_if_fail(key_file, NULL);
g_return_val_if_fail(group_name, NULL);
@@ -749,27 +708,47 @@
/* Install it now so we can them manipulate the created widget */
gnc_main_window_open_page(GNC_MAIN_WINDOW(window), page);
- /* Expanded accounts */
- count = g_key_file_get_integer(key_file, group_name, ACCT_COUNT, &error);
+ /* Filter information. Ignore missing keys. */
+ hide = g_key_file_get_boolean(key_file, group_name, HIDE_ZERO, &error);
if (error) {
g_warning("error reading group %s key %s: %s",
- group_name, ACCT_COUNT, error->message);
+ group_name, HIDE_ZERO, error->message);
g_error_free(error);
- LEAVE("bad value");
- return page;
+ error = NULL;
+ hide = FALSE;
}
- for (i = 1; i <= count; i++) {
- key = g_strdup_printf(ACCT_OPEN, i);
- value = g_key_file_get_string(key_file, group_name, key, &error);
- if (error) {
- g_warning("error reading group %s key %s: %s",
- group_name, key, error->message);
- g_error_free(error);
- error = NULL;
- } else {
- tree_restore_expanded_row(priv->tree_view, value);
- g_free(value);
+ priv->fd.hide_zero_total = hide;
+
+ i = g_key_file_get_integer(key_file, group_name, ACCT_TYPES, &error);
+ if (error) {
+ g_warning("error reading group %s key %s: %s",
+ group_name, ACCT_TYPES, error->message);
+ g_error_free(error);
+ error = NULL;
+ i = -1;
+ }
+ priv->fd.visible_types = i;
+
+ /* Expanded accounts. Skip if count key missing. */
+ count = g_key_file_get_integer(key_file, group_name, ACCT_COUNT, &error);
+ if (error == NULL) {
+ for (i = 1; i <= count; i++) {
+ key = g_strdup_printf(ACCT_OPEN, i);
+ value = g_key_file_get_string(key_file, group_name, key, &error);
+ if (error) {
+ g_warning("error reading group %s key %s: %s",
+ group_name, key, error->message);
+ g_error_free(error);
+ error = NULL;
+ } else {
+ tree_restore_expanded_row(priv->tree_view, value);
+ g_free(value);
+ }
}
+ } else {
+ g_warning("error reading group %s key %s: %s",
+ group_name, ACCT_COUNT, error->message);
+ g_error_free(error);
}
/* Selected account (if any) */
@@ -778,6 +757,10 @@
tree_restore_selected_row(priv->tree_view, value);
g_free(value);
}
+
+ /* Update tree view for any changes */
+ gnc_tree_view_account_refilter(GNC_TREE_VIEW_ACCOUNT(priv->tree_view));
+
LEAVE(" ");
return page;
}
@@ -813,6 +796,7 @@
GtkTreeViewColumn *col,
GncPluginPageAccountTree *page)
{
+ GncPluginPageAccountTreePrivate *priv;
GtkWidget *window;
GncPluginPage *new_page;
Account *account;
@@ -822,6 +806,7 @@
if (account == NULL)
return;
+ priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
window = GNC_PLUGIN_PAGE (page)->window;
new_page = gnc_plugin_page_register_new (account, FALSE);
gnc_main_window_open_page (GNC_MAIN_WINDOW(window), new_page);
@@ -1307,93 +1292,275 @@
g_free(acct_name);
}
-/******************************/
-/* Options Dialog */
-/******************************/
+/*********************/
-static void
-gnc_plugin_page_account_tree_options_apply_cb (GNCOptionWin * propertybox,
- gpointer user_data)
+/** This function tells the account tree view whether or not to filter
+ * out a particular account. Accounts may be filtered if the user
+ * has decided not to display that particular account type, or if the
+ * user has requested taht accoutns with a zero total not be shown.
+ *
+ * @param account The account that was toggled.
+ *
+ * @param user_data A pointer to the account tree page.
+ *
+ * @return TRUE if the account should be visible. FALSE if the
+ * account should be hidden. */
+gboolean
+gnc_plugin_page_account_tree_filter_accounts (Account *account, gpointer user_data)
{
- GncPluginPageAccountTreePrivate *priv = user_data;
- if(!priv)
- return;
+
+ GncPluginPageAccountTree *page = user_data;
+ GncPluginPageAccountTreePrivate *priv;
+ GNCAccountType acct_type;
+ gnc_numeric total;
+ gboolean result;
- ENTER(" ");
- gnc_option_db_commit(priv->odb);
- LEAVE(" ");
+ g_return_val_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page), TRUE);
+
+ ENTER("account %p:%s, page %p", account, xaccAccountGetName(account), page);
+
+ priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
+ if (priv->fd.hide_zero_total) {
+ total = xaccAccountGetBalanceInCurrency (account, NULL, TRUE);
+ if (gnc_numeric_zero_p(total)) {
+ LEAVE(" hide: zero balance");
+ return FALSE;
+ }
+ }
+
+ acct_type = xaccAccountGetType(account);
+ result = (priv->fd.visible_types & (1 << acct_type)) ? TRUE : FALSE;
+ LEAVE(" %s", result ? "show" : "hide");
+ return result;
}
-static void
-gnc_plugin_page_account_tree_options_help_cb (GNCOptionWin * propertybox,
- gpointer user_data)
+/** The "hide zero totals" button in the Filter dialog changed state.
+ * Update the page to reflect these changes.
+ *
+ * @param button The GtkCheckButton that was toggled.
+ *
+ * @param page A pointer to the account tree page to update. */
+void
+gppat_filter_hide_zero_toggled_cb (GtkToggleButton *button,
+ GncPluginPageAccountTree *page)
{
- GtkWidget *dialog;
+ GncPluginPageAccountTreePrivate *priv;
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_OK,
- "Set the account tree options you want using this dialog.");
+ g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ ENTER("button %p, page %p", button, page);
+ priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
+ priv->fd.hide_zero_total = gtk_toggle_button_get_active(button);
+ gnc_tree_view_account_refilter(GNC_TREE_VIEW_ACCOUNT(priv->tree_view));
+ LEAVE("hide_zero %d", priv->fd.hide_zero_total);
}
-static void
-gnc_plugin_page_account_tree_options_close_cb (GNCOptionWin * propertybox,
- gpointer user_data)
+/** The "clear all account types" button in the Filter dialog was
+ * clicked. Clear all account types shown, and update the visible
+ * page.
+ *
+ * @param button The button that was clicked.
+ *
+ * @param page A pointer to the account tree page to update. */
+void
+gppat_filter_clear_all_cb (GtkWidget *button,
+ GncPluginPageAccountTree *page)
{
- GncPluginPageAccountTreePrivate *priv = user_data;
- if(!priv)
- return;
+ GncPluginPageAccountTreePrivate *priv;
+ GtkTreeSelection *selection;
+ GtkTreeView *view;
- gnc_options_dialog_destroy(priv->editor_dialog);
- priv->editor_dialog = NULL;
+ g_return_if_fail(GTK_IS_BUTTON(button));
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page));
+
+ ENTER("button %p, page %p", button, page);
+ priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
+ view = GTK_TREE_VIEW(gnc_glade_lookup_widget(button, FILTER_TREE_VIEW));
+ selection = gtk_tree_view_get_selection(view);
+ g_signal_handler_block(selection, priv->fd.selection_changed_cb_id);
+ priv->fd.visible_types = 0;
+ gnc_tree_model_account_types_set_selection(view, priv->fd.visible_types);
+ g_signal_handler_unblock(selection, priv->fd.selection_changed_cb_id);
+ gnc_tree_view_account_refilter(GNC_TREE_VIEW_ACCOUNT(priv->tree_view));
+ LEAVE("types 0x%x", priv->fd.visible_types);
}
-static void
-gnc_plugin_page_acct_tree_options_new (GncPluginPageAccountTreePrivate *priv)
+/** The "select all account types" button in the Filter dialog was
+ * clicked. Make all account types visible, and update the page.
+ *
+ * @param button The button that was clicked.
+ *
+ * @param page A pointer to the account tree page to update. */
+void
+gppat_filter_select_all_cb (GtkWidget *button,
+ GncPluginPageAccountTree *page)
{
- SCM func, opts_and_id;
+ GncPluginPageAccountTreePrivate *priv;
+ GtkTreeSelection *selection;
+ GtkTreeView *view;
- scm_gc_unprotect_object(priv->options);
- func = scm_c_eval_string("gnc:make-new-acct-tree-window");
- opts_and_id = scm_call_0(func);
- priv->options = SCM_CAR(opts_and_id);
- scm_gc_protect_object(priv->options);
- priv->options_id = scm_num2int(SCM_CDR(opts_and_id), SCM_ARG1, __FUNCTION__);
+ g_return_if_fail(GTK_IS_BUTTON(button));
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page));
+
+ ENTER("button %p, page %p", button, page);
+ priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
+ view = GTK_TREE_VIEW(gnc_glade_lookup_widget(button, FILTER_TREE_VIEW));
+ selection = gtk_tree_view_get_selection(view);
+ g_signal_handler_block(selection, priv->fd.selection_changed_cb_id);
+ priv->fd.visible_types = -1;
+ gnc_tree_model_account_types_set_selection(view, priv->fd.visible_types);
+ g_signal_handler_unblock(selection, priv->fd.selection_changed_cb_id);
+ gnc_tree_view_account_refilter(GNC_TREE_VIEW_ACCOUNT(priv->tree_view));
+ LEAVE("types 0x%x", priv->fd.visible_types);
}
-/*********************/
+/** The "select default account types" button in the Filter dialog was
+ * clicked. Set all account types to their default visibility (which
+ * happens to be visible for all of them), and update the page.
+ *
+ * @param button The button that was clicked.
+ *
+ * @param page A pointer to the account tree page to update. */
+void
+gppat_filter_select_default_cb (GtkWidget *button,
+ GncPluginPageAccountTree *page)
+{
+ ENTER("button %p, page %p", button, page);
+ gppat_filter_select_all_cb(button, page);
+ LEAVE(" ");
+}
+/** The account type selection in the Filter dialog was changed.
+ * Reread the set of selected (i.e. visible) accounts and update the
+ * page.
+ *
+ * @param button The button that was clicked.
+ *
+ * @param page A pointer to the account tree page to update. */
static void
-gnc_plugin_page_account_tree_cmd_view_options (GtkAction *action, GncPluginPageAccountTree *page)
+gppat_filter_selection_changed_cb (GtkTreeSelection *selection,
+ GncPluginPageAccountTree *page)
{
GncPluginPageAccountTreePrivate *priv;
+ GtkTreeView *view;
- g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (page));
+ g_return_if_fail(GTK_IS_TREE_SELECTION(selection));
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page));
+
+ ENTER("selection %p, page %p", selection, page);
priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
+ view = gtk_tree_selection_get_tree_view(selection);
+ priv->fd.visible_types = gnc_tree_model_account_types_get_selection(view);
+ gnc_tree_view_account_refilter(GNC_TREE_VIEW_ACCOUNT(priv->tree_view));
+ LEAVE("types 0x%x", priv->fd.visible_types);
+}
- if (!priv->editor_dialog) {
- priv->editor_dialog = gnc_options_dialog_new(_("Account Tree Options"));
- gnc_build_options_dialog_contents(priv->editor_dialog,
- priv->odb);
-
- gnc_options_dialog_set_apply_cb(priv->editor_dialog,
- gnc_plugin_page_account_tree_options_apply_cb,
- priv);
- gnc_options_dialog_set_help_cb(priv->editor_dialog,
- gnc_plugin_page_account_tree_options_help_cb,
- priv);
- gnc_options_dialog_set_close_cb(priv->editor_dialog,
- gnc_plugin_page_account_tree_options_close_cb,
- priv);
+/** The Filter dialog was closed. CHeck to see if this was done via
+ * the OK button. If so, make the changes permanent. If not, revert
+ * any changes.
+ *
+ * @param dialog A pointer to the "Filter By" dialog.
+ *
+ * @param response The response code from closing the dialog.
+ *
+ * @param page A pointer to the account tree page to update. */
+void
+gppat_filter_response_cb (GtkWidget *dialog,
+ gint response,
+ GncPluginPageAccountTree *page)
+{
+ GncPluginPageAccountTreePrivate *priv;
+ GtkWidget *view;
+ guint32 types;
+
+ g_return_if_fail(GTK_IS_DIALOG(dialog));
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page));
+
+ ENTER("dialog %p, response %d, page %p", dialog, response, page);
+ view = gnc_glade_lookup_widget(dialog, FILTER_TREE_VIEW);
+
+ priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
+ if (response != GTK_RESPONSE_OK) {
+ priv->fd.visible_types = priv->fd.original_visible_types;
+ priv->fd.hide_zero_total = priv->fd.original_hide_zero_total;
+ gnc_tree_view_account_refilter(GNC_TREE_VIEW_ACCOUNT(priv->tree_view));
}
- gtk_window_present(GTK_WINDOW(gnc_options_dialog_widget(priv->editor_dialog)));
+ types = gnc_tree_model_account_types_get_selection(GTK_TREE_VIEW(view));
+
+ /* Clean up and delete dialog */
+ priv->fd.selection_changed_cb_id = 0;
+ g_atomic_pointer_compare_and_exchange((gpointer *)&priv->fd.dialog,
+ dialog, NULL);
+ gtk_widget_destroy(dialog);
+ LEAVE("types 0x%x", types);
}
static void
+gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action,
+ GncPluginPageAccountTree *page)
+{
+ GncPluginPageAccountTreePrivate *priv;
+ GtkWidget *dialog, *button;
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
+ GladeXML *xml;
+ gchar *title;
+
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page));
+ ENTER("(action %p, page %p)", action, page);
+
+ priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
+ if (priv->fd.dialog) {
+ gtk_window_present(GTK_WINDOW(priv->fd.dialog));
+ LEAVE("existing dialog");
+ return;
+ }
+
+ /* Create the dialog */
+ xml = gnc_glade_xml_new ("account.glade", "Filter By");
+ dialog = glade_xml_get_widget (xml, "Filter By");
+ priv->fd.dialog = dialog;
+ gtk_window_set_transient_for(GTK_WINDOW(dialog),
+ GTK_WINDOW(GNC_PLUGIN_PAGE(page)->window));
+ /* Translators: The %s is the name of the plugin page */
+ title = g_strdup_printf(_("Filter %s by..."),
+ gnc_plugin_page_get_page_name(GNC_PLUGIN_PAGE(page)));
+ gtk_window_set_title(GTK_WINDOW(dialog), title);
+ g_free(title);
+
+ /* Remember current state */
+ priv->fd.original_visible_types = priv->fd.visible_types;
+ priv->fd.original_hide_zero_total = priv->fd.hide_zero_total;
+
+ /* Update the dialog widgets for the current state */
+ button = glade_xml_get_widget (xml, "hide_zero");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
+ priv->fd.hide_zero_total);
+
+ view = GTK_TREE_VIEW(glade_xml_get_widget (xml, FILTER_TREE_VIEW));
+ priv->fd.model = gnc_tree_model_account_types_master();
+ gtk_tree_view_set_model(view, priv->fd.model);
+ gtk_tree_view_insert_column_with_attributes
+ (view,
+ -1, _("Account Types"), gtk_cell_renderer_text_new(),
+ "text", GNC_TREE_MODEL_ACCOUNT_TYPES_COL_NAME, NULL);
+ selection = gtk_tree_view_get_selection(view);
+ gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
+ gnc_tree_model_account_types_set_selection(view, priv->fd.visible_types);
+ priv->fd.selection_changed_cb_id =
+ g_signal_connect(G_OBJECT(selection), "changed",
+ G_CALLBACK(gppat_filter_selection_changed_cb), page);
+
+ /* Wire up the rest of the callbacks */
+ glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, page);
+
+ /* Show it */
+ gtk_widget_show_all(dialog);
+ LEAVE(" ");
+}
+
+static void
gnc_plugin_page_account_tree_cmd_reconcile (GtkAction *action,
GncPluginPageAccountTree *page)
{
Modified: gnucash/trunk/src/gnome/ui/gnc-plugin-page-account-tree-ui.xml
===================================================================
--- gnucash/trunk/src/gnome/ui/gnc-plugin-page-account-tree-ui.xml 2005-12-30 05:07:14 UTC (rev 12204)
+++ gnucash/trunk/src/gnome/ui/gnc-plugin-page-account-tree-ui.xml 2005-12-30 06:25:03 UTC (rev 12205)
@@ -19,7 +19,6 @@
<menuitem name="EditEditAccount" action="EditEditAccountAction"/>
<menuitem name="EditDeleteAccount" action="EditDeleteAccountAction"/>
</placeholder>
- <menuitem name="EditAccountViewOptions" action="EditAccountViewOptionsAction"/>
</menu>
<menu name="Actions" action="ActionsAction">
<placeholder name="ActionsPlaceholder">
@@ -39,9 +38,6 @@
</menubar>
<popup name="MainPopup" action="FakeToplevel">
- <placeholder name="PopupPlaceholder1">
- <menuitem name="PopupOptions" action="PopupOptionsAction"/>
- </placeholder>
<placeholder name="PopupPlaceholder2">
<menuitem name="AccountOpenAccount" action="FileOpenAccountAction"/>
<menuitem name="AccountOpenSubaccounts" action="FileOpenSubaccountsAction"/>
@@ -71,8 +67,6 @@
<toolitem name="ToolbarOpenAccount" action="FileOpenAccountAction"/>
<toolitem name="ToolbarEditAccount" action="EditEditAccountAction"/>
<separator name="ToolbarSep3"/>
- <toolitem name="ToolbarAccountViewOptions" action="EditAccountViewOptionsAction"/>
- <separator name="ToolbarSep4"/>
<toolitem name="ToolbarNewAccount" action="FileNewAccountAction"/>
<toolitem name="ToolbarDeleteAccount" action="EditDeleteAccountAction"/>
</placeholder>
Modified: gnucash/trunk/src/scm/main-window.scm
===================================================================
--- gnucash/trunk/src/scm/main-window.scm 2005-12-30 05:07:14 UTC (rev 12204)
+++ gnucash/trunk/src/scm/main-window.scm 2005-12-30 06:25:03 UTC (rev 12205)
@@ -21,77 +21,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; account tree options
-;; like reports, we have an integer tree id that is the index into a
-;; global hash table, and URLs of the form gnc-acct-tree:id=%d will
-;; open to the right window.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define gnc:*acct-tree-options* (make-hash-table 11))
-(define gnc:*acct-tree-id* 0)
-
-(define (gnc:find-acct-tree-window-options id)
- (hash-ref gnc:*acct-tree-options* id))
-
-(define (gnc:make-acct-tree-window-options)
- (let* ((options (gnc:new-options))
- (add-option
- (lambda (opt)
- (gnc:register-option options opt))))
-
- (add-option
- (gnc:make-simple-boolean-option
- (N_ "Account Tree") (N_ "Double click expands parent accounts")
- "a" (N_ "Double clicking on an account with children expands \
-the account instead of opening a register.") #f))
-
- (add-option
- (gnc:make-list-option
- (N_ "Account Tree") (N_ "Account types to display")
- "b" (N_ "Select the account types that should be displayed.")
- (list 'bank 'cash 'credit 'asset 'liability 'stock
- 'mutual 'currency 'income 'expense 'equity 'payable 'receivable)
- (list (list->vector (list 'bank (N_ "Bank") ""))
- (list->vector (list 'cash (N_ "Cash") ""))
- (list->vector (list 'credit (N_ "Credit") ""))
- (list->vector (list 'asset (N_ "Asset") ""))
- (list->vector (list 'liability (N_ "Liability") ""))
- (list->vector (list 'stock (N_ "Stock") ""))
- (list->vector (list 'mutual (N_ "Mutual Fund") ""))
- (list->vector (list 'currency (N_ "Currency") ""))
- (list->vector (list 'income (N_ "Income") ""))
- (list->vector (list 'expense (N_ "Expense") ""))
- (list->vector (list 'equity (N_ "Equity") ""))
- (list->vector (list 'payable (N_ "Accounts Payable") ""))
- (list->vector (list 'receivable (N_ "Accounts Receivable") "")))))
-
- options))
-
-(define (gnc:make-new-acct-tree-window)
- (let ((options (gnc:make-acct-tree-window-options))
- (id gnc:*acct-tree-id*))
- (hash-set! gnc:*acct-tree-options* id options)
- (set! gnc:*acct-tree-id* (+ 1 id))
- (cons options id)))
-
-(define (gnc:free-acct-tree-window id)
- (hash-remove! gnc:*acct-tree-options* id))
-
-
-(define (gnc:acct-tree-generate-restore-forms optobj id)
- (string-append
- ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
- (simple-format #f ";; options for account tree id=~S\n" id)
- "(let ((options (gnc:make-acct-tree-window-options)))\n"
- (gnc:generate-restore-forms optobj "options")
- (simple-format
- #f " (hash-set! gnc:*acct-tree-options* ~A options)\n" id)
- " \""
- (gnc:html-build-url gnc:url-type-accttree (sprintf #f "%a" id) #f)
- "\")\n\n"))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; book open and close hooks for mdi
;;
;; we need to save all the active report and acct tree info during
@@ -113,11 +42,6 @@
(display (gnc:report-generate-restore-forms v))))
#t *gnc:_reports_*)
- (hash-fold
- (lambda (k v p)
- (display (gnc:acct-tree-generate-restore-forms v k)) #t)
- #t gnc:*acct-tree-options*)
-
(force-output)))
))))
Modified: gnucash/trunk/src/scm/main.scm
===================================================================
--- gnucash/trunk/src/scm/main.scm 2005-12-30 05:07:14 UTC (rev 12204)
+++ gnucash/trunk/src/scm/main.scm 2005-12-30 06:25:03 UTC (rev 12205)
@@ -76,9 +76,6 @@
(export gnc:load-help-topics)
;; from main-window.scm
-(export gnc:find-acct-tree-window-options)
-(export gnc:make-new-acct-tree-window)
-(export gnc:free-acct-tree-window)
(export gnc:main-window-save-state)
(export gnc:main-window-properties-cb)
More information about the gnucash-changes
mailing list