Merge branch 'plugins' into 'master'
Merge Plugins branch into master: this allow gnome-layouts-switcher to work as a plugin. See merge request applications/manjaro-hello!72fhdk-master-patch-98229
commit
db5194a319
|
@ -2,7 +2,7 @@
|
||||||
# Script to generate mo files in a temp locale folder
|
# Script to generate mo files in a temp locale folder
|
||||||
# Use it only for testing purpose
|
# Use it only for testing purpose
|
||||||
export PLUGIN_HELLO=True
|
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
|
rm -rf locale
|
||||||
mkdir locale
|
mkdir locale
|
||||||
cd po
|
cd po
|
||||||
|
|
|
@ -13,18 +13,82 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
|
||||||
|
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:
|
try:
|
||||||
from application_utility.browser.application_browser import ApplicationBrowser
|
from application_utility.browser.application_browser import ApplicationBrowser
|
||||||
from application_utility.browser.exceptions import NoAppInIsoError
|
from application_utility.browser.exceptions import NoAppInIsoError
|
||||||
from application_utility.config.hello_config import HelloConfig
|
from application_utility.config.hello_config import HelloConfig
|
||||||
APPS_PLUGIN = True
|
try:
|
||||||
|
conf = HelloConfig(application="manjaro-hello")
|
||||||
except ModuleNotFoundError as e:
|
self.box = ApplicationBrowser(conf, window)
|
||||||
APPS_PLUGIN = False
|
except Exception as err:
|
||||||
print(f"Warning: Application Browser plugin not found : {e}")
|
print("Error in Embled application:", err)
|
||||||
|
except ModuleNotFoundError as err:
|
||||||
gi.require_version("Gtk", "3.0")
|
print(f"Info: Application-utility not installed")
|
||||||
from gi.repository import Gtk, GdkPixbuf
|
self.loaded = self.box is not None
|
||||||
|
return self.loaded
|
||||||
|
|
||||||
|
|
||||||
class Hello(Gtk.Window):
|
class Hello(Gtk.Window):
|
||||||
|
@ -73,7 +137,7 @@ class Hello(Gtk.Window):
|
||||||
widget.get_image_position() is Gtk.PositionType.RIGHT:
|
widget.get_image_position() is Gtk.PositionType.RIGHT:
|
||||||
img = Gtk.Image.new_from_file(
|
img = Gtk.Image.new_from_file(
|
||||||
self.preferences["data_path"] + "img/external-link.png")
|
self.preferences["data_path"] + "img/external-link.png")
|
||||||
img.set_margin_left(2)
|
img.set_margin_start(2)
|
||||||
widget.set_image(img)
|
widget.set_image(img)
|
||||||
|
|
||||||
# Create pages
|
# Create pages
|
||||||
|
@ -104,12 +168,9 @@ class Hello(Gtk.Window):
|
||||||
self.builder.get_object("install").set_visible(True)
|
self.builder.get_object("install").set_visible(True)
|
||||||
# Installed systems
|
# Installed systems
|
||||||
else:
|
else:
|
||||||
if APPS_PLUGIN:
|
manager = EmbedManager(EmbedBrowser(), EmbedLayouts())
|
||||||
conf = HelloConfig(application="manjaro-hello")
|
manager.get_modules(self)
|
||||||
app_browser = ApplicationBrowser(conf, self)
|
manager.display(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()
|
self.window.show()
|
||||||
|
|
||||||
|
@ -333,12 +394,10 @@ def get_lsb_infos():
|
||||||
for line in lsb_release:
|
for line in lsb_release:
|
||||||
if "=" in line:
|
if "=" in line:
|
||||||
var, arg = line.rstrip().split("=")
|
var, arg = line.rstrip().split("=")
|
||||||
if var.startswith("DISTRIB_"):
|
if not arg:
|
||||||
var = var[8:]
|
continue
|
||||||
if arg.startswith("\"") and arg.endswith("\""):
|
var = var.replace("DISTRIB_","")
|
||||||
arg = arg[1:-1]
|
lsb[var] = arg.strip('"')
|
||||||
if arg:
|
|
||||||
lsb[var] = arg
|
|
||||||
except (OSError, KeyError) as error:
|
except (OSError, KeyError) as error:
|
||||||
print(error)
|
print(error)
|
||||||
return 'not Manjaro', '0.0'
|
return 'not Manjaro', '0.0'
|
||||||
|
|
|
@ -502,25 +502,55 @@ We, the Manjaro Developers, hope that you will enjoy using Manjaro as much as we
|
||||||
<property name="top_attach">8</property>
|
<property name="top_attach">8</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="name">boxPlugins</property>
|
||||||
|
<property name="spacing">0</property>
|
||||||
|
<property name="homogeneous">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="appBrowser">
|
<object class="GtkButton" id="appBrowser">
|
||||||
<property name="label" translatable="yes">Applications</property>
|
<property name="label" translatable="yes">Applications</property>
|
||||||
<property name="name">appBrowser</property>
|
<property name="name">appBrowser</property>
|
||||||
|
<property name="visible">False</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="tooltip_text" translatable="yes">Common application selection</property>
|
<property name="tooltip_text" translatable="yes">Common application selection</property>
|
||||||
|
<property name="margin_left">15</property>
|
||||||
|
<property name="margin_right">15</property>
|
||||||
<signal name="clicked" handler="on_btn_clicked" swapped="no"/>
|
<signal name="clicked" handler="on_btn_clicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="expand">True</property>
|
||||||
<property name="top_attach">8</property>
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<object class="GtkButton" id="appLayouts">
|
||||||
|
<property name="label" translatable="yes">Gnome Layouts Manager</property>
|
||||||
|
<property name="name">appLayouts</property>
|
||||||
|
<property name="visible">False</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="tooltip_text" translatable="yes">Manjaro Gnone config tool</property>
|
||||||
|
<property name="margin_left">15</property>
|
||||||
|
<property name="margin_right">15</property>
|
||||||
|
<signal name="clicked" handler="on_btn_clicked" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
</object>
|
||||||
<placeholder/>
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">8</property>
|
||||||
|
<property name="width">3</property>
|
||||||
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
|
|
Loading…
Reference in New Issue