示例#1
0
    def createLanguageMenu(self):
        """
        Creates the language menu options based in the
        translations located in Packages/Deviot/Languages
        """
        menu_language = []
        lang_ids = I18n().getLangIds()
        for id_lang in lang_ids:
            lang_names = I18n().getLangNames(id_lang)
            caption = '%s (%s)' % (lang_names[0], lang_names[1])
            options = {}
            options['caption'] = caption
            options['command'] = 'select_language'
            options['args'] = {'id_lang': id_lang}
            options['checkbox'] = True
            menu_language.append(options)

        # get language menu preset
        menu_preset = self.getTemplateMenu(file_name='language.json')
        # load languages
        menu_preset[0]['children'][0]['children'] = menu_language
        # save data as ST menu
        self.saveSublimeMenu(data=menu_preset,
                             sub_folder='language',
                             user_path=True)
示例#2
0
import json
import glob
from re import search

try:
    from . import Serial, Paths
    from .Preferences import Preferences
    from .JSONFile import JSONFile
    from .I18n import I18n
except:
    from libs.Preferences import Preferences
    from libs.JSONFile import JSONFile
    from libs import Serial, Paths
    from libs.I18n import I18n

_ = I18n().translate


class Menu(object):
    '''
    Class to handle the differents option in the plugin menu.
    '''
    def __init__(self):
        '''
        Call the construct of the command library to make the
        differents call by CLI
        '''
        super(Menu, self).__init__()

    def createBoardsMenu(self):
        '''
示例#3
0
文件: Paths.py 项目: margyle/Deviot
def selectDir(window,
              index=-2,
              level=0,
              paths=None,
              key=None,
              func=None,
              label=None):
    try:
        from .Preferences import Preferences
        from .I18n import I18n
    except:
        from libs.Preferences import Preferences
        from libs.I18n import I18n

    if index == -1:
        return ''

    if level > 0 and index == 0:
        sel_path = paths[0].split('(')[1][:-1]
        if func:
            if key:
                save_path = [sel_path, index, level]
                if (key == 'default_path'):
                    sel_path = save_path
                Preferences().set('last_path', save_path)
                func(key, sel_path)
        return

    else:
        if index == 1:
            level -= 1
        elif index > 1:
            level += 1

        default_path = Preferences().get('default_path', False)
        if (not default_path):
            default_path = Preferences().get('last_path', False)

        if (index == -2 and default_path):
            paths = [default_path[0]]
            index = default_path[1]
            level = default_path[2]

        if level <= 0:
            level = 0
            dir_path = '.'
            parent_path = '..'

            paths = listRootPath()

        else:
            sel_path = paths[index]
            if sel_path == ROOT_PATH:
                sel_path = '/'
            dir_path = os.path.abspath(sel_path)
            parent_path = os.path.join(dir_path, '..')

            cur_dir = Dir(dir_path)
            sub_dirs = cur_dir.listDirs()
            paths = [d.getPath() for d in sub_dirs]

        _ = I18n().translate

        paths.insert(0, parent_path)
        paths.insert(0, _('select_cur_dir_{0}', dir_path))

    sublime.set_timeout(
        lambda: window.show_quick_panel(
            paths, lambda index: selectDir(window, index, level, paths, key,
                                           func)), 5)