示例#1
0
def MakeThemeTool(tool_id):
    """Makes a themed bitmap for the tool book of the plugin dialog.
    @param tool_id: An art identifier id
    @return: 32x32 bitmap
    @todo: why does drawing a bitmap overlay on gtk not draw on transparent area

    """
    osize = Profile_Get('ICON_SZ', default=(24, 24))
    Profile_Set('ICON_SZ', (32, 32))
    base = wx.ArtProvider.GetBitmap(str(tool_id), wx.ART_TOOLBAR)
    Profile_Set('ICON_SZ', osize)
    if not base.IsOk():
        base = wx.ArtProvider.GetBitmap(wx.ART_WARNING,
                                        wx.ART_TOOLBAR,
                                        size=(32, 32))

    over = wx.ArtProvider.GetBitmap(str(ed_glob.ID_PLUGMGR), wx.ART_MENU)
    if over.IsOk():
        # Draw overlay onto button
        mdc = wx.MemoryDC()
        mdc.SelectObject(base)
        mdc.SetBrush(wx.TRANSPARENT_BRUSH)
        mdc.SetPen(wx.TRANSPARENT_PEN)
        mdc.DrawBitmap(over, 15, 15, False)
        mdc.SelectObject(wx.NullBitmap)

    return base
示例#2
0
    def GetFontDictionary(self, default=True):
        """Does a system lookup to build a default set of fonts using
        ten point fonts as the standard size.
        @keyword default: return the default dictionary of fonts, else return
                          the current running dictionary of fonts if it exists.
        @return: font dictionary (primary, secondary) + (size, size2)

        """
        if hasattr(self, 'fonts') and not default:
            return self.fonts

        font = Profile_Get('FONT1', 'font', None)
        if font is not None:
            mfont = font
        else:
            mfont = wx.Font(10, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL,
                            wx.FONTWEIGHT_NORMAL)
            Profile_Set('FONT1', mfont, 'font')
        primary = mfont.GetFaceName()

        font = Profile_Get('FONT2', 'font', None)
        if font is None:
            font = wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                           wx.FONTWEIGHT_NORMAL)
            Profile_Set('FONT2', font, 'font')
        secondary = font.GetFaceName()
        faces = {
            self.FONT_PRIMARY: primary,
            self.FONT_SECONDARY: secondary,
            self.FONT_SIZE: mfont.GetPointSize(),
            self.FONT_SIZE2: font.GetPointSize(),
            self.FONT_SIZE3: mfont.GetPointSize() - 2
        }
        return faces
示例#3
0
    def OnFindClose(self, evt):
        """Destroy Find Dialog After Cancel is clicked in it
        @param evt: event that called this handler

        """
        if self._finddlg is not None:
            # Save the lookin values for next time dialog is shown
            self._li_choices = self._finddlg.GetLookinChoices()
            self._li_sel = self._finddlg.GetLookinSelection()
            self._filters = self._finddlg.GetFileFilters()

            # Store in profile. Only save most recent 5 in history
            if len(self._li_choices) > 5:
                choices = self._li_choices[-5:]
            else:
                choices = self._li_choices

            # Save the most recent choices of search locations
            Profile_Set('SEARCH_LOC', choices)
            Profile_Set('SEARCH_FILTER', self._filters)

            # Destroy it
#            self._finddlg.Destroy()

#        self._finddlg = None
        evt.Skip()
 def OnCheckBox(self, event):
     """Update checkbox linked configuration options"""
     e_obj = event.GetEventObject()
     config = Profile_Get(PYTOOL_CONFIG, default=dict())
     if e_obj is self._check_on_save_cb:
         config[TLC_COMPILE_ON_SAVE] = e_obj.Value
         Profile_Set(PYTOOL_CONFIG, config)
     elif e_obj is self._load_proj_cb:
         config[TLC_LOAD_LAST_PROJECT] = e_obj.Value
         Profile_Set(PYTOOL_CONFIG, config)
