diff --git a/gramps/gen/config.py b/gramps/gen/config.py index 80d5faf77..a1cd70d70 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', "http://gramps-project.org") register('htmlview.url-handler', False) diff --git a/gramps/plugins/lib/maps/geography.py b/gramps/plugins/lib/maps/geography.py index 318dade92..4d0b1b2b6 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): """ @@ -1076,4 +1079,11 @@ class GeoGraphyView(OsmGps, NavigationView): _('The maximum number of places to show'), 4, 'geography.max_places', (1000, 10000)) + configdialog.add_checkbox(table, + _('Use keypad for shortcuts :\n' + 'Either we choose the + and - from the keypad if we select this,\n' + 'or we use the characters from the keyboard.'), + 5, 'geography.use-keypad', + extra_callback=self.update_shortcuts) + return _('The map'), table diff --git a/gramps/plugins/lib/maps/osmgps.py b/gramps/plugins/lib/maps/osmgps.py index 7a250f1ed..e8805682c 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 41ec3cdc0..a259d9110 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 87628852a..296551c91 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 23a6e5639..7b529c037 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 d87a1d14b..5cb4e4299 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 5311953a2..79f4dc78e 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,