diff --git a/launch.sh b/launch.sh
index 7200f96..243ae3e 100755
--- a/launch.sh
+++ b/launch.sh
@@ -2,7 +2,7 @@
# Script to generate mo files in a temp locale folder
# Use it only for testing purpose
export PLUGIN_HELLO=True
-export PYTHONPATH="/home/fh/Data/projects/application-utility"
+export PYTHONPATH="$HOME/test/gnome-layout-switcher/bin:$HOME/Data/projects/application-utility"
rm -rf locale
mkdir locale
cd po
diff --git a/src/manjaro_hello.py b/src/manjaro_hello.py
index e4b229a..412b6c1 100644
--- a/src/manjaro_hello.py
+++ b/src/manjaro_hello.py
@@ -13,20 +13,84 @@ import subprocess
import sys
import webbrowser
-try:
- from application_utility.browser.application_browser import ApplicationBrowser
- from application_utility.browser.exceptions import NoAppInIsoError
- from application_utility.config.hello_config import HelloConfig
- APPS_PLUGIN = True
-
-except ModuleNotFoundError as e:
- APPS_PLUGIN = False
- print(f"Warning: Application Browser plugin not found : {e}")
-
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GdkPixbuf
+class EmbedManager:
+ """manage included applications"""
+ def __init__(self, *args):
+ self.apps = []
+ self.count = 0
+ for app in args:
+ self.apps.append(app)
+
+ def get_modules(self, window: Gtk.Window):
+ for app in self.apps:
+ app.load(window)
+ self.count = sum((1 for x in self.apps if x.loaded))
+
+ def display(self, window: Gtk.Window):
+ for app in self.apps:
+ app.display(window)
+ if app.loaded:
+ btn = window.builder.get_object(app.name)
+ if self.count < 2:
+ btn.set_margin_start(200)
+ btn.set_margin_end(200)
+ #TODO if self.count>2 !!! ???
+
+
+class Embed:
+ """abstact class for include app"""
+ def __init__(self):
+ """ abstact class initialisation """
+ self.name = "app" + self.__class__.__name__[5:]
+ self.loaded = False
+ self.box = None
+
+ def load(self, window: Gtk.Window) -> bool:
+ """ load modules if installed"""
+ raise Exception('abstract method')
+
+ def display(self, window: Gtk.Window):
+ """ show btn and add page"""
+ window.builder.get_object(self.name).set_visible(self.loaded)
+ if self.loaded:
+ window.builder.get_object("stack").add_named(self.box, self.name + "page")
+
+class EmbedLayouts(Embed):
+ """Gnome layout switcher"""
+ def load(self, window: Gtk.Window) -> bool:
+ try:
+ from layoutswitcherlib.layoutsbox import LayoutBox
+ try:
+ self.box = LayoutBox(window, usehello=True)
+ except Exception as err:
+ print("Error in Embled application:", err)
+ except ModuleNotFoundError as err:
+ print(f"Info: Gnome-layout-switcher not installed")
+ self.loaded = self.box is not None
+ return self.loaded
+
+class EmbedBrowser(Embed):
+ """Application-utility"""
+ def load(self, window: Gtk.Window) -> bool:
+ try:
+ from application_utility.browser.application_browser import ApplicationBrowser
+ from application_utility.browser.exceptions import NoAppInIsoError
+ from application_utility.config.hello_config import HelloConfig
+ try:
+ conf = HelloConfig(application="manjaro-hello")
+ self.box = ApplicationBrowser(conf, window)
+ except Exception as err:
+ print("Error in Embled application:", err)
+ except ModuleNotFoundError as err:
+ print(f"Info: Application-utility not installed")
+ self.loaded = self.box is not None
+ return self.loaded
+
+
class Hello(Gtk.Window):
"""Hello"""
@@ -73,7 +137,7 @@ class Hello(Gtk.Window):
widget.get_image_position() is Gtk.PositionType.RIGHT:
img = Gtk.Image.new_from_file(
self.preferences["data_path"] + "img/external-link.png")
- img.set_margin_left(2)
+ img.set_margin_start(2)
widget.set_image(img)
# Create pages
@@ -104,12 +168,9 @@ class Hello(Gtk.Window):
self.builder.get_object("install").set_visible(True)
# Installed systems
else:
- if APPS_PLUGIN:
- conf = HelloConfig(application="manjaro-hello")
- app_browser = ApplicationBrowser(conf, self)
- # create page install Applications
- self.builder.get_object("stack").add_named(app_browser, "appBrowserpage")
- self.builder.get_object("appBrowser").set_visible(True)
+ manager = EmbedManager(EmbedBrowser(), EmbedLayouts())
+ manager.get_modules(self)
+ manager.display(self)
self.window.show()
@@ -333,12 +394,10 @@ def get_lsb_infos():
for line in lsb_release:
if "=" in line:
var, arg = line.rstrip().split("=")
- if var.startswith("DISTRIB_"):
- var = var[8:]
- if arg.startswith("\"") and arg.endswith("\""):
- arg = arg[1:-1]
- if arg:
- lsb[var] = arg
+ if not arg:
+ continue
+ var = var.replace("DISTRIB_","")
+ lsb[var] = arg.strip('"')
except (OSError, KeyError) as error:
print(error)
return 'not Manjaro', '0.0'
diff --git a/ui/manjaro-hello.glade b/ui/manjaro-hello.glade
index 660d910..f7295e8 100644
--- a/ui/manjaro-hello.glade
+++ b/ui/manjaro-hello.glade
@@ -503,17 +503,53 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
-
@@ -522,12 +558,6 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
-
-
-
-
-
-
homepage