Exemple #1
0
 def OnCreateFileHistory(self):
     """
     A hook to allow a derived class to create a different type of file
     history. Called from Initialize.
     """
     max_files = int(wx.ConfigBase_Get().Read("MRULength",str(DEFAULT_MRU_FILE_NUM)))
     enableMRU = wx.ConfigBase_Get().ReadInt("EnableMRU", True)
     if enableMRU:
         self._fileHistory = wx.FileHistory(maxFiles=max_files,idBase=ID_MRU_FILE1)
 def OnSort(self, event):
     id = event.GetId()
     if id == OutlineService.SORT_ASC:
         wx.ConfigBase_Get().WriteInt("OutlineSort", SORT_ASC)
         self.GetView().OnSort(SORT_ASC)
         return True
     elif id == OutlineService.SORT_DESC:
         wx.ConfigBase_Get().WriteInt("OutlineSort", SORT_DESC)
         self.GetView().OnSort(SORT_DESC)
         return True
     elif id == OutlineService.SORT_NONE:
         wx.ConfigBase_Get().WriteInt("OutlineSort", SORT_NONE)
         self.GetView().OnSort(SORT_NONE)
         return True
Exemple #3
0
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id)
        pathLabel = wx.StaticText(self, -1, _("Interpreters:"))
        config = wx.ConfigBase_Get()
      ###  path = config.Read("ActiveGridPythonLocation")
        choices,default_selection = interpretermanager.InterpreterManager().GetChoices()
        self._pathTextCtrl = wx.ComboBox(self, -1,choices=choices, style = wx.CB_READONLY)
        if len(choices) > 0:
            self._pathTextCtrl.SetSelection(default_selection)
       ## self._pathTextCtrl.SetToolTipString(self._pathTextCtrl.GetValue())
        ##self._pathTextCtrl.SetInsertionPointEnd()
        choosePathButton = wx.Button(self, -1, _("Configure..."))
        pathSizer = wx.BoxSizer(wx.HORIZONTAL)
        HALF_SPACE = 5
        SPACE = 10
        pathSizer.Add(pathLabel, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.TOP, HALF_SPACE)
        pathSizer.Add(self._pathTextCtrl, 1, wx.EXPAND|wx.LEFT|wx.TOP, HALF_SPACE)
        pathSizer.Add(choosePathButton, 0, wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT|wx.TOP, HALF_SPACE)
        wx.EVT_BUTTON(self, choosePathButton.GetId(), self.OnChoosePath)
        mainSizer = wx.BoxSizer(wx.VERTICAL)                
        mainSizer.Add(pathSizer, 0, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, SPACE)

        self._otherOptions = STCTextEditor.TextOptionsPanel(self, -1, configPrefix = "Python", label = "Python", hasWordWrap = True, hasTabs = True, addPage=False, hasFolding=True)
        mainSizer.Add(self._otherOptions, 0, wx.EXPAND|wx.BOTTOM, SPACE)
        self.SetSizer(mainSizer)
        parent.AddPage(self, _("Python"))
Exemple #4
0
    def SaveFindConfig(self,
                       findString,
                       wholeWord,
                       matchCase,
                       regExpr=None,
                       wrap=None,
                       upDown=None,
                       replaceString=None):
        """ Save find/replace patterns and search flags to registry.
        
            findString = search pattern
            wholeWord = match whole word only
            matchCase = match case
            regExpr = use regular expressions in search pattern
            wrap = return to top/bottom of file on search
            upDown = search up or down from current cursor position
            replaceString = replace string
        """
        config = wx.ConfigBase_Get()

        config.Write(FIND_MATCHPATTERN, findString)
        config.WriteInt(FIND_MATCHCASE, matchCase)
        config.WriteInt(FIND_MATCHWHOLEWORD, wholeWord)
        if replaceString != None:
            config.Write(FIND_MATCHREPLACE, replaceString)
        if regExpr != None:
            config.WriteInt(FIND_MATCHREGEXPR, regExpr)
        if wrap != None:
            config.WriteInt(FIND_MATCHWRAP, wrap)
        if upDown != None:
            config.WriteInt(FIND_MATCHUPDOWN, upDown)
