Browse Source

Add loading spinner while restoring session

merge-requests/1327/merge
Julian Sparber 5 years ago
parent
commit
99f1317277
  1. 31
      data/resources/ui/window.ui
  2. 11
      src/window.rs

31
data/resources/ui/window.ui

@ -8,14 +8,43 @@
<property name="visible-child">login</property>
<property name="transition-type">crossfade</property>
<child>
<object class="Login" id="login" />
<object class="Login" id="login"/>
</child>
<child>
<object class="GtkStack" id="sessions">
<property name="transition-type">crossfade</property>
</object>
</child>
<child>
<object class="GtkWindowHandle" id="loading_page">
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkHeaderBar">
<property name="show-title-buttons">True</property>
<style>
<class name="flat"/>
</style>
</object>
</child>
<child>
<object class="GtkSpinner">
<property name="spinning">True</property>
<property name="valign">center</property>
<property name="halign">center</property>
<property name="vexpand">True</property>
<style>
<class name="session-loading-spinner"/>
</style>
</object>
</child>
</object>
</property>
</object>
</child>
</object>
</child>
</template>
</interface>

11
src/window.rs

@ -25,6 +25,8 @@ mod imp {
pub login: TemplateChild<Login>,
#[template_child]
pub sessions: TemplateChild<gtk::Stack>,
#[template_child]
pub loading_page: TemplateChild<gtk::WindowHandle>,
}
#[glib::object_subclass]
@ -134,7 +136,7 @@ impl Window {
}
if n > 0 {
self.switch_to_sessions_page();
self.switch_to_loading_page();
}
}
Err(error) => warn!("Failed to restore previous sessions: {:?}", error),
@ -181,6 +183,13 @@ impl Window {
priv_.main_stack.set_visible_child(&priv_.sessions.get());
}
pub fn switch_to_loading_page(&self) {
let priv_ = imp::Window::from_instance(self);
priv_
.main_stack
.set_visible_child(&priv_.loading_page.get());
}
pub fn switch_to_login_page(&self) {
let priv_ = imp::Window::from_instance(self);
priv_

Loading…
Cancel
Save