Mercurial > libervia-web
annotate src/browser/sat_browser/libervia_widget.py @ 1043:d8666fdb015c
pages (tickets, merge-requests): fixed items URLs
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 24 Jan 2018 09:58:00 +0100 |
parents | fd4eae654182 |
children | f2170536ba23 |
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 |
964
fd4eae654182
misc: date update (yes it's a bit late :p )
Goffi <goffi@goffi.org>
parents:
836
diff
changeset
|
5 # Copyright (C) 2011-2017 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/>. |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
19 """Libervia base widget""" |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
21 import pyjd # this is dummy in pyjs |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
22 from sat.core.log import getLogger |
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
23 log = getLogger(__name__) |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
24 |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
25 from sat.core.i18n import _ |
635
40c3c6aaafaa
browser side (LiberviaWidget): an error is raised when expect is True on getParent
Goffi <goffi@goffi.org>
parents:
632
diff
changeset
|
26 from sat.core import exceptions |
598
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
596
diff
changeset
|
27 from sat_frontends.quick_frontend import quick_widgets |
618
698bdb84f6a7
browser_side: always display the main tab bar with a "+" button to add a new tab
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
28 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
29 from pyjamas.ui.FlexTable import FlexTable |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
30 from pyjamas.ui.TabPanel import TabPanel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 from pyjamas.ui.SimplePanel import SimplePanel |
33 | 32 from pyjamas.ui.AbsolutePanel import AbsolutePanel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 from pyjamas.ui.VerticalPanel import VerticalPanel |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
34 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 from pyjamas.ui.HTMLPanel import HTMLPanel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 from pyjamas.ui.Label import Label |
543
d02335553b5d
browser_side (plugin OTR): display OTR states with icons instead of a text
souliane <souliane@mailoo.org>
parents:
536
diff
changeset
|
37 from pyjamas.ui.HTML import HTML |
83 | 38 from pyjamas.ui.Button import Button |
320
a0ded7df30f7
browser_side: based on LiberviaWidget.getWidgetsPanel, add a generic method to retrieve the first ancestor of any class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
39 from pyjamas.ui.Widget import Widget |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
40 from pyjamas.ui.ClickListener import ClickHandler |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
41 from pyjamas.ui import HasAlignment |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
42 from pyjamas.ui.DragWidget import DragWidget |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 from pyjamas.ui.DropWidget import DropWidget |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 from pyjamas import DOM |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
320
diff
changeset
|
45 from pyjamas import Window |
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
320
diff
changeset
|
46 |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
47 import dialog |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
48 import base_menu |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
49 import base_widget |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
50 import base_panel |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
51 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
52 |
662
ebb602d8b3f2
browser_side: replace all instances of 'str' with 'unicode'
souliane <souliane@mailoo.org>
parents:
659
diff
changeset
|
53 unicode = str # FIXME: pyjamas workaround |
ebb602d8b3f2
browser_side: replace all instances of 'str' with 'unicode'
souliane <souliane@mailoo.org>
parents:
659
diff
changeset
|
54 |
ebb602d8b3f2
browser_side: replace all instances of 'str' with 'unicode'
souliane <souliane@mailoo.org>
parents:
659
diff
changeset
|
55 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
56 # FIXME: we need to group several unrelated panels/widgets in this module because of isinstance tests and other references to classes (e.g. if we separate Drag n Drop classes in a separate module, we'll have cyclic import because of the references to LiberviaWidget in DropCell). |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
57 # TODO: use a more generic method (either use duck typing, or register classes in a generic way, without hard references), then split classes in separate modules |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
58 |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
59 |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
60 ### Drag n Drop ### |
603
462d0458e679
browser_side: base_widget.DropCell raises an exception if the callback doesn't return a LiberviaWidget instance
souliane <souliane@mailoo.org>
parents:
598
diff
changeset
|
61 |
462d0458e679
browser_side: base_widget.DropCell raises an exception if the callback doesn't return a LiberviaWidget instance
souliane <souliane@mailoo.org>
parents:
598
diff
changeset
|
62 |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
63 class DragLabel(DragWidget): |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
64 |
594
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
65 def __init__(self, text, type_, host=None): |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
66 """Base of Drag n Drop mecanism in Libervia |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
67 |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
68 @param text: data embedded with in drag n drop operation |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
69 @param type_: type of data that we are dragging |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
70 @param host: if not None, the host will be use to highlight BorderWidgets |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
71 """ |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
72 DragWidget.__init__(self) |
594
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
73 self.host = host |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
74 self._text = text |
594
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
75 self.type_ = type_ |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
76 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
77 def onDragStart(self, event): |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
78 dt = event.dataTransfer |
594
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
79 dt.setData('text/plain', "%s\n%s" % (self._text, self.type_)) |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
80 dt.setDragImage(self.getElement(), 15, 15) |
594
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
81 if self.host is not None: |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
82 current_panel = self.host.tab_panel.getCurrentPanel() |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
83 for widget in current_panel.widgets: |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
84 if isinstance(widget, BorderWidget): |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
85 widget.addStyleName('borderWidgetOnDrag') |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
86 |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
87 def onDragEnd(self, event): |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
88 if self.host is not None: |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
89 current_panel = self.host.tab_panel.getCurrentPanel() |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
90 for widget in current_panel.widgets: |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
91 if isinstance(widget, BorderWidget): |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
92 widget.removeStyleName('borderWidgetOnDrag') |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
93 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
94 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
95 class LiberviaDragWidget(DragLabel): |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
96 """ A DragLabel which keep the widget being dragged as class value """ |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
97 current = None # widget currently dragged |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
98 |
594
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
99 def __init__(self, text, type_, widget): |
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
100 DragLabel.__init__(self, text, type_, widget.host) |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
101 self.widget = widget |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
102 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
103 def onDragStart(self, event): |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
104 LiberviaDragWidget.current = self.widget |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
105 DragLabel.onDragStart(self, event) |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
106 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
107 def onDragEnd(self, event): |
594
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
108 DragLabel.onDragEnd(self, event) |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
109 LiberviaDragWidget.current = None |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 |
659
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
111 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 class DropCell(DropWidget): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 """Cell in the middle grid which replace itself with the dropped widget on DnD""" |
195 | 114 drop_keys = {} |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
115 |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
116 def __init__(self, host): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 DropWidget.__init__(self) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
118 self.host = host |
83 | 119 self.setStyleName('dropCell') |
195 | 120 |
121 @classmethod | |
598
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
596
diff
changeset
|
122 def addDropKey(cls, key, cb): |
603
462d0458e679
browser_side: base_widget.DropCell raises an exception if the callback doesn't return a LiberviaWidget instance
souliane <souliane@mailoo.org>
parents:
598
diff
changeset
|
123 """Add a association between a key and a class to create on drop. |
598
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
596
diff
changeset
|
124 |
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
596
diff
changeset
|
125 @param key: key to be associated (e.g. "CONTACT", "CHAT") |
603
462d0458e679
browser_side: base_widget.DropCell raises an exception if the callback doesn't return a LiberviaWidget instance
souliane <souliane@mailoo.org>
parents:
598
diff
changeset
|
126 @param cb: a callable (either a class or method) returning a |
462d0458e679
browser_side: base_widget.DropCell raises an exception if the callback doesn't return a LiberviaWidget instance
souliane <souliane@mailoo.org>
parents:
598
diff
changeset
|
127 LiberviaWidget instance |
598
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
596
diff
changeset
|
128 """ |
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
596
diff
changeset
|
129 DropCell.drop_keys[key] = cb |
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
596
diff
changeset
|
130 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 def onDragEnter(self, event): |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
132 if self == LiberviaDragWidget.current: |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
133 return |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 self.addStyleName('dragover') |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 DOM.eventPreventDefault(event) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 def onDragLeave(self, event): |
33 | 138 if event.clientX <= self.getAbsoluteLeft() or event.clientY <= self.getAbsoluteTop() or\ |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
139 event.clientX >= self.getAbsoluteLeft() + self.getOffsetWidth() - 1 or event.clientY >= self.getAbsoluteTop() + self.getOffsetHeight() - 1: |
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
140 # We check that we are inside widget's box, and we don't remove the style in this case because |
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
141 # if the mouse is over a widget inside the DropWidget, if will leave the DropWidget, and we |
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
142 # don't want that |
33 | 143 self.removeStyleName('dragover') |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 def onDragOver(self, event): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 DOM.eventPreventDefault(event) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 def _getCellAndRow(self, grid, event): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 """Return cell and row index where the event is occuring""" |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 cell = grid.getEventTargetCell(event) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 row = DOM.getParent(cell) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 return (row.rowIndex, cell.cellIndex) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 def onDrop(self, event): |
603
462d0458e679
browser_side: base_widget.DropCell raises an exception if the callback doesn't return a LiberviaWidget instance
souliane <souliane@mailoo.org>
parents:
598
diff
changeset
|
155 """ |
462d0458e679
browser_side: base_widget.DropCell raises an exception if the callback doesn't return a LiberviaWidget instance
souliane <souliane@mailoo.org>
parents:
598
diff
changeset
|
156 @raise NoLiberviaWidgetException: something else than a LiberviaWidget |
462d0458e679
browser_side: base_widget.DropCell raises an exception if the callback doesn't return a LiberviaWidget instance
souliane <souliane@mailoo.org>
parents:
598
diff
changeset
|
157 has been returned by the callback. |
462d0458e679
browser_side: base_widget.DropCell raises an exception if the callback doesn't return a LiberviaWidget instance
souliane <souliane@mailoo.org>
parents:
598
diff
changeset
|
158 """ |
396
a71fcc27f231
browser_side: small improvements for ListManager
souliane <souliane@mailoo.org>
parents:
370
diff
changeset
|
159 self.removeStyleName('dragover') |
198
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
160 DOM.eventPreventDefault(event) |
734
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
161 item, item_type = eventGetData(event) |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
162 if item_type == "WIDGET": |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
163 if not LiberviaDragWidget.current: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
164 log.error("No widget registered in LiberviaDragWidget !") |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
165 return |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
166 _new_panel = LiberviaDragWidget.current |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
167 if self == _new_panel: # We can't drop on ourself |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
168 return |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
169 # we need to remove the widget from the panel as it will be inserted elsewhere |
636
86ae737da6f3
browser side (widgets management): removed getWidgetsPanel: we use directly getParent which do the same thing + displayWidget now detect hidden widgets (widgets without parent WidgetsPanel)
Goffi <goffi@goffi.org>
parents:
635
diff
changeset
|
170 widgets_panel = _new_panel.getParent(WidgetsPanel, expect=True) |
197
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
171 wid_row = widgets_panel.getWidgetCoords(_new_panel)[0] |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
172 row_wids = widgets_panel.getLiberviaRowWidgets(wid_row) |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
173 if len(row_wids) == 1 and wid_row == widgets_panel.getWidgetCoords(self)[0]: |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
174 # the dropped widget is the only one in the same row |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
175 # as the target widget (self), we don't do anything |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
176 return |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
177 widgets_panel.removeWidget(_new_panel) |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
178 elif item_type in self.drop_keys: |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
179 _new_panel = self.drop_keys[item_type](self.host, item) |
603
462d0458e679
browser_side: base_widget.DropCell raises an exception if the callback doesn't return a LiberviaWidget instance
souliane <souliane@mailoo.org>
parents:
598
diff
changeset
|
180 if not isinstance(_new_panel, LiberviaWidget): |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
181 raise base_widget.NoLiberviaWidgetException |
39
305e81c7a32c
Tarot game: a game can now be finished
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
182 else: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
183 log.warning("unmanaged item type") |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
184 return |
84 | 185 if isinstance(self, LiberviaWidget): |
596
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
186 # self.host.unregisterWidget(self) # FIXME |
179
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
187 self.onQuit() |
84 | 188 if not isinstance(_new_panel, LiberviaWidget): |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
189 log.warning("droping an object which is not a class of LiberviaWidget") |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
190 _flextable = self.getParent() |
88
50b480fd0605
browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
191 _widgetspanel = _flextable.getParent().getParent() |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
192 row_idx, cell_idx = self._getCellAndRow(_flextable, event) |
650
7e3cdc39c3e7
browser_side: fixes misc issues (forgotten parenthesis and wrong argument)
souliane <souliane@mailoo.org>
parents:
649
diff
changeset
|
193 if self.host.getSelected() == self: |
192
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
194 self.host.setSelected(None) |
88
50b480fd0605
browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
195 _widgetspanel.changeWidget(row_idx, cell_idx, _new_panel) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
196 """_unempty_panels = filter(lambda wid:not isinstance(wid,EmptyWidget),list(_flextable)) |
34 | 197 _width = 90/float(len(_unempty_panels) or 1) |
198 #now we resize all the cell of the column | |
199 for panel in _unempty_panels: | |
200 td_elt = panel.getElement().parentNode | |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
201 DOM.setStyleAttribute(td_elt, "width", "%s%%" % _width)""" |
596
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
202 if isinstance(self, quick_widgets.QuickWidget): |
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
203 self.host.widgets.deleteWidget(self) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
204 |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
205 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
206 class EmptyWidget(DropCell, SimplePanel): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
207 """Empty dropable panel""" |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
208 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
209 def __init__(self, host): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
210 SimplePanel.__init__(self) |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
211 DropCell.__init__(self, host) |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
212 #self.setWidget(HTML('')) |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
213 self.setSize('100%', '100%') |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
214 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
215 |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
216 class BorderWidget(EmptyWidget): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
217 def __init__(self, host): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
218 EmptyWidget.__init__(self, host) |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
219 self.addStyleName('borderPanel') |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
220 |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
221 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
222 class LeftBorderWidget(BorderWidget): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
223 def __init__(self, host): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
224 BorderWidget.__init__(self, host) |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
225 self.addStyleName('leftBorderWidget') |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
226 |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
227 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
228 class RightBorderWidget(BorderWidget): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
229 def __init__(self, host): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
230 BorderWidget.__init__(self, host) |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
231 self.addStyleName('rightBorderWidget') |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
232 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
233 |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
234 class BottomBorderWidget(BorderWidget): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
235 def __init__(self, host): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
236 BorderWidget.__init__(self, host) |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
237 self.addStyleName('bottomBorderWidget') |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
238 |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
239 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
240 class DropTab(Label, DropWidget): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
241 |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
242 def __init__(self, tab_panel, text): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
243 Label.__init__(self, text) |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
244 DropWidget.__init__(self, tab_panel) |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
245 self.tab_panel = tab_panel |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
246 self.setStyleName('dropCell') |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
247 self.setWordWrap(False) |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
248 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
249 def _getIndex(self): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
250 """ get current index of the DropTab """ |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
251 # XXX: awful hack, but seems the only way to get index |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
252 return self.tab_panel.tabBar.panel.getWidgetIndex(self.getParent().getParent()) - 1 |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
253 |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
254 def onDragEnter(self, event): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
255 #if self == LiberviaDragWidget.current: |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
256 # return |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
257 self.parent.addStyleName('dragover') |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
258 DOM.eventPreventDefault(event) |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
259 |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
260 def onDragLeave(self, event): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
261 self.parent.removeStyleName('dragover') |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
262 |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
263 def onDragOver(self, event): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
264 DOM.eventPreventDefault(event) |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
265 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
266 def onDrop(self, event): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
267 DOM.eventPreventDefault(event) |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
268 self.parent.removeStyleName('dragover') |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
269 if self._getIndex() == self.tab_panel.tabBar.getSelectedTab(): |
659
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
270 # the widget comes from the same tab, so nothing to do, we let it there |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
271 return |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
272 |
734
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
273 item, item_type = eventGetData(event) |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
274 if item_type == "WIDGET": |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
275 if not LiberviaDragWidget.current: |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
276 log.error("No widget registered in LiberviaDragWidget !") |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
277 return |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
278 _new_panel = LiberviaDragWidget.current |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
279 elif item_type in DropCell.drop_keys: |
659
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
280 pass # create the widget when we are sure there's a tab for it |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
281 else: |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
282 log.warning("unmanaged item type") |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
283 return |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
284 |
659
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
285 # XXX: when needed, new tab creation must be done exactly here to not mess up with LiberviaDragWidget.onDragEnd |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
286 try: |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
287 widgets_panel = self.tab_panel.getWidget(self._getIndex()) |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
288 except IndexError: # widgets panel doesn't exist, e.g. user dropped in "+" tab |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
289 widgets_panel = self.tab_panel.addWidgetsTab(None) |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
290 if widgets_panel is None: # user cancelled |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
291 return |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
292 |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
293 if item_type == "WIDGET": |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
294 _new_panel.getParent(WidgetsPanel, expect=True).removeWidget(_new_panel) |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
295 else: |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
296 _new_panel = DropCell.drop_keys[item_type](self.tab_panel.host, item) |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
297 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
298 widgets_panel.addWidget(_new_panel) |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
299 |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
300 |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
301 ### Libervia Widget ### |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
302 |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
303 |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
304 class WidgetHeader(AbsolutePanel, LiberviaDragWidget): |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
305 |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
306 def __init__(self, parent, host, title, info=None): |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
307 """ |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
308 @param parent (LiberviaWidget): LiberWidget instance |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
309 @param host (SatWebFrontend): SatWebFrontend instance |
543
d02335553b5d
browser_side (plugin OTR): display OTR states with icons instead of a text
souliane <souliane@mailoo.org>
parents:
536
diff
changeset
|
310 @param title (Label, HTML): text widget instance |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
311 @param info (Widget): text widget instance |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
312 """ |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
313 AbsolutePanel.__init__(self) |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
314 self.add(title) |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
315 if info: |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
316 # FIXME: temporary design to display the info near the menu |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
317 button_group_wrapper = HorizontalPanel() |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
318 button_group_wrapper.add(info) |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
319 else: |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
320 button_group_wrapper = SimplePanel() |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
321 button_group_wrapper.setStyleName('widgetHeader_buttonsWrapper') |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
322 button_group = base_widget.WidgetMenuBar(parent, host) |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
663
diff
changeset
|
323 button_group.addItem('<img src="media/icons/misc/settings.png"/>', True, base_menu.SimpleCmd(parent.onSetting)) |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
663
diff
changeset
|
324 button_group.addItem('<img src="media/icons/misc/close.png"/>', True, base_menu.SimpleCmd(parent.onClose)) |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
325 button_group_wrapper.add(button_group) |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
326 self.add(button_group_wrapper) |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
327 self.addStyleName('widgetHeader') |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
328 LiberviaDragWidget.__init__(self, "", "WIDGET", parent) |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
329 |
210
3092f6b1710c
browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
201
diff
changeset
|
330 |
84 | 331 class LiberviaWidget(DropCell, VerticalPanel, ClickHandler): |
83 | 332 """Libervia's widget which can replace itself with a dropped widget on DnD""" |
210
3092f6b1710c
browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
201
diff
changeset
|
333 |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
663
diff
changeset
|
334 def __init__(self, host, title='', info=None, selectable=False, plugin_menu_context=None): |
84 | 335 """Init the widget |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
336 |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
337 @param host (SatWebFrontend): SatWebFrontend instance |
662
ebb602d8b3f2
browser_side: replace all instances of 'str' with 'unicode'
souliane <souliane@mailoo.org>
parents:
659
diff
changeset
|
338 @param title (unicode): title shown in the header of the widget |
663
423182fea41c
browser_side: fixes OTR using the new resource system and proper triggers (send and receive message) or listener (presence update)
souliane <souliane@mailoo.org>
parents:
662
diff
changeset
|
339 @param info (unicode): info shown in the header of the widget |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
340 @param selectable (bool): True is widget can be selected by user |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
663
diff
changeset
|
341 @param plugin_menu_context (iterable): contexts of menus to have (list of C.MENU_* constant) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
342 """ |
83 | 343 VerticalPanel.__init__(self) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
344 DropCell.__init__(self, host) |
84 | 345 ClickHandler.__init__(self) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
346 self._selectable = selectable |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
663
diff
changeset
|
347 self._plugin_menu_context = [] if plugin_menu_context is None else plugin_menu_context |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
348 self._title_id = HTMLPanel.createUniqueId() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
349 self._setting_button_id = HTMLPanel.createUniqueId() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
350 self._close_button_id = HTMLPanel.createUniqueId() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
351 self._title = Label(title) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
352 self._title.setStyleName('widgetHeader_title') |
559
77372641e05d
browser_side (plugin OTR): display the correct icons on opening the window + auto-open on accepted invitation
souliane <souliane@mailoo.org>
parents:
543
diff
changeset
|
353 if info is not None: |
663
423182fea41c
browser_side: fixes OTR using the new resource system and proper triggers (send and receive message) or listener (presence update)
souliane <souliane@mailoo.org>
parents:
662
diff
changeset
|
354 self._info = HTML(info) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
355 self._info.setStyleName('widgetHeader_info') |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
356 else: |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
357 self._info = None |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
358 header = WidgetHeader(self, host, self._title, self._info) |
83 | 359 self.add(header) |
360 self.setSize('100%', '100%') | |
361 self.addStyleName('widget') | |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
362 if self._selectable: |
84 | 363 self.addClickListener(self) |
309
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
294
diff
changeset
|
364 |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
663
diff
changeset
|
365 @property |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
663
diff
changeset
|
366 def plugin_menu_context(self): |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
663
diff
changeset
|
367 return self._plugin_menu_context |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
663
diff
changeset
|
368 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
369 def getDebugName(self): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
370 return "%s (%s)" % (self, self._title.getText()) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
371 |
458
1eeed8028199
browser side: rename parameter of getParent / getWidgetPanel from 'verbose' to 'expect'
souliane <souliane@mailoo.org>
parents:
449
diff
changeset
|
372 def getParent(self, class_=None, expect=True): |
1eeed8028199
browser side: rename parameter of getParent / getWidgetPanel from 'verbose' to 'expect'
souliane <souliane@mailoo.org>
parents:
449
diff
changeset
|
373 """Return the closest ancestor of the specified class. |
1eeed8028199
browser side: rename parameter of getParent / getWidgetPanel from 'verbose' to 'expect'
souliane <souliane@mailoo.org>
parents:
449
diff
changeset
|
374 |
320
a0ded7df30f7
browser_side: based on LiberviaWidget.getWidgetsPanel, add a generic method to retrieve the first ancestor of any class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
375 Note: this method overrides pyjamas.ui.Widget.getParent |
458
1eeed8028199
browser side: rename parameter of getParent / getWidgetPanel from 'verbose' to 'expect'
souliane <souliane@mailoo.org>
parents:
449
diff
changeset
|
376 |
320
a0ded7df30f7
browser_side: based on LiberviaWidget.getWidgetsPanel, add a generic method to retrieve the first ancestor of any class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
377 @param class_: class of the ancestor to look for or None to return the first parent |
635
40c3c6aaafaa
browser side (LiberviaWidget): an error is raised when expect is True on getParent
Goffi <goffi@goffi.org>
parents:
632
diff
changeset
|
378 @param expect: set to True if the parent is expected (raise an error if not found) |
320
a0ded7df30f7
browser_side: based on LiberviaWidget.getWidgetsPanel, add a generic method to retrieve the first ancestor of any class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
379 @return: the parent/ancestor or None if it has not been found |
635
40c3c6aaafaa
browser side (LiberviaWidget): an error is raised when expect is True on getParent
Goffi <goffi@goffi.org>
parents:
632
diff
changeset
|
380 @raise exceptions.InternalError: expect is True and no parent is found |
320
a0ded7df30f7
browser_side: based on LiberviaWidget.getWidgetsPanel, add a generic method to retrieve the first ancestor of any class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
381 """ |
a0ded7df30f7
browser_side: based on LiberviaWidget.getWidgetsPanel, add a generic method to retrieve the first ancestor of any class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
382 current = Widget.getParent(self) |
a0ded7df30f7
browser_side: based on LiberviaWidget.getWidgetsPanel, add a generic method to retrieve the first ancestor of any class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
383 if class_ is None: |
a0ded7df30f7
browser_side: based on LiberviaWidget.getWidgetsPanel, add a generic method to retrieve the first ancestor of any class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
384 return current # this is the default behavior |
a0ded7df30f7
browser_side: based on LiberviaWidget.getWidgetsPanel, add a generic method to retrieve the first ancestor of any class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
385 while current is not None and not isinstance(current, class_): |
a0ded7df30f7
browser_side: based on LiberviaWidget.getWidgetsPanel, add a generic method to retrieve the first ancestor of any class
souliane <souliane@mailoo.org>
parents:
309
diff
changeset
|
386 current = Widget.getParent(current) |
458
1eeed8028199
browser side: rename parameter of getParent / getWidgetPanel from 'verbose' to 'expect'
souliane <souliane@mailoo.org>
parents:
449
diff
changeset
|
387 if current is None and expect: |
635
40c3c6aaafaa
browser side (LiberviaWidget): an error is raised when expect is True on getParent
Goffi <goffi@goffi.org>
parents:
632
diff
changeset
|
388 raise exceptions.InternalError("Can't find parent %s for %s" % (class_, self)) |
177
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
389 return current |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
390 |
84 | 391 def onClick(self, sender): |
192
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
392 self.host.setSelected(self) |
83 | 393 |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
394 def onClose(self, sender): |
179
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
395 """ Called when the close button is pushed """ |
636
86ae737da6f3
browser side (widgets management): removed getWidgetsPanel: we use directly getParent which do the same thing + displayWidget now detect hidden widgets (widgets without parent WidgetsPanel)
Goffi <goffi@goffi.org>
parents:
635
diff
changeset
|
396 widgets_panel = self.getParent(WidgetsPanel, expect=True) |
86ae737da6f3
browser side (widgets management): removed getWidgetsPanel: we use directly getParent which do the same thing + displayWidget now detect hidden widgets (widgets without parent WidgetsPanel)
Goffi <goffi@goffi.org>
parents:
635
diff
changeset
|
397 widgets_panel.removeWidget(self) |
179
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
398 self.onQuit() |
610
5b19fb5eae7e
browser side: widget is deleted by default when close button is clicked in LiberviaWidget
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
399 self.host.widgets.deleteWidget(self) |
179
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
400 |
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
401 def onQuit(self): |
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
402 """ Called when the widget is actually ending """ |
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
403 pass |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
404 |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
225
diff
changeset
|
405 def refresh(self): |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
225
diff
changeset
|
406 """This can be overwritten by a child class to refresh the display when, |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
225
diff
changeset
|
407 instead of creating a new one, an existing widget is found and reused. |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
225
diff
changeset
|
408 """ |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
225
diff
changeset
|
409 pass |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
225
diff
changeset
|
410 |
89
8d2c7be09eef
browser side: CSS: removed useless z-indexes, and replaced tabs by spaces
Goffi <goffi@goffi.org>
parents:
88
diff
changeset
|
411 def onSetting(self, sender): |
636
86ae737da6f3
browser side (widgets management): removed getWidgetsPanel: we use directly getParent which do the same thing + displayWidget now detect hidden widgets (widgets without parent WidgetsPanel)
Goffi <goffi@goffi.org>
parents:
635
diff
changeset
|
412 widpanel = self.getParent(WidgetsPanel, expect=True) |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
413 row, col = widpanel.getIndex(self) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
414 body = VerticalPanel() |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
415 |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
416 # colspan & rowspan |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
417 colspan = widpanel.getColSpan(row, col) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
418 rowspan = widpanel.getRowSpan(row, col) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
419 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
420 def onColSpanChange(value): |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
421 widpanel.setColSpan(row, col, value) |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
422 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
423 def onRowSpanChange(value): |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
424 widpanel.setRowSpan(row, col, value) |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
425 colspan_setter = dialog.IntSetter("Columns span", colspan) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
426 colspan_setter.addValueChangeListener(onColSpanChange) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
427 colspan_setter.setWidth('100%') |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
428 rowspan_setter = dialog.IntSetter("Rows span", rowspan) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
429 rowspan_setter.addValueChangeListener(onRowSpanChange) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
430 rowspan_setter.setWidth('100%') |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
431 body.add(colspan_setter) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
432 body.add(rowspan_setter) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
433 |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
434 # size |
92
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
435 width_str = self.getWidth() |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
436 if width_str.endswith('px'): |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
437 width = int(width_str[:-2]) |
92
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
438 else: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
439 width = 0 |
97
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
440 height_str = self.getHeight() |
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
441 if height_str.endswith('px'): |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
442 height = int(height_str[:-2]) |
97
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
443 else: |
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
444 height = 0 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
445 |
92
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
446 def onWidthChange(value): |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
447 if not value: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
448 self.setWidth('100%') |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
449 else: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
450 self.setWidth('%dpx' % value) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
451 |
92
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
452 def onHeightChange(value): |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
453 if not value: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
454 self.setHeight('100%') |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
455 else: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
456 self.setHeight('%dpx' % value) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
457 width_setter = dialog.IntSetter("width (0=auto)", width) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
458 width_setter.addValueChangeListener(onWidthChange) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
459 width_setter.setWidth('100%') |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
460 height_setter = dialog.IntSetter("height (0=auto)", height) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
461 height_setter.addValueChangeListener(onHeightChange) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
462 height_setter.setHeight('100%') |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
463 body.add(width_setter) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
464 body.add(height_setter) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
465 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
466 # reset |
92
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
467 def onReset(sender): |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
468 colspan_setter.setValue(1) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
469 rowspan_setter.setValue(1) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
470 width_setter.setValue(0) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
471 height_setter.setValue(0) |
210
3092f6b1710c
browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
201
diff
changeset
|
472 |
92
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
473 reset_bt = Button("Reset", onReset) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
474 body.add(reset_bt) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
475 body.setCellHorizontalAlignment(reset_bt, HasAlignment.ALIGN_CENTER) |
210
3092f6b1710c
browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
201
diff
changeset
|
476 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
477 _dialog = dialog.GenericDialog("Widget setting", body) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
478 _dialog.show() |
89
8d2c7be09eef
browser side: CSS: removed useless z-indexes, and replaced tabs by spaces
Goffi <goffi@goffi.org>
parents:
88
diff
changeset
|
479 |
83 | 480 def setTitle(self, text): |
481 """change the title in the header of the widget | |
482 @param text: text of the new title""" | |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
483 self._title.setText(text) |
84 | 484 |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
485 def setHeaderInfo(self, text): |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
486 """change the info in the header of the widget |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
487 @param text: text of the new title""" |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
488 try: |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
489 self._info.setHTML(text) |
559
77372641e05d
browser_side (plugin OTR): display the correct icons on opening the window + auto-open on accepted invitation
souliane <souliane@mailoo.org>
parents:
543
diff
changeset
|
490 except TypeError: |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
491 log.error("LiberviaWidget.setInfo: info widget has not been initialized!") |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
492 |
84 | 493 def isSelectable(self): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
494 return self._selectable |
84 | 495 |
496 def setSelectable(self, selectable): | |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
497 if not self._selectable: |
84 | 498 try: |
499 self.removeClickListener(self) | |
500 except ValueError: | |
501 pass | |
502 if self.selectable and not self in self._clickListeners: | |
503 self.addClickListener(self) | |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
504 self._selectable = selectable |
83 | 505 |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
506 def getWarningData(self): |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
507 """ Return exposition warning level when this widget is selected and something is sent to it |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
508 This method should be overriden by children |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
509 @return: tuple (warning level type/HTML msg). Type can be one of: |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
510 - PUBLIC |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
511 - GROUP |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
512 - ONE2ONE |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
513 - MISC |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
514 - NONE |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
515 """ |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
516 if not self._selectable: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
517 log.error("getWarningLevel must not be called for an unselectable widget") |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
518 raise Exception |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
519 # TODO: cleaner warning types (more general constants) |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
520 return ("NONE", None) |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
521 |
83 | 522 def setWidget(self, widget, scrollable=True): |
523 """Set the widget that will be in the body of the LiberviaWidget | |
524 @param widget: widget to put in the body | |
525 @param scrollable: if true, the widget will be in a ScrollPanelWrapper""" | |
526 if scrollable: | |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
527 _scrollpanelwrapper = base_panel.ScrollPanelWrapper() |
83 | 528 _scrollpanelwrapper.setStyleName('widgetBody') |
529 _scrollpanelwrapper.setWidget(widget) | |
530 body_wid = _scrollpanelwrapper | |
531 else: | |
532 body_wid = widget | |
533 self.add(body_wid) | |
534 self.setCellHeight(body_wid, '100%') | |
535 | |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
536 def doDetachChildren(self): |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
537 # We need to force the use of a panel subclass method here, |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
538 # for the same reason as doAttachChildren |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
539 VerticalPanel.doDetachChildren(self) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
540 |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
541 def doAttachChildren(self): |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
542 # We need to force the use of a panel subclass method here, else |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
543 # the event will not propagate to children |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
544 VerticalPanel.doAttachChildren(self) |
83 | 545 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
546 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
547 # XXX: WidgetsPanel and MainTabPanel are both here to avoir cyclic import |
34 | 548 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
549 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
550 class WidgetsPanel(base_panel.ScrollPanelWrapper): |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
551 """The panel wanaging the widgets indide a tab""" |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
552 |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
553 def __init__(self, host, locked=False): |
620
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
554 """ |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
555 |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
556 @param host (SatWebFrontend): host instance |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
557 @param locked (bool): If True, the tab containing self will not be |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
558 removed when there are no more widget inside self. If False, the |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
559 tab will be removed with self's last widget. |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
560 """ |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
561 base_panel.ScrollPanelWrapper.__init__(self) |
88
50b480fd0605
browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
562 self.setSize('100%', '100%') |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
563 self.host = host |
620
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
564 self.locked = locked |
192
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
565 self.selected = None |
83 | 566 self.flextable = FlexTable() |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
567 self.flextable.setSize('100%', '100%') |
88
50b480fd0605
browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
568 self.setWidget(self.flextable) |
83 | 569 self.setStyleName('widgetsPanel') |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
570 _bottom = BottomBorderWidget(self.host) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
571 self.flextable.setWidget(0, 0, _bottom) # There will be always an Empty widget on the last row, |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
572 # dropping a widget there will add a new row |
101
ad0696615768
browser side: bottomBorderWidget size fix (for webkit)
Goffi <goffi@goffi.org>
parents:
97
diff
changeset
|
573 td_elt = _bottom.getElement().parentNode |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
574 DOM.setStyleAttribute(td_elt, "height", "1px") # needed so the cell adapt to the size of the border (specially in webkit) |
596
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
575 self._max_cols = 1 # give the maximum number of columns in a raw |
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
576 |
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
577 @property |
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
578 def widgets(self): |
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
579 return iter(self.flextable) |
83 | 580 |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
581 def isLocked(self): |
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
582 return self.locked |
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
583 |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
584 def changeWidget(self, row, col, wid): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
585 """Change the widget in the given location, add row or columns when necessary""" |
694
82123705474b
massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
586 log.debug(u"changing widget: %s %s %s" % (wid.getDebugName(), row, col)) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
587 last_row = max(0, self.flextable.getRowCount() - 1) |
596
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
588 # try: # FIXME: except without exception specified ! |
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
589 prev_wid = self.flextable.getWidget(row, col) |
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
590 # except: |
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
591 # log.error("Trying to change an unexisting widget !") |
9054793ab60d
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
592 # return |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
593 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
594 cellFormatter = self.flextable.getFlexCellFormatter() |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
595 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
596 if isinstance(prev_wid, BorderWidget): |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
597 # We are on a border, we must create a row and/or columns |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
598 prev_wid.removeStyleName('dragover') |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
599 |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
600 if isinstance(prev_wid, BottomBorderWidget): |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
601 # We are on the bottom border, we create a new row |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
602 self.flextable.insertRow(last_row) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
603 self.flextable.setWidget(last_row, 0, LeftBorderWidget(self.host)) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
604 self.flextable.setWidget(last_row, 1, wid) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
605 self.flextable.setWidget(last_row, 2, RightBorderWidget(self.host)) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
606 cellFormatter.setHorizontalAlignment(last_row, 2, HasAlignment.ALIGN_RIGHT) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
607 row = last_row |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
608 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
609 elif isinstance(prev_wid, LeftBorderWidget): |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
610 if col != 0: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
611 log.error("LeftBorderWidget must be on the first column !") |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
612 return |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
613 self.flextable.insertCell(row, col + 1) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
614 self.flextable.setWidget(row, 1, wid) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
615 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
616 elif isinstance(prev_wid, RightBorderWidget): |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
617 if col != self.flextable.getCellCount(row) - 1: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
618 log.error("RightBorderWidget must be on the last column !") |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
619 return |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
620 self.flextable.insertCell(row, col) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
621 self.flextable.setWidget(row, col, wid) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
622 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
623 else: |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
624 prev_wid.removeFromParent() |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
625 self.flextable.setWidget(row, col, wid) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
626 |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
627 _max_cols = max(self._max_cols, self.flextable.getCellCount(row)) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
628 if _max_cols != self._max_cols: |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
629 self._max_cols = _max_cols |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
630 self._sizesAdjust() |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
631 |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
632 def _sizesAdjust(self): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
633 cellFormatter = self.flextable.getFlexCellFormatter() |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
634 width = 100.0 / max(1, self._max_cols - 2) # we don't count the borders |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
635 |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
636 for row_idx in xrange(self.flextable.getRowCount()): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
637 for col_idx in xrange(self.flextable.getCellCount(row_idx)): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
638 _widget = self.flextable.getWidget(row_idx, col_idx) |
649
ccf95ec87005
browser_side: fixes issue when placing a LiberviaWidget and some cells of the WidgetsPanel are empty
souliane <souliane@mailoo.org>
parents:
648
diff
changeset
|
639 if _widget and not isinstance(_widget, BorderWidget): |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
640 td_elt = _widget.getElement().parentNode |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
641 DOM.setStyleAttribute(td_elt, "width", "%.2f%%" % width) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
642 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
643 last_row = max(0, self.flextable.getRowCount() - 1) |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
644 cellFormatter.setColSpan(last_row, 0, self._max_cols) |
178 | 645 |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
646 def addWidget(self, wid): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
647 """Add a widget to a new cell on the next to last row""" |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
648 last_row = max(0, self.flextable.getRowCount() - 1) |
694
82123705474b
massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
649 log.debug(u"putting widget %s at %d, %d" % (wid.getDebugName(), last_row, 0)) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
650 self.changeWidget(last_row, 0, wid) |
83 | 651 |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
652 def removeWidget(self, wid): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
653 """Remove a widget and the cell where it is""" |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
654 _row, _col = self.flextable.getIndex(wid) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
655 self.flextable.remove(wid) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
656 self.flextable.removeCell(_row, _col) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
657 if not self.getLiberviaRowWidgets(_row): # we have no more widgets, we remove the row |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
658 self.flextable.removeRow(_row) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
659 _max_cols = 1 |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
660 for row_idx in xrange(self.flextable.getRowCount()): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
661 _max_cols = max(_max_cols, self.flextable.getCellCount(row_idx)) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
662 if _max_cols != self._max_cols: |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
663 self._max_cols = _max_cols |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
664 self._sizesAdjust() |
177
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
665 current = self |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
666 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
667 blank_page = self.getLiberviaWidgetsCount() == 0 # do we still have widgets on the page ? |
177
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
668 |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
669 if blank_page and not self.isLocked(): |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
670 # we now notice the MainTabPanel that the WidgetsPanel is empty and need to be removed |
177
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
671 while current is not None: |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
672 if isinstance(current, MainTabPanel): |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
673 current.onWidgetPanelRemove(self) |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
674 return |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
675 current = current.getParent() |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
676 log.error("no MainTabPanel found !") |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
677 |
197
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
678 def getWidgetCoords(self, wid): |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
679 return self.flextable.getIndex(wid) |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
680 |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
681 def getLiberviaRowWidgets(self, row): |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
682 """ Return all the LiberviaWidget in the row """ |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
683 return [wid for wid in self.getRowWidgets(row) if isinstance(wid, LiberviaWidget)] |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
684 |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
685 def getRowWidgets(self, row): |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
686 """ Return all the widgets in the row """ |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
687 widgets = [] |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
688 cols = self.flextable.getCellCount(row) |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
689 for col in xrange(cols): |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
690 widgets.append(self.flextable.getWidget(row, col)) |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
691 return widgets |
0fc32122a877
browser side: dropped widget's row is now checked, to avoid the drop on a removed BorderWidget. This finish the previous commit.
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
692 |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
693 def getLiberviaWidgetsCount(self): |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
694 """ Get count of contained widgets """ |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
695 return len([wid for wid in self.flextable if isinstance(wid, LiberviaWidget)]) |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
696 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
697 def getIndex(self, wid): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
698 return self.flextable.getIndex(wid) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
699 |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
700 def getColSpan(self, row, col): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
701 cellFormatter = self.flextable.getFlexCellFormatter() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
702 return cellFormatter.getColSpan(row, col) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
703 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
704 def setColSpan(self, row, col, value): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
705 cellFormatter = self.flextable.getFlexCellFormatter() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
706 return cellFormatter.setColSpan(row, col, value) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
707 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
708 def getRowSpan(self, row, col): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
709 cellFormatter = self.flextable.getFlexCellFormatter() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
710 return cellFormatter.getRowSpan(row, col) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
711 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
712 def setRowSpan(self, row, col, value): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
713 cellFormatter = self.flextable.getFlexCellFormatter() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
714 return cellFormatter.setRowSpan(row, col, value) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
715 |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
716 |
618
698bdb84f6a7
browser_side: always display the main tab bar with a "+" button to add a new tab
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
717 class MainTabPanel(TabPanel, ClickHandler): |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
718 """The panel managing the tabs""" |
23 | 719 |
720 def __init__(self, host): | |
654
40c72f3b7638
browser_side: MainPanel is now based on a DockPanel, which allows to use less tables and also to remove some "window resized" listeners
souliane <souliane@mailoo.org>
parents:
652
diff
changeset
|
721 TabPanel.__init__(self, FloatingTab=True) |
618
698bdb84f6a7
browser_side: always display the main tab bar with a "+" button to add a new tab
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
722 ClickHandler.__init__(self) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
723 self.host = host |
148
8635bc9db9bf
added parameter management to test XMLUI, but it's currently deactivated for security reasons (need some configuration options) + separated mainTabPanel CSS from LiberviaTabPanel
Goffi <goffi@goffi.org>
parents:
139
diff
changeset
|
724 self.setStyleName('liberviaTabPanel') |
659
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
725 self.tabBar.addTab(DropTab(self, u'✚'), asHTML=False) |
657
0b7e4226378d
browser_side: hide the tab bar and contact list's toggle button until the profile is connected
souliane <souliane@mailoo.org>
parents:
656
diff
changeset
|
726 self.tabBar.setVisible(False) # set to True when profile is logged |
656
4dbd99de3aaa
browser_side: only display "+" button when the tab bar contains only 1 tab, and display it over the contact list to not use vertical space
souliane <souliane@mailoo.org>
parents:
654
diff
changeset
|
727 self.tabBar.addStyleDependentName('oneTab') |
618
698bdb84f6a7
browser_side: always display the main tab bar with a "+" button to add a new tab
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
728 |
698bdb84f6a7
browser_side: always display the main tab bar with a "+" button to add a new tab
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
729 def onTabSelected(self, sender, tabIndex): |
698bdb84f6a7
browser_side: always display the main tab bar with a "+" button to add a new tab
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
730 if tabIndex < self.getWidgetCount(): |
698bdb84f6a7
browser_side: always display the main tab bar with a "+" button to add a new tab
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
731 TabPanel.onTabSelected(self, sender, tabIndex) |
836
d827b7c0cf97
browser: fixes bug while changing or closing the tab
souliane <souliane@mailoo.org>
parents:
818
diff
changeset
|
732 self.host.selected_widget = self.getCurrentPanel().selected |
618
698bdb84f6a7
browser_side: always display the main tab bar with a "+" button to add a new tab
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
733 return |
698bdb84f6a7
browser_side: always display the main tab bar with a "+" button to add a new tab
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
734 # user clicked the "+" tab |
659
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
735 self.addWidgetsTab(None, select=True) |
618
698bdb84f6a7
browser_side: always display the main tab bar with a "+" button to add a new tab
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
736 |
192
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
737 def getCurrentPanel(self): |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
738 """ Get the panel of the currently selected tab |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
739 |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
740 @return: WidgetsPanel |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
741 """ |
192
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
742 return self.deck.visibleWidget |
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
743 |
620
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
744 def addTab(self, widget, label, select=False): |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
745 """Create a new tab for the given widget. |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
746 |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
747 @param widget (Widget): widget to associate to the tab |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
748 @param label (unicode): label of the tab |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
749 @param select (bool): True to select the added tab |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
750 """ |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
751 TabPanel.add(self, widget, DropTab(self, label), False) |
656
4dbd99de3aaa
browser_side: only display "+" button when the tab bar contains only 1 tab, and display it over the contact list to not use vertical space
souliane <souliane@mailoo.org>
parents:
654
diff
changeset
|
752 if self.getWidgetCount() > 1: |
4dbd99de3aaa
browser_side: only display "+" button when the tab bar contains only 1 tab, and display it over the contact list to not use vertical space
souliane <souliane@mailoo.org>
parents:
654
diff
changeset
|
753 self.tabBar.removeStyleDependentName('oneTab') |
658
476d8d9973d3
browser_side: the contact list's height needs a window resize after it's been added or when the tab bar display is changed
souliane <souliane@mailoo.org>
parents:
657
diff
changeset
|
754 self.host.resize() |
620
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
755 if select: |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
756 self.selectTab(self.getWidgetCount() - 1) |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
757 |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
758 def addWidgetsTab(self, label, select=False, locked=False): |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
759 """Create a new tab for containing LiberviaWidgets. |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
760 |
659
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
761 @param label (unicode): label of the tab (None or '' for user prompt) |
620
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
762 @param select (bool): True to select the added tab |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
763 @param locked (bool): If True, the tab will not be removed when there |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
764 are no more widget inside. If False, the tab will be removed with |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
765 the last widget. |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
766 @return: WidgetsPanel |
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
767 """ |
650
7e3cdc39c3e7
browser_side: fixes misc issues (forgotten parenthesis and wrong argument)
souliane <souliane@mailoo.org>
parents:
649
diff
changeset
|
768 widgets_panel = WidgetsPanel(self.host, locked=locked) |
659
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
769 |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
770 if not label: |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
771 default_label = _(u'new tab') |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
772 try: |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
773 label = Window.prompt(_(u'Name of the new tab'), default_label) |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
774 if not label: # empty label or user pressed "cancel" |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
775 return None |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
776 except: # this happens when the user prevents the page to open the prompt dialog |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
777 label = default_label |
8e7d4de56e75
browser_side: allow to drop a widget in the "+" tab
souliane <souliane@mailoo.org>
parents:
658
diff
changeset
|
778 |
621
b77e1070035c
browser_side: fixes previous patch, forgot to pass an argument
souliane <souliane@mailoo.org>
parents:
620
diff
changeset
|
779 self.addTab(widgets_panel, label, select) |
620
ac5881d683d3
browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
souliane <souliane@mailoo.org>
parents:
619
diff
changeset
|
780 return widgets_panel |
177
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
781 |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
782 def onWidgetPanelRemove(self, panel): |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
783 """ Called when a child WidgetsPanel is empty and need to be removed """ |
618
698bdb84f6a7
browser_side: always display the main tab bar with a "+" button to add a new tab
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
784 widget_index = self.getWidgetIndex(panel) |
177
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
785 self.remove(panel) |
194
6198be95a39c
browser side: new tab is automatically selected, if a tab is removed, the last one is automatically selected
Goffi <goffi@goffi.org>
parents:
193
diff
changeset
|
786 widgets_count = self.getWidgetCount() |
656
4dbd99de3aaa
browser_side: only display "+" button when the tab bar contains only 1 tab, and display it over the contact list to not use vertical space
souliane <souliane@mailoo.org>
parents:
654
diff
changeset
|
787 if widgets_count == 1: |
4dbd99de3aaa
browser_side: only display "+" button when the tab bar contains only 1 tab, and display it over the contact list to not use vertical space
souliane <souliane@mailoo.org>
parents:
654
diff
changeset
|
788 self.tabBar.addStyleDependentName('oneTab') |
658
476d8d9973d3
browser_side: the contact list's height needs a window resize after it's been added or when the tab bar display is changed
souliane <souliane@mailoo.org>
parents:
657
diff
changeset
|
789 self.host.resize() |
618
698bdb84f6a7
browser_side: always display the main tab bar with a "+" button to add a new tab
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
790 self.selectTab(widget_index if widget_index < widgets_count else widgets_count - 1) |
734
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
791 |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
792 |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
793 def eventGetData(event): |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
794 """Retrieve the event data. |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
795 |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
796 @param event(EventObject) |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
797 @return tuple: (event_text, event_type) |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
798 """ |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
799 dt = event.dataTransfer |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
800 # 'text', 'text/plain', and 'Text' are equivalent. |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
801 try: |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
802 item, item_type = dt.getData("text/plain").split('\n') # Workaround for webkit, only text/plain seems to be managed |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
803 if item_type and item_type[-1] == '\0': # Workaround for what looks like a pyjamas bug: the \0 should not be there, and |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
804 item_type = item_type[:-1] # .strip('\0') and .replace('\0','') don't work. TODO: check this and fill a bug report |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
805 # item_type = dt.getData("type") |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
806 log.debug(u"event data: %s (type %s)" % (item, item_type)) |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
807 except: |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
808 log.debug("event data not found") |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
809 item = ' ' |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
810 item_type = None |
26046f13e93b
browser_side: factorize retrieval of drop event data
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
811 return item, item_type |