我想改变GTK + 3窗口上的关闭按钮的风格,带有所谓的“标题栏”,其中窗口是没有装饰的渲染,GTK撰写标题栏和小部件。

是什么类型的元素是“x”关闭按钮,它属于哪些css类(如果有)?

请注意,这是 not 窗口管理器主题的一部分,但实际上由gtk +绘制。

有帮助吗?

解决方案

它是一个带有图标生成的gtkbutton,带有样式类生成的window-close-symbolic(与标题上的其他按钮相同的类),假设应用程序使用内置关闭按钮。

其他提示

您可以使用 gtkparasite 找到元素的类型和名称以及它是如何嵌套的。

min / max / close按钮选择器:

headerbar.titlebar button.titlebutton.close
headerbar.titlebar button.titlebutton.maximize
headerbar.titlebar button.titlebutton.minimize
.

用于任何/每个单独/最大/关闭按钮的选择器:

headerbar.titlebar > :last-child button.titlebutton
.

整个MIN / MAX / CLEST按钮的容器的选择器:

headerbar.titlebar > :last-child
.

左键的选择器(通常,但不总是,应用程序按钮):

headerbar.titlebar > :first-child > button.titlebutton
.

左侧按钮容器的选择器:

headerbar.titlebar > :first-child
.

我在我自己的主题中使用了这些选择器,可以在这里检查相关的代码: http://xfce-evolution.sourceforge.net

对于python

header = Gtk.HeaderBar()
header.set_show_close_button(False)

button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
img = Gtk.Image.new_from_icon_name("window-close-symbolic", Gtk.IconSize.MENU)
button.set_image(img)
button.connect("clicked", Gtk.main_quit)
header.pack_end(button)

seperator = Gtk.Separator.new(Gtk.Orientation.VERTICAL)
header.pack_end(seperator)

#window/self.set_titlebar(header)
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top