changeset 1119:5968fd8d2248

primitivus: change behavior of commands ":presence" and ":status" : - ":presence " and ":status " open a dialog (like if you type it without the trailing space) - you need to type ":presence online" to directly reset your presence (was done with ":presence " before) - there's no more way to directly set an empty status (you now do it via the dialog)
author souliane <souliane@mailoo.org>
date Sat, 23 Aug 2014 20:11:37 +0200
parents b1cb1d70bea9
children d1f6b927131e
files frontends/src/constants.py frontends/src/primitivus/primitivus
diffstat 2 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/constants.py	Sun Aug 24 13:15:51 2014 +0200
+++ b/frontends/src/constants.py	Sat Aug 23 20:11:37 2014 +0200
@@ -40,13 +40,13 @@
                                 ("chat", _("Free for chat")),
                                 ("away", _("Away from keyboard")),
                                 ("dnd", _("Do not disturb")),
-                                ("xa", _("Away"))])
+                                ("xa", _("Extended away"))])
     except TypeError:
         presence = {"": _("Online"),
                     "chat": _("Free for chat"),
                     "away": _("Away from keyboard"),
                     "dnd": _("Do not disturb"),
-                    "xa": _("Away")
+                    "xa": _("Extended away")
                     }
     return presence
 
--- a/frontends/src/primitivus/primitivus	Sun Aug 24 13:15:51 2014 +0200
+++ b/frontends/src/primitivus/primitivus	Sat Aug 23 20:11:37 2014 +0200
@@ -112,7 +112,8 @@
     def commandHandler(self):
         #TODO: separate class with auto documentation (with introspection)
         #      and completion method
-        command = self.get_edit_text()
+        tokens = self.get_edit_text().split(' ')
+        command, args = tokens[0], tokens[1:]
         if command == 'quit':
             self.app.onExit()
             raise urwid.ExitMainLoop()
@@ -120,13 +121,18 @@
             wid = sat_widgets.GenericList(logging.memoryGet())
             self.app.addWindow(wid)
         elif command == 'presence':
-            self.app.status_bar.onPresenceClick()
-        elif command in ['presence %s' % show for show in commonConst.PRESENCE.keys()]:
-            self.app.status_bar.onChange(user_data=sat_widgets.ClickableText(commonConst.PRESENCE[command[9:]]))
+            values = [value for value in commonConst.PRESENCE.keys()]
+            values = [value if value else 'online' for value in values]  # the empty value actually means 'online'
+            if args and args[0] in values:
+                presence = '' if args[0] == 'online' else args[0]
+                self.app.status_bar.onChange(user_data=sat_widgets.ClickableText(commonConst.PRESENCE[presence]))
+            else:
+                self.app.status_bar.onPresenceClick()
         elif command == 'status':
-            self.app.status_bar.onStatusClick()
-        elif command.startswith('status '):
-            self.app.status_bar.onChange(user_data=sat_widgets.AdvancedEdit(command[7:]))
+            if args:
+                self.app.status_bar.onChange(user_data=sat_widgets.AdvancedEdit(args[0]))
+            else:
+                self.app.status_bar.onStatusClick()
         else:
             return
         self.set_edit_text('')