From 70ab3b0f7139b827857fe3a6a7f6728d00a06d89 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 22 Apr 2010 23:14:03 +0100 Subject: [PATCH 1/5] Store terminal titles in layouts --- terminatorlib/editablelabel.py | 7 +++++++ terminatorlib/terminal.py | 5 +++++ terminatorlib/titlebar.py | 12 ++++++++++++ 3 files changed, 24 insertions(+) diff --git a/terminatorlib/editablelabel.py b/terminatorlib/editablelabel.py index a970a3fd..f99578ed 100644 --- a/terminatorlib/editablelabel.py +++ b/terminatorlib/editablelabel.py @@ -130,4 +130,11 @@ class EditableLabel(gtk.EventBox): """Set the label foreground""" self._label.modify_fg(state, color) + def is_custom(self): + """Return whether or not we have a custom string set""" + return(self._custom) + + def set_custom(self): + """Set the customness of the string to True""" + self._custom = True gobject.type_register(EditableLabel) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index a6d1f3cb..b1c43c12 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -1282,6 +1282,9 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) if layout != "default": # There's no point explicitly noting default profiles layout['profile'] = profile + title = self.titlebar.get_custom_string() + if title: + layout['title'] = title name = 'terminal%d' % count count = count + 1 global_layout[name] = layout @@ -1298,6 +1301,8 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) # This doesn't need/use self.titlebar, but it's safer than sending # None self.really_create_group(self.titlebar, layout['group']) + if layout.has_key('title') and layout['title'] != '': + self.titlebar.set_custom_string(layout['title']) # There now begins a great list of keyboard event handlers def key_zoom_in(self): diff --git a/terminatorlib/titlebar.py b/terminatorlib/titlebar.py index 4c9ae65e..78cc267d 100755 --- a/terminatorlib/titlebar.py +++ b/terminatorlib/titlebar.py @@ -244,4 +244,16 @@ class Titlebar(gtk.EventBox): self.bellicon.hide() return(False) + def get_custom_string(self): + """If we have a custom string set, return it, otherwise None""" + if self.label.is_custom(): + return(self.label.get_text()) + else: + return(None) + + def set_custom_string(self, string): + """Set a custom string""" + self.label.set_text(string) + self.label.set_custom() + gobject.type_register(Titlebar) From 785ed8b5916914e8dbf9d256459f8bf0ca5a4a68 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 5 May 2010 09:44:55 +0100 Subject: [PATCH 2/5] Apply modified patch from Juan Manuel Santos to improve the directional navigation by not relying on bogus assumptions about the behaviour of get_cusor_position --- terminatorlib/window.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/terminatorlib/window.py b/terminatorlib/window.py index 2a6cfb34..6418b2ef 100755 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -623,9 +623,10 @@ class Window(Container, gtk.Window): if len(winners) > 1: # Break an n-way tie using the cursor position - cursor_x, cursor_y = terminal.get_cursor_position() - cursor_x = cursor_x + allocation.x - cursor_y = cursor_y + allocation.y + term_alloc = terminal.allocation + cursor_x = term_alloc.x + term_alloc.width / 2 + cursor_y = term_alloc.y + term_alloc.height / 2 + for term in winners: rect = layout[term] if util.get_nav_tiebreak(direction, cursor_x, cursor_y, From 4fca314259bd052f703a2a2ab56eb70a62cab95b Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 5 May 2010 09:46:09 +0100 Subject: [PATCH 3/5] Note the deprecation of Terminal::get_cursor_position --- terminatorlib/terminal.py | 1 + 1 file changed, 1 insertion(+) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index b1c43c12..465343ad 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -1249,6 +1249,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) def get_cursor_position(self): """Return the co-ordinates of our cursor""" + # FIXME: THIS METHOD IS DEPRECATED AND UNUSED col, row = self.vte.get_cursor_position() width = self.vte.get_char_width() height = self.vte.get_char_height() From 630da9b06d00f143ed57c497ee10bbd0b3376d92 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 5 May 2010 12:53:01 +0100 Subject: [PATCH 4/5] I think tabs should always be homogeneous. Let's see how that works out --- terminatorlib/notebook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index 4e69bba3..43c2b9b2 100755 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -45,7 +45,7 @@ class Notebook(Container, gtk.Notebook): # the new order of terminals. We probably need to preserve this for # navigation to next/prev terminals. #self.connect('page-reordered', self.on_page_reordered) - self.set_property('homogeneous', not self.config['scroll_tabbar']) + self.set_property('homogeneous', True) self.set_scrollable(self.config['scroll_tabbar']) pos = getattr(gtk, 'POS_%s' % self.config['tab_position'].upper()) From d12223769b71e389566e36a57b194430a09a5239 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 13 May 2010 09:17:30 +0200 Subject: [PATCH 5/5] guard against gtk/pygtk not letting us call set_orientation() on gtk.Box --- terminatorlib/notebook.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index 43c2b9b2..a803f3ce 100755 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -405,12 +405,14 @@ class TabLabel(gtk.HBox): """Update the angle of a label""" position = self.notebook.get_tab_pos() if position == gtk.POS_LEFT: - self.set_orientation(gtk.ORIENTATION_VERTICAL) + if hasattr(self, 'set_orientation'): + self.set_orientation(gtk.ORIENTATION_VERTICAL) self.label.set_angle(90) elif position == gtk.POS_RIGHT: self.label.set_angle(270) else: - self.set_orientation(gtk.ORIENTATION_HORIZONTAL) + if hasattr(self, 'set_orientation'): + self.set_orientation(gtk.ORIENTATION_HORIZONTAL) self.label.set_angle(0) def on_close(self, _widget):