gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Tue Aug 27 09:28:25 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/d963ca0d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/13d31797 (commit)
	from  https://github.com/Gnucash/gnucash/commit/90da06b8 (commit)



commit d963ca0d3ae44c77cd99550617ecc369958eb95c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Aug 24 17:06:58 2019 +0800

    fincalc: remove C accelerator for Clear
    
    because it clashes with Close button

diff --git a/gnucash/gtkbuilder/dialog-fincalc.glade b/gnucash/gtkbuilder/dialog-fincalc.glade
index 2573494ec..851138e57 100644
--- a/gnucash/gtkbuilder/dialog-fincalc.glade
+++ b/gnucash/gtkbuilder/dialog-fincalc.glade
@@ -215,12 +215,9 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="spacing">6</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
                                 <child>
                                   <object class="GtkButton" id="payment_periods_clear_button">
-                                    <property name="label" translatable="yes">_Clear</property>
+                                    <property name="label" translatable="yes">Clear</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
@@ -272,12 +269,9 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="spacing">6</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
                                 <child>
                                   <object class="GtkButton" id="interest_rate_clear_button">
-                                    <property name="label" translatable="yes">_Clear</property>
+                                    <property name="label" translatable="yes">Clear</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
@@ -329,12 +323,9 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="spacing">6</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
                                 <child>
                                   <object class="GtkButton" id="present_value_clear_button">
-                                    <property name="label" translatable="yes">_Clear</property>
+                                    <property name="label" translatable="yes">Clear</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
@@ -386,12 +377,9 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="spacing">6</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
                                 <child>
                                   <object class="GtkButton" id="periodic_payment_clear_button">
-                                    <property name="label" translatable="yes">_Clear</property>
+                                    <property name="label" translatable="yes">Clear</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
@@ -443,12 +431,9 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="spacing">6</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
                                 <child>
                                   <object class="GtkButton" id="future_value_clear_button">
-                                    <property name="label" translatable="yes">_Clear</property>
+                                    <property name="label" translatable="yes">Clear</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
@@ -634,6 +619,7 @@
                           <packing>
                             <property name="left_attach">1</property>
                             <property name="top_attach">12</property>
+                            <property name="width">2</property>
                           </packing>
                         </child>
                         <child>
@@ -951,9 +937,6 @@
                         <child>
                           <placeholder/>
                         </child>
-                        <child>
-                          <placeholder/>
-                        </child>
                       </object>
                     </child>
                   </object>

commit 13d3179729130f8930f636fe3cd45bed3a6e32e7
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Aug 23 21:14:38 2019 +0800

    Bug 605602 - precision of Financial Calculator seems to depend on locale
    
    * the calc_clicked_cb had mechanism to abort if no fields were
      empty. disable it.
    
    * to convert gnc_numeric to string, the only suitable print_info is
      gnc_share_print_info_places which takes decimal and outputs suitable
      print_info. Not very appropriate, but works.

diff --git a/gnucash/gnome/dialog-fincalc.c b/gnucash/gnome/dialog-fincalc.c
index 8e96f7790..c6d71f956 100644
--- a/gnucash/gnome/dialog-fincalc.c
+++ b/gnucash/gnome/dialog-fincalc.c
@@ -68,6 +68,7 @@ struct _FinCalcDialog
     GtkWidget *payment_combo;
 
     GtkWidget *end_of_period_radio;
+    GtkWidget *precision;
     GtkWidget *discrete_compounding_radio;
 
     GtkWidget *payment_total_label;
@@ -99,6 +100,7 @@ void fincalc_update_calc_button_cb(GtkWidget *unused, FinCalcDialog *fcd);
 void fincalc_calc_clicked_cb(GtkButton *button, FinCalcDialog *fcd);
 void fincalc_compounding_radio_toggled(GtkToggleButton *togglebutton, gpointer data);
 void fincalc_amount_clear_clicked_cb(GtkButton *button, FinCalcDialog *fcd);
+void fincalc_precision_spin_value_changed_cb (GtkButton *button, FinCalcDialog *fcd);
 void fincalc_response_cb (GtkDialog *dialog, gint response, FinCalcDialog *fcd);
 
 /** Implementations *****************************************************/
@@ -128,7 +130,7 @@ normalize_period(unsigned int *period)
 static void
 fi_to_gui(FinCalcDialog *fcd)
 {
-    const gnc_commodity *commodity;
+    int precision;
     static char string[64];
     gnc_numeric total;
     gnc_numeric npp;
@@ -153,12 +155,11 @@ fi_to_gui(FinCalcDialog *fcd)
 
     pmt = double_to_gnc_numeric (fcd->financial_info.pmt, 100000, GNC_HOW_RND_ROUND_HALF_UP);
 
-    commodity = gnc_default_currency ();
+    precision = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(fcd->precision));
 
