summaryrefslogtreecommitdiffstats
path: root/qml/helpers.py
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2018-12-06 12:47:17 +0100
committerPapoteur <papoteur@mageia.org>2018-12-17 10:19:29 +0100
commitd16c6580baed691a873d5bfa1e9af2b5b7146cda (patch)
treedc48c6d35fba31f1625621208ca6642b8d541ec8 /qml/helpers.py
parentfb5ab5bd0965dc2741e842bbaa2832860b01e831 (diff)
downloadmageiawelcome-d16c6580baed691a873d5bfa1e9af2b5b7146cda.tar
mageiawelcome-d16c6580baed691a873d5bfa1e9af2b5b7146cda.tar.gz
mageiawelcome-d16c6580baed691a873d5bfa1e9af2b5b7146cda.tar.bz2
mageiawelcome-d16c6580baed691a873d5bfa1e9af2b5b7146cda.tar.xz
mageiawelcome-d16c6580baed691a873d5bfa1e9af2b5b7146cda.zip
Add QML matter
Suppress webkit matter
Diffstat (limited to 'qml/helpers.py')
-rw-r--r--qml/helpers.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/qml/helpers.py b/qml/helpers.py
new file mode 100644
index 0000000..773070d
--- /dev/null
+++ b/qml/helpers.py
@@ -0,0 +1,83 @@
+# -*- coding: utf-8 -*-
+
+
+import csv
+import gettext
+import rpm
+
+gettext.install("mageiawelcome")
+
+install = _("Install")
+launch = _("Launch")
+
+ts = rpm.TransactionSet()
+
+def get_desktop_name(x):
+ return {
+ '01plasma':'KDE Plasma',
+ '02GNOME':'Gnome',
+ 'gnome': 'Gnome Wayland',
+ 'gnome-xorg': 'Gnome X.org',
+ 'LXDE':'LXDE',
+ 'MATE':'Mate',
+ 'Cinnamon':'Cinnamon',
+ '23E17':'Enlightenment',
+ '07IceWM':'IceWM',
+ '26Openbox':'Openbox',
+ '03WindowMaker':'WindowMaker',
+ '09Fvwm2':'Fvwm2',
+ }.get(x,'Other')
+
+def get_desktop_name2(x):
+ return {
+ 'KDE':'KDE Plasma',
+ 'XFCE':'Xfce',
+ 'LXQt':'LXQt',
+ 'MATE':'Mate',
+ 'GNOME':'Gnome',
+ 'X-Cinnamon':'Cinnamon',
+ }.get(x,'unknown')
+
+
+def is_installed(name):
+ mi = ts.dbMatch('name', name)
+ release = ""
+ for h in mi:
+ release = (h['release']).decode("utf-8")
+ if release.endswith("tainted"):
+ repo = 'tainted'
+ elif release.endswith("nonfree"):
+ repo = 'nonfree'
+ else:
+ repo = ''
+ return release != "", repo
+
+
+def get_listapp():
+ listapp = ''
+ with open("apps.csv", 'rt') as f:
+ mycsv = csv.reader(f,delimiter='|')
+ next(mycsv)
+ for r in mycsv:
+ if (r[5] == 'false'):
+ start_btn = ""
+ else:
+ start_btn = "<button class='cmd small green' data-run='"+ r[5] + "'><i class='icon-ok-sign'> </i>" + launch +"</button>"
+ if (r[6] != ''):
+ label = "<span class='label red'>" + r[6] + "</span>"
+ title = " title='{}'".format(_("Need {} repository enabled").format(r[6]))
+ else:
+ label = ""
+ title = ""
+ is_app_installed, repo = is_installed(r[1])
+ if ( not is_app_installed or repo != r[6]):# NOT INSTALLED IN EXPECTED RELEASE
+ if is_app_installed and r[6] == "": # ANOTHER RELEASE THAN CORE IS INSTALLED
+ listapp += "<li class='urpme " + r[3] +"' id='" + r[0] + "'><img class=icon src=img/" + r[0] + ".png /><div class='chkbox'></div> \
+<h6>" + r[2] + "</h6><p class='description'>" + r[4] + "</p>" + label
+ else:
+ listapp += "<li class='" + r[3] +"' id='" + r[0] + "'><img class=icon src=img/" + r[0] + ".png /><div class='chkbox'><input type='checkbox' datasrc='" + r[1] +"'></div> \
+<h6>" + r[2] + "</h6><p class='description'>" + r[4] + "</p>" + label + "<button class='inst small' data-rpm='" + r[1] + "'" + title +"><i class='icon-circle-arrow-down'> </i>" + install +"</button></li>"
+ else: # INSTALLED
+ listapp += "<li class='urpme " + r[3] +"' id='" + r[0] + "'><img class=icon src=img/" + r[0] + ".png /><div class='chkbox'></div> \
+<h6>" + r[2] + "</h6><p class='description'>" + r[4] + "</p>" + start_btn + label + "</li>"
+ return listapp