Пример #1
0
 def add_feed(self):
     dialog = [
         ('string', 'caption', tr('Caption'), tr('Feed Caption:'), None),
         ('string', 'url', tr('New Feed URL'), tr('Feed URL:'), None),
     ]
     from modules.EasyGuider import EasyDialog
     easy = EasyDialog.EasyDialog(self.sharewin, tr('Add Feed'), dialog)
     values = None
     if easy.ShowModal() == wx.ID_OK:
         values = easy.GetValue()
     easy.Destroy()
     if values:
         #add feed to db
         item, node = self.sharewin.get_cur_node()
         RssDb.init(Globals.rss_dbfile)
         f = RssDb.Feed(category_id=node['data']['id'],
                        title=values["caption"],
                        link=values['url'])
         f.commit()
         data = {
             'type': 'rss',
             'level': 'feed',
             'caption': values["caption"],
             'data': {
                 'url': values['url'],
                 'homeurl': '',
                 'save': False,
                 'id': f.id
             }
         }
         obj = self.sharewin.addnode(item, data=data)
         self.add_feed_ids(node['data']['id'], f.id, obj)
Пример #2
0
    def add_category(self):
        dialog = [
            ('string', 'caption', tr('New Category'), tr('Category Name:'),
             None),
        ]
        from modules.EasyGuider import EasyDialog
        easy = EasyDialog.EasyDialog(self.sharewin, tr('Input'), dialog)
        values = None
        if easy.ShowModal() == wx.ID_OK:
            values = easy.GetValue()
        easy.Destroy()
        if values:
            #add category to db
            import RssDb
            RssDb.init(Globals.rss_dbfile)
            category = RssDb.Category(title=values["caption"])
            category.save()

            data = {
                'type': 'rss',
                'level': 'category',
                'caption': values['caption'],
                'data': {
                    'save': False,
                    'id': category.id
                }
            }
            root, node = self.sharewin.get_cur_node()
            obj = self.sharewin.addnode(root, data=data)
            self.add_category_ids(category.id, obj)
Пример #3
0
def OnDocumentVoiceConfig(win, event):
    if not win.pytts:
        try:
            import pyTTS
            win.pytts = pyTTS.Create()
            win.pytts_flag = pyTTS.tts_is_xml, pyTTS.tts_async
            win.pytts.OnEndStream = win.OnTTSEndStream
        except:
            error.traceback()
            common.showerror(win, tr("Can't import pyTTS module, please install it first."))
            return
    voices = win.pytts.GetVoiceNames()
    if not voices:
        common.showerror(win, tr("There is no available voices installed"))
        return
    if not win.pref.voice_name:
        win.pref.voice_name = voices[0]
    dialog = [
            ('single', 'voice_name', win.pref.voice_name, tr('Voice names:'), zip(voices, voices)),
            ('int', 'tts_rate', win.pref.tts_rate, tr('TTS speak rate:'), None)
        ]
    from modules.EasyGuider import EasyDialog
    dlg = EasyDialog.EasyDialog(win, title=tr("Text to Speech setting"), elements=dialog)
    values = None
    if dlg.ShowModal() == wx.ID_OK:
        values = dlg.GetValue()
    dlg.Destroy()
    win.pref.tts_rate = values['tts_rate']
    win.pref.voice_name = values['voice_name']
    win.pref.save()
Пример #4
0
 def feed_properties(self, item):
     node = self.sharewin.get_node(item)
     feed_id = node['data']['id']
     f = RssDb.Feed.get(feed_id)
     elements = [
         ('string', 'caption', f.title, tr('Feed Caption:'), None),
         ('string', 'url', f.link, tr('Feed URL:'), None),
         ('string', 'homeurl', f.homelink, tr('Home URL:'), None),
     ]
     from modules.EasyGuider import EasyDialog
     easy = EasyDialog.EasyDialog(self.sharewin, tr('Feed Properties'),
                                  elements)
     values = None
     if easy.ShowModal() == wx.ID_OK:
         values = easy.GetValue()
     easy.Destroy()
     if values:
         feed_id = node['data']['id']
         node['caption'] = values['caption']
         node['url'] = values['url']
         node['homeurl'] = values['homeurl']
         #            self.sharewin.save()
         f.title = values['caption']
         f.link = values['url']
         f.homelink = values['homeurl']
         f.commit()
         self.refresh_feed_unread(feed_id)
Пример #5
0
 def cate_properties(self, item):
     node = self.sharewin.get_node(item)
     elements = [('string', 'caption', node['caption'],
                  tr('Category Name:'), None)]
     from modules.EasyGuider import EasyDialog
     easy = EasyDialog.EasyDialog(self.sharewin, tr('Category Properties'),
                                  elements)
     values = None
     if easy.ShowModal() == wx.ID_OK:
         values = easy.GetValue()
     easy.Destroy()
     if values:
         cate_id = node['data']['id']
         node['caption'] = values['caption']
         #            self.sharewin.save()
         c = RssDb.Category.get(cate_id)
         c.title = values['caption']
         c.commit()
         self.sharewin.tree.SetItemText(item, c.title)
Пример #6
0
def get_django_name(win):
    elements = [
        ('string', 'appname', '', tr('Django application name:'), None),
        ('bool', 'template', False,
         tr('Create templates directory in app folder:'), None),
        ('bool', 'template_tags', False,
         tr('Create templatetags directory in app folder:'), None),
    ]
    from modules.EasyGuider import EasyDialog
    easy = EasyDialog.EasyDialog(win, title=tr('Input'), elements=elements)
    values = None
    if easy.ShowModal() == wx.ID_OK:
        values = easy.GetValue()
        appname = values['appname']
        if not appname:
            common.showerror(win,
                             tr("Django application name cannot be empty."))
    easy.Destroy()
    return values
Пример #7
0
    def OnSetProject(self, event=None):
        item = self.tree.GetSelection()
        from modules import dict4ini
        filename = self.get_node_filename(item)
        proj_file = os.path.join(filename, '_project')
        name = []
        if os.path.exists(proj_file):
            ini = dict4ini.DictIni(proj_file)
            name = ini.default.get('projectname', [])
        dialog = [
            ('multi', 'project_name', name, tr('Project Names'),
             self.project_names),
        ]
        from modules.EasyGuider import EasyDialog
        dlg = EasyDialog.EasyDialog(self.mainframe,
                                    title=tr("Project Setting"),
                                    elements=dialog)
        values = None
        if dlg.ShowModal() == wx.ID_OK:
            values = dlg.GetValue()
        dlg.Destroy()
        if values is not None:
            filename = self.get_node_filename(item)
            proj_file = os.path.join(filename, '_project')
            ini = dict4ini.DictIni(proj_file)
            ini.default.projectname = values['project_name']
            self.callplugin('remove_project', ini,
                            list(set(name) - set(values['project_name'])))
            self.callplugin('set_project', ini, values['project_name'])
            ini.save()

            old_project_name = name
            new_project_name = ini.default.projectname
            #add check project plugin call point
            path = filename
            project_names = common.getCurrentPathProjectName(path)
            self.callplugin(
                'project_end', self,
                list(set(old_project_name) - set(new_project_name)), path)
            self.callplugin(
                'project_begin', self,
                list(set(new_project_name) - set(old_project_name)), path)
Пример #8
0
def OnDocbookEnclose(editor):
    #find the docbook.acp file
    docbookini = common.getConfigPathFile('docbook_xml.ini')
    from modules import dict4ini
    x = dict4ini.DictIni(docbookini)
    taglist = x.default.taglist
    taglist.sort()
    #popup a selection win
    if taglist:
        from modules.EasyGuider import EasyDialog
        dialog = [
            ('single', 'tagname', taglist[0], tr('Select a tag:'), taglist),
        ]
        dlg = EasyDialog.EasyDialog(editor,
                                    tr('Select a DocBook Element Name'),
                                    dialog)
        values = None
        if dlg.ShowModal() == wx.ID_OK:
            values = dlg.GetValue()
        dlg.Destroy()
        if values:
            tagname = values['tagname']
            text = editor.GetSelectedText()
            editor.BeginUndoAction()
            if text:
                editor.ReplaceSelection('')
            if x.tag_values.has_key(tagname):
                settext(editor, [x.tag_values[tagname]])
            else:
                editor.AddText('<%s>%s</%s>' % (tagname, text, tagname))
                pos = editor.GetCurrentPos() - len(values['tagname']) - 3
                editor.GotoPos(pos)
            editor.EndUndoAction()
    else:
        common.showerror(
            editor, tr("There are not tags defined in conf/docbook_xml.ini."))
def get_acp_files(win):
    i = get_inputassistant_obj(win)
    i.install_acp(win, win.languagename)

    files = []
    objs = i.get_acp(win.languagename)
    if objs:
        files = [obj.filename for obj in objs]

    b = glob.glob(os.path.join(Globals.workpath, '*.acp')) + glob.glob(
        os.path.join(Globals.confpath, '*.acp'))
    afiles = set(b)
    afiles.difference_update(files)
    afiles = list(afiles)
    afiles.sort()

    sfiles = [obj.filename for obj in win.custom_assistant]

    elements = [
        ('static', 'applied', '\n'.join(files), tr('Default acp files:'),
         None),
        ('multi', 'custom', sfiles, tr('Available acp files:'), afiles),
    ]
    from modules.EasyGuider import EasyDialog
    easy = EasyDialog.EasyDialog(win,
                                 title=tr('Acp Selector'),
                                 elements=elements)
    values = None
    if easy.ShowModal() == wx.ID_OK:
        values = easy.GetValue()
        win.custom_assistant = []
        for f in values['custom']:
            win.custom_assistant.append(i.get_assistant(f))
        i.install_acp(win, win.languagename, True)

    easy.Destroy()