Exemplo n.º 1
0
    def __saveGPSConf(self):

        '''
        Saves the preferences from the GPS preferences panel.
        '''
        geocacher.config().gpsType = self.gpsType.GetValue()
        geocacher.config().gpsConnection = self.gpsConnection.GetValue()
Exemplo n.º 2
0
    def __buildGCPanel(self, parent):
        '''
        Builds the geocaching.com preferences panel.

        Argument
        parent: the parent window for this panel.
        '''
        panel = wx.Panel(parent, wx.ID_ANY)
        gcGrid = wx.GridBagSizer(5, 5)

        label = wx.StaticText(panel,
                              wx.ID_ANY,
                              _('User Name'),
                              size=(self.labelWidth, -1))
        gcGrid.Add(label, (0, 0))
        self.gcUserName = wx.TextCtrl(panel,
                                      wx.ID_ANY,
                                      geocacher.config().GCUserName,
                                      size=(self.entryWidth, -1))
        gcGrid.Add(self.gcUserName, (0, 1))

        label = wx.StaticText(panel, wx.ID_ANY, _('User ID'))
        gcGrid.Add(label, (1, 0))
        self.gcUserId = wx.TextCtrl(panel,
                                    wx.ID_ANY,
                                    geocacher.config().GCUserID,
                                    size=(self.entryWidth, -1))
        gcGrid.Add(self.gcUserId, (1, 1))

        panel.SetSizer(gcGrid)
        return panel
Exemplo n.º 3
0
 def cacheAddLog(found, self=self, cache=cache):
     if found:
         logType = 'Found It'
         logDate = cache.found_date
     else:
         logType = "Didn't find it"
         logDate = cache.dnf_date
     dlg = FoundCache(self, cache.code, logType,
                      logDate, cache.own_log,
                      cache.own_log_encoded)
     if dlg.ShowModal() == wx.ID_OK:
         Publisher.sendMessage('status.push',
                               _('Marking cache %s as "%s"') % (cache.code, logType))
         newLog = cache.addLog(None,
                               date        = wxDateTimeToPy(dlg.date.GetValue()),
                               logType     = logType,
                               finder_id   = geocacher.config().GCUserID,
                               finder_name = geocacher.config().GCUserName,
                               encoded     = dlg.encodeLog.GetValue(),
                               text        = dlg.logText.GetValue())
         if found:
             cache.found = True
             cache.found_date = newLog.date
         else:
             cache.dnf = True
             cache.dnf_date = newLog.date
         cache.own_log_id = newLog.logId
         cache.user_date = datetime.now()
         cache.save()
         geocacher.db().commit()
         cache.refreshOwnLog()
         self._table.ReloadRow(row)
         self.Reset()
         Publisher.sendMessage('status.pop')
     dlg.Destroy()
Exemplo n.º 4
0
    def __buildGPSPanel(self,parent):
        '''
        Builds the GPS preferences panel.

        Argument
        parent: the parent window for this panel.
        '''
        panel = wx.Panel(parent, wx.ID_ANY)
        gpsGrid = wx.GridBagSizer(5, 5)

        label = wx.StaticText(panel,wx.ID_ANY,_('Type'),
            size = (self.labelWidth,-1))
        gpsGrid.Add(label, (0,0))
        self.gpsType = wx.ComboBox(panel, wx.ID_ANY,
            value=geocacher.config().gpsType,
            choices=['garmin'],
            style=wx.CB_SORT|wx.CB_READONLY,
            size = (self.entryWidth,-1))
        gpsGrid.Add(self.gpsType, (0,1))

        label = wx.StaticText(panel,wx.ID_ANY,_('Port'))
        gpsGrid.Add(label, (1,0))
        self.gpsConnection = wx.ComboBox(panel, wx.ID_ANY,
            value=geocacher.config().gpsConnection,
            choices=['usb:'],
            style=wx.CB_SORT,
            size = (self.entryWidth,-1))
        gpsGrid.Add(self.gpsConnection, (1,1))

        panel.SetSizer(gpsGrid)
        return panel
Exemplo n.º 5
0
    def __buildGCPanel(self, parent):
        '''
        Builds the geocaching.com preferences panel.

        Argument
        parent: the parent window for this panel.
        '''
        panel = wx.Panel(parent, wx.ID_ANY)
        gcGrid = wx.GridBagSizer(5, 5)

        label = wx.StaticText(panel,wx.ID_ANY,_('User Name'),
            size = (self.labelWidth,-1))
        gcGrid.Add(label, (0,0))
        self.gcUserName = wx.TextCtrl(panel,
            wx.ID_ANY,geocacher.config().GCUserName,
            size = (self.entryWidth,-1))
        gcGrid.Add(self.gcUserName, (0,1))

        label = wx.StaticText(panel,wx.ID_ANY,_('User ID'))
        gcGrid.Add(label, (1,0))
        self.gcUserId = wx.TextCtrl(panel,wx.ID_ANY,
            geocacher.config().GCUserID,
            size = (self.entryWidth,-1))
        gcGrid.Add(self.gcUserId, (1,1))

        panel.SetSizer(gcGrid)
        return panel
Exemplo n.º 6
0
 def OnGpsUpload(self, event=None):
     '''
     Uploads caches to GPS
     '''
     self.pushStatus(_('Uploading caches to GPS'))
     opts = ExportOptions(self, True)
     if opts.ShowModal() == wx.ID_OK:
         opts.SaveConf()
         caches = self.selectCaches(True)
         if len(caches) == 0:
             wx.MessageBox(
                 parent=self,
                 message=_(
                     'With the current settings there is nothing to export!'
                 ),
                 caption=_('Nothing to export'),
                 style=wx.OK | wx.ICON_ERROR)
         else:
             fd, tmpFile = tempfile.mkstemp()
             gpx = Gpx()
             if gpx.export(
                     tmpFile,
                     caches,
             ):
                 gpsCom = GpsCom(gps=geocacher.config().gpsType,
                                 port=geocacher.config().gpsConnection)
                 ok, message = gpsCom.gpxToGps(tmpFile)
                 if not ok:
                     self.GpsError(message)
             os.remove(tmpFile)
     self.popStatus()
