2007-02-16 Zsolt Foldvari <zfoldvar@users.sourceforge.net>

* src/data/mainX.css: enable formatted notes on narrative web
	* src/plugins/NarrativeWeb.py: enable formatted notes on narrative web
	* src/MarkupText.py: properly reset xml generator output: fix #924
	* src/ManagedWindow.py: enable accelerators in editor windows 
	* src/Editors/_EditPrimary.py: enable accelerators in editor windows
	* src/Editors/_EditSecondary.py: enable accelerators in editor windows
	* src/Editors/_EditReference.py: enable accelerators in editor windows
	* src/DisplayTabs/_NoteTab.py: enable accelerators in editor windows 
	* src/DisplayTabs/_ButtonTab.py: enable accelerators in editor windows
	* src/DisplayTabs/_GrampsTab.py: enable accelerators in editor windows



svn: r8137
This commit is contained in:
Zsolt Foldvari 2007-02-16 21:20:36 +00:00
parent b49ef36e5d
commit d3b383109d
16 changed files with 164 additions and 48 deletions

View File

@ -1,3 +1,15 @@
2007-02-16 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/data/mainX.css: enable formatted notes on narrative web
* src/plugins/NarrativeWeb.py: enable formatted notes on narrative web
* src/MarkupText.py: properly reset xml generator output: fix #924
* src/ManagedWindow.py: enable accelerators in editor windows
* src/Editors/_EditPrimary.py: enable accelerators in editor windows
* src/Editors/_EditSecondary.py: enable accelerators in editor windows
* src/Editors/_EditReference.py: enable accelerators in editor windows
* src/DisplayTabs/_NoteTab.py: enable accelerators in editor windows
* src/DisplayTabs/_ButtonTab.py: enable accelerators in editor windows
* src/DisplayTabs/_GrampsTab.py: enable accelerators in editor windows
2007-02-16 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/ProgressDialog.py: more work on progress dialog

View File

@ -60,7 +60,14 @@ class ButtonTab(GrampsTab):
'del' : _('Remove'),
'edit' : _('Edit'),
'share' : _('Share'),
}
}
_ACCEL = {
'add': 'Insert',
'del': 'Delete',
'edit': '<Control>E',
'share': '<Control>S',
}
def __init__(self, dbstate, uistate, track, name, share_button=False):
"""
@ -97,6 +104,13 @@ class ButtonTab(GrampsTab):
self.tooltips.set_tip(self.edit_btn, self._MSG['edit'])
self.tooltips.set_tip(self.del_btn, self._MSG['del'])
key, mod = gtk.accelerator_parse(self._ACCEL['add'])
self.add_btn.add_accelerator('activate', self.accel_group, key, mod, gtk.ACCEL_VISIBLE)
key, mod = gtk.accelerator_parse(self._ACCEL['edit'])
self.edit_btn.add_accelerator('activate', self.accel_group, key, mod, gtk.ACCEL_VISIBLE)
key, mod = gtk.accelerator_parse(self._ACCEL['del'])
self.del_btn.add_accelerator('activate', self.accel_group, key, mod, gtk.ACCEL_VISIBLE)
if share_button:
self.share_btn = SimpleButton(gtk.STOCK_INDEX, self.share_button_clicked)
self.tooltips.set_tip(self.share_btn, self._MSG['share'])

View File

@ -73,6 +73,7 @@ class GrampsTab(gtk.HBox):
self.label_container = self.build_label_widget()
# build the interface
self.accel_group = gtk.AccelGroup()
self.share_btn = None
self.build_interface()
@ -158,3 +159,4 @@ class GrampsTab(gtk.HBox):
can be used to add widgets to the interface.
"""
pass

View File

@ -79,11 +79,16 @@ class NoteTab(GrampsTab):
return self.buf.get_char_count() == 0
def build_interface(self):
BUTTON = [(_('Italic'),gtk.STOCK_ITALIC,'<i>i</i>','<Control>I'),
(_('Bold'),gtk.STOCK_BOLD,'<b>b</b>','<Control>B'),
(_('Underline'),gtk.STOCK_UNDERLINE,'<u>u</u>','<Control>U'),
]
vbox = gtk.VBox()
self.text = gtk.TextView()
self.text.set_accepts_tab(True)
self.flowed = gtk.RadioButton(None, _('Flowed'))
self.format = gtk.RadioButton(self.flowed, _('Formatted'))
@ -112,25 +117,29 @@ class NoteTab(GrampsTab):
hbox.set_border_width(6)
hbox.pack_start(self.flowed, False)
hbox.pack_start(self.format, False)
vbox.pack_start(hbox, False)
self.pack_start(vbox, True)
self.buf = EditorBuffer()
self.text.set_buffer(self.buf)
tooltips = gtk.Tooltips()
for tip,stock,font in [('Italic',gtk.STOCK_ITALIC,'<i>i</i>'),
('Bold',gtk.STOCK_BOLD,'<b>b</b>'),
('Underline',gtk.STOCK_UNDERLINE,'<u>u</u>'),
]:
button = gtk.ToggleButton()
for tip, stock, markup, accel in BUTTON:
image = gtk.Image()
image.set_from_stock(stock, gtk.ICON_SIZE_MENU)
button = gtk.ToggleButton()
button.set_image(image)
tooltips.set_tip(button, tip)
button.set_relief(gtk.RELIEF_NONE)
self.buf.setup_widget_from_xml(button,font)
tooltips.set_tip(button, tip)
self.buf.setup_widget_from_xml(button, markup)
key, mod = gtk.accelerator_parse(accel)
button.add_accelerator('activate', self.accel_group,
key, mod, gtk.ACCEL_VISIBLE)
hbox.pack_start(button, False)
if self.note_obj:
self.empty = False
self.buf.set_text(self.note_obj.get(markup=True))

View File

@ -84,14 +84,24 @@ class EditPrimary(ManagedWindow.ManagedWindow):
return obj.get_handle()
else:
return id(self)
def _setup_notebook_tabs(self, notebook):
for child in notebook.get_children():
label = notebook.get_tab_label(child)
page_no = notebook.page_num(child)
label.drag_dest_set(0, [], 0)
label.connect('drag_motion', self._switch_page_on_dnd,notebook,page_no)
label.connect('drag_motion',
self._switch_page_on_dnd,
notebook,
page_no)
try:
self.window.get_toplevel().add_accel_group(child.accel_group)
except AttributeError:
pass
self.register_accelerator('<Control>Page_Down', notebook.next_page)
self.register_accelerator('<Control>Page_Up', notebook.prev_page)
def _switch_page_on_dnd(self, widget, context, x, y, time, notebook, page_no):
if notebook.get_current_page() != page_no:
notebook.set_current_page(page_no)

View File

@ -92,7 +92,18 @@ class EditReference(ManagedWindow.ManagedWindow):
label = notebook.get_tab_label(child)
page_no = notebook.page_num(child)
label.drag_dest_set(0, [], 0)
label.connect('drag_motion', self._switch_page_on_dnd,notebook,page_no)
label.connect('drag_motion',
self._switch_page_on_dnd,
notebook,
page_no)
try:
self.window.get_toplevel().add_accel_group(child.accel_group)
except AttributeError:
pass
# FIXME: Since Reference editors have two notebooks accelerators
# are not working this way!!
self.register_accelerator('<Control>Page_Down', notebook.next_page)
self.register_accelerator('<Control>Page_Up', notebook.prev_page)
def _switch_page_on_dnd(self, widget, context, x, y, time, notebook, page_no):
if notebook.get_current_page() != page_no:

View File

@ -88,8 +88,18 @@ class EditSecondary(ManagedWindow.ManagedWindow):
label = notebook.get_tab_label(child)
page_no = notebook.page_num(child)
label.drag_dest_set(0, [], 0)
label.connect('drag_motion', self._switch_page_on_dnd,notebook,page_no)
label.connect('drag_motion',
self._switch_page_on_dnd,
notebook,
page_no)
try:
self.window.get_toplevel().add_accel_group(child.accel_group)
except AttributeError:
pass
self.register_accelerator('<Control>Page_Down', notebook.next_page)
self.register_accelerator('<Control>Page_Up', notebook.prev_page)
def _switch_page_on_dnd(self, widget, context, x, y, time, notebook, page_no):
if notebook.get_current_page() != page_no:
notebook.set_current_page(page_no)

View File

@ -306,6 +306,8 @@ class ManagedWindow:
...
"""
self.accel_group = gtk.AccelGroup()
self.accelerators = {}
window_key = self.build_window_key(obj)
menu_label,submenu_label = self.build_menu_names(obj)
self._gladeobj = None
@ -340,10 +342,22 @@ class ManagedWindow:
# On the top level: we use gramps top window
self.parent_window = self.uistate.window
def register_accelerator(self, accelerator, callback, *args):
key, mod = gtk.accelerator_parse(accelerator)
self.accelerators[(key, mod)] = (callback, args)
self.accel_group.connect_group(key, mod, gtk.ACCEL_VISIBLE,
self.accel_func)
def accel_func(self, accel_group, acceleratable, keyval, modifier):
if self.accelerators.has_key((keyval, modifier)):
callback, args = self.accelerators[(keyval, modifier)]
callback(*args)
def set_window(self,window,title,text,msg=None):
set_titles(window, title, text, msg)
self.window = window
self.window.connect('delete-event', self.close)
self.window.get_toplevel().add_accel_group(self.accel_group)
def build_menu_names(self,obj):
return ('Undefined Menu','Undefined Submenu')

View File

@ -57,9 +57,9 @@ import gtk
class MarkupParser(ContentHandler):
"""A simple ContentHandler class to parse Gramps markup'ed text.
Use it with xml.sax.parse() or xml.sax.parseString().
Parsing result can be obtained via it's public attributes.
Use it with xml.sax.parse() or xml.sax.parseString(). A root tag, 'gramps',
is required. Parsing result can be obtained via the public attributes of
the class:
@attr content: clean text
@attr type: str
@attr elements: list of markup elements
@ -220,7 +220,7 @@ class MarkupWriter:
def generate(self, text, elements):
# reset output and start root element
self._output.seek(0)
self._output.truncate(0)
self._writer.startElement('gramps', self._attrs)
# split the elements to events
@ -528,7 +528,10 @@ if __name__ == '__main__':
def cb(window, event):
gtk.main_quit()
win.connect('delete-event', cb)
accel_group = gtk.AccelGroup()
win.add_accel_group(accel_group)
vbox = gtk.VBox()
win.add(vbox)
@ -568,10 +571,10 @@ if __name__ == '__main__':
buf = EditorBuffer()
text.set_buffer(buf)
tooltips = gtk.Tooltips()
for tip,stock,font in [('Italic',gtk.STOCK_ITALIC,'<i>i</i>'),
('Bold',gtk.STOCK_BOLD,'<b>b</b>'),
('Underline',gtk.STOCK_UNDERLINE,'<u>u</u>'),
]:
for tip,stock,font,accel in [('Italic',gtk.STOCK_ITALIC,'<i>i</i>','<Control>I'),
('Bold',gtk.STOCK_BOLD,'<b>b</b>','<Control>B'),
('Underline',gtk.STOCK_UNDERLINE,'<u>u</u>','<Control>U'),
]:
button = gtk.ToggleButton()
image = gtk.Image()
image.set_from_stock(stock, gtk.ICON_SIZE_MENU)
@ -579,6 +582,9 @@ if __name__ == '__main__':
tooltips.set_tip(button, tip)
button.set_relief(gtk.RELIEF_NONE)
buf.setup_widget_from_xml(button,font)
key, mod = gtk.accelerator_parse(accel)
button.add_accelerator('activate', accel_group,
key, mod, gtk.ACCEL_VISIBLE)
hbox.pack_start(button, False)
buf.set_text('<gramps>'

View File

@ -110,6 +110,10 @@ TD.data {
padding: 1px 3em 1px 1px; /* Defines spacing between rows */
font-weight: bold;
}
TD.note {
padding: 1px 3em 1px 1px; /* Defines spacing between rows */
/*font-weight: bold;*/
}
TD.field {
padding: 1px 3em 1px 1px; /* Defines spacing between rows */
/*width: 15%;*/

View File

@ -112,6 +112,10 @@ TD.data {
padding: 3px 3em 3px 3px; /* Defines spacing between rows */
font-weight: bold;
}
TD.note {
padding: 3px 3em 3px 3px; /* Defines spacing between rows */
/*font-weight: bold;*/
}
TD.field {
padding: 3px 3em 3px 3px; /* Defines spacing between rows */
/*width: 15%;*/

View File

@ -115,6 +115,11 @@ TD.data {
padding-right: 3em;
font-weight: bold;
}
TD.note {
padding: 4px; /* Defines spacing between rows */
padding-right: 3em;
/*font-weight: bold;*/
}
TD.field {
padding: 4px; /* Defines spacing between rows */
padding-right: 3em;

View File

@ -123,6 +123,14 @@ TD.data {
font-weight: bold;
background-color: #f0ece6;
}
TD.note {
margin: 0;
padding: 4px; /* Defines spacing between rows */
padding-left: 10px;
padding-right: 3em;
/*font-weight: bold;*/
background-color: #f0ece6;
}
TD.field {
margin: 0;
padding: 4px; /* Defines spacing between rows */

View File

@ -132,6 +132,11 @@ TD.data {
padding-right: 3em;
font-weight: bold;
}
TD.note {
padding: 3px; /* Defines spacing between rows */
padding-right: 3em;
/*font-weight: bold;*/
}
/* float left and right */
.leftwrap {
float: left;

View File

@ -110,6 +110,8 @@ TD.field {
}
TD.data {
}
TD.note {
}
#summaryarea TABLE.infolist TR TD {
font-weight: bold;
}

View File

@ -158,7 +158,7 @@ class BasePage:
self.graphgens = options.handler.options_dict['NWEBgraphgens']
self.use_home = self.options.handler.options_dict['NWEBhomenote'] != ""
self.page_title = ""
self.warn_dir = True
self.warn_dir = True
def store_file(self,archive,html_dir,from_path,to_path):
if archive:
@ -168,18 +168,18 @@ class BasePage:
dirname = os.path.dirname(dest)
if not os.path.isdir(dirname):
os.makedirs(dirname)
if from_path != dest:
shutil.copyfile(from_path,dest)
elif self.warn_dir:
WarningDialog(
_("Possible destination error") + "\n" +
_("You appear to have set your target directory "
"to a directory used for data storage. This "
"could create problems with file management. "
"It is recommended that you consider using "
"a different directory to store your generated "
"web pages."))
self.warn_dir = False
if from_path != dest:
shutil.copyfile(from_path,dest)
elif self.warn_dir:
WarningDialog(
_("Possible destination error") + "\n" +
_("You appear to have set your target directory "
"to a directory used for data storage. This "
"could create problems with file management. "
"It is recommended that you consider using "
"a different directory to store your generated "
"web pages."))
self.warn_dir = False
def copy_media(self,photo,store_ref=True):
@ -277,7 +277,7 @@ class BasePage:
obj = db.get_object_from_handle(self.footer)
if obj:
of.write('<div class="user_footer">\n')
of.write(obj.get_note())
of.write(obj.get_note(markup=True))
of.write('</div>\n')
of.write('</body>\n')
of.write('</html>\n')
@ -312,7 +312,7 @@ class BasePage:
obj = db.get_object_from_handle(self.header)
if obj:
of.write(' <div class="user_header">\n')
of.write(obj.get_note())
of.write(obj.get_note(markup=True))
of.write(' </div>\n')
of.write('<div id="navheader">\n')
@ -429,7 +429,7 @@ class BasePage:
if not noteobj:
return
format = noteobj.get_format()
text = noteobj.get()
text = noteobj.get(markup=True)
try:
text = unicode(text)
except UnicodeDecodeError:
@ -1079,7 +1079,7 @@ class IntroductionPage(BasePage):
note_obj = obj.get_note_object()
if note_obj:
text = note_obj.get()
text = note_obj.get(markup=True)
if note_obj.get_format():
of.write('<pre>\n%s\n</pre>\n' % text)
else:
@ -1126,7 +1126,7 @@ class HomePage(BasePage):
note_obj = obj.get_note_object()
if note_obj:
text = note_obj.get()
text = note_obj.get(markup=True)
if note_obj.get_format():
of.write('<pre>\n%s\n</pre>\n' % text)
else:
@ -1345,7 +1345,7 @@ class ContactPage(BasePage):
nobj = obj.get_note_object()
if nobj:
format = nobj.get_format()
text = nobj.get()
text = nobj.get(markup=True)
if format:
text = u"<pre>%s</pre>" % text
@ -1922,12 +1922,12 @@ class IndividualPage(BasePage):
of.write('<td class="data">%s</td>\n</tr>\n' % attr.get_value())
nobj = family.get_note_object()
if nobj:
text = nobj.get()
text = nobj.get(markup=True)
format = nobj.get_format()
if text:
of.write('<tr><td>&nbsp;</td>\n')
of.write('<td class="field">%s</td>\n' % _('Narrative'))
of.write('<td class="data">\n')
of.write('<td class="note">\n')
if format:
of.write( u"<pre>%s</pre>" % text )
else: