annotate frontends/src/primitivus/keys.py @ 1265:e3a9ea76de35 frontends_multi_profiles

quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p): This refactoring allow primitivus to manage correctly several profiles at once, with various other improvments: - profile_manager can now plug several profiles at once, requesting password when needed. No more profile plug specific method is used anymore in backend, instead a "validated" key is used in actions - Primitivus widget are now based on a common "PrimitivusWidget" classe which mainly manage the decoration so far - all widgets are treated in the same way (contactList, Chat, Progress, etc), no more chat_wins specific behaviour - widgets are created in a dedicated manager, with facilities to react on new widget creation or other events - quick_frontend introduce a new QuickWidget class, which aims to be as generic and flexible as possible. It can manage several targets (jids or something else), and several profiles - each widget class return a Hash according to its target. For example if given a target jid and a profile, a widget class return a hash like (target.bare, profile), the same widget will be used for all resources of the same jid - better management of CHAT_GROUP mode for Chat widgets - some code moved from Primitivus to QuickFrontend, the final goal is to have most non backend code in QuickFrontend, and just graphic code in subclasses - no more (un)escapePrivate/PRIVATE_PREFIX - contactList improved a lot: entities not in roster and special entities (private MUC conversations) are better managed - resources can be displayed in Primitivus, and their status messages - profiles are managed in QuickFrontend with dedicated managers This is work in progress, other frontends are broken. Urwid SàText need to be updated. Most of features of Primitivus should work as before (or in a better way ;))
author Goffi <goffi@goffi.org>
date Wed, 10 Dec 2014 19:00:09 +0100
parents 9cc858acae91
children 069ad98b360d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1158
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
3
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Primitivus: a SAT frontend
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
6
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
11
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
16
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
19
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
20 """This file manage the action <=> key map"""
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
21
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from urwid_satext.keys import action_key_map
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
23
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
24
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
25 action_key_map.update(
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
26 {
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
27 # Edit bar
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
28 ("edit", "MODE_INSERTION"): "i",
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
29 ("edit", "MODE_COMMAND"): ":",
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
30 ("edit", "HISTORY_PREV"): "up",
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
31 ("edit", "HISTORY_NEXT"): "down",
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
32
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
33 # global
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
34 ("global", "MENU_HIDE"): 'meta m',
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
35 ("global", "NOTIFICATION_NEXT"): 'ctrl n',
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
36 ("global", "OVERLAY_HIDE"): 'ctrl s',
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
37 ("global", "DEBUG"): 'ctrl d',
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
38 ("global", "CONTACTS_HIDE"): 'f2',
1177
a283968818da primitivus: added REFRESH_SCREEN key to global namespace
Goffi <goffi@goffi.org>
parents: 1158
diff changeset
39 ('global', "REFRESH_SCREEN"): "ctrl l", # ctrl l is used by Urwid to refresh screen
1158
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
40
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
41 # global menu
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
42 ("menu_global", "APP_QUIT"): 'ctrl x',
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
43 ("menu_global", "ROOM_JOIN"): 'meta j',
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
44
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1186
diff changeset
45 # primitivus widgets
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1186
diff changeset
46 ("primitivus_widget", "DECORATION_HIDE"): "meta l",
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1186
diff changeset
47
1158
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
48 # contact list
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
49 ("contact_list", "STATUS_HIDE"): "meta s",
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
50 ("contact_list", "DISCONNECTED_HIDE"): "meta d",
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1186
diff changeset
51 ("contact_list", "RESOURCES_HIDE"): "meta r",
1158
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
52
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
53 # chat panel
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
54 ("chat_panel", "OCCUPANTS_HIDE"): "meta p",
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
55 ("chat_panel", "TIMESTAMP_HIDE"): "meta t",
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
56 ("chat_panel", "SHORT_NICKNAME"): "meta n",
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
57 ("chat_panel", "SUBJECT_SWITCH"): "meta s",
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
58
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
59 #card game
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
60 ("card_game", "CARD_SELECT"): ' ',
1186
9cc858acae91 primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents: 1177
diff changeset
61
9cc858acae91 primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents: 1177
diff changeset
62 #focus
9cc858acae91 primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents: 1177
diff changeset
63 ("focus", "FOCUS_EXTRA"): "ctrl f",
1158
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
64 })
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
65
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
66
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
67 action_key_map.set_close_namespaces(tuple(), ('global', 'focus', 'menu_global'))
c0f15e52695a primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
diff changeset
68 action_key_map.check_namespaces()