gnucash maint: Multiple changes pushed

Robert Fewell bobit at code.gnucash.org
Thu Sep 24 11:33:50 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/7f7ae2ef (commit)
	 via  https://github.com/Gnucash/gnucash/commit/227bbda1 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/95b502ea (commit)
	from  https://github.com/Gnucash/gnucash/commit/a926991d (commit)



commit 7f7ae2ef005312e168a0313aa44dc195c171392d
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu Sep 24 12:44:49 2020 +0100

    Bug 554391 - Select account if Tax Options dialog opened from CoA
    
    If the Tax options dialog is opened from the Chart of Accounts and an
    account is selected then the tax dialog will preselect that account.

diff --git a/gnucash/gnome-utils/gnc-ui.h b/gnucash/gnome-utils/gnc-ui.h
index 359051a5e..a5049ddea 100644
--- a/gnucash/gnome-utils/gnc-ui.h
+++ b/gnucash/gnome-utils/gnc-ui.h
@@ -111,7 +111,7 @@ int      gnc_choose_radio_option_dialog (GtkWidget *parent,
         int default_value,
         GList *radio_list);
 
-void     gnc_tax_info_dialog (GtkWidget *parent);
+void     gnc_tax_info_dialog (GtkWidget *parent, Account *account);
 void     gnc_stock_split_dialog (GtkWidget *parent, Account * initial);
 
 typedef enum
diff --git a/gnucash/gnome/dialog-tax-info.c b/gnucash/gnome/dialog-tax-info.c
index 9b34799b2..3f18765fd 100644
--- a/gnucash/gnome/dialog-tax-info.c
+++ b/gnucash/gnome/dialog-tax-info.c
@@ -103,6 +103,7 @@ typedef struct
     GtkWidget * tax_identity_edit_button;
 
     GtkWidget * acct_info;
+    GtkWidget * income_radio;
     GtkWidget * expense_radio;
     GtkWidget * asset_radio;
     GtkWidget * liab_eq_radio;
@@ -883,6 +884,39 @@ gnc_tax_info_update_accounts (TaxInfoDialog *ti_dialog)
     return num_accounts;
 }
 
+static void
+gnc_tax_info_set_acct (TaxInfoDialog *ti_dialog, Account *account)
+{
+    if (account == NULL)
+        return;
+
+    ti_dialog->account_type = xaccAccountGetType (account);
+
+    if (ti_dialog->account_type == ACCT_TYPE_INCOME)
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ti_dialog->income_radio), TRUE);
+    else if (ti_dialog->account_type == ACCT_TYPE_EXPENSE)
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ti_dialog->expense_radio), TRUE);
+    else if ((ti_dialog->account_type == ACCT_TYPE_ASSET) ||
+             (ti_dialog->account_type == ACCT_TYPE_BANK) ||
+             (ti_dialog->account_type == ACCT_TYPE_CASH) ||
+             (ti_dialog->account_type == ACCT_TYPE_STOCK) ||
+             (ti_dialog->account_type == ACCT_TYPE_MUTUAL) ||
+             (ti_dialog->account_type == ACCT_TYPE_RECEIVABLE))
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ti_dialog->asset_radio), TRUE);
+    else if ((ti_dialog->account_type == ACCT_TYPE_LIABILITY) ||
+             (ti_dialog->account_type == ACCT_TYPE_EQUITY) ||
+             (ti_dialog->account_type == ACCT_TYPE_CREDIT) ||
+             (ti_dialog->account_type == ACCT_TYPE_PAYABLE))
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ti_dialog->liab_eq_radio), TRUE);
+    else if (ti_dialog->account_type == ACCT_TYPE_EQUITY)
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ti_dialog->liab_eq_radio), TRUE);
+    else
+        return;
+
+    gnc_tree_view_account_set_selected_account (GNC_TREE_VIEW_ACCOUNT(ti_dialog->account_treeview),
+                                                account);
+}
+
 static void
 gnc_tax_info_acct_type_cb (GtkWidget *w, gpointer data)
 {
@@ -1440,6 +1474,7 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
         gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(tree_view));
 
         income_radio = GTK_WIDGET(gtk_builder_get_object (builder, "income_radio"));
+        ti_dialog->income_radio = income_radio;
         expense_radio = GTK_WIDGET(gtk_builder_get_object (builder, "expense_radio"));
         ti_dialog->expense_radio = expense_radio;
         asset_radio = GTK_WIDGET(gtk_builder_get_object (builder, "asset_radio"));
@@ -1520,7 +1555,7 @@ refresh_handler (GHashTable *changes, gpointer user_data)
  * Return: nothing                                                  *
 \********************************************************************/
 void
