diff --git a/plugins/date/date.py b/plugins/date/date.py index 466a81a..6c6e4e3 100644 --- a/plugins/date/date.py +++ b/plugins/date/date.py @@ -4,6 +4,7 @@ import CryptoBoxPlugin class date(CryptoBoxPlugin.CryptoBoxPlugin): pluginCapabilities = [ "system" ] + pluginVisibility = [ "preferences" ] requestAuth = False rank = 10 diff --git a/plugins/disks/disks.py b/plugins/disks/disks.py index 5824a72..dddab93 100644 --- a/plugins/disks/disks.py +++ b/plugins/disks/disks.py @@ -2,7 +2,8 @@ import CryptoBoxPlugin class disks(CryptoBoxPlugin.CryptoBoxPlugin): - pluginCapabilities = [ "menu" ] + pluginCapabilities = [ "system" ] + pluginVisibility = [ "menu" ] requestAuth = False rank = 10 diff --git a/plugins/format_fs/format_fs.py b/plugins/format_fs/format_fs.py index a5463d8..3dafed8 100644 --- a/plugins/format_fs/format_fs.py +++ b/plugins/format_fs/format_fs.py @@ -4,6 +4,7 @@ from CryptoBoxExceptions import * class format_fs(CryptoBoxPlugin.CryptoBoxPlugin): pluginCapabilities = [ "volume" ] + pluginVisibility = [ "volume" ] requestAuth = True rank = 60 diff --git a/plugins/help/help.py b/plugins/help/help.py index b9c9be5..7381253 100644 --- a/plugins/help/help.py +++ b/plugins/help/help.py @@ -2,7 +2,8 @@ import CryptoBoxPlugin class help(CryptoBoxPlugin.CryptoBoxPlugin): - pluginCapabilities = [ "menu" ] + pluginCapabilities = [ "system" ] + pluginVisibility = [ "menu" ] requestAuth = False rank = 80 diff --git a/plugins/language_selection/language_selection.py b/plugins/language_selection/language_selection.py index 9b28764..7290ce9 100644 --- a/plugins/language_selection/language_selection.py +++ b/plugins/language_selection/language_selection.py @@ -3,7 +3,8 @@ import CryptoBoxPlugin class language_selection(CryptoBoxPlugin.CryptoBoxPlugin): - pluginCapabilities = [ "system", "menu" ] + pluginCapabilities = [ "system" ] + pluginVisibility = [ "menu", "preferences" ] requestAuth = False rank = 60 diff --git a/plugins/logs/logs.py b/plugins/logs/logs.py index 683056a..09b033e 100644 --- a/plugins/logs/logs.py +++ b/plugins/logs/logs.py @@ -4,6 +4,7 @@ import os class logs(CryptoBoxPlugin.CryptoBoxPlugin): pluginCapabilities = [ "system" ] + pluginVisibility = [ "preferences" ] requestAuth = False rank = 90 diff --git a/plugins/network/network.py b/plugins/network/network.py index 5d6d0d2..7a6f65f 100644 --- a/plugins/network/network.py +++ b/plugins/network/network.py @@ -10,6 +10,7 @@ CHANGE_IP_DELAY=1 class network(CryptoBoxPlugin.CryptoBoxPlugin): pluginCapabilities = [ "system" ] + pluginVisibility = [ "preferences" ] requestAuth = True rank = 30 diff --git a/plugins/partition/partition.py b/plugins/partition/partition.py index 20b2222..723ad48 100644 --- a/plugins/partition/partition.py +++ b/plugins/partition/partition.py @@ -7,6 +7,7 @@ import CryptoBoxPlugin class partition(CryptoBoxPlugin.CryptoBoxPlugin): pluginCapabilities = [ "system" ] + pluginVisibility = [ "preferences" ] requestAuth = True rank = 80 diff --git a/plugins/plugin-interface.txt b/plugins/plugin-interface.txt index 3fef72f..7e4e0ee 100644 --- a/plugins/plugin-interface.txt +++ b/plugins/plugin-interface.txt @@ -32,11 +32,13 @@ Python code interface: time (for the "date" plugin)) - the class variable "pluginCapabilities" must be an array of strings (supported: "system" and "volume") + - the class variable "pluginVisibility" may contain one or more of the following items: + menu/preferences/volume. This obviously should fit to the 'pluginCapabilities' variable. + An empty list is interpreted as a disabled plugin. - the class variable "requestAuth" is boolean and defines, if admin authentication is necessary for this plugin - the class variable "rank" is an integer in the range of 0..100 - it determines the order of plugins in listings (lower value -> higher priority) - - the class variable "enabled" is boolean and detemines the default availability of the plugin - volume plugins contain the attribute "device" (you may trust this value - a volume plugin will never get called with an invalid device) - the python module which contains the plugin's class should also contain a class called @@ -50,8 +52,8 @@ Language file structure: Name (a short description) Link (the visible text for links to this plugin) Rank (defines the order of the plugins displayed (0..100)) - - all warnings, error and success messages should be stored below WarningMessage.??? - (resp. ErrorMessage or SuccessMessage) + - all warnings, hints and success messages should be stored below WarningMessage.??? + (resp. AdviceMessage or SuccessMessage) Clearsilver template: diff --git a/plugins/plugin_manager/gtk-ok_nuvola.png b/plugins/plugin_manager/gtk-ok_nuvola.png deleted file mode 100644 index b89792c..0000000 Binary files a/plugins/plugin_manager/gtk-ok_nuvola.png and /dev/null differ diff --git a/plugins/plugin_manager/gtk-stop_nuvola.png b/plugins/plugin_manager/gtk-stop_nuvola.png deleted file mode 100644 index 788a2fd..0000000 Binary files a/plugins/plugin_manager/gtk-stop_nuvola.png and /dev/null differ diff --git a/plugins/plugin_manager/lang/en.hdf b/plugins/plugin_manager/lang/en.hdf index 26542d4..b3d2a1c 100644 --- a/plugins/plugin_manager/lang/en.hdf +++ b/plugins/plugin_manager/lang/en.hdf @@ -1,17 +1,24 @@ Name = Plugin Manager Link = Manage plugins -Title.PluginManager = Plugin Manager +Title { + PluginManager = Plugin Manager + VolumePlugins = Volume plugins + SystemPlugins = System plugins +} -Button.SaveSettings = Save settings +Button { + SaveSettings = Save settings + Up = move up + Down = move down +} Text { PluginName = Plugin - PluginRank = Priority + PluginRank = Order PluginEnabled = Enabled? RequestsAuth = Requires admin? - VolumePlugin = Volume - SystemPlugin = System - MenuPlugin = Menu - PluginTypes = Type of plugin + InMenu = Main menu + InPreferences = Preferences + WhereVisible = Where visible? } diff --git a/plugins/plugin_manager/plugin_list.cs b/plugins/plugin_manager/plugin_list.cs index 93206e5..dbeb8ae 100644 --- a/plugins/plugin_manager/plugin_list.cs +++ b/plugins/plugin_manager/plugin_list.cs @@ -14,6 +14,10 @@ width: 24px; height: 24px; } + + table.plugin_list a img { + border: none; + } @@ -22,36 +26,75 @@ +

