[Gnucash-changes] r11891 - gnucash/trunk - Scott Oonk's patch to simplify the mouse selection logic in

David Hampton hampton at cvs.gnucash.org
Wed Nov 9 17:34:27 EST 2005


Author: hampton
Date: 2005-11-09 17:34:26 -0500 (Wed, 09 Nov 2005)
New Revision: 11891

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c
   gnucash/trunk/src/register/register-gnome/gnucash-item-edit.h
Log:
Scott Oonk's patch to simplify the mouse selection logic in
gnucash-item-edit.  It also fixes a problem where selection with the
mouse does not work correctly if you start draging in one direction,
then drag back over the original start point.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2005-11-09 20:51:03 UTC (rev 11890)
+++ gnucash/trunk/ChangeLog	2005-11-09 22:34:26 UTC (rev 11891)
@@ -1,3 +1,11 @@
+2005-11-09  Scott Oonk  <scott.oonk at gmail.com>
+
+	* src/register/register-gnome/gnucash-item-edit.[ch]: This patch
+	simplifies the mouse selection logic in gnucash-item-edit.  It
+	also fixes a problem where selection with the mouse does not work
+	correctly if you start draging in one direction, then drag back
+	over the original start point.
+
 2005-11-09  Christian Stimming  <stimming at tuhh.de>
 
 	* macros/autogen.sh: Remove the automatic call to ./configure from

Modified: gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c	2005-11-09 20:51:03 UTC (rev 11890)
+++ gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c	2005-11-09 22:34:26 UTC (rev 11891)
@@ -765,68 +765,12 @@
 
         if (extend_selection)
         {
-                // Setting the selection-range on the GtkEditable implicitly
-                // sets the `position` to the end of the range; this is
-                // unfortunate if you're setting and using the `position` to
-                // be at the end or beginning of the selection range to
-                // discriminate the forward- or reverse- nature of the
-                // dragging.  Now we just keep even-more-explicit enumeration
-                // of the selection-direction. -- jsled, Mar 2005, Gnome2 port
-
-                gboolean selection_exists;
-                gint current_pos, start_sel, end_sel, orig_start, orig_end;
-
-                current_pos = gtk_editable_get_position (editable);
-		selection_exists = gtk_editable_get_selection_bounds (editable, &start_sel, &end_sel);
-                orig_start = start_sel;
-                orig_end = end_sel;
-
-                if ( item_edit->selection_dir == UNKNOWN && start_sel == end_sel )
-                {
-                        start_sel = current_pos;
-                        end_sel = pos;
-                }
-
-                // determine direction
-                if ( item_edit->selection_dir == UNKNOWN )
-                {
-                        if ( pos < start_sel )
-                        {
-                                item_edit->selection_dir = REVERSE;
-                        }
-                        else if ( pos > end_sel )
-                        {
-                                item_edit->selection_dir = FORWARD;
-                        }
-                }
-
-                // act accordingly
-                if ( item_edit->selection_dir == FORWARD )
-                {
-                        end_sel = pos;
-                }
-                else if ( item_edit->selection_dir == REVERSE )
-                {
-                        start_sel = pos;
-                }
-                else
-                {
-                        // @@FIXME : don't printf... so ghetto.
-                        printf( "unknown, but with movement\n" );
-                }
-
-                gtk_editable_set_position (editable, pos);
-
-                gtk_editable_select_region(editable, start_sel, end_sel);
-
-                pos = gtk_editable_get_position (editable);
-                selection_exists = gtk_editable_get_selection_bounds (editable, &start_sel, &end_sel);
+                gtk_editable_select_region (editable, item_edit->anchor_pos, pos);
         }
         else
         {
-                gtk_editable_select_region(editable, 0, 0);
                 gtk_editable_set_position (editable, pos);
-                item_edit->selection_dir = UNKNOWN;
+                item_edit->anchor_pos = pos;
         }
 
         queue_sync (item_edit);

Modified: gnucash/trunk/src/register/register-gnome/gnucash-item-edit.h
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-item-edit.h	2005-11-09 20:51:03 UTC (rev 11890)
+++ gnucash/trunk/src/register/register-gnome/gnucash-item-edit.h	2005-11-09 22:34:26 UTC (rev 11891)
@@ -103,9 +103,8 @@
 
         gboolean reset_pos;
         gint x_offset;
+        gint anchor_pos;
 
-        enum { UNKNOWN, FORWARD, REVERSE } selection_dir;
-
         /* Where are we */
         VirtualLocation virt_loc;
 



More information about the gnucash-changes mailing list