Exemplo n.º 7
0
 def OnGpsUpload(self, event=None):
     """
     Uploads caches to GPS
     """
     self.pushStatus(_("Uploading caches to GPS"))
     opts = ExportOptions(self, True)
     if opts.ShowModal() == wx.ID_OK:
         opts.SaveConf()
         caches = self.selectCaches(True)
         if len(caches) == 0:
             wx.MessageBox(
                 parent=self,
                 message=_("With the current settings there is nothing to export!"),
                 caption=_("Nothing to export"),
                 style=wx.OK | wx.ICON_ERROR,
             )
         else:
             fd, tmpFile = tempfile.mkstemp()
             gpx = Gpx()
             if gpx.export(tmpFile, caches):
                 gpsCom = GpsCom(gps=geocacher.config().gpsType, port=geocacher.config().gpsConnection)
                 ok, message = gpsCom.gpxToGps(tmpFile)
                 if not ok:
                     self.GpsError(message)
             os.remove(tmpFile)
     self.popStatus()
Exemplo n.º 8
0
    def OnLoadWpt(self, event=None):
        """
        Handles the event from the "Load Waypoint" menu item.

        Keyword Argument
        event: The event causing this function to be called.
        """
        self.pushStatus(_("Loading caches from file"))
        wildcard = "GPX File (*.gpx)|*.gpx|" "Compressed GPX File (*.zip)|*.zip|" "All files (*.*)|*.*"

        if os.path.isdir(geocacher.config().importFolder):
            directory = geocacher.config().importFolder
        else:
            directory = wx.StandardPaths.GetDocumentsDir(wx.StandardPaths.Get())

        dlg = wx.FileDialog(
            self,
            message=_("Choose a file to load"),
            defaultDir=directory,
            defaultFile="",
            wildcard=wildcard,
            style=wx.OPEN | wx.MULTIPLE,
        )
        if os.path.isfile(geocacher.config().importFile):
            dlg.SetPath(geocacher.config().importFile)
            ext = os.path.splitext(geocacher.config().importFile)[1]
            if ext != "":
                if ext == ".gpx":
                    dlg.SetFilterIndex(0)
                elif ext == ".zip":
                    dlg.SetFilterIndex(2)

        if dlg.ShowModal() == wx.ID_OK:
            geocacher.config().importFolder = dlg.GetDirectory()
            paths = dlg.GetPaths()
            geocacher.config().importFile = paths[0]
            options = [_("Update"), _("Replace")]
            dlg = wx.SingleChoiceDialog(
                self, _("Load option"), _("Type of file load"), choices=options, style=wx.CHOICEDLG_STYLE
            )
            if geocacher.config().importMode == "replace":
                dlg.SetSelection(1)
            else:
                dlg.SetSelection(0)
            if dlg.ShowModal() == wx.ID_OK:
                if dlg.GetSelection() == 0:
                    geocacher.config().importMode = "update"
                else:
                    geocacher.config().importMode = "replace"

                changes = {}
                for path in paths:
                    self.pushStatus(_("Loading caches from file: %s") % path)
                    changes[path] = self.LoadFile(path)
                    self.popStatus()
                self.displayImportedChanges(changes)
                self.cacheGrid.ReloadCaches()
            dlg.Destroy()
            self.popStatus()
Exemplo n.º 9
0
 def UpdateUserDataLabels(self):
     '''
     Updates the user data column labels from the program configuration.
     '''
     self.colLabels['user_data1'] = geocacher.config().userData1Label
     self.colLabels['user_data2'] = geocacher.config().userData1Label
     self.colLabels['user_data3'] = geocacher.config().userData1Label
     self.colLabels['user_data4'] = geocacher.config().userData1Label
Exemplo n.º 10
0
 def UpdateUserDataLabels(self):
     '''
     Updates the user data column labels from the program configuration.
     '''
     self.colLabels['user_data1'] = geocacher.config().userData1Label
     self.colLabels['user_data2'] = geocacher.config().userData1Label
     self.colLabels['user_data3'] = geocacher.config().userData1Label
     self.colLabels['user_data4'] = geocacher.config().userData1Label
Exemplo n.º 11
0
 def milestones(self, jump=100):
     cur = geocacher.db().cursor()
     cur.execute(
         "SELECT code, found_date FROM Caches WHERE found = 1 ORDER BY found_date, own_log_id"
     )
     rows = cur.fetchall()
     dateFormat = geocacher.config().dateFormat
     html = self.titleWide('Milestones')
     html += "<table width='750' style='text-align: left;'>\n"
     html += "<tr>\n"
     html += self.hrCell('Milestone')
     html += self.hrCell('Date')
     html += self.hrCell('Interval')
     html += self.hrCell('&nbsp;')
     html += self.hrCell('Code')
     html += self.hrCell('&nbsp;')
     html += self.hrCell('Cache Name')
     html += "</tr>\n"
     if jump > 1:
         row, prevDate = self.mileStoneRow(rows[0][0], 1)
         html += row
     else:
         prevDate = None
     index = jump
     numFound = len(rows)
     while index < numFound:
         row, prevDate = self.mileStoneRow(rows[index - 1][0], index,
                                           prevDate)
         html += row
         index += jump
     row, prevDate = self.mileStoneRow(rows[numFound - 1][0], numFound,
                                       prevDate)
     html += row
     html += "</table>\n"
     firstDay = rows[0][1].date()
     lastDay = rows[numFound - 1][1].date()
     elapsedDays = (lastDay - firstDay).days + 1
     elapsedRate = float(numFound) / float(elapsedDays)
     cur.execute(
         "SELECT COUNT(*) FROM (SELECT DISTINCT DATE(found_date) FROM Caches WHERE found = 1)"
     )
     cacheDays = cur.fetchone()[0]
     cacheRate = float(numFound) / float(cacheDays)
     elapsedNext = roundUp((index - numFound) / elapsedRate)
     cacheNext = roundUp((index - numFound) / cacheRate)
     nextDate = lastDay + datetime.timedelta(days=elapsedNext)
     html += "<i><br />%s should reach <b>%i</b> finds in <b>%i</b> days (<b>%i</b> Caching days) on <b>%s</b> </i><br />\n" % (
         self.userName, index, elapsedNext, cacheNext,
         nextDate.strftime(geocacher.config().dateFormat))
     index += jump
     elapsedNext = roundUp((index - numFound) / elapsedRate)
     cacheNext = roundUp((index - numFound) / cacheRate)
     nextDate = lastDay + datetime.timedelta(days=elapsedNext)
     html += "and <b>%i</b> finds in <b>%i</b> days (<b>%i</b> Caching days) on <b>%s</b> </i><br />\n" % (
         index, elapsedNext, cacheNext,
         nextDate.strftime(geocacher.config().dateFormat))
     html += """<br /><br />\n"""
     return html