Exemple #5
0
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id)
        pathLabel = wx.StaticText(self, -1, _("python.exe Path:"))
        config = wx.ConfigBase_Get()
        path = config.Read("ActiveGridPythonLocation")
        self._pathTextCtrl = wx.TextCtrl(self, -1, path, size=(150, -1))
        self._pathTextCtrl.SetToolTipString(self._pathTextCtrl.GetValue())
        self._pathTextCtrl.SetInsertionPointEnd()
        choosePathButton = wx.Button(self, -1, _("Browse..."))
        pathSizer = wx.BoxSizer(wx.HORIZONTAL)
        HALF_SPACE = 5
        SPACE = 10
        pathSizer.Add(pathLabel, 0,
                      wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.TOP, HALF_SPACE)
        pathSizer.Add(self._pathTextCtrl, 1, wx.EXPAND | wx.LEFT | wx.TOP,
                      HALF_SPACE)
        pathSizer.Add(choosePathButton, 0,
                      wx.ALIGN_RIGHT | wx.LEFT | wx.RIGHT | wx.TOP, HALF_SPACE)
        wx.EVT_BUTTON(self, choosePathButton.GetId(), self.OnChoosePath)
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(pathSizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP,
                      SPACE)

        self._otherOptions = STCTextEditor.TextOptionsPanel(
            self,
            -1,
            configPrefix="Python",
            label="Python",
            hasWordWrap=True,
            hasTabs=True,
            addPage=False,
            hasFolding=True)
        mainSizer.Add(self._otherOptions, 0, wx.EXPAND | wx.BOTTOM, SPACE)
        self.SetSizer(mainSizer)
        parent.AddPage(self, _("Python"))
Exemple #6
0
 def SavePythonInterpretersConfig(self):
     config = wx.ConfigBase_Get()
     if sysutils.isWindows():
         dct = self.ConvertInterpretersToDictList()
         if dct == []:
             return
         config.Write(self.KEY_PREFIX, pickle.dumps(dct))
     else:
         prefix = self.KEY_PREFIX
         id_list = [str(kl.Id) for kl in self.interpreters]
         config.Write(prefix, os.pathsep.join(id_list))
         for kl in self.interpreters:
             config.WriteInt("%s/%d/Id" % (prefix, kl.Id), kl.Id)
             config.Write("%s/%d/Name" % (prefix, kl.Id), kl.Name)
             config.Write("%s/%d/Version" % (prefix, kl.Id), kl.Version)
             config.Write("%s/%d/Path" % (prefix, kl.Id), kl.Path)
             config.WriteInt("%s/%d/Default" % (prefix, kl.Id), kl.Default)
             config.Write("%s/%d/SysPathList" % (prefix, kl.Id),
                          os.pathsep.join(kl.SysPathList))
             config.Write("%s/%d/PythonPathList" % (prefix, kl.Id),
                          os.pathsep.join(kl.PythonPathList))
             config.Write("%s/%d/Builtins" % (prefix, kl.Id),
                          os.pathsep.join(kl.Builtins))
             config.Write("%s/%d/Environ" % (prefix, kl.Id),
                          json.dumps(kl.Environ.environ))
             config.Write("%s/%d/Packages" % (prefix, kl.Id),
                          json.dumps(kl.Packages))
Exemple #7
0
    def InstallControls(self,
                        frame,
                        menuBar=None,
                        toolBar=None,
                        statusBar=None,
                        document=None):
        if document and document.GetDocumentTemplate().GetDocumentType(
        ) != TextDocument:
            return
        config = wx.ConfigBase_Get()

        formatMenuIndex = menuBar.FindMenu(_("&Format"))
        if formatMenuIndex > -1:
            formatMenu = menuBar.GetMenu(formatMenuIndex)
        else:
            formatMenu = wx.Menu()
        formatMenu = wx.Menu()
        if not menuBar.FindItemById(TextService.WORD_WRAP_ID):
            formatMenu.AppendCheckItem(
                TextService.WORD_WRAP_ID, _("Word Wrap"),
                _("Wraps text horizontally when checked"))
            formatMenu.Check(TextService.WORD_WRAP_ID,
                             config.ReadInt("TextEditorWordWrap", True))
            wx.EVT_MENU(frame, TextService.WORD_WRAP_ID, frame.ProcessEvent)
            wx.EVT_UPDATE_UI(frame, TextService.WORD_WRAP_ID,
                             frame.ProcessUpdateUIEvent)
        if not menuBar.FindItemById(TextService.CHOOSE_FONT_ID):
            formatMenu.Append(TextService.CHOOSE_FONT_ID, _("Font..."),
                              _("Sets the font to use"))
            wx.EVT_MENU(frame, TextService.CHOOSE_FONT_ID, frame.ProcessEvent)
            wx.EVT_UPDATE_UI(frame, TextService.CHOOSE_FONT_ID,
                             frame.ProcessUpdateUIEvent)
        if formatMenuIndex == -1:
            viewMenuIndex = menuBar.FindMenu(_("&View"))
            menuBar.Insert(viewMenuIndex + 1, formatMenu, _("&Format"))