示例#5
0
 def OnSortOpt(self, event):
     """Handle changes to sorting options"""
     e_obj = event.GetEventObject()
     cfgobj = Profile_Get(CB_PROFILE_KEY, default=dict())
     if e_obj == self._alpha:
         cfgobj[CB_SORT_OPTION] = CB_ALPHA_SORT  # Set Alpha mode
         Profile_Set(CB_PROFILE_KEY, cfgobj)  # generate update msg
     elif e_obj == self._linenum:
         cfgobj[CB_SORT_OPTION] = CB_LINENUM_SORT  # Set Line number mode
         Profile_Set(CB_PROFILE_KEY, cfgobj)  # generate update msg
     else:
         event.Skip()
示例#6
0
 def OnCheck(self, event):
     """Update the configuration"""
     e_obj = event.GetEventObject()
     value = e_obj.GetValue()
     cfg = Profile_Get(handlers.CONFIG_KEY, default=dict())
     if e_obj is self.savecb:
         cfg['autosave'] = value
         Profile_Set(handlers.CONFIG_KEY, cfg)
     elif e_obj is self.saveallcb:
         cfg['autosaveall'] = value
         Profile_Set(handlers.CONFIG_KEY, cfg)
     else:
         event.Skip()
示例#7
0
 def OnShowBrowser(self, evt):
     """Shows the filebrowser"""
     if evt.GetId() == ID_FILEBROWSE:
         mgr = self._mw.GetFrameManager()
         pane = mgr.GetPane(PANE_NAME)
         if pane.IsShown():
             pane.Hide()
             Profile_Set('SHOW_FB', False)
         else:
             pane.Show()
             Profile_Set('SHOW_FB', True)
         mgr.Update()
     else:
         evt.Skip()
示例#8
0
    def OnPerspectiveMenu(self, evt):
        """Handles menu events generated by the managers control menu.
        @param evt: event that called this handler

        """
        e_id = evt.GetId()
        if e_id == ID_SAVE_PERSPECTIVE:
            name = wx.GetTextFromUser(_("Perspective Name"), \
                                      _("Save Perspective"))
            if name:
                self.AddPerspective(name, p_data=None)
                self.SavePerspectives()
                Profile_Set('DEFAULT_VIEW', name)

                # It may make sense to update all windows to use this
                # perspective at this point but it may be an unexpected
                # event to happen when there is many windows open. Will
                # leave this to future consideration.
                for mainw in wx.GetApp().GetMainWindows():
                    mainw.AddPerspective(name, self._viewset[name])

        elif e_id == ID_DELETE_PERSPECTIVE:
            views = [
                view for view in self._viewset.keys()
                if view != AUTO_PERSPECTIVE
            ]
            name = wx.GetSingleChoice(_("Perspective to Delete"),
                                      _("Delete Perspective"), views)

            if name:
                self.RemovePerspective(name)
                self.SavePerspectives()
                for mainw in wx.GetApp().GetMainWindows():
                    mainw.RemovePerspective(name)
            else:
                pass

            # Update all windows data sets
            for mainw in wx.GetApp().GetMainWindows():
                mainw.LoadPerspectives()

        elif e_id in self._ids + [ID_AUTO_PERSPECTIVE]:
            if e_id == ID_AUTO_PERSPECTIVE:
                Profile_Set('DEFAULT_VIEW', AUTO_PERSPECTIVE)
                self.SetAutoPerspective()
            else:
                self.SetPerspectiveById(e_id)
        else:
            evt.Skip()
