Merge lp:~274914765-t/terminator/terminator into lp:terminator/trunk

Proposed by 274914765@qq.com
Status: Needs review
Proposed branch: lp:~274914765-t/terminator/terminator
Merge into: lp:terminator/trunk
Diff against target: 487 lines (+114/-42)
9 files modified
.bzrignore (+8/-0)
po/zh_CN.po (+4/-0)
po/zh_HK.po (+4/-0)
po/zh_TW.po (+4/-0)
terminatorlib/config.py (+8/-7)
terminatorlib/preferences.glade (+49/-15)
terminatorlib/prefseditor.py (+13/-5)
terminatorlib/terminator.py (+4/-2)
terminatorlib/window.py (+20/-13)
To merge this branch: bzr merge lp:~274914765-t/terminator/terminator
Reviewer Review Type Date Requested Status
Stephen Boddy Pending
274914765@qq.com Pending
Review via email: mp+283133@code.launchpad.net

This proposal supersedes a proposal from 2016-01-18.

Description of the change

Hi , this time I add a config option: show_on_center, providing a GUI way to set window position.

And I edit the source files with vim , which automatically trims whitespace. i tried to avoid including those, but it didn't work. I am so sorry for that!

To post a comment you must log in.
Revision history for this message
Stephen Boddy (stephen-j-boddy) wrote : Posted in a previous version of this proposal

From a quick look, this is incomplete. There is no GUI way for the user to set this value. If I've understood correctly I'd have to edit the config by hand. Which is fine until I save another setting, and the "position=center" entry gets overwritten... so I change it by hand again... and so on.

Also you are using a text editor that automatically trims whitespace. Unless submitting a change specifically to fix whitespace, please try to avoid including those, as they just add noise (not a problem here, but best to be consistent :-)

review: Needs Fixing
Revision history for this message
274914765@qq.com (274914765-t) wrote : Posted in a previous version of this proposal

> From a quick look, this is incomplete. There is no GUI way for the user to set
> this value. If I've understood correctly I'd have to edit the config by hand.
> Which is fine until I save another setting, and the "position=center" entry
> gets overwritten... so I change it by hand again... and so on.
>
> Also you are using a text editor that automatically trims whitespace. Unless
> submitting a change specifically to fix whitespace, please try to avoid
> including those, as they just add noise (not a problem here, but best to be
> consistent :-)

Why don't we provide a GUI way for the user who wants to set this value? Do you think so?

1712. By 274914765@qq.com

provide chinese support for the config option of show_on_center

Unmerged revisions

1712. By 274914765@qq.com

provide chinese support for the config option of show_on_center

1711. By 274914765@qq.com

merges branch

1710. By 274914765@qq.com

