I could resolve this issue to call this.get_style_context().remove_class("csd") after set_titlebar(header) is called. But not sure why I have to remove "csd" class while it's a custom header.
Fujiwara On 04/11/17 21:33, Takao Fujiwara-san wrote:
I'd like to create a custom GtkHeaderBar in GTK 3.22. If I use GtkBox as the header, it can draw the background color. If I use a class inherited from GtkBox, it draws the transparent color. Seems GtkBox uses rgba from ".titlebar:not(headerbar)" of gtk-contained.css:1736 but the inherited class uses "window.csd > .titlebar:not(headerbar)" of gtk-contained.css:2041 from Inspector. How can I set the non-transparent color in the inherited class? The following is the test code. public class CustomHeader : Gtk.Box { public CustomHeader(Gtk.Orientation orientation, int spacing) { GLib.Object( orientation : orientation, spacing : spacing ); } } public class TestWindow : Gtk.Window { public TestWindow() { GLib.Object( type : Gtk.WindowType.TOPLEVEL ); #if USE_HBOX var header = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); #else var header = new CustomHeader(Gtk.Orientation.HORIZONTAL, 0); #endif header.set_css_name("headerbar"); var vvbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0); header.pack_start(vvbox, true, true, 0); var label = new Gtk.Label("Title"); label.get_style_context().add_class("title"); vvbox.pack_start(label, true, false, 0); var sub_label = new Gtk.Label("Subtitle"); sub_label.get_style_context().add_class("subtitle"); vvbox.pack_start(sub_label, true, false, 0); set_titlebar(header); var vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0); add(vbox); var llabel = new Gtk.Label("test"); vbox.pack_start(llabel, true, true, 0); } public static int main (string[] args) { Gtk.init (ref args); var window = new TestWindow(); window.show_all(); Gtk.main(); return 0; } } _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list