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

* src/DisplayTabs/_NoteTab.py: accelerators replaced with key-press
	signal handler.
	* src/DisplayTabs/_ButtonTab.py: accelerators removed; wrong concept.
	* src/DisplayTabs/_GrampsTab.py: accelerators removed; wrong concept.
	* src/Editors/_EditPrimary.py: accelerators removed; wrong concept.
	* src/Editors/_EditSecondary.py: accelerators removed; wrong concept.
	* src/Editors/_EditReference.py: accelerators removed; wrong concept.
	* src/ManagedWindow.py: accelerators removed; wrong concept.



svn: r8154
This commit is contained in:
Zsolt Foldvari 2007-02-18 18:08:26 +00:00
parent 7d6aebf315
commit 9d4b8bbb59
8 changed files with 39 additions and 67 deletions

View File

@ -1,3 +1,13 @@
2007-02-16 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/DisplayTabs/_NoteTab.py: accelerators replaced with key-press
signal handler.
* src/DisplayTabs/_ButtonTab.py: accelerators removed; wrong concept.
* src/DisplayTabs/_GrampsTab.py: accelerators removed; wrong concept.
* src/Editors/_EditPrimary.py: accelerators removed; wrong concept.
* src/Editors/_EditSecondary.py: accelerators removed; wrong concept.
* src/Editors/_EditReference.py: accelerators removed; wrong concept.
* src/ManagedWindow.py: accelerators removed; wrong concept.
2007-02-17 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/GrampsDb/_GrampsDbWriteXML.py: add non-gtk xml writer
* src/GrampsDb/__init__.py: export non-gtk writer

View File

@ -62,13 +62,6 @@ class ButtonTab(GrampsTab):
'share' : _('Share'),
}
_ACCEL = {
'add': 'Insert',
'del': 'Delete',
'edit': '<Control>E',
'share': '<Control>S',
}
def __init__(self, dbstate, uistate, track, name, share_button=False):
"""
Similar to the base class, except after Build
@ -104,13 +97,6 @@ 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,7 +73,6 @@ 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()

View File

@ -82,12 +82,18 @@ class NoteTab(GrampsTab):
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'),
#('Separator', None, None, None),
]
vbox = gtk.VBox()
self.text = gtk.TextView()
self.text.set_accepts_tab(True)
# Accelerator dictionary used for formatting shortcuts
# key: tuple(key, modifier)
# value: widget, to emit 'activate' signal on
self.accelerator = {}
self.text.connect('key-press-event', self._on_key_press_event)
self.flowed = gtk.RadioButton(None, _('Flowed'))
self.format = gtk.RadioButton(self.flowed, _('Formatted'))
@ -124,21 +130,19 @@ class NoteTab(GrampsTab):
self.text.set_buffer(self.buf)
tooltips = gtk.Tooltips()
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)
button.set_relief(gtk.RELIEF_NONE)
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 markup:
button = gtk.ToggleButton()
image = gtk.Image()
image.set_from_stock(stock, gtk.ICON_SIZE_MENU)
button.set_image(image)
button.set_relief(gtk.RELIEF_NONE)
tooltips.set_tip(button, tip)
self.buf.setup_widget_from_xml(button, markup)
key, mod = gtk.accelerator_parse(accel)
self.accelerator[(key, mod)] = button
hbox.pack_start(button, False)
else:
hbox.pack_start(gtk.VSeparator(), False)
if self.note_obj:
self.empty = False
@ -152,6 +156,15 @@ class NoteTab(GrampsTab):
self.buf.connect_after('remove-tag', self.update)
self.rebuild()
def _on_key_press_event(self, widget, event):
log.debug("Key %s (%d) was pressed on %s" %
(gtk.gdk.keyval_name(event.keyval), event.keyval, widget))
key = event.keyval
mod = event.state
if self.accelerator.has_key((key, mod)):
self.accelerator[(key, mod)].emit('activate')
return True
def update(self, obj, *args):
if self.note_obj:
start = self.buf.get_start_iter()

View File

@ -94,13 +94,6 @@ class EditPrimary(ManagedWindow.ManagedWindow):
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:

View File

@ -96,15 +96,7 @@ class EditReference(ManagedWindow.ManagedWindow):
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:
notebook.set_current_page(page_no)

View File

@ -92,13 +92,6 @@ class EditSecondary(ManagedWindow.ManagedWindow):
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:

View File

@ -306,8 +306,6 @@ 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
@ -342,22 +340,10 @@ 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')