示例#9
0
    def LoadStyleSheet(self, style_sheet, force=False):
        """Loads a custom style sheet and returns True on success
        @param style_sheet: path to style sheet to load
        @keyword force: Force re-parse of style sheet, default is to use cached
                        data when available
        @return: whether style sheet was loaded or not
        @rtype: bool

        """
        if isinstance(style_sheet, basestring) and \
           os.path.exists(style_sheet) and \
           ((force or style_sheet not in StyleMgr.STYLES) or \
             style_sheet != self.style_set):
            reader = util.GetFileReader(style_sheet)
            if reader == -1:
                self.LOG("[ed_style][err] Failed to open style sheet: %s" %
                         style_sheet)
                return False
            ret_val = self.SetStyles(style_sheet,
                                     self.ParseStyleData(reader.read()))
            reader.close()
            return ret_val
        elif style_sheet not in StyleMgr.STYLES:
            self.LOG("[ed_style][warn] Style sheet %s does not exists" %
                     style_sheet)
            # Reset to default style
            if Profile_Get('SYNTHEME') != 'default':
                Profile_Set('SYNTHEME', 'default')
                self.SetStyles('default', DEF_STYLE_DICT)
            return False
        else:
            self.LOG("[ed_style][info] Using cached style data")
            return True
 def OnAddPyExe(self, event):
     """Handle adding new item"""
     config = Profile_Get(PYTOOL_CONFIG, default=dict())
     curpy = config.get(TLC_PYTHON_PATH, u'')
     cdir = ebmlib.GetPathName(curpy)
     cfile = ebmlib.GetFileName(curpy)
     dlg = wx.FileDialog(self,
                         _("Select Python Executable"),
                         cdir,
                         cfile,
                         style=wx.FD_OPEN | wx.FD_CHANGE_DIR
                         | wx.FD_FILE_MUST_EXIST)
     dlg.CenterOnParent()
     result = dlg.ShowModal()
     path = dlg.Path
     dlg.Destroy()
     if result != wx.ID_OK:
         return
     if path and os.path.exists(path):
         allpy = config.get(TLC_ALL_PYTHON_PATHS, [])
         if path not in allpy:
             # Update collection of paths
             allpy.append(path)
             allpy.sort()
             config[TLC_ALL_PYTHON_PATHS] = allpy
             # Update Choice control and current selection
             self._python_path_combo.Items = allpy
             self._python_path_combo.StringSelection = path
             # Update current python to the newly added one
             config[TLC_PYTHON_PATH] = path
             Profile_Set(PYTOOL_CONFIG, config)
示例#11
0
    def __init__(self, parent):
        super(ConfigNotebook, self).__init__(parent)

        # Make sure config has been initialized
        prefs = Profile_Get(handlers.CONFIG_KEY, default=None)
        if prefs is None:
            buff = eclib.OutputBuffer(self)
            buff.Hide()
            Profile_Set(
                handlers.CONFIG_KEY,
                dict(autoclear=False,
                     errorbeep=False,
                     wrapoutput=False,
                     defaultf=buff.GetDefaultForeground().Get(),
                     defaultb=buff.GetDefaultBackground().Get(),
                     errorf=buff.GetErrorForeground().Get(),
                     errorb=buff.GetErrorBackground().Get(),
                     infof=buff.GetInfoForeground().Get(),
                     infob=buff.GetInfoBackground().Get(),
                     warnf=buff.GetWarningForeground().Get(),
                     warnb=buff.GetWarningBackground().Get()))
            buff.Destroy()

        # Setup
        self.AddPage(ConfigPanel(self), _("General"))
        self.AddPage(OutputPanel(self), _("Output"))
        self.AddPage(MiscPanel(self), _("Misc"))
示例#12
0
 def OnCheck(self, evt):
     """Handle checkbox events"""
     e_id = evt.GetId()
     e_val = evt.GetEventObject().GetValue()
     cfg = Profile_Get(handlers.CONFIG_KEY, default=dict())
     if e_id == ID_AUTOCLEAR:
         cfg['autoclear'] = e_val
         Profile_Set(handlers.CONFIG_KEY, cfg)
     elif e_id == ID_ERROR_BEEP:
         cfg['errorbeep'] = e_val
         Profile_Set(handlers.CONFIG_KEY, cfg)
     elif e_id == ID_WRAP_OUTPUT:
         cfg['wrapoutput'] = e_val
         Profile_Set(handlers.CONFIG_KEY, cfg)
     else:
         evt.Skip()
