question for gtk gurus

Kevin Finn
Sun, 06 May 2001 23:21:20 -0500

     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



  if( ( match = gnc_quickfill_get_string_match( xferData->qf, new_text_w
) )
   && ( match_str = gnc_quickfill_string( match ) )
   && safe_strcmp( new_text, old_text ) )
                gtk_signal_handler_block (GTK_OBJECT (entry),

                gtk_signal_handler_block (GTK_OBJECT (entry),

                gtk_entry_set_text( entry, match_str );

                gtk_signal_handler_unblock (GTK_OBJECT (entry),

                gtk_signal_handler_unblock (GTK_OBJECT (entry),

    /* stop the current insert */
    gtk_signal_emit_stop_by_name( GTK_OBJECT( entry ), "insert_text" );
    gtk_editable_set_position( GTK_EDITABLE(entry), new_text_len );
    gtk_entry_select_region( entry, new_text_len, -1 );

    /* this printf indicates that the widget has the right
       text selected, even though it doesn't appear so on the 
       screen. */
    printf("gnc_xfer_description_insert_cb end: selected %d %d\n",
        GTK_EDITABLE(entry)->selection_end_pos );


Kevin Finn