Accept control-click as an alternative for right-click when the Gdk
backend is Quartz. This is a standard behavior on Macs, since they often have single-button mice or trackpads. svn: r19753
This commit is contained in:
@@ -43,6 +43,7 @@ import pango
|
||||
# GRAMPS classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gui.utils
|
||||
from buttontab import ButtonTab
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@@ -97,7 +98,7 @@ class EmbeddedList(ButtonTab):
|
||||
"""
|
||||
Handle button press, not double-click, that is done in init_interface
|
||||
"""
|
||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
if gui.utils.is_right_click(event):
|
||||
ref = self.get_selected()
|
||||
if ref:
|
||||
self.right_click(obj, event)
|
||||
|
||||
@@ -47,7 +47,7 @@ import gobject
|
||||
# GRAMPS classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gui.utils import open_file_with_default_application
|
||||
import gui.utils
|
||||
from gui.dbguielement import DbGUIElement
|
||||
from gui.selectors import SelectorFactory
|
||||
import gen.lib
|
||||
@@ -66,7 +66,7 @@ import const
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def make_launcher(path):
|
||||
return lambda x: open_file_with_default_application(path)
|
||||
return lambda x: gui.utils.open_file_with_default_application(path)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -112,7 +112,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
||||
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
||||
self.edit_button_clicked(obj)
|
||||
return True
|
||||
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
elif gui.utils.is_right_click(event):
|
||||
reflist = self.iconlist.get_selected_items()
|
||||
if len(reflist) == 1:
|
||||
ref = self.media_list[reflist[0][0]]
|
||||
|
||||
@@ -42,6 +42,7 @@ import gobject
|
||||
# GRAMPS classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gui.utils
|
||||
from embeddedlist import EmbeddedList
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@@ -102,7 +103,7 @@ class GroupEmbeddedList(EmbeddedList):
|
||||
"""
|
||||
Handle button press, not double-click, that is done in init_interface
|
||||
"""
|
||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
if gui.utils.is_right_click(event):
|
||||
obj = self.get_selected()
|
||||
if obj and obj[1]:
|
||||
self._tmpgroup = obj[0]
|
||||
|
||||
@@ -51,7 +51,7 @@ import pango
|
||||
#-------------------------------------------------------------------------
|
||||
import Utils
|
||||
import ThumbNails
|
||||
from gui.utils import add_menuitem, open_file_with_default_application
|
||||
import gui.utils
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gui import widgets
|
||||
@@ -592,7 +592,7 @@ class EditPerson(EditPrimary):
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
|
||||
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
elif gui.utils.is_right_click(event):
|
||||
media_list = self.obj.get_media_list()
|
||||
if media_list:
|
||||
photo = media_list[0]
|
||||
@@ -610,9 +610,10 @@ class EditPerson(EditPrimary):
|
||||
menu.set_title(_("Media Object"))
|
||||
obj = self.db.get_object_from_handle(photo.get_reference_handle())
|
||||
if obj:
|
||||
add_menuitem(menu, _("View"), photo, self._popup_view_photo)
|
||||
add_menuitem(menu, _("Edit Object Properties"), photo,
|
||||
self._popup_change_description)
|
||||
gui.utilsadd_menuitem(menu, _("View"), photo,
|
||||
self._popup_view_photo)
|
||||
gui.utils.add_menuitem(menu, _("Edit Object Properties"), photo,
|
||||
self._popup_change_description)
|
||||
menu.popup(None, None, None, event.button, event.time)
|
||||
|
||||
def _popup_view_photo(self, obj):
|
||||
@@ -625,7 +626,7 @@ class EditPerson(EditPrimary):
|
||||
object_handle = photo.get_reference_handle()
|
||||
ref_obj = self.db.get_object_from_handle(object_handle)
|
||||
photo_path = Utils.media_path_full(self.db, ref_obj.get_path())
|
||||
open_file_with_default_application(photo_path)
|
||||
gui.utils.open_file_with_default_application(photo_path)
|
||||
|
||||
def _popup_change_description(self, obj):
|
||||
"""
|
||||
|
||||
@@ -44,6 +44,7 @@ import ManagedWindow
|
||||
import DateHandler
|
||||
from gen.display.name import displayer as name_displayer
|
||||
import config
|
||||
import gui.utils
|
||||
import GrampsDisplay
|
||||
from QuestionDialog import SaveDialog
|
||||
import gen.lib
|
||||
@@ -283,7 +284,7 @@ class EditPrimary(ManagedWindow.ManagedWindow, DbGUIElement):
|
||||
pressed while on contexteventbox
|
||||
It opens a context menu with possible actions
|
||||
"""
|
||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3 :
|
||||
if gui.utils.is_right_click(event):
|
||||
if self.obj.get_handle() == 0 :
|
||||
return False
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ from gui.widgets.grampletpane import (AVAILABLE_GRAMPLETS,
|
||||
make_requested_gramplet,
|
||||
GuiGramplet)
|
||||
from gui.widgets.undoablebuffer import UndoableBuffer
|
||||
from gui.utils import add_menuitem
|
||||
import gui.utils
|
||||
from QuestionDialog import QuestionDialog
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@@ -415,7 +415,7 @@ class GrampsBar(gtk.Notebook):
|
||||
"""
|
||||
Called when a button is pressed in the tabs section of the GrampsBar.
|
||||
"""
|
||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
if gui.utils.is_right_click(event):
|
||||
menu = gtk.Menu()
|
||||
|
||||
ag_menu = gtk.MenuItem(_('Add a gramplet'))
|
||||
|
||||
@@ -32,7 +32,7 @@ Utility functions that depend on GUI components or for GUI components
|
||||
import os
|
||||
import sys
|
||||
from gen.ggettext import gettext as _
|
||||
from constfunc import has_display
|
||||
import constfunc
|
||||
# gtk is not included here, because this file is currently imported
|
||||
# by code that needs to run without the DISPLAY variable (eg, in
|
||||
# the cli only).
|
||||
@@ -144,7 +144,7 @@ class ProgressMeter(object):
|
||||
else:
|
||||
self.__cancel_callback = self.handle_cancel
|
||||
|
||||
if has_display():
|
||||
if constfunc.has_display():
|
||||
self.__dialog = gtk.Dialog()
|
||||
else:
|
||||
self.__dialog = CLIDialog()
|
||||
@@ -363,3 +363,23 @@ def process_pending_events(max_count=10):
|
||||
count += 1
|
||||
if count >= max_count:
|
||||
break
|
||||
|
||||
# Then there's the infamous Mac one-button mouse (or more likely these
|
||||
# days, one-button trackpad). The canonical mac way to generate what
|
||||
# Gdk calls a button-3 is <ctrl> button-1, but that's not baked into
|
||||
# Gdk. We'll emulate the behavior here.
|
||||
|
||||
def is_right_click(event):
|
||||
"""
|
||||
Returns True if the event is a button-3 or equivalent
|
||||
"""
|
||||
import gtk
|
||||
|
||||
if event.type == gtk.gdk.BUTTON_PRESS:
|
||||
if constfunc.is_quartz():
|
||||
if (event.button == 3
|
||||
or (event.button == 1 and event.state & gtk.gdk.CONTROL_MASK)):
|
||||
return True
|
||||
|
||||
if event.button == 3:
|
||||
return True
|
||||
|
||||
@@ -64,6 +64,7 @@ from QuestionDialog import QuestionDialog, QuestionDialog2
|
||||
from gui.filtereditor import FilterEditor
|
||||
from gen.ggettext import sgettext as _
|
||||
from DdTargets import DdTargets
|
||||
import gui.utils
|
||||
|
||||
#----------------------------------------------------------------
|
||||
#
|
||||
@@ -757,7 +758,7 @@ class ListView(NavigationView):
|
||||
else:
|
||||
self.edit(obj)
|
||||
return True
|
||||
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
elif gui.utils.is_right_click(event):
|
||||
menu = self.uistate.uimanager.get_widget('/Popup')
|
||||
#construct quick reports if needed
|
||||
if menu and self.QR_CATEGORY > -1 :
|
||||
|
||||
@@ -46,7 +46,7 @@ import const
|
||||
from gui.editors import EditPerson, EditFamily
|
||||
import ManagedWindow
|
||||
import ConfigParser
|
||||
from gui.utils import add_menuitem
|
||||
import gui.utils
|
||||
from QuickReports import run_quick_report_by_name
|
||||
import GrampsDisplay
|
||||
from glade import Glade
|
||||
@@ -603,7 +603,7 @@ class GuiGramplet(object):
|
||||
elif event.type == gtk.gdk.BUTTON_PRESS: # single
|
||||
self.uistate.set_active(handle, 'Person')
|
||||
return True # handled event
|
||||
elif event.button == 3: # right mouse
|
||||
elif gui.utils.is_right_click(event):
|
||||
#FIXME: add a popup menu with options
|
||||
try:
|
||||
EditPerson(self.dbstate,
|
||||
@@ -664,7 +664,7 @@ class GuiGramplet(object):
|
||||
elif event.type == gtk.gdk.BUTTON_PRESS: # single
|
||||
self.uistate.set_active(handle, 'Family')
|
||||
return True # handle event
|
||||
elif event.button == 3: # right mouse
|
||||
elif gui.utils.is_right_click(event):
|
||||
#FIXME: add a popup menu with options
|
||||
try:
|
||||
EditFamily(self.dbstate,
|
||||
@@ -1373,7 +1373,7 @@ class GrampletPane(gtk.ScrolledWindow):
|
||||
print "Can't make gramplet of type '%s'." % name
|
||||
|
||||
def _button_press(self, obj, event):
|
||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||
if gui.utils.is_right_click(event):
|
||||
self._popup_xy = (event.x, event.y)
|
||||
uiman = self.uistate.uimanager
|
||||
ag_menu = uiman.get_widget('/GrampletPopup/AddGramplet')
|
||||
@@ -1384,7 +1384,8 @@ class GrampletPane(gtk.ScrolledWindow):
|
||||
if gplug.navtypes == []]
|
||||
names.sort()
|
||||
for name in names:
|
||||
add_menuitem(qr_menu, name, None, self.add_gramplet)
|
||||
gui.utils.add_menuitem(qr_menu, name, None,
|
||||
self.add_gramplet)
|
||||
ag_menu.set_submenu(qr_menu)
|
||||
rg_menu = uiman.get_widget('/GrampletPopup/RestoreGramplet')
|
||||
if rg_menu:
|
||||
@@ -1397,7 +1398,8 @@ class GrampletPane(gtk.ScrolledWindow):
|
||||
if len(names) > 0:
|
||||
qr_menu = gtk.Menu()
|
||||
for name in names:
|
||||
add_menuitem(qr_menu, name, None, self.restore_gramplet)
|
||||
gui.utils.add_menuitem(qr_menu, name, None,
|
||||
self.restore_gramplet)
|
||||
rg_menu.set_submenu(qr_menu)
|
||||
menu = uiman.get_widget('/GrampletPopup')
|
||||
if menu:
|
||||
|
||||
Reference in New Issue
Block a user