window: Show account switcher on loading and error pages

If there are any sessions
This commit is contained in:
Kévin Commaille 2023-11-28 16:08:09 +01:00
parent bed14c3b99
commit 56da95ee68
No known key found for this signature in database
GPG Key ID: 29A48C1F03620416
5 changed files with 28 additions and 4 deletions

View File

@ -6,7 +6,12 @@ use gtk::{
};
use super::AccountSwitcherPopover;
use crate::{components::Avatar, session_list::SessionInfo, utils::BoundObjectWeakRef, Window};
use crate::{
components::Avatar,
session_list::SessionInfo,
utils::{template_callbacks::TemplateCallbacks, BoundObjectWeakRef},
Window,
};
mod imp {
use glib::subclass::InitializingObject;
@ -30,6 +35,7 @@ mod imp {
SessionInfo::static_type();
Self::bind_template(klass);
TemplateCallbacks::bind_template_callbacks(klass);
}
fn instance_init(obj: &InitializingObject<Self>) {

View File

@ -1,6 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="AccountSwitcherButton" parent="GtkToggleButton">
<binding name="visible">
<closure type="gboolean" function="invert_boolean">
<lookup name="is-empty" type="SessionList">
<lookup name="session-list" type="Window">
<lookup name="root">AccountSwitcherButton</lookup>
</lookup>
</lookup>
</closure>
</binding>
<property name="tooltip-text" translatable="yes">Switch Accounts</property>
<accessibility>
<property name="label" translatable="yes">Switch Accounts</property>

View File

@ -4,12 +4,15 @@
<child>
<object class="AdwToolbarView">
<child type="top">
<object class="GtkHeaderBar">
<object class="AdwHeaderBar">
<property name="title-widget">
<object class="AdwWindowTitle">
<property name="title" translatable="yes">Error</property>
</object>
</property>
<child type="start">
<object class="AccountSwitcherButton"/>
</child>
</object>
</child>
<property name="content">

View File

@ -7,7 +7,7 @@ use ruma::RoomId;
use tracing::{error, info, warn};
use crate::{
account_switcher::AccountSwitcherPopover,
account_switcher::{AccountSwitcherButton, AccountSwitcherPopover},
components::Spinner,
error_page::ErrorPage,
greeter::Greeter,
@ -67,6 +67,8 @@ mod imp {
type ParentType = adw::ApplicationWindow;
fn class_init(klass: &mut Self::Class) {
AccountSwitcherButton::static_type();
Self::bind_template(klass);
klass.add_binding_action(

View File

@ -17,7 +17,11 @@
<property name="child">
<object class="AdwToolbarView">
<child type="top">
<object class="GtkHeaderBar"/>
<object class="AdwHeaderBar">
<child type="start">
<object class="AccountSwitcherButton"/>
</child>
</object>
</child>
<property name="content">
<object class="GtkBox">