r21715 - gnucash/trunk/src/business/business-gnome - Make the report name for clicking "Print Invoice" a preference.

Christian Stimming cstim at code.gnucash.org
Sun Dec 11 15:59:48 EST 2011


Author: cstim
Date: 2011-12-11 15:59:48 -0500 (Sun, 11 Dec 2011)
New Revision: 21715
Trac: http://svn.gnucash.org/trac/changeset/21715

Modified:
   gnucash/trunk/src/business/business-gnome/dialog-invoice.c
   gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c
   gnucash/trunk/src/business/business-gnome/gnc-plugin-business.h
   gnucash/trunk/src/business/business-gnome/gncmod-business-gnome.c
   gnucash/trunk/src/business/business-gnome/gtkbuilder/business-prefs.glade
   gnucash/trunk/src/business/business-gnome/schemas/apps_gnucash_dialog_business_common.schemas.in
Log:
Make the report name for clicking "Print Invoice" a preference.

The implementation of a GtkComboBox in the preference is somewhat suboptimal
as the gconf key is the integer index in the combo box, but the needed key is
the (untranslated!) string of the report name. As a workaround, the list
of names exists twice, once in business-prefs.glade and once in gnc-plugin-business.c.
At least this works fine from the point of view of the user.

Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c	2011-12-11 20:39:34 UTC (rev 21714)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c	2011-12-11 20:59:48 UTC (rev 21715)
@@ -610,17 +610,21 @@
 static void
 gnc_invoice_window_print_invoice(GncInvoice *invoice)
 {
-    SCM func, arg;
+    SCM func, arg, arg2;
     SCM args = SCM_EOL;
     int report_id;
+    const char *reportname = gnc_plugin_business_get_invoice_printreport();
 
     g_return_if_fail (invoice);
+    if (!reportname)
+        reportname = "Printable Invoice"; // fallback if the option lookup failed
 
-    func = scm_c_eval_string ("gnc:invoice-report-create");
+    func = scm_c_eval_string ("gnc:invoice-report-create-withname");
     g_return_if_fail (scm_is_procedure (func));
 
     arg = SWIG_NewPointerObj(invoice, SWIG_TypeQuery("_p__gncInvoice"), 0);
-    args = scm_cons (arg, args);
+    arg2 = scm_from_locale_string(reportname);
+    args = scm_cons2 (arg, arg2, args);
 
     /* scm_gc_protect_object(func); */
 

Modified: gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c	2011-12-11 20:39:34 UTC (rev 21714)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c	2011-12-11 20:59:48 UTC (rev 21715)
@@ -1169,3 +1169,24 @@
                      G_CALLBACK(gnc_plugin_business_main_window_page_changed),
                      plugin);
 }
+
+static const char* invoice_printreport_values[] =
+{
+    // FIXME: You must manually keep this list in sync with the one at the end
+    // of business-prefs.glade
+    "Printable Invoice",
+    "Tax Invoice",
+    "Easy Invoice",
+    "Fancy Invoice",
+    NULL
+};
+
+const char *gnc_plugin_business_get_invoice_printreport(void)
+{
+    int value = gnc_gconf_get_int(GCONF_SECTION_INVOICE,
+                                  "invoice_printreport", NULL);
+    if (value >= 0 && value < 4)
+        return invoice_printreport_values[value];
+    else
+        return NULL;
+}

Modified: gnucash/trunk/src/business/business-gnome/gnc-plugin-business.h
===================================================================
--- gnucash/trunk/src/business/business-gnome/gnc-plugin-business.h	2011-12-11 20:39:34 UTC (rev 21714)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-business.h	2011-12-11 20:59:48 UTC (rev 21715)
@@ -62,5 +62,6 @@
 GncMainWindow *gnc_plugin_business_get_window (void);
 void gnc_invoice_remind_bills_due (void);
 void gnc_invoice_remind_bills_due_cb (void);
+const char *gnc_plugin_business_get_invoice_printreport(void);
 
 #endif /* __GNC_PLUGIN_BUSINESS_H */

Modified: gnucash/trunk/src/business/business-gnome/gncmod-business-gnome.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gncmod-business-gnome.c	2011-12-11 20:39:34 UTC (rev 21714)
+++ gnucash/trunk/src/business/business-gnome/gncmod-business-gnome.c	2011-12-11 20:59:48 UTC (rev 21715)
@@ -113,7 +113,7 @@
 
         /* Add to preferences under Business */
         /* The parameters are; glade file, items to add from glade file - last being the dialog, preference tab name */
-        gnc_preferences_add_page("business-prefs.glade", "days_in_adj,business_prefs",
+        gnc_preferences_add_page("business-prefs.glade", "liststore_printinvoice,days_in_adj,business_prefs",
                                  _("Business"));
     }
 