示例#13
0
    def __init__(self, parent):
        eclib.ControlBox.__init__(self, parent)

        # Attributes
        self._log = wx.GetApp().GetLog()
        self._mw = self.__FindMainWindow()
        self._buffer = OutputDisplay(self)
        self._fnames = list()
        self._chFiles = None # Created in __DoLayout
        self._worker = None
        self._busy = False
        self._isready = False
        self._config = dict(file='', lang=0,
                            cfile='', clang=0,
                            last='', lastlang=0,
                            prelang=0, largs='',
                            lcmd='')
        self._prefs = Profile_Get(cfgdlg.LAUNCH_PREFS, default=None)

        # Setup
        self.__DoLayout()
        hstate = Profile_Get(LAUNCH_KEY)
        if hstate is not None:
            handlers.SetState(hstate)
        if self._prefs is None:
            Profile_Set(cfgdlg.LAUNCH_PREFS,
                        dict(autoclear=False,
                             defaultf=self._buffer.GetDefaultForeground().Get(),
                             defaultb=self._buffer.GetDefaultBackground().Get(),
                             errorf=self._buffer.GetErrorForeground().Get(),
                             errorb=self._buffer.GetErrorBackground().Get(),
                             infof=self._buffer.GetInfoForeground().Get(),
                             infob=self._buffer.GetInfoBackground().Get(),
                             warnf=self._buffer.GetWarningForeground().Get(),
                             warnb=self._buffer.GetWarningBackground().Get()))
            self._prefs = Profile_Get(cfgdlg.LAUNCH_PREFS)

        self.UpdateBufferColors()
        cbuffer = self._mw.GetNotebook().GetCurrentCtrl()
        self.SetupControlBar(cbuffer)
        self._config['lang'] = GetLangIdFromMW(self._mw)
        self.UpdateCurrentFiles(self._config['lang'])
        self.SetFile(GetTextBuffer(self._mw).GetFileName())

        # Setup filetype settings
        self.RefreshControlBar()

        # Event Handlers
        self.Bind(wx.EVT_BUTTON, self.OnButton)
        self.Bind(wx.EVT_CHOICE, self.OnChoice)
        ed_msg.Subscribe(self.OnPageChanged, ed_msg.EDMSG_UI_NB_CHANGED)
        ed_msg.Subscribe(self.OnFileOpened, ed_msg.EDMSG_FILE_OPENED)
        ed_msg.Subscribe(self.OnThemeChanged, ed_msg.EDMSG_THEME_CHANGED)
        ed_msg.Subscribe(self.OnLexerChange, ed_msg.EDMSG_UI_STC_LEXER)
        ed_msg.Subscribe(self.OnConfigExit, cfgdlg.EDMSG_LAUNCH_CFG_EXIT)
        ed_msg.Subscribe(self.OnRunMsg, MSG_RUN_LAUNCH)
        ed_msg.Subscribe(self.OnRunLastMsg, MSG_RUN_LAST)
        ed_msg.RegisterCallback(self._CanLaunch, REQUEST_ACTIVE)
        ed_msg.RegisterCallback(self._CanReLaunch, REQUEST_RELAUNCH)
示例#14
0
    def OnConfigExit(self, msg):
        """Update current state when the config dialog has been closed
        @param msg: Message Object

        """
        util.Log("[Launch][info] Saving config to profile")
        self.RefreshControlBar()
        Profile_Set(LAUNCH_KEY, handlers.GetState())
示例#15
0
    def SetShellTheme(self, style):
        """Set the color scheme used by the shell
        @param style: style sheet name (string)

        """
        self._shell_style = style
        Profile_Set(PYSHELL_STYLE, style)
        self.UpdateAllStyles(style)
示例#16
0
 def SaveExpressions(self):
     """Store expressions to the users persistent configuration"""
     config = Profile_Get(ToolConfig.PYTOOL_CONFIG, default=dict())
     expressionslist = []
     for expression in self.expressions:
         expressionslist.append((expression, self.expressions[expression]))
     config[ToolConfig.TLC_EXPRESSIONS] = expressionslist
     Profile_Set(ToolConfig.PYTOOL_CONFIG, config)
示例#17
0
def UpdateBufferStyles(sheet):
    """Update the style used in all buffers
    @param sheet: Style sheet to use

    """
    # Only update if the sheet has changed
    if sheet is not None:
        Profile_Set('SYNTHEME', sheet)
