Merge lp:~pas-anddev/terminator/terminator-fixes into lp:terminator/trunk

Proposed by Pavel Khlebovich
Status: Merged
Merged at revision: 1343
Proposed branch: lp:~pas-anddev/terminator/terminator-fixes
Merge into: lp:terminator/trunk
Diff against target: 96 lines (+19/-3)
3 files modified
terminatorlib/config.py (+7/-2)
terminatorlib/optionparse.py (+6/-1)
terminatorlib/window.py (+6/-0)
To merge this branch: bzr merge lp:~pas-anddev/terminator/terminator-fixes
Reviewer Review Type Date Requested Status
Terminator Pending
Review via email: mp+100247@code.launchpad.net

Description of the change

= Bug 805870 =

modified: window.py
This is the workaround for focus stealing prevention found in Guake and deskbar-applet.

= Bug 806424 =

modified: config.py, optionparser.py
Introduces commandline option --config (with -c as the alias) which makes it possible to use alternative configuration file.

While the issue is better solved by making Config instance a singleton, the fix is a bit dirty, but very noninvasive. It introduces global variable "options" in optionparser, but IMO it's not an issue since commandline arguments are never changed in runtime and variable's visibility is limited to the module.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'terminatorlib/config.py'
--- terminatorlib/config.py 2012-01-14 20:39:00 +0000
+++ terminatorlib/config.py 2012-03-30 21:48:19 +0000
@@ -421,6 +421,8 @@
421 Borg.__init__(self, self.__class__.__name__)421 Borg.__init__(self, self.__class__.__name__)
422422
423 self.prepare_attributes()423 self.prepare_attributes()
424 import optionparse
425 self.command_line_options = optionparse.options
424 self.load()426 self.load()
425427
426 def prepare_attributes(self):428 def prepare_attributes(self):
@@ -520,7 +522,10 @@
520 dbg('ConfigBase::load: config already loaded')522 dbg('ConfigBase::load: config already loaded')
521 return523 return
522524
523 filename = os.path.join(get_config_dir(), 'config')525 if not self.command_line_options.config:
526 self.command_line_options.config = os.path.join(get_config_dir(), 'config')
527 filename = self.command_line_options.config
528
524 dbg('looking for config file: %s' % filename)529 dbg('looking for config file: %s' % filename)
525 try:530 try:
526 configfile = open(filename, 'r')531 configfile = open(filename, 'r')
@@ -616,7 +621,7 @@
616 if not os.path.isdir(config_dir):621 if not os.path.isdir(config_dir):
617 os.makedirs(config_dir)622 os.makedirs(config_dir)
618 try:623 try:
619 parser.write(open(os.path.join(config_dir, 'config'), 'w'))624 parser.write(open(self.command_line_options.config, 'w'))
620 except Exception, ex:625 except Exception, ex:
621 err('ConfigBase::save: Unable to save config: %s' % ex)626 err('ConfigBase::save: Unable to save config: %s' % ex)
622627
623628
=== modified file 'terminatorlib/optionparse.py'
--- terminatorlib/optionparse.py 2010-09-04 09:03:57 +0000
+++ terminatorlib/optionparse.py 2012-03-30 21:48:19 +0000
@@ -26,6 +26,8 @@
26import version26import version
27from translation import _27from translation import _
2828
29options = None
30
29def execute_cb(option, opt, value, lparser):31def execute_cb(option, opt, value, lparser):
30 """Callback for use in parsing execute options"""32 """Callback for use in parsing execute options"""
31 assert value is None33 assert value is None
@@ -40,7 +42,6 @@
40 """Parse the command line options"""42 """Parse the command line options"""
41 usage = "usage: %prog [options]"43 usage = "usage: %prog [options]"
4244
43 configobj = config.Config()
44 parser = OptionParser(usage)45 parser = OptionParser(usage)
4546
46 parser.add_option('-v', '--version', action='store_true', dest='version',47 parser.add_option('-v', '--version', action='store_true', dest='version',
@@ -55,6 +56,8 @@
55 help=_('Hide the window at startup'))56 help=_('Hide the window at startup'))
56 parser.add_option('-T', '--title', dest='forcedtitle', help=_('Specify a \57 parser.add_option('-T', '--title', dest='forcedtitle', help=_('Specify a \
57title for the window'))58title for the window'))
59 parser.add_option('-c', '--config', dest='config', help=_('Specify a \
60config file'))
58 parser.add_option('--geometry', dest='geometry', type='string', help=_('Set \61 parser.add_option('--geometry', dest='geometry', type='string', help=_('Set \
59the preferred size and position of the window (see X man page)'))62the preferred size and position of the window (see X man page)'))
60 parser.add_option('-e', '--command', dest='command', help=_('Specify a \63 parser.add_option('-e', '--command', dest='command', help=_('Specify a \
@@ -82,6 +85,7 @@
82 parser.add_option(item, dest='dummy', action='store',85 parser.add_option(item, dest='dummy', action='store',
83 help=SUPPRESS_HELP)86 help=SUPPRESS_HELP)
8487
88 global options
85 (options, args) = parser.parse_args()89 (options, args) = parser.parse_args()
86 if len(args) != 0:90 if len(args) != 0:
87 parser.error('Additional unexpected arguments found: %s' % args)91 parser.error('Additional unexpected arguments found: %s' % args)
@@ -118,6 +122,7 @@
118 if options.layout is None:122 if options.layout is None:
119 options.layout = 'default'123 options.layout = 'default'
120124
125 configobj = config.Config()
121 if options.profile and options.profile not in configobj.list_profiles():126 if options.profile and options.profile not in configobj.list_profiles():
122 options.profile = None127 options.profile = None
123128
124129
=== modified file 'terminatorlib/window.py'
--- terminatorlib/window.py 2011-08-22 20:05:38 +0000
+++ terminatorlib/window.py 2012-03-30 21:48:19 +0000
@@ -273,6 +273,12 @@
273 if self.position:273 if self.position:
274 self.move(self.position[0], self.position[1])274 self.move(self.position[0], self.position[1])
275 self.show()275 self.show()
276 self.grab_focus()
277 try:
278 t = gtk.gdk.x11_get_server_time(self.window)
279 except AttributeError:
280 t = 0
281 self.window.focus(t)
276 else:282 else:
277 self.position = self.get_position()283 self.position = self.get_position()
278 self.hidefunc()284 self.hidefunc()