Exemplo n.º 12
0
    def buildToolBar(self):
        """
        Builds the toolbar for the main window.
        """
        TBFLAGS = wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT

        tb = self.CreateToolBar(TBFLAGS)
        self.tb = tb

        self.tbFilterName = wx.StaticText(tb, wx.ID_ANY, _("Fiter:"), style=wx.TEXT_ATTR_FONT_ITALIC)
        tb.AddControl(self.tbFilterName)

        self.cbHideMine = wx.CheckBox(tb, wx.ID_ANY, _("Hide Mine"))
        tb.AddControl(self.cbHideMine)
        self.Bind(wx.EVT_CHECKBOX, self.OnCbHideMine, self.cbHideMine)
        self.cbHideMine.SetValue(geocacher.config().filterMine)

        self.cbHideFound = wx.CheckBox(tb, wx.ID_ANY, _("Hide Found"))
        tb.AddControl(self.cbHideFound)
        self.Bind(wx.EVT_CHECKBOX, self.OnCbHideFound, self.cbHideFound)
        self.cbHideFound.SetValue(geocacher.config().filterFound)

        self.cbHideDisabled = wx.CheckBox(tb, wx.ID_ANY, _("Hide Disabled"))
        tb.AddControl(self.cbHideDisabled)
        self.Bind(wx.EVT_CHECKBOX, self.OnCbHideDisabled, self.cbHideDisabled)
        self.cbHideDisabled.SetValue(geocacher.config().filterDisabled)

        self.cbHideArchived = wx.CheckBox(tb, wx.ID_ANY, _("Hide Archived"))
        tb.AddControl(self.cbHideArchived)
        self.Bind(wx.EVT_CHECKBOX, self.OnCbHideArchived, self.cbHideArchived)
        self.cbHideArchived.SetValue(geocacher.config().filterArchived)

        self.cbHideOverDist = wx.CheckBox(tb, wx.ID_ANY, _("Hide Over"))
        tb.AddControl(self.cbHideOverDist)
        self.Bind(wx.EVT_CHECKBOX, self.OnCbHideOverDist, self.cbHideOverDist)
        self.cbHideOverDist.SetValue(geocacher.config().filterOverDist)

        self.tbMaxDistance = wx.TextCtrl(tb, wx.ID_ANY, value=str(geocacher.config().filterMaxDist), size=[100, -1])
        tb.AddControl(self.tbMaxDistance)
        self.tbMaxDistance.Bind(wx.EVT_LEFT_DCLICK, self.OnMaxDistVal)

        tb.AddSeparator()

        tb.AddControl(wx.StaticText(tb, wx.ID_ANY, _("Home location"), style=wx.TEXT_ATTR_FONT_ITALIC))
        choices = geocacher.db().getLocationNameList()
        if geocacher.config().currentLocation in choices:
            current = geocacher.config().currentLocation
        else:
            current = choices[0]
            geocacher.config().currentLocation = current
        self.selLocation = wx.ComboBox(
            tb, wx.ID_ANY, current, choices=choices, size=[150, -1], style=wx.CB_DROPDOWN | wx.CB_SORT
        )
        tb.AddControl(self.selLocation)
        self.Bind(wx.EVT_COMBOBOX, self.OnSelLocation, self.selLocation)
        tb.Realize()

        self.ShowHideFilterBar(geocacher.config().showFilter)
Exemplo n.º 13
0
 def open(self, dbfile=None, debugging=False):
     if dbfile is None: dbfile = geocacher.config().dbfile
     self.close()
     if debugging:
         self.prepdb(":memory:", True)
     else:
         geocacher.config().dbfile = dbfile
         if not os.path.isdir(geocacher.config().dbpath):
             os.makedirs(geocacher.config().dbpath)
         self.prepdb(geocacher.config().dbfile, True)
Exemplo n.º 14
0
 def open(self, dbfile=None, debugging=False):
     if dbfile is None: dbfile = geocacher.config().dbfile
     self.close()
     if debugging:
         self.prepdb(":memory:", True)
     else:
         geocacher.config().dbfile = dbfile
         if not os.path.isdir(geocacher.config().dbpath):
             os.makedirs(geocacher.config().dbpath)
         self.prepdb(geocacher.config().dbfile, True)
Exemplo n.º 15
0
    def __init__(self,parent,cache):
        '''
        Initialises the additional waypoints dialog.

        Arguments
        parent: The parent window for the dialog.
        cache:  The cache object to display the additional waypoints from.
        '''

        wx.Dialog.__init__(self,parent,wx.ID_ANY,_("Additional Waypoints for ")+cache.code,size = (490,500),
                           style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)

        # Create a scrolled panel and a vertical sizer within it to take the logs
        sw = Scrolled.ScrolledPanel(self, -1, size=(480, 450),
                                 style = wx.TAB_TRAVERSAL)
        wptSizer = wx.BoxSizer(orient=wx.VERTICAL)

        res = Xrc.XmlResource(os.path.join(geocacher.getBasePath(), 'xrc', 'addWaypointsPanel.xrc'))

        # Create a block for each log and add it to the logs sizer
        for wpt in cache.getAddWaypoints():
            wptPanel = res.LoadPanel(sw, 'addWaypointPanel')
            code = Xrc.XRCCTRL(wptPanel, 'codeText')
            wptType = Xrc.XRCCTRL(wptPanel, 'typeText')
            lat = Xrc.XRCCTRL(wptPanel, 'latText')
            lon = Xrc.XRCCTRL(wptPanel, 'lonText')
            name = Xrc.XRCCTRL(wptPanel, 'nameText')
            comment = Xrc.XRCCTRL(wptPanel, 'commentText')

            code.SetValue(wpt.code)
            wptType.SetValue(wpt.sym)
            lat.SetValue(latToStr(wpt.lat, geocacher.config().coordinateFormat))
            lon.SetValue(lonToStr(wpt.lon, geocacher.config().coordinateFormat))
            name.SetValue(wpt.name)
            comment.SetValue(wpt.cmt)
            wptSizer.Add(wptPanel)

        # Final Setup of the scrolled panel
        sw.SetSizer(wptSizer)
        sw.SetAutoLayout(1)
        sw.SetupScrolling()

        # Buttons
        closeButton = wx.Button(self,wx.ID_CLOSE)

        self.Bind(wx.EVT_BUTTON, self.OnClose,closeButton)

        buttonBox = wx.BoxSizer(orient=wx.HORIZONTAL)
        buttonBox.Add(closeButton, 0, wx.EXPAND)

        # finally, put the scrolledPannel and buttons in a sizer to manage the layout
        mainSizer = wx.BoxSizer(orient=wx.VERTICAL)
        mainSizer.Add(sw)
        mainSizer.Add(buttonBox, 0, wx.EXPAND)
        self.SetSizer(mainSizer)
