2

I created a spin button in GTK+ like this:

flow_spin = gtk_spin_button_new_with_range (100,1500,25);

and I want to change it's font and size. I googled in order to find a workaround because it seems that the spin button widget doesn't change it's format natively, but nothing worked.

This:

flow_spin.Child.ModifyFont(FontDescription.FromString("Courier 16"));

as well as this, didn't work:

flow_spin.Markup = "<span size='38000'>big text</span>";

As for this, the plus and minus buttons got bigger, but the text area remained the same size:

gtk_widget_set_size_request ( flow_spin,50, 50);

I look if possibly for a method, similar to this ?

gtk_label_set_markup (GTK_LABEL (label), "<span font='8' foreground='black' weight='normal'>100</span>");

Since I am a beginner at C as well as GTK+, any suggestions would be appreciated.

user3060854
  • 923
  • 2
  • 15
  • 25

1 Answers1

0

Gtk supports CSS for styling. You can load a CSS file in your program with gtk_css_provider_load_from_file().

So, just add a style provider on GtkWidget you want to stylish.

It's good read:

liberforce
  • 11,189
  • 37
  • 48
Lara Maia
  • 124
  • 11
  • 2
    I think it's better to read the official documentation chapter about CSS at https://developer.gnome.org/gtk3/stable/theming.html . A blog post from 6 years ago, while the CSS theming implementation only has been stable for around 1 year won't have all the quirks explained. – liberforce Nov 03 '17 at 09:21
  • @liberforce If you read the blog you will see that it just show how to use css flags with gtk (it never change since 6 years ago), and everyone knows how to find the documentation. But no problem, I've added the link. – Lara Maia Nov 05 '17 at 16:19