cht電腦資訊gcin
adm Find login register

.gtkrc-2.0 tricks (gtk3 不適用)

caleb
joined: 2007-09-22
posted: 630
promoted: 134
bookmarked: 90
1subject: .gtkrc-2.0 tricks (gtk3 不適用)Promote 1 Bookmark 12011-12-05quote  

最新版本在 http://evilvte.blogspot.com/2011/12/useful-gtk-2x-styling.html

底下轉貼:

重點:

1. 設定 GtkWidget::focus-line-width 可讓 widget (當然也包括 button) 更小

2. 可用 widget_class 限定只讓特定 widgets 受影響

3. 如果 .gtkrc-2.0 設定滿意了,可以把結果轉到 gcin code 裡,這樣就不需要 .gtkrc-2.0

style "evilvte_close_button"
{
  GtkButton::default-border = { 0, 0, 0, 0 }
  GtkButton::default-outside-border = { 0, 0, 0, 0 }
  GtkButton::inner-border = { 0, 0, 0, 0 }
  xthickness = 0
  ythickness = 0
}
widget_class "*.GtkNotebook.GtkHBox.GtkButton" style "evilvte_close_button"

style "evilvte_notebook"
{
  xthickness = 0
  ythickness = 0
}
widget_class "*.GtkNotebook" style "evilvte_notebook"

style "evilvte_focus-line"
{
  GtkWidget::focus-line-width = 0
}
widget_class "*" style "evilvte_focus-line"

eliu

joined: 2007-08-09
posted: 11482
promoted: 617
bookmarked: 187
新竹, 台灣
2subject: Promote 0 Bookmark 02011-12-05quote  

我加的 gtkrc for button border 在 gtk3 可以用嗎?

caleb
joined: 2007-09-22
posted: 630
promoted: 134
bookmarked: 90
3subject: Promote 0 Bookmark 02011-12-05quote  

eliu
我加的 gtkrc for button border 在 gtk3 可以用嗎?

應該都不行,gtk3 要用 css 。

類似這樣,把 css 定義在 GTK3_CSS 裡:

    GtkCssProvider *provider = gtk_css_provider_new();
    gtk_css_provider_load_from_data(provider, GTK3_CSS, -1, NULL);
    gtk_style_context_add_provider_for_screen(gdk_display_get_default_screen(gdk_display_get_default()), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
    g_object_unref(provider);

eliu

joined: 2007-08-09
posted: 11482
promoted: 617
bookmarked: 187
新竹, 台灣
4subject: Promote 0 Bookmark 02011-12-05quote  

gcin.cpp
gtk_init (&argc, &argv);

static char button_rc[]="style \"button\"\n"
"{\n"
" GtkButton::inner-border = {0,0,0,0}\n"
"\n"
"xthickness = 1\n"
"ythickness = 0\n"
"}\n"
"class \"GtkButton\" style \"button\"";

gtk_rc_parse_string(button_rc);

我是說這一段要用什麼取代?

caleb
joined: 2007-09-22
posted: 630
promoted: 134
bookmarked: 90
5subject: Promote 0 Bookmark 02011-12-05quote  

eliu

static char button_rc[]="style \"button\"\n"
"{\n"
" GtkButton::inner-border = {0,0,0,0}\n"
"\n"
"xthickness = 1\n"
"ythickness = 0\n"
"}\n"
"class \"GtkButton\" style \"button\"";

GtkButton
{
  border-width: 0;
  padding: 0;
  -GtkButton-inner-border: 0;
}

類似這樣,寫到我上一篇的 GTK3_CSS 裡。

不過我沒在 gcin 調整過 css,我日常用的 gcin 完全看不到 button :P

cht電腦資訊gcin
adm Find login register
views:14205