+ - +

+ + + + + + + + + + + + + +
checked="checked" />checked="checked" /> + "> + <?cs var:html_escape(Lang.Plugins.plugin_manager.Button.Down) ?> + " > + <?cs var:html_escape(Lang.Plugins.plugin_manager.Button.Up) ?> +

+ + +

+ +

- + + - - - - - + + + - - - - - - - + + + - -
X-X-X-checked="checked" />checked="checked" />checked="checked" /> checked="checked" />
+ + "> + <?cs var:html_escape(Lang.Plugins.plugin_manager.Button.Down) ?> + " > + <?cs var:html_escape(Lang.Plugins.plugin_manager.Button.Up) ?> + + +

@@ -59,3 +102,5 @@

+ + diff --git a/plugins/plugin_manager/plugin_manager.py b/plugins/plugin_manager/plugin_manager.py index 3b6a839..cd6e19b 100644 --- a/plugins/plugin_manager/plugin_manager.py +++ b/plugins/plugin_manager/plugin_manager.py @@ -1,15 +1,30 @@ import CryptoBoxPlugin +import Plugins class plugin_manager(CryptoBoxPlugin.CryptoBoxPlugin): pluginCapabilities = [ "system" ] + pluginVisibility = [ "preferences" ] requestAuth = True rank = 90 - def doAction(self, store=None, **args): + def doAction(self, store=None, action=None, plugin_name=None, **args): import re - if store: + if plugin_name: + ## check for invalid characters + if re.search(u'\W', plugin_name): return "plugin_list" + pluginList = Plugins.PluginManager(self.cbox, self.cbox.prefs["Locations"]["PluginDir"]) + plugin = pluginList.getPlugin(plugin_name) + if not plugin: return "plugin_list" + ## take only plugins, that are of the same type as the choosen one + self.plugins = [e for e in pluginList.getPlugins() if e.pluginCapabilities == plugin.pluginCapabilities] + if action == "up": + self.__move_up(plugin) + elif action == "down": + self.__move_down(plugin) + return "plugin_list" + elif store: for key in args.keys(): if key.endswith("_listed"): if not re.search(u'\W',key): @@ -27,26 +42,80 @@ class plugin_manager(CryptoBoxPlugin.CryptoBoxPlugin): return "no status" + def __sortPlugins(self): + """sort all plugins in the list according to their rank""" + def cmp_func(x,y): + xRank = x.getRank() + yRank = y.getRank() + if xRank < yRank: return -1 + elif xRank == yRank: return 0 + else: return 1 + self.plugins.sort(cmp = cmp_func) + + + def __distributeRanks(self): + """evenly distribute the 'rank' values according to the current order of + the list""" + dist = 100/len(self.plugins) + for index,pl in enumerate(self.plugins): + try: + self.cbox.prefs.pluginConf[pl.getName()]["rank"] = dist*index + except KeyError: + self.cbox.prefs.pluginConf[pl.getName()] = {} + self.cbox.prefs.pluginConf[pl.getName()]["rank"] = dist*index + self.cbox.prefs.pluginConf.write() + + + def __move_up(self, plugin): + self.__sortPlugins() + try: + index = self.plugins.index(plugin) + ## first elements may not move up + if index == 0: + return + except ValueError: + return + self.plugins.remove(plugin) + self.plugins.insert(index-1, plugin) + self.__distributeRanks() + + + def __move_down(self, plugin): + self.__sortPlugins() + try: + index = self.plugins.index(plugin) + ## last elements may not move down + if index == len(self.plugins) - 1: + return + except ValueError: + return + self.plugins.remove(plugin) + self.plugins.insert(index+1, plugin) + self.__distributeRanks() + + def __setConfig(self, name, args): + import re setting = {} - setting["enabled"] = False - try: - if args[name + "_enabled"]: - setting["enabled"] = True - except KeyError: - pass - setting["rank"] = "80" + setting["visibility"] = [] + ## look for "_visible_" values and apply them + pattern = re.compile(u'%s_visible_([\w]+)$' % name) + for key in args.keys(): + if key.startswith(name + "_visible_"): + (vis_type, ) = pattern.match(key).groups() + setting["visibility"].append(vis_type) + setting["rank"] = "50" try: r = int(args[name + "_rank"]) if r>=0 and r<=100: setting["rank"] = r - except KeyError, ValueError: + except (KeyError, ValueError): pass setting["requestAuth"] = False try: if args[name + "_auth"]: setting["requestAuth"] = True - except KeyError, ValueError: + except (KeyError, ValueError): pass self.cbox.prefs.pluginConf[name] = setting diff --git a/plugins/plugin_manager/tango-go-down.png b/plugins/plugin_manager/tango-go-down.png new file mode 100644 index 0000000..6a8566d Binary files /dev/null and b/plugins/plugin_manager/tango-go-down.png differ diff --git a/plugins/plugin_manager/tango-go-up.png b/plugins/plugin_manager/tango-go-up.png new file mode 100644 index 0000000..a1576db Binary files /dev/null and b/plugins/plugin_manager/tango-go-up.png differ diff --git a/plugins/shutdown/shutdown.py b/plugins/shutdown/shutdown.py index 0638058..8f3773a 100644 --- a/plugins/shutdown/shutdown.py +++ b/plugins/shutdown/shutdown.py @@ -4,7 +4,8 @@ REDIRECT_DELAY = 180 class shutdown(CryptoBoxPlugin.CryptoBoxPlugin): - pluginCapabilities = [ "system", "menu" ] + pluginCapabilities = [ "system" ] + pluginVisibility = [ "preferences", "menu" ] requestAuth = False rank = 90 diff --git a/plugins/system_preferences/show_plugins.cs b/plugins/system_preferences/show_plugins.cs index b39f6a1..a36c9a1 100644 --- a/plugins/system_preferences/show_plugins.cs +++ b/plugins/system_preferences/show_plugins.cs @@ -7,7 +7,7 @@ + ?> diff --git a/plugins/system_preferences/system_preferences.py b/plugins/system_preferences/system_preferences.py index df86e14..cc67c22 100644 --- a/plugins/system_preferences/system_preferences.py +++ b/plugins/system_preferences/system_preferences.py @@ -2,7 +2,8 @@ import CryptoBoxPlugin class system_preferences(CryptoBoxPlugin.CryptoBoxPlugin): - pluginCapabilities = [ "menu" ] + pluginCapabilities = [ "system" ] + pluginVisibility = [ "menu" ] requestAuth = False rank = 20 diff --git a/plugins/user_manager/user_manager.py b/plugins/user_manager/user_manager.py index 088060f..f638ead 100644 --- a/plugins/user_manager/user_manager.py +++ b/plugins/user_manager/user_manager.py @@ -5,6 +5,7 @@ RESERVED_USERS = [ "admin" ] class user_manager(CryptoBoxPlugin.CryptoBoxPlugin): pluginCapabilities = [ "system" ] + pluginVisibility = [ "preferences" ] requestAuth = True rank = 45 diff --git a/plugins/volume_details/volume_details.py b/plugins/volume_details/volume_details.py index 40d82db..941ad62 100644 --- a/plugins/volume_details/volume_details.py +++ b/plugins/volume_details/volume_details.py @@ -4,6 +4,7 @@ import CryptoBoxPlugin class volume_details(CryptoBoxPlugin.CryptoBoxPlugin): pluginCapabilities = [ "volume" ] + pluginVisibility = [ "volume" ] requestAuth = False rank = 100 diff --git a/plugins/volume_mount/volume_mount.py b/plugins/volume_mount/volume_mount.py index 9d3cbf4..69979c8 100644 --- a/plugins/volume_mount/volume_mount.py +++ b/plugins/volume_mount/volume_mount.py @@ -5,6 +5,7 @@ from CryptoBoxExceptions import * class volume_mount(CryptoBoxPlugin.CryptoBoxPlugin): pluginCapabilities = [ "volume" ] + pluginVisibility = [ "volume" ] requestAuth = False rank = 0 diff --git a/plugins/volume_props/volume_props.py b/plugins/volume_props/volume_props.py index 605dc75..6cfcb5d 100644 --- a/plugins/volume_props/volume_props.py +++ b/plugins/volume_props/volume_props.py @@ -5,6 +5,7 @@ from CryptoBoxExceptions import * class volume_props(CryptoBoxPlugin.CryptoBoxPlugin): pluginCapabilities = [ "volume" ] + pluginVisibility = [ "volume" ] requestAuth = False rank = 40