Exemplo n.º 16
0
    def __init__(self, parent, id):
        '''
        Initialisation for the main frame.

        Arguments
        parent: The parent window of the frame.
        id:     The ID to give the frame.
        '''
        self.displayCache = None
        size = geocacher.config().mainWinSize
        # check that the Current location is in the db
        if geocacher.config().currentLocation not in geocacher.db(
        ).getLocationNameList():
            geocacher.config().currentLocation = geocacher.db(
            ).getLocationNameList()[0]
        wx.Frame.__init__(self,
                          parent,
                          wx.ID_ANY,
                          _("Geocacher"),
                          size=(size),
                          style=wx.DEFAULT_FRAME_STYLE
                          | wx.NO_FULL_REPAINT_ON_RESIZE)
        self.Bind(wx.EVT_CLOSE, self.OnQuit)
        self.SetIcon(
            wx.Icon(
                os.path.join(geocacher.getBasePath(), 'gfx',
                             'treasure_chest.ico'), wx.BITMAP_TYPE_ICO))
        self.buildStatusBar()

        self.buildMenu()

        self.buildToolBar()

        self.splitter = wx.SplitterWindow(self,
                                          wx.ID_ANY,
                                          style=wx.SP_LIVE_UPDATE
                                          | wx.SP_BORDER)
        self.cacheGrid = CacheGrid(self.splitter)
        self.Description = Html.HtmlWindow(self.splitter,
                                           wx.ID_ANY,
                                           name="Description Pannel")
        self.splitter.SetMinimumPaneSize(20)
        self.splitter.SplitHorizontally(self.cacheGrid, self.Description,
                                        geocacher.config().detailSplit)

        self.updateStatus()

        self.displayedCache = None
        self.updateDetail(geocacher.config().displayedCache)

        Publisher.subscribe(self.updateDetailMsg, 'cache.selected')
        Publisher.subscribe(self.NewLocationMsg, 'location.new')
        Publisher.subscribe(self.popStatusMsg, 'status.pop')
        Publisher.subscribe(self.pushStatusMsg, 'status.push')
        Publisher.subscribe(self.updateStatusMsg, 'status.update')
Exemplo n.º 17
0
    def __init__(self):
        '''
        Initialises the cacheStats object based on the given database and
        configuration objects.
        '''
        self.userName = geocacher.config().GCUserName
        self.userId = geocacher.config().GCUserID

        cur = geocacher.db().cursor()
        cur.execute('SELECT COUNT(id) From Caches WHERE found = 1')
        self.found = cur.fetchone()[0]
Exemplo n.º 18
0
    def __init__(self):
        '''
        Initialises the cacheStats object based on the given database and
        configuration objects.
        '''
        self.userName = geocacher.config().GCUserName
        self.userId = geocacher.config().GCUserID

        cur = geocacher.db().cursor()
        cur.execute('SELECT COUNT(id) From Caches WHERE found = 1')
        self.found =  cur.fetchone()[0]
Exemplo n.º 19
0
    def zipExport(self, filename, caches):
        '''
        Exports the given caches to the given zip file in the .gpx format.

        Arguments
        filename: Path to the file to export the cache information to
        caches:   List of cache objects to be exported
        '''
        assert os.path.isdir(os.path.split(filename)[0])

        config = geocacher.config()

        if len(caches) == 0:
            return True

        if os.path.isfile(filename):
            try:
                os.remove(filename)
            except:
                return False

        baseName = os.path.splitext(os.path.basename(filename))[0]
        try:
            tempDir = tempfile.mkdtemp()
            archive = zipfile.ZipFile(filename,
                                      mode='w',
                                      compression=zipfile.ZIP_DEFLATED)
        except:
            return False

        gpxFileName = os.path.join(tempDir, baseName + '.gpx')
        ret1 = self.export(gpxFileName, caches,
                           geocacher.config().exportSepAddWpts)
        archive.write(gpxFileName,
                      os.path.basename(gpxFileName).encode("utf_8"))

        if config.exportAddWpts and config.exportSepAddWpts:

            gpxAddFileName = os.path.join(tempDir, baseName + '-wpts.gpx')
            ret2, count = self.exportAddWpt(gpxAddFileName, caches)
            if count != 0:
                archive.write(gpxAddFileName,
                              os.path.basename(gpxAddFileName).encode("utf_8"))
        else:
            ret2 = True

        archive.close()

        shutil.rmtree(tempDir)
        return ret1 and ret2
Exemplo n.º 20
0
 def backup(self):
     self.close()
     dbpath = geocacher.config().dbpath
     today = datetime.date.today().isoformat()
     ext = "-%s.zip" % (today)
     zfilename = os.sep.join([dbpath, 'Geocacher_Backup%s' % ext])
     z=zipfile.ZipFile(zfilename, "w", allowZip64=True)
     for dbfile in filter(lambda x:x.lower().endswith('.sqlite'), os.listdir(geocacher.config().dbpath)):
         dbfile = os.sep.join([dbpath, dbfile.encode('ascii')])
         arcname = "%s-%s.sqlite" % (os.path.splitext(os.path.split(dbfile)[1])[0], today)
         arcname = arcname.encode('ascii')
         z.write(dbfile, arcname, compress_type=zipfile.ZIP_DEFLATED)
     z.close()
     self.open()
Exemplo n.º 21
0
    def zipExport(self,
                  filename,caches):
        '''
        Exports the given caches to the given zip file in the .gpx format.

        Arguments
        filename: Path to the file to export the cache information to
        caches:   List of cache objects to be exported
        '''
        assert os.path.isdir(os.path.split(filename)[0])

        config=geocacher.config()

        if len(caches) == 0:
            return True

        if os.path.isfile(filename):
            try:
                os.remove(filename)
            except:
                return False

        baseName = os.path.splitext(os.path.basename(filename))[0]
        try:
            tempDir = tempfile.mkdtemp()
            archive = zipfile.ZipFile(filename,
                                      mode='w',
                                      compression=zipfile.ZIP_DEFLATED)
        except:
            return False

        gpxFileName = os.path.join(tempDir, baseName+'.gpx')
        ret1 = self.export(gpxFileName,caches, geocacher.config().exportSepAddWpts)
        archive.write(gpxFileName, os.path.basename(gpxFileName).encode("utf_8"))

        if config.exportAddWpts and config.exportSepAddWpts:

            gpxAddFileName = os.path.join(tempDir, baseName+'-wpts.gpx')
            ret2, count = self.exportAddWpt(gpxAddFileName,caches)
            if count != 0:
                archive.write(gpxAddFileName,
                              os.path.basename(gpxAddFileName).encode("utf_8"))
        else:
            ret2 = True

        archive.close()

        shutil.rmtree(tempDir)
        return ret1 and ret2
