Add support of expand attribute on group tag
issue7220 review44151002
This commit is contained in:
1 parent
8832a273de
commit
a5ef4b5337
3 files changed
+26
-5
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Add support of expand attribute on group tag
|
||||
* Add the context model name in the screen context
|
||||
* Use limit to expand tree
|
||||
* Add keyword attribute to button tag
|
||||
|
||||
@@ -34,7 +34,7 @@ from .form_gtk.dictionary import DictWidget
|
||||
from .form_gtk.multiselection import MultiSelection
|
||||
from .form_gtk.pyson import PYSON
|
||||
from .form_gtk.state_widget import (Label, VBox, Image, Frame, ScrolledWindow,
|
||||
Notebook, Alignment)
|
||||
Notebook, Alignment, Expander)
|
||||
|
||||
_ = gettext.gettext
|
||||
|
||||
@@ -167,6 +167,7 @@ class ViewForm(View):
|
||||
self.widgets = defaultdict(list)
|
||||
self.state_widgets = []
|
||||
self.notebooks = []
|
||||
self.expandables = []
|
||||
|
||||
container = self.parse(xml)
|
||||
|
||||
@@ -384,10 +385,18 @@ class ViewForm(View):
|
||||
if attr not in attributes and attr in field.attrs:
|
||||
attributes[attr] = field.attrs[attr]
|
||||
|
||||
frame = Frame(attributes.get('string'), attrs=attributes)
|
||||
frame.add(group.table)
|
||||
self.state_widgets.append(frame)
|
||||
container.add(frame, attributes)
|
||||
can_expand = attributes.get('expandable')
|
||||
if can_expand:
|
||||
widget = Expander(attributes.get('string'), attrs=attributes)
|
||||
widget.add(group.table)
|
||||
widget.set_expanded(can_expand == '1')
|
||||
self.expandables.append(widget)
|
||||
else:
|
||||
widget = Frame(attributes.get('string'), attrs=attributes)
|
||||
widget.add(group.table)
|
||||
|
||||
self.state_widgets.append(widget)
|
||||
container.add(widget, attributes)
|
||||
|
||||
def _parse_paned(self, node, container, attributes, Paned):
|
||||
attributes.setdefault('yexpand', True)
|
||||
@@ -557,6 +566,9 @@ class ViewForm(View):
|
||||
child = notebook.get_nth_page(i)
|
||||
if focus_widget.is_ancestor(child):
|
||||
notebook.set_current_page(i)
|
||||
for group in self.expandables:
|
||||
if focus_widget.is_ancestor(group):
|
||||
group.set_expanded(True)
|
||||
focus_widget.grab_focus()
|
||||
|
||||
def button_clicked(self, widget):
|
||||
|
||||
@@ -109,3 +109,11 @@ class Alignment(gtk.Alignment):
|
||||
self.add(widget)
|
||||
widget.connect('show', lambda *a: self.show())
|
||||
widget.connect('hide', lambda *a: self.hide())
|
||||
|
||||
|
||||
class Expander(StateMixin, gtk.Expander):
|
||||
|
||||
def __init__(self, label=None, attrs=None):
|
||||
if not label:
|
||||
label = None
|
||||
super(Expander, self).__init__(label=label, attrs=attrs)
|
||||
Reference in new issue
Block a user