6659: Justified paragraph layout does not work in "Custom Book Text" in book report

svn: r22191
This commit is contained in:
Benny Malengier 2013-05-07 12:37:00 +00:00
parent d551e2b5e4
commit ded3b12080
4 changed files with 64 additions and 16 deletions

View File

@ -366,6 +366,7 @@ class GuiTextOption(Gtk.ScrolledWindow):
gtext.set_size_request(-1, 70)
gtext.get_buffer().set_text("\n".join(value))
gtext.set_editable(1)
gtext.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
self.add(gtext)
self.__buff = gtext.get_buffer()

View File

@ -88,6 +88,8 @@ from gramps.gen.display.name import displayer as _nd
#------------------------------------------------------------------------
_UNSUPPORTED = _("Unsupported")
_RETURN = Gdk.keyval_from_name("Return")
_KP_ENTER = Gdk.keyval_from_name("KP_Enter")
#------------------------------------------------------------------------
#
# Private Functions
@ -239,8 +241,10 @@ class BookListDisplay(object):
"on_save_clicked" : self.do_nothing,
"on_clear_clicked" : self.do_nothing
})
self.blist = ListModel(self.xml.get_object("list"), [('Name',-1,10)],)
self.guilistbooks = self.xml.get_object('list')
self.guilistbooks.connect('button-press-event', self.on_button_press)
self.guilistbooks.connect('key-press-event', self.on_key_pressed)
self.blist = ListModel(self.guilistbooks, [('Name',-1,10)],)
self.redraw()
self.selection = None
@ -295,6 +299,34 @@ class BookListDisplay(object):
else:
self.top.run()
def on_button_press(self, obj, event):
"""
Checks for a double click event. In the list, we want to
treat a double click as if it was OK button press.
"""
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
store, the_iter = self.blist.get_selected()
if not the_iter:
return False
self.on_booklist_ok_clicked(obj)
#emit OK response on dialog to close it automatically
self.top.response(-5)
return True
return False
def on_key_pressed(self, obj, event):
"""
Handles the return key being pressed on list. If the key is pressed,
the Edit button handler is called
"""
if event.type == Gdk.EventType.KEY_PRESS:
if event.keyval in (_RETURN, _KP_ENTER):
self.on_booklist_ok_clicked(obj)
#emit OK response on dialog to close it automatically
self.top.response(-5)
return True
return False
def do_nothing(self, object):
pass

View File

@ -194,12 +194,22 @@ class ReportDialog(ManagedWindow):
self.notebook = Gtk.Notebook()
self.notebook.set_scrollable(True)
self.notebook.set_border_width(6)
try:
#assume a vbox or hbox
self.window.vbox.pack_start(self.notebook, expand=True, fill=True, padding=0)
except:
#general container instead:
self.window.vbox.add(self.notebook)
self.setup_report_options_frame()
self.setup_other_frames()
self.notebook.set_current_page(0)
try:
#assume a vbox or hbox
self.window.vbox.pack_start(self.tbl, expand=True, fill=True, padding=0)
except:
#general container instead:
self.window.vbox.add(self.tbl)
self.show()
@ -293,7 +303,7 @@ class ReportDialog(ManagedWindow):
label = Gtk.Label(label='<span size="larger" weight="bold">%s</span>' %
self.report_name)
label.set_use_markup(True)
self.window.vbox.pack_start(label, True, True, self.border_pad)
self.window.vbox.pack_start(label, False, False, self.border_pad)
def setup_style_frame(self):
"""Set up the style frame of the dialog. This function relies
@ -376,6 +386,7 @@ class ReportDialog(ManagedWindow):
row += 1
def setup_other_frames(self):
from gramps.gui.plug._guioptions import GuiTextOption
for key in self.frame_names:
flist = self.frames[key]
table = Gtk.Table(3, len(flist))
@ -393,6 +404,10 @@ class ReportDialog(ManagedWindow):
text_widget.set_alignment(0.0, 0.5)
table.attach(text_widget, 1, 2, row, row+1,
Gtk.AttachOptions.SHRINK|Gtk.AttachOptions.FILL, Gtk.AttachOptions.SHRINK)
if isinstance(widget, GuiTextOption):
table.attach(widget, 2, 3, row, row+1,
yoptions=Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL)
else:
table.attach(widget, 2, 3, row, row+1,
yoptions=Gtk.AttachOptions.SHRINK)
else: