Skip to content

Commit

Permalink
Fix window controls finally. Merry Christmas!
Browse files Browse the repository at this point in the history
  • Loading branch information
lainsce committed Dec 26, 2023
1 parent 889005a commit e94a1a1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 37 deletions.
3 changes: 1 addition & 2 deletions lib/Widgets/AboutWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ public class He.AboutWindow : He.Window {

this.app_bar.valign = Gtk.Align.START;
this.app_bar.show_back = false;
this.app_bar.show_left_title_buttons = true;
this.app_bar.show_right_title_buttons = false;
this.app_bar.decoration_layout = ":close";

window_overlay.add_overlay (app_bar);
window_overlay.set_child (about_box);
Expand Down
51 changes: 18 additions & 33 deletions lib/Widgets/AppBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class He.AppBar : He.Bin {
private Gtk.Box title_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
private Gtk.Box subtitle_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
private Gtk.Box control_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
private Gtk.Box win_control_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
private Gtk.Box win_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
private Gtk.Box win2_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
private Gtk.Box sub_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
Expand Down Expand Up @@ -370,11 +371,22 @@ public class He.AppBar : He.Bin {

construct {
title_box.halign = Gtk.Align.END;
win_box.hexpand = true;
win_box.halign = Gtk.Align.END;
win_box.valign = Gtk.Align.START;
win2_box.halign = Gtk.Align.START;
win2_box.valign = Gtk.Align.START;
create_start_window_controls ();
create_end_window_controls ();

win_control_box.valign = Gtk.Align.START;
win_control_box.hexpand = true;
win_control_box.margin_start = 6;
win_control_box.margin_top = 6;
win_control_box.margin_end = 6;
win_control_box.append (win_box);
win_control_box.prepend (win2_box);

back_button.set_icon_name ("go-previous-symbolic");
back_button.set_tooltip_text ("Go Back");
back_button.add_css_class ("flat");
Expand All @@ -399,10 +411,8 @@ public class He.AppBar : He.Bin {
viewsubtitle.set_visible (false);

top_box.hexpand = true;
top_box.append (win2_box);
top_box.append (control_box);
top_box.append (title_box);
top_box.append (win_box);

subtitle_box.append (viewsubtitle);
subtitle_box.set_visible (false);
Expand Down Expand Up @@ -439,8 +449,12 @@ public class He.AppBar : He.Bin {
main_box.append (top_box);
main_box.append (sub_box);

var win_controls_overlay = new Gtk.Overlay ();
win_controls_overlay.set_child (main_box);
win_controls_overlay.add_overlay (win_control_box);

var winhandle = new Gtk.WindowHandle ();
winhandle.set_child (main_box);
winhandle.set_child (win_controls_overlay);
winhandle.set_parent (this);
winhandle.hexpand = true;

Expand All @@ -450,36 +464,7 @@ public class He.AppBar : He.Bin {
flat = true;
main_box.add_css_class ("flat-appbar");

// The following is just a slice of craziness to make the design work
// for any type of window titlebar control scheme
notify["show-left-title-buttons"].connect (() => {
if (title.empty) {
top_box.margin_top = 36;
} else if (title.empty && !sidetitle.empty) {
top_box.margin_top = 0;
} else if (!show_left_title_buttons && !show_right_title_buttons) {
top_box.margin_top = 36;
} else {
top_box.margin_top = 0;
}
if (show_left_title_buttons && show_right_title_buttons) {
top_box.margin_top = 0;
}
});
notify["show-right-title-buttons"].connect (() => {
if (title.empty) {
top_box.margin_top = 36;
} else if (title.empty && !sidetitle.empty) {
top_box.margin_top = 0;
} else if (!show_left_title_buttons && !show_right_title_buttons) {
top_box.margin_top = 36;
} else {
top_box.margin_top = 0;
}
if (show_left_title_buttons && show_right_title_buttons) {
top_box.margin_top = 0;
}
});
top_box.margin_top = 36;
}

static construct {
Expand Down
4 changes: 2 additions & 2 deletions lib/Widgets/SettingsWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@
viewtitle.margin_end = 12;
viewtitle.margin_bottom = 6;

appbar.show_left_title_buttons = true;
appbar.show_right_title_buttons = false;
appbar.decoration_layout = ":close";
appbar.show_back = false;
appbar.hexpand = true;

Expand All @@ -107,6 +106,7 @@
this.set_focusable (true);

this.set_modal (true);
this.add_css_class ("dialog-content");

on_pages_changed (0, 0, this.stack.pages.get_n_items ());
}
Expand Down

0 comments on commit e94a1a1

Please sign in to comment.