开发者

Gtk Change Font and font color for an application

开发者 https://www.devze.com 2022-12-24 18:47 出处:网络
I am having one Gtk+ and 开发者_JS百科C application in which i want to set the font to some XYZ font type and font color to blue, for all the labels and text in the application how can i do this in on

I am having one Gtk+ and 开发者_JS百科C application in which i want to set the font to some XYZ font type and font color to blue, for all the labels and text in the application how can i do this in one go, I have developed all the screen using Glade RAD tool, and currently i am doing this by calling following function for each label.

gtk_label_set_markup( label,"<span font='FONT NAME' foreground='#FFFFFF' size='large'><b>MY Text</b></span>");

So how can i tell the Gtk to use my font and font color for every label and for every widget in the application.

Thanks,


It is generally considered bad form to do that; apps should respect the user's theme. That said, you can deploy a resource file with the settings you want to override in your application, and then use gtk_rc_parse() to load the file at runtime.

Check out GTK+ Resource Files documentation for details.


I also wanted to change the size of the font (because in the windows I don't see any common way how to modify general GTKMM's font size, and user wants bigger fonts because he has small screen).

This works, when called before displaying window:

style = formatString( "style \"my-style\" { font_name = \"Mono %i\" } class \"*\" style \"my-style\"", fontSize);
gtk_rc_parse_string( style );

This is a way to 'create application setting' and apply it on the fly. By the way, class "*" means that all items will have this style applied.

0

精彩评论

暂无评论...
验证码 换一张
取 消