cleaning up some code in newtab
** removed old reference to the box ** better handling of new tab spawning
This commit is contained in:
parent
9c60a60484
commit
ce63d6c29c
45
terminator
45
terminator
|
@ -1045,47 +1045,60 @@ class Terminator:
|
||||||
|
|
||||||
def newtab(self,widget):
|
def newtab(self,widget):
|
||||||
terminal = TerminatorTerm (self, self.profile, None, widget.get_cwd())
|
terminal = TerminatorTerm (self, self.profile, None, widget.get_cwd())
|
||||||
widgetbox = widget
|
parent = widget.get_parent ()
|
||||||
parent = widgetbox.get_parent ()
|
|
||||||
|
|
||||||
if isinstance(parent, gtk.Paned) or isinstance(parent, gtk.Window):
|
if isinstance(parent, gtk.Paned) or isinstance(parent, gtk.Window):
|
||||||
#no notebook yet.
|
#no notebook yet.
|
||||||
notebook = gtk.Notebook()
|
notebook = gtk.Notebook()
|
||||||
notebook.connect('page-reordered',self.on_page_reordered)
|
notebook.connect('page-reordered',self.on_page_reordered)
|
||||||
notebook.set_property('homogeneous', True)
|
notebook.set_property('homogeneous', True)
|
||||||
notebook.set_tab_reorderable(widgetbox, True)
|
notebook.set_tab_reorderable(widget, True)
|
||||||
|
|
||||||
if isinstance(parent, gtk.Paned):
|
if isinstance(parent, gtk.Paned):
|
||||||
if parent.get_child1() == widgetbox:
|
if parent.get_child1() == widget:
|
||||||
widgetbox.reparent(notebook)
|
widget.reparent(notebook)
|
||||||
parent.pack1(notebook)
|
parent.pack1(notebook)
|
||||||
else:
|
else:
|
||||||
widgetbox.reparent(notebook)
|
widget.reparent(notebook)
|
||||||
parent.pack2(notebook)
|
parent.pack2(notebook)
|
||||||
elif isinstance(parent, gtk.Window):
|
elif isinstance(parent, gtk.Window):
|
||||||
widgetbox.reparent(notebook)
|
widget.reparent(notebook)
|
||||||
parent.add(notebook)
|
parent.add(notebook)
|
||||||
notebook.set_tab_reorderable(widgetbox,True)
|
notebook.set_tab_reorderable(widget,True)
|
||||||
notebooklabel = ""
|
notebooklabel = ""
|
||||||
if widget._vte.get_window_title() is not None:
|
if widget._vte.get_window_title() is not None:
|
||||||
notebooklabel = widget._vte.get_window_title()
|
notebooklabel = widget._vte.get_window_title()
|
||||||
notebook.set_tab_label_text(widgetbox, notebooklabel)
|
notebook.set_tab_label_text(widget, notebooklabel)
|
||||||
notebook. set_tab_label_packing(widgetbox, True, True, gtk.PACK_START)
|
notebook. set_tab_label_packing(widget, True, True, gtk.PACK_START)
|
||||||
notebook.show()
|
notebook.show()
|
||||||
elif isinstance(parent, gtk.Notebook):
|
elif isinstance(parent, gtk.Notebook):
|
||||||
notebook = parent
|
notebook = parent
|
||||||
else:
|
else:
|
||||||
return (False)
|
return (False)
|
||||||
|
|
||||||
notebook.append_page(terminal,terminal._vte.get_window_title())
|
## NOTE
|
||||||
notebook. set_tab_label_packing(terminal, True, True, gtk.PACK_START)
|
## Here we need to append to the notebook before we can
|
||||||
notebook.set_tab_reorderable(terminal,True)
|
## spawn the terminal (WINDOW_ID needs to be set)
|
||||||
notebook.set_current_page(-1)
|
|
||||||
index = self.term_list.index(widget)
|
notebook.append_page(terminal,None)
|
||||||
self.term_list.insert (index + 1, terminal)
|
|
||||||
terminal.show ()
|
terminal.show ()
|
||||||
terminal.spawn_child ()
|
terminal.spawn_child ()
|
||||||
|
## Some gtk/vte weirdness
|
||||||
|
## If we don't use this silly test,
|
||||||
|
## terminal._vte.get_window_title() might return
|
||||||
|
## bogus values
|
||||||
|
notebooklabel = ""
|
||||||
|
if terminal._vte.get_window_title() is not None:
|
||||||
|
notebooklabel = terminal._vte.get_window_title()
|
||||||
|
notebook.set_tab_label_text(terminal, notebooklabel)
|
||||||
|
notebook.set_tab_label_packing(terminal, True, True, gtk.PACK_START)
|
||||||
|
notebook.set_tab_reorderable(terminal,True)
|
||||||
|
## Now, we set focus on the new term
|
||||||
|
notebook.set_current_page(-1)
|
||||||
terminal._vte.grab_focus ()
|
terminal._vte.grab_focus ()
|
||||||
|
|
||||||
|
index = self.term_list.index(widget)
|
||||||
|
self.term_list.insert (index + 1, terminal)
|
||||||
return (True)
|
return (True)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue