Mercurial > libervia-web
annotate src/browser/sat_browser/widget.py @ 687:3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
- Chat uses presence and avatar listener, remove unecessary methods for MUC and contact states
- contact list doesn't add unecessary ContactBox (e.g for MUC bare entities)
- nick, message alerts are handled directly in ContactLabel
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 23 Mar 2015 09:35:46 +0100 |
parents | 9877607c719a |
children | c2f22ca12e23 |
rev | line source |
---|---|
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
4 # Libervia: a Salut à Toi frontend |
685 | 5 # Copyright (C) 2011, 2012, 2013, 2014, 2015 Jérôme Poisson <goffi@goffi.org> |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
10 # (at your option) any later version. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
15 # GNU Affero General Public License for more details. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
20 import pyjd # this is dummy in pyjs |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
21 from sat.core.log import getLogger |
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
22 log = getLogger(__name__) |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
23 |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
24 from sat.core.i18n import D_ |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
25 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 from pyjamas.ui.VerticalPanel import VerticalPanel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
83 | 28 from pyjamas.ui.Button import Button |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
29 from pyjamas.ui.Frame import Frame |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 from pyjamas import DOM |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
31 |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
32 |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
33 import dialog |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
637
diff
changeset
|
34 import libervia_widget |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
35 from constants import Const as C |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
36 from sat_frontends.quick_frontend import quick_widgets |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
37 from sat_frontends.tools import host_listener |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
38 |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
39 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
40 # class UniBoxPanel(HorizontalPanel): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
41 # """Panel containing the UniBox""" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
42 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
43 # def __init__(self, host): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
44 # HorizontalPanel.__init__(self) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
45 # self.host = host |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
46 # self.setStyleName('uniBoxPanel') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
47 # self.unibox = None |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
48 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
49 # def refresh(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
50 # """Enable or disable this panel. Contained widgets are created when necessary.""" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
51 # enable = self.host.getCachedParam(C.COMPOSITION_KEY, C.ENABLE_UNIBOX_PARAM) == 'true' |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
52 # self.setVisible(enable) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
53 # if enable and not self.unibox: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
54 # self.button = Button('<img src="media/icons/tango/actions/32/format-text-italic.png" class="richTextIcon"/>') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
55 # self.button.setTitle('Open the rich text editor') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
56 # self.button.addStyleName('uniBoxButton') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
57 # self.add(self.button) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
58 # self.unibox = UniBox(self.host) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
59 # self.add(self.unibox) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
60 # self.setCellWidth(self.unibox, '100%') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
61 # self.button.addClickListener(self.openRichMessageEditor) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
62 # self.unibox.addKey("@@: ") |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
63 # self.unibox.onSelectedChange(self.host.getSelected()) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
64 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
65 # def openRichMessageEditor(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
66 # """Open the rich text editor.""" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
67 # self.button.setVisible(False) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
68 # self.unibox.setVisible(False) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
69 # self.setCellWidth(self.unibox, '0px') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
70 # self.host.panel._contactsMove(self) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
71 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
72 # def afterEditCb(): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
73 # Window.removeWindowResizeListener(self) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
74 # self.host.panel._contactsMove(self.host.panel._hpanel) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
75 # self.setCellWidth(self.unibox, '100%') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
76 # self.button.setVisible(True) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
77 # self.unibox.setVisible(True) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
78 # self.host.resize() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
79 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
80 # richtext.RichMessageEditor.getOrCreate(self.host, self, afterEditCb) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
81 # Window.addWindowResizeListener(self) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
82 # self.host.resize() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
83 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
84 # def onWindowResized(self, width, height): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
85 # right = self.host.panel.menu.getAbsoluteLeft() + self.host.panel.menu.getOffsetWidth() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
86 # left = self.host.panel._contacts.getAbsoluteLeft() + self.host.panel._contacts.getOffsetWidth() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
87 # ideal_width = right - left - 40 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
88 # self.host.richtext.setWidth("%spx" % ideal_width) |
292
1a5dc08c2749
browser_side: set the ideal width for the rich text dialog when displayed in the unibox panel
souliane <souliane@mailoo.org>
parents:
291
diff
changeset
|
89 |
210
3092f6b1710c
browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
206
diff
changeset
|
90 |
310
5d11ec1f2c22
browser_side: make UniBox inherit from a more basic MessageBox class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
91 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
92 # class UniBox(MessageBox, MouseHandler): # AutoCompleteTextBox): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
93 # """This text box is used as a main typing point, for message, microblog, etc""" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
94 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
95 # def __init__(self, host): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
96 # MessageBox.__init__(self, host) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
97 # #AutoCompleteTextBox.__init__(self) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
98 # self.setStyleName('uniBox') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
99 # # FIXME |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
100 # # host.addSelectedListener(self.onSelectedChange) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
101 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
102 # def addKey(self, key): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
103 # return |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
104 # #self.getCompletionItems().completions.append(key) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
105 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
106 # def removeKey(self, key): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
107 # return |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
108 # # TODO: investigate why AutoCompleteTextBox doesn't work here, |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
109 # # maybe it can work on a TextBox but no TextArea. Remove addKey |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
110 # # and removeKey methods if they don't serve anymore. |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
111 # try: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
112 # self.getCompletionItems().completions.remove(key) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
113 # except KeyError: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
114 # log.warning("trying to remove an unknown key") |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
115 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
116 # def _getTarget(self, txt): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
117 # """ Say who will receive the messsage |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
118 # @return: a tuple (selected, target_type, target info) with: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
119 # - target_hook: None if we use the selected widget, (msg, data) if we have a hook (e.g. "@@: " for a public blog), where msg is the parsed message (i.e. without the "hook key: "@@: bla" become ("bla", None)) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
120 # - target_type: one of PUBLIC, GROUP, ONE2ONE, STATUS, MISC |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
121 # - msg: HTML message which will appear in the privacy warning banner """ |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
122 # target = self._selected_cache |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
123 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
124 # def getSelectedOrStatus(): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
125 # if target and target.isSelectable(): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
126 # _type, msg = target.getWarningData() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
127 # target_hook = None # we use the selected widget, not a hook |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
128 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
129 # _type, msg = "STATUS", "This will be your new status message" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
130 # target_hook = (txt, None) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
131 # return (target_hook, _type, msg) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
132 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
133 # if not txt.startswith('@'): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
134 # target_hook, _type, msg = getSelectedOrStatus() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
135 # elif txt.startswith('@@: '): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
136 # _type = "PUBLIC" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
137 # msg = MicroblogPanel.warning_msg_public |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
138 # target_hook = (txt[4:], None) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
139 # elif txt.startswith('@'): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
140 # _end = txt.find(': ') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
141 # if _end == -1: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
142 # target_hook, _type, msg = getSelectedOrStatus() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
143 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
144 # group = txt[1:_end] # only one target group is managed for the moment |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
145 # if not group or not group in self.host.contact_panel.getGroups(): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
146 # # the group doesn't exists, we ignore the key |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
147 # group = None |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
148 # target_hook, _type, msg = getSelectedOrStatus() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
149 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
150 # _type = "GROUP" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
151 # msg = MicroblogPanel.warning_msg_group % group |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
152 # target_hook = (txt[_end + 2:], group) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
153 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
154 # log.error("Unknown target") |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
155 # target_hook, _type, msg = getSelectedOrStatus() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
156 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
157 # return (target_hook, _type, msg) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
158 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
159 # def onKeyPress(self, sender, keycode, modifiers): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
160 # _txt = self.getText() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
161 # target_hook, type_, msg = self._getTarget(_txt) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
162 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
163 # if keycode == KEY_ENTER: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
164 # if _txt: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
165 # if target_hook: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
166 # parsed_txt, data = target_hook |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
167 # self.host.send([(type_, data)], parsed_txt) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
168 # self.host._updateInputHistory(_txt) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
169 # self.setText('') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
170 # self.host.showWarning(None, None) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
171 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
172 # self.host.showWarning(type_, msg) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
173 # MessageBox.onKeyPress(self, sender, keycode, modifiers) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
174 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
175 # def getTargetAndData(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
176 # """For external use, to get information about the (hypothetical) message |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
177 # that would be sent if we press Enter right now in the unibox. |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
178 # @return a tuple (target, data) with: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
179 # - data: what would be the content of the message (body) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
180 # - target: JID, group with the prefix "@" or the public entity "@@" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
181 # """ |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
182 # _txt = self.getText() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
183 # target_hook, _type, _msg = self._getTarget(_txt) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
184 # if target_hook: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
185 # data, target = target_hook |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
186 # if target is None: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
187 # return target_hook |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
188 # return (data, "@%s" % (target if target != "" else "@")) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
189 # if isinstance(self._selected_cache, MicroblogPanel): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
190 # groups = self._selected_cache.accepted_groups |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
191 # target = "@%s" % (groups[0] if len(groups) > 0 else "@") |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
192 # if len(groups) > 1: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
193 # Window.alert("Sole the first group of the selected panel is taken in consideration: '%s'" % groups[0]) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
194 # # elif isinstance(self._selected_cache, ChatPanel): # FIXME |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
195 # # target = self._selected_cache.target |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
196 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
197 # target = None |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
198 # return (_txt, target) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
199 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
200 # def onWidgetClosed(self, lib_wid): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
201 # """Called when a libervia widget is closed""" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
202 # if self._selected_cache == lib_wid: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
203 # self.onSelectedChange(None) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
204 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
205 # """def complete(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
206 # |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
207 # #self.visible=False #XXX: self.visible is not unset in pyjamas when ENTER is pressed and a completion is done |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
208 # #XXX: fixed directly on pyjamas, if the patch is accepted, no need to walk around this |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
209 # return AutoCompleteTextBox.complete(self)""" |
33 | 210 |
210
3092f6b1710c
browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
206
diff
changeset
|
211 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
637
diff
changeset
|
212 class WebWidget(quick_widgets.QuickWidget, libervia_widget.LiberviaWidget): |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
213 """ (mini)browser like widget """ |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
214 |
615
70872a83ef15
browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents:
612
diff
changeset
|
215 def __init__(self, host, target, show_url=True, profiles=None): |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
216 """ |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
217 @param host: SatWebFrontend instance |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
218 @param target: url to open |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
219 """ |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
220 quick_widgets.QuickWidget.__init__(self, host, target, C.PROF_KEY_NONE) |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
637
diff
changeset
|
221 libervia_widget.LiberviaWidget.__init__(self, host) |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
222 self._vpanel = VerticalPanel() |
188
39936b83da9d
Browser Side: Web Panel widget position/size fix
Goffi <goffi@goffi.org>
parents:
187
diff
changeset
|
223 self._vpanel.setSize('100%', '100%') |
210
3092f6b1710c
browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
206
diff
changeset
|
224 self._url = dialog.ExtTextBox(enter_cb=self.onUrlClick) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
225 self._url.setText(target or "") |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
226 self._url.setWidth('100%') |
615
70872a83ef15
browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents:
612
diff
changeset
|
227 if show_url: |
70872a83ef15
browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents:
612
diff
changeset
|
228 hpanel = HorizontalPanel() |
70872a83ef15
browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents:
612
diff
changeset
|
229 hpanel.add(self._url) |
70872a83ef15
browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents:
612
diff
changeset
|
230 btn = Button("Go", self.onUrlClick) |
70872a83ef15
browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents:
612
diff
changeset
|
231 hpanel.setCellWidth(self._url, "100%") |
70872a83ef15
browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents:
612
diff
changeset
|
232 hpanel.add(btn) |
70872a83ef15
browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents:
612
diff
changeset
|
233 self._vpanel.add(hpanel) |
70872a83ef15
browser side (web panel): add an option to hide url headed + use it for public blog
Goffi <goffi@goffi.org>
parents:
612
diff
changeset
|
234 self._vpanel.setCellHeight(hpanel, '20px') |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
235 self._frame = Frame(target or "") |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
236 self._frame.setSize('100%', '100%') |
188
39936b83da9d
Browser Side: Web Panel widget position/size fix
Goffi <goffi@goffi.org>
parents:
187
diff
changeset
|
237 DOM.setStyleAttribute(self._frame.getElement(), "position", "relative") |
181
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
238 self._vpanel.add(self._frame) |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
239 self.setWidget(self._vpanel) |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
240 |
c0b78a3af06d
browser side: web widget first draft
Goffi <goffi@goffi.org>
parents:
179
diff
changeset
|
241 def onUrlClick(self, sender): |
612
5983d6be4f07
browser side (web panel): schemes are now checked, if no scheme is given (or a not accepted one), http:// is used
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
242 url = self._url.getText() |
5983d6be4f07
browser side (web panel): schemes are now checked, if no scheme is given (or a not accepted one), http:// is used
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
243 scheme_end = url.find(':') |
5983d6be4f07
browser side (web panel): schemes are now checked, if no scheme is given (or a not accepted one), http:// is used
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
244 scheme = "" if scheme_end == -1 else url[:scheme_end] |
5983d6be4f07
browser side (web panel): schemes are now checked, if no scheme is given (or a not accepted one), http:// is used
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
245 if scheme not in C.WEB_PANEL_SCHEMES: |
5983d6be4f07
browser side (web panel): schemes are now checked, if no scheme is given (or a not accepted one), http:// is used
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
246 url = "http://" + url |
5983d6be4f07
browser side (web panel): schemes are now checked, if no scheme is given (or a not accepted one), http:// is used
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
247 self._frame.setUrl(url) |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
248 |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
249 |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
250 ## Menu |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
251 |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
252 def hostReady(host): |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
253 def onWebWidget(): |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
254 web_widget = host.displayWidget(WebWidget, C.WEB_PANEL_DEFAULT_URL) |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
255 host.setSelected(web_widget) |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
256 |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
257 def gotMenus(): |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
258 host.menus.addMenu(C.MENU_GLOBAL, (D_(u"General"), D_(u"Web widget")), callback=onWebWidget) |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
259 host.addListener('gotMenus', gotMenus) |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
260 |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
261 host_listener.addListener(hostReady) |