Re: changing font, color, size, etc. in a GtkEntry
- From: Eric Wajnberg <eric wajnberg sophia inra fr>
- To: gtk-app-devel-list gnome org
- Subject: Re: changing font, color, size, etc. in a GtkEntry
- Date: Wed, 06 Nov 2013 08:14:37 +0100
Thanks Michael,
This is indeed the sort of solutions I've tried.
However, as I've mentioned in my original post, functions like
pango_font_description_from_string, etc. are not recognized in my coding
environment (while I can define pointer to things like
PangoFontDescription without problem).
This looks weird to me. Is there some specific libraries or headers I
have to load or declare before? Or are these fonctions available on GTK
3 only, and - if yes - what can I do, then?
(I am coding on Windows with CodeBlocks 12.11 and GTK 2.24.0).
Any help on this will be welcomed!
Cheers, Eric.
Michael Cronenworth wrote, On 05/11/2013 17:15,
Eric Wajnberg wrote:
I simply want to modify the font, color, size, etc. of the characters
entered
while they are typed in a GtkEntry. I am coding with GTK 2.24.0.
Looking around on the web, I found several possible functions to do
that, some
of them seem to be specific to GTK3, however. I found - and tried to
play with -
things like:
gtk_entry_set_attributes
gtk_widget_modify_text
gtk_widget_modify_base
gtk_widget_modify_font
gtk_widget_create_pango_layout
gtk_widget_create_pango_context
Some of them lead me to define and to argument a pointer to a struct
of type
PangoFontDescription or GtkStyle. Hence, it seems that I also need to
use
function like, e.g., pango_font_description_set_weight, etc., but I'm
not fully
sure about this.
I remained unable to sort this out, and some of these functions are
even not recognized in my coding environment..
You are close. You need to use gtk_widget_modify_font(). You pass in a
font description created by:
PangoFontDescription *fontDesc =
pango_font_description_from_string( "monospace 10" );
This would set the entry text to a monospace-type font with 10 point
size. Don't forget to call pango_font_description_free() afterwards.
If you wish to change font while typing you need to connect to the
"key-press-event" signal on the GtkEntry widget and handle key presses
that way.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Eric Wajnberg
Associated Professor at the
University of Montreal (Quebec, Canada)
I.N.R.A.
400 Route des Chappes, BP 167,
06903 Sophia Antipolis Cedex, France
Tel: (33-0) 4.92.38.64.47
Fax: (33-0) 4.92.38.65.57
e-mail: wajnberg sophia inra fr
Web page: http://www.sophia.inra.fr/perso/wajnberg/
Editor-in-Chief of BioControl, Published by Springer.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]