add progress and done pages

main
mirkobrombin 2 years ago
parent 587dbeea12
commit d5f9688c9f

@ -26,9 +26,11 @@
<object class="AdwCarousel" id="carousel">
<property name="vexpand">True</property>
<property name="hexpand">True</property>
<property name="allow_scroll_wheel">True</property>
<property name="allow_mouse_drag">True</property>
<property name="allow_long_swipes">True</property>
<property name="allow_scroll_wheel">False</property>
<property name="allow_mouse_drag">False</property>
<property name="allow_long_swipes">False</property>
<!-- Welcome -->
<child>
<object class="AdwStatusPage">
<property name="icon-name">pm.mirko.UbuntuSmoother</property>
@ -49,6 +51,8 @@
</child>
</object>
</child>
<!-- Configuration -->
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
@ -114,6 +118,45 @@
</child>
</object>
</child>
<!-- Progress -->
<child>
<object class="AdwStatusPage">
<property name="title">Please Wait…</property>
<property name="description">The changes are being applied.</property>
<property name="halign">fill</property>
<property name="valign">fill</property>
<property name="hexpand">true</property>
<child>
<object class="GtkSpinner" id="spinner">
<property name="valign">center</property>
<property name="halign">center</property>
</object>
</child>
</object>
</child>
<!-- Done -->
<child>
<object class="AdwStatusPage">
<property name="icon-name">emblem-default-symbolic</property>
<property name="title">Done!</property>
<property name="description">You can now enjoy your new Ubuntu experience.</property>
<property name="halign">fill</property>
<property name="valign">fill</property>
<property name="hexpand">true</property>
<child>
<object class="GtkButton" id="btn_close">
<property name="label">Close</property>
<property name="halign">center</property>
<style>
<class name="pill" />
<class name="suggested-action" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>

@ -19,6 +19,7 @@ from gi.repository import Gtk, Gio, Adw
from ubuntu_smoother.models.preset import Preset
from ubuntu_smoother.models.config import Config
from ubuntu_smoother.utils.configurator import Configurator
from ubuntu_smoother.utils.run_async import RunAsync
@Gtk.Template(resource_path='/pm/mirko/UbuntuSmoother/gtk/window.ui')
@ -28,9 +29,15 @@ class UbuntuSmootherWindow(Adw.ApplicationWindow):
carousel = Gtk.Template.Child()
btn_start = Gtk.Template.Child()
btn_save = Gtk.Template.Child()
btn_close = Gtk.Template.Child()
switch_snap = Gtk.Template.Child()
switch_flatpak = Gtk.Template.Child()
switch_apport = Gtk.Template.Child()
page_welcome = -1
page_configuration = 0
page_progress = 1
page_done = 2
spinner = Gtk.Template.Child()
def __init__(self, **kwargs):
super().__init__(**kwargs)
@ -50,16 +57,29 @@ class UbuntuSmootherWindow(Adw.ApplicationWindow):
def __connect_signals(self):
self.btn_start.connect('clicked', self.__on_btn_start_clicked)
self.btn_save.connect('clicked', self.on_btn_save_clicked)
self.btn_close.connect('clicked', self.on_btn_close_clicked)
self.switch_snap.connect('state-set', self.__on_switch_snap_state_set)
self.switch_flatpak.connect(
'state-set', self.__on_switch_flatpak_state_set)
self.switch_apport.connect(
'state-set', self.__on_switch_apport_state_set)
def __show_page(self, page: int):
_page = self.carousel.get_nth_page(page + 1)
self.carousel.scroll_to(_page, True)
def __on_btn_start_clicked(self, widget):
index = int(self.carousel.get_position())
next_page = self.carousel.get_nth_page(index + 1)
self.carousel.scroll_to(next_page, True)
self.__show_page(self.page_configuration)
def on_btn_save_clicked(self, widget):
def on_done(*args):
self.spinner.stop()
self.__show_page(self.page_done)
self.__show_page(self.page_progress)
self.spinner.start()
RunAsync(Configurator(self.__config, fake=True).apply, on_done)
def __on_switch_snap_state_set(self, widget, state):
self.__config.snap = state
@ -70,5 +90,5 @@ class UbuntuSmootherWindow(Adw.ApplicationWindow):
def __on_switch_apport_state_set(self, widget, state):
self.__config.apport = state
def on_btn_save_clicked(self, widget):
Configurator(self.__config, fake=True).apply()
def on_btn_close_clicked(self, widget):
self.get_application().quit()

Loading…
Cancel
Save