示例#18
0
 def OnCheck(self, evt):
     """Update Profile"""
     e_obj = evt.GetEventObject()
     cfgobj = Profile_Get(FB_PROF_KEY, default=dict())
     if e_obj in (self._vhf_cb, self._sync_cb):
         cfgobj[e_obj.Name] = e_obj.Value
         Profile_Set(FB_PROF_KEY, cfgobj)
     else:
         evt.Skip()
示例#19
0
 def SaveCurrentSession(self):
     """Save the current session"""
     session = Profile_Get('LAST_SESSION')
     # Compatibility with older session data
     if not isinstance(session, basestring) or not len(session):
         session = os.path.join(ed_glob.CONFIG['SESSION_DIR'],
                                u"__default.session")
         Profile_Set('LAST_SESSION', session)
     self.SaveSessionFile(session)
示例#20
0
    def OnCheckBox(self, evt):
        evt_obj = evt.GetEventObject()
        if evt_obj in (self._autorb, self._manualrb):
            self._config[TLC_AUTO_RUN] = self._autorb.GetValue()
        else:
            evt.Skip()
            return

        Profile_Set(PYTOOL_CONFIG, self._config)
    def OnRunModeCheckBox(self, evt):
        evt_obj = evt.GetEventObject()
        config = Profile_Get(PYTOOL_CONFIG, default=dict())
        if evt_obj in (self._lintautorb, self._lintmanualrb):
            config[TLC_LINT_AUTORUN] = self._lintautorb.GetValue()
        else:
            evt.Skip()
            return

        Profile_Set(PYTOOL_CONFIG, config)
    def OnIgnoreSysExitCheckBox(self, evt):
        config = Profile_Get(PYTOOL_CONFIG, default=dict())
        if evt.GetEventObject() is self._igsyscb:
            igsys = self._igsyscb.GetValue()
            config[TLC_IGNORE_SYSEXIT] = igsys
        else:
            evt.Skip()
            return

        Profile_Set(PYTOOL_CONFIG, config)
示例#23
0
 def OnColor(self, evt):
     """Handle color change events"""
     e_id = evt.GetId()
     color = COLOR_MAP.get(e_id, None)
     cfg = Profile_Get(handlers.CONFIG_KEY, default=dict())
     if color is not None:
         cfg[color] = evt.GetValue().Get()
         Profile_Set(handlers.CONFIG_KEY, cfg)
     else:
         evt.Skip()
    def OnTrapExceptionsCheckBox(self, evt):
        config = Profile_Get(PYTOOL_CONFIG, default=dict())
        if evt.GetEventObject() is self._trapcb:
            trap = self._trapcb.GetValue()
            config[TLC_TRAP_EXCEPTIONS] = trap
            RpdbDebugger().set_trap_unhandled_exceptions(trap)
        else:
            evt.Skip()
            return

        Profile_Set(PYTOOL_CONFIG, config)
示例#25
0
    def SaveCurrentSession(self):
        """Save the current session"""
        if self._ses_load:
            return

        session = Profile_Get('LAST_SESSION')
        # Compatibility with older session data
        if not isinstance(session, basestring) or not len(session):
            mgr = ed_session.EdSessionMgr()
            session = mgr.DefaultSession
            Profile_Set('LAST_SESSION', session)
        self.SaveSessionFile(session)
    def OnSynchronicityCheckBox(self, evt):
        evt_obj = evt.GetEventObject()
        config = Profile_Get(PYTOOL_CONFIG, default=dict())
        if evt_obj is self._synccb:
            synchronicity = self._synccb.GetValue()
            config[TLC_SYNCHRONICITY] = synchronicity
            RpdbDebugger().set_synchronicity(synchronicity)
        else:
            evt.Skip()
            return

        Profile_Set(PYTOOL_CONFIG, config)
