diff --git a/.gitignore b/.gitignore
index aae2eb0..7cc5d46 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*~
locale/*
__pycache__/
+.idea
\ No newline at end of file
diff --git a/.idea/manjaro-hello.iml b/.idea/manjaro-hello.iml
new file mode 100644
index 0000000..6711606
--- /dev/null
+++ b/.idea/manjaro-hello.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..8656114
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..75718e6
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..eef1ec8
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,724 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ share_dir
+ application
+ applications
+ appBrowser
+ application_browser
+ on_btn
+
+
+ data_path
+ appBrowser
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1534949710604
+
+
+ 1534949710604
+
+
+ 1536411499431
+
+
+
+ 1536411499431
+
+
+ 1536411521103
+
+
+
+ 1536411521103
+
+
+ 1536411558753
+
+
+
+ 1536411558753
+
+
+ 1536414428607
+
+
+
+ 1536414428607
+
+
+ 1536415933849
+
+
+
+ 1536415933849
+
+
+ 1536416490489
+
+
+
+ 1536416490489
+
+
+ 1536418940294
+
+
+
+ 1536418940294
+
+
+ 1536419834210
+
+
+
+ 1536419834210
+
+
+ 1536420193376
+
+
+
+ 1536420193376
+
+
+ 1536421211422
+
+
+
+ 1536421211422
+
+
+ 1536421394042
+
+
+
+ 1536421394042
+
+
+ 1536422379462
+
+
+
+ 1536422379462
+
+
+ 1536422647180
+
+
+
+ 1536422647180
+
+
+ 1536425218221
+
+
+
+ 1536425218221
+
+
+ 1536425669114
+
+
+
+ 1536425669114
+
+
+ 1536426261137
+
+
+
+ 1536426261137
+
+
+ 1536426713520
+
+
+
+ 1536426713520
+
+
+ 1536426798365
+
+
+
+ 1536426798365
+
+
+ 1536428318542
+
+
+
+ 1536428318542
+
+
+ 1536429127582
+
+
+
+ 1536429127582
+
+
+ 1536733349233
+
+
+
+ 1536733349233
+
+
+ 1536734042101
+
+
+
+ 1536734042101
+
+
+ 1536734080399
+
+
+
+ 1536734080399
+
+
+ 1536734107278
+
+
+
+ 1536734107278
+
+
+ 1536740355223
+
+
+
+ 1536740355223
+
+
+ 1536740428541
+
+
+
+ 1536740428541
+
+
+ 1536755165290
+
+
+
+ 1536755165290
+
+
+ 1536755180580
+
+
+
+ 1536755180580
+
+
+ 1536755298128
+
+
+
+ 1536755298128
+
+
+ 1536759081083
+
+
+
+ 1536759081083
+
+
+ 1536759713291
+
+
+
+ 1536759713291
+
+
+ 1536762438800
+
+
+
+ 1536762438800
+
+
+ 1536762559794
+
+
+
+ 1536762559794
+
+
+ 1536762794077
+
+
+
+ 1536762794077
+
+
+ 1536764417230
+
+
+
+ 1536764417230
+
+
+ 1536764914803
+
+
+
+ 1536764914803
+
+
+ 1536765243062
+
+
+
+ 1536765243062
+
+
+ 1536765504956
+
+
+
+ 1536765504956
+
+
+ 1536765540320
+
+
+
+ 1536765540320
+
+
+ 1536765638966
+
+
+
+ 1536765638966
+
+
+ 1536765831882
+
+
+
+ 1536765831882
+
+
+ 1536767498224
+
+
+
+ 1536767498224
+
+
+ 1536767653840
+
+
+
+ 1536767653840
+
+
+ 1536767721691
+
+
+
+ 1536767721691
+
+
+ 1536770497272
+
+
+
+ 1536770497272
+
+
+ 1536770929972
+
+
+
+ 1536770929972
+
+
+ 1536820041782
+
+
+
+ 1536820041782
+
+
+ 1536820124591
+
+
+
+ 1536820124594
+
+
+ 1536841615043
+
+
+
+ 1536841615043
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/src/app-utility
+ 59
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/data/preferences.json b/data/preferences.json
index 03491c2..a31f196 100644
--- a/data/preferences.json
+++ b/data/preferences.json
@@ -1,24 +1,24 @@
{
- "default_locale": "en",
- "autostart_path": "~/.config/autostart/manjaro-hello.desktop",
- "data_path": "/usr/share/manjaro-hello/data/",
- "desktop_path": "/usr/share/applications/manjaro-hello.desktop",
- "installer_path": "/usr/bin/calamares",
- "live_path": "/run/miso/bootmnt/manjaro",
- "locale_path": "/usr/share/locale/",
- "logo_path": "/usr/share/icons/hicolor/64x64/apps/manjaro.png",
- "save_path": "~/.config/manjaro-hello.json",
- "ui_path": "/usr/share/manjaro-hello/ui/manjaro-hello.glade",
- "urls": {
- "development": "https://gitlab.manjaro.org",
- "chat": "https://kiwiirc.com/client/irc.freenode.net/?nick=manjaro-web|?#manjaro",
- "donate": "https://manjaro.org/donate",
- "facebook": "https://www.facebook.com/ManjaroLinux",
- "forum": "https://forum.manjaro.org",
- "google+": "https://plus.google.com/118244873957924966264",
- "mailling": "https://lists.manjaro.org/cgi-bin/mailman/listinfo",
- "reddit": "https://www.reddit.com/r/ManjaroLinux",
- "twitter": "https://twitter.com/ManjaroLinux",
- "wiki": "https://wiki.manjaro.org"
- }
+ "default_locale": "en",
+ "autostart_path": "~/.config/autostart/manjaro-hello.desktop",
+ "data_path": "/usr/share/manjaro-hello/data/",
+ "desktop_path": "/usr/share/applications/manjaro-hello.desktop",
+ "installer_path": "/usr/bin/calamares",
+ "live_path": "/run/miso/bootmnt/manjaro",
+ "locale_path": "/usr/share/locale/",
+ "logo_path": "/usr/share/icons/hicolor/64x64/apps/manjaro.png",
+ "save_path": "~/.config/manjaro-hello.json",
+ "ui_path": "/usr/share/manjaro-hello/ui/manjaro-hello.glade",
+ "urls": {
+ "development": "https://gitlab.manjaro.org",
+ "chat": "https://kiwiirc.com/client/irc.freenode.net/?nick=manjaro-web|?#manjaro",
+ "donate": "https://manjaro.org/donate",
+ "facebook": "https://www.facebook.com/ManjaroLinux",
+ "forum": "https://forum.manjaro.org",
+ "google+": "https://plus.google.com/118244873957924966264",
+ "mailling": "https://lists.manjaro.org/cgi-bin/mailman/listinfo",
+ "reddit": "https://www.reddit.com/r/ManjaroLinux",
+ "twitter": "https://twitter.com/ManjaroLinux",
+ "wiki": "https://wiki.manjaro.org"
+ }
}
diff --git a/src/__init__.py b/src/__init__.py
index e69de29..281af6f 100644
--- a/src/__init__.py
+++ b/src/__init__.py
@@ -0,0 +1 @@
+__all__ = ["manjaro_hello"]
\ No newline at end of file
diff --git a/src/manjaro_hello.py b/src/manjaro_hello.py
index 3040cca..d7e43d1 100644
--- a/src/manjaro_hello.py
+++ b/src/manjaro_hello.py
@@ -1,21 +1,34 @@
#!/usr/bin/env python3
import gettext
+import gi
import json
import locale
+import logging
import os
import subprocess
import sys
import webbrowser
-import gi
+
+try:
+ from application_utility.browser.application_browser import ApplicationBrowser
+ from application_utility.browser.exceptions import NoAppInIsoError
+ from application_utility.browser.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 Hello():
+class Hello(Gtk.Window):
"""Hello"""
def __init__(self):
+ Gtk.Window.__init__(self, title="Manjaro Hello", border_width=6)
self.app = "manjaro-hello"
self.dev = "--dev" in sys.argv # Dev mode activated ?
@@ -23,12 +36,11 @@ class Hello():
if self.dev:
self.preferences = read_json("data/preferences.json")
self.preferences["data_path"] = "data/"
- self.preferences["desktop_path"] = os.getcwd() + "/{}.desktop".format(self.app)
+ self.preferences["desktop_path"] = os.getcwd() + f"/{self.app}.desktop"
self.preferences["locale_path"] = "locale/"
- self.preferences["ui_path"] = "ui/{}.glade".format(self.app)
+ self.preferences["ui_path"] = f"ui/{self.app}.glade"
else:
- self.preferences = read_json("/usr/share/{}/data/preferences.json".format(self.app))
-
+ self.preferences = read_json(f"/usr/share/{self.app}/data/preferences.json")
# Get saved infos
self.save = read_json(self.preferences["save_path"])
if not self.save:
@@ -55,7 +67,7 @@ class Hello():
for widget in self.builder.get_object("homepage").get_children():
if isinstance(widget, Gtk.Button) and \
- widget.get_image_position() is Gtk.PositionType.RIGHT:
+ 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)
@@ -84,10 +96,17 @@ class Hello():
self.builder.get_object("autostart").set_active(self.autostart)
# Live systems
- if os.path.exists(self.preferences["live_path"]) and \
- os.path.isfile(self.preferences["installer_path"]):
+ if os.path.exists(self.preferences["live_path"]) and os.path.isfile(self.preferences["installer_path"]):
self.builder.get_object("installlabel").set_visible(True)
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)
self.window.show()
@@ -115,24 +134,24 @@ class Hello():
else:
return self.preferences["default_locale"]
- def set_locale(self, locale):
+ def set_locale(self, use_locale):
"""Set locale of ui and pages.
- :param locale: locale to use
- :type locale: str
+ :param use_locale: locale to use
+ :type use_locale: str
"""
try:
translation = gettext.translation(self.app, self.preferences[
- "locale_path"], [locale], fallback=True)
+ "locale_path"], [use_locale], fallback=True)
translation.install()
except OSError:
return
- self.save["locale"] = locale
+ self.save["locale"] = use_locale
# Real-time locale changing
elts = {
- "comments": { "aboutdialog"},
+ "comments": {"aboutdialog"},
"label": {
"autostartlabel",
"development",
@@ -193,14 +212,14 @@ class Hello():
i3_config = fix_path("~/.i3/config")
if os.path.isfile(i3_config):
i3_autostart = "exec --no-startup-id " + self.app
- with open(i3_config, "r+") as fil:
- content = fil.read()
- fil.seek(0)
+ with open(i3_config, "r+") as file:
+ content = file.read()
+ file.seek(0)
if autostart:
- fil.write(content.replace("#" + i3_autostart, i3_autostart))
+ file.write(content.replace("#" + i3_autostart, i3_autostart))
else:
- fil.write(content.replace(i3_autostart, "#" + i3_autostart))
- fil.truncate()
+ file.write(content.replace(i3_autostart, "#" + i3_autostart))
+ file.truncate()
self.autostart = autostart
except OSError as error:
print(error)
@@ -215,7 +234,7 @@ class Hello():
filename = self.preferences["data_path"] + "pages/{}/{}".format(self.save["locale"], name)
if not os.path.isfile(filename):
filename = self.preferences["data_path"] + \
- "pages/{}/{}".format(self.preferences["default_locale"], name)
+ "pages/{}/{}".format(self.preferences["default_locale"], name)
try:
with open(filename, "r") as fil:
return fil.read()
@@ -238,9 +257,13 @@ class Hello():
dialog = self.builder.get_object("aboutdialog")
dialog.run()
dialog.hide()
+ elif name == "appBrowser":
+ # or use only "on_btn_clicked" ?
+ self.builder.get_object("home").set_sensitive(not name == "home")
+ self.builder.get_object("stack").set_visible_child_name(name + "page")
def on_btn_clicked(self, btn):
- """Event for clicked button."""
+ """Event for applications button."""
name = btn.get_name()
self.builder.get_object("home").set_sensitive(not name == "home")
self.builder.get_object("stack").set_visible_child_name(name + "page")
@@ -296,14 +319,15 @@ def write_json(path, content):
except OSError as error:
print(error)
+
def get_lsb_infos():
"""Read informations from the lsb-release file.
:return: args from lsb-release file
:rtype: dict"""
lsb = {}
try:
- with open("/etc/lsb-release") as fil:
- for line in fil:
+ with open("/etc/lsb-release") as lsb_release:
+ for line in lsb_release:
if "=" in line:
var, arg = line.rstrip().split("=")
if var.startswith("DISTRIB_"):
@@ -312,11 +336,14 @@ def get_lsb_infos():
arg = arg[1:-1]
if arg:
lsb[var] = arg
- except OSError as error:
+ except (OSError, KeyError) as error:
print(error)
+ return 'not Manjaro', '0.0'
return lsb["CODENAME"], lsb["RELEASE"]
if __name__ == "__main__":
- Hello()
+ logging.basicConfig(level=logging.DEBUG)
+ hello = Hello()
+ hello.connect("destroy", Gtk.main_quit)
Gtk.main()
diff --git a/ui/manjaro-hello.glade b/ui/manjaro-hello.glade
index 3c38124..ec3df93 100644
--- a/ui/manjaro-hello.glade
+++ b/ui/manjaro-hello.glade
@@ -1,5 +1,5 @@
-
+
-
-
-
False
@@ -586,6 +600,9 @@ Stéphane
Андрей Раугас
gpl-3-0
+
+
+
True
@@ -608,8 +625,5 @@ Stéphane
-
-
-