Make 'title' attribute available on dialog widgets
Gertty uses WidgetWraps around the LineBox widget for popup widgets. Add LineBoxTitlePropertyMixin which adds property and setter for title attribute, accessing the underlying title_widget on the wrapped LineBox widget. We use the popup method in the controller to display these dialogs. It uses an Overlay widget to display our dialog widget on top of the current view. If the widget to be displayed by the Overlay widget has title attribute, copy it to the Overlay widget. Change-Id: I4c6ecbc7ed87867cd67cd93c1125384dd5d4b9af
This commit is contained in:
parent
b009075467
commit
c7ed7ab38a
@ -453,6 +453,8 @@ class App(object):
|
||||
'center', width,
|
||||
'middle', height,
|
||||
min_width=min_width, min_height=min_height)
|
||||
if hasattr(widget, 'title'):
|
||||
overlay.title = widget.title
|
||||
self.log.debug("Overlaying %s on screen %s" % (widget, self.frame.body))
|
||||
self.screens.append(self.frame.body)
|
||||
self.frame.body = overlay
|
||||
|
@ -128,13 +128,23 @@ class MyEdit(urwid.Edit):
|
||||
self.ring.kill(text)
|
||||
return super(MyEdit, self).keypress(size, key)
|
||||
|
||||
class SystemMessage(urwid.WidgetWrap):
|
||||
class LineBoxTitlePropertyMixin(object):
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return self._w.title_widget.text.strip()
|
||||
|
||||
@title.setter
|
||||
def title(self, text):
|
||||
return self._w.set_title(text)
|
||||
|
||||
class SystemMessage(urwid.WidgetWrap, LineBoxTitlePropertyMixin):
|
||||
def __init__(self, message):
|
||||
w = urwid.Filler(urwid.Text(message, align='center'))
|
||||
super(SystemMessage, self).__init__(urwid.LineBox(w))
|
||||
super(SystemMessage, self).__init__(urwid.LineBox(w, u'System Message'))
|
||||
|
||||
@mouse_scroll_decorator.ScrollByWheel
|
||||
class ButtonDialog(urwid.WidgetWrap):
|
||||
class ButtonDialog(urwid.WidgetWrap, LineBoxTitlePropertyMixin):
|
||||
def __init__(self, title, message, entry_prompt=None,
|
||||
entry_text='', buttons=[], ring=None):
|
||||
button_widgets = []
|
||||
@ -180,7 +190,7 @@ class LineEditDialog(ButtonDialog):
|
||||
return None
|
||||
return key
|
||||
|
||||
class TextEditDialog(urwid.WidgetWrap):
|
||||
class TextEditDialog(urwid.WidgetWrap, LineBoxTitlePropertyMixin):
|
||||
signals = ['save', 'cancel']
|
||||
def __init__(self, title, prompt, button, text, ring=None):
|
||||
save_button = FixedButton(button)
|
||||
|
@ -56,7 +56,7 @@ class EditTopicDialog(mywid.ButtonDialog):
|
||||
return None
|
||||
return key
|
||||
|
||||
class CherryPickDialog(urwid.WidgetWrap):
|
||||
class CherryPickDialog(urwid.WidgetWrap, mywid.LineBoxTitlePropertyMixin):
|
||||
signals = ['save', 'cancel']
|
||||
def __init__(self, app, change):
|
||||
save_button = mywid.FixedButton('Propose Change')
|
||||
@ -87,7 +87,7 @@ class CherryPickDialog(urwid.WidgetWrap):
|
||||
super(CherryPickDialog, self).__init__(urwid.LineBox(fill,
|
||||
'Propose Change to Branch'))
|
||||
|
||||
class ReviewDialog(urwid.WidgetWrap):
|
||||
class ReviewDialog(urwid.WidgetWrap, mywid.LineBoxTitlePropertyMixin):
|
||||
signals = ['submit', 'save', 'cancel']
|
||||
def __init__(self, app, revision_key):
|
||||
self.revision_key = revision_key
|
||||
|
@ -24,7 +24,7 @@ from gertty import gitrepo
|
||||
from gertty import sync
|
||||
from gertty.view import mouse_scroll_decorator
|
||||
|
||||
class PatchsetDialog(urwid.WidgetWrap):
|
||||
class PatchsetDialog(urwid.WidgetWrap, mywid.LineBoxTitlePropertyMixin):
|
||||
signals = ['ok', 'cancel']
|
||||
|
||||
def __init__(self, patchsets, old, new):
|
||||
|
Loading…
x
Reference in New Issue
Block a user