Skip to content

Commit 192b784

Browse files
committed
Merge pull request #1676 from carlesalbasboix/add_navigation_mouse_buttons
2 parents 9325608 + 983c97f commit 192b784

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

gramps/gui/views/navigationview.py

+17
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ def fwd_clicked(self, *obj):
382382
Move forward one object in the history.
383383
"""
384384
hobj = self.get_history()
385+
if hobj.lock:
386+
return
385387
hobj.lock = True
386388
if not hobj.at_end():
387389
hobj.forward()
@@ -395,6 +397,8 @@ def back_clicked(self, *obj):
395397
Move backward one object in the history.
396398
"""
397399
hobj = self.get_history()
400+
if hobj.lock:
401+
return
398402
hobj.lock = True
399403
if not hobj.at_front():
400404
hobj.back()
@@ -486,6 +490,19 @@ def key_press_handler(self, widget, event):
486490
return True
487491
return super(NavigationView, self).key_press_handler(widget, event)
488492

493+
def button_press_handler(self, widget, event):
494+
"""
495+
Handle forward and backward buttons, or pass it on.
496+
"""
497+
if self.active:
498+
if event.button == 8:
499+
self.back_clicked()
500+
return True
501+
elif event.button == 9:
502+
self.fwd_clicked()
503+
return True
504+
return super(NavigationView, self).button_press_handler(widget, event)
505+
489506
def call_copy(self):
490507
"""
491508
Navigation specific copy (control+c) hander. If the

gramps/gui/views/pageview.py

+8
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def __init__(self, title, pdata, dbstate, uistate):
130130
self.dbstate.connect("no-database", self.disable_action_group)
131131
self.dbstate.connect("database-changed", self.enable_action_group)
132132
self.uistate.window.connect("key-press-event", self.key_press_handler)
133+
self.uistate.window.connect("button-press-event", self.button_press_handler)
133134

134135
self.model = None
135136
self.selection = None
@@ -264,6 +265,13 @@ def key_press_handler(self, widget, event):
264265
"""
265266
return False
266267

268+
def button_press_handler(self, widget, event):
269+
"""
270+
A general button press handler. Override if you want to handle
271+
special buttons, like forward or backward.
272+
"""
273+
return False
274+
267275
def copy_to_clipboard(self, objclass, handles):
268276
"""
269277
This code is called on Control+C in a navigation view. If the

0 commit comments

Comments
 (0)