r23362 - gnucash/trunk/src - Improve visual appearance and sorting of Invoice payment dialog
Geert Janssens
gjanssens at code.gnucash.org
Thu Oct 31 18:25:08 EDT 2013
Author: gjanssens
Date: 2013-10-31 18:25:03 -0400 (Thu, 31 Oct 2013)
New Revision: 23362
Trac: http://svn.gnucash.org/trac/changeset/23362
Added:
gnucash/trunk/src/gnome-utils/tree-view-utils.c
gnucash/trunk/src/gnome-utils/tree-view-utils.h
Modified:
gnucash/trunk/src/business/business-gnome/dialog-payment.c
gnucash/trunk/src/business/business-gnome/gtkbuilder/dialog-payment.glade
gnucash/trunk/src/engine/gncInvoice.c
gnucash/trunk/src/gnome-utils/Makefile.am
Log:
Improve visual appearance and sorting of Invoice payment dialog
Modified: gnucash/trunk/src/business/business-gnome/dialog-payment.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-payment.c 2013-10-31 22:24:27 UTC (rev 23361)
+++ gnucash/trunk/src/business/business-gnome/dialog-payment.c 2013-10-31 22:25:03 UTC (rev 23362)
@@ -33,11 +33,13 @@
#include "gnc-gui-query.h"
#include "gnc-ui-util.h"
#include "qof.h"
+#include "gnc-date.h"
#include "gnc-date-edit.h"
#include "gnc-amount-edit.h"
#include "gnc-gtk-utils.h"
#include "gnc-prefs.h"
#include "gnc-tree-view-account.h"
+#include "tree-view-utils.h"
#include "Transaction.h"
#include "Account.h"
#include "gncOwner.h"
@@ -287,7 +289,7 @@
for (node = list; node; node = node->next)
{
GNCLot *lot = node->data;
- const gchar *doc_date_str = NULL;
+ time64 doc_date_time = 0;
const gchar *doc_type_str = NULL;
const gchar *doc_id_str = NULL;
const gchar *doc_deb_str = NULL;
@@ -315,7 +317,7 @@
else
continue; /* No valid split in this lot, skip it */
}
- doc_date_str = gnc_print_date (doc_date);
+ doc_date_time = timespecToTime64 (doc_date);
/* Find the document type. No type means pre-payment in this case */
if (document)
@@ -351,7 +353,7 @@
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- 0, doc_date_str,
+ 0, doc_date_time,
1, doc_id_str,
2, doc_type_str,
3, doc_deb_str,
@@ -752,6 +754,27 @@
return (pw != NULL);
}
+static void print_date (GtkTreeViewColumn *tree_column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ GValue value = { 0 };
+ time64 doc_date_time;
+ gchar *doc_date_str;
+
+ g_return_if_fail (cell && iter && tree_model);
+
+
+ gtk_tree_model_get_value (tree_model, iter, 0, &value);
+ doc_date_time = (time64) g_value_get_int64 (&value);
+ g_value_unset (&value);
+ doc_date_str = qof_print_date (doc_date_time);
+ g_object_set (G_OBJECT (cell), "text", doc_date_str, NULL);
+ g_free (doc_date_str);
+}
+
static PaymentWindow *
new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice)
{
@@ -759,6 +782,8 @@
GtkBuilder *builder;
GtkWidget *box, *label, *credit_box, *debit_box;
GtkTreeSelection *selection;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
char * cm_class = (gncOwnerGetType (owner) == GNC_OWNER_CUSTOMER ?
DIALOG_PAYMENT_CUSTOMER_CM_CLASS :
DIALOG_PAYMENT_VENDOR_CM_CLASS);
@@ -862,6 +887,41 @@
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->docs_list_tree_view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ /* Configure date column */
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 0);
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ tree_view_column_set_default_width (GTK_TREE_VIEW (pw->docs_list_tree_view),
+ column, "31-12-2013");
+ gtk_tree_view_column_set_cell_data_func (column, renderer,
+ (GtkTreeCellDataFunc) print_date,
+ NULL, NULL);
+
+ /* Configure document number column */
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 1);
+ tree_view_column_set_default_width (GTK_TREE_VIEW (pw->docs_list_tree_view),
+ column, "INV2013-016");
+
+ /* Configure document type column */
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 2);
+ tree_view_column_set_default_width (GTK_TREE_VIEW (pw->docs_list_tree_view),
+ column, _("Credit Note"));
+
+ /* Configure debit column */
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 3);
+ tree_view_column_set_default_width (GTK_TREE_VIEW (pw->docs_list_tree_view),
+ column, "11,999.00");
+
+ /* Configure credit column */
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 4);
+ tree_view_column_set_default_width (GTK_TREE_VIEW (pw->docs_list_tree_view),
+ column, "11,999.00");
+
+ gtk_tree_sortable_set_sort_column_id (
+ GTK_TREE_SORTABLE (gtk_tree_view_get_model (GTK_TREE_VIEW (pw->docs_list_tree_view))),
+ 0, GTK_SORT_ASCENDING);
+
+
box = GTK_WIDGET (gtk_builder_get_object (builder, "acct_window"));
pw->acct_tree = GTK_WIDGET(gnc_tree_view_account_new (FALSE));
gtk_container_add (GTK_CONTAINER (box), pw->acct_tree);
Modified: gnucash/trunk/src/business/business-gnome/gtkbuilder/dialog-payment.glade
===================================================================
--- gnucash/trunk/src/business/business-gnome/gtkbuilder/dialog-payment.glade 2013-10-31 22:24:27 UTC (rev 23361)
+++ gnucash/trunk/src/business/business-gnome/gtkbuilder/dialog-payment.glade 2013-10-31 22:25:03 UTC (rev 23362)
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.24"/>
+ <!-- interface-naming-policy toplevel-contextual -->
<object class="GtkDialog" id="Payment Dialog">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Process Payment</property>
- <property name="default_height">380</property>
+ <property name="default_height">560</property>
<property name="type_hint">dialog</property>
<signal name="destroy" handler="gnc_payment_window_destroy_cb" swapped="no"/>
<child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox1">
+ <object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
<object class="GtkTable" id="table1">
@@ -38,7 +38,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">The company associated with this payment.</property>
+ <property name="tooltip_markup">The company associated with this payment.</property>
<property name="tooltip_text" translatable="yes">The company associated with this payment.</property>
<property name="border_width">3</property>
<child>
@@ -53,7 +53,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">The company associated with this payment.</property>
+ <property name="tooltip_markup">The company associated with this payment.</property>
<property name="tooltip_text" translatable="yes">The company associated with this payment.</property>
<property name="label" translatable="yes">(owner)</property>
<attributes>
@@ -154,12 +154,6 @@
<property name="clickable">True</property>
<property name="sort_indicator">True</property>
<property name="sort_column_id">0</property>
- <child>
- <object class="GtkCellRendererText" id="docs_list_date_renderer"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
</object>
</child>
<child>
@@ -303,7 +297,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
+ <property name="tooltip_markup">The amount to pay for this invoice.
If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.
@@ -330,7 +324,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
+ <property name="tooltip_markup">The amount to pay for this invoice.
If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.
@@ -356,7 +350,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
+ <property name="tooltip_markup">The amount to pay for this invoice.
If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.
@@ -412,7 +406,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
+ <property name="tooltip_markup">The amount to pay for this invoice.
If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.
@@ -438,7 +432,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
+ <property name="tooltip_markup">The amount to pay for this invoice.
If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.
@@ -492,7 +486,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
+ <property name="tooltip_markup">The amount to pay for this invoice.
If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.
@@ -509,8 +503,8 @@
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
+ <property name="x_options"/>
+ <property name="y_options"/>
<property name="y_padding">3</property>
</packing>
</child>
@@ -519,7 +513,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
+ <property name="tooltip_markup">The amount to pay for this invoice.
If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.
@@ -536,20 +530,11 @@
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
+ <property name="x_options"/>
+ <property name="y_options"/>
<property name="y_padding">3</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
</object>
<packing>
<property name="expand">False</property>
@@ -629,7 +614,7 @@
</packing>
</child>
<child internal-child="action_area">
- <object class="GtkButtonBox" id="dialog-action_area1">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
@@ -640,7 +625,6 @@
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="gnc_payment_cancel_cb" swapped="no"/>
</object>
@@ -657,7 +641,6 @@
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="gnc_payment_ok_cb" swapped="no"/>
</object>
@@ -690,7 +673,7 @@
<object class="GtkListStore" id="docs_list_model">
<columns>
<!-- column-name doc_date -->
- <column type="gchararray"/>
+ <column type="gint64"/>
<!-- column-name doc_id -->
<column type="gchararray"/>
<!-- column-name doc_type -->
Modified: gnucash/trunk/src/engine/gncInvoice.c
===================================================================
--- gnucash/trunk/src/engine/gncInvoice.c 2013-10-31 22:24:27 UTC (rev 23361)
+++ gnucash/trunk/src/engine/gncInvoice.c 2013-10-31 22:25:03 UTC (rev 23362)
@@ -918,11 +918,9 @@
case GNC_INVOICE_EMPL_INVOICE:
return _("Expense");
case GNC_INVOICE_CUST_CREDIT_NOTE:
- return _("Customer Credit Note");
case GNC_INVOICE_VEND_CREDIT_NOTE:
- return _("Vendor Credit Note");
case GNC_INVOICE_EMPL_CREDIT_NOTE:
- return _("Employee Credit Note");
+ return _("Credit Note");
default:
PWARN("Unknown invoice type");
return NULL;
Modified: gnucash/trunk/src/gnome-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome-utils/Makefile.am 2013-10-31 22:24:27 UTC (rev 23361)
+++ gnucash/trunk/src/gnome-utils/Makefile.am 2013-10-31 22:25:03 UTC (rev 23362)
@@ -102,6 +102,7 @@
gnc-window.c \
gncmod-gnome-utils.c \
misc-gnome-utils.c \
+ tree-view-utils.c \
search-param.c \
print-session.c \
swig-gnome-utils.c \
@@ -180,6 +181,7 @@
gnc-ui.h \
gnc-window.h \
misc-gnome-utils.h \
+ tree-view-utils.h \
print-session.h \
window-main-summarybar.h
Added: gnucash/trunk/src/gnome-utils/tree-view-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/tree-view-utils.c (rev 0)
+++ gnucash/trunk/src/gnome-utils/tree-view-utils.c 2013-10-31 22:25:03 UTC (rev 23362)
@@ -0,0 +1,71 @@
+/*
+ * tree-view-utils.c -- some convenience functions for use with
+ * plain GtkTreeViews in situations where a
+ * fully fledged GncTreeView is overkill.
+ * Handy with GtkTreeViews defined in glade files.
+ *
+ * Copyright (C) 2013 Geert Janssens <geert at kobaltwit.be>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation Voice: +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
+ * Boston, MA 02110-1301, USA gnu at gnu.org
+ */
+
+/** @addtogroup GUI
+ @{ */
+/** @addtogroup GncTreeView
+ * @{ */
+/** @file tree-view-utils.c
+ @brief Simple convenience functions for common tasks on GtkTreeViews.
+ @author Geert Janssens <geert at kobaltwit.be>
+*/
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <string.h>
+
+#include "tree-view-utils.h"
+
+void tree_view_column_set_default_width (GtkTreeView *view,
+ GtkTreeViewColumn *column,
+ const gchar *sizing_text)
+{
+ PangoLayout* layout;
+ int default_width, title_width;
+ const gchar *column_title;
+
+ /* Default size is the larger of the column title and the sizing text */
+ column_title = gtk_tree_view_column_get_title (column);
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), column_title);
+ pango_layout_get_pixel_size(layout, &title_width, NULL);
+ g_object_unref(layout);
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), sizing_text);
+ pango_layout_get_pixel_size(layout, &default_width, NULL);
+ g_object_unref(layout);
+ default_width = MAX(default_width, title_width);
+ if (default_width)
+ {
+ default_width += 10; /* add some padding */
+ g_object_set(G_OBJECT(column),
+ "sizing", GTK_TREE_VIEW_COLUMN_FIXED,
+ "fixed-width", default_width,
+ NULL);
+ }
+}
+
+/** @} */
+/** @} */
Added: gnucash/trunk/src/gnome-utils/tree-view-utils.h
===================================================================
--- gnucash/trunk/src/gnome-utils/tree-view-utils.h (rev 0)
+++ gnucash/trunk/src/gnome-utils/tree-view-utils.h 2013-10-31 22:25:03 UTC (rev 23362)
@@ -0,0 +1,56 @@
+/*
+ * tree-view-utils.c -- some convenience functions for use with
+ * plain GtkTreeViews in situations where a
+ * fully fledged GncTreeView is overkill.
+ * Handy with GtkTreeViews defined in glade files.
+ *
+ * Copyright (C) 2013 Geert Janssens <geert at kobaltwit.be>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation Voice: +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
+ * Boston, MA 02110-1301, USA gnu at gnu.org
+ */
+
+/** @addtogroup GUI
+ @{ */
+/** @addtogroup GncTreeView
+ * @{ */
+/** @file tree-view-utils.c
+ @brief Simple convenience functions for common tasks on GtkTreeViews.
+ @author Geert Janssens <geert at kobaltwit.be>
+*/
+
+#ifndef TREE_VIEW_UTILS_H_
+#define TREE_VIEW_UTILS_H_
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <string.h>
+
+/** Set default width for a treeview column. This base width
+ * is the largest of the column title and some arbitrary
+ * text passed in via sizing_text. This base width is then
+ * increased with some padding.
+ */
+void tree_view_column_set_default_width (GtkTreeView *view,
+ GtkTreeViewColumn *column,
+ const gchar *sizing_text);
+
+/** @} */
+/** @} */
+
+#endif /* TREE_VIEW_UTILS_H_ */
More information about the gnucash-changes
mailing list