Exemple #8
0
 def OnOK(self, optionsDialog):
     """
     Updates the config based on the selections in the options panel.
     """
     config = wx.ConfigBase_Get()
     config.WriteInt("ShowTipAtStartup", self._showTipsCheckBox.GetValue())
     config.WriteInt(consts.CHECK_UPDATE_ATSTARTUP_KEY,
                     self._chkUpdateCheckBox.GetValue())
     if self.language_combox.GetValue() != config.Read("Language", ""):
         wx.MessageBox(
             _("Language changes will not appear until the application is restarted."
               ), _("Language Options"), wx.OK | wx.ICON_INFORMATION,
             self.GetParent())
     config.Write("Language", self.language_combox.GetValue())
     config.Write("MRULength", self._mru_ctrl.GetValue())
     config.WriteInt("EnableMRU", self._enableMRUCheckBox.GetValue())
     config.Write(consts.DEFAULT_FILE_ENCODING_KEY,
                  self.encodings_combo.GetValue())
     if self._AllowModeChanges():
         config.WriteInt("UseMDI",
                         (self._documentRadioBox.GetStringSelection()
                          == self._mdiChoice))
         config.WriteInt("UseWinMDI",
                         (self._documentRadioBox.GetStringSelection()
                          == self._winMdiChoice))
Exemple #9
0
    def OnOK(self, optionsDialog):
        config = wx.ConfigBase_Get()
        config.Write("ActiveGridPHPLocation",
                     self._pathTextCtrl.GetValue().strip())
        config.Write("ActiveGridPHPINILocation",
                     self._iniTextCtrl.GetValue().strip())

        self._otherOptions.OnOK(optionsDialog)
Exemple #10
0
    def OnOK(self, optionsDialog):
        config = wx.ConfigBase_Get()

        config.Write(SVN_CONFIG_DIR, self._svnConfigDir.GetValue())

        WriteSvnUrlList(self._svnURLCombobox)

        os.environ["SVN_SSH"] = self._svnSSH.GetValue()
Exemple #11
0
    def __init__(self, parent, id, title, size, findString=None):
        wx.Dialog.__init__(self, parent, id, title, size=size)

        config = wx.ConfigBase_Get()
        borderSizer = wx.BoxSizer(wx.VERTICAL)
        gridSizer = wx.GridBagSizer(SPACE, SPACE)

        lineSizer = wx.BoxSizer(wx.HORIZONTAL)
        lineSizer.Add(wx.StaticText(self, -1, _("Find what:")), 0,
                      wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, SPACE)
        if not findString:
            findString = config.Read(FIND_MATCHPATTERN, "")
        self._findCtrl = wx.TextCtrl(self, -1, findString, size=(200, -1))
        lineSizer.Add(self._findCtrl, 0)
        gridSizer.Add(lineSizer, pos=(0, 0), span=(1, 2))
        choiceSizer = wx.BoxSizer(wx.VERTICAL)
        self._wholeWordCtrl = wx.CheckBox(self, -1, _("Match whole word only"))
        self._wholeWordCtrl.SetValue(config.ReadInt(FIND_MATCHWHOLEWORD,
                                                    False))
        self._matchCaseCtrl = wx.CheckBox(self, -1, _("Match case"))
        self._matchCaseCtrl.SetValue(config.ReadInt(FIND_MATCHCASE, False))
        self._regExprCtrl = wx.CheckBox(self, -1, _("Regular expression"))
        self._regExprCtrl.SetValue(config.ReadInt(FIND_MATCHREGEXPR, False))
        self._wrapCtrl = wx.CheckBox(self, -1, _("Wrap"))
        self._wrapCtrl.SetValue(config.ReadInt(FIND_MATCHWRAP, False))
        choiceSizer.Add(self._wholeWordCtrl, 0, wx.BOTTOM, SPACE)
        choiceSizer.Add(self._matchCaseCtrl, 0, wx.BOTTOM, SPACE)
        choiceSizer.Add(self._regExprCtrl, 0, wx.BOTTOM, SPACE)
        choiceSizer.Add(self._wrapCtrl, 0)
        gridSizer.Add(choiceSizer, pos=(1, 0), span=(2, 1))

        self._radioBox = wx.RadioBox(self,
                                     -1,
                                     _("Direction"),
                                     choices=["Up", "Down"])
        self._radioBox.SetSelection(config.ReadInt(FIND_MATCHUPDOWN, 1))
        gridSizer.Add(self._radioBox, pos=(1, 1), span=(2, 1))

        buttonSizer = wx.BoxSizer(wx.VERTICAL)
        findBtn = wx.Button(self, FindService.FINDONE_ID, _("Find Next"))
        findBtn.SetDefault()
        wx.EVT_BUTTON(self, FindService.FINDONE_ID, self.OnActionEvent)
        cancelBtn = wx.Button(self, wx.ID_CANCEL)
        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnClose)
        BTM_SPACE = HALF_SPACE
        if wx.Platform == "__WXMAC__":
            BTM_SPACE = SPACE
        buttonSizer.Add(findBtn, 0, wx.BOTTOM, BTM_SPACE)
        buttonSizer.Add(cancelBtn, 0)
        gridSizer.Add(buttonSizer, pos=(0, 2), span=(3, 1))

        borderSizer.Add(gridSizer, 0, wx.ALL, SPACE)

        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.SetSizer(borderSizer)
        self.Fit()
        self._findCtrl.SetFocus()
