示例#1
0
 def edit(self, obj):
     for handle in self.selected_handles():
         place = self.dbstate.db.get_place_from_handle(handle)
         try:
             EditPlace(self.dbstate, self.uistate, [], place)
         except WindowActiveError:
             pass
 def __add_place(self, parent, plat, plon):
     """
     Add a new place using longitude and latitude of location centered
     on the map
     """
     self.select_fct.close()
     new_place = Place()
     new_place.set_latitude(str(plat))
     new_place.set_longitude(str(plon))
     if parent:
         if isinstance(parent, Place):
             placeref = PlaceRef()
             placeref.ref = parent
             new_place.add_placeref(placeref)
         else:
             found = None
             for place in self.dbstate.db.iter_places():
                 found = place
                 if place.name.get_value() == parent:
                     break
             placeref = PlaceRef()
             placeref.ref = found.get_handle()
             new_place.add_placeref(placeref)
     try:
         EditPlace(self.dbstate, self.uistate, [], new_place)
         self.add_marker(None, None, plat, plon, None, True, 0)
     except WindowActiveError:
         pass
示例#3
0
文件: locations.py 项目: wmbr/gramps
 def edit_place(self, treeview):
     """
     Edit the selected place.
     """
     model, iter_ = treeview.get_selection().get_selected()
     if iter_:
         handle = model.get_value(iter_, 0)
         place = self.dbstate.db.get_place_from_handle(handle)
         try:
             EditPlace(self.dbstate, self.uistate, [], place)
         except WindowActiveError:
             pass
示例#4
0
 def __edit_place(self, parent, plat, plon):
     """
     Edit the selected place at the marker position
     """
     self.select_fct.close()
     place = self.dbstate.db.get_place_from_gramps_id(self.mark[9])
     place.set_latitude(str(plat))
     place.set_longitude(str(plon))
     try:
         EditPlace(self.dbstate, self.uistate, [], place)
     except WindowActiveError:
         pass
示例#5
0
    def add_place_from_kml(self, menu, event, lat, lon):
        """
        Add new place(s) from a kml file

        1 - ask for a kml file ?
        2 - Read the kml file.
        3 - create the place(s) with name and title found in the kml marker.

        """
        dummy_menu = menu
        dummy_event = event
        dummy_lat = lat
        dummy_lon = lon
        # Ask for the kml file
        filtering = Gtk.FileFilter()
        filtering.add_pattern("*.kml")
        kml = Gtk.FileChooserDialog(_("Select a kml file used to add places"),
                                    action=Gtk.FileChooserAction.OPEN,
                                    parent=self.uistate.window,
                                    buttons=(_('_Cancel'),
                                             Gtk.ResponseType.CANCEL,
                                             _('_Apply'), Gtk.ResponseType.OK))
        mpath = HOME_DIR
        kml.set_current_folder(os.path.dirname(mpath))
        kml.set_filter(filtering)

        status = kml.run()
        if status == Gtk.ResponseType.OK:
            val = kml.get_filename()
            if val:
                kmlfile = Kml(val)
                points = kmlfile.add_points()
                for place in points:
                    (name, coords) = place
                    latlong = coords.pop()
                    (lat, lon) = latlong
                    place_name = PlaceName()
                    place_name.set_value(name)
                    new_place = Place()
                    new_place.set_name(place_name)
                    new_place.set_title(name)
                    new_place.set_latitude(str(lat))
                    new_place.set_longitude(str(lon))
                    try:
                        EditPlace(self.dbstate, self.uistate, [], new_place)
                    except WindowActiveError:
                        pass
        kml.destroy()
示例#6
0
 def rowactivated_cb2(self, treeview, path, column):
     """
     Called when a Place row is activated.
     """
     dummy_tv = treeview
     dummy_col = column
     iter_ = self.model_2.get_iter(path)
     handle = self.model_2.get_value(iter_, 0)
     place = self.dbstate.db.get_place_from_handle(handle)
     if place:
         try:
             EditPlace(self.dbstate, self.uistate, [], place)
         except WindowActiveError:
             pass
         return True
     return False
