Skip to content

Commit

Permalink
fix: show window controls on sidebar when they are set to left
Browse files Browse the repository at this point in the history
but only when the flap is not folded (desktop mode); when it's folded, the controls should be visible on the main headerbar

fix: #236
  • Loading branch information
GeopJr committed May 9, 2023
1 parent 93011b3 commit 1d1f67b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
2 changes: 0 additions & 2 deletions data/ui/dialogs/main.ui
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.20"/>
<requires lib="libhandy" version="1.0"/>
<template class="TubaDialogsMainWindow" parent="AdwApplicationWindow">
<property name="width_request">360</property>
<property name="height_request">600</property>
Expand Down
2 changes: 1 addition & 1 deletion data/ui/views/sidebar/view.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<property name="hexpand">false</property>

<child>
<object class="AdwHeaderBar">
<object class="AdwHeaderBar" id="sb_header">
<property name="show-start-title-buttons">0</property>
<property name="show-end-title-buttons">0</property>
<child type="start">
Expand Down
13 changes: 12 additions & 1 deletion src/Views/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,24 @@ public class Tuba.Views.Main : Views.TabbedBase {
header.pack_start (sidebar_button);
sidebar_button.icon_name = "tuba-dock-left-symbolic";

header.show_start_title_buttons = false;
app.notify["main-window"].connect (() => {
if (app.main_window == null) {
sidebar_button.hide ();
return;
}

app.main_window.flap.bind_property ("folded", sidebar_button, "visible", BindingFlags.SYNC_CREATE);
app.main_window.flap.bind_property ("folded", sidebar_button, "visible", BindingFlags.SYNC_CREATE, (b, src, ref target) => {
var state = src.get_boolean ();
target.set_boolean (state);

var sidebar = app.main_window.flap.flap as Views.Sidebar;
if (sidebar != null) sidebar.show_window_controls = !state;
header.show_start_title_buttons = state;

return true;
});

app.main_window.flap.bind_property ("reveal-flap", sidebar_button, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
// app.main_window.flap.bind_property ("reveal-flap", sidebar_button, "icon-name", BindingFlags.SYNC_CREATE, (b, src, ref target) => {
// var state = src.get_boolean ();
Expand Down
12 changes: 12 additions & 0 deletions src/Views/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ public class Tuba.Views.Sidebar : Box, AccountHolder {
[GtkChild] unowned Widgets.Avatar avatar;
[GtkChild] unowned Widgets.EmojiLabel title;
[GtkChild] unowned Label subtitle;
[GtkChild] unowned Adw.HeaderBar sb_header;

private bool _show_window_controls = false;
public bool show_window_controls {
get {
return _show_window_controls;
}
set {
_show_window_controls = value;
sb_header.show_start_title_buttons = value;
}
}

protected InstanceAccount? account { get; set; default = null; }

Expand Down

0 comments on commit 1d1f67b

Please sign in to comment.