Modified: gnucash/trunk/src/business/business-gnome/gtkbuilder/business-prefs.glade
===================================================================
--- gnucash/trunk/src/business/business-gnome/gtkbuilder/business-prefs.glade	2011-12-11 20:39:34 UTC (rev 21714)
+++ gnucash/trunk/src/business/business-gnome/gtkbuilder/business-prefs.glade	2011-12-11 20:59:48 UTC (rev 21715)
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy project-wide -->
@@ -11,7 +11,7 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="border_width">6</property>
-        <property name="n_rows">9</property>
+        <property name="n_rows">10</property>
         <property name="n_columns">4</property>
         <property name="column_spacing">12</property>
         <child>
@@ -57,8 +57,8 @@
             <property name="draw_indicator">True</property>
           </object>
           <packing>
-            <property name="top_attach">8</property>
-            <property name="bottom_attach">9</property>
+            <property name="top_attach">9</property>
+            <property name="bottom_attach">10</property>
             <property name="x_options">GTK_FILL</property>
             <property name="y_options"></property>
             <property name="x_padding">12</property>
@@ -84,8 +84,8 @@
           <packing>
             <property name="left_attach">3</property>
             <property name="right_attach">4</property>
-            <property name="top_attach">7</property>
-            <property name="bottom_attach">8</property>
+            <property name="top_attach">8</property>
+            <property name="bottom_attach">9</property>
             <property name="x_options"></property>
             <property name="y_options"></property>
           </packing>
@@ -102,8 +102,8 @@
           <packing>
             <property name="left_attach">2</property>
             <property name="right_attach">3</property>
-            <property name="top_attach">7</property>
-            <property name="bottom_attach">8</property>
+            <property name="top_attach">8</property>
+            <property name="bottom_attach">9</property>
             <property name="x_options">GTK_FILL</property>
             <property name="y_options"></property>
           </packing>
@@ -123,8 +123,8 @@
           </object>
           <packing>
             <property name="right_attach">2</property>
-            <property name="top_attach">7</property>
-            <property name="bottom_attach">8</property>
+            <property name="top_attach">8</property>
+            <property name="bottom_attach">9</property>
             <property name="x_options">GTK_FILL</property>
             <property name="y_options"></property>
             <property name="x_padding">12</property>
@@ -140,8 +140,8 @@
           </object>
           <packing>
             <property name="right_attach">2</property>
-            <property name="top_attach">6</property>
-            <property name="bottom_attach">7</property>
+            <property name="top_attach">7</property>
+            <property name="bottom_attach">8</property>
             <property name="x_options">GTK_FILL</property>
             <property name="y_options"></property>
           </packing>
@@ -262,6 +262,41 @@
           </packing>
         </child>
         <child>
+          <object class="GtkComboBox" id="gconf/dialogs/business/invoice/invoice_printreport">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="model">liststore_printinvoice</property>
+            <child>
+              <object class="GtkCellRendererText" id="cellrenderertext2"/>
+              <attributes>
+                <attribute name="text">0</attribute>
+              </attributes>
+            </child>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="right_attach">3</property>
+            <property name="top_attach">6</property>
+            <property name="bottom_attach">7</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xpad">10</property>
+            <property name="label" translatable="yes">Report for printing:</property>
+          </object>
+          <packing>
+            <property name="top_attach">6</property>
+            <property name="bottom_attach">7</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
           <placeholder/>
         </child>
         <child>
@@ -315,6 +350,9 @@
         <child>
           <placeholder/>
         </child>
+        <child>
+          <placeholder/>
+        </child>
       </object>
     </child>
   </object>
@@ -325,4 +363,24 @@
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
+  <object class="GtkListStore" id="liststore_printinvoice">
+    <columns>
+      <!-- column-name item -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Printable Invoice</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Tax Invoice</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Easy Invoice</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Fancy Invoice</col>
+      </row>
+    </data>
+  </object>
 </interface>

Modified: gnucash/trunk/src/business/business-gnome/schemas/apps_gnucash_dialog_business_common.schemas.in
===================================================================
--- gnucash/trunk/src/business/business-gnome/schemas/apps_gnucash_dialog_business_common.schemas.in	2011-12-11 20:39:34 UTC (rev 21714)
+++ gnucash/trunk/src/business/business-gnome/schemas/apps_gnucash_dialog_business_common.schemas.in	2011-12-11 20:59:48 UTC (rev 21715)
@@ -63,6 +63,20 @@
     </schema>
 
     <schema>
+      <key>/schemas/apps/gnucash/dialogs/business/invoice/invoice_printreport</key>
+      <applyto>/apps/gnucash/dialogs/business/invoice/invoice_printreport</applyto>
+      <owner>gnucash</owner>
+      <type>int</type>
+      <default>0</default>
+      <locale name="C">
+        <short>The invoice report to be used for printing</short>
+        <long>
+          The name of the report to be used for invoice printing.
+        </long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/gnucash/dialogs/business/invoice/use_new_window</key>
       <applyto>/apps/gnucash/dialogs/business/invoice/use_new_window</applyto>
       <owner>gnucash</owner>



More information about the gnucash-changes mailing list