Exemplo n.º 22
0
    def OnGpsLocation(self, event=None):
        """
        Handles the event from the "Location from GPS" menu item.

        Keyword Argument
        event: The event causing this function to be called.
        """
        self.pushStatus(_("Loading new location form GPS"))
        gpsCom = GpsCom(gps=geocacher.config().gpsType, port=geocacher.config().gpsConnection)
        ok, lat, lon, message = gpsCom.getCurrentPos()
        if ok:
            self.NewLocation(lat, lon, _("the GPS"), _("GPS Point"))
        else:
            self.GpsError(message)
        self.popStatus()
Exemplo n.º 23
0
    def OnMaintainDb(self, event=None):
        """
        Handles the event from the "Maintain Database" menu item.

        Keyword Argument
        event: The event causing this function to be called.
        """
        self.pushStatus(_("Maintaining Database"))
        opts = DatabaseCleanupOptions(self)
        if opts.ShowModal() == wx.ID_OK:
            opts.SaveConf()
            geocacher.db().maintdb()
            if geocacher.config().cleanupCacheAct != "none" or geocacher.config().cleanupLog > 0:
                self.cacheGrid.ReloadCaches()
        self.popStatus()
Exemplo n.º 24
0
 def __init__(self, debugging=False):
     __sharde_state = {}
     self.__dict__ = self.__shared_state
     if not hasattr(self, "allstatements"):
         self.allstatements = sorted(filter(lambda x: x.startswith("statements_v"), Database.__dict__.keys()))
     if not hasattr(self, "database"):
         self.open(geocacher.config().dbfile, debugging)
Exemplo n.º 25
0
    def OnGpsLocation(self, event=None):
        '''
        Handles the event from the "Location from GPS" menu item.

        Keyword Argument
        event: The event causing this function to be called.
        '''
        self.pushStatus(_('Loading new location form GPS'))
        gpsCom = GpsCom(gps=geocacher.config().gpsType,
                        port=geocacher.config().gpsConnection)
        ok, lat, lon, message = gpsCom.getCurrentPos()
        if ok:
            self.NewLocation(lat, lon, _('the GPS'), _('GPS Point'))
        else:
            self.GpsError(message)
        self.popStatus()
Exemplo n.º 26
0
    def OnQuit(self, event=None):
        '''
        Handles the exit application event saving the necessary data before
        exiting.

        Keyword Argument
        event: The event causing this function to be called.
        '''
        geocacher.config().mainWinSize = self.GetSize()
        geocacher.config().detailSplit = self.splitter.GetSashPosition()
        geocacher.config().cacheColumnOrder = self.cacheGrid.GetCols()
        if self.displayedCache != None:
            geocacher.config().displayedCache = self.displayedCache
        else:
            geocacher.config().displayedCache = ''
        self.Destroy()
Exemplo n.º 27
0
    def OnMaintainDb(self, event=None):
        '''
        Handles the event from the "Maintain Database" menu item.

        Keyword Argument
        event: The event causing this function to be called.
        '''
        self.pushStatus(_("Maintaining Database"))
        opts = DatabaseCleanupOptions(self)
        if opts.ShowModal() == wx.ID_OK:
            opts.SaveConf()
            geocacher.db().maintdb()
            if geocacher.config(
            ).cleanupCacheAct != 'none' or geocacher.config().cleanupLog > 0:
                self.cacheGrid.ReloadCaches()
        self.popStatus()
Exemplo n.º 28
0
    def SaveConf(self):
        '''
        Saves the values form the dialog to the configuration structure
        '''
        config = geocacher.config()
        config.exportFilterDisp = self.displayed.GetValue()
        config.exportFilterSel = self.selected.GetValue()
        config.exportFilterUser = self.userFlag.GetValue()

        if not self.gps:
            config.exportFile = self.path.GetPath()

        config.exportScope = self.types[self.exType.GetSelection()]
        simple = config.exportScope == self.types[0]
        full = config.exportScope == self.types[1]

        config.exportGc = (self.gc.GetValue() and (not simple)) or full
        config.exportLogs = (self.logs.GetValue() and (not simple)) or full
        config.exportTbs = (self.tbs.GetValue() and (not simple)) or full

        config.exportAddWpts = (self.addWpts.GetValue() and (not simple)) or full
        config.exportSepAddWpts = self.sepAddWpts.GetValue()

        config.exportAdjWpts = self.adjWpts.GetValue()
        config.exportAdjWptSufix = self.adjWptSufix.GetValue()

        config.exportLimitLogs = self.limitLogs.GetValue()
        config.exportMaxLogs = self.maxLogs.GetValue()
        config.exportLogOrder = self.logOrder.GetSelection()

        config.exportGpxVersion = self.gpxVersion.GetSelection()
Exemplo n.º 29
0
    def SaveConf(self):
        '''
        Saves the values form the dialog to the configuration structure
        '''
        config = geocacher.config()
        config.exportFilterDisp = self.displayed.GetValue()
        config.exportFilterSel = self.selected.GetValue()
        config.exportFilterUser = self.userFlag.GetValue()

        if not self.gps:
            config.exportFile = self.path.GetPath()

        config.exportScope = self.types[self.exType.GetSelection()]
        simple = config.exportScope == self.types[0]
        full = config.exportScope == self.types[1]

        config.exportGc = (self.gc.GetValue() and (not simple)) or full
        config.exportLogs = (self.logs.GetValue() and (not simple)) or full
        config.exportTbs = (self.tbs.GetValue() and (not simple)) or full

        config.exportAddWpts = (self.addWpts.GetValue() and
                                (not simple)) or full
        config.exportSepAddWpts = self.sepAddWpts.GetValue()

        config.exportAdjWpts = self.adjWpts.GetValue()
        config.exportAdjWptSufix = self.adjWptSufix.GetValue()

        config.exportLimitLogs = self.limitLogs.GetValue()
        config.exportMaxLogs = self.maxLogs.GetValue()
        config.exportLogOrder = self.logOrder.GetSelection()

        config.exportGpxVersion = self.gpxVersion.GetSelection()
