Mercurial > libervia-web
annotate src/browser/sat_browser/base_widget.py @ 632:c2abadf31afb frontends_multi_profiles
browser side (menu): minor improvments:
- use of new style class for MenuCmd and PluginMenuCmd (useless for pyjamas, but can be useful in the future)
- use of try/except instead of hasattr
- do not use "None" for WidgetMenuBar's __init__
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 23 Feb 2015 18:43:08 +0100 |
parents | 5baca9d46c34 |
children | 40c3c6aaafaa |
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 |
340 | 5 # Copyright (C) 2011, 2012, 2013, 2014 Jérôme Poisson <goffi@goffi.org> |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
10 # (at your option) any later version. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
15 # GNU Affero General Public License for more details. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
20 import pyjd # this is dummy in pyjs |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
21 from sat.core.log import getLogger |
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
22 log = getLogger(__name__) |
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
|
23 from sat_frontends.quick_frontend import quick_widgets |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from pyjamas.ui.SimplePanel import SimplePanel |
33 | 25 from pyjamas.ui.AbsolutePanel import AbsolutePanel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 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
|
27 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 from pyjamas.ui.ScrollPanel import ScrollPanel |
195 | 29 from pyjamas.ui.FlexTable import FlexTable |
23 | 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.HTMLPanel import HTMLPanel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 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
|
33 from pyjamas.ui.HTML import HTML |
83 | 34 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
|
35 from pyjamas.ui.Widget import Widget |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
36 from pyjamas.ui.DragWidget import DragWidget |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 from pyjamas.ui.DropWidget import DropWidget |
19 | 38 from pyjamas.ui.ClickListener import ClickHandler |
83 | 39 from pyjamas.ui import HasAlignment |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 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
|
41 from pyjamas import Window |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
42 |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
320
diff
changeset
|
43 from __pyjamas__ import doc |
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
320
diff
changeset
|
44 |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
45 import dialog |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
46 import base_menu |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
47 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
48 |
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
|
49 class NoLiberviaWidgetException(Exception): |
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
|
50 pass |
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
|
51 |
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
|
52 |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
53 class DragLabel(DragWidget): |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
54 |
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
|
55 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
|
56 """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
|
57 |
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
|
58 @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
|
59 @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
|
60 @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
|
61 """ |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
62 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
|
63 self.host = host |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
64 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
|
65 self.type_ = type_ |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
66 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
67 def onDragStart(self, event): |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 |
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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 widget.removeStyleName('borderWidgetOnDrag') |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
83 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
84 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
85 class LiberviaDragWidget(DragLabel): |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
86 """ 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
|
87 current = None # widget currently dragged |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
88 |
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
|
89 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
|
90 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
|
91 self.widget = widget |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
92 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
93 def onDragStart(self, event): |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
94 LiberviaDragWidget.current = self.widget |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
95 DragLabel.onDragStart(self, event) |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
96 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
97 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
|
98 DragLabel.onDragEnd(self, event) |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
99 LiberviaDragWidget.current = None |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
101 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 class DropCell(DropWidget): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 """Cell in the middle grid which replace itself with the dropped widget on DnD""" |
195 | 104 drop_keys = {} |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
105 |
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
|
106 def __init__(self, host): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 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
|
108 self.host = host |
83 | 109 self.setStyleName('dropCell') |
195 | 110 |
111 @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
|
112 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
|
113 """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
|
114 |
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
|
115 @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
|
116 @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
|
117 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
|
118 """ |
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
|
119 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
|
120 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 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
|
122 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
|
123 return |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 self.addStyleName('dragover') |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 DOM.eventPreventDefault(event) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 def onDragLeave(self, event): |
33 | 128 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
|
129 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
|
130 # 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
|
131 # 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
|
132 # don't want that |
33 | 133 self.removeStyleName('dragover') |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 def onDragOver(self, event): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 DOM.eventPreventDefault(event) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 def _getCellAndRow(self, grid, event): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 """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
|
140 cell = grid.getEventTargetCell(event) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 row = DOM.getParent(cell) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 return (row.rowIndex, cell.cellIndex) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 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
|
145 """ |
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
|
146 @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
|
147 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
|
148 """ |
396
a71fcc27f231
browser_side: small improvements for ListManager
souliane <souliane@mailoo.org>
parents:
370
diff
changeset
|
149 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
|
150 DOM.eventPreventDefault(event) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 dt = event.dataTransfer |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
152 # 'text', 'text/plain', and 'Text' are equivalent. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 try: |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
154 item, item_type = dt.getData("text/plain").split('\n') # Workaround for webkit, only text/plain seems to be managed |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
155 if item_type and item_type[-1] == '\0': # Workaround for what looks like a pyjamas bug: the \0 should not be there, and |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
156 item_type = item_type[:-1] # .strip('\0') and .replace('\0','') don't work. TODO: check this and fill a bug report |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
157 # item_type = dt.getData("type") |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
158 log.debug("message: %s" % item) |
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
159 log.debug("type: %s" % item_type) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 except: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
161 log.debug("no message found") |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
162 item = ' ' |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 item_type = None |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
164 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
|
165 if not LiberviaDragWidget.current: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
166 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
|
167 return |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
168 _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
|
169 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
|
170 return |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
171 # we need to remove the widget from the panel as it will be inserted elsewhere |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
172 widgets_panel = _new_panel.getWidgetsPanel() |
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
|
173 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
|
174 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
|
175 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
|
176 # 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
|
177 # 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
|
178 return |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
179 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
|
180 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
|
181 _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
|
182 if not isinstance(_new_panel, 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
|
183 raise NoLiberviaWidgetException |
39
305e81c7a32c
Tarot game: a game can now be finished
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
184 else: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
185 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
|
186 return |
84 | 187 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
|
188 # 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
|
189 self.onQuit() |
84 | 190 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
|
191 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
|
192 _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
|
193 _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
|
194 row_idx, cell_idx = self._getCellAndRow(_flextable, event) |
192
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
195 if self.host.getSelected == self: |
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
196 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
|
197 _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
|
198 """_unempty_panels = filter(lambda wid:not isinstance(wid,EmptyWidget),list(_flextable)) |
34 | 199 _width = 90/float(len(_unempty_panels) or 1) |
200 #now we resize all the cell of the column | |
201 for panel in _unempty_panels: | |
202 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
|
203 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
|
204 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
|
205 self.host.widgets.deleteWidget(self) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
206 |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
207 |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
208 class WidgetMenuBar(base_menu.GenericMenuBar): |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
209 |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
210 ITEM_TPL = "<img src='media/icons/misc/%s.png' />" |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
211 |
510
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
502
diff
changeset
|
212 def __init__(self, parent, host, vertical=False, styles=None): |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
213 """ |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
214 |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
215 @param parent (Widget): LiberviaWidget, or instance of another class |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
216 implementing the method addMenus |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
217 @param host (SatWebFrontend) |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
218 @param vertical (bool): if True, set the menu vertically |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
219 @param styles (dict): optional styles dict |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
220 """ |
510
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
502
diff
changeset
|
221 menu_styles = {'menu_bar': 'widgetHeader_buttonGroup'} |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
502
diff
changeset
|
222 if styles: |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
502
diff
changeset
|
223 menu_styles.update(styles) |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
502
diff
changeset
|
224 base_menu.GenericMenuBar.__init__(self, host, vertical=vertical, styles=menu_styles) |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
225 |
632
c2abadf31afb
browser side (menu): minor improvments:
Goffi <goffi@goffi.org>
parents:
617
diff
changeset
|
226 # regroup all the dynamic menu categories in a sub-menu |
c2abadf31afb
browser side (menu): minor improvments:
Goffi <goffi@goffi.org>
parents:
617
diff
changeset
|
227 sub_menu = WidgetSubMenuBar(host, vertical=True) |
c2abadf31afb
browser side (menu): minor improvments:
Goffi <goffi@goffi.org>
parents:
617
diff
changeset
|
228 try: |
606
7af8f4ab3675
browser side: fixed avatar getting + better DEFAULT/EMPTY avatars constants + use of jid.JID for microblog's author
Goffi <goffi@goffi.org>
parents:
598
diff
changeset
|
229 parent.addMenus(sub_menu) |
632
c2abadf31afb
browser side (menu): minor improvments:
Goffi <goffi@goffi.org>
parents:
617
diff
changeset
|
230 except (AttributeError, TypeError): # FIXME: pyjamas can throw a TypeError depending on compilation options |
c2abadf31afb
browser side (menu): minor improvments:
Goffi <goffi@goffi.org>
parents:
617
diff
changeset
|
231 pass |
c2abadf31afb
browser side (menu): minor improvments:
Goffi <goffi@goffi.org>
parents:
617
diff
changeset
|
232 else: |
606
7af8f4ab3675
browser side: fixed avatar getting + better DEFAULT/EMPTY avatars constants + use of jid.JID for microblog's author
Goffi <goffi@goffi.org>
parents:
598
diff
changeset
|
233 if len(sub_menu.getCategories()) > 0: |
7af8f4ab3675
browser side: fixed avatar getting + better DEFAULT/EMPTY avatars constants + use of jid.JID for microblog's author
Goffi <goffi@goffi.org>
parents:
598
diff
changeset
|
234 self.addCategory('', '', 'plugins', sub_menu) |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
235 |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
236 @classmethod |
502
4aa627b059df
browser_side: categories of the menus can be "flattened":
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
237 def getCategoryHTML(cls, menu_name_i18n, type_): |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
238 return cls.ITEM_TPL % type_ |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
239 |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
240 |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
241 class WidgetSubMenuBar(base_menu.GenericMenuBar): |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
242 |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
243 def __init__(self, host, vertical=True): |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
244 """ |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
245 |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
246 @param host (SatWebFrontend) |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
247 @param vertical (bool): if True, set the menu vertically |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
248 """ |
502
4aa627b059df
browser_side: categories of the menus can be "flattened":
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
249 base_menu.GenericMenuBar.__init__(self, host, vertical=vertical, flat_level=1) |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
250 |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
251 @classmethod |
502
4aa627b059df
browser_side: categories of the menus can be "flattened":
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
252 def getCategoryHTML(cls, menu_name_i18n, type_): |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
253 return menu_name_i18n |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
254 |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
255 |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
256 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
|
257 |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
258 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
|
259 """ |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
260 @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
|
261 @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
|
262 @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
|
263 @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
|
264 """ |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
265 AbsolutePanel.__init__(self) |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
266 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
|
267 if info: |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
268 # 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
|
269 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
|
270 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
|
271 else: |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
272 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
|
273 button_group_wrapper.setStyleName('widgetHeader_buttonsWrapper') |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
274 button_group = WidgetMenuBar(parent, host) |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
275 button_group.addItem('<img src="media/icons/misc/settings.png"/>', True, base_menu.MenuCmd(parent, 'onSetting')) |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
276 button_group.addItem('<img src="media/icons/misc/close.png"/>', True, base_menu.MenuCmd(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
|
277 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
|
278 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
|
279 self.addStyleName('widgetHeader') |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
280 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
|
281 |
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
|
282 |
84 | 283 class LiberviaWidget(DropCell, VerticalPanel, ClickHandler): |
83 | 284 """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
|
285 |
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
|
286 def __init__(self, host, title='', info=None, selectable=False): |
84 | 287 """Init the widget |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
288 |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
289 @param host (SatWebFrontend): SatWebFrontend instance |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
290 @param title (str): title shown in the header of the widget |
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
|
291 @param info (str, callable): 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
|
292 @param selectable (bool): True is widget can be selected by user |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
293 """ |
83 | 294 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
|
295 DropCell.__init__(self, host) |
84 | 296 ClickHandler.__init__(self) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
297 self._selectable = selectable |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
298 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
|
299 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
|
300 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
|
301 self._title = Label(title) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
302 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
|
303 if info is not None: |
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
|
304 if isinstance(info, str): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
305 self._info = HTML(info) |
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
|
306 else: # the info will be set by a callback |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
307 assert callable(info) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
308 self._info = HTML() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
309 info(self._info.setHTML) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
310 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
|
311 else: |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
312 self._info = None |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
313 header = WidgetHeader(self, host, self._title, self._info) |
83 | 314 self.add(header) |
315 self.setSize('100%', '100%') | |
316 self.addStyleName('widget') | |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
317 if self._selectable: |
84 | 318 self.addClickListener(self) |
309
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
294
diff
changeset
|
319 |
609
ec77c2bc18d3
brower side: removed close listener for LiberviaWidget
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
320 # FIXME |
ec77c2bc18d3
brower side: removed close listener for LiberviaWidget
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
321 # def onClose(sender): |
ec77c2bc18d3
brower side: removed close listener for LiberviaWidget
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
322 # """Check dynamically if the unibox is enable or not""" |
ec77c2bc18d3
brower side: removed close listener for LiberviaWidget
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
323 # if self.host.uni_box: |
ec77c2bc18d3
brower side: removed close listener for LiberviaWidget
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
324 # self.host.uni_box.onWidgetClosed(sender) |
309
05e264e96a1c
browser_side: make unibox optional
souliane <souliane@mailoo.org>
parents:
294
diff
changeset
|
325 |
609
ec77c2bc18d3
brower side: removed close listener for LiberviaWidget
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
326 # self.addCloseListener(onClose) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
327 # self.host.registerWidget(self) # FIXME |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
328 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
329 def getDebugName(self): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
330 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
|
331 |
458
1eeed8028199
browser side: rename parameter of getParent / getWidgetPanel from 'verbose' to 'expect'
souliane <souliane@mailoo.org>
parents:
449
diff
changeset
|
332 def getWidgetsPanel(self, expect=True): |
1eeed8028199
browser side: rename parameter of getParent / getWidgetPanel from 'verbose' to 'expect'
souliane <souliane@mailoo.org>
parents:
449
diff
changeset
|
333 return self.getParent(WidgetsPanel, expect) |
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
|
334 |
458
1eeed8028199
browser side: rename parameter of getParent / getWidgetPanel from 'verbose' to 'expect'
souliane <souliane@mailoo.org>
parents:
449
diff
changeset
|
335 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
|
336 """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
|
337 |
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
|
338 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
|
339 |
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
|
340 @param class_: class of the ancestor to look for or None to return the first parent |
458
1eeed8028199
browser side: rename parameter of getParent / getWidgetPanel from 'verbose' to 'expect'
souliane <souliane@mailoo.org>
parents:
449
diff
changeset
|
341 @param expect: set to True if the parent is expected (print a message 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
|
342 @return: the parent/ancestor or None if it has not been found |
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
|
343 """ |
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
|
344 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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 if current is None and expect: |
527
4c6d7db9b45c
browser_side: change a log.debug to log.error
souliane <souliane@mailoo.org>
parents:
510
diff
changeset
|
350 log.error("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
|
351 return current |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
352 |
84 | 353 def onClick(self, sender): |
192
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
354 self.host.setSelected(self) |
83 | 355 |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
356 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
|
357 """ Called when the close button is pushed """ |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
358 _widgetspanel = self.getWidgetsPanel() |
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
|
359 _widgetspanel.removeWidget(self) |
179
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
360 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
|
361 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
|
362 |
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
363 def onQuit(self): |
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
364 """ 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
|
365 pass |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
366 |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
225
diff
changeset
|
367 def refresh(self): |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
225
diff
changeset
|
368 """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
|
369 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
|
370 """ |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
225
diff
changeset
|
371 pass |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
225
diff
changeset
|
372 |
89
8d2c7be09eef
browser side: CSS: removed useless z-indexes, and replaced tabs by spaces
Goffi <goffi@goffi.org>
parents:
88
diff
changeset
|
373 def onSetting(self, sender): |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
374 widpanel = self.getWidgetsPanel() |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
375 row, col = widpanel.getIndex(self) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
376 body = VerticalPanel() |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
377 |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
378 # colspan & rowspan |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
379 colspan = widpanel.getColSpan(row, col) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
380 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
|
381 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
382 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
|
383 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
|
384 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
385 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
|
386 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
|
387 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
|
388 colspan_setter.addValueChangeListener(onColSpanChange) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
389 colspan_setter.setWidth('100%') |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
390 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
|
391 rowspan_setter.addValueChangeListener(onRowSpanChange) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
392 rowspan_setter.setWidth('100%') |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
393 body.add(colspan_setter) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
394 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
|
395 |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
396 # 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
|
397 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
|
398 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
|
399 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
|
400 else: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
401 width = 0 |
97
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
402 height_str = self.getHeight() |
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
403 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
|
404 height = int(height_str[:-2]) |
97
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
405 else: |
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
406 height = 0 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
407 |
92
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
408 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
|
409 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
|
410 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
|
411 else: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
412 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
|
413 |
92
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
414 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
|
415 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
|
416 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
|
417 else: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
418 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
|
419 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
|
420 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
|
421 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
|
422 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
|
423 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
|
424 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
|
425 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
|
426 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
|
427 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
428 # 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
|
429 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
|
430 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
|
431 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
|
432 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
|
433 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
|
434 |
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 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
|
436 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
|
437 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
|
438 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
439 _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
|
440 _dialog.show() |
89
8d2c7be09eef
browser side: CSS: removed useless z-indexes, and replaced tabs by spaces
Goffi <goffi@goffi.org>
parents:
88
diff
changeset
|
441 |
83 | 442 def setTitle(self, text): |
443 """change the title in the header of the widget | |
444 @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
|
445 self._title.setText(text) |
84 | 446 |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
527
diff
changeset
|
447 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
|
448 """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
|
449 @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
|
450 try: |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
451 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
|
452 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
|
453 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
|
454 |
84 | 455 def isSelectable(self): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
456 return self._selectable |
84 | 457 |
458 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
|
459 if not self._selectable: |
84 | 460 try: |
461 self.removeClickListener(self) | |
462 except ValueError: | |
463 pass | |
464 if self.selectable and not self in self._clickListeners: | |
465 self.addClickListener(self) | |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
466 self._selectable = selectable |
83 | 467 |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
468 def getWarningData(self): |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
469 """ 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
|
470 This method should be overriden by children |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
471 @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
|
472 - PUBLIC |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
473 - GROUP |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
474 - ONE2ONE |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
475 - MISC |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
476 - NONE |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
477 """ |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
574
diff
changeset
|
478 if not self._selectable: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
479 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
|
480 raise Exception |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
481 # TODO: cleaner warning types (more general constants) |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
482 return ("NONE", None) |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
198
diff
changeset
|
483 |
83 | 484 def setWidget(self, widget, scrollable=True): |
485 """Set the widget that will be in the body of the LiberviaWidget | |
486 @param widget: widget to put in the body | |
487 @param scrollable: if true, the widget will be in a ScrollPanelWrapper""" | |
488 if scrollable: | |
489 _scrollpanelwrapper = ScrollPanelWrapper() | |
490 _scrollpanelwrapper.setStyleName('widgetBody') | |
491 _scrollpanelwrapper.setWidget(widget) | |
492 body_wid = _scrollpanelwrapper | |
493 else: | |
494 body_wid = widget | |
495 self.add(body_wid) | |
496 self.setCellHeight(body_wid, '100%') | |
497 | |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
498 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
|
499 # 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
|
500 # for the same reason as doAttachChildren |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
501 VerticalPanel.doDetachChildren(self) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
502 |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
503 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
|
504 # 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
|
505 # the event will not propagate to children |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
506 VerticalPanel.doAttachChildren(self) |
83 | 507 |
574
b07f0fe2763a
browser_side: safer attributes handling in getOrCreateLiberviaWidget + use it to create MUC panels
souliane <souliane@mailoo.org>
parents:
559
diff
changeset
|
508 def matchEntity(self, item): |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
509 """Check if this widget corresponds to the given entity. |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
510 |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
511 This method should be overwritten by child classes. |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
512 @return: True if the widget matches the entity""" |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
225
diff
changeset
|
513 raise NotImplementedError |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
225
diff
changeset
|
514 |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
515 def addMenus(self, menu_bar): |
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
494
diff
changeset
|
516 """Add menus to the header. |
494
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
517 |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
518 This method can be overwritten by child classes. |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
519 @param menu_bar (GenericMenuBar): menu bar of the widget's header |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
520 """ |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
521 pass |
5d8632a7bfde
browser_side: refactorisation of menus and LiberviaWidget's header
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
522 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
523 |
34 | 524 class ScrollPanelWrapper(SimplePanel): |
525 """Scroll Panel like component, wich use the full available space | |
526 to work around percent size issue, it use some of the ideas found | |
527 here: http://code.google.com/p/google-web-toolkit/issues/detail?id=316 | |
528 specially in code given at comment #46, thanks to Stefan Bachert""" | |
529 | |
530 def __init__(self, *args, **kwargs): | |
531 SimplePanel.__init__(self) | |
532 self.spanel = ScrollPanel(*args, **kwargs) | |
533 SimplePanel.setWidget(self, self.spanel) | |
534 DOM.setStyleAttribute(self.getElement(), "position", "relative") | |
535 DOM.setStyleAttribute(self.getElement(), "top", "0px") | |
536 DOM.setStyleAttribute(self.getElement(), "left", "0px") | |
537 DOM.setStyleAttribute(self.getElement(), "width", "100%") | |
538 DOM.setStyleAttribute(self.getElement(), "height", "100%") | |
539 DOM.setStyleAttribute(self.spanel.getElement(), "position", "absolute") | |
540 DOM.setStyleAttribute(self.spanel.getElement(), "width", "100%") | |
541 DOM.setStyleAttribute(self.spanel.getElement(), "height", "100%") | |
542 | |
543 def setWidget(self, widget): | |
544 self.spanel.setWidget(widget) | |
545 | |
546 def setScrollPosition(self, position): | |
547 self.spanel.setScrollPosition(position) | |
548 | |
549 def scrollToBottom(self): | |
550 self.setScrollPosition(self.spanel.getElement().scrollHeight) | |
551 | |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
552 |
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
|
553 class EmptyWidget(DropCell, SimplePanel): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
554 """Empty dropable panel""" |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
555 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
556 def __init__(self, host): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
557 SimplePanel.__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
|
558 DropCell.__init__(self, host) |
96
d7a4bbaddfb0
browser side: removed in EmptyPanel
Goffi <goffi@goffi.org>
parents:
92
diff
changeset
|
559 #self.setWidget(HTML('')) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
560 self.setSize('100%', '100%') |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
561 |
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
|
562 |
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 class BorderWidget(EmptyWidget): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
564 def __init__(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
|
565 EmptyWidget.__init__(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
|
566 self.addStyleName('borderPanel') |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
567 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
568 |
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
|
569 class LeftBorderWidget(BorderWidget): |
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 def __init__(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
|
571 BorderWidget.__init__(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
|
572 self.addStyleName('leftBorderWidget') |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
573 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
574 |
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
|
575 class RightBorderWidget(BorderWidget): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
576 def __init__(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
|
577 BorderWidget.__init__(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
|
578 self.addStyleName('rightBorderWidget') |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
579 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
580 |
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
|
581 class BottomBorderWidget(BorderWidget): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
582 def __init__(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
|
583 BorderWidget.__init__(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
|
584 self.addStyleName('bottomBorderWidget') |
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 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
586 |
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
|
587 class WidgetsPanel(ScrollPanelWrapper): |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
588 |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
589 def __init__(self, host, locked=False): |
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
|
590 ScrollPanelWrapper.__init__(self) |
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
|
591 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
|
592 self.host = host |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
593 self.locked = locked # if True: tab will not be removed when there are no more widgets inside |
192
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
594 self.selected = None |
83 | 595 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
|
596 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
|
597 self.setWidget(self.flextable) |
83 | 598 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
|
599 _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
|
600 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
|
601 # 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
|
602 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
|
603 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
|
604 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
|
605 |
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
|
606 @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
|
607 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
|
608 return iter(self.flextable) |
83 | 609 |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
610 def isLocked(self): |
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
611 return self.locked |
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
612 |
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
|
613 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
|
614 """Change the widget in the given location, add row or columns when necessary""" |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
615 log.debug("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
|
616 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
|
617 # 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
|
618 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
|
619 # 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
|
620 # 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
|
621 # 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
|
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 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
|
624 |
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 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
|
626 # 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
|
627 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
|
628 |
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
|
629 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
|
630 # 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
|
631 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
|
632 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
|
633 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
|
634 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
|
635 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
|
636 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
|
637 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
638 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
|
639 if col != 0: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
640 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
|
641 return |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
642 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
|
643 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
|
644 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
645 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
|
646 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
|
647 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
|
648 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
|
649 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
|
650 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
|
651 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
652 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
|
653 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
|
654 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
|
655 |
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
|
656 _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
|
657 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
|
658 self._max_cols = _max_cols |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
659 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
|
660 |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
661 def _sizesAdjust(self): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
662 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
|
663 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
|
664 |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
665 for row_idx in xrange(self.flextable.getRowCount()): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
666 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
|
667 _widget = self.flextable.getWidget(row_idx, col_idx) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
668 if not isinstance(_widget, BorderWidget): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
669 td_elt = _widget.getElement().parentNode |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
670 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
|
671 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
672 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
|
673 cellFormatter.setColSpan(last_row, 0, self._max_cols) |
178 | 674 |
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
|
675 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
|
676 """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
|
677 last_row = max(0, self.flextable.getRowCount() - 1) |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
678 log.debug("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
|
679 self.changeWidget(last_row, 0, wid) |
83 | 680 |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
681 def removeWidget(self, wid): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
682 """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
|
683 _row, _col = self.flextable.getIndex(wid) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
684 self.flextable.remove(wid) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
685 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
|
686 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
|
687 self.flextable.removeRow(_row) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
688 _max_cols = 1 |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
689 for row_idx in xrange(self.flextable.getRowCount()): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
690 _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
|
691 if _max_cols != self._max_cols: |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
692 self._max_cols = _max_cols |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
693 self._sizesAdjust() |
177
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
694 current = self |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
695 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
696 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
|
697 |
184
97d5e9de1106
browser side: contacts panel switch:
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
698 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
|
699 # 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
|
700 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
|
701 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
|
702 current.onWidgetPanelRemove(self) |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
703 return |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
704 current = current.getParent() |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
705 log.error("no MainTabPanel found !") |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
706 |
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
|
707 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
|
708 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
|
709 |
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
|
710 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
|
711 """ 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
|
712 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
|
713 |
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
|
714 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
|
715 """ 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
|
716 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
|
717 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
|
718 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
|
719 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
|
720 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
|
721 |
196
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
722 def getLiberviaWidgetsCount(self): |
c2639c9f86ea
Browser Side: Widgets can now be moved, header (title bar) is draggable:
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
723 """ 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
|
724 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
|
725 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
726 def getIndex(self, wid): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
727 return self.flextable.getIndex(wid) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
728 |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
729 def getColSpan(self, row, col): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
730 cellFormatter = self.flextable.getFlexCellFormatter() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
731 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
|
732 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
733 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
|
734 cellFormatter = self.flextable.getFlexCellFormatter() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
735 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
|
736 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
737 def getRowSpan(self, row, col): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
738 cellFormatter = self.flextable.getFlexCellFormatter() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
739 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
|
740 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
741 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
|
742 cellFormatter = self.flextable.getFlexCellFormatter() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
743 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
|
744 |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
745 |
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
|
746 class DropTab(Label, DropWidget): |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
747 |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
748 def __init__(self, tab_panel, text): |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
749 Label.__init__(self, text) |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
750 DropWidget.__init__(self, tab_panel) |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
751 self.tab_panel = tab_panel |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
752 self.setStyleName('dropCell') |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
753 self.setWordWrap(False) |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
754 DOM.setStyleAttribute(self.getElement(), "min-width", "30px") |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
755 |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
756 def _getIndex(self): |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
757 """ get current index of the DropTab """ |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
758 # XXX: awful hack, but seems the only way to get index |
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
|
759 return self.tab_panel.tabBar.panel.getWidgetIndex(self.getParent().getParent()) - 1 |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
760 |
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
|
761 def onDragEnter(self, event): |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
762 #if self == LiberviaDragWidget.current: |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
763 # return |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
764 self.addStyleName('dragover') |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
765 DOM.eventPreventDefault(event) |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
766 |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
767 def onDragLeave(self, event): |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
768 self.removeStyleName('dragover') |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
769 |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
770 def onDragOver(self, event): |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
771 DOM.eventPreventDefault(event) |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
772 |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
773 def onDrop(self, event): |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
774 DOM.eventPreventDefault(event) |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
775 self.removeStyleName('dragover') |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
776 if self._getIndex() == self.tab_panel.tabBar.getSelectedTab(): |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
777 # the widget come from the DragTab, so nothing to do, we let it there |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
778 return |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
779 |
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
|
780 # FIXME: quite the same stuff as in DropCell, need some factorisation |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
781 dt = event.dataTransfer |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
782 # 'text', 'text/plain', and 'Text' are equivalent. |
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
|
783 try: |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
784 item, item_type = dt.getData("text/plain").split('\n') # Workaround for webkit, only text/plain seems to be managed |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
785 if item_type and item_type[-1] == '\0': # Workaround for what looks like a pyjamas bug: the \0 should not be there, and |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
786 item_type = item_type[:-1] # .strip('\0') and .replace('\0','') don't work. TODO: check this and fill a bug report |
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
787 # item_type = dt.getData("type") |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
788 log.debug("message: %s" % item) |
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
789 log.debug("type: %s" % item_type) |
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
|
790 except: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
791 log.debug("no message found") |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
792 item = ' ' |
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
|
793 item_type = None |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
794 if item_type == "WIDGET": |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
795 if not LiberviaDragWidget.current: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
796 log.error("No widget registered in LiberviaDragWidget !") |
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
|
797 return |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
798 _new_panel = LiberviaDragWidget.current |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
799 _new_panel.getWidgetsPanel().removeWidget(_new_panel) |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
800 elif item_type in DropCell.drop_keys: |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
801 _new_panel = DropCell.drop_keys[item_type](self.tab_panel.host, item) |
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
|
802 else: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
803 log.warning("unmanaged item type") |
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
|
804 return |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
805 |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
806 widgets_panel = self.tab_panel.getWidget(self._getIndex()) |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
807 widgets_panel.addWidget(_new_panel) |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
808 |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
809 |
34 | 810 class MainTabPanel(TabPanel): |
23 | 811 |
812 def __init__(self, host): | |
33 | 813 TabPanel.__init__(self) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
814 self.host = host |
23 | 815 self.tabBar.setVisible(False) |
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
|
816 self.setStyleName('liberviaTabPanel') |
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
|
817 self.addStyleName('mainTabPanel') |
33 | 818 Window.addWindowResizeListener(self) |
819 | |
192
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
820 def getCurrentPanel(self): |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
821 """ Get the panel of the currently selected tab |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
822 |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
823 @return: WidgetsPanel |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
610
diff
changeset
|
824 """ |
192
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
825 return self.deck.visibleWidget |
cf5c83e7d515
browser side: per tab selected widget management
Goffi <goffi@goffi.org>
parents:
191
diff
changeset
|
826 |
33 | 827 def onWindowResized(self, width, height): |
828 tab_panel_elt = self.getElement() | |
829 _elts = doc().getElementsByClassName('gwt-TabBar') | |
830 if not _elts.length: | |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
432
diff
changeset
|
831 log.error("no TabBar found, it should exist !") |
33 | 832 tab_bar_h = 0 |
833 else: | |
834 tab_bar_h = _elts.item(0).offsetHeight | |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
186
diff
changeset
|
835 ideal_height = height - DOM.getAbsoluteTop(tab_panel_elt) - tab_bar_h - 5 |
185
40adfd4ee4d7
browser side: fixed MainTabPanel size
Goffi <goffi@goffi.org>
parents:
184
diff
changeset
|
836 ideal_width = width - DOM.getAbsoluteLeft(tab_panel_elt) - 5 |
243
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
837 self.setWidth("%s%s" % (ideal_width, "px")) |
63e9b680d3e7
browser_side, blog: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
232
diff
changeset
|
838 self.setHeight("%s%s" % (ideal_height, "px")) |
23 | 839 |
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
|
840 def add(self, widget, text=''): |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
841 tab = DropTab(self, text) |
ab239b3b67b3
browser side: tabs are now dropable (i.e. we can now move widgets between tabs)
Goffi <goffi@goffi.org>
parents:
197
diff
changeset
|
842 TabPanel.add(self, widget, tab, False) |
225
9b93a21dc5e2
browser_side: display widget title in the debug info (LiberviaWidget method "getDebugName")
souliane <souliane@mailoo.org>
parents:
210
diff
changeset
|
843 if self.getWidgetCount() > 1: |
23 | 844 self.tabBar.setVisible(True) |
33 | 845 self.host.resize() |
177
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
846 |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
847 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
|
848 """ Called when a child WidgetsPanel is empty and need to be removed """ |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
849 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
|
850 widgets_count = self.getWidgetCount() |
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
|
851 if widgets_count == 1: |
177
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
852 self.tabBar.setVisible(False) |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
853 self.host.resize() |
ba95cd824e06
browser side: tab is removed if it doesn't contain widget anymore.
Goffi <goffi@goffi.org>
parents:
174
diff
changeset
|
854 self.selectTab(0) |
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
|
855 else: |
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
|
856 self.selectTab(widgets_count - 1) |