Exemple #12
0
 def SaveFindDirConfig(self, dirString, searchSubfolders):
     """ Save search dir patterns and flags to registry.
     
         dirString = search directory
         searchSubfolders = Search subfolders
     """
     config = wx.ConfigBase_Get()
     config.Write(FIND_MATCHDIR, dirString)
     config.WriteInt(FIND_MATCHDIRSUBFOLDERS, searchSubfolders)
Exemple #13
0
    def OnUpdate(self, sender = None, hint = None):
        if wx.lib.docview.View.OnUpdate(self, sender, hint):
            return

        if hint == "Word Wrap":
            self.SetWordWrap(wx.ConfigBase_Get().ReadInt("TextEditorWordWrap", True))
        elif hint == "Font":
            font, color = self._GetFontAndColorFromConfig()
            self.SetFont(font, color)
Exemple #14
0
 def __init__(self, parent, id):
     wx.Panel.__init__(self, parent, id)
     SPACE = 10
     HALF_SPACE = 5
     config = wx.ConfigBase_Get()
     self._textFont = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
     fontData = config.Read("TextEditorFont", "")
     if fontData:
         nativeFont = wx.NativeFontInfo()
         nativeFont.FromString(fontData)
         self._textFont.SetNativeFontInfo(nativeFont)
     self._originalTextFont = self._textFont
     self._textColor = wx.BLACK
     colorData = config.Read("TextEditorColor", "")
     if colorData:
         red = int("0x" + colorData[0:2], 16)
         green = int("0x" + colorData[2:4], 16)
         blue = int("0x" + colorData[4:6], 16)
         self._textColor = wx.Colour(red, green, blue)
     self._originalTextColor = self._textColor
     parent.AddPage(self, _("Text"))
     fontLabel = wx.StaticText(self, -1, _("Font:"))
     self._sampleTextCtrl = wx.TextCtrl(self, -1, "", size=(125, -1))
     self._sampleTextCtrl.SetEditable(False)
     chooseFontButton = wx.Button(self, -1, _("Choose Font..."))
     wx.EVT_BUTTON(self, chooseFontButton.GetId(), self.OnChooseFont)
     self._wordWrapCheckBox = wx.CheckBox(self, -1,
                                          _("Wrap words inside text area"))
     self._wordWrapCheckBox.SetValue(wx.ConfigBase_Get().ReadInt(
         "TextEditorWordWrap", True))
     textPanelBorderSizer = wx.BoxSizer(wx.VERTICAL)
     textPanelSizer = wx.BoxSizer(wx.VERTICAL)
     textFontSizer = wx.BoxSizer(wx.HORIZONTAL)
     textFontSizer.Add(fontLabel, 0, wx.ALIGN_LEFT | wx.RIGHT | wx.TOP,
                       HALF_SPACE)
     textFontSizer.Add(self._sampleTextCtrl, 0,
                       wx.ALIGN_LEFT | wx.EXPAND | wx.RIGHT, HALF_SPACE)
     textFontSizer.Add(chooseFontButton, 0, wx.ALIGN_RIGHT | wx.LEFT,
                       HALF_SPACE)
     textPanelSizer.Add(textFontSizer, 0, wx.ALL, HALF_SPACE)
     textPanelSizer.Add(self._wordWrapCheckBox, 0, wx.ALL, HALF_SPACE)
     textPanelBorderSizer.Add(textPanelSizer, 0, wx.ALL, SPACE)
     self.SetSizer(textPanelBorderSizer)
     self.UpdateSampleFont()