Exemplo n.º 30
0
 def backup(self):
     self.close()
     dbpath = geocacher.config().dbpath
     today = datetime.date.today().isoformat()
     ext = "-%s.zip" % (today)
     zfilename = os.sep.join([dbpath, 'Geocacher_Backup%s' % ext])
     z = zipfile.ZipFile(zfilename, "w", allowZip64=True)
     for dbfile in filter(lambda x: x.lower().endswith('.sqlite'),
                          os.listdir(geocacher.config().dbpath)):
         dbfile = os.sep.join([dbpath, dbfile.encode('ascii')])
         arcname = "%s-%s.sqlite" % (os.path.splitext(
             os.path.split(dbfile)[1])[0], today)
         arcname = arcname.encode('ascii')
         z.write(dbfile, arcname, compress_type=zipfile.ZIP_DEFLATED)
     z.close()
     self.open()
Exemplo n.º 31
0
    def GetColLabelValue(self, col):
        '''
        Returns the label for the given column.

        Argument
        row: Column number to return the label for.
        '''
        id = self.colNames[col]
        label = self.colLabels[id]
        if id == geocacher.config().cacheSortColumn:
            if geocacher.config().cacheSortDescend:
                return label + u" \u2207"
            else:
                return label + u" \u2206"
        else:
            return label
Exemplo n.º 32
0
    def OnQuit(self, event=None):
        """
        Handles the exit application event saving the necessary data before
        exiting.

        Keyword Argument
        event: The event causing this function to be called.
        """
        geocacher.config().mainWinSize = self.GetSize()
        geocacher.config().detailSplit = self.splitter.GetSashPosition()
        geocacher.config().cacheColumnOrder = self.cacheGrid.GetCols()
        if self.displayedCache != None:
            geocacher.config().displayedCache = self.displayedCache
        else:
            geocacher.config().displayedCache = ""
        self.Destroy()
Exemplo n.º 33
0
 def BeginEdit(self, row, col, grid):
     self.startValue = grid.GetTable().GetValue(row, col)
     format = geocacher.config().coordinateFormat
     self._tc.SetValue(degToStr(self.startValue, format, self.mode))
     self._tc.SetInsertionPointEnd()
     self._tc.SetFocus()
     self._tc.SetSelection(0, self._tc.GetLastPosition())
Exemplo n.º 34
0
    def GetColLabelValue(self, col):
        '''
        Returns the label for the given column.

        Argument
        row: Column number to return the label for.
        '''
        id = self.colNames[col]
        label = self.colLabels[id]
        if id == geocacher.config().cacheSortColumn:
            if geocacher.config().cacheSortDescend:
                return label + u" \u2207"
            else:
                return label + u" \u2206"
        else:
            return label
Exemplo n.º 35
0
 def BeginEdit(self, row, col, grid):
     self.startValue = grid.GetTable().GetValue(row, col)
     format = geocacher.config().coordinateFormat
     self._tc.SetValue(degToStr(self.startValue, format, self.mode))
     self._tc.SetInsertionPointEnd()
     self._tc.SetFocus()
     self._tc.SetSelection(0, self._tc.GetLastPosition())
Exemplo n.º 36
0
    def OnExportWpt(self, event=None):
        '''
        Handles the event from the "Export Waypoints to file" menu item.

        Keyword Argument
        event: The event causing this function to be called.
        '''
        self.pushStatus(_('Exporting caches to file'))
        opts = ExportOptions(self, False)
        if opts.ShowModal() == wx.ID_OK:
            opts.SaveConf()
            config = geocacher.config()
            path = config.exportFile
            self.popStatus()
            self.pushStatus(_('Exporting caches to file: %s') % path)
            if os.path.isfile(path):
                question = wx.MessageDialog(
                    None,
                    message=
                    _('"%s" already exists are you sure you want to replace it ?'
                      ) % path,
                    caption=_('File Already Exists'),
                    style=wx.YES_NO | wx.ICON_WARNING)
                if question.ShowModal() == wx.ID_NO:
                    question.Destroy()
                    self.popStatus()
                    return
            ext = os.path.splitext(path)[1]
            caches = self.selectCaches(False)
            if len(caches) == 0:
                wx.MessageBox(
                    parent=self,
                    message=_(
                        'With the current settings there is nothing to export!'
                    ),
                    caption=_('Nothing to export'),
                    style=wx.OK | wx.ICON_ERROR)
            else:
                gpx = Gpx()
                if ext == '.gpx':
                    ret = gpx.export(path, caches)
                elif ext == '.zip':
                    ret = gpx.zipExport(path, caches)
                else:
                    ret = True
                    wx.MessageBox(
                        parent=self,
                        message=
                        _('Error exporting to file: %s\n file type not supported'
                          ) % config.exportPath,
                        caption=_('Way point export Error'),
                        style=wx.OK | wx.ICON_ERROR)
                if not ret:
                    wx.MessageBox(parent=self,
                                  message=_('Error exporting to file: %s') %
                                  path,
                                  caption=_('Way point export Error'),
                                  style=wx.OK | wx.ICON_ERROR)
            self.popStatus()
Exemplo n.º 37
0
 def GetBestSize(self, grid, attr, dc, row, col):
     value = self.table.GetValue(row, col)
     if geocacher.config().imperialUnits:
         text = '%0.2f Mi' % (value * 0.621371192)
     else:
         text = '%0.2f km' % value
     w, h = dc.GetTextExtent(text)
     return wx.Size(w, h)
Exemplo n.º 38
0
 def GetBestSize(self, grid, attr, dc, row, col):
     value = self.table.GetValue(row, col)
     if geocacher.config().imperialUnits:
         text = '%0.2f Mi' % (value * 0.621371192)
     else:
         text = '%0.2f km' % value
     w, h = dc.GetTextExtent(text)
     return wx.Size(w, h)
Exemplo n.º 39
0
 def TransferToWindow(self):
     textCtrl = self.GetWindow()
     value = self.data.get(self.key, 0)
     if self.new:
         textCtrl.SetValue("")
     else:
         textCtrl.SetValue(degToStr(value, geocacher.config().coordinateFormat, self.mode))
     return True