示例#27
0
    def __init__(self, parent):
        ctrlbox.ControlBox.__init__(self, parent)

        # Attributes
        self._mw = self.__FindMainWindow()
        self._buffer = OutputDisplay(self)
        self._fnames = list()
        self._chFiles = None  # Created in __DoLayout
        self._worker = None
        self._busy = False
        self._isready = False
        self._config = dict(file='',
                            lang=0,
                            cfile='',
                            clang=0,
                            last='',
                            lastlang=0,
                            prelang=0)
        self._prefs = Profile_Get('Launch.Prefs', default=None)

        # Setup
        self.__DoLayout()
        hstate = Profile_Get(LAUNCH_KEY)
        if hstate is not None:
            handlers.SetState(hstate)
        if self._prefs is None:
            Profile_Set(
                'Launch.Prefs',
                dict(autoclear=False,
                     defaultf=self._buffer.GetDefaultForeground().Get(),
                     defaultb=self._buffer.GetDefaultBackground().Get(),
                     errorf=self._buffer.GetErrorForeground().Get(),
                     errorb=self._buffer.GetErrorBackground().Get(),
                     infof=self._buffer.GetInfoForeground().Get(),
                     infob=self._buffer.GetInfoBackground().Get(),
                     warnf=self._buffer.GetWarningForeground().Get(),
                     warnb=self._buffer.GetWarningBackground().Get()))
            self._prefs = Profile_Get('Launch.Prefs')

        self.UpdateBufferColors()
        cbuffer = self._mw.GetNotebook().GetCurrentCtrl()
        self.SetupControlBar(cbuffer)

        # Event Handlers
        self.Bind(wx.EVT_BUTTON, self.OnButton)
        self.Bind(wx.EVT_CHOICE, self.OnChoice)
        ed_msg.Subscribe(self.OnPageChanged, ed_msg.EDMSG_UI_NB_CHANGED)
        ed_msg.Subscribe(self.OnFileOpened, ed_msg.EDMSG_FILE_OPENED)
        ed_msg.Subscribe(self.OnThemeChanged, ed_msg.EDMSG_THEME_CHANGED)
        ed_msg.Subscribe(self.OnConfigExit, cfgdlg.EDMSG_LAUNCH_CFG_EXIT)
        ed_msg.Subscribe(self.OnRunMsg, MSG_RUN_LAUNCH)
        ed_msg.RegisterCallback(self._CanLaunch, REQUEST_ACTIVE)
示例#28
0
 def UpdateLineBuffCfg(self):
     """Update the line buffer configuration"""
     util.Log("[Launch][info] LineBuffer config updated")
     val = self._bufftxt.GetValue()
     if self._bufftxt.IsInBounds(val):
         cfg = Profile_Get(handlers.CONFIG_KEY, default=dict())
         cval = cfg.get('linebuffer', DEFAULT_LINEBUFFER)
         ival = int(val)
         if ival == 0:
             ival = -1
         if ival != cval:
             cfg['linebuffer'] = ival
             Profile_Set(handlers.CONFIG_KEY, cfg)
示例#29
0
def UpdateBufferStyles(sheet):
    """Update the style used in all buffers
    @sheet: Style sheet to use

    """
    # Only update if the sheet has changed
    if sheet is None or sheet == Profile_Get('SYNTHEME'):
        return

    Profile_Set('SYNTHEME', sheet)
    for mainw in wx.GetApp().GetMainWindows():
        mainw.nb.UpdateTextControls('UpdateAllStyles')
        mainw.SetStatusText(_("Changed color scheme to %s") % \
                            sheet, ed_glob.SB_INFO)
示例#30
0
 def StoreState(cls):
     """Store the state of this handler"""
     if cls.meta.transient:
         util.Log(
             "[Launch][info] Transient XML handler: settings will not persist"
         )
         # TODO: update XML configuration file?
         return
     data = Profile_Get(CONFIG_KEY, default=dict())
     cdata = data.get(cls.GetName(), None)
     if data != cdata:
         util.Log("[Launch][info] Store config: %s" % cls.GetName())
         data[cls.GetName()] = (cls.meta.default, cls.meta.commands.items())
         Profile_Set(CONFIG_KEY, data)