question for gtk gurus

Dave Peticolas dave@krondo.com
Mon, 07 May 2001 00:36:49 -0700


Kevin Finn writes:
>      I'm interested in adding quickfill capability to the transfer
> dialog (based on the Description field), because that would make things
> just that much more convenient when using the automatic credit card
> payment transfers (and ultimately I would like to add an automatic
> interest transfer at the beginning of reconciliation of bank statements,
> credit card statements, etc., but that's off in the future).  I've
> liberally copied the quickfill code from:
> 
> gnucash-sheet.c (gnucash_sheet_insert_cb/delete_cb)
> table-allgui.c (gnc_table_modify_update)
> quickfillcell.c (quick_modify)
> 
> and it almost works.  That is, if I type the first character of a
> matchable description into the Description entry, the rest of the word
> is added, the remaining letters are selected, and the cursor is moved
> appropriately, just like quickfill in the register.  However, if I type
> a second letter, the selection isn't added and the cursor isn't moved. 
> As far as I can tell, I am using gtk_entry_select_region and
> gtk_entry_set_position correctly, and checking the entry afterwards does
> indicate that the text is selected, even though it doesn't appear to be.
> 
>      What I'm doing is listed below, are there any gotchas that I'm
> missing?  I can post the whole thing if that would help, I haven't done
> so now because it's full of printfs and would need some cleanup.
> 
>      Thanks for any ideas, I think I'm really close to getting this to
> work.

IIRC, one of the things that the register code depends upon is that
the gtk entry widget used to handle most of the editing functionality
is never realized, and an unrealized entry widget doesn't mess with
with the highlited region. However, a realized entry widget will munge
any region changes you make during the insert callback.

What you might try is also connecting to the entry's key press
signal using *connect_after and fixing up the selection, but only
if you changed it during the insert text signal.

dave