Another round of backported fixes from Egmont's patch-o-rama

* Fix drag and drop of a link from Firefox / Chrome
* Fix profile re-use when opening new window
* Fix scrollbar position on current terminals when changed in prefs
This commit is contained in:
Stephen Boddy 2015-12-02 22:33:05 +01:00
commit b160d1464e
3 changed files with 29 additions and 27 deletions

View File

@ -62,6 +62,12 @@ terminator trunk:
(Steve Boddy) (Steve Boddy)
* Remove invalid double-quote (") from the pathchar for url regex * Remove invalid double-quote (") from the pathchar for url regex
matching (Steve Boddy, LP#1514578) matching (Steve Boddy, LP#1514578)
* Fix drag and drop of a link from Firefox / Chrome (Egmont
Koblinger, LP#1518705)
* Fix profile re-use when opening new window (Egmont Koblinger,
LP#1520705)
* Fix scrollbar position on current terminals when changed in
prefs (Egmont Koblinger, LP#1520761)
terminator 0.98: terminator 0.98:
* Features * Features

View File

@ -76,6 +76,7 @@ class Terminal(gtk.VBox):
} }
TARGET_TYPE_VTE = 8 TARGET_TYPE_VTE = 8
TARGET_TYPE_MOZ = 9
MOUSEBUTTON_LEFT = 1 MOUSEBUTTON_LEFT = 1
MOUSEBUTTON_MIDDLE = 2 MOUSEBUTTON_MIDDLE = 2
@ -85,7 +86,6 @@ class Terminal(gtk.VBox):
vte = None vte = None
terminalbox = None terminalbox = None
scrollbar = None scrollbar = None
scrollbar_position = None
titlebar = None titlebar = None
searchbar = None searchbar = None
@ -243,19 +243,9 @@ class Terminal(gtk.VBox):
terminalbox = gtk.HBox() terminalbox = gtk.HBox()
self.scrollbar = gtk.VScrollbar(self.vte.get_adjustment()) self.scrollbar = gtk.VScrollbar(self.vte.get_adjustment())
self.scrollbar.set_no_show_all(True)
self.scrollbar_position = self.config['scrollbar_position']
if self.scrollbar_position not in ('hidden', 'disabled'): terminalbox.pack_start(self.vte, True, True, 0)
self.scrollbar.show() terminalbox.pack_start(self.scrollbar, False, True, 0)
if self.scrollbar_position == 'left':
func = terminalbox.pack_end
else:
func = terminalbox.pack_start
func(self.vte)
func(self.scrollbar, False)
terminalbox.show_all() terminalbox.show_all()
return(terminalbox) return(terminalbox)
@ -355,7 +345,7 @@ class Terminal(gtk.VBox):
srcvtetargets = [("vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE)] srcvtetargets = [("vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE)]
dsttargets = [("vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE), dsttargets = [("vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE),
('text/x-moz-url', 0, 0), ('text/x-moz-url', 0, self.TARGET_TYPE_MOZ),
('_NETSCAPE_URL', 0, 0)] ('_NETSCAPE_URL', 0, 0)]
dsttargets = gtk.target_list_add_text_targets(dsttargets) dsttargets = gtk.target_list_add_text_targets(dsttargets)
dsttargets = gtk.target_list_add_uri_targets(dsttargets) dsttargets = gtk.target_list_add_uri_targets(dsttargets)
@ -791,16 +781,14 @@ class Terminal(gtk.VBox):
self.vte.set_scroll_on_keystroke(self.config['scroll_on_keystroke']) self.vte.set_scroll_on_keystroke(self.config['scroll_on_keystroke'])
self.vte.set_scroll_on_output(self.config['scroll_on_output']) self.vte.set_scroll_on_output(self.config['scroll_on_output'])
if self.scrollbar_position != self.config['scrollbar_position']:
self.scrollbar_position = self.config['scrollbar_position']
if self.config['scrollbar_position'] in ['disabled', 'hidden']: if self.config['scrollbar_position'] in ['disabled', 'hidden']:
self.scrollbar.hide() self.scrollbar.hide()
else: else:
self.scrollbar.show() self.scrollbar.show()
if self.config['scrollbar_position'] == 'left': if self.config['scrollbar_position'] == 'left':
self.reorder_child(self.scrollbar, 0) self.terminalbox.reorder_child(self.scrollbar, 0)
elif self.config['scrollbar_position'] == 'right': elif self.config['scrollbar_position'] == 'right':
self.reorder_child(self.vte, 0) self.terminalbox.reorder_child(self.vte, 0)
if hasattr(self.vte, 'set_alternate_screen_scroll'): if hasattr(self.vte, 'set_alternate_screen_scroll'):
self.vte.set_alternate_screen_scroll( self.vte.set_alternate_screen_scroll(
@ -1081,7 +1069,7 @@ class Terminal(gtk.VBox):
return(False) return(False)
def on_drag_data_received(self, widget, drag_context, x, y, selection_data, def on_drag_data_received(self, widget, drag_context, x, y, selection_data,
_info, _time, data): info, _time, data):
"""Something has been dragged into the terminal. Handle it as either a """Something has been dragged into the terminal. Handle it as either a
URL or another terminal.""" URL or another terminal."""
dbg('drag data received of type: %s' % selection_data.type) dbg('drag data received of type: %s' % selection_data.type)
@ -1089,6 +1077,12 @@ class Terminal(gtk.VBox):
gtk.targets_include_uri(drag_context.targets): gtk.targets_include_uri(drag_context.targets):
# copy text with no modification yet to destination # copy text with no modification yet to destination
txt = selection_data.data txt = selection_data.data
# https://bugs.launchpad.net/terminator/+bug/1518705
if info == self.TARGET_TYPE_MOZ:
txt = txt.decode('utf-16').encode('utf-8')
txt = txt.split('\n')[0]
txt_lines = txt.split( "\r\n" ) txt_lines = txt.split( "\r\n" )
if txt_lines[-1] == '': if txt_lines[-1] == '':
for line in txt_lines[:-1]: for line in txt_lines[:-1]:
@ -1805,7 +1799,7 @@ class Terminal(gtk.VBox):
self.emit('ungroup-tab') self.emit('ungroup-tab')
def key_new_window(self): def key_new_window(self):
self.terminator.new_window(self.terminator.pid_cwd(self.pid)) self.terminator.new_window(self.terminator.pid_cwd(self.pid), self.get_profile())
def key_new_tab(self): def key_new_tab(self):
self.get_toplevel().tab_new(self) self.get_toplevel().tab_new(self)

View File

@ -187,13 +187,15 @@ class Terminator(Borg):
return terminal return terminal
return None return None
def new_window(self, cwd=None): def new_window(self, cwd=None, profile=None):
"""Create a window with a Terminal in it""" """Create a window with a Terminal in it"""
maker = Factory() maker = Factory()
window = maker.make('Window') window = maker.make('Window')
terminal = maker.make('Terminal') terminal = maker.make('Terminal')
if cwd: if cwd:
terminal.set_cwd(cwd) terminal.set_cwd(cwd)
if profile and self.config['always_split_with_profile']:
terminal.force_set_profile(None, profile)
window.add(terminal) window.add(terminal)
window.show(True) window.show(True)
terminal.spawn_child() terminal.spawn_child()