A model/buffer for GtkEntry



A while back [1] I tackled the possibility of having GtkEntry store it's
text in a application configurable memory buffer. This makes GtkEntry
very useful for use with gnome-keyring and seahorse passwords/secrets [2].

I've given it another shot, and come up with what I think is a much
better approach. I've implemented a GtkEntryBuffer class (or
GtkEntryModel) which segregates all the text storage and conversion to
displayable text.

A rough outline to give an idea:

GtkEntryBuffer signals
 * inserted_text
 * deleted_text

GtkEntryBuffer virtual methods
 * get_text
 * get_length
 * insert_text
 * delete_text

GtkEntryBuffer functions:
 * gtk_entry_buffer_new
 * gtk_entry_buffer_get_bytes
 * gtk_entry_buffer_get_length
 * gtk_entry_buffer_get_text
 * gtk_entry_buffer_set_text
 * gtk_entry_buffer_get_display_text
 * gtk_entry_buffer_get_display_length
 * gtk_entry_buffer_get_display_mode
 * gtk_entry_buffer_set_max_length
 * gtk_entry_buffer_get_max_length
 * gtk_entry_buffer_insert_text
 * gtk_entry_buffer_delete_text
 * gtk_entry_buffer_get_visibility
 * gtk_entry_buffer_set_visibility
 * gtk_entry_buffer_get_invisible_char
 * gtk_entry_buffer_set_invisible_char
 * gtk_entry_buffer_unset_invisible_char
 * gtk_entry_buffer_have_invisible_char

Some questions/points I'd love to have advice on:

1. I think that abstracting out the text storage of GtkEntry is the
right way forward. Does that seem right?

2. Naming: GtkEntryModel or GtkEntryBuffer?

3. As hinted at by the above functions, this moves the conversion to
displayable text into the GtkEntryBuffer class. This helps remove tons
of 'entry->visible' cases in GtkEntry and cleans up the code a whole lot.

4. Interface vs. Subclass: I found that a subclass is far more useful
in this case.

5. GtkEntryBuffer can be used directly, or can be derived from. The
default implementation of the virtual methods acts exactly as one would
expect from GtkEntry.

6. Various properties that were on GtkEntry are now on GtkEntryModel.
Leaving temporary wrappers in GtkEntry is pretty easy. Would we mark
them deprecated? That includes:

gtk_entry_set_visibility
gtk_entry_get_visibility
gtk_entry_set_invisible_char
gtk_entry_get_invisible_char
gtk_entry_unset_invisible_char
gtk_entry_set_max_length
gtk_entry_get_max_length

I imagine these would live on as convenience functions (and maybe some
of the above):

gtk_entry_set_text
gtk_entry_get_text_length
gtk_entry_get_text

Bug report filed here with some initial rough patches:

http://bugzilla.gnome.org/show_bug.cgi?id=576801


Anything else I'm missing?

Cheers,

Stef



[1] http://mail.gnome.org/archives/gtk-devel-list/2009-March/msg00000.html

[2]
http://mail.gnome.org/archives/gnome-keyring-list/2009-January/msg00003.html



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]