diff --git a/gramps/gen/config.py b/gramps/gen/config.py index 112aeb972..065d6b527 100644 --- a/gramps/gen/config.py +++ b/gramps/gen/config.py @@ -169,6 +169,7 @@ register('geography.zoom', 0) register('geography.zoom_when_center', 12) register('geography.show_cross', False) register('geography.path', "") +register('geography.use-keypad', True) register('htmlview.start-url', URL_HOMEPAGE) register('htmlview.url-handler', False) diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py index 028690b9b..3e7eaa6a7 100644 --- a/gramps/plugins/lib/maps/geography.py +++ b/gramps/plugins/lib/maps/geography.py @@ -123,6 +123,7 @@ class GeoGraphyView(OsmGps, NavigationView): ('geography.map_service', constants.OPENSTREETMAP), ('geography.max_places', 5000), + ('geography.use-keypad', True), ) def __init__(self, title, pdata, dbstate, uistate, @@ -198,6 +199,7 @@ class GeoGraphyView(OsmGps, NavigationView): NavigationView.change_page(self) self.uistate.clear_filter_results() self.end_selection = None + self.osm.grab_focus() def do_size_request(self, requisition): """ @@ -240,6 +242,7 @@ class GeoGraphyView(OsmGps, NavigationView): if self.active: self.bookmarks.redraw() self.build_tree() + self.osm.grab_focus() def can_configure(self): """ diff --git a/gramps/plugins/lib/maps/osmgps.py b/gramps/plugins/lib/maps/osmgps.py index 4e2de9a21..0f5c6706f 100644 --- a/gramps/plugins/lib/maps/osmgps.py +++ b/gramps/plugins/lib/maps/osmgps.py @@ -163,10 +163,35 @@ class OsmGps(): self.osm.connect('button_press_event', self.map_clicked) self.osm.connect("motion-notify-event", self.motion_event) self.osm.connect('changed', self.zoom_changed) + self.update_shortcuts(True) self.osm.show() self.vbox.pack_start(self.osm, True, True, 0) self.goto_handle(handle=None) + def update_shortcuts(self, arg): + """ + connect the keyboard or the keypad for shortcuts + arg is mandatory because this function is also called by the checkbox button + """ + config.set('geography.use-keypad', + self._config.get('geography.use-keypad')) + if config.get('geography.use-keypad'): + print "use keypad", config.get('geography.use-keypad') + self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMIN, Gdk.keyval_from_name("KP_Add")) + self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMOUT, Gdk.keyval_from_name("KP_Subtract")) + else: + print "use keyboard", config.get('geography.use-keypad') + self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMIN, Gdk.keyval_from_name("plus")) + self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.ZOOMOUT, Gdk.keyval_from_name("minus")) + + self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.UP, Gdk.keyval_from_name("Up")) + self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.DOWN, Gdk.keyval_from_name("Down")) + self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.LEFT, Gdk.keyval_from_name("Left")) + self.osm.set_keyboard_shortcut(osmgpsmap.MapKey_t.RIGHT, Gdk.keyval_from_name("Right")) + + # For shortcuts work, we must grab the focus + self.osm.grab_focus() + def add_selection_layer(self): """ add the selection layer @@ -309,6 +334,7 @@ class OsmGps(): mouse button 2 : begin zone selection mouse button 3 : call the menu """ + self.osm.grab_focus() lat, lon = self.osm.get_event_location(event).get_degrees() current = osm.convert_screen_to_geographic(int(event.x), int(event.y)) lat, lon = current.get_degrees() diff --git a/gramps/plugins/view/geoclose.py b/gramps/plugins/view/geoclose.py index bc7800330..30d801ba7 100644 --- a/gramps/plugins/view/geoclose.py +++ b/gramps/plugins/view/geoclose.py @@ -123,6 +123,7 @@ class GeoClose(GeoGraphyView): ('geography.lock', False), ('geography.center-lat', 0.0), ('geography.center-lon', 0.0), + ('geography.use-keypad', True), ('geography.map_service', constants.OPENSTREETMAP), ('geography.max_places', 5000), diff --git a/gramps/plugins/view/geofamclose.py b/gramps/plugins/view/geofamclose.py index e182bb7ca..c22356981 100644 --- a/gramps/plugins/view/geofamclose.py +++ b/gramps/plugins/view/geofamclose.py @@ -121,6 +121,7 @@ class GeoFamClose(GeoGraphyView): ('geography.lock', False), ('geography.center-lat', 0.0), ('geography.center-lon', 0.0), + ('geography.use-keypad', True), ('geography.map_service', constants.OPENSTREETMAP), ('geography.max_places', 5000), diff --git a/gramps/plugins/view/geomoves.py b/gramps/plugins/view/geomoves.py index 995e11b19..74e826d09 100644 --- a/gramps/plugins/view/geomoves.py +++ b/gramps/plugins/view/geomoves.py @@ -125,6 +125,7 @@ class GeoMoves(GeoGraphyView): ('geography.lock', True), ('geography.center-lat', 0.0), ('geography.center-lon', 0.0), + ('geography.use-keypad', True), ('geography.map_service', constants.OPENSTREETMAP), ('geography.max_places', 5000), diff --git a/gramps/plugins/view/geoperson.py b/gramps/plugins/view/geoperson.py index ae53a5243..1e7bcc58f 100644 --- a/gramps/plugins/view/geoperson.py +++ b/gramps/plugins/view/geoperson.py @@ -129,6 +129,7 @@ class GeoPerson(GeoGraphyView): ('geography.lock', False), ('geography.center-lat', 0.0), ('geography.center-lon', 0.0), + ('geography.use-keypad', True), #('geography.gps_mode', GPS_DISABLED), #('geography.gps_update_rate', float(1.0)), diff --git a/gramps/webapp/empty.sql b/gramps/webapp/empty.sql index 38cd3874a..a0702463c 100644 --- a/gramps/webapp/empty.sql +++ b/gramps/webapp/empty.sql @@ -863,6 +863,7 @@ INSERT INTO "grampsdb_config" VALUES(197,'geography.map_service',NULL,'int','1') INSERT INTO "grampsdb_config" VALUES(198,'geography.lock',NULL,'bool','False'); INSERT INTO "grampsdb_config" VALUES(199,'geography.path',NULL,'str',''); INSERT INTO "grampsdb_config" VALUES(200,'geography.center-lat',NULL,'float','0.0'); +INSERT INTO "grampsdb_config" VALUES(201,'geography.use-keypad',NULL,'bool','False'); CREATE TABLE "grampsdb_tag" ( "id" integer NOT NULL PRIMARY KEY, "handle" varchar(19) NOT NULL UNIQUE, diff --git a/gramps/webapp/example.sql b/gramps/webapp/example.sql index 624b24baf..22ce1b54b 100644 --- a/gramps/webapp/example.sql +++ b/gramps/webapp/example.sql @@ -840,6 +840,7 @@ INSERT INTO "grampsdb_config" VALUES(177,'geography.map_service',NULL,'int','1') INSERT INTO "grampsdb_config" VALUES(178,'geography.lock',NULL,'bool','False'); INSERT INTO "grampsdb_config" VALUES(179,'geography.path',NULL,'str',''); INSERT INTO "grampsdb_config" VALUES(180,'geography.center-lat',NULL,'float','0.0'); +INSERT INTO "grampsdb_config" VALUES(181,'geography.use-keypad',NULL,'bool','False'); CREATE TABLE "grampsdb_tag" ( "id" integer NOT NULL PRIMARY KEY, "handle" varchar(19) NOT NULL UNIQUE,