Thanks lethalman and nemequ.
저는 누군가에게 도움이 될 것이라고 생각합니다. 여기에 Vala와 CSS를 사용하는 방법에 대한 약간의 예가 있습니다.
using Gtk;
public class StyleApp1 : Gtk.Window
{
public StyleApp1()
{
this.title = "Style app example";
this.set_border_width (10);
this.set_position (Gtk.WindowPosition.CENTER);
this.set_default_size (350, 200);
this.destroy.connect (Gtk.main_quit);
var screen = this.get_screen();
var css_provider = new Gtk.CssProvider();
string path = "styleapp1.css";
// test if the css file exist
if (FileUtils.test (path, FileTest.EXISTS))
{
try {
css_provider.load_from_path(path);
Gtk.StyleContext.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER);
} catch (Error e) {
error ("Cannot load CSS stylesheet: %s", e.message);
}
}
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
this.add (box);
var label = new Gtk.Label ("Thank you");
box.add (label);
var label2 = new Gtk.Label ("Stackoverflow");
label2.get_style_context().add_class("my_class");
box.add (label2);
}
}
static int main(string[] args) {
Gtk.init(ref args);
StyleApp1 win = new StyleApp1();
win.show_all();
Gtk.main();
return 0;
}
과 styleapp1.css 파일 :
GtkWindow {
font-size: 17px;
}
.my_class {
color: pink;
}
NB : 당신이 add_provider_for_screen 대신 add_provider를 사용하는 경우. 사용자 정의하려는 모든 위젯에 대해 add_provider를 사용해야합니다.
가능한 복제본 [GTK에서 글꼴 크기를 어떻게 바꿀 수 있습니까?] (http://stackoverflow.com/questions/1269326/how-can-i-change-the-font-size-in-gtk) –
다른 질문은 GTK 2에만 해당됩니다. (나는 그것을 태그로 붙였다.) CSS는이 질문에 대한 정답이다. – ptomato