def __init__(self): self.plugin_name = self.__class__.__name__ self.config = config.Config() self.check_config() self.match = self.config.plugin_get(self.plugin_name, 'match') if hasattr(self.match, 'decode'): self.match = self.match.decode('string_escape')
def __init__(self): self.terminator = Terminator() self.terminator.register_launcher_window(self) self.config = config.Config() self.config.base.reload() self.builder = Gtk.Builder() try: # Figure out where our library is on-disk so we can open our UI (head, _tail) = os.path.split(config.__file__) librarypath = os.path.join(head, 'layoutlauncher.glade') with open(librarypath, mode='rt') as f: gladedata = f.read() except Exception as ex: print("Failed to find layoutlauncher.glade") print(ex) return self.builder.add_from_string(gladedata) self.window = self.builder.get_object('layoutlauncherwin') icon_theme = Gtk.IconTheme.get_default() if icon_theme.lookup_icon('terminator-layout', 48, 0): self.window.set_icon_name('terminator-layout') else: dbg('Unable to load Terminator layout launcher icon') icon = self.window.render_icon(Gtk.STOCK_DIALOG_INFO, Gtk.IconSize.BUTTON) self.window.set_icon(icon) self.builder.connect_signals(self) self.window.connect('destroy', self.on_destroy_event) self.window.show_all() self.layouttreeview = self.builder.get_object('layoutlist') self.layouttreestore = self.builder.get_object('layoutstore') self.update_layouts()
def __init__(self): self.plugin_name = self.__class__.__name__ self.current_path = None self.config = config.Config() self.check_config() self.match = self.config.plugin_get(self.plugin_name, 'match') for key, val in REPLACE.iteritems(): self.match = self.match.replace(key, val)
def __init__(self): self.plugin_name = self.__class__.__name__ self.current_path = None self.config = config.Config() current_config = self.config.plugin_get_config(self.plugin_name) # Default editor if not current_config: self.config.plugin_set(self.plugin_name, 'editor', 'gvim') self.config.plugin_set(self.plugin_name, 'options', "--remote-silent") self.config.save()
def save_config(self, dialog): terminator = terminatorlib.terminator.Terminator() for terminal in terminator.terminals: terminal.pluginng_matches_add(self) self.config = {} conf = config.Config() conf.plugin_del_config(self.plugin_name) gen_store = dialog.gen_store action_stores = dialog.action_stores for pattern_row in gen_store: pkey, enabled, name, pattern = dialog.get_gen_fields(pattern_row) self.config[pkey] = {} self.config[pkey]['enabled'] = enabled self.config[pkey]['name'] = name self.config[pkey]['pattern'] = pattern self.config[pkey]['actions'] = {} for action_row in action_stores[pkey]: ckey, command, in_terminal, use_shell = dialog.get_action_fields( action_row) self.config[pkey]['actions'][ckey] = {} self.config[pkey]['actions'][ckey]['command'] = command self.config[pkey]['actions'][ckey]['in-terminal'] = in_terminal self.config[pkey]['actions'][ckey]['use-shell'] = use_shell conf.plugin_set(self.plugin_name, pkey, self.config[pkey]) conf.save() # we don't want to save compiled REs for pkey in self.config.keys(): self.config[pkey]['compiled'] = re.compile( self.config[pkey]['pattern']) # Update terminal config for terminal in terminator.terminals: terminal.pluginng_matches_add(self)
def read_config(self): self.config = {} conf = config.Config() saved_config = conf.plugin_get_config(self.plugin_name) if saved_config: for key in saved_config: s = saved_config[key] if not (s.has_key('pattern') and s.has_key('name') and s.has_key('actions') and len(s['actions']) > 0): continue if not self.config.has_key(key): self.config[key] = {} self.config[key]['enabled'] = s.as_bool('enabled') self.config[key]['name'] = s['name'] self.config[key]['pattern'] = s['pattern'] self.config[key]['compiled'] = re.compile( self.config[key]['pattern']) self.config[key]['actions'] = s['actions'] for action in s['actions'].keys(): if s['actions'][action].has_key('in-terminal'): self.config[key]['actions'][action]['in-terminal'] = s[ 'actions'][action].as_bool('in-terminal') else: # default value self.config[key]['actions'][action][ 'in-terminal'] = True if s['actions'][action].has_key('use-shell'): self.config[key]['actions'][action]['use-shell'] = s[ 'actions'][action].as_bool('use-shell') else: # default value self.config[key]['actions'][action][ 'use-shell'] = False
def parse_options(): '''Parse the arguments''' argslist = [ (( '-v', '--version', ), dict(action='version', version='%(prog)s {}'.format(version.APP_VERSION), help=_('Display program version'))), (( '-m', '--maximise', ), dict(action='store_true', dest='maximise', help=_('Maximize the window'))), (( '-f', '--fullscreen', ), dict(action='store_true', dest='fullscreen', help=_('Make the window fill the screen'))), (( '-b', '--borderless', ), dict(action='store_true', dest='borderless', help=_('Disable window borders'))), (( '-H', '--hidden', ), dict(action='store_true', dest='hidden', help=_('Hide the window at startup'))), (( '-T', '--title', ), dict(action='store', dest='forcedtitle', metavar='TITLE', help=_('Specify a title for the window'))), (('--geometry', ), dict( action='store', dest='geometry', type=str, metavar='GEOMETRY', help= _('Set the preferred size and position of the window (see X man page)' ))), (( '-g', '--config', ), dict(action='store', dest='config', metavar='CONFIG', help=_('Specify a config file'))), (('--working-directory', ), dict(action='store', dest='working_directory', metavar='DIR', help=_('Set the working directory'))), (( '-i', '--icon', ), dict(action='store', dest='forcedicon', metavar='ICON', help=_('Set a custom icon for the window (by file or name)'))), (( '-r', '--role', ), dict(action='store', dest='role', metavar='ROLE', help=_('Set a custom WM_WINDOW_ROLE property on the window'))), (( '-l', '--layout', ), dict(action='store', dest='layout', default='default', help=_('Launch with the given layout'))), (( '-s', '--select-layout', ), dict(action='store_true', dest='select', help=_('Select a layout from a list'))), (( '-p', '--profile', ), dict(action='store', dest='profile', default='default', help=_('Use a different profile as the default'))), (( '-u', '--no-dbus', ), dict(action='store_true', dest='nodbus', help=_('Disable DBus'))), (( '-d', '--debug', ), dict( action='count', dest='debug', default=0, help=_('Enable debugging information (twice for debug server)'))), (('--debug-classes', ), dict( action='store', dest='debug_classes', help=_('Comma separated list of classes to limit debugging to'))), (('--debug-methods', ), dict( action='store', dest='debug_methods', help=_('Comma separated list of methods to limit debugging to'))), (('--new-tab', ), dict( action='store_true', dest='new_tab', help=_('If Terminator is already running, just open a new tab'))), (( '-e', '--execute', ), dict(action='store', dest='execute', nargs=REMAINDER, help=_('Use the rest of arguments as a command to execute'))), ] parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter) for args, kwargs in argslist: parser.add_argument(*args, **kwargs) parser.parse_args(namespace=options) if options.debug_classes or options.debug_methods: if not options.debug > 0: options.debug = 1 if options.debug: util.DEBUG = True if options.debug > 1: util.DEBUGFILES = True if options.debug_classes: classes = options.debug_classes.split(',') for item in classes: util.DEBUGCLASSES.append(item.strip()) if options.debug_methods: methods = options.debug_methods.split(',') for item in methods: util.DEBUGMETHODS.append(item.strip()) if options.working_directory: path = os.path.expanduser(options.working_directory) if os.path.isdir(path): options.working_directory = path os.chdir(path) else: err('OptionParse::parse_options: %s does not exist' % path) options.working_directory = None configobj = config.Config() if options.layout not in configobj.list_layouts(): options.layout = 'default' if options.profile not in configobj.list_profiles(): options.profile = 'default' if util.DEBUG == True: dbg('OptionParse::parse_options: command line options: %s' % options)