[kupfer] plugin.session_support: Refactor commands
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] plugin.session_support: Refactor commands
- Date: Sun, 6 Dec 2009 20:47:35 +0000 (UTC)
commit 2aaaf811669aa167a16bfe2ab7d9ba13d752eba7
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sun Dec 6 17:24:43 2009 +0100
plugin.session_support: Refactor commands
Refactor the RunnableLeaves of session_support. Leaf.object of each of
them is now the list of commands they will run.
This also means that if we have both Gnome and XFCE session management
items, they will not be identified as duplicates by Kupfer since
Gnome Logout and XFCE Logout have distinct Logout.object (duplicates
are removed by Kupfer); the user will see both (and then understand
something is wrong).
kupfer/plugin/session_support.py | 27 +++++++++++----------------
1 files changed, 11 insertions(+), 16 deletions(-)
---
diff --git a/kupfer/plugin/session_support.py b/kupfer/plugin/session_support.py
index 5dce99d..f229ac4 100644
--- a/kupfer/plugin/session_support.py
+++ b/kupfer/plugin/session_support.py
@@ -20,41 +20,36 @@ def launch_commandline_with_fallbacks(commands, print_error=True):
pretty.print_error(__name__, "Unable to run command(s)", commands)
return False
-class Logout (RunnableLeaf):
+class CommandLeaf (RunnableLeaf):
+ """The represented object of the CommandLeaf is a list of commandlines"""
+ def run(self):
+ launch_commandline_with_fallbacks(self.object)
+
+class Logout (CommandLeaf):
"""Log out from desktop"""
def __init__(self, commands, name=None):
if not name: name = _("Log Out...")
- super(Logout, self).__init__(name=name)
- self._commands = commands
- def run(self):
- launch_commandline_with_fallbacks(self._commands)
+ CommandLeaf.__init__(self, commands, name)
def get_description(self):
return _("Log out or change user")
def get_icon_name(self):
return "system-log-out"
-class Shutdown (RunnableLeaf):
+class Shutdown (CommandLeaf):
"""Shutdown computer or reboot"""
def __init__(self, commands, name=None):
if not name: name = _("Shut Down...")
- super(Shutdown, self).__init__(name=name)
- self._commands = commands
- def run(self):
- launch_commandline_with_fallbacks(self._commands)
-
+ CommandLeaf.__init__(self, commands, name)
def get_description(self):
return _("Shut down, restart or suspend computer")
def get_icon_name(self):
return "system-shutdown"
-class LockScreen (RunnableLeaf):
+class LockScreen (CommandLeaf):
"""Lock screen"""
def __init__(self, commands, name=None):
if not name: name = _("Lock Screen")
- super(LockScreen, self).__init__(name=name)
- self._commands = commands
- def run(self):
- launch_commandline_with_fallbacks(self._commands)
+ CommandLeaf.__init__(self, commands, name)
def get_description(self):
return _("Enable screensaver and lock")
def get_icon_name(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]