def install_send_to_types(types, application=None, injint=None): """Install application in the SendTo menu for 1 or more types. application should be the full path to the AppDir. If application is None then it is the running program which will be installed. The user is asked to confirm the setting for each type.""" if len(types) < 1: return if not application: application = rox.app_dir if application[0] != '/': application = os.path.abspath(application) win = InstallList( application, _('type handler'), 'SendTo', types, _("""The application can handle files of these types. Click on OK to add it to the SendTo menu for the type of file, and also the customized File menu.""" ), check=False) if win.run() != int(rox.g.RESPONSE_ACCEPT): win.destroy() return types = win.get_active() for tname in types: mime_type = mime.lookup(tname) sname = save_path( SITE, 'SendTo/.%s_%s' % (mime_type.media, mime_type.subtype), win.aname) _install_at(sname, application, injint) types = win.get_uninstall() for tname in types: mime_type = mime.lookup(tname) sname = save_path( SITE, 'SendTo/.%s_%s' % (mime_type.media, mime_type.subtype), win.aname) os.remove(sname) win.destroy()
def _install_type_handler(types, dir, desc, application=None, overwrite=True, info=None): if len(types)<1: return if not application: application=rox.app_dir if application[0]!='/': application=os.path.abspath(application) win=InstallList(application, desc, dir, types, info) if win.run()!=rox.g.RESPONSE_ACCEPT: win.destroy() return types=win.get_active() for tname in types: type = mime.lookup(tname) sname=rox.choices.save(dir, '%s_%s' % (type.media, type.subtype)) os.symlink(application, sname+'.tmp') os.rename(sname+'.tmp', sname) win.destroy()
def install_send_to_types(types, application=None, injint=None): """Install application in the SendTo menu for 1 or more types. application should be the full path to the AppDir. If application is None then it is the running program which will be installed. The user is asked to confirm the setting for each type.""" if len(types)<1: return if not application: application=rox.app_dir if application[0]!='/': application=os.path.abspath(application) win=InstallList(application, _('type handler'), 'SendTo', types, _("""The application can handle files of these types. Click on OK to add it to the SendTo menu for the type of file, and also the customized File menu."""), check=False) if win.run()!=int(rox.g.RESPONSE_ACCEPT): win.destroy() return types=win.get_active() for tname in types: mime_type=mime.lookup(tname) sname=save_path(SITE, 'SendTo/.%s_%s' % (mime_type.media, mime_type.subtype), win.aname) _install_at(sname, application, injint) types=win.get_uninstall() for tname in types: mime_type=mime.lookup(tname) sname=save_path(SITE, 'SendTo/.%s_%s' % (mime_type.media, mime_type.subtype), win.aname) os.remove(sname) win.destroy()
def _install_type_handler(types, dir, desc, application=None, overwrite=True, info=None, injint=None): """Internal function. Does the work of setting MIME-types or MIME-thumb""" if len(types) < 1: return if not application: application = rox.app_dir if application[0] != '/': application = os.path.abspath(application) win = InstallList(application, desc, dir, types, info) if win.run() != int(rox.g.RESPONSE_ACCEPT): win.destroy() return try: types = win.get_active() for tname in types: mime_type = mime.lookup(tname) sname = save_path(SITE, dir, '%s_%s' % (mime_type.media, mime_type.subtype)) _install_at(sname, application, injint) types = win.get_uninstall() for tname in types: mime_type = mime.lookup(tname) sname = save_path(SITE, dir, '%s_%s' % (mime_type.media, mime_type.subtype)) os.remove(sname) finally: win.destroy()
def _install_type_handler(types, dir, desc, application=None, overwrite=True, info=None, injint=None): """Internal function. Does the work of setting MIME-types or MIME-thumb""" if len(types)<1: return if not application: application=rox.app_dir if application[0]!='/': application=os.path.abspath(application) win=InstallList(application, desc, dir, types, info) if win.run()!=int(rox.g.RESPONSE_ACCEPT): win.destroy() return try: types=win.get_active() for tname in types: mime_type = mime.lookup(tname) sname=save_path(SITE, dir, '%s_%s' % (mime_type.media, mime_type.subtype)) _install_at(sname, application, injint) types=win.get_uninstall() for tname in types: mime_type = mime.lookup(tname) sname=save_path(SITE, dir, '%s_%s' % (mime_type.media, mime_type.subtype)) os.remove(sname) finally: win.destroy()
def load_types(self): """Load list of types into window""" self.model.clear() for tname in self.types: mime_type=mime.lookup(tname) if self.check: old=load_path(self.site, self.dir, '%s_%s' % (mime_type.media, mime_type.subtype)) if old and os.path.islink(old): old=os.readlink(old) oname=os.path.basename(old) elif old: oname='script' else: oname='' if old==self.app: dinstall=False can_un=True else: dinstall=True can_un=False else: dinstall=True can_un=False oname='' icon=mime_type.get_icon(mime.ICON_SIZE_SMALL) titer=self.model.append() self.model.set(titer, _TNAME, tname, _COMMENT, mime_type.get_comment(), _INSTALL, dinstall, _UNINSTALL, False, _IS_OURS, can_un) if self.check: self.model.set(titer, _CURRENT, oname) if icon: self.model.set(titer, _ICON, icon)
def load_types(self): """Load list of types into window""" self.model.clear() for tname in self.types: mime_type = mime.lookup(tname) if self.check: old = load_path(self.site, self.dir, '%s_%s' % (mime_type.media, mime_type.subtype)) if old and os.path.islink(old): old = os.readlink(old) oname = os.path.basename(old) elif old: oname = 'script' else: oname = '' if old == self.app: dinstall = False can_un = True else: dinstall = True can_un = False else: dinstall = True can_un = False oname = '' icon = mime_type.get_icon(mime.ICON_SIZE_SMALL) titer = self.model.append() self.model.set(titer, _TNAME, tname, _COMMENT, mime_type.get_comment(), _INSTALL, dinstall, _UNINSTALL, False, _IS_OURS, can_un) if self.check: self.model.set(titer, _CURRENT, oname) if icon: self.model.set(titer, _ICON, icon)