Exemple #15
0
 def CheckAppUpdate(self, ignore_error=False):
     api_addr = '%s/member/get_update' % (UserDataDb.HOST_SERVER_ADDR)
     config = wx.ConfigBase_Get()
     langId = GeneralOption.GetLangId(config.Read("Language", ""))
     lang = wx.Locale.GetLanguageInfo(langId).CanonicalName
     app_version = sysutilslib.GetAppVersion()
     data = UserDataDb.get_db().RequestData(api_addr,
                                            arg={
                                                'app_version': app_version,
                                                'lang': lang
                                            })
     if data is None:
         if not ignore_error:
             wx.MessageBox(_("could not connect to version server"),
                           style=wx.OK | wx.ICON_ERROR)
         return
     #no update
     if data['code'] == 0:
         if not ignore_error:
             wx.MessageBox(data['message'])
     #have update
     elif data['code'] == 1:
         ret = wx.MessageBox(data['message'], _("Update Available"),
                             wx.YES_NO | wx.ICON_QUESTION)
         if ret == wx.YES:
             new_version = data['new_version']
             download_url = '%s/member/download_app' % (
                 UserDataDb.HOST_SERVER_ADDR)
             payload = dict(new_version=new_version,
                            lang=lang,
                            os_name=sys.platform)
             user_id = UserDataDb.get_db().GetUserId()
             if user_id:
                 payload.update({'member_id': user_id})
             req = requests.get(download_url, params=payload, stream=True)
             #print req.headers,"------------"
             #print req.url
             if 'Content-Length' not in req.headers:
                 data = req.json()
                 if data['code'] != 0:
                     wx.MessageBox(data['message'],
                                   style=wx.OK | wx.ICON_ERROR)
             else:
                 file_length = req.headers['Content-Length']
                 content_disposition = req.headers['Content-Disposition']
                 file_name = content_disposition[content_disposition.
                                                 find(";") + 1:].replace(
                                                     "filename=",
                                                     "").replace("\"", "")
                 file_downloader = FileDownloader(file_length, file_name,
                                                  req, self.Install)
                 file_downloader.StartDownload()
     #other error
     else:
         if not ignore_error:
             wx.MessageBox(data['message'], style=wx.OK | wx.ICON_ERROR)
Exemple #16
0
    def SaveExtensions(self):

        config = wx.ConfigBase_Get()

        config.DeleteGroup(ExtensionService.EXTENSIONS_KEY)

        for extension in self._extensions:

            config.Write(self.__getExtensionKeyName(extension.menuItemName),
                         xmlutils.marshal(extension))
    def ShowFindInFileDialog(self, findString=None):
        config = wx.ConfigBase_Get()

        frame = wx.Dialog(wx.GetApp().GetTopWindow(), -1, _("Find in File"), size= (320,200))
        borderSizer = wx.BoxSizer(wx.HORIZONTAL)

        contentSizer = wx.BoxSizer(wx.VERTICAL)
        lineSizer = wx.BoxSizer(wx.HORIZONTAL)
        lineSizer.Add(wx.StaticText(frame, -1, _("Find what:")), 0, wx.ALIGN_CENTER | wx.RIGHT, HALF_SPACE)
        if not findString:
            findString = config.Read(FindService.FIND_MATCHPATTERN, "")
        findCtrl = wx.TextCtrl(frame, -1, findString, size=(200,-1))
        lineSizer.Add(findCtrl, 0, wx.LEFT, HALF_SPACE)
        contentSizer.Add(lineSizer, 0, wx.BOTTOM, SPACE)
        wholeWordCtrl = wx.CheckBox(frame, -1, _("Match whole word only"))
        wholeWordCtrl.SetValue(config.ReadInt(FindService.FIND_MATCHWHOLEWORD, False))
        matchCaseCtrl = wx.CheckBox(frame, -1, _("Match case"))
        matchCaseCtrl.SetValue(config.ReadInt(FindService.FIND_MATCHCASE, False))
        regExprCtrl = wx.CheckBox(frame, -1, _("Regular expression"))
        regExprCtrl.SetValue(config.ReadInt(FindService.FIND_MATCHREGEXPR, False))
        contentSizer.Add(wholeWordCtrl, 0, wx.BOTTOM, SPACE)
        contentSizer.Add(matchCaseCtrl, 0, wx.BOTTOM, SPACE)
        contentSizer.Add(regExprCtrl, 0, wx.BOTTOM, SPACE)
        borderSizer.Add(contentSizer, 0, wx.TOP | wx.BOTTOM | wx.LEFT, SPACE)

        buttonSizer = wx.BoxSizer(wx.VERTICAL)
        findBtn = wx.Button(frame, wx.ID_OK, _("Find"))
        findBtn.SetDefault()
        BTM_SPACE = HALF_SPACE
        if wx.Platform == "__WXMAC__":
            BTM_SPACE = SPACE
        buttonSizer.Add(findBtn, 0, wx.BOTTOM, BTM_SPACE)
        buttonSizer.Add(wx.Button(frame, wx.ID_CANCEL), 0)
        borderSizer.Add(buttonSizer, 0, wx.ALL, SPACE)

        frame.SetSizer(borderSizer)
        frame.Fit()

        frame.CenterOnParent()
        status = frame.ShowModal()

        # save user choice state for this and other Find Dialog Boxes
        findString = findCtrl.GetValue()
        matchCase = matchCaseCtrl.IsChecked()
        wholeWord = wholeWordCtrl.IsChecked()
        regExpr = regExprCtrl.IsChecked()
        self.SaveFindConfig(findString, wholeWord, matchCase, regExpr)

        frame.Destroy()

        if status == wx.ID_OK:
            self.DoFindIn(findString, matchCase, wholeWord, regExpr, currFileOnly=True)
            return True
        else:
            return False
