Skip to content

Commit

Permalink
[NetworkBrowser]
Browse files Browse the repository at this point in the history
* reorg menu for ATV
  • Loading branch information
jbleyel committed Jan 17, 2024
1 parent 2bdf643 commit 05fa118
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
18 changes: 18 additions & 0 deletions networkbrowser/src/MountManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@
from .AutoMount import iAutoMount, AutoMount
from .UserManager import UserManager

try:
from Components.SystemInfo import BoxInfo
IMAGEDISTRO = BoxInfo.getItem("distro")
except:
from boxbranding import getImageDistro
IMAGEDISTRO = getImageDistro()


class AutoMountManager(Screen):
skin = """
<screen name="AutoMountManager" position="center,center" size="560,400" title="AutoMountManager">
<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
<widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
<widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
<widget source="config" render="Listbox" position="5,50" size="540,300" scrollbarMode="showOnDemand" >
<convert type="TemplatedMultiContent">
{"template": [
Expand Down Expand Up @@ -59,6 +67,13 @@ def __init__(self, session, iface, plugin_path):
"red": self.exit,
})
self["key_red"] = StaticText(_("Close"))
if IMAGEDISTRO in ("openatv",):
self["key_yellow"] = StaticText(_("Mount Again"))
self["mountactions"] = ActionMap(["ColorActions"],
{
"yellow": self.mountAgain,
})

self["introduction"] = StaticText(_("Press OK to select."))

self.list = []
Expand Down Expand Up @@ -170,6 +185,9 @@ def restartfinishedCB(self, data):
def createSetup(self):
self.session.open(MountManagerMenu)

def mountAgain(self):
iAutoMount.getAutoMountPoints()


config.networkbrowser = ConfigSubsection()
config.networkbrowser.automountpoll = ConfigYesNo(default=False)
Expand Down
42 changes: 36 additions & 6 deletions networkbrowser/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
from Components.Network import iNetwork
from .MountManager import AutoMountManager
from .AutoMount import iAutoMount
from Components.SystemInfo import BoxInfo

try:
from Components.SystemInfo import BoxInfo
IMAGEDISTRO = BoxInfo.getItem("distro")
except:
from boxbranding import getImageDistro
IMAGEDISTRO = getImageDistro()

plugin_path = ""
mountagaincheckpoller = None
Expand Down Expand Up @@ -104,12 +112,34 @@ def SchedMount(session, **kwargs):
session.open(MountAgainCheck)


def menuBrowser(menuid, **kwargs):
if menuid == "network":
return [(_("Network Browser"), NetworkBrowserMain, "netmounts_browser", 1)]
else:
return []


def menuManager(menuid, **kwargs):
if menuid == "network":
return [(_("Mount Manager"), MountManagerMain, "netmounts_manager", 2)]
else:
return []


def Plugins(path, **kwargs):
global plugin_path
plugin_path = path
return [
PluginDescriptor(where=[PluginDescriptor.WHERE_AUTOSTART, PluginDescriptor.WHERE_SESSIONSTART], fnc=autostart),
PluginDescriptor(name=_("Network Browser"), description=_("Search for network shares"), where=PluginDescriptor.WHERE_NETWORKMOUNTS, fnc={"ifaceSupported": NetworkBrowserCallFunction, "menuEntryName": lambda x: _("Network Browser"), "menuEntryDescription": lambda x: _("Search for network shares...")}),
PluginDescriptor(name=_("Mount Manager"), description=_("Manage network shares"), where=PluginDescriptor.WHERE_NETWORKMOUNTS, fnc={"ifaceSupported": MountManagerCallFunction, "menuEntryName": lambda x: _("Mount Manager"), "menuEntryDescription": lambda x: _("Manage your network shares...")}),
PluginDescriptor(name=_("Mount Again"), description=_("Attempt to mount shares again"), where=PluginDescriptor.WHERE_NETWORKMOUNTS, fnc={"ifaceSupported": RemountCallFunction, "menuEntryName": lambda x: _("Mount again"), "menuEntryDescription": lambda x: _("Attempt to recover lost mounts (in background)")})
]

if IMAGEDISTRO in ("openatv",):
return [
PluginDescriptor(where=[PluginDescriptor.WHERE_AUTOSTART, PluginDescriptor.WHERE_SESSIONSTART], fnc=autostart),
PluginDescriptor(name=_("Network Browser"), description=_("Search for network shares"), where=PluginDescriptor.WHERE_MENU, fnc=menuBrowser),
PluginDescriptor(name=_("Mount Manager"), description=_("Manage network shares"), where=PluginDescriptor.WHERE_MENU, fnc=menuManager),
]
else:
return [
PluginDescriptor(where=[PluginDescriptor.WHERE_AUTOSTART, PluginDescriptor.WHERE_SESSIONSTART], fnc=autostart),
PluginDescriptor(name=_("Network Browser"), description=_("Search for network shares"), where=PluginDescriptor.WHERE_NETWORKMOUNTS, fnc={"ifaceSupported": NetworkBrowserCallFunction, "menuEntryName": lambda x: _("Network Browser"), "menuEntryDescription": lambda x: _("Search for network shares...")}),
PluginDescriptor(name=_("Mount Manager"), description=_("Manage network shares"), where=PluginDescriptor.WHERE_NETWORKMOUNTS, fnc={"ifaceSupported": MountManagerCallFunction, "menuEntryName": lambda x: _("Mount Manager"), "menuEntryDescription": lambda x: _("Manage your network shares...")}),
PluginDescriptor(name=_("Mount Again"), description=_("Attempt to mount shares again"), where=PluginDescriptor.WHERE_NETWORKMOUNTS, fnc={"ifaceSupported": RemountCallFunction, "menuEntryName": lambda x: _("Mount again"), "menuEntryDescription": lambda x: _("Attempt to recover lost mounts (in background)")})
]

2 comments on commit 05fa118

@koivo
Copy link
Contributor

@koivo koivo commented on 05fa118 Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit breaks networkbrowser on images without boxinfo.
Please fix this.

from Components.SystemInfo import BoxInfo

@koivo
Copy link
Contributor

@koivo koivo commented on 05fa118 Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.