示例#7
0
 def edit_place(self, menuitem, treeview):
     """
     Edit the place related to the selected event.
     """
     model, iter_ = treeview.get_selection().get_selected()
     if iter_:
         handle = model.get_value(iter_, 0)
         try:
             event = self.dbstate.db.get_event_from_handle(handle)
             place_handle = event.get_place_handle()
             place_id = latitude = longitude = ""
             if place_handle:
                 plc = self.dbstate.db.get_place_from_handle(place_handle)
                 EditPlace(self.dbstate, self.uistate, [], plc)
         except WindowActiveError:
             pass
示例#8
0
 def __add_place(self, parent, plat, plon):
     """
     Add a new place using longitude and latitude of location centered
     on the map
     """
     self.select_fct.close()
     new_place = Place()
     new_place.set_latitude(str(plat))
     new_place.set_longitude(str(plon))
     if parent:
         if isinstance(parent, Place):
             placeref = PlaceRef()
             placeref.ref = parent
             new_place.add_placeref(placeref)
         elif isinstance(parent, gi.overrides.Gtk.TreeModelRow):
             # We are here because we selected a place from geocoding
             # parent[0] : country
             # parent[1] : state
             # parent[2] : town
             # parent[3] : name
             value = PlaceSelection.untag_text(parent[2], 1)
             plname = PlaceName()
             plname.set_value(value)
             handle = self.place_exists(value)
             if handle:
                 # The town already exists. We create a place with name
                 placeref = PlaceRef()
                 placeref.ref = handle
                 new_place.add_placeref(placeref)
                 value = PlaceSelection.untag_text(parent[3], 1)
                 plname.set_value(value)
             new_place.set_name(plname)
         else:
             found = None
             for place in self.dbstate.db.iter_places():
                 found = place
                 if place.name.get_value() == parent:
                     break
             placeref = PlaceRef()
             placeref.ref = found.get_handle()
             new_place.add_placeref(placeref)
     try:
         EditPlace(self.dbstate, self.uistate, [], new_place)
         self.add_marker(None, None, plat, plon, None, True, 0)
     except WindowActiveError:
         pass
示例#9
0
 def __add_place(self, parent, plat, plon):
     """
     Add a new place using longitude and latitude of location centered
     on the map
     """
     self.select_fct.close()
     new_place = Place()
     new_place.set_latitude(str(plat))
     new_place.set_longitude(str(plon))
     if parent:
         placeref = PlaceRef()
         placeref.ref = parent
         new_place.add_placeref(placeref)
     try:
         EditPlace(self.dbstate, self.uistate, [], new_place)
         self.add_marker(None, None, plat, plon, None, True, 0)
     except WindowActiveError:
         pass
示例#10
0
    def add(self, obj):
        """
        Add a new place.  Use the currently selected rows as parent places.
        """
        parent_list = []
        for handle in self.selected_handles():
            placeref = PlaceRef()
            placeref.ref = handle
            parent_list.append(placeref)

        place = Place()
        if len(parent_list) > 0:
            place.placeref_list = parent_list

        try:
            EditPlace(self.dbstate, self.uistate, [], place)
        except WindowActiveError:
            pass
示例#11
0
 def __link_place(self, parent, plat, plon):
     """
     Link an existing place using longitude and latitude of location centered
     on the map
     """
     selector = SelectPlace(self.dbstate, self.uistate, [])
     place = selector.run()
     if place:
         self.select_fct.close()
         place.set_latitude(str(plat))
         place.set_longitude(str(plon))
         if parent:
             placeref = PlaceRef()
             placeref.ref = parent
             place.add_placeref(placeref)
         try:
             EditPlace(self.dbstate, self.uistate, [], place)
             self.add_marker(None, None, plat, plon, None, True, 0)
         except WindowActiveError:
             pass
示例#12
0
 def add(self, obj):
     try:
         EditPlace(self.dbstate, self.uistate, [], Place())
     except WindowActiveError:
         pass