GtkEntry change font size, can it be done in the XML?
I have a c app with a GUI built with glade. I need to change the font size, and it seems easiest to just change the XML file. Here's a snip of one of the GtkEntry sections:
<child> <object class="GtkEntry" id="count1"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="editable">False</property> <property name="invisible_char">●</property> <property name="activates_default">True</property> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> <property name="position">1</property> </packing> </child> Can I just add a line there that will specify the font or just the font size? Thanks, Jon |
The short answer is no.
Ed |
Ok, how about the long answer? I'm guessing I need to do this in the C code, with set attributes, but I haven't found clear documentation on how to do that. Can you give me a pointer?
Thanks, Jon |
Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.
:) (I don't know the answer.) Doesn't Gtk use CSS? Does the XML have an equivalent to HTML's style attribute? Also, are there not differences between Gtk 3 and Gtk 4 - you haven't specified which one you're using? |
Quote:
Ed |
OK, I'm trying to do this in the C code. Here's what I did :
PangoAttrList *attr; gtk_init (&argc, &argv); builder = gtk_builder_new (); gtk_builder_add_from_file (builder, "scaler.glade", NULL); window = GTK_WIDGET (gtk_builder_get_object (builder, "window1")); // Pscaler1 = GTK_ENTRY( gtk_builder_get_object(builder, "count1" ) ); Pscaler[0] = GTK_ENTRY( gtk_builder_get_object(builder, "count1" ) ); attr= pango_attr_list_new(); pango_attr_list_insert(attr,pango_attr_scale_new(PANGO_SCALE_XX_LARGE)); gtk_entry_set_attributes(Pscaler[0], attr); But, I get a compile-time error :/home/elson/scaler3/scaler.c:246: undefined reference to `gtk_entry_set_attributes' Any idea what is going on? This is an older Beagle Board system running Gtk 2.0 so may not have all the latest features. And, if there's a way to bump up the size of all fonts, that might be fine, as this is a single-purpose embedded computer. Thanks, Jon |
You still haven't told what version of gtk that you are using. An Example for gtk3:
PangoDem.c Code:
#include <gtk/gtk.h> |
Oh ok. I re-read post #6, you said gtk2, not sure if I have an example in my cache.
|
Quote:
You should have said at the beginning that you are using GTK 2 and you want increase the font size globally. In your ~/.gtkrc-2.0, add: Code:
gtk-font-name = "Sans 14" Ed |
Hmm, I am linked with gtk+-2.0, not sure if that makes a difference. Anyway, I have managed to change the font size of the toolbar items on emacs, but it had NO effect on the app in question. I can't find aywhere in the .c or .glade file that calls for a specific font.
There was no ~/.gtkrc-2.0 file, so I created one, and put the above text there, but it seemed to make no difference. Thanks, Jon |
You did stop X, and then re start it?
If you are wanting to change gtk2 globally ~/.gtkrc-2.0 Code:
gtk-icon-theme-name="Adwaita" |
Your desktop environment may have its own font settings that override ~/.gtkrc-2.0
Ed |
Quote:
One issue is there may be very few fonts loaded on this system. I used fc-list and typed in several versions of the font name, last version of ~/.gtkrc-3.0 was: gtk-icon-theme-name= "Tangerine" gtk-theme-name= "dark" gtk-font-name = "DejaVu Sans Mono:style=Bold 24" But, I also tried it without the :style= part. I am just pretty lost here. Thanks, Jon |
Quote:
Thanks, Jon |
That should have worked. Run your program under strace to see which files it is reading.
Ed |
All times are GMT -5. The time now is 05:33 PM. |