Exemplo n.º 40
0
    def __init__(self, parent, id):
        """
        Initialisation for the main frame.

        Arguments
        parent: The parent window of the frame.
        id:     The ID to give the frame.
        """
        self.displayCache = None
        size = geocacher.config().mainWinSize
        # check that the Current location is in the db
        if geocacher.config().currentLocation not in geocacher.db().getLocationNameList():
            geocacher.config().currentLocation = geocacher.db().getLocationNameList()[0]
        wx.Frame.__init__(
            self,
            parent,
            wx.ID_ANY,
            _("Geocacher"),
            size=(size),
            style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE,
        )
        self.Bind(wx.EVT_CLOSE, self.OnQuit)
        self.SetIcon(wx.Icon(os.path.join(geocacher.getBasePath(), "gfx", "treasure_chest.ico"), wx.BITMAP_TYPE_ICO))
        self.buildStatusBar()

        self.buildMenu()

        self.buildToolBar()

        self.splitter = wx.SplitterWindow(self, wx.ID_ANY, style=wx.SP_LIVE_UPDATE | wx.SP_BORDER)
        self.cacheGrid = CacheGrid(self.splitter)
        self.Description = Html.HtmlWindow(self.splitter, wx.ID_ANY, name="Description Pannel")
        self.splitter.SetMinimumPaneSize(20)
        self.splitter.SplitHorizontally(self.cacheGrid, self.Description, geocacher.config().detailSplit)

        self.updateStatus()

        self.displayedCache = None
        self.updateDetail(geocacher.config().displayedCache)

        Publisher.subscribe(self.updateDetailMsg, "cache.selected")
        Publisher.subscribe(self.NewLocationMsg, "location.new")
        Publisher.subscribe(self.popStatusMsg, "status.pop")
        Publisher.subscribe(self.pushStatusMsg, "status.push")
        Publisher.subscribe(self.updateStatusMsg, "status.update")
Exemplo n.º 41
0
    def OnExportWpt(self, event=None):
        """
        Handles the event from the "Export Waypoints to file" menu item.

        Keyword Argument
        event: The event causing this function to be called.
        """
        self.pushStatus(_("Exporting caches to file"))
        opts = ExportOptions(self, False)
        if opts.ShowModal() == wx.ID_OK:
            opts.SaveConf()
            config = geocacher.config()
            path = config.exportFile
            self.popStatus()
            self.pushStatus(_("Exporting caches to file: %s") % path)
            if os.path.isfile(path):
                question = wx.MessageDialog(
                    None,
                    message=_('"%s" already exists are you sure you want to replace it ?') % path,
                    caption=_("File Already Exists"),
                    style=wx.YES_NO | wx.ICON_WARNING,
                )
                if question.ShowModal() == wx.ID_NO:
                    question.Destroy()
                    self.popStatus()
                    return
            ext = os.path.splitext(path)[1]
            caches = self.selectCaches(False)
            if len(caches) == 0:
                wx.MessageBox(
                    parent=self,
                    message=_("With the current settings there is nothing to export!"),
                    caption=_("Nothing to export"),
                    style=wx.OK | wx.ICON_ERROR,
                )
            else:
                gpx = Gpx()
                if ext == ".gpx":
                    ret = gpx.export(path, caches)
                elif ext == ".zip":
                    ret = gpx.zipExport(path, caches)
                else:
                    ret = True
                    wx.MessageBox(
                        parent=self,
                        message=_("Error exporting to file: %s\n file type not supported") % config.exportPath,
                        caption=_("Way point export Error"),
                        style=wx.OK | wx.ICON_ERROR,
                    )
                if not ret:
                    wx.MessageBox(
                        parent=self,
                        message=_("Error exporting to file: %s") % path,
                        caption=_("Way point export Error"),
                        style=wx.OK | wx.ICON_ERROR,
                    )
            self.popStatus()
Exemplo n.º 42
0
 def __init__(self, debugging=False):
     __sharde_state = {}
     self.__dict__ = self.__shared_state
     if not hasattr(self, "allstatements"):
         self.allstatements = sorted(
             filter(lambda x: x.startswith("statements_v"),
                    Database.__dict__.keys()))
     if not hasattr(self, "database"):
         self.open(geocacher.config().dbfile, debugging)
Exemplo n.º 43
0
 def Save(self):
     existingNames = geocacher.db().getLocationNameList()
     newNames = self.GetNames()
     for row in self.data:
         if row[0] in existingNames:
             location = geocacher.db().getLocationByName(row[0])
             location.lat = row[1]
             location.lon = row[2]
             location.save()
         else:
             geocacher.db().addLocation(row[0], row[1], row[2])
     for name in existingNames:
         if name not in newNames:
             location = geocacher.db().getLocationByName(name)
             location.delete()
     geocacher.db().commit()
     if geocacher.config().currentLocation not in newNames:
         geocacher.config().currentLocation = newNames[0]
Exemplo n.º 44
0
 def Save(self):
     existingNames = geocacher.db().getLocationNameList()
     newNames = self.GetNames()
     for row in self.data:
         if row[0] in existingNames:
             location = geocacher.db().getLocationByName(row[0])
             location.lat = row[1]
             location.lon = row[2]
             location.save()
         else:
             geocacher.db().addLocation(row[0], row[1], row[2])
     for name in existingNames:
         if name not in newNames:
             location = geocacher.db().getLocationByName(name)
             location.delete()
     geocacher.db().commit()
     if geocacher.config().currentLocation not in newNames:
         geocacher.config().currentLocation = newNames[0]
Exemplo n.º 45
0
    def maintdb(self):
        config = geocacher.config()
        if config.cleanupBackup:
            print "Backing up"
            self.backup()
        cur = self.cursor()

        if config.cleanupCacheAct == 'delete':
            # delete caches which have not been seen in gpx files for
            # config.cleanupCacheDays excluding caches we have found or own
            sql = "DELETE FROM Caches WHERE gpx_date < date('now', '-%i day' ) AND owner != ? AND owner_id != ? AND found = 0 AND corrected = 0" % config.cleanupCacheAge
            cur.execute(sql, (
                config.GCUserName,
                config.GCUserID,
            ))

        # need to archive unseen caches that we have found if in delete mode
        if config.cleanupCacheAct in ['archive', 'delete']:
            # mark caches which have not been seen in gpx files for
            # config.cleanupCacheDays as archived and unavailable
            sql = "UPDATE Caches SET available = 0, archived = 1 WHERE gpx_date < date('now', '-%i day' )" % config.cleanupCacheAge
            cur.execute(sql)

        # Cleanup any orphaned Attributes, Logs, Travelbugs and Waypoints
        cur.execute(
            "DELETE FROM Attributes WHERE cache_id NOT IN (SELECT id FROM Caches)"
        )
        cur.execute(
            "DELETE FROM Logs WHERE cache_id NOT IN (SELECT id FROM Caches)")
        cur.execute(
            "DELETE FROM Travelbugs WHERE cache_id NOT IN (SELECT id FROM Caches)"
        )
        cur.execute(
            "DELETE FROM Waypoints WHERE cache_id NOT IN (SELECT id FROM Caches)"
        )
        self.commit()

        if config.cleanupLog > 0:
            # remove logs  older than config.cleanupLog days old except own
            sql = "SELECT * FROM Logs WHERE finder_name != ? AND finder_id != ?  AND log_date < DATE('now', '-%i day')  AND cache_id NOT IN (SELECT id FROM Caches WHERE owner = ? OR owner_id = ?)" % config.cleanupLog
            cur.execute(sql, (
                config.GCUserName,
                config.GCUserID,
                config.GCUserName,
                config.GCUserID,
            ))

        if config.cleanupCompact:
            print "Vacuuming"
            cur.execute("vacuum")
            self.commit()

        if config.cleanupIndexes:
            print "Rebuilding indexes"
            cur.execute("analyze")
            self.commit()
