From 6f4cc90d523907b5c987f5cc8dead0900571c57b Mon Sep 17 00:00:00 2001 From: pas Date: Fri, 30 Mar 2012 23:35:19 +0400 Subject: [PATCH 1/2] Add commandline option for specifying config file --- terminatorlib/config.py | 9 +++++++-- terminatorlib/optionparse.py | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index fc9ed558..eeb61bd8 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -421,6 +421,8 @@ class ConfigBase(Borg): Borg.__init__(self, self.__class__.__name__) self.prepare_attributes() + import optionparse + self.command_line_options = optionparse.options self.load() def prepare_attributes(self): @@ -520,7 +522,10 @@ class ConfigBase(Borg): dbg('ConfigBase::load: config already loaded') return - filename = os.path.join(get_config_dir(), 'config') + if not self.command_line_options.config: + self.command_line_options.config = os.path.join(get_config_dir(), 'config') + filename = self.command_line_options.config + dbg('looking for config file: %s' % filename) try: configfile = open(filename, 'r') @@ -616,7 +621,7 @@ class ConfigBase(Borg): if not os.path.isdir(config_dir): os.makedirs(config_dir) try: - parser.write(open(os.path.join(config_dir, 'config'), 'w')) + parser.write(open(self.command_line_options.config, 'w')) except Exception, ex: err('ConfigBase::save: Unable to save config: %s' % ex) diff --git a/terminatorlib/optionparse.py b/terminatorlib/optionparse.py index 13a2a09d..a7c0e5e6 100755 --- a/terminatorlib/optionparse.py +++ b/terminatorlib/optionparse.py @@ -26,6 +26,8 @@ import config import version from translation import _ +options = None + def execute_cb(option, opt, value, lparser): """Callback for use in parsing execute options""" assert value is None @@ -40,7 +42,6 @@ def parse_options(): """Parse the command line options""" usage = "usage: %prog [options]" - configobj = config.Config() parser = OptionParser(usage) parser.add_option('-v', '--version', action='store_true', dest='version', @@ -55,6 +56,8 @@ def parse_options(): help=_('Hide the window at startup')) parser.add_option('-T', '--title', dest='forcedtitle', help=_('Specify a \ title for the window')) + parser.add_option('-c', '--config', dest='config', help=_('Specify a \ +config file')) parser.add_option('--geometry', dest='geometry', type='string', help=_('Set \ the preferred size and position of the window (see X man page)')) parser.add_option('-e', '--command', dest='command', help=_('Specify a \ @@ -82,6 +85,7 @@ different profile as the default')) parser.add_option(item, dest='dummy', action='store', help=SUPPRESS_HELP) + global options (options, args) = parser.parse_args() if len(args) != 0: parser.error('Additional unexpected arguments found: %s' % args) @@ -118,6 +122,7 @@ different profile as the default')) if options.layout is None: options.layout = 'default' + configobj = config.Config() if options.profile and options.profile not in configobj.list_profiles(): options.profile = None From 9b15e3033efc8651c4b0a35f1a19bf1da70ee422 Mon Sep 17 00:00:00 2001 From: pas Date: Sat, 31 Mar 2012 01:02:57 +0400 Subject: [PATCH 2/2] Focus window after showing it via hotkey the same way Guake does it --- terminatorlib/window.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/terminatorlib/window.py b/terminatorlib/window.py index 8fb4fbf7..36b0bb6d 100755 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -273,6 +273,12 @@ class Window(Container, gtk.Window): if self.position: self.move(self.position[0], self.position[1]) self.show() + self.grab_focus() + try: + t = gtk.gdk.x11_get_server_time(self.window) + except AttributeError: + t = 0 + self.window.focus(t) else: self.position = self.get_position() self.hidefunc()