src/mailto.py
def choose_client(self, query):
        """Select a new email client."""
        from client import Client
        client = Client(self.wf)
        log.debug('Choosing email client')
        log.debug('query : %s', query)
        # apps list a list of tuples [(name, path), ...]
        apps = [d for d in client.all_email_apps if os.path.exists(d['path'])]

        log.debug('%d email clients on system', len(apps))

        if client.empty:
            if not client.updating:
                client.update(force=True)

            self.wf.add_item(
                'Application list is currently empty',
                'Check back in a few seconds after the update has finished',
                icon=ICON_WARNING,
            )
            self.wf.send_feedback()
            return

        if not query:  # Show current setting
            if not self.wf.settings.get('default_app'):  # System default
                app = client.system_default_app
                self.wf.add_item(
                    'Current Email Client: System Default',
                    app['path'],
                    # modifier_subtitles={'cmd': app['bundleid']},
                    copytext=app['bundleid'],
                    largetext=app['bundleid'],
                    icon=app['path'],
                    icontype='fileicon'
                )
            else:  # User has already set a preferred client
                app = client.default_app
                self.wf.add_item(
                    'Current Email Client: {}'.format(app['name']),
                    app['path'],
                    # modifier_subtitles={'cmd': app['bundleid']},
                    copytext=app['bundleid'],
                    largetext=app['bundleid'],
                    icon=app['path'],
                    icontype='fileicon'
                )
                # Offer to reset
                app = client.system_default_app
                it = self.wf.add_item(
                    'System Default ({})'.format(app['name']),
                    app['path'],
                    arg='setclient DEFAULT',
                    valid=True,
                    copytext=app['bundleid'],
                    largetext=app['bundleid'],
                    icon=app['path'],
                    icontype='fileicon'
                )
                it.add_modifier('cmd', subtitle=app['bundleid'])

        if query:
            apps = self.wf.filter(query, apps, lambda d: d['name'],
                                  min_score=30)

        if not apps:
            self.wf.add_item('Nothing found',
                             'Try another query',
                             icon=ICON_WARNING)

        for app in apps:
            arg = 'setclient {}'.format(quote(app['path']))
            it = self.wf.add_item(
                app['name'],
                app['path'],
                valid=True,
                copytext=app['bundleid'],
                largetext=app['bundleid'],
                arg=arg,
                icon=app['path'],
                icontype='fileicon',
            )
            it.add_modifier('cmd', subtitle=app['bundleid'])

        self.wf.send_feedback()
Select a new email client.
Select a new email client.
Select a new email client .
def choose_client(self, query):
        from client import Client
        client = Client(self.wf)
        log.debug('Choosing email client')
        log.debug('query : %s', query)
        apps = [d for d in client.all_email_apps if os.path.exists(d['path'])]
        log.debug('%d email clients on system', len(apps))
        if client.empty:
            if not client.updating:
                client.update(force=True)
            self.wf.add_item(
                'Application list is currently empty',
                'Check back in a few seconds after the update has finished',
                icon=ICON_WARNING,
            )
            self.wf.send_feedback()
            return
        if not query:  
            if not self.wf.settings.get('default_app'):  
                app = client.system_default_app
                self.wf.add_item(
                    'Current Email Client: System Default',
                    app['path'],
                    copytext=app['bundleid'],
                    largetext=app['bundleid'],
                    icon=app['path'],
                    icontype='fileicon'
                )
            else:  
                app = client.default_app
                self.wf.add_item(
                    'Current Email Client: {}'.format(app['name']),
                    app['path'],
                    copytext=app['bundleid'],
                    largetext=app['bundleid'],
                    icon=app['path'],
                    icontype='fileicon'
                )
                app = client.system_default_app
                it = self.wf.add_item(
                    'System Default ({})'.format(app['name']),
                    app['path'],
                    arg='setclient DEFAULT',
                    valid=True,
                    copytext=app['bundleid'],
                    largetext=app['bundleid'],
                    icon=app['path'],
                    icontype='fileicon'
                )
                it.add_modifier('cmd', subtitle=app['bundleid'])
        if query:
            apps = self.wf.filter(query, apps, lambda d: d['name'],
                                  min_score=30)
        if not apps:
            self.wf.add_item('Nothing found',
                             'Try another query',
                             icon=ICON_WARNING)
        for app in apps:
            arg = 'setclient {}'.format(quote(app['path']))
            it = self.wf.add_item(
                app['name'],
                app['path'],
                valid=True,
                copytext=app['bundleid'],
                largetext=app['bundleid'],
                arg=arg,
                icon=app['path'],
                icontype='fileicon',
            )
            it.add_modifier('cmd', subtitle=app['bundleid'])
        self.wf.send_feedback()
def choose_client ( self , query ) : from client import Client client = Client ( self . wf ) log . debug ( 'Choosing email client' ) log . debug ( 'query : %s' , query ) apps = [ d for d in client . all_email_apps if os . path . exists ( d [ 'path' ] ) ] log . debug ( '%d email clients on system' , len ( apps ) ) if client . empty : if not client . updating : client . update ( force = True ) self . wf . add_item ( 'Application list is currently empty' , 'Check back in a few seconds after the update has finished' , icon = ICON_WARNING , ) self . wf . send_feedback ( ) return if not query : if not self . wf . settings . get ( 'default_app' ) : app = client . system_default_app self . wf . add_item ( 'Current Email Client: System Default' , app [ 'path' ] , copytext = app [ 'bundleid' ] , largetext = app [ 'bundleid' ] , icon = app [ 'path' ] , icontype = 'fileicon' ) else : app = client . default_app self . wf . add_item ( 'Current Email Client: {}' . format ( app [ 'name' ] ) , app [ 'path' ] , copytext = app [ 'bundleid' ] , largetext = app [ 'bundleid' ] , icon = app [ 'path' ] , icontype = 'fileicon' ) app = client . system_default_app it = self . wf . add_item ( 'System Default ({})' . format ( app [ 'name' ] ) , app [ 'path' ] , arg = 'setclient DEFAULT' , valid = True , copytext = app [ 'bundleid' ] , largetext = app [ 'bundleid' ] , icon = app [ 'path' ] , icontype = 'fileicon' ) it . add_modifier ( 'cmd' , subtitle = app [ 'bundleid' ] ) if query : apps = self . wf . filter ( query , apps , lambda d : d [ 'name' ] , min_score = 30 ) if not apps : self . wf . add_item ( 'Nothing found' , 'Try another query' , icon = ICON_WARNING ) for app in apps : arg = 'setclient {}' . format ( quote ( app [ 'path' ] ) ) it = self . wf . add_item ( app [ 'name' ] , app [ 'path' ] , valid = True , copytext = app [ 'bundleid' ] , largetext = app [ 'bundleid' ] , arg = arg , icon = app [ 'path' ] , icontype = 'fileicon' , ) it . add_modifier ( 'cmd' , subtitle = app [ 'bundleid' ] ) self . wf . send_feedback ( )
Select a new email client.
Select a new email client .
"""Select a new email client.""" # apps list a list of tuples [(name, path), ...] # Show current setting # System default # modifier_subtitles={'cmd': app['bundleid']}, # User has already set a preferred client # modifier_subtitles={'cmd': app['bundleid']}, # Offer to reset
self
query