Exemplo n.º 46
0
    def __init__(self, table):
        Grid.PyGridCellRenderer.__init__(self)
        self._dir = os.path.join(geocacher.getBasePath(),'gfx')
        self._themeDir = geocacher.config().iconTheme
        self.table = table
        self._images = {}
        self._default = None

        self.colSize = None
        self.rowSize = None
Exemplo n.º 47
0
 def getCurrentLocationLatLon(self):
     '''Returns the Lat and lon of the currently configured location or 0.0,0.0 if it does not exist'''
     cur = self.cursor()
     cur.execute("SELECT lat, lon FROM Locations WHERE name = ?", (geocacher.config().currentLocation,))
     row = cur.fetchone()
     if row is None:
         return (0.0, 0.0)
     else:
         lat, lon = row
         return (lat, lon)
Exemplo n.º 48
0
    def OnShowFilter(self, event=None):
        '''
        Handles the event from the "Show Filter" menu item.

        Keyword Argument
        event: The event causing this function to be called.
        '''
        show = self.miShowFilter.IsChecked()
        geocacher.config().showFilter = show
        self.ShowHideFilterBar(show)
Exemplo n.º 49
0
    def OnShowFilter(self, event=None):
        """
        Handles the event from the "Show Filter" menu item.

        Keyword Argument
        event: The event causing this function to be called.
        """
        show = self.miShowFilter.IsChecked()
        geocacher.config().showFilter = show
        self.ShowHideFilterBar(show)
Exemplo n.º 50
0
 def TransferToWindow(self):
     textCtrl = self.GetWindow()
     value = self.data.get(self.key, 0)
     if self.new:
         textCtrl.SetValue('')
     else:
         textCtrl.SetValue(
             degToStr(value,
                      geocacher.config().coordinateFormat, self.mode))
     return True
Exemplo n.º 51
0
 def SaveConf(self):
     '''
     Saves the values form the dialog to the configuration structure
     '''
     config = geocacher.config()
     config.cleanupBackup = self.backup.GetValue()
     config.cleanupCacheAct = self.actions[self.cacheAction.GetSelection()]
     config.cleanupCacheAge = self.cacheAge.GetValue()
     config.cleanupLog = self.logAge.GetValue()
     config.cleanupIndexes = self.indexes.GetValue()
     config.cleanupCompact = self.compact.GetValue()
Exemplo n.º 52
0
 def formatDist(self, distance):
     if geocacher.config().imperialUnits:
         if distance < 1.0:
             return '%i yd' % int(distance * 1760)
         else:
             return '%0.2f mi' % distance
     else:
         if distance < 1.0:
             return '%i m' % int(distance * 1000)
         else:
             return '%0.2f km' % distance
Exemplo n.º 53
0
 def formatDist(self, distance):
     if geocacher.config().imperialUnits:
         if distance < 1.0:
             return '%i yd' % int(distance * 1760)
         else:
             return '%0.2f mi' % distance
     else:
         if distance < 1.0:
             return '%i m' % int(distance * 1000)
         else:
             return '%0.2f km' % distance
Exemplo n.º 54
0
 def SaveConf(self):
     '''
     Saves the values form the dialog to the configuration structure
     '''
     config = geocacher.config()
     config.cleanupBackup = self.backup.GetValue()
     config.cleanupCacheAct = self.actions[self.cacheAction.GetSelection()]
     config.cleanupCacheAge = self.cacheAge.GetValue()
     config.cleanupLog = self.logAge.GetValue()
     config.cleanupIndexes = self.indexes.GetValue()
     config.cleanupCompact = self.compact.GetValue()
Exemplo n.º 55
0
 def getCurrentLocationLatLon(self):
     '''Returns the Lat and lon of the currently configured location or 0.0,0.0 if it does not exist'''
     cur = self.cursor()
     cur.execute("SELECT lat, lon FROM Locations WHERE name = ?",
                 (geocacher.config().currentLocation, ))
     row = cur.fetchone()
     if row is None:
         return (0.0, 0.0)
     else:
         lat, lon = row
         return (lat, lon)
Exemplo n.º 56
0
    def OnHideDisabled(self, state):
        '''
        Handles the event from the toggling of the "Hide Disabled"
        tool bar or menu item.

        Argument
        state: The state of the check box causing the function to be called.
        '''
        geocacher.config().filterDisabled = state
        self.miHideDisabled.Check(state)
        self.cbHideDisabled.SetValue(state)
        self.updateFilter()
Exemplo n.º 57
0
 def __saveDisplayConf(self):
     '''
     Saves the preferences from the display preferences panel.
     '''
     if self.dispUnits.GetValue() == self.dispUnitsChoices[0]:
         geocacher.config().imperialUnits = False
     else:
         geocacher.config().imperialUnits = True
     geocacher.config().coordinateFormat = self.dispCoordFmt.GetValue()
     geocacher.config().iconTheme = self.iconThemeSel.GetValue()
     geocacher.config().userData1Label = self.dispUserData1.GetValue()
     geocacher.config().userData2Label = self.dispUserData2.GetValue()
     geocacher.config().userData3Label = self.dispUserData3.GetValue()
     geocacher.config().userData4Label = self.dispUserData4.GetValue()
Exemplo n.º 58
0
    def OnPrefs(self, event=None):
        '''
        Handles the event from the "Preferences" menu item.

        Keyword Argument
        event: The event causing this function to be called.
        '''
        dlg = Preferences(self, wx.ID_ANY)
        if dlg.ShowModal() == wx.ID_OK:
            self.cacheGrid.UpdateUserDataLabels()
            self.updateLocations()
            self.updateCurrentLocation(geocacher.config().currentLocation)
        dlg.Destroy()
Exemplo n.º 59
0
    def updateCurrentLocation(self, name):
        '''
        Updates the cache data in the table/grid when a new location is
        selected.

        Argument
        name: name of the new home location to be used.
        '''
        self.pushStatus(_('Updating home location to: %s') % name)
        self.selLocation.SetValue(name)
        geocacher.config().currentLocation = name
        self.cacheGrid.UpdateLocation()
        self.updateStatus()
        self.popStatus()