code cleanup

main
mirkobrombin 2 years ago
parent 060a5e4e36
commit 9a3bd446cd

@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from ubuntu_smoother.window import UbuntuSmootherWindow
from gi.repository import Gtk, Gio, Adw
import sys
import gi
import logging
@ -21,10 +23,6 @@ import logging
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
from gi.repository import Gtk, Gio, Adw
from ubuntu_smoother.window import UbuntuSmootherWindow
logging.basicConfig(level=logging.INFO)
@ -62,7 +60,7 @@ class UbuntuSmootherApplication(Adw.Application):
self.add_action(action)
if shortcuts:
self.set_accels_for_action(f"app.{name}", shortcuts)
def close(self, *args):
"""Close the application."""
self.quit()
@ -71,4 +69,4 @@ class UbuntuSmootherApplication(Adw.Application):
def main(version):
"""The application's entry point."""
app = UbuntuSmootherApplication()
return app.run(sys.argv)
return app.run(sys.argv)

@ -4,4 +4,3 @@ class Config:
self.snap = snap
self.flatpak = flatpak
self.apport = apport

@ -3,4 +3,3 @@ class Preset:
snap: bool = True
flatpak: bool = True
apport: bool = True

@ -1,10 +1,13 @@
import shutil
def is_snap_installed():
return shutil.which('snap') is not None
def is_flatpak_installed():
return shutil.which('flatpak') is not None
def is_apport_installed():
return shutil.which('apport') is not None

@ -8,6 +8,7 @@ from ubuntu_smoother.utils.snap import Snap
logger = logging.getLogger("UbuntuSmoother::Configurator")
class Configurator:
def __init__(self, config: 'Config', fake: bool = False):
@ -18,7 +19,7 @@ class Configurator:
self.__enable_snap() if self.config.snap else self.__disable_snap()
self.__enable_flatpak() if self.config.flatpak else self.__disable_flatpak()
self.__enable_apport() if self.config.apport else self.__disable_apport()
def __enable_snap(self):
if self.fake:
logger.info("Fake: Snap enabled")
@ -32,7 +33,7 @@ class Configurator:
if not self.config.flatpak:
Snap.install(['snap-store'])
def __disable_snap(self):
if self.fake:
logger.info("Fake: Snap disabled")
@ -40,7 +41,7 @@ class Configurator:
if checks.is_snap_installed():
Apt.purge(['snapd'])
def __enable_flatpak(self):
if self.fake:
logger.info("Fake: Flatpak enabled")

@ -51,8 +51,10 @@ class UbuntuSmootherWindow(Adw.ApplicationWindow):
self.btn_start.connect('clicked', self.__on_btn_start_clicked)
self.btn_save.connect('clicked', self.on_btn_save_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)
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 __on_btn_start_clicked(self, widget):
index = int(self.carousel.get_position())

Loading…
Cancel
Save