-    total = gnc_numeric_mul (npp, pmt, gnc_commodity_get_fraction (commodity),
-                             GNC_HOW_RND_ROUND_HALF_UP);
+    total = gnc_numeric_mul (npp, pmt, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
 
-    xaccSPrintAmount (string, total, gnc_default_print_info (FALSE));
+    xaccSPrintAmount (string, total, gnc_share_print_info_places (precision));
     gtk_label_set_text (GTK_LABEL(fcd->payment_total_label), string);
 
     i = normalize_period(&fcd->financial_info.CF);
@@ -280,6 +281,12 @@ fincalc_amount_clear_clicked_cb(GtkButton *button, FinCalcDialog *fcd)
         gtk_entry_set_text(edit, "");
 }
 
+void
+fincalc_precision_spin_value_changed_cb (GtkButton *button, FinCalcDialog *fcd)
+{
+    gtk_widget_set_sensitive (GTK_WIDGET(fcd->calc_button), TRUE);
+}
+
 static void
 init_fi(FinCalcDialog *fcd)
 {
@@ -427,7 +434,6 @@ calc_value(FinCalcDialog *fcd, FinCalcValue value)
         fi_calc_future_value(&fcd->financial_info);
         break;
     default:
-        PERR("Unknown financial variable");
         break;
     }
 
@@ -450,6 +456,7 @@ fincalc_calc_clicked_cb(GtkButton *button, FinCalcDialog *fcd)
         calc_value(fcd, i);
         return;
     }
+    calc_value(fcd, NUM_FIN_CALC_VALUES);
 }
 
 void fincalc_response_cb (GtkDialog *dialog,
@@ -555,8 +562,10 @@ gnc_ui_fincalc_dialog_create(GtkWindow *parent)
     GtkWidget *button;
     GtkWidget *combo;
     GtkWidget *edit;
+    GtkWidget *spin;
     GtkWidget *hbox;
     GtkBuilder *builder;
+    GtkAdjustment *adjustment;
 
     if (gnc_forall_gui_components (DIALOG_FINCALC_CM_CLASS,
                                    show_handler, NULL))
@@ -655,6 +664,11 @@ gnc_ui_fincalc_dialog_create(GtkWindow *parent)
     g_signal_connect(fcd->compounding_combo, "changed",
                      G_CALLBACK (fincalc_update_calc_button_cb), fcd);
 
+    spin = GTK_WIDGET (gtk_builder_get_object (builder, "precision_spin"));
+    adjustment = gtk_adjustment_new (2, 0, 10, 1, 1, 1);
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin), adjustment);
+    fcd->precision = spin;
+
     button = GTK_WIDGET(gtk_builder_get_object (builder, "period_payment_radio"));
     fcd->end_of_period_radio = button;
 
diff --git a/gnucash/gtkbuilder/dialog-fincalc.glade b/gnucash/gtkbuilder/dialog-fincalc.glade
index c7a9bdb2f..2573494ec 100644
--- a/gnucash/gtkbuilder/dialog-fincalc.glade
+++ b/gnucash/gtkbuilder/dialog-fincalc.glade
@@ -477,6 +477,46 @@
                             <property name="position">4</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkBox" id="vbox83">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="orientation">vertical</property>
+                            <child>
+                              <object class="GtkLabel" id="label803">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="label" translatable="yes">Precision</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="precision_spin">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="input_purpose">number</property>
+                                <property name="climb_rate">1</property>
+                                <property name="numeric">True</property>
+                                <property name="value">1</property>
+                                <signal name="value-changed" handler="fincalc_precision_spin_value_changed_cb" swapped="no"/>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">5</property>
+                          </packing>
+                        </child>
                         <child>
                           <object class="GtkAlignment" id="alignment31">
                             <property name="visible">True</property>
@@ -509,7 +549,7 @@
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">True</property>
-                            <property name="position">5</property>
+                            <property name="position">6</property>
                           </packing>
                         </child>
                       </object>



Summary of changes:
 gnucash/gnome/dialog-fincalc.c          | 26 +++++++++---
 gnucash/gtkbuilder/dialog-fincalc.glade | 71 ++++++++++++++++++++++-----------
 2 files changed, 67 insertions(+), 30 deletions(-)



More information about the gnucash-changes mailing list