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

Proposed by Pavel Khlebovich on 2012-03-30
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 2012-03-30 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
1=== modified file 'terminatorlib/config.py'
2--- terminatorlib/config.py 2012-01-14 20:39:00 +0000
3+++ terminatorlib/config.py 2012-03-30 21:48:19 +0000
4@@ -421,6 +421,8 @@
5 Borg.__init__(self, self.__class__.__name__)
6
7 self.prepare_attributes()
8+ import optionparse
9+ self.command_line_options = optionparse.options
10 self.load()
11
12 def prepare_attributes(self):
13@@ -520,7 +522,10 @@
14 dbg('ConfigBase::load: config already loaded')
15 return
16
17- filename = os.path.join(get_config_dir(), 'config')
18+ if not self.command_line_options.config:
19+ self.command_line_options.config = os.path.join(get_config_dir(), 'config')
20+ filename = self.command_line_options.config
21+
22 dbg('looking for config file: %s' % filename)
23 try:
24 configfile = open(filename, 'r')
25@@ -616,7 +621,7 @@
26 if not os.path.isdir(config_dir):
27 os.makedirs(config_dir)
28 try:
29- parser.write(open(os.path.join(config_dir, 'config'), 'w'))
30+ parser.write(open(self.command_line_options.config, 'w'))
31 except Exception, ex:
32 err('ConfigBase::save: Unable to save config: %s' % ex)
33
34
35=== modified file 'terminatorlib/optionparse.py'
36--- terminatorlib/optionparse.py 2010-09-04 09:03:57 +0000
37+++ terminatorlib/optionparse.py 2012-03-30 21:48:19 +0000
38@@ -26,6 +26,8 @@
39 import version
40 from translation import _
41
42+options = None
43+
44 def execute_cb(option, opt, value, lparser):
45 """Callback for use in parsing execute options"""
46 assert value is None
47@@ -40,7 +42,6 @@
48 """Parse the command line options"""
49 usage = "usage: %prog [options]"
50
51- configobj = config.Config()
52 parser = OptionParser(usage)
53
54 parser.add_option('-v', '--version', action='store_true', dest='version',
55@@ -55,6 +56,8 @@
56 help=_('Hide the window at startup'))
57 parser.add_option('-T', '--title', dest='forcedtitle', help=_('Specify a \
58 title for the window'))
59+ parser.add_option('-c', '--config', dest='config', help=_('Specify a \
60+config file'))
61 parser.add_option('--geometry', dest='geometry', type='string', help=_('Set \
62 the preferred size and position of the window (see X man page)'))
63 parser.add_option('-e', '--command', dest='command', help=_('Specify a \
64@@ -82,6 +85,7 @@
65 parser.add_option(item, dest='dummy', action='store',
66 help=SUPPRESS_HELP)
67
68+ global options
69 (options, args) = parser.parse_args()
70 if len(args) != 0:
71 parser.error('Additional unexpected arguments found: %s' % args)
72@@ -118,6 +122,7 @@
73 if options.layout is None:
74 options.layout = 'default'
75
76+ configobj = config.Config()
77 if options.profile and options.profile not in configobj.list_profiles():
78 options.profile = None
79
80
81=== modified file 'terminatorlib/window.py'
82--- terminatorlib/window.py 2011-08-22 20:05:38 +0000
83+++ terminatorlib/window.py 2012-03-30 21:48:19 +0000
84@@ -273,6 +273,12 @@
85 if self.position:
86 self.move(self.position[0], self.position[1])
87 self.show()
88+ self.grab_focus()
89+ try:
90+ t = gtk.gdk.x11_get_server_time(self.window)
91+ except AttributeError:
92+ t = 0
93+ self.window.focus(t)
94 else:
95 self.position = self.get_position()
96 self.hidefunc()