Re: GtkEntry placeholder in GTK2

2016-11-14 Thread Colomban Wendling
Hi,

Le 14/11/2016 à 14:30, Gabriele Greco a écrit :
> I know GTK 3.2+ has a nice gtk_entry_set_placeholder_text() method, but I'm
> wondering if there is some clever method to do something similar with GTK2,
> I've not found anything googling around, but placeholder texts are a so
> common interface concept today that I doubt that someone has not yet
> "emulated" it in gtk2...

I wrote something like that ages ago, you can find it there:
https://github.com/b4n/gvg/blob/master/src/gvg-entry.c

I haven't touched this for ages though, but IIRC it worked nicely.

Hope it helps,
Colomban
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GtkEntry placeholder in GTK2

2016-11-14 Thread Gabriele Greco
Hello,

I know GTK 3.2+ has a nice gtk_entry_set_placeholder_text() method, but I'm
wondering if there is some clever method to do something similar with GTK2,
I've not found anything googling around, but placeholder texts are a so
common interface concept today that I doubt that someone has not yet
"emulated" it in gtk2...

If no one has already done it, I think this could work:

- initialize the widget with placeholder text
- set a user data on the widget telling the text is placeholder
- set the color of the foreground text for this text widget to gray
- add a focus in event and a on change event on the widget
- if focus in and user data == placeholder, erase the text, save it in
another user data, remove the custom style from the gtkentry
- if on changed and result text empty reload the placeholder text and
switch the style
- if on changed and previous text was empty clear the placeholder text and
switch the style

I wonder if this can work... I can also build a subclass string with this
behaviour since I need this in a few different places :(

-- 
*Bye,*
* Gabry*
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list