Exemple #18
0
 def OnOK(self, event):
     """
     Calls the OnOK method of all of the OptionDialog's embedded panels
     """
     for name in self._optionsPanels:
         optionsPanel = self._optionsPanels[name]
         optionsPanel.OnOK(event)
         
     sel = self.tree.GetSelection()
     text = self.tree.GetItemText(sel)
     wx.ConfigBase_Get().Write("OptionName",text)
Exemple #19
0
    def LoadOutline(self, view, lineNum=-1, force=False):
        if not self.GetView():
            return

        if hasattr(view, "DoLoadOutlineCallback"):
            self.SaveExpansionState()
            if view.DoLoadOutlineCallback(force=force,lineNum=lineNum):
                self.GetView().OnSort(wx.ConfigBase_Get().ReadInt("OutlineSort", SORT_BY_NONE))
                self.LoadExpansionState()
            else:
                self.SyncToPosition(view,lineNum)
Exemple #20
0
    def InitPositionCache(self):
        """Initialize and load the on disk document position cache.
        @param book_path: path to on disk cache

        """
        self._init = True
        cache_path = os.path.join(appdirs.getAppDataFolder(), "cache")
        if not os.path.exists(cache_path):
            dirutils.MakeDirs(cache_path)
        self._book = os.path.join(cache_path, 'positions')
        if wx.ConfigBase_Get().ReadInt('SAVE_DOCUMENT_POS', True):
            self.LoadBook(self._book)
    def ProcessUpdateUIEvent(self, event):
        if Service.Service.ProcessUpdateUIEvent(self, event):
            return True

        id = event.GetId()
        if id == OutlineService.SORT_ASC:
            event.Enable(True)

            config = wx.ConfigBase_Get()
            sort = config.ReadInt("OutlineSort", SORT_NONE)
            if sort == SORT_ASC:
                self._outlineSortMenu.Check(OutlineService.SORT_ASC, True)
            else:
                self._outlineSortMenu.Check(OutlineService.SORT_ASC, False)

            return True
        elif id == OutlineService.SORT_DESC:
            event.Enable(True)

            config = wx.ConfigBase_Get()
            sort = config.ReadInt("OutlineSort", SORT_NONE)
            if sort == SORT_DESC:
                self._outlineSortMenu.Check(OutlineService.SORT_DESC, True)
            else:
                self._outlineSortMenu.Check(OutlineService.SORT_DESC, False)

            return True
        elif id == OutlineService.SORT_NONE:
            event.Enable(True)

            config = wx.ConfigBase_Get()
            sort = config.ReadInt("OutlineSort", SORT_NONE)
            if sort == SORT_NONE:
                self._outlineSortMenu.Check(OutlineService.SORT_NONE, True)
            else:
                self._outlineSortMenu.Check(OutlineService.SORT_NONE, False)

            return True
        else:
            return False
Exemple #22
0
def ReadSvnUrlList():
    """ Read in list of SNV repository URLs.  First in list is the last one path used. """
    config = wx.ConfigBase_Get()
    urlStringList = config.Read(SVN_REPOSITORY_URL)
    if len(urlStringList):
        urlList = eval(urlStringList)
    else:
        urlList = []
    if len(urlList) == 0:
        svnService = wx.GetApp().GetService(SVNService)
        if svnService and hasattr(svnService, "_defaultURL"):
            urlList.append(svnService._defaultURL)
    return urlList
