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

svn: r22190
This commit is contained in:
Benny Malengier 2013-05-07 12:35:33 +00:00
parent 7f411bb964
commit 4621d09d4d
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.set_size_request(-1, 70)
gtext.get_buffer().set_text("\n".join(value)) gtext.get_buffer().set_text("\n".join(value))
gtext.set_editable(1) gtext.set_editable(1)
gtext.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
self.add(gtext) self.add(gtext)
self.__buff = gtext.get_buffer() self.__buff = gtext.get_buffer()

View File

@ -88,6 +88,8 @@ from gramps.gen.display.name import displayer as _nd
#------------------------------------------------------------------------ #------------------------------------------------------------------------
_UNSUPPORTED = _("Unsupported") _UNSUPPORTED = _("Unsupported")
_RETURN = Gdk.keyval_from_name("Return")
_KP_ENTER = Gdk.keyval_from_name("KP_Enter")
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Private Functions # Private Functions
@ -239,8 +241,10 @@ class BookListDisplay(object):
"on_save_clicked" : self.do_nothing, "on_save_clicked" : self.do_nothing,
"on_clear_clicked" : self.do_nothing "on_clear_clicked" : self.do_nothing
}) })
self.guilistbooks = self.xml.get_object('list')
self.blist = ListModel(self.xml.get_object("list"), [('Name',-1,10)],) 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.redraw()
self.selection = None self.selection = None
@ -294,7 +298,35 @@ class BookListDisplay(object):
return return
else: else:
self.top.run() 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): def do_nothing(self, object):
pass pass

View File

@ -194,13 +194,23 @@ class ReportDialog(ManagedWindow):
self.notebook = Gtk.Notebook() self.notebook = Gtk.Notebook()
self.notebook.set_scrollable(True) self.notebook.set_scrollable(True)
self.notebook.set_border_width(6) self.notebook.set_border_width(6)
self.window.vbox.add(self.notebook) 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_report_options_frame()
self.setup_other_frames() self.setup_other_frames()
self.notebook.set_current_page(0) self.notebook.set_current_page(0)
self.window.vbox.add(self.tbl) 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() self.show()
def get_title(self): def get_title(self):
@ -293,7 +303,7 @@ class ReportDialog(ManagedWindow):
label = Gtk.Label(label='<span size="larger" weight="bold">%s</span>' % label = Gtk.Label(label='<span size="larger" weight="bold">%s</span>' %
self.report_name) self.report_name)
label.set_use_markup(True) 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): def setup_style_frame(self):
"""Set up the style frame of the dialog. This function relies """Set up the style frame of the dialog. This function relies
@ -376,6 +386,7 @@ class ReportDialog(ManagedWindow):
row += 1 row += 1
def setup_other_frames(self): def setup_other_frames(self):
from gramps.gui.plug._guioptions import GuiTextOption
for key in self.frame_names: for key in self.frame_names:
flist = self.frames[key] flist = self.frames[key]
table = Gtk.Table(3, len(flist)) table = Gtk.Table(3, len(flist))
@ -393,7 +404,11 @@ class ReportDialog(ManagedWindow):
text_widget.set_alignment(0.0, 0.5) text_widget.set_alignment(0.0, 0.5)
table.attach(text_widget, 1, 2, row, row+1, table.attach(text_widget, 1, 2, row, row+1,
Gtk.AttachOptions.SHRINK|Gtk.AttachOptions.FILL, Gtk.AttachOptions.SHRINK) Gtk.AttachOptions.SHRINK|Gtk.AttachOptions.FILL, Gtk.AttachOptions.SHRINK)
table.attach(widget, 2, 3, row, row+1, 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) yoptions=Gtk.AttachOptions.SHRINK)
else: else:
table.attach(widget, 2, 3, row, row+1, table.attach(widget, 2, 3, row, row+1,

View File

@ -128,41 +128,41 @@ class CustomTextOptions(MenuReportOptions):
top = TextOption(_("Initial Text"), [""] ) top = TextOption(_("Initial Text"), [""] )
top.set_help(_("Text to display at the top.")) top.set_help(_("Text to display at the top."))
menu.add_option(category_name,"top",top) menu.add_option(category_name, "top", top)
mid = TextOption(_("Middle Text"), [""] ) mid = TextOption(_("Middle Text"), [""] )
mid.set_help(_("Text to display in the middle")) mid.set_help(_("Text to display in the middle"))
menu.add_option(category_name,"mid",mid) menu.add_option(category_name, "mid", mid)
bot = TextOption(_("Final Text"), [""] ) bot = TextOption(_("Final Text"), [""] )
bot.set_help(_("Text to display last.")) bot.set_help(_("Text to display last."))
menu.add_option(category_name,"bot",bot) menu.add_option(category_name, "bot", bot)
def make_default_style(self,default_style): def make_default_style(self,default_style):
"""Make the default output style for the Custom Text report.""" """Make the default output style for the Custom Text report."""
font = FontStyle() font = FontStyle()
font.set(face=FONT_SANS_SERIF,size=12,bold=0,italic=0) font.set(face=FONT_SANS_SERIF, size=12, bold=0, italic=0)
para = ParagraphStyle() para = ParagraphStyle()
para.set_font(font) para.set_font(font)
para.set_alignment(PARA_ALIGN_CENTER) para.set_alignment(PARA_ALIGN_CENTER)
para.set(pad=0.5) para.set(pad=0.5)
para.set_description(_('The style used for the first portion of the custom text.')) para.set_description(_('The style used for the first portion of the custom text.'))
default_style.add_paragraph_style("CBT-Initial",para) default_style.add_paragraph_style("CBT-Initial", para)
font = FontStyle() font = FontStyle()
font.set(face=FONT_SANS_SERIF,size=12,bold=0,italic=0) font.set(face=FONT_SANS_SERIF, size=12, bold=0, italic=0)
para = ParagraphStyle() para = ParagraphStyle()
para.set_font(font) para.set_font(font)
para.set(pad=0.5) para.set(pad=0.5)
para.set_alignment(PARA_ALIGN_CENTER) para.set_alignment(PARA_ALIGN_CENTER)
para.set_description(_('The style used for the middle portion of the custom text.')) para.set_description(_('The style used for the middle portion of the custom text.'))
default_style.add_paragraph_style("CBT-Middle",para) default_style.add_paragraph_style("CBT-Middle", para)
font = FontStyle() font = FontStyle()
font.set(face=FONT_SANS_SERIF,size=12,bold=0,italic=0) font.set(face=FONT_SANS_SERIF, size=12, bold=0, italic=0)
para = ParagraphStyle() para = ParagraphStyle()
para.set_font(font) para.set_font(font)
para.set_alignment(PARA_ALIGN_CENTER) para.set_alignment(PARA_ALIGN_CENTER)
para.set(pad=0.5) para.set(pad=0.5)
para.set_description(_('The style used for the last portion of the custom text.')) para.set_description(_('The style used for the last portion of the custom text.'))
default_style.add_paragraph_style("CBT-Final",para) default_style.add_paragraph_style("CBT-Final", para)