Re: Hinting GtkEntry



Qui, 2007-05-24 �15:27 +0100, Ross Burton escreveu:
> Hi,
> 
> Several applications have GtkEntry classes which show a message in faded
> text when the entry is normally empty and disabled, wiping it when the
> entry is focused (as an example see the search bar in Evolution).
> 
Hello,

 A feature I would also like to see on GtkEntry is the possibility to
have a GdkWindow created on the sides at demand, as GtkTextView allows
(maybe just at left and right though). This would make doing a search
entry, and other less common entries (like the goto-line from gedit),
much easier to do; as you'd only have to overload expose and
button-press events for those windows.

 Currently, search entry widgets are mostly done by hacks. eg: Banshee
(SVN) inherits a GtkHBox, placing a non-framed GtkEntry in the middle,
and then draws the frame at the GtkHBox's expose (there is some
additional hackery for those styles without interior-focus). I dunno how
Evolution works, but you get two focus when using a style without
interior-focus, so... Others don't even try to draw GtkEntry frame at
all.

 Since, the inner text window is public, you can already sub-class
GtkEntry and implement this feature at your application level. But this
is quite some work, so people will just hack it through, resulting in
search entries that look and feel different (and broken on exotic
styles). For an example of an implementation of this feature, see
YGtkExtEntry:
https://forgesvn1.novell.com/svn/yast/trunk/gtk/src/ygtkfindentry.h
https://forgesvn1.novell.com/svn/yast/trunk/gtk/src/ygtkfindentry.c

 If there is interest in this feature, let me know, and I will work on a
patch for it. I would suggest the methods to be based on GtkTextView's:

/* Possibly, we could re-use GtkTextWindowType if we also want to
   allow windows at the top and bottom. */
typedef enum {
  GTK_ENTRY_WINDOW_WIDGET, GTK_ENTRY_WINDOW_TEXT,
  GTK_ENTRY_WINDOW_LEFT,   GTK_ENTRY_WINDOW_RIGHT
} GtkEntryWindowType;

GdkWindow* gtk_entry_get_window (GtkEntry *entry,
                                 GtkEntryWindowType win);
GtkEntryWindowType gtk_entry_get_window_type
                                            (GtkEntry *entry,
                                             GdkWindow *window);
/* Passing size > 0 would create the window, if it doesn't exist yet.
   size == 0, destroys the window, if one exists. */
void gtk_entry_set_border_window_size (GtkEntry *entry,
                                       GtkEntryWindowType type,
                                       gint size);
gint gtk_entry_get_border_window_size (GtkEntry *entry,
                                       GtkEntryWindowType type);

Cheers,
 Ricardo

> I've made a simple subclass of GtkEntry which does this for Tasks, but
> is there any interest of adding this as a "hint" property to GtkEntry in
> GTK+ instead?
> 
> Ross




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