r20275 - gnucash/trunk/src/business/business-gnome - Fix r20272: The text selection after auto-completion should work correctly now.

Christian Stimming cstim at code.gnucash.org
Sat Feb 12 04:46:58 EST 2011


Author: cstim
Date: 2011-02-12 04:46:57 -0500 (Sat, 12 Feb 2011)
New Revision: 20275
Trac: http://svn.gnucash.org/trac/changeset/20275

Modified:
   gnucash/trunk/src/business/business-gnome/dialog-customer.c
Log:
Fix r20272: The text selection after auto-completion should work correctly now.

Modified: gnucash/trunk/src/business/business-gnome/dialog-customer.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-customer.c	2011-02-11 13:40:08 UTC (rev 20274)
+++ gnucash/trunk/src/business/business-gnome/dialog-customer.c	2011-02-12 09:46:57 UTC (rev 20275)
@@ -153,14 +153,11 @@
 
     /* stored data for the description quickfill selection function */
     QuickFill *addr2_quickfill;
-    gint addr2_start_selection;
-    gint addr2_end_selection;
-    guint addr2_selection_source_id;
+    gint addrX_start_selection;
+    gint addrX_end_selection;
+    guint addrX_selection_source_id;
 
     QuickFill *addr3_quickfill;
-    gint addr3_start_selection;
-    gint addr3_end_selection;
-    guint addr3_selection_source_id;
 };
 
 void
@@ -393,10 +390,8 @@
         cw->customer_guid = *guid_null ();
     }
 
-    if (cw->addr2_selection_source_id)
-        g_source_remove (cw->addr2_selection_source_id);
-    if (cw->addr3_selection_source_id)
-        g_source_remove (cw->addr3_selection_source_id);
+    if (cw->addrX_selection_source_id)
+        g_source_remove (cw->addrX_selection_source_id);
 
     gnc_unregister_gui_component (cw->component_id);
     gnc_resume_gui_refresh ();
@@ -928,11 +923,13 @@
     CustomerWindow *wdata = user_data;
     g_return_val_if_fail(user_data, FALSE);
 
+    /* g_warning("Selection start=%d end=%d",wdata->addrX_start_selection, wdata->addrX_end_selection); */
+
     gtk_editable_select_region(GTK_EDITABLE(wdata->addr2_entry),
-                               wdata->addr2_start_selection,
-                               wdata->addr2_end_selection);
+                               wdata->addrX_start_selection,
+                               wdata->addrX_end_selection);
 
-    wdata->addr2_selection_source_id = 0;
+    wdata->addrX_selection_source_id = 0;
     return FALSE;
 }
 
@@ -943,10 +940,10 @@
     g_return_val_if_fail(user_data, FALSE);
 
     gtk_editable_select_region(GTK_EDITABLE(wdata->addr3_entry),
-                               wdata->addr3_start_selection,
-                               wdata->addr3_end_selection);
+                               wdata->addrX_start_selection,
+                               wdata->addrX_end_selection);
 
-    wdata->addr3_selection_source_id = 0;
+    wdata->addrX_selection_source_id = 0;
     return FALSE;
 }
 
@@ -957,10 +954,10 @@
     g_return_val_if_fail(user_data, FALSE);
 
     gtk_editable_select_region(GTK_EDITABLE(wdata->shipaddr2_entry),
-                               wdata->addr2_start_selection,
-                               wdata->addr2_end_selection);
+                               wdata->addrX_start_selection,
+                               wdata->addrX_end_selection);
 
-    wdata->addr2_selection_source_id = 0;
+    wdata->addrX_selection_source_id = 0;
     return FALSE;
 }
 
@@ -971,10 +968,10 @@
     g_return_val_if_fail(user_data, FALSE);
 
     gtk_editable_select_region(GTK_EDITABLE(wdata->shipaddr3_entry),
-                               wdata->addr3_start_selection,
-                               wdata->addr3_end_selection);
+                               wdata->addrX_start_selection,
+                               wdata->addrX_end_selection);
 
-    wdata->addr3_selection_source_id = 0;
+    wdata->addrX_selection_source_id = 0;
     return FALSE;
 }
 
@@ -1025,6 +1022,8 @@
             gint match_str_len = strlen(match_str);
             if (match_str_len > concatenated_text_len)
             {
+                /* g_warning("Got match \"%s\" match_str_len=%d new_text=%s position=%d prefix_len=%d", match_str, match_str_len, new_text, *position, prefix_len); */
+
                 g_signal_handlers_block_matched (G_OBJECT (editable),
                                                  G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, user_data);
 
@@ -1040,8 +1039,13 @@
                 g_signal_stop_emission_by_name (G_OBJECT (editable), "insert_text");
 
                 /* set the position */
-                *position = g_utf8_strlen(concatenated_text, -1);
+                *position = concatenated_text_len;
 
+                /* select region on idle, because it would be reset once this function
+                   finishes */
+                wdata->addrX_start_selection = *position;
+                wdata->addrX_end_selection = -1;
+
                 return TRUE;
             }
         }
@@ -1066,9 +1070,7 @@
     {
         /* select region on idle, because it would be reset once this function
            finishes */
-        wdata->addr2_start_selection = *position;
-        wdata->addr2_end_selection = -1;
-        wdata->addr2_selection_source_id = g_idle_add(idle_select_region_addr2,
+        wdata->addrX_selection_source_id = g_idle_add(idle_select_region_addr2,
                                            user_data);
     }
 }
@@ -1088,9 +1090,7 @@
     /* Did we insert something? Then set up the correct idle handler */
     if (r)
     {
-        wdata->addr3_start_selection = *position;
-        wdata->addr3_end_selection = -1;
-        wdata->addr3_selection_source_id = g_idle_add(idle_select_region_addr3,
+        wdata->addrX_selection_source_id = g_idle_add(idle_select_region_addr3,
                                            user_data);
     }
 }
@@ -1110,9 +1110,7 @@
     /* Did we insert something? Then set up the correct idle handler */
     if (r)
     {
-        wdata->addr2_start_selection = *position;
-        wdata->addr2_end_selection = -1;
-        wdata->addr2_selection_source_id = g_idle_add(idle_select_region_shipaddr2,
+        wdata->addrX_selection_source_id = g_idle_add(idle_select_region_shipaddr2,
                                            user_data);
     }
 }
@@ -1132,9 +1130,7 @@
     /* Did we insert something? Then set up the correct idle handler */
     if (r)
     {
-        wdata->addr3_start_selection = *position;
-        wdata->addr3_end_selection = -1;
-        wdata->addr3_selection_source_id = g_idle_add(idle_select_region_shipaddr3,
+        wdata->addrX_selection_source_id = g_idle_add(idle_select_region_shipaddr3,
                                            user_data);
     }
 }



More information about the gnucash-changes mailing list