Exemple #23
0
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id)
        mainSizer = wx.BoxSizer(wx.VERTICAL)                

        config = wx.ConfigBase_Get()

        pathLabel = wx.StaticText(self, -1, _("PHP Executable Path:"))
        path = config.Read("ActiveGridPHPLocation")
        self._pathTextCtrl = wx.TextCtrl(self, -1, path, size = (150, -1))
        self._pathTextCtrl.SetToolTipString(self._pathTextCtrl.GetValue())
        self._pathTextCtrl.SetInsertionPointEnd()
        choosePathButton = wx.Button(self, -1, _("Browse..."))
        pathSizer = wx.BoxSizer(wx.HORIZONTAL)
        HALF_SPACE = 5
        SPACE = 10
        pathSizer.Add(pathLabel, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.TOP, HALF_SPACE)
        pathSizer.Add(self._pathTextCtrl, 1, wx.EXPAND|wx.LEFT|wx.TOP, HALF_SPACE)
        pathSizer.Add(choosePathButton, 0, wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT|wx.TOP, HALF_SPACE)
        wx.EVT_BUTTON(self, choosePathButton.GetId(), self.OnChoosePath)
        mainSizer.Add(pathSizer, 0, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, SPACE)

        iniLabel = wx.StaticText(self, -1, _("php.ini Path:"))
        ini = config.Read("ActiveGridPHPINILocation")
        if not ini:
            if sysutils.isRelease():
                ini = os.path.normpath(os.path.join(appdirs.getSystemDir(), "php.ini"))
            else:
                tmp = self._pathTextCtrl.GetValue().strip()
                if tmp and len(tmp) > 0:
                    ini = os.path.normpath(os.path.join(os.path.dirname(tmp), "php.ini"))

        self._iniTextCtrl = wx.TextCtrl(self, -1, ini, size = (150, -1))
        self._iniTextCtrl.SetToolTipString(self._iniTextCtrl.GetValue())
        self._iniTextCtrl.SetInsertionPointEnd()
        chooseIniButton = wx.Button(self, -1, _("Browse..."))
        iniSizer = wx.BoxSizer(wx.HORIZONTAL)
        HALF_SPACE = 5
        SPACE = 10
        iniSizer.Add(iniLabel, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.TOP, HALF_SPACE)
        iniSizer.Add(self._iniTextCtrl, 1, wx.EXPAND|wx.LEFT|wx.TOP, HALF_SPACE)
        iniSizer.Add(chooseIniButton, 0, wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT|wx.TOP, HALF_SPACE)
        wx.EVT_BUTTON(self, chooseIniButton.GetId(), self.OnChooseIni)
        mainSizer.Add(iniSizer, 0, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, SPACE)

        self._otherOptions = STCTextEditor.TextOptionsPanel(self, -1, configPrefix = "PHP", label = "PHP", hasWordWrap = True, hasTabs = True, addPage=False, hasFolding=False)
        #STCTextEditor.TextOptionsPanel.__init__(self, parent, id, configPrefix = "PHP", label = "PHP", hasWordWrap = True, hasTabs = True)
        mainSizer.Add(self._otherOptions, 0, wx.EXPAND|wx.BOTTOM, SPACE)

        self.SetSizer(mainSizer)
        parent.AddPage(self, _("PHP"))
Exemple #24
0
 def OnOK(self, optionsDialog):
     config = wx.ConfigBase_Get()
     doWordWrapUpdate = config.ReadInt("TextEditorWordWrap", True) != self._wordWrapCheckBox.GetValue()
     config.WriteInt("TextEditorWordWrap", self._wordWrapCheckBox.GetValue())
     doFontUpdate = self._originalTextFont != self._textFont or self._originalTextColor != self._textColor
     config.Write("TextEditorFont", self._textFont.GetNativeFontInfoDesc())
     config.Write("TextEditorColor", "%02x%02x%02x" % (self._textColor.Red(), self._textColor.Green(), self._textColor.Blue()))
     if doWordWrapUpdate or doFontUpdate:
         for document in optionsDialog.GetDocManager().GetDocuments():
             if document.GetDocumentTemplate().GetDocumentType() == TextDocument:
                 if doWordWrapUpdate:
                     document.UpdateAllViews(hint = "Word Wrap")
                 if doFontUpdate:
                     document.UpdateAllViews(hint = "Font")
