Skip to content

Commit

Permalink
feat(Sidebar): headerbar account switcher avi (#460)
Browse files Browse the repository at this point in the history
* feat(Sidebar): headerbar account switcher avi

* chore: lint
  • Loading branch information
GeopJr authored Aug 31, 2023
1 parent 413d8df commit 3b3565d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
23 changes: 15 additions & 8 deletions data/ui/views/sidebar/view.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,27 @@
<child type="top">
<object class="AdwHeaderBar">
<child type="start">
<object class="GtkToggleButton" id="accounts_button">
<signal name="toggled" handler="on_mode_changed"/>
<property name="tooltip_text" translatable="yes">Switch Account</property>
<child>
<object class="TubaWidgetsAvatar" id="accounts_button_avi">
<property name="size">26</property>
</object>
</child>
<style>
<class name="flat"/>
<class name="circular"/>
</style>
</object>
</child>
<child type="end">
<object class="GtkButton" id="compose_button">
<property name="icon-name">document-edit-symbolic</property>
<property name="action-name">app.compose</property>
<property name="tooltip_text" translatable="yes">Compose</property>
</object>
</child>
<child type="end">
<object class="GtkToggleButton" id="accounts_button">
<property name="icon-name">tuba-people-symbolic</property>
<signal name="toggled" handler="on_mode_changed"/>
<property name="tooltip_text" translatable="yes">Switch Account</property>
</object>
</child>
</object>
</child>

Expand Down Expand Up @@ -140,4 +148,3 @@

</template>
</interface>

4 changes: 4 additions & 0 deletions src/Views/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class Tuba.Views.Sidebar : Gtk.Widget, AccountHolder {
[GtkChild] unowned Gtk.Stack mode;
[GtkChild] unowned Gtk.ListBox items;
[GtkChild] unowned Gtk.ListBox saved_accounts;
[GtkChild] unowned Widgets.Avatar accounts_button_avi;

[GtkChild] unowned Widgets.Avatar avatar;
[GtkChild] unowned Widgets.EmojiLabel title;
Expand Down Expand Up @@ -95,6 +96,7 @@ public class Tuba.Views.Sidebar : Gtk.Widget, AccountHolder {
private Binding sidebar_handle_short;
private Binding sidebar_avatar;
private Binding sidebar_display_name;
private Binding sidebar_avatar_btn;
protected virtual void on_account_changed (InstanceAccount? account) {
if (this.account != null) {
sidebar_handle_short.unbind ();
Expand All @@ -111,6 +113,7 @@ public class Tuba.Views.Sidebar : Gtk.Widget, AccountHolder {
if (account != null) {
sidebar_handle_short = this.account.bind_property ("handle_short", subtitle, "label", BindingFlags.SYNC_CREATE);
sidebar_avatar = this.account.bind_property ("avatar", avatar, "avatar-url", BindingFlags.SYNC_CREATE);
sidebar_avatar_btn = this.account.bind_property ("avatar", accounts_button_avi, "avatar-url", BindingFlags.SYNC_CREATE);
sidebar_display_name = this.account.bind_property (
"display-name",
title,
Expand All @@ -131,6 +134,7 @@ public class Tuba.Views.Sidebar : Gtk.Widget, AccountHolder {
subtitle.label = _("No account selected");
avatar.account = null;
account_items.model = null;
accounts_button_avi.account = null;
}
}

Expand Down

0 comments on commit 3b3565d

Please sign in to comment.