-gnc_tax_info_dialog (GtkWidget * parent)
+gnc_tax_info_dialog (GtkWidget * parent, Account * account)
 {
     TaxInfoDialog *ti_dialog;
     gint component_id;
@@ -1529,6 +1564,9 @@ gnc_tax_info_dialog (GtkWidget * parent)
 
     gnc_tax_info_dialog_create (parent, ti_dialog);
 
+    if (account)
+        gnc_tax_info_set_acct (ti_dialog, account);
+
     component_id = gnc_register_gui_component (DIALOG_TAX_INFO_CM_CLASS,
                    refresh_handler, close_handler,
                    ti_dialog);
diff --git a/gnucash/gnome/gnc-plugin-basic-commands.c b/gnucash/gnome/gnc-plugin-basic-commands.c
index 2f85604c8..11ff549fb 100644
--- a/gnucash/gnome/gnc-plugin-basic-commands.c
+++ b/gnucash/gnome/gnc-plugin-basic-commands.c
@@ -524,7 +524,7 @@ gnc_main_window_cmd_edit_tax_options (GtkAction *action, GncMainWindowActionData
 {
     g_return_if_fail (data != NULL);
 
-    gnc_tax_info_dialog (GTK_WIDGET (data->window));
+    gnc_tax_info_dialog (GTK_WIDGET (data->window), NULL);
 }
 
 static void
diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c
index ea44c1216..52a78455e 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.c
@@ -165,6 +165,7 @@ static void gnc_plugin_page_account_tree_cmd_refresh (GtkAction *action, GncPlug
 static void gnc_plugin_page_account_tree_cmd_autoclear (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);
+static void gnc_plugin_page_account_tree_cmd_edit_tax_options (GtkAction *action, GncPluginPageAccountTree *page);
 static void gnc_plugin_page_account_tree_cmd_lots (GtkAction *action, GncPluginPageAccountTree *page);
 static void gnc_plugin_page_account_tree_cmd_scrub (GtkAction *action, GncPluginPageAccountTree *page);
 static void gnc_plugin_page_account_tree_cmd_scrub_sub (GtkAction *action, GncPluginPageAccountTree *page);
@@ -272,7 +273,18 @@ static GtkActionEntry gnc_plugin_page_account_tree_actions [] =
         N_("Renumber the children of the selected account"),
         G_CALLBACK (gnc_plugin_page_account_tree_cmd_renumber_accounts)
     },
-
+    {
+        "EditTaxOptionsAction", NULL,
+        /* Translators: remember to reuse this *
+         * translation in dialog-account.glade */
+        N_("Ta_x Report Options"), NULL,
+        /* Translators: currently implemented are *
+         * US: income tax and                     *
+         * DE: VAT                                *
+         * So adjust this string                  */
+        N_("Setup relevant accounts for tax reports, e.g. US income tax"),
+        G_CALLBACK (gnc_plugin_page_account_tree_cmd_edit_tax_options)
+    },
     /* View menu */
     {
         "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL,
@@ -1922,6 +1934,18 @@ gnc_plugin_page_account_tree_cmd_stock_split (GtkAction *action,
     gnc_stock_split_dialog (window, account);
 }
 
+static void
+gnc_plugin_page_account_tree_cmd_edit_tax_options (GtkAction *action,
+        GncPluginPageAccountTree *page)
+{
+    GtkWidget *window;
+    Account *account;
+
+    account = gnc_plugin_page_account_tree_get_current_account (page);
+    window = GNC_PLUGIN_PAGE (page)->window;
+    gnc_tax_info_dialog (window, account);
+}
+
 static void
 gnc_plugin_page_account_tree_cmd_lots (GtkAction *action,
                                        GncPluginPageAccountTree *page)
diff --git a/gnucash/ui/gnc-plugin-page-account-tree-ui.xml b/gnucash/ui/gnc-plugin-page-account-tree-ui.xml
index 2eb8124d5..ecde1c84b 100644
--- a/gnucash/ui/gnc-plugin-page-account-tree-ui.xml
+++ b/gnucash/ui/gnc-plugin-page-account-tree-ui.xml
@@ -10,6 +10,7 @@
         <separator name="EditSep2"/>
         <menuitem name="FileOpenAccount" action="FileOpenAccountAction"/>
         <menuitem name="FileOpenSubaccounts" action="FileOpenSubaccountsAction"/>
+        <menuitem name="EditTaxOptions" action="EditTaxOptionsAction"/>
       </placeholder>
     </menu>
     <menu name="Actions" action="ActionsAction">

commit 227bbda16c30778888dcabcdb03286d7b5f34999
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu Sep 24 12:42:02 2020 +0100

    Bug 554391 - Add Apply button to Tax Options dialog

diff --git a/gnucash/gnome/dialog-tax-info.c b/gnucash/gnome/dialog-tax-info.c
index e63c9842a..9b34799b2 100644
--- a/gnucash/gnome/dialog-tax-info.c
+++ b/gnucash/gnome/dialog-tax-info.c
@@ -109,6 +109,7 @@ typedef struct
     GtkWidget * account_treeview;
     GtkWidget * select_button;
     GtkWidget * num_acct_label;
+    GtkWidget * apply_button;
 
     GtkWidget * txf_info;
     GtkWidget * tax_related_button;
@@ -226,6 +227,7 @@ static void
 gnc_tax_info_set_changed (TaxInfoDialog *ti_dialog, gboolean changed)
 {
     ti_dialog->changed = changed;
+    gtk_widget_set_sensitive (ti_dialog->apply_button, changed);
 }
 
 static GList *
@@ -811,10 +813,11 @@ gnc_tax_info_dialog_response (GtkDialog *dialog, gint response, gpointer data)
 {
     TaxInfoDialog *ti_dialog = data;
 
-    if (response == GTK_RESPONSE_OK && ti_dialog->changed)
+    if (ti_dialog->changed && (response == GTK_RESPONSE_APPLY || response == GTK_RESPONSE_OK))
         gui_to_accounts (ti_dialog);
 
-    gnc_close_gui_component_by_data (DIALOG_TAX_INFO_CM_CLASS, ti_dialog);
+    if (response != GTK_RESPONSE_APPLY)
+        gnc_close_gui_component_by_data (DIALOG_TAX_INFO_CM_CLASS, ti_dialog);
 }
 
 static void
@@ -1383,6 +1386,8 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
         label = GTK_WIDGET(gtk_builder_get_object (builder, "txf_category_label"));
         gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(tree_view));
 
+        ti_dialog->apply_button = GTK_WIDGET(gtk_builder_get_object (builder, "apply_button"));
+
         button = GTK_WIDGET(gtk_builder_get_object (builder, "current_account_button"));
         ti_dialog->current_account_button = button;
 
diff --git a/gnucash/gtkbuilder/dialog-tax-info.glade b/gnucash/gtkbuilder/dialog-tax-info.glade
index b9bbdb1e5..20301fea2 100644
--- a/gnucash/gtkbuilder/dialog-tax-info.glade
+++ b/gnucash/gtkbuilder/dialog-tax-info.glade
@@ -38,6 +38,21 @@
                 <property name="position">0</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkButton" id="apply_button">
+                <property name="label" translatable="yes">_Apply</property>
+                <property name="visible">True</property>
+                <property name="sensitive">False</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
             <child>
               <object class="GtkButton" id="ok_button">
                 <property name="label" translatable="yes">_OK</property>
@@ -50,7 +65,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">1</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>
@@ -712,6 +727,7 @@
     </child>
     <action-widgets>
       <action-widget response="-6">cancel_button</action-widget>
+      <action-widget response="-10">apply_button</action-widget>
       <action-widget response="-5">ok_button</action-widget>
     </action-widgets>
     <child type="titlebar">

commit 95b502ea9681122dae9a1b284c1511e090b3ba21
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu Sep 24 11:36:55 2020 +0100

    Bug 797897 - Cannot select multiple accounts in Tax Report Options
    
    Multi selection was disabled for Bug 518833, 27/01/2019 but the select
    sub accounts button was left giving the impression of multi selection.
    
    I have enabled the multi selection for the tree view and while testing
    all accounts selected were updated with the selected tax option.

diff --git a/gnucash/gnome/dialog-tax-info.c b/gnucash/gnome/dialog-tax-info.c
index ca1da5033..e63c9842a 100644
--- a/gnucash/gnome/dialog-tax-info.c
+++ b/gnucash/gnome/dialog-tax-info.c
@@ -930,8 +930,7 @@ gnc_tax_info_account_changed_cb (GtkTreeSelection *selection,
 
     case 1:
         /* Get the account. This view is set for multiple selection, so we
-           can only get a list of accounts. 1-25-19: The dialog does not work
-           for multiple accounts so it was changed to single selection */
+           can only get a list of accounts. */
         view = GNC_TREE_VIEW_ACCOUNT(ti_dialog->account_treeview);
         accounts = gnc_tree_view_account_get_selected_accounts (view);
         if (accounts == NULL)
@@ -941,7 +940,7 @@ gnc_tax_info_account_changed_cb (GtkTreeSelection *selection,
             return;
         }
         account_to_gui (ti_dialog, accounts->data);
-        g_list_free(accounts);
+        g_list_free (accounts);
 
         gnc_tax_info_set_changed (ti_dialog, FALSE);
         break;
@@ -1423,7 +1422,7 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
         ti_dialog->account_treeview = GTK_WIDGET(tree_view);
 
         selection = gtk_tree_view_get_selection (tree_view);
-        gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+        gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
         g_signal_connect (G_OBJECT (selection), "changed",
                           G_CALLBACK (gnc_tax_info_account_changed_cb),
                           ti_dialog);



Summary of changes:
 gnucash/gnome-utils/gnc-ui.h                   |  2 +-
 gnucash/gnome/dialog-tax-info.c                | 56 ++++++++++++++++++++++----
 gnucash/gnome/gnc-plugin-basic-commands.c      |  2 +-
 gnucash/gnome/gnc-plugin-page-account-tree.c   | 26 +++++++++++-
 gnucash/gtkbuilder/dialog-tax-info.glade       | 18 ++++++++-
 gnucash/ui/gnc-plugin-page-account-tree-ui.xml |  1 +
 6 files changed, 94 insertions(+), 11 deletions(-)



More information about the gnucash-changes mailing list