Exemple #25
0
def WriteSvnUrlList(comboBox):
    """ Save out list of SVN repository URLs from combobox.  Put on top the current selection.  Only save out first 10 from the list """
    urlList = []

    url = comboBox.GetValue()
    if len(url):
        urlList.append(url)

    for i in range(min(comboBox.GetCount(), 10)):
        url = comboBox.GetString(i)
        if url not in urlList:
            urlList.append(url)

    config = wx.ConfigBase_Get()
    config.Write(SVN_REPOSITORY_URL, urlList.__repr__())
Exemple #26
0
def GetAppInfoLanguage(doc=None):
    from activegrid.server.projectmodel import LANGUAGE_DEFAULT
    
    if doc:
        language = doc.GetAppInfo().language
    else:
        language = None
        
    if not language:
        config = wx.ConfigBase_Get()
        language = config.Read(ProjectEditor.APP_LAST_LANGUAGE, LANGUAGE_DEFAULT)
        
        if doc:
            doc.GetAppInfo().language = language  # once it is selected, it must be set.
        
    return language
Exemple #27
0
 def _GetFontAndColorFromConfig(self):
     font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
     config = wx.ConfigBase_Get()
     fontData = config.Read("TextEditorFont", "")
     if fontData:
         nativeFont = wx.NativeFontInfo()
         nativeFont.FromString(fontData)
         font.SetNativeFontInfo(nativeFont)
     color = wx.BLACK
     colorData = config.Read("TextEditorColor", "")
     if colorData:
         red = int("0x" + colorData[0:2], 16)
         green = int("0x" + colorData[2:4], 16)
         blue = int("0x" + colorData[4:6], 16)
         color = wx.Colour(red, green, blue)
     return font, color
Exemple #28
0
    def GetFlags(self):
        """ Load search parameters from registry """
        config = wx.ConfigBase_Get()

        flags = 0
        if config.ReadInt(FIND_MATCHWHOLEWORD, False):
            flags = flags | wx.FR_WHOLEWORD
        if config.ReadInt(FIND_MATCHCASE, False):
            flags = flags | wx.FR_MATCHCASE
        if config.ReadInt(FIND_MATCHUPDOWN, False):
            flags = flags | wx.FR_DOWN
        if config.ReadInt(FIND_MATCHREGEXPR, False):
            flags = flags | FindService.FR_REGEXP
        if config.ReadInt(FIND_MATCHWRAP, False):
            flags = flags | FindService.FR_WRAP
        return flags
Exemple #29
0
 def ShowTipfOfDay(self,must_display=False):
     docManager = self.GetDocumentManager()
     tips_path = os.path.join(sysutilslib.mainModuleDir, "noval", "tool", "data", "tips.txt")
     # wxBug: On Mac, having the updates fire while the tip dialog is at front
     # for some reason messes up menu updates. This seems a low-level wxWidgets bug,
     # so until I track this down, turn off UI updates while the tip dialog is showing.
     if os.path.isfile(tips_path):
         config = wx.ConfigBase_Get()
         index = config.ReadInt("TipIndex", 0)
         if must_display:
             showTip = config.ReadInt("ShowTipAtStartup", 1)
             showTipResult = wx.ShowTip(docManager.FindSuitableParent(), wx.CreateFileTipProvider(tips_path, index), showAtStartup = showTip)
             if showTipResult != showTip:
                 config.WriteInt("ShowTipAtStartup", showTipResult)
         else:
             self.ShowTip(docManager.FindSuitableParent(), wx.CreateFileTipProvider(tips_path, index))
Exemple #30
0
    def OnRightClick(self, event):
        menu = wx.Menu()

        menu.AppendRadioItem(OutlineService.SORT_BY_NONE, _("Unsorted"), _("Display items in original order"))
        menu.AppendRadioItem(OutlineService.SORT_BY_LINE, _("Sort By Line"), _("Display items in line order"))
        menu.AppendRadioItem(OutlineService.SORT_BY_NAME, _("Sort By Name(A-Z)"), _("Display items in name order"))

        config = wx.ConfigBase_Get()
        sort = config.ReadInt("OutlineSort", SORT_BY_NONE)
        if sort == SORT_BY_NONE:
            menu.Check(OutlineService.SORT_BY_NONE, True)
        elif sort == SORT_BY_LINE:
            menu.Check(OutlineService.SORT_BY_LINE, True)
        elif sort == SORT_BY_NAME:
            menu.Check(OutlineService.SORT_BY_NAME, True)

        self.GetControl().PopupMenu(menu, event.GetPosition())
        menu.Destroy()