add a config option: show_on_center, provide a GUI way for the user who wants to set window position

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2010-01-14 23:18:41 +0000
3+++ .bzrignore 2016-01-21 11:42:51 +0000
4@@ -5,3 +5,11 @@
5 terminatorlib/meliae
6 _trial_temp
7 terminatorc
8+.idea
9+INSTALLED_FILES
10+MANIFEST
11+build
12+dist
13+data/terminator.appdata.xml
14+data/terminator.desktop
15+po/.intltool-merge-cache
16
17=== modified file 'po/zh_CN.po'
18--- po/zh_CN.po 2016-01-14 05:07:51 +0000
19+++ po/zh_CN.po 2016-01-21 11:42:51 +0000
20@@ -734,6 +734,10 @@
21 msgid "Hide from taskbar"
22 msgstr "从任务栏隐藏"
23
24+#: ../terminatorlib/preferences.glade.h:50
25+msgid "Show on center"
26+msgstr "居中显示"
27+
28 #: ../terminatorlib/preferences.glade.h:51
29 msgid "Window geometry hints"
30 msgstr "窗口大小位置提示"
31
32=== modified file 'po/zh_HK.po'
33--- po/zh_HK.po 2015-12-04 05:11:31 +0000
34+++ po/zh_HK.po 2016-01-21 11:42:51 +0000
35@@ -725,6 +725,10 @@
36 msgid "Hide from taskbar"
37 msgstr ""
38
39+#: ../terminatorlib/preferences.glade.h:50
40+msgid "Show on center"
41+msgstr ""
42+
43 #: ../terminatorlib/preferences.glade.h:51
44 msgid "Window geometry hints"
45 msgstr ""
46
47=== modified file 'po/zh_TW.po'
48--- po/zh_TW.po 2015-12-04 05:11:31 +0000
49+++ po/zh_TW.po 2016-01-21 11:42:51 +0000
50@@ -725,6 +725,10 @@
51 msgid "Hide from taskbar"
52 msgstr ""
53
54+#: ../terminatorlib/preferences.glade.h:50
55+msgid "Show on center"
56+msgstr ""
57+
58 #: ../terminatorlib/preferences.glade.h:51
59 msgid "Window geometry hints"
60 msgstr "視窗形狀小叮嚀"
61
62=== modified file 'terminatorlib/config.py'
63--- terminatorlib/config.py 2015-12-03 14:36:39 +0000
64+++ terminatorlib/config.py 2016-01-21 11:42:51 +0000
65@@ -67,7 +67,7 @@
66 >>> config.options_set({})
67 >>> config.options_get()
68 {}
69->>>
70+>>>
71
72 """
73
74@@ -100,6 +100,7 @@
75 'homogeneous_tabbar' : True,
76 'hide_from_taskbar' : False,
77 'always_on_top' : False,
78+ 'show_on_center' : False,
79 'hide_on_lose_focus' : False,
80 'sticky' : False,
81 'try_posix_regexp' : platform.system() != 'Linux',
82@@ -195,7 +196,7 @@
83 'edit_terminal_title': '<Control><Alt>x',
84 'layout_launcher' : '<Alt>l',
85 'next_profile' : '',
86- 'previous_profile' : '',
87+ 'previous_profile' : '',
88 'help' : 'F1'
89 },
90 'profiles': {
91@@ -279,7 +280,7 @@
92 system_prop_font = None
93 system_focus = None
94 inhibited = None
95-
96+
97 def __init__(self, profile='default'):
98 self.base = ConfigBase()
99 self.set_profile(profile)
100@@ -345,7 +346,7 @@
101
102 def replace_layout(self, name, layout):
103 """Replace an existing layout"""
104- return(self.base.replace_layout(name, layout))
105+ return(self.base.replace_layout(name, layout))
106
107 def del_layout(self, layout):
108 """Delete a layout"""
109@@ -379,7 +380,7 @@
110 else:
111 self.system_prop_font = "Sans 10"
112 self.gconf.notify_add(
113- '/desktop/gnome/interface/font_name',
114+ '/desktop/gnome/interface/font_name',
115 self.on_gconf_notify)
116 return(self.system_prop_font)
117
118@@ -400,7 +401,7 @@
119 else:
120 self.system_mono_font = "Mono 10"
121 self.gconf.notify_add(
122- '/desktop/gnome/interface/monospace_font_name',
123+ '/desktop/gnome/interface/monospace_font_name',
124 self.on_gconf_notify)
125 return(self.system_mono_font)
126
127@@ -679,7 +680,7 @@
128 """Force a reload of the base config"""
129 self.loaded = False
130 self.load()
131-
132+
133 def save(self):
134 """Save the config to a file"""
135 dbg('ConfigBase::save: saving config')
136
137=== modified file 'terminatorlib/preferences.glade'
138--- terminatorlib/preferences.glade 2015-12-03 14:36:39 +0000
139+++ terminatorlib/preferences.glade 2016-01-21 11:42:51 +0000
140@@ -453,9 +453,8 @@
141 <signal name="toggled" handler="on_alwaysontopcheck_toggled" swapped="no"/>
142 </object>
143 <packing>
144- <property name="right_attach">2</property>
145- <property name="top_attach">1</property>
146- <property name="bottom_attach">2</property>
147+ <property name="top_attach">2</property>
148+ <property name="bottom_attach">3</property>
149 <property name="x_options">GTK_FILL</property>
150 <property name="y_options"/>
151 </packing>
152@@ -472,9 +471,8 @@
153 <signal name="toggled" handler="on_stickycheck_toggled" swapped="no"/>
154 </object>
155 <packing>
156- <property name="right_attach">2</property>
157- <property name="top_attach">2</property>
158- <property name="bottom_attach">3</property>
159+ <property name="top_attach">6</property>
160+ <property name="bottom_attach">9</property>
161 <property name="x_options">GTK_FILL</property>
162 <property name="y_options"/>
163 </packing>
164@@ -491,9 +489,8 @@
165 <signal name="toggled" handler="on_hideonlosefocuscheck_toggled" swapped="no"/>
166 </object>
167 <packing>
168- <property name="right_attach">2</property>
169- <property name="top_attach">3</property>
170- <property name="bottom_attach">4</property>
171+ <property name="top_attach">4</property>
172+ <property name="bottom_attach">5</property>
173 <property name="x_options">GTK_FILL</property>
174 <property name="y_options"/>
175 </packing>
176@@ -510,9 +507,8 @@
177 <signal name="toggled" handler="on_hidefromtaskbcheck_toggled" swapped="no"/>
178 </object>
179 <packing>
180- <property name="right_attach">2</property>
181- <property name="top_attach">4</property>
182- <property name="bottom_attach">5</property>
183+ <property name="top_attach">3</property>
184+ <property name="bottom_attach">4</property>
185 <property name="x_options">GTK_FILL</property>
186 <property name="y_options"/>
187 </packing>
188@@ -529,7 +525,6 @@
189 <signal name="toggled" handler="on_wingeomcheck_toggled" swapped="no"/>
190 </object>
191 <packing>
192- <property name="right_attach">2</property>
193 <property name="top_attach">5</property>
194 <property name="bottom_attach">6</property>
195 <property name="x_options">GTK_FILL</property>
196@@ -548,13 +543,51 @@
197 <signal name="toggled" handler="on_dbuscheck_toggled" swapped="no"/>
198 </object>
199 <packing>
200+ <property name="top_attach">1</property>
201+ <property name="bottom_attach">2</property>
202+ <property name="x_options">GTK_FILL</property>
203+ <property name="y_options"></property>
204+ </packing>
205+ </child>
206+ <child>
207+ <object class="GtkCheckButton" id="showoncenter">
208+ <property name="label" translatable="yes">Show on center</property>
209+ <property name="visible">True</property>
210+ <property name="can_focus">True</property>
211+ <property name="receives_default">False</property>
212+ <property name="draw_indicator">True</property>
213+ <signal name="toggled" handler="on_showoncenter_toggled"/>
214+ </object>
215+ <packing>
216+ <property name="left_attach">1</property>
217 <property name="right_attach">2</property>
218- <property name="top_attach">6</property>
219- <property name="bottom_attach">7</property>
220+ <property name="top_attach">1</property>
221+ <property name="bottom_attach">2</property>
222 <property name="x_options">GTK_FILL</property>
223 <property name="y_options"/>
224 </packing>
225 </child>
226+ <child>
227+ <placeholder/>
228+ </child>
229+ <child>
230+ <placeholder/>
231+ </child>
232+ <child>
233+ <placeholder/>
234+ </child>
235+ <child>
236+ <placeholder/>
237+ </child>
238+ <child>
239+ <placeholder/>
240+ </child>
241+ <child>
242+ <placeholder/>
243+ </child>
244+ <child>
245+ <placeholder/>
246+ </child>
247 </object>
248 <packing>
249 <property name="expand">True</property>
250@@ -4258,3 +4291,4 @@
251 </action-widgets>
252 </object>
253 </interface>
254+
255
256=== modified file 'terminatorlib/prefseditor.py'
257--- terminatorlib/prefseditor.py 2015-12-03 14:36:39 +0000
258+++ terminatorlib/prefseditor.py 2016-01-21 11:42:51 +0000
259@@ -152,7 +152,7 @@
260 'edit_tab_title' : _('Edit tab title'),
261 'layout_launcher' : _('Open layout launcher window'),
262 'next_profile' : _('Switch to next profile'),
263- 'previous_profile' : _('Switch to previous profile'),
264+ 'previous_profile' : _('Switch to previous profile'),
265 'help' : _('Open the manual')
266 }
267
268@@ -280,6 +280,9 @@
269 #Always on top
270 widget = guiget('alwaysontopcheck')
271 widget.set_active(self.config['always_on_top'])
272+ #Show on center
273+ widget = guiget('showoncenter')
274+ widget.set_active(self.config['show_on_center'])
275 #Hide on lose focus
276 widget = guiget('hideonlosefocuscheck')
277 widget.set_active(self.config['hide_on_lose_focus'])
278@@ -706,6 +709,11 @@
279 self.config['hide_on_lose_focus'] = widget.get_active()
280 self.config.save()
281
282+ def on_showoncenter_toggled(self, widget):
283+ """Show on center setting changed"""
284+ self.config['show_on_center'] = widget.get_active()
285+ self.config.save()
286+
287 def on_stickycheck_toggled(self, widget):
288 """Sticky setting changed"""
289 self.config['sticky'] = widget.get_active()
290@@ -977,10 +985,10 @@
291
292 customwidget = guiget('cursor_color_custom_radiobutton')
293 colorwidget = guiget('cursor_color')
294-
295+
296 colorwidget.set_sensitive(customwidget.get_active())
297 self.config['cursor_color_fg'] = not customwidget.get_active()
298-
299+
300 try:
301 colorwidget.set_color(gtk.gdk.color_parse(self.config['cursor_color']))
302 except (ValueError, TypeError):
303@@ -1260,7 +1268,7 @@
304 widget.set_sensitive(not value)
305 self.config['use_system_font'] = value
306 self.config.save()
307-
308+
309 if self.config['use_system_font'] == True:
310 fontname = self.config.get_system_mono_font()
311 if fontname is not None:
312@@ -1392,7 +1400,7 @@
313 def on_profile_name_edited(self, cell, path, newtext):
314 """Update a profile name"""
315 oldname_broken = cell.get_property('text')
316-
317+
318 guiget = self.builder.get_object
319 treeview = guiget('profilelist')
320 treeselection = treeview.get_selection()
321
322=== modified file 'terminatorlib/terminator.py'
323--- terminatorlib/terminator.py 2015-12-02 19:57:31 +0000
324+++ terminatorlib/terminator.py 2016-01-21 11:42:51 +0000
325@@ -271,6 +271,8 @@
326 parts = layout[windef]['position'].split(':')
327 if len(parts) == 2:
328 window.move(int(parts[0]), int(parts[1]))
329+ elif layout[windef]['position'].lower() == 'center':
330+ window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
331 if layout[windef].has_key('size'):
332 parts = layout[windef]['size']
333 winx = int(parts[0])
334@@ -357,9 +359,9 @@
335 if self.config['handle_size'] in xrange(0, 6):
336 gtk.rc_parse_string("""
337 style "terminator-paned-style" {
338- GtkPaned::handle_size = %s
339+ GtkPaned::handle_size = %s
340 }
341- class "GtkPaned" style "terminator-paned-style"
342+ class "GtkPaned" style "terminator-paned-style"
343 """ % self.config['handle_size'])
344 gtk.rc_reset_styles(gtk.settings_get_default())
345
346
347=== modified file 'terminatorlib/window.py'
348--- terminatorlib/window.py 2015-11-30 15:19:39 +0000
349+++ terminatorlib/window.py 2016-01-21 11:42:51 +0000
350@@ -78,16 +78,16 @@
351
352 if options.role:
353 self.set_role(options.role)
354-
355+
356 if options.classname is not None:
357 self.set_wmclass(options.classname, self.wmclass_class)
358-
359+
360 if options.forcedicon is not None:
361 icon_to_apply = options.forcedicon
362
363 if options.geometry:
364 if not self.parse_geometry(options.geometry):
365- err('Window::__init__: Unable to parse geometry: %s' %
366+ err('Window::__init__: Unable to parse geometry: %s' %
367 options.geometry)
368
369 self.apply_icon(icon_to_apply)
370@@ -142,6 +142,7 @@
371 borderless = self.config['borderless']
372 skiptaskbar = self.config['hide_from_taskbar']
373 alwaysontop = self.config['always_on_top']
374+ showoncenter = self.config['show_on_center']
375 sticky = self.config['sticky']
376
377 if options:
378@@ -158,6 +159,7 @@
379 self.set_maximised(maximise)
380 self.set_borderless(borderless)
381 self.set_always_on_top(alwaysontop)
382+ self.set_show_on_center(showoncenter)
383 self.set_real_transparency()
384 self.set_sticky(sticky)
385 if self.hidebound:
386@@ -275,7 +277,7 @@
387 def confirm_close(self, window, type):
388 """Display a confirmation dialog when the user is closing multiple
389 terminals in one window"""
390-
391+
392 return(not (self.construct_confirm_close(window, type) == gtk.RESPONSE_ACCEPT))
393
394 def on_destroy_event(self, widget, data=None):
395@@ -313,7 +315,7 @@
396 # pylint: disable-msg=W0613
397 def on_window_state_changed(self, window, event):
398 """Handle the state of the window changing"""
399- self.isfullscreen = bool(event.new_window_state &
400+ self.isfullscreen = bool(event.new_window_state &
401 gtk.gdk.WINDOW_STATE_FULLSCREEN)
402 self.ismaximised = bool(event.new_window_state &
403 gtk.gdk.WINDOW_STATE_MAXIMIZED)
404@@ -356,6 +358,11 @@
405 """Set the always on top window hint from the supplied value"""
406 self.set_keep_above(value)
407
408+ def set_show_on_center(self, value):
409+ """Set show on the center of window from the supplied value"""
410+ if value == True:
411+ self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
412+
413 def set_sticky(self, value):
414 """Set the sticky hint from the supplied value"""
415 if value == True:
416@@ -376,7 +383,7 @@
417
418 if colormap:
419 self.set_colormap(colormap)
420-
421+
422 def show(self, startup=False):
423 """Undo the startup show request if started in hidden mode"""
424 #Present is necessary to grab focus when window is hidden from taskbar.
425@@ -458,7 +465,7 @@
426 container = maker.make('VPaned')
427 else:
428 container = maker.make('HPaned')
429-
430+
431 self.set_pos_by_ratio = True
432
433 if not sibling:
434@@ -481,7 +488,7 @@
435 container.add(term)
436 container.show_all()
437 sibling.grab_focus()
438-
439+
440 while gtk.events_pending():
441 gtk.main_iteration_do(False)
442 self.set_pos_by_ratio = False
443@@ -507,7 +514,7 @@
444 self.set_property('term_zoomed', True)
445
446 if font_scale:
447- widget.cnxids.new(widget, 'size-allocate',
448+ widget.cnxids.new(widget, 'size-allocate',
449 widget.zoom_scale, self.zoom_data)
450
451 widget.grab_focus()
452@@ -554,7 +561,7 @@
453 p.rotate(widget, clockwise)
454 self.show_all()
455 widget.grab_focus()
456-
457+
458 while gtk.events_pending():
459 gtk.main_iteration_do(False)
460 self.set_pos_by_ratio = False
461@@ -648,7 +655,7 @@
462 extra_height = win_height - total_font_height
463
464 dbg('setting geometry hints: (ewidth:%s)(eheight:%s),\
465-(fwidth:%s)(fheight:%s)' % (extra_width, extra_height,
466+(fwidth:%s)(fheight:%s)' % (extra_width, extra_height,
467 font_width, font_height))
468 self.set_geometry_hints(self, -1, -1, -1, -1, extra_width,
469 extra_height, font_width, font_height, -1.0, -1.0)
470@@ -743,7 +750,7 @@
471 if not maker.isinstance(notebook, 'Notebook'):
472 dbg('note in a notebook, refusing to ungroup tab')
473 return
474-
475+
476 self.set_groups(None, self.get_visible_terminals())
477
478 def move_tab(self, widget, direction):
479@@ -773,7 +780,7 @@
480 else:
481 err('unknown direction: %s' % direction)
482 return
483-
484+
485 notebook.reorder_child(child, page)
486
487 def navigate_terminal(self, terminal, direction):