예제 #1
0
    def photo_drag_end(self, widget, drag_context, x, y, data, info, time, on_map):
        """Respond to drops and position photos accordingly.
        
        This method allows photos to be dropped in from the photo
        pane or any other drag source, such as the file browser.
        """
        if not data.get_text():
            return

        lat, lon = MapView.y_to_latitude(y), MapView.x_to_longitude(x)

        files = [unquote(urlparse(s).path.strip()) for s in data.get_text().split("\n") if s]

        if self.external_drag:
            self.open_files(files)
        self.external_drag = True

        if on_map:
            for filename in files:
                photo = Photograph.cache.get(filename)
                if photo is not None:
                    photo.manual = True
                    photo.set_location(lat, lon)

        self.selection.emit("changed")
예제 #2
0
def move_by_arrow_keys(accel_group, acceleratable, keyval, modifier):
    """Move the map view by 5% of its length in the given direction."""
    key = Gdk.keyval_name(keyval)
    factor = 0.45 if key in ('Up', 'Left') else 0.55
    if key in ('Up', 'Down'):
        lat = MapView.y_to_latitude(MapView.get_height() * factor)
        lon = MapView.get_center_longitude()
    else:
        lat = MapView.get_center_latitude()
        lon = MapView.x_to_longitude(MapView.get_width() * factor)
    if valid_coords(lat, lon):
        MapView.center_on(lat, lon)