Merge pull request #541 from jralls/accels.

This commit is contained in:
John Ralls 2018-02-06 14:48:49 -08:00
commit 0445004e7d
5 changed files with 42 additions and 4 deletions

View File

@ -35,6 +35,7 @@ _LOG = logging.getLogger(".dialog")
#-------------------------------------------------------------------------
from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GdkPixbuf
#-------------------------------------------------------------------------
@ -46,6 +47,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.const import ICON, URL_BUGHOME
from gramps.gen.config import config
from gramps.gen.constfunc import is_quartz
from .glade import Glade
from .display import display_url
@ -506,6 +508,12 @@ def main(args):
win = Gtk.Window()
win.set_title('Dialog test window')
win.set_position(Gtk.WindowPosition.CENTER)
#Set the mnemonic modifier on Macs to alt-ctrl so that it
#doesn't interfere with the extended keyboard, see
#https://gramps-project.org/bugs/view.php?id=6943
if is_quartz():
win.set_mnemonic_modifier(
Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK)
def cb(window, event):
Gtk.main_quit()
win.connect('delete-event', cb)

View File

@ -46,6 +46,7 @@ from gi.repository import Gtk
#
#------------------------------------------------------------------------
from gramps.gen.const import GLADE_DIR, GRAMPS_LOCALE as glocale
from gramps.gen.constfunc import is_quartz
#------------------------------------------------------------------------
#
@ -142,11 +143,19 @@ class Glade(Gtk.Builder):
# toplevel is given
if toplevel:
loadlist = [toplevel] + also_load
self.add_objects_from_file(path, loadlist)
with open(path, 'r', encoding='utf-8') as builder_file:
data = builder_file.read().replace('\n', '')
if is_quartz():
data = data.replace('GDK_CONTROL_MASK', 'GDK_META_MASK')
self.add_objects_from_string(data, loadlist)
self.__toplevel = self.get_object(toplevel)
# toplevel not given
else:
self.add_from_file(path)
with open(path, 'r', encoding='utf-8') as builder_file:
data = builder_file.read().replace('\n', '')
if is_quartz():
data = data.replace('GDK_CONTROL_MASK', 'GDK_META_MASK')
self.add_from_string(data)
# first, use filename as possible toplevel widget name
self.__toplevel = self.get_object(filename.rpartition('.')[0])

View File

@ -38,6 +38,7 @@ from io import StringIO
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
from gi.repository import Gdk
#-------------------------------------------------------------------------
#
@ -47,6 +48,7 @@ from gi.repository import Gtk
from gramps.gen.const import GLADE_FILE, ICON
from gramps.gen.errors import WindowActiveError
from gramps.gen.config import config
from gramps.gen.constfunc import is_quartz
from .glade import Glade
#-------------------------------------------------------------------------
@ -488,6 +490,13 @@ class ManagedWindow:
#closing the Gtk.Window must also close ManagedWindow
self.window = window
self.window.connect('delete-event', self.close)
#Set the mnemonic modifier on Macs to alt-ctrl so that it
#doesn't interfere with the extended keyboard, see
#https://gramps-project.org/bugs/view.php?id=6943
if is_quartz():
self.window.set_mnemonic_modifier(
Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK)
if self.modal:
self.window.set_modal(True)
# The following makes sure that we only have one modal window open;

View File

@ -55,6 +55,7 @@ LOG = logging.getLogger(".")
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
from gi.repository import Gdk
#-------------------------------------------------------------------------
#
@ -394,7 +395,12 @@ class ViewManager(CLIManager):
self.window.set_icon_from_file(ICON)
self.window.set_default_size(width, height)
self.window.move(horiz_position, vert_position)
#Set the mnemonic modifier on Macs to alt-ctrl so that it
#doesn't interfere with the extended keyboard, see
#https://gramps-project.org/bugs/view.php?id=6943
if is_quartz():
self.window.set_mnemonic_modifier(
Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.window.add(vbox)
hpane = Gtk.Paned()

View File

@ -52,7 +52,7 @@ from gi.repository import Pango
#-------------------------------------------------------------------------
from gramps.gen.errors import MaskError, ValidationError, WindowActiveError
from .undoableentry import UndoableEntry
from gramps.gen.constfunc import is_quartz
#============================================================================
#
# MaskedEntry and ValidatableMaskedEntry copied and merged from the Kiwi
@ -1248,6 +1248,12 @@ def main(args):
win = Gtk.Window()
win.set_title('ValidatableMaskedEntry test window')
win.set_position(Gtk.WindowPosition.CENTER)
#Set the mnemonic modifier on Macs to alt-ctrl so that it
#doesn't interfere with the extended keyboard, see
#https://gramps-project.org/bugs/view.php?id=6943
if is_quartz():
win.set_mnemonic_modifier(
Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK)
def cb(window, event):
Gtk.main_quit()
win.connect('delete-event', cb)