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