r20279 - gnucash/trunk/src - Add address auto-completion of r20272 also for address line 4.
Christian Stimming
cstim at code.gnucash.org
Sat Feb 12 10:18:46 EST 2011
Author: cstim
Date: 2011-02-12 10:18:46 -0500 (Sat, 12 Feb 2011)
New Revision: 20279
Trac: http://svn.gnucash.org/trac/changeset/20279
Modified:
gnucash/trunk/src/app-utils/gnc-addr-quickfill.c
gnucash/trunk/src/app-utils/gnc-addr-quickfill.h
gnucash/trunk/src/business/business-gnome/dialog-customer.c
gnucash/trunk/src/business/business-gnome/glade/customer.glade
Log:
Add address auto-completion of r20272 also for address line 4.
Modified: gnucash/trunk/src/app-utils/gnc-addr-quickfill.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-addr-quickfill.c 2011-02-12 14:49:09 UTC (rev 20278)
+++ gnucash/trunk/src/app-utils/gnc-addr-quickfill.c 2011-02-12 15:18:46 UTC (rev 20279)
@@ -34,6 +34,7 @@
{
QuickFill *qf_addr2;
QuickFill *qf_addr3;
+ QuickFill *qf_addr4;
QuickFillSort qf_sort;
QofBook *book;
gint listener;
@@ -44,7 +45,7 @@
gpointer user_data, gpointer event_data)
{
AddressQF *qfb = user_data;
- const char *addr2, *addr3;
+ const char *addr2, *addr3, *addr4;
/* We only listen for GncAddress events */
if (!GNC_IS_ADDRESS (entity))
@@ -61,6 +62,7 @@
addr2 = gncAddressGetAddr2(GNC_ADDRESS(entity));
addr3 = gncAddressGetAddr3(GNC_ADDRESS(entity));
+ addr4 = gncAddressGetAddr4(GNC_ADDRESS(entity));
if (event_type & QOF_EVENT_MODIFY)
{
/* If the description was changed into something non-empty, so
@@ -75,6 +77,11 @@
/* Add the new string to the quickfill */
gnc_quickfill_insert (qfb->qf_addr3, addr3, QUICKFILL_LIFO);
}
+ if (addr4 && strlen(addr4) > 0)
+ {
+ /* Add the new string to the quickfill */
+ gnc_quickfill_insert (qfb->qf_addr4, addr4, QUICKFILL_LIFO);
+ }
}
else if (event_type & QOF_EVENT_DESTROY)
{
@@ -88,6 +95,11 @@
/* Remove the description from the quickfill */
gnc_quickfill_insert (qfb->qf_addr3, addr3, QUICKFILL_LIFO);
}
+ if (addr4 && strlen(addr4) > 0)
+ {
+ /* Remove the description from the quickfill */
+ gnc_quickfill_insert (qfb->qf_addr4, addr4, QUICKFILL_LIFO);
+ }
}
}
@@ -97,6 +109,7 @@
AddressQF *qfb = user_data;
gnc_quickfill_destroy (qfb->qf_addr2);
gnc_quickfill_destroy (qfb->qf_addr3);
+ gnc_quickfill_destroy (qfb->qf_addr4);
qof_event_unregister_handler (qfb->listener);
g_free (qfb);
}
@@ -113,6 +126,10 @@
gnc_quickfill_insert (s->qf_addr3,
gncAddressGetAddr3(address),
s->qf_sort);
+
+ gnc_quickfill_insert (s->qf_addr4,
+ gncAddressGetAddr4(address),
+ s->qf_sort);
}
/** Creates a new query that searches for all GncAddress items in the
@@ -141,7 +158,8 @@
result->qf_addr2 = gnc_quickfill_new();
result->qf_addr3 = gnc_quickfill_new();
- result->qf_sort = QUICKFILL_LIFO;
+ result->qf_addr4 = gnc_quickfill_new();
+ result->qf_sort = QUICKFILL_ALPHA;
result->book = book;
g_list_foreach (entries, address_cb, result);
@@ -190,3 +208,20 @@
return qfb->qf_addr3;
}
+
+QuickFill * gnc_get_shared_address_addr4_quickfill (QofBook *book, const char * key)
+{
+ AddressQF *qfb;
+
+ g_assert(book);
+ g_assert(key);
+
+ qfb = qof_book_get_data (book, key);
+
+ if (!qfb)
+ {
+ qfb = build_shared_quickfill(book, key);
+ }
+
+ return qfb->qf_addr4;
+}
Modified: gnucash/trunk/src/app-utils/gnc-addr-quickfill.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-addr-quickfill.h 2011-02-12 14:49:09 UTC (rev 20278)
+++ gnucash/trunk/src/app-utils/gnc-addr-quickfill.h 2011-02-12 15:18:46 UTC (rev 20279)
@@ -65,6 +65,16 @@
QuickFill * gnc_get_shared_address_addr3_quickfill (QofBook *book,
const char * key);
+/** Create/fetch a quickfill GncAddress description strings on the
+ * Addr4 part.
+ *
+ * Identical to gnc_get_shared_address_addr2_quickfill(). You should
+ * also use the same key as for the other function because the
+ * internal quickfills are updated simultaneously.
+ */
+QuickFill * gnc_get_shared_address_addr4_quickfill (QofBook *book,
+ const char * key);
+
#endif
/** @} */
Modified: gnucash/trunk/src/business/business-gnome/dialog-customer.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-customer.c 2011-02-12 14:49:09 UTC (rev 20278)
+++ gnucash/trunk/src/business/business-gnome/dialog-customer.c 2011-02-12 15:18:46 UTC (rev 20279)
@@ -71,12 +71,18 @@
void gnc_customer_addr3_insert_cb(GtkEditable *editable,
gchar *new_text, gint new_text_length,
gint *position, gpointer user_data);
+void gnc_customer_addr4_insert_cb(GtkEditable *editable,
+ gchar *new_text, gint new_text_length,
+ gint *position, gpointer user_data);
void gnc_customer_shipaddr2_insert_cb(GtkEditable *editable,
gchar *new_text, gint new_text_length,
gint *position, gpointer user_data);
void gnc_customer_shipaddr3_insert_cb(GtkEditable *editable,
gchar *new_text, gint new_text_length,
gint *position, gpointer user_data);
+void gnc_customer_shipaddr4_insert_cb(GtkEditable *editable,
+ gchar *new_text, gint new_text_length,
+ gint *position, gpointer user_data);
gboolean
gnc_customer_addr2_key_press_cb( GtkEntry *entry, GdkEventKey *event,
gpointer user_data );
@@ -84,11 +90,17 @@
gnc_customer_addr3_key_press_cb( GtkEntry *entry, GdkEventKey *event,
gpointer user_data );
gboolean
+gnc_customer_addr4_key_press_cb( GtkEntry *entry, GdkEventKey *event,
+ gpointer user_data );
+gboolean
gnc_customer_shipaddr2_key_press_cb( GtkEntry *entry, GdkEventKey *event,
gpointer user_data );
gboolean
gnc_customer_shipaddr3_key_press_cb( GtkEntry *entry, GdkEventKey *event,
gpointer user_data );
+gboolean
+gnc_customer_shipaddr4_key_press_cb( GtkEntry *entry, GdkEventKey *event,
+ gpointer user_data );
#define ADDR_QUICKFILL "GncAddress-Quickfill"
@@ -153,11 +165,11 @@
/* stored data for the description quickfill selection function */
QuickFill *addr2_quickfill;
+ QuickFill *addr3_quickfill;
+ QuickFill *addr4_quickfill;
gint addrX_start_selection;
gint addrX_end_selection;
guint addrX_selection_source_id;
-
- QuickFill *addr3_quickfill;
};
void
@@ -672,6 +684,7 @@
/* Set up the addr line quickfill */
cw->addr2_quickfill = gnc_get_shared_address_addr2_quickfill(cw->book, ADDR_QUICKFILL);
cw->addr3_quickfill = gnc_get_shared_address_addr3_quickfill(cw->book, ADDR_QUICKFILL);
+ cw->addr4_quickfill = gnc_get_shared_address_addr4_quickfill(cw->book, ADDR_QUICKFILL);
/* Set the Discount, and Credit amounts */
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->discount_amount),
@@ -946,7 +959,19 @@
wdata->addrX_selection_source_id = 0;
return FALSE;
}
+static gboolean
+idle_select_region_addr4(gpointer user_data)
+{
+ CustomerWindow *wdata = user_data;
+ g_return_val_if_fail(user_data, FALSE);
+ gtk_editable_select_region(GTK_EDITABLE(wdata->addr4_entry),
+ wdata->addrX_start_selection,
+ wdata->addrX_end_selection);
+ wdata->addrX_selection_source_id = 0;
+ return FALSE;
+}
+
static gboolean
idle_select_region_shipaddr2(gpointer user_data)
{
@@ -974,7 +999,19 @@
wdata->addrX_selection_source_id = 0;
return FALSE;
}
+static gboolean
+idle_select_region_shipaddr4(gpointer user_data)
+{
+ CustomerWindow *wdata = user_data;
+ g_return_val_if_fail(user_data, FALSE);
+ gtk_editable_select_region(GTK_EDITABLE(wdata->shipaddr4_entry),
+ wdata->addrX_start_selection,
+ wdata->addrX_end_selection);
+ wdata->addrX_selection_source_id = 0;
+ return FALSE;
+}
+
/* Implementation of the steps common to all address lines. Returns
* TRUE if anything was inserted by quickfill, otherwise FALSE. */
static gboolean
@@ -1095,6 +1132,26 @@
}
}
+void gnc_customer_addr4_insert_cb(GtkEditable *editable,
+ gchar *new_text, gint new_text_length,
+ gint *position, gpointer user_data)
+{
+ CustomerWindow *wdata = user_data;
+ gboolean r;
+
+ /* The handling common to all address lines is done in this other
+ * function. */
+ r = gnc_customer_addr_common_insert_cb(editable, new_text, new_text_length,
+ position, user_data, wdata->addr4_quickfill);
+
+ /* Did we insert something? Then set up the correct idle handler */
+ if (r)
+ {
+ wdata->addrX_selection_source_id = g_idle_add(idle_select_region_addr4,
+ user_data);
+ }
+}
+
void gnc_customer_shipaddr2_insert_cb(GtkEditable *editable,
gchar *new_text, gint new_text_length,
gint *position, gpointer user_data)
@@ -1135,6 +1192,26 @@
}
}
+void gnc_customer_shipaddr4_insert_cb(GtkEditable *editable,
+ gchar *new_text, gint new_text_length,
+ gint *position, gpointer user_data)
+{
+ CustomerWindow *wdata = user_data;
+ gboolean r;
+
+ /* The handling common to all address lines is done in this other
+ * function. */
+ r = gnc_customer_addr_common_insert_cb(editable, new_text, new_text_length,
+ position, user_data, wdata->addr4_quickfill);
+
+ /* Did we insert something? Then set up the correct idle handler */
+ if (r)
+ {
+ wdata->addrX_selection_source_id = g_idle_add(idle_select_region_shipaddr4,
+ user_data);
+ }
+}
+
static gboolean
gnc_customer_common_key_press_cb( GtkEntry *entry,
GdkEventKey *event,
@@ -1183,6 +1260,15 @@
wdata->addr3_entry);
}
gboolean
+gnc_customer_addr4_key_press_cb( GtkEntry *entry,
+ GdkEventKey *event,
+ gpointer user_data )
+{
+ CustomerWindow *wdata = user_data;
+ return gnc_customer_common_key_press_cb(entry, event, user_data,
+ wdata->addr4_entry);
+}
+gboolean
gnc_customer_shipaddr2_key_press_cb( GtkEntry *entry,
GdkEventKey *event,
gpointer user_data )
@@ -1200,3 +1286,12 @@
return gnc_customer_common_key_press_cb(entry, event, user_data,
wdata->shipaddr3_entry);
}
+gboolean
+gnc_customer_shipaddr4_key_press_cb( GtkEntry *entry,
+ GdkEventKey *event,
+ gpointer user_data )
+{
+ CustomerWindow *wdata = user_data;
+ return gnc_customer_common_key_press_cb(entry, event, user_data,
+ wdata->shipaddr4_entry);
+}
Modified: gnucash/trunk/src/business/business-gnome/glade/customer.glade
===================================================================
--- gnucash/trunk/src/business/business-gnome/glade/customer.glade 2011-02-12 14:49:09 UTC (rev 20278)
+++ gnucash/trunk/src/business/business-gnome/glade/customer.glade 2011-02-12 15:18:46 UTC (rev 20279)
@@ -331,6 +331,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
+ <signal name="insert_text" handler="gnc_customer_addr4_insert_cb"/>
+ <signal name="key_press_event" handler="gnc_customer_addr4_key_press_cb"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -911,6 +913,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
+ <signal name="insert_text" handler="gnc_customer_shipaddr4_insert_cb"/>
+ <signal name="key_press_event" handler="gnc_customer_shipaddr4_key_press_cb"/>
</widget>
<packing>
<property name="expand">False</property>
More information about the gnucash-changes
mailing list