@@ -11,6 +11,7 @@ const gtk = @import("gtk");
11
11
const i18n = @import ("../../../os/main.zig" ).i18n ;
12
12
const apprt = @import ("../../../apprt.zig" );
13
13
const configpkg = @import ("../../../config.zig" );
14
+ const TitlebarStyle = configpkg .Config .GtkTitlebarStyle ;
14
15
const input = @import ("../../../input.zig" );
15
16
const CoreSurface = @import ("../../../Surface.zig" );
16
17
const ext = @import ("../ext.zig" );
@@ -101,6 +102,25 @@ pub const Window = extern struct {
101
102
);
102
103
};
103
104
105
+ pub const @"titlebar-style" = struct {
106
+ pub const name = "titlebar-style" ;
107
+ const impl = gobject .ext .defineProperty (
108
+ name ,
109
+ Self ,
110
+ TitlebarStyle ,
111
+ .{
112
+ .default = .native ,
113
+ .accessor = gobject .ext .typedAccessor (
114
+ Self ,
115
+ TitlebarStyle ,
116
+ .{
117
+ .getter = Self .getTitlebarStyle ,
118
+ },
119
+ ),
120
+ },
121
+ );
122
+ };
123
+
104
124
pub const @"headerbar-visible" = struct {
105
125
pub const name = "headerbar-visible" ;
106
126
const impl = gobject .ext .defineProperty (
@@ -546,6 +566,7 @@ pub const Window = extern struct {
546
566
"tabs-visible" ,
547
567
"tabs-wide" ,
548
568
"toolbar-style" ,
569
+ "titlebar-style" ,
549
570
}) | key | {
550
571
self .as (gobject .Object ).notifyByPspec (
551
572
@field (properties , key ).impl .param_spec ,
@@ -716,6 +737,14 @@ pub const Window = extern struct {
716
737
return false ;
717
738
}
718
739
740
+ fn isFullscreen (self : * Window ) bool {
741
+ return self .as (gtk .Window ).isFullscreen () != 0 ;
742
+ }
743
+
744
+ fn isMaximized (self : * Window ) bool {
745
+ return self .as (gtk .Window ).isMaximized () != 0 ;
746
+ }
747
+
719
748
fn getHeaderbarVisible (self : * Self ) bool {
720
749
const priv = self .private ();
721
750
@@ -727,46 +756,72 @@ pub const Window = extern struct {
727
756
if (priv .quick_terminal ) return false ;
728
757
729
758
// If we're fullscreen we never show the header bar.
730
- if (self .as ( gtk . Window ). isFullscreen () != 0 ) return false ;
759
+ if (self .isFullscreen ()) return false ;
731
760
732
761
// The remainder needs a config
733
762
const config_obj = self .private ().config orelse return true ;
734
763
const config = config_obj .get ();
735
764
736
- // *Conditionally* disable the header bar when maximized,
737
- // and gtk-titlebar-hide-when-maximized is set
738
- if (self .as (gtk .Window ).isMaximized () != 0 and
739
- config .@"gtk-titlebar-hide-when-maximized" )
740
- {
765
+ // *Conditionally* disable the header bar when maximized, and
766
+ // gtk-titlebar-hide-when-maximized is set
767
+ if (self .isMaximized () and config .@"gtk-titlebar-hide-when-maximized" ) {
741
768
return false ;
742
769
}
743
770
744
- return config .@"gtk-titlebar" ;
771
+ return switch (config .@"gtk-titlebar-style" ) {
772
+ // If the titlebar style is tabs never show the titlebar.
773
+ .tabs = > false ,
774
+
775
+ // If the titlebar style is native show the titlebar if configured
776
+ // to do so.
777
+ .native = > config .@"gtk-titlebar" ,
778
+ };
745
779
}
746
780
747
781
fn getTabsAutohide (self : * Self ) bool {
748
782
const priv = self .private ();
749
783
const config = if (priv .config ) | v | v .get () else return true ;
750
- return switch (config .@"window-show-tab-bar" ) {
751
- // Auto we always autohide... obviously.
752
- .auto = > true ,
753
784
754
- // Always we never autohide because we always show the tab bar.
755
- .always = > false ,
785
+ return switch (config .@"gtk-titlebar-style" ) {
786
+ // If the titlebar style is tabs we cannot autohide.
787
+ .tabs = > false ,
788
+
789
+ .native = > switch (config .@"window-show-tab-bar" ) {
790
+ // Auto we always autohide... obviously.
791
+ .auto = > true ,
756
792
757
- // Never we autohide because it doesn't actually matter,
758
- // since getTabsVisible will return false.
759
- .never = > true ,
793
+ // Always we never autohide because we always show the tab bar.
794
+ .always = > false ,
795
+
796
+ // Never we autohide because it doesn't actually matter,
797
+ // since getTabsVisible will return false.
798
+ .never = > true ,
799
+ },
760
800
};
761
801
}
762
802
763
803
fn getTabsVisible (self : * Self ) bool {
764
804
const priv = self .private ();
765
805
const config = if (priv .config ) | v | v .get () else return true ;
766
- return switch (config .@"window-show-tab-bar" ) {
767
- .always , .auto = > true ,
768
- .never = > false ,
769
- };
806
+
807
+ switch (config .@"gtk-titlebar-style" ) {
808
+ .tabs = > {
809
+ // *Conditionally* disable the tab bar when maximized, the titlebar
810
+ // style is tabs, and gtk-titlebar-hide-when-maximized is set.
811
+ if (self .isMaximized () and config .@"gtk-titlebar-hide-when-maximized" ) {
812
+ return false ;
813
+ }
814
+
815
+ // If the titlebar style is tabs the tab bar must always be visible.
816
+ return true ;
817
+ },
818
+ .native = > {
819
+ return switch (config .@"window-show-tab-bar" ) {
820
+ .always , .auto = > true ,
821
+ .never = > false ,
822
+ };
823
+ },
824
+ }
770
825
}
771
826
772
827
fn getTabsWide (self : * Self ) bool {
@@ -785,6 +840,12 @@ pub const Window = extern struct {
785
840
};
786
841
}
787
842
843
+ fn getTitlebarStyle (self : * Self ) TitlebarStyle {
844
+ const priv = self .private ();
845
+ const config = if (priv .config ) | v | v .get () else return .native ;
846
+ return config .@"gtk-titlebar-style" ;
847
+ }
848
+
788
849
fn propConfig (
789
850
_ : * adw.ApplicationWindow ,
790
851
_ : * gobject.ParamSpec ,
@@ -894,6 +955,16 @@ pub const Window = extern struct {
894
955
};
895
956
}
896
957
958
+ fn closureTitlebarStyleIsTab (
959
+ _ : * Self ,
960
+ value : TitlebarStyle ,
961
+ ) callconv (.c ) bool {
962
+ return switch (value ) {
963
+ .native = > false ,
964
+ .tabs = > true ,
965
+ };
966
+ }
967
+
897
968
//---------------------------------------------------------------
898
969
// Virtual methods
899
970
@@ -1662,6 +1733,7 @@ pub const Window = extern struct {
1662
1733
properties .@"tabs-visible" .impl ,
1663
1734
properties .@"tabs-wide" .impl ,
1664
1735
properties .@"toolbar-style" .impl ,
1736
+ properties .@"titlebar-style" .impl ,
1665
1737
});
1666
1738
1667
1739
// Bindings
@@ -1689,6 +1761,7 @@ pub const Window = extern struct {
1689
1761
class .bindTemplateCallback ("notify_menu_active" , & propMenuActive );
1690
1762
class .bindTemplateCallback ("notify_quick_terminal" , & propQuickTerminal );
1691
1763
class .bindTemplateCallback ("notify_scale_factor" , & propScaleFactor );
1764
+ class .bindTemplateCallback ("titlebar_style_is_tabs" , & closureTitlebarStyleIsTab );
1692
1765
1693
1766
// Virtual methods
1694
1767
gobject .Object .virtual_methods .dispose .implement (class , & dispose );
0 commit comments