From 0da21aa1d883e15873ca1ef8db07107127a92277 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Sun, 24 Feb 2008 20:42:08 +0000 Subject: [PATCH 01/28] beginning with drag and drop --- TODO | 2 + terminator | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 159 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index 3e66cca9..ea15c09f 100644 --- a/TODO +++ b/TODO @@ -1,2 +1,4 @@ * Edit doc/terminatorrc.5 manpage to contain the information about the options * Write a Tab feature for terminator + +* Drag and Drop terms diff --git a/terminator b/terminator index 0d2b9cfc..1791ee84 100755 --- a/terminator +++ b/terminator @@ -157,12 +157,27 @@ class TerminatorTerm: packfunc (self._vte) packfunc (self._scrollbar, False) - self._vte.connect ("key-press-event", self.on_vte_key_press) self._vte.connect ("button-press-event", self.on_vte_button_press) self._vte.connect ("popup-menu", self.on_vte_popup_menu) + + """drag and drop""" + target = [ ( "vte", 0, 81 ) ] + self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, target, gtk.gdk.ACTION_MOVE) + self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,target, gtk.gdk.ACTION_MOVE) + + self._vte.connect("drag-begin", self.on_drag_begin) + self._vte.connect("drag-data-get", self.on_drag_data_get, self) + self._vte.connect("drag-end", self.on_drag_end) + self._vte.connect("drag-data-delete", self.on_drag_data_delete) + + self._vte.connect("drag-motion", self.on_drag_motion) + self._vte.connect("drag-drop", self.on_drag_drop) + self._vte.connect("drag-data-received", self.on_drag_data_received, self) # self._vte.connect ("window-title-changed", self.on_vte_title_change) + + exit_action = self.gconf_client.get_string (self.profile + "/exit_action") if not exit_action: if self.defaults['child_restart']: @@ -171,7 +186,11 @@ class TerminatorTerm: exit_action = "close" if exit_action == "restart": self._vte.connect ("child-exited", self.spawn_child) - if exit_action == "close": + #gnome-terminal Bug: http://bugzilla.gnome.org/show_bug.cgi?id=518184 + #/apps/gnome-terminal/profiles//exit_action might be + #set to "left" instead of close + # LP#194771 + if exit_action in ("close", "left"): self._vte.connect ("child-exited", lambda close_term: self.terminator.closeterm (self)) self._vte.add_events (gtk.gdk.ENTER_NOTIFY_MASK) @@ -186,6 +205,140 @@ class TerminatorTerm: self.spawn_child () + def on_drag_begin(self,widget, drag_context): + #parent is hbox + print "Drag begin on ", + parent = widget.get_parent() + print parent + + def on_drag_data_get(self,widget, drag_context, selection_data, info, time, data): + print "Drag data get" + selection_data.set("vte",81, str(data.terminator.term_list.index (self))) + + def on_drag_data_delete(self, widget, drag_context): + print "Drag data delete" + + def on_drag_end(self, widget, drag_context): + print "Drag end" + + def on_drag_motion(self, widget, drag_context, x, y, time): + return + print "Drag Motion on ", + parent = widget.get_parent() + print "%dx%d -> %dx%d" % (parent.allocation.width, parent.allocation.height , x, y) + + coef1 = float(parent.allocation.height)/float(parent.allocation.width) + coef2 = -float(parent.allocation.height)/float(parent.allocation.width) + b1 = 0 + b2 = parent.allocation.height + print "%f %f %d %d" %(coef1, coef2, b1,b2) + if (x*coef1 + b1 > y ) and (x*coef2 + b2 < y ): + print "right" + if (x*coef1 + b1 > y ) and (x*coef2 + b2 > y ): + print "top" + if (x*coef1 + b1 < y ) and (x*coef2 + b2 > y ): + print "left" + if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ): + print "bottom" + + def on_drag_drop(self, widget, drag_context, x, y, time): + print "Drag Drop on", + parent = widget.get_parent() + print parent, + + def on_drag_data_received(self, widget, drag_context, x, y, selection_data, info, time, data): + print "Drag Data Received on " + widgetsrc = data.terminator.term_list[int(selection_data.data)] + srchbox = widgetsrc.get_box() + dsthbox = widget.get_parent() + + coef1 = float(widget.allocation.height)/float(widget.allocation.width) + coef2 = -float(widget.allocation.height)/float(widget.allocation.width) + b1 = 0 + b2 = dsthbox.allocation.height + + if (x*coef1 + b1 > y ) and (x*coef2 + b2 < y ): + pos = "right" + if (x*coef1 + b1 > y ) and (x*coef2 + b2 > y ): + pos = "top" + if (x*coef1 + b1 < y ) and (x*coef2 + b2 > y ): + pos = "left" + if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ): + pos = "bottom" + + + if dsthbox == srchbox: + print "on itself" + return + + dstpaned = dsthbox.get_parent() + srcpaned = srchbox.get_parent() + if isinstance(dstpaned, gtk.Window) and isinstance(srcpaned, gtk.Window): + print "Only one terminal" + return + + """remove src pane""" + + if srcpaned.get_child1() == srchbox: + srcsibling = srcpaned.get_child2() + else: + srcsibling = srcpaned.get_child1() + + srcgdparent = srcpaned.get_parent() + + if isinstance (srcgdparent, gtk.Window): + print "SRC = window" + srcpaned.remove(srchbox) + srcpaned.remove(srcsibling) + srcgdparent.remove(srcpaned) + srcpaned.destroy() + srcgdparent.add(srcsibling) + srcsibling.reparent(srcgdparent) + if isinstance (srcgdparent, gtk.Paned): + print "SRC = paned" + srcpaned.remove(srchbox) + srcgdparent.remove(srcpaned) + srcsibling.reparent(srcgdparent) + srcpaned.destroy() + + + + dstpaned = dsthbox.get_parent() + if isinstance (dstpaned, gtk.Window): + print "DST = window" + # We have just one term + pane = (pos in ("top", "bottom")) and gtk.VPaned() or gtk.HPaned() + dsthbox.reparent (pane) + #srchbox.reparent(pane) + pane.pack1 (dsthbox, True, True) + pane.pack2 (srchbox, True, True) + dstpaned.add(pane) + position = (pos in ("top", "bottom")) and dstpaned.allocation.height or dstpaned.allocation.width + + + if isinstance (dstpaned, gtk.Paned): + print "DST = paned" + pane = (pos in ("top", "bottom")) and gtk.VPaned() or gtk.HPaned() + position = (pos in ("top", "bottom")) and dstpaned.allocation.height or dstpaned.allocation.width + print "%s %d" % (pos, position) + if (dsthbox == dstpaned.get_child1 ()): + dsthbox.reparent (pane) + dstpaned.pack1 (pane, True, True) + else: + dsthbox.reparent (pane) + dstpaned.pack2 (pane, True, True) + + pane.pack1 (dsthbox, True, True) + pane.pack2 (srchbox, True, True) + + pane.show_all() + pane.set_position (position / 2) + + + + + + def spawn_child (self, event=None): update_records = self.gconf_client.get_bool (self.profile + "/update_records") or True login = self.gconf_client.get_bool (self.profile + "/login_shell") or False @@ -345,9 +498,8 @@ class TerminatorTerm: if event.button == 1: self._vte.grab_focus () return False - - # Right mouse button should display a context menu - if event.button == 3: + # Right mouse button should display a context menu if ctrl not pressed + if event.button == 3 and event.state & gtk.gdk.CONTROL_MASK == 0: self.do_popup (event) return True From 77d209303ac2890d16cfaa2b5035ccbc080f3efd Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Mon, 25 Feb 2008 00:39:09 +0000 Subject: [PATCH 02/28] drag and drop: behaviour should be correct now --- terminator | 90 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/terminator b/terminator index 1791ee84..24f4f1b6 100755 --- a/terminator +++ b/terminator @@ -166,13 +166,10 @@ class TerminatorTerm: self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, target, gtk.gdk.ACTION_MOVE) self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,target, gtk.gdk.ACTION_MOVE) - self._vte.connect("drag-begin", self.on_drag_begin) self._vte.connect("drag-data-get", self.on_drag_data_get, self) - self._vte.connect("drag-end", self.on_drag_end) - self._vte.connect("drag-data-delete", self.on_drag_data_delete) + #for testing purpose: drag-motion self._vte.connect("drag-motion", self.on_drag_motion) - self._vte.connect("drag-drop", self.on_drag_drop) self._vte.connect("drag-data-received", self.on_drag_data_received, self) # self._vte.connect ("window-title-changed", self.on_vte_title_change) @@ -204,23 +201,11 @@ class TerminatorTerm: self.matches['nntp'] = self._vte.match_add ('''\''') self.spawn_child () - - def on_drag_begin(self,widget, drag_context): - #parent is hbox - print "Drag begin on ", - parent = widget.get_parent() - print parent def on_drag_data_get(self,widget, drag_context, selection_data, info, time, data): print "Drag data get" selection_data.set("vte",81, str(data.terminator.term_list.index (self))) - - def on_drag_data_delete(self, widget, drag_context): - print "Drag data delete" - - def on_drag_end(self, widget, drag_context): - print "Drag end" - + def on_drag_motion(self, widget, drag_context, x, y, time): return print "Drag Motion on ", @@ -252,21 +237,7 @@ class TerminatorTerm: srchbox = widgetsrc.get_box() dsthbox = widget.get_parent() - coef1 = float(widget.allocation.height)/float(widget.allocation.width) - coef2 = -float(widget.allocation.height)/float(widget.allocation.width) - b1 = 0 - b2 = dsthbox.allocation.height - - if (x*coef1 + b1 > y ) and (x*coef2 + b2 < y ): - pos = "right" - if (x*coef1 + b1 > y ) and (x*coef2 + b2 > y ): - pos = "top" - if (x*coef1 + b1 < y ) and (x*coef2 + b2 > y ): - pos = "left" - if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ): - pos = "bottom" - - + #check if computation requireds if dsthbox == srchbox: print "on itself" return @@ -276,8 +247,32 @@ class TerminatorTerm: if isinstance(dstpaned, gtk.Window) and isinstance(srcpaned, gtk.Window): print "Only one terminal" return + #get the diagonales function for the receiving widget + coef1 = float(widget.allocation.height)/float(widget.allocation.width) + coef2 = -float(widget.allocation.height)/float(widget.allocation.width) + b1 = 0 + b2 = dsthbox.allocation.height + #determine mouse position in rectangle + """ + -------- + |\ /| + | \ / | + | \/ | + | /\ | + | / \ | + |/ \| + -------- + """ + if (x*coef1 + b1 > y ) and (x*coef2 + b2 < y ): + pos = "right" + if (x*coef1 + b1 > y ) and (x*coef2 + b2 > y ): + pos = "top" + if (x*coef1 + b1 < y ) and (x*coef2 + b2 > y ): + pos = "left" + if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ): + pos = "bottom" - """remove src pane""" + #remove src pane if srcpaned.get_child1() == srchbox: srcsibling = srcpaned.get_child2() @@ -287,7 +282,7 @@ class TerminatorTerm: srcgdparent = srcpaned.get_parent() if isinstance (srcgdparent, gtk.Window): - print "SRC = window" + #src gd parent is a window srcpaned.remove(srchbox) srcpaned.remove(srcsibling) srcgdparent.remove(srcpaned) @@ -295,17 +290,17 @@ class TerminatorTerm: srcgdparent.add(srcsibling) srcsibling.reparent(srcgdparent) if isinstance (srcgdparent, gtk.Paned): - print "SRC = paned" + #src gd parent is a paned srcpaned.remove(srchbox) srcgdparent.remove(srcpaned) srcsibling.reparent(srcgdparent) srcpaned.destroy() - - + + #dst paned dstpaned = dsthbox.get_parent() if isinstance (dstpaned, gtk.Window): - print "DST = window" + #dst parent is a window # We have just one term pane = (pos in ("top", "bottom")) and gtk.VPaned() or gtk.HPaned() dsthbox.reparent (pane) @@ -317,9 +312,14 @@ class TerminatorTerm: if isinstance (dstpaned, gtk.Paned): - print "DST = paned" + #dst parent is a paned pane = (pos in ("top", "bottom")) and gtk.VPaned() or gtk.HPaned() - position = (pos in ("top", "bottom")) and dstpaned.allocation.height or dstpaned.allocation.width + + if pos in ("top", "bottom"): + position = isinstance(dstpaned, gtk.VPaned) and dstpaned.allocation.height/2 or dstpaned.allocation.height + if pos in ("left", "right"): + position = isinstance(dstpaned, gtk.HPaned) and dstpaned.allocation.width/2 or dstpaned.allocation.width + print "%s %d" % (pos, position) if (dsthbox == dstpaned.get_child1 ()): dsthbox.reparent (pane) @@ -327,9 +327,13 @@ class TerminatorTerm: else: dsthbox.reparent (pane) dstpaned.pack2 (pane, True, True) - - pane.pack1 (dsthbox, True, True) - pane.pack2 (srchbox, True, True) + if pos in ("top", "left"): + pane.remove(dsthbox) + pane.pack1 (srchbox, True, True) + pane.pack2 (dsthbox, True, True) + else: + pane.pack1 (dsthbox, True, True) + pane.pack2 (srchbox, True, True) pane.show_all() pane.set_position (position / 2) From ff2a6b0fa65dfd5260d524687568db2432066846 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Mon, 25 Feb 2008 18:56:51 +0000 Subject: [PATCH 03/28] fixed a bug where the source term was set to the bottom or right of the destination term --- terminator | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/terminator b/terminator index e3e232ed..e43bf9ec 100755 --- a/terminator +++ b/terminator @@ -203,7 +203,7 @@ class TerminatorTerm: selection_data.set("vte",81, str(data.terminator.term_list.index (self))) def on_drag_motion(self, widget, drag_context, x, y, time): - return + #return print "Drag Motion on ", parent = widget.get_parent() print "%dx%d -> %dx%d" % (parent.allocation.width, parent.allocation.height , x, y) @@ -299,10 +299,15 @@ class TerminatorTerm: #dst parent is a window # We have just one term pane = (pos in ("top", "bottom")) and gtk.VPaned() or gtk.HPaned() - dsthbox.reparent (pane) + dstpaned.remove(dsthbox) + #dsthbox.reparent (pane) #srchbox.reparent(pane) - pane.pack1 (dsthbox, True, True) - pane.pack2 (srchbox, True, True) + if pos in ("top", "left"): + pane.pack1 (srchbox, True, True) + pane.pack2 (dsthbox, True, True) + else: + pane.pack1 (dsthbox, True, True) + pane.pack2 (srchbox, True, True) dstpaned.add(pane) position = (pos in ("top", "bottom")) and dstpaned.allocation.height or dstpaned.allocation.width From 4396433c2d900c408ec9b46199923583f07c7da3 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Mon, 25 Feb 2008 20:41:36 +0000 Subject: [PATCH 04/28] Fixed Ctrl-Rightclick keybinding for DnD: * changed gtk.gdk.ACTION_MOVE to gtk.gdk.ACTION_COPY --- terminator | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/terminator b/terminator index e43bf9ec..e59c2161 100755 --- a/terminator +++ b/terminator @@ -163,13 +163,12 @@ class TerminatorTerm: """drag and drop""" target = [ ( "vte", 0, 81 ) ] - self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, target, gtk.gdk.ACTION_MOVE) - self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,target, gtk.gdk.ACTION_MOVE) - + self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, target, gtk.gdk.ACTION_COPY) + self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,target, gtk.gdk.ACTION_COPY) self._vte.connect("drag-data-get", self.on_drag_data_get, self) #for testing purpose: drag-motion - self._vte.connect("drag-motion", self.on_drag_motion) + #self._vte.connect("drag-motion", self.on_drag_motion, self) self._vte.connect("drag-data-received", self.on_drag_data_received, self) self._vte.connect ("composited-changed", self.on_composited_changed) @@ -200,18 +199,20 @@ class TerminatorTerm: def on_drag_data_get(self,widget, drag_context, selection_data, info, time, data): print "Drag data get" - selection_data.set("vte",81, str(data.terminator.term_list.index (self))) + selection_data.set("vte",info, str(data.terminator.term_list.index (self))) - def on_drag_motion(self, widget, drag_context, x, y, time): - #return + def on_drag_motion(self, widget, drag_context, x, y, time, data): print "Drag Motion on ", parent = widget.get_parent() + + print "%dx%d -> %dx%d" % (parent.allocation.width, parent.allocation.height , x, y) coef1 = float(parent.allocation.height)/float(parent.allocation.width) coef2 = -float(parent.allocation.height)/float(parent.allocation.width) b1 = 0 b2 = parent.allocation.height + print "%f %f %d %d" %(coef1, coef2, b1,b2) if (x*coef1 + b1 > y ) and (x*coef2 + b2 < y ): print "right" @@ -221,6 +222,7 @@ class TerminatorTerm: print "left" if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ): print "bottom" + def on_drag_drop(self, widget, drag_context, x, y, time): print "Drag Drop on", @@ -531,7 +533,7 @@ class TerminatorTerm: # Left mouse button should transfer focus to this vte widget if event.button == 1: self._vte.grab_focus () - return False + return False # Right mouse button should display a context menu if ctrl not pressed if event.button == 3 and event.state & gtk.gdk.CONTROL_MASK == 0: self.do_popup (event) From bdad9597f794db055b916dc7e35c7ecf7e8bd19a Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Tue, 26 Feb 2008 19:57:22 +0000 Subject: [PATCH 05/28] fixes issue where moving a term with --no-gconf and scrollbar_position=disabled in ~/.terminatorrc will create a scroll bar of the left of src and dst terms --- terminator | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/terminator b/terminator index 3d08ab1a..b91bd018 100755 --- a/terminator +++ b/terminator @@ -157,7 +157,7 @@ class TerminatorTerm: line = line.strip () if line: (key,value) = line.split ("=") - print >> sys.stderr, _('''Overriding setting '%s' from default value '%s' to: '%s' ''')%(key.strip (), self.defaults[key.strip ()], value.strip ()) + print >> sys.stderr, _('''Overriding setting '%s' from default value '%s' to: '%s' ''') % (key.strip (), self.defaults[key.strip ()], value.strip ()) self.defaults[key.strip ()] = value.strip () except: pass @@ -370,9 +370,9 @@ class TerminatorTerm: pane.pack1 (dsthbox, True, True) pane.pack2 (srchbox, True, True) - pane.show_all() + pane.show() pane.set_position (position / 2) - + self.reconfigure_vte() def spawn_child (self, event=None): update_records = self.gconf_client.get_bool (self.profile + "/update_records") or True @@ -421,7 +421,7 @@ class TerminatorTerm: ret = value.get_float () elif value.type == gconf.VALUE_BOOL: ret = value.get_bool () - + if ret == None: print >> sys.stderr, _('Unknown value requested. Unable to find in gconf profile or default settings: ') + property From 649bc217506ba93a3ab05c0473bfbdb1f12a18a8 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Tue, 26 Feb 2008 20:57:06 +0000 Subject: [PATCH 06/28] removing useless self.reconfigure_vte() in on_drag_data_received() --- terminator | 1 - 1 file changed, 1 deletion(-) diff --git a/terminator b/terminator index b91bd018..a2552485 100755 --- a/terminator +++ b/terminator @@ -372,7 +372,6 @@ class TerminatorTerm: pane.show() pane.set_position (position / 2) - self.reconfigure_vte() def spawn_child (self, event=None): update_records = self.gconf_client.get_bool (self.profile + "/update_records") or True From 429339108b1c77431311c7ff412453e4f0f27531 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Wed, 27 Feb 2008 20:11:47 +0000 Subject: [PATCH 07/28] Cleaned up dnd code * added a destroy method to TerminatorTerm so a term can be destroyed with its corresponding vte and hbox * splitaxis now creates a term and add it to the receiving term * closeterm now remove the term and destroy it * added Terminator.add(widget, term, pos) add a term to widget a pos * added Terminator.remove(widget) removes a widget from the Terminator view --- terminator | 134 ++++++++++++++++++----------------------------------- 1 file changed, 46 insertions(+), 88 deletions(-) diff --git a/terminator b/terminator index a2552485..bbf6ec2c 100755 --- a/terminator +++ b/terminator @@ -302,76 +302,9 @@ class TerminatorTerm: if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ): pos = "bottom" - #remove src pane - - if srcpaned.get_child1() == srchbox: - srcsibling = srcpaned.get_child2() - else: - srcsibling = srcpaned.get_child1() - - srcgdparent = srcpaned.get_parent() - - if isinstance (srcgdparent, gtk.Window): - #src gd parent is a window - srcpaned.remove(srchbox) - srcpaned.remove(srcsibling) - srcgdparent.remove(srcpaned) - srcpaned.destroy() - srcgdparent.add(srcsibling) - srcsibling.reparent(srcgdparent) - if isinstance (srcgdparent, gtk.Paned): - #src gd parent is a paned - srcpaned.remove(srchbox) - srcgdparent.remove(srcpaned) - srcsibling.reparent(srcgdparent) - srcpaned.destroy() - - - #dst paned - dstpaned = dsthbox.get_parent() - if isinstance (dstpaned, gtk.Window): - #dst parent is a window - # We have just one term - pane = (pos in ("top", "bottom")) and gtk.VPaned() or gtk.HPaned() - dstpaned.remove(dsthbox) - #dsthbox.reparent (pane) - #srchbox.reparent(pane) - if pos in ("top", "left"): - pane.pack1 (srchbox, True, True) - pane.pack2 (dsthbox, True, True) - else: - pane.pack1 (dsthbox, True, True) - pane.pack2 (srchbox, True, True) - dstpaned.add(pane) - position = (pos in ("top", "bottom")) and dstpaned.allocation.height or dstpaned.allocation.width - - - if isinstance (dstpaned, gtk.Paned): - #dst parent is a paned - pane = (pos in ("top", "bottom")) and gtk.VPaned() or gtk.HPaned() - - if pos in ("top", "bottom"): - position = isinstance(dstpaned, gtk.VPaned) and dstpaned.allocation.height/2 or dstpaned.allocation.height - if pos in ("left", "right"): - position = isinstance(dstpaned, gtk.HPaned) and dstpaned.allocation.width/2 or dstpaned.allocation.width - - print "%s %d" % (pos, position) - if (dsthbox == dstpaned.get_child1 ()): - dsthbox.reparent (pane) - dstpaned.pack1 (pane, True, True) - else: - dsthbox.reparent (pane) - dstpaned.pack2 (pane, True, True) - if pos in ("top", "left"): - pane.remove(dsthbox) - pane.pack1 (srchbox, True, True) - pane.pack2 (dsthbox, True, True) - else: - pane.pack1 (dsthbox, True, True) - pane.pack2 (srchbox, True, True) - - pane.show() - pane.set_position (position / 2) + data.terminator.remove(widgetsrc) + data.terminator.add(self, widgetsrc,pos) + return def spawn_child (self, event=None): update_records = self.gconf_client.get_bool (self.profile + "/update_records") or True @@ -731,6 +664,10 @@ class TerminatorTerm: def get_box (self): return self._box + def destroy(self): + self.get_box().destroy() + self._vte.destroy() + class Terminator: def __init__ (self, profile, command = None): self.profile = profile @@ -843,23 +780,22 @@ class Terminator: self.on_destroy_event (window, gtk.gdk.Event (gtk.gdk.DESTROY)) - def splitaxis (self, widget, vertical=True): - """ Split the provided widget on the horizontal or vertical axis. """ - - # create a new terminal and parent pane. - terminal = TerminatorTerm (self, self.profile, None, widget.get_cwd()) + def add(self, widget, terminal, pos): + vertical = pos in ("top", "bottom") pane = (vertical) and gtk.VPaned () or gtk.HPaned () - # get the parent of the provided terminal parent = widget.get_box ().get_parent () if isinstance (parent, gtk.Window): # We have just one term widget.get_box ().reparent (pane) - - pane.pack1 (widget.get_box (), True, True) - pane.pack2 (terminal.get_box (), True, True) - + if pos in ("top", "left"): + pane.remove(widget.get_box ()) + pane.pack1 (terminal.get_box (), True, True) + pane.pack2 (widget.get_box (), True, True) + else: + pane.pack1 (widget.get_box (), True, True) + pane.pack2 (terminal.get_box (), True, True) parent.add (pane) position = (vertical) and parent.allocation.height \ @@ -876,7 +812,14 @@ class Terminator: else: widget.get_box ().reparent (pane) parent.pack2 (pane, True, True) - + if pos in ("top", "left"): + pane.remove(widget.get_box ()) + pane.pack1 (terminal.get_box (), True, True) + pane.pack2 (widget.get_box (), True, True) + else: + pane.pack1 (widget.get_box (), True, True) + pane.pack2 (terminal.get_box (), True, True) + pane.pack1 (widget.get_box (), True, True) pane.pack2 (terminal.get_box (), True, True) @@ -893,8 +836,17 @@ class Terminator: terminal._vte.grab_focus () return (terminal) - - def closeterm (self, widget): + + def splitaxis (self, widget, vertical=True): + """ Split the provided widget on the horizontal or vertical axis. """ + # create a new terminal and parent pane. + terminal = TerminatorTerm (self, self.profile, None, widget.get_cwd()) + pos = vertical and "bottom" or "right" + self.add(widget, terminal, pos) + terminal.get_box ().show () + return terminal + + def remove(self, widget): parent = widget.get_box ().get_parent () sibling = None @@ -917,14 +869,14 @@ class Terminator: if not sibling: # something is wrong, give up print >> sys.stderr, "Error: %s is not a child of %s"%(widget, parent) - return + return False - self.term_list.remove (widget) + parent.remove(widget.get_box()) grandparent.remove (parent) sibling.reparent (grandparent) - widget.get_box ().destroy () parent.destroy () - + self.term_list.remove (widget) + if not isinstance (sibling, gtk.Paned): for term in self.term_list: if term.get_box () == sibling: @@ -934,7 +886,13 @@ class Terminator: if index == 0: index = 1 self.term_list[index - 1]._vte.grab_focus () - return + return True + + def closeterm (self, widget): + if self.remove(widget): + widget.destroy () + return True + return False def go_next (self, term): current = self.term_list.index (term) From bd86949ad60649e9dbf956332800b1af245d3f24 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Wed, 27 Feb 2008 20:27:29 +0000 Subject: [PATCH 08/28] some documentation --- terminator | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/terminator b/terminator index bbf6ec2c..e5960dee 100755 --- a/terminator +++ b/terminator @@ -780,7 +780,10 @@ class Terminator: self.on_destroy_event (window, gtk.gdk.Event (gtk.gdk.DESTROY)) - def add(self, widget, terminal, pos): + def add(self, widget, terminal, pos = "bottom"): + """ + Add a term to another at position pos + """ vertical = pos in ("top", "bottom") pane = (vertical) and gtk.VPaned () or gtk.HPaned () # get the parent of the provided terminal @@ -847,6 +850,8 @@ class Terminator: return terminal def remove(self, widget): + """Remove a TerminatorTerm from the Terminator view and terms list + Returns True on success, False on failure""" parent = widget.get_box ().get_parent () sibling = None From 246b7a1e3628665ce63a8414c1b6c8aa3fcbead2 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Fri, 29 Feb 2008 17:50:32 +0000 Subject: [PATCH 09/28] Added grandparent.resize_children() in Terminator.remove() to force the terminal term to have the right size when returning otherwise, resizing is delayed and dnd between 2 siblings will squeeze a term --- terminator | 1 + 1 file changed, 1 insertion(+) diff --git a/terminator b/terminator index e5960dee..3029022a 100755 --- a/terminator +++ b/terminator @@ -879,6 +879,7 @@ class Terminator: parent.remove(widget.get_box()) grandparent.remove (parent) sibling.reparent (grandparent) + grandparent.resize_children() parent.destroy () self.term_list.remove (widget) From 847ee62684801d28ed21de72f22807c3c698e8d9 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Sun, 2 Mar 2008 12:44:08 +0000 Subject: [PATCH 10/28] Highlight focused term support --- terminator | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/terminator b/terminator index a71af6b4..110401d1 100755 --- a/terminator +++ b/terminator @@ -185,14 +185,17 @@ class TerminatorTerm: self._termbox = gtk.HBox () self._termbox.show() self._title = gtk.Label() + self._title.show() + self._titlebox = gtk.EventBox() + self._titlebox.add(self._title) self._box = gtk.VBox () self._box.show() - self._box.pack_start(self._title, False) + self._box.pack_start(self._titlebox, False) self._box.pack_start(self._termbox) if self.reconf('titlebars'): - self._title.show() + self._titlebox.show() else: - self._title.hide() + self._titlebox.hide() self._scrollbar = gtk.VScrollbar (self._vte.get_adjustment ()) if self.scrollbar_position != "hidden" and self.scrollbar_position != "disabled": @@ -212,6 +215,8 @@ class TerminatorTerm: self._vte.connect ("composited-changed", self.on_composited_changed) self._vte.connect ("window-title-changed", self.on_vte_title_change) self._vte.connect ("grab-focus", self.on_vte_focus) + self._vte.connect ("focus-out-event", self.on_vte_focus_out) + self._vte.connect ("focus-in-event", self.on_vte_focus_in) exit_action = self.gconf_client.get_string (self.profile + "/exit_action") exit_action = self.reconf ("exit_action") @@ -604,6 +609,16 @@ class TerminatorTerm: self._title.set_text(vte.get_window_title ()) self.terminator.set_window_title("Terminator: %s" %vte.get_window_title ()) + def on_vte_focus_in(self, vte, event): + self._titlebox.modify_bg(gtk.STATE_NORMAL,self.terminator.window.get_style().bg[gtk.STATE_SELECTED]) + self._title.modify_fg(gtk.STATE_NORMAL, self.terminator.window.get_style().fg[gtk.STATE_SELECTED]) + return + + def on_vte_focus_out(self, vte, event): + self._titlebox.modify_bg(gtk.STATE_NORMAL, self.terminator.window.get_style().bg[gtk.STATE_NORMAL]) + self._title.modify_fg(gtk.STATE_NORMAL, self.terminator.window.get_style().fg[gtk.STATE_NORMAL]) + return + def on_vte_focus(self, vte): if vte.get_window_title (): self.terminator.set_window_title("Terminator: %s" %vte.get_window_title ()) From ed3f6956698042e045bc7f549872ca16a18da6a9 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Tue, 4 Mar 2008 19:08:31 +0000 Subject: [PATCH 11/28] * Adding layout over destination pane on DnD --- terminator | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/terminator b/terminator index 12cd4b18..9d941985 100755 --- a/terminator +++ b/terminator @@ -220,7 +220,7 @@ class TerminatorTerm: self._vte.connect("drag-data-get", self.on_drag_data_get, self) #for testing purpose: drag-motion - #self._vte.connect("drag-motion", self.on_drag_motion, self) + self._vte.connect("drag-motion", self.on_drag_motion, self) self._vte.connect("drag-data-received", self.on_drag_data_received, self) self._vte.connect ("composited-changed", self.on_composited_changed) @@ -258,26 +258,49 @@ class TerminatorTerm: selection_data.set("vte",info, str(data.terminator.term_list.index (self))) def on_drag_motion(self, widget, drag_context, x, y, time, data): - print "Drag Motion on ", + #print "Drag Motion on ", parent = widget.get_parent() + rect = gtk.gdk.Rectangle(0, 0, parent.allocation.width, parent.allocation.height) + allocation = widget.allocation + widget.window.invalidate_rect(rect, True) + widget.window.process_updates(True) + context = widget.window.cairo_create() + context.set_source_rgba(1, 0, 0, 0.5) #red - - print "%dx%d -> %dx%d" % (parent.allocation.width, parent.allocation.height , x, y) + #print "%dx%d -> %dx%d" % (parent.allocation.width, parent.allocation.height , x, y) coef1 = float(parent.allocation.height)/float(parent.allocation.width) coef2 = -float(parent.allocation.height)/float(parent.allocation.width) b1 = 0 b2 = parent.allocation.height - print "%f %f %d %d" %(coef1, coef2, b1,b2) + #print "%f %f %d %d" %(coef1, coef2, b1,b2) if (x*coef1 + b1 > y ) and (x*coef2 + b2 < y ): - print "right" + #print "right" + pos1 = (allocation.width,0) + pos2 = (allocation.width/2, allocation.height/2) + pos3 = (allocation.width,allocation.height) if (x*coef1 + b1 > y ) and (x*coef2 + b2 > y ): - print "top" + #print "top" + pos1 = (0,0) + pos2 = (allocation.width/2, allocation.height/2) + pos3 = (allocation.width,0) if (x*coef1 + b1 < y ) and (x*coef2 + b2 > y ): - print "left" + #print "left" + pos1 = (0,0) + pos2 = (allocation.width/2, allocation.height/2) + pos3 = (0,allocation.height) if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ): - print "bottom" + #print "bottom" + pos1 = (0,allocation.height) + pos2 = (allocation.width/2, allocation.height/2) + pos3 = (allocation.width,allocation.height) + + context.move_to(pos1[0],pos1[1]) + context.line_to(pos2[0],pos2[1]) + context.line_to(pos3[0],pos3[1]) + context.line_to(pos1[0],pos1[1]) + context.fill() def on_drag_drop(self, widget, drag_context, x, y, time): @@ -289,7 +312,7 @@ class TerminatorTerm: print "Drag Data Received on " widgetsrc = data.terminator.term_list[int(selection_data.data)] srchbox = widgetsrc.get_box() - dsthbox = widget.get_parent() + dsthbox = widget.get_parent().get_parent() #check if computation requireds if dsthbox == srchbox: From 9ebbc671edc252d3b83af74ae683cc238438d2ce Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Tue, 4 Mar 2008 20:25:51 +0000 Subject: [PATCH 12/28] * cleaned up on_drag_motion --- terminator | 71 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/terminator b/terminator index 9d941985..893ba4df 100755 --- a/terminator +++ b/terminator @@ -259,48 +259,58 @@ class TerminatorTerm: def on_drag_motion(self, widget, drag_context, x, y, time, data): #print "Drag Motion on ", - parent = widget.get_parent() - rect = gtk.gdk.Rectangle(0, 0, parent.allocation.width, parent.allocation.height) - allocation = widget.allocation + srcwidget = drag_context.get_source_widget() + if widget == srcwidget: + #on self + return + + alloc = widget.allocation + rect = gtk.gdk.Rectangle(0, 0, alloc.width, alloc.height) widget.window.invalidate_rect(rect, True) widget.window.process_updates(True) + context = widget.window.cairo_create() - context.set_source_rgba(1, 0, 0, 0.5) #red + if self.gconf_client.get_bool (self.profile + "/use_theme_colors"): + color = self._vte.get_style ().text[gtk.STATE_NORMAL] + else: + color = gtk.gdk.color_parse (self.reconf ('foreground_color')) + #color = gtk.gdk.color_parse(self.reconf ('foreground_color')) - #print "%dx%d -> %dx%d" % (parent.allocation.width, parent.allocation.height , x, y) + + + context.set_source_rgba(color.red, color.green, color.blue, 0.5) #red - coef1 = float(parent.allocation.height)/float(parent.allocation.width) - coef2 = -float(parent.allocation.height)/float(parent.allocation.width) + + coef1 = float(alloc.height)/float(alloc.width) + coef2 = -float(alloc.height)/float(alloc.width) b1 = 0 - b2 = parent.allocation.height - + b2 = alloc.height + topleft = (0,0) + topright = (alloc.width,0) + bottomleft = (0, alloc.height) + bottomright = (alloc.width,alloc.height) + middle = (alloc.width/2, alloc.height/2) #print "%f %f %d %d" %(coef1, coef2, b1,b2) + coord = () if (x*coef1 + b1 > y ) and (x*coef2 + b2 < y ): #print "right" - pos1 = (allocation.width,0) - pos2 = (allocation.width/2, allocation.height/2) - pos3 = (allocation.width,allocation.height) + coord = (topright, middle, bottomright) if (x*coef1 + b1 > y ) and (x*coef2 + b2 > y ): #print "top" - pos1 = (0,0) - pos2 = (allocation.width/2, allocation.height/2) - pos3 = (allocation.width,0) + coord = (topleft, middle, topright) if (x*coef1 + b1 < y ) and (x*coef2 + b2 > y ): #print "left" - pos1 = (0,0) - pos2 = (allocation.width/2, allocation.height/2) - pos3 = (0,allocation.height) + coord = (topleft, middle, bottomleft) if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ): #print "bottom" - pos1 = (0,allocation.height) - pos2 = (allocation.width/2, allocation.height/2) - pos3 = (allocation.width,allocation.height) + coord = (bottomleft, middle, bottomright) + + if len(coord) > 0 : + context.move_to(coord[2][0],coord[2][1]) + for i in coord: + context.line_to(i[0],i[1]) - context.move_to(pos1[0],pos1[1]) - context.line_to(pos2[0],pos2[1]) - context.line_to(pos3[0],pos3[1]) - context.line_to(pos1[0],pos1[1]) - context.fill() + context.fill() def on_drag_drop(self, widget, drag_context, x, y, time): @@ -311,14 +321,15 @@ class TerminatorTerm: def on_drag_data_received(self, widget, drag_context, x, y, selection_data, info, time, data): print "Drag Data Received on " widgetsrc = data.terminator.term_list[int(selection_data.data)] - srchbox = widgetsrc.get_box() - dsthbox = widget.get_parent().get_parent() - + srcvte = drag_context.get_source_widget() #check if computation requireds - if dsthbox == srchbox: + if srcvte == widget: print "on itself" return + srchbox = widgetsrc.get_box() + dsthbox = widget.get_parent().get_parent() + dstpaned = dsthbox.get_parent() srcpaned = srchbox.get_parent() if isinstance(dstpaned, gtk.Window) and isinstance(srcpaned, gtk.Window): From 6322a5ba0d9dc0e8d5a3f83e550251d93bf38e69 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Wed, 5 Mar 2008 16:28:20 +0000 Subject: [PATCH 13/28] adding rectangle layout --- terminator | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/terminator b/terminator index 893ba4df..8e6a63b7 100755 --- a/terminator +++ b/terminator @@ -116,6 +116,7 @@ class TerminatorTerm: 'scrollback_lines' : 100, 'focus' : 'sloppy', 'exit_action' : 'close', + 'overlay_type' : "triangle", 'palette' : '#000000000000:#CDCD00000000:#0000CDCD0000:#CDCDCDCD0000:#30BF30BFA38E:#A53C212FA53C:#0000CDCDCDCD:#FAFAEBEBD7D7:#404040404040:#FFFF00000000:#0000FFFF0000:#FFFFFFFF0000:#00000000FFFF:#FFFF0000FFFF:#0000FFFFFFFF:#FFFFFFFFFFFF', 'word_chars' : '-A-Za-z0-9,./?%&#:_', 'mouse_autohide' : True, @@ -214,8 +215,9 @@ class TerminatorTerm: self._vte.connect ("popup-menu", self.on_vte_popup_menu) """drag and drop""" - target = [ ( "vte", 0, 81 ) ] + target = [ ( "vte", 0, 81 ), ('text/plain', 0, 0) ] self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, target, gtk.gdk.ACTION_COPY) + #self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,target, gtk.gdk.ACTION_COPY) self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,target, gtk.gdk.ACTION_COPY) self._vte.connect("drag-data-get", self.on_drag_data_get, self) @@ -264,6 +266,7 @@ class TerminatorTerm: #on self return + alloc = widget.allocation rect = gtk.gdk.Rectangle(0, 0, alloc.width, alloc.height) widget.window.invalidate_rect(rect, True) @@ -287,26 +290,43 @@ class TerminatorTerm: b2 = alloc.height topleft = (0,0) topright = (alloc.width,0) + topmiddle = (alloc.width/2,0) bottomleft = (0, alloc.height) bottomright = (alloc.width,alloc.height) + bottommiddle = (alloc.width/2, alloc.height) middle = (alloc.width/2, alloc.height/2) + middleleft = (0, alloc.height/2) + middleright = (alloc.width, alloc.height/2) + overlay_type = self.reconf ('overlay_type') #print "%f %f %d %d" %(coef1, coef2, b1,b2) coord = () if (x*coef1 + b1 > y ) and (x*coef2 + b2 < y ): #print "right" - coord = (topright, middle, bottomright) + if overlay_type == "triangle": + coord = (topright, middle, bottomright) + else: + coord = (topright, topmiddle, bottommiddle, bottomright) if (x*coef1 + b1 > y ) and (x*coef2 + b2 > y ): #print "top" - coord = (topleft, middle, topright) + if overlay_type == "triangle": + coord = (topleft, middle, topright) + else: + coord = (topleft, topright, middleright , middleleft) if (x*coef1 + b1 < y ) and (x*coef2 + b2 > y ): #print "left" - coord = (topleft, middle, bottomleft) + if overlay_type == "triangle": + coord = (topleft, middle, bottomleft) + else: + coord = (topleft, topmiddle, bottommiddle, bottomleft) if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ): #print "bottom" - coord = (bottomleft, middle, bottomright) + if overlay_type == "triangle": + coord = (bottomleft, middle, bottomright) + else: + coord = (bottomleft, bottomright, middleright , middleleft) if len(coord) > 0 : - context.move_to(coord[2][0],coord[2][1]) + context.move_to(coord[len(coord)-1][0],coord[len(coord)-1][1]) for i in coord: context.line_to(i[0],i[1]) From c81df8ab054c353d3e799a70ace287321cd16467 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Thu, 6 Mar 2008 14:54:31 +0000 Subject: [PATCH 14/28] fiddling around with text dnd --- terminator | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/terminator b/terminator index 8e6a63b7..06a23ee5 100755 --- a/terminator +++ b/terminator @@ -215,10 +215,11 @@ class TerminatorTerm: self._vte.connect ("popup-menu", self.on_vte_popup_menu) """drag and drop""" - target = [ ( "vte", 0, 81 ), ('text/plain', 0, 0) ] - self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, target, gtk.gdk.ACTION_COPY) - #self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,target, gtk.gdk.ACTION_COPY) - self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,target, gtk.gdk.ACTION_COPY) + srctargets = [ ( "vte", 0, 81 ) ] + dsttargets = [ ( "vte", 0, 81 ), ('text/plain', 0, 0) , ("STRING", 0, 0), ("COMPOUND_TEXT", 0, 0)] + self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, srctargets, gtk.gdk.ACTION_COPY) + #self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_COPY) + self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_COPY) self._vte.connect("drag-data-get", self.on_drag_data_get, self) #for testing purpose: drag-motion @@ -261,6 +262,22 @@ class TerminatorTerm: def on_drag_motion(self, widget, drag_context, x, y, time, data): #print "Drag Motion on ", + """ +x-special/gnome-icon-list +text/uri-list +UTF8_STRING +COMPOUND_TEXT +TEXT +STRING +text/plain;charset=utf-8 +text/plain;charset=UTF-8 +text/plain + """ + print "motion" + + if 'text/plain' in drag_context.targets: + #copy text from another widget + return srcwidget = drag_context.get_source_widget() if widget == srcwidget: #on self @@ -340,6 +357,13 @@ class TerminatorTerm: def on_drag_data_received(self, widget, drag_context, x, y, selection_data, info, time, data): print "Drag Data Received on " + if selection_data.type == 'text/plain': + #copy text to destination + txt = selection_data.data.strip() + if txt[0:7] == "file://": + txt = txt[7:] + self._vte.feed_child("'%s'" % txt) + return widgetsrc = data.terminator.term_list[int(selection_data.data)] srcvte = drag_context.get_source_widget() #check if computation requireds From 4109deef2650eeae8572cfecce5afa6c49f40241 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Thu, 6 Mar 2008 14:56:30 +0000 Subject: [PATCH 15/28] changed gtk.gdk.ACTION_COPY to gtk.gdk.ACTION_MOVE --- terminator | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/terminator b/terminator index 06a23ee5..3da5c8ca 100755 --- a/terminator +++ b/terminator @@ -217,9 +217,9 @@ class TerminatorTerm: """drag and drop""" srctargets = [ ( "vte", 0, 81 ) ] dsttargets = [ ( "vte", 0, 81 ), ('text/plain', 0, 0) , ("STRING", 0, 0), ("COMPOUND_TEXT", 0, 0)] - self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, srctargets, gtk.gdk.ACTION_COPY) - #self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_COPY) - self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_COPY) + self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, srctargets, gtk.gdk.ACTION_MOVE) + #self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_MOVE) + self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_MOVE) self._vte.connect("drag-data-get", self.on_drag_data_get, self) #for testing purpose: drag-motion @@ -273,7 +273,7 @@ text/plain;charset=utf-8 text/plain;charset=UTF-8 text/plain """ - print "motion" + #print "motion" if 'text/plain' in drag_context.targets: #copy text from another widget From 90ffd49eb7c7f592117bd08c8e2309bfe8138fe3 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Thu, 6 Mar 2008 14:57:16 +0000 Subject: [PATCH 16/28] rectangle overlay default --- terminator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminator b/terminator index 3da5c8ca..c5babd82 100755 --- a/terminator +++ b/terminator @@ -116,7 +116,7 @@ class TerminatorTerm: 'scrollback_lines' : 100, 'focus' : 'sloppy', 'exit_action' : 'close', - 'overlay_type' : "triangle", + 'overlay_type' : "rectangle", 'palette' : '#000000000000:#CDCD00000000:#0000CDCD0000:#CDCDCDCD0000:#30BF30BFA38E:#A53C212FA53C:#0000CDCDCDCD:#FAFAEBEBD7D7:#404040404040:#FFFF00000000:#0000FFFF0000:#FFFFFFFF0000:#00000000FFFF:#FFFF0000FFFF:#0000FFFFFFFF:#FFFFFFFFFFFF', 'word_chars' : '-A-Za-z0-9,./?%&#:_', 'mouse_autohide' : True, From 416685efa0056fd33341336883a7db5cd7e24e9b Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Thu, 6 Mar 2008 19:06:23 +0000 Subject: [PATCH 17/28] * Added: titlebars can be drag and dropped --- terminator | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/terminator b/terminator index c5babd82..20bf2798 100755 --- a/terminator +++ b/terminator @@ -215,13 +215,14 @@ class TerminatorTerm: self._vte.connect ("popup-menu", self.on_vte_popup_menu) """drag and drop""" - srctargets = [ ( "vte", 0, 81 ) ] + srcvtetargets = [ ( "vte", 0, 81 ) ] dsttargets = [ ( "vte", 0, 81 ), ('text/plain', 0, 0) , ("STRING", 0, 0), ("COMPOUND_TEXT", 0, 0)] - self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, srctargets, gtk.gdk.ACTION_MOVE) + self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, srcvtetargets, gtk.gdk.ACTION_MOVE) + self._titlebox.drag_source_set( gtk.gdk.BUTTON1_MASK, srcvtetargets, gtk.gdk.ACTION_MOVE) #self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_MOVE) self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_MOVE) self._vte.connect("drag-data-get", self.on_drag_data_get, self) - + self._titlebox.connect("drag-data-get", self.on_drag_data_get, self) #for testing purpose: drag-motion self._vte.connect("drag-motion", self.on_drag_motion, self) self._vte.connect("drag-data-received", self.on_drag_data_received, self) @@ -279,7 +280,7 @@ text/plain #copy text from another widget return srcwidget = drag_context.get_source_widget() - if widget == srcwidget: + if (isinstance(srcwidget, gtk.EventBox) and srcwidget == self._titlebox) or widget == srcwidget: #on self return From 998a59bddff46c8e200280ae26482f311e229a9c Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Thu, 6 Mar 2008 19:13:10 +0000 Subject: [PATCH 18/28] fix drop on itself with titlebars --- terminator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminator b/terminator index 20bf2798..20434e39 100755 --- a/terminator +++ b/terminator @@ -368,7 +368,7 @@ text/plain widgetsrc = data.terminator.term_list[int(selection_data.data)] srcvte = drag_context.get_source_widget() #check if computation requireds - if srcvte == widget: + if (isinstance(srcvte, gtk.EventBox) and srcvte == self._titlebox) or srcvte == widget: print "on itself" return From e8657fb9867a4b889eaf203933d3de79cf669411 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Thu, 6 Mar 2008 20:00:08 +0000 Subject: [PATCH 19/28] add terminator icon to dnd --- terminator | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/terminator b/terminator index 20434e39..4e7f91b4 100755 --- a/terminator +++ b/terminator @@ -27,6 +27,9 @@ gettext.install ('terminator') # import unix-lib import pwd + +TARGET_TYPE_VTE = 8 + # import gconf if possible, if not construct a fake replacement class fakegconfclient: def get_string (self, key): @@ -215,12 +218,14 @@ class TerminatorTerm: self._vte.connect ("popup-menu", self.on_vte_popup_menu) """drag and drop""" - srcvtetargets = [ ( "vte", 0, 81 ) ] - dsttargets = [ ( "vte", 0, 81 ), ('text/plain', 0, 0) , ("STRING", 0, 0), ("COMPOUND_TEXT", 0, 0)] + srcvtetargets = [ ( "vte", 0, TARGET_TYPE_VTE ) ] + dsttargets = [ ( "vte", 0, TARGET_TYPE_VTE ), ('text/plain', 0, 0) , ("STRING", 0, 0), ("COMPOUND_TEXT", 0, 0)] self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, srcvtetargets, gtk.gdk.ACTION_MOVE) self._titlebox.drag_source_set( gtk.gdk.BUTTON1_MASK, srcvtetargets, gtk.gdk.ACTION_MOVE) #self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_MOVE) self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_MOVE) + self._vte.connect("drag-begin", self.on_drag_begin, self) + self._titlebox.connect("drag-begin", self.on_drag_begin, self) self._vte.connect("drag-data-get", self.on_drag_data_get, self) self._titlebox.connect("drag-data-get", self.on_drag_data_get, self) #for testing purpose: drag-motion @@ -257,10 +262,15 @@ class TerminatorTerm: self.spawn_child () + def on_drag_begin(self, widget, drag_context, data): + if os.path.exists("/usr/share/icons/hicolor/48x48/apps/terminator.png"): + widget.drag_source_set_icon_pixbuf( gtk.gdk.pixbuf_new_from_file("/usr/share/icons/hicolor/48x48/apps/terminator.png")) + def on_drag_data_get(self,widget, drag_context, selection_data, info, time, data): print "Drag data get" selection_data.set("vte",info, str(data.terminator.term_list.index (self))) - + + def on_drag_motion(self, widget, drag_context, x, y, time, data): #print "Drag Motion on ", """ @@ -360,11 +370,13 @@ text/plain print "Drag Data Received on " if selection_data.type == 'text/plain': #copy text to destination + #print "%s %s" % (selection_data.type, selection_data.target) txt = selection_data.data.strip() if txt[0:7] == "file://": - txt = txt[7:] - self._vte.feed_child("'%s'" % txt) + txt = "'%s'" % txt[7:] + self._vte.feed_child(txt) return + widgetsrc = data.terminator.term_list[int(selection_data.data)] srcvte = drag_context.get_source_widget() #check if computation requireds From f4c5112847cdefd6a4ac0c00b37794215abe3a7c Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Fri, 7 Mar 2008 12:09:59 +0000 Subject: [PATCH 20/28] aggregating methids --- terminator | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/terminator b/terminator index 4e7f91b4..a5816380 100755 --- a/terminator +++ b/terminator @@ -218,8 +218,8 @@ class TerminatorTerm: self._vte.connect ("popup-menu", self.on_vte_popup_menu) """drag and drop""" - srcvtetargets = [ ( "vte", 0, TARGET_TYPE_VTE ) ] - dsttargets = [ ( "vte", 0, TARGET_TYPE_VTE ), ('text/plain', 0, 0) , ("STRING", 0, 0), ("COMPOUND_TEXT", 0, 0)] + srcvtetargets = [ ( "vte", gtk.TARGET_SAME_APP, TARGET_TYPE_VTE ) ] + dsttargets = [ ( "vte", gtk.TARGET_SAME_APP, TARGET_TYPE_VTE ), ('text/plain', 0, 0) , ("STRING", 0, 0), ("COMPOUND_TEXT", 0, 0)] self._vte.drag_source_set( gtk.gdk.CONTROL_MASK | gtk.gdk.BUTTON3_MASK, srcvtetargets, gtk.gdk.ACTION_MOVE) self._titlebox.drag_source_set( gtk.gdk.BUTTON1_MASK, srcvtetargets, gtk.gdk.ACTION_MOVE) #self._vte.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT |gtk.DEST_DEFAULT_DROP ,dsttargets, gtk.gdk.ACTION_MOVE) @@ -305,17 +305,11 @@ text/plain color = self._vte.get_style ().text[gtk.STATE_NORMAL] else: color = gtk.gdk.color_parse (self.reconf ('foreground_color')) - #color = gtk.gdk.color_parse(self.reconf ('foreground_color')) - - - - context.set_source_rgba(color.red, color.green, color.blue, 0.5) #red - coef1 = float(alloc.height)/float(alloc.width) - coef2 = -float(alloc.height)/float(alloc.width) - b1 = 0 - b2 = alloc.height + context.set_source_rgba(color.red, color.green, color.blue, 0.5) + + pos = self.get_location(widget, x, y) topleft = (0,0) topright = (alloc.width,0) topmiddle = (alloc.width/2,0) @@ -328,25 +322,25 @@ text/plain overlay_type = self.reconf ('overlay_type') #print "%f %f %d %d" %(coef1, coef2, b1,b2) coord = () - if (x*coef1 + b1 > y ) and (x*coef2 + b2 < y ): + if pos == "right": #print "right" if overlay_type == "triangle": coord = (topright, middle, bottomright) else: coord = (topright, topmiddle, bottommiddle, bottomright) - if (x*coef1 + b1 > y ) and (x*coef2 + b2 > y ): + if pos == "top": #print "top" if overlay_type == "triangle": coord = (topleft, middle, topright) else: coord = (topleft, topright, middleright , middleleft) - if (x*coef1 + b1 < y ) and (x*coef2 + b2 > y ): + if pos == "left": #print "left" if overlay_type == "triangle": coord = (topleft, middle, bottomleft) else: coord = (topleft, topmiddle, bottommiddle, bottomleft) - if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ): + if pos == "bottom": #print "bottom" if overlay_type == "triangle": coord = (bottomleft, middle, bottomright) @@ -392,12 +386,20 @@ text/plain if isinstance(dstpaned, gtk.Window) and isinstance(srcpaned, gtk.Window): print "Only one terminal" return + pos = self.get_location(widget, x, y) + + data.terminator.remove(widgetsrc) + data.terminator.add(self, widgetsrc,pos) + return + + def get_location(self, vte, x, y): + pos = "" #get the diagonales function for the receiving widget - coef1 = float(widget.allocation.height)/float(widget.allocation.width) - coef2 = -float(widget.allocation.height)/float(widget.allocation.width) + coef1 = float(vte.allocation.height)/float(vte.allocation.width) + coef2 = -float(vte.allocation.height)/float(vte.allocation.width) b1 = 0 - b2 = dsthbox.allocation.height - #determine mouse position in rectangle + b2 = vte.allocation.height + #determine position in rectangle """ -------- |\ /| @@ -416,11 +418,9 @@ text/plain pos = "left" if (x*coef1 + b1 < y ) and (x*coef2 + b2 < y ): pos = "bottom" + return pos + - data.terminator.remove(widgetsrc) - data.terminator.add(self, widgetsrc,pos) - return - def spawn_child (self, event=None): update_records = self.gconf_client.get_bool (self.profile + "/update_records") or True login = self.gconf_client.get_bool (self.profile + "/login_shell") or False From b22e25a6ecb04a81d267c6096eb7eb6387878a55 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Sat, 8 Mar 2008 20:13:22 +0000 Subject: [PATCH 21/28] adding tab support --- terminator | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 170 insertions(+), 7 deletions(-) diff --git a/terminator b/terminator index a5816380..9c97afd1 100755 --- a/terminator +++ b/terminator @@ -675,6 +675,9 @@ text/plain elif keyname == 'S': self.do_scrollbar_toggle () return (True) + elif keyname == 'T': + self.terminator.newtab(self) + return (True) elif keyname in ('Up', 'Down', 'Left', 'Right'): self.terminator.resizeterm (self, keyname) return (True) @@ -771,6 +774,10 @@ text/plain item = gtk.MenuItem (_("Split V_ertically")) item.connect ("activate", lambda menu_item: self.terminator.splitaxis (self, True)) menu.append (item) + + item = gtk.MenuItem (_("Open _Tab")) + item.connect ("activate", lambda menu_item: self.terminator.newtab (self)) + menu.append (item) item = gtk.MenuItem () menu.append (item) @@ -788,7 +795,11 @@ text/plain vte.set_property ("tooltip-text", vte.get_window_title ()) #set the title anyhow, titlebars setting only show/hide the label self._title.set_text(vte.get_window_title ()) - self.terminator.set_window_title("Terminator: %s" %vte.get_window_title ()) + self.terminator.set_window_title("Terminator: %s" % vte.get_window_title ()) + notebookpage = self.terminator.get_first_notebook_page(vte) + while notebookpage != None: + notebookpage[0].set_tab_label_text(notebookpage[1], vte.get_window_title ()) + notebookpage = self.terminator.get_first_notebook_page(notebookpage[0]) def on_vte_focus_in(self, vte, event): self._titlebox.modify_bg(gtk.STATE_NORMAL,self.terminator.window.get_style().bg[gtk.STATE_SELECTED]) @@ -802,7 +813,11 @@ text/plain def on_vte_focus(self, vte): if vte.get_window_title (): - self.terminator.set_window_title("Terminator: %s" %vte.get_window_title ()) + self.terminator.set_window_title("Terminator: %s" % vte.get_window_title ()) + notebookpage = self.terminator.get_first_notebook_page(vte) + while notebookpage != None: + notebookpage[0].set_tab_label_text(notebookpage[1], vte.get_window_title ()) + notebookpage = self.terminator.get_first_notebook_page(notebookpage[0]) def get_box (self): return self._box @@ -961,6 +976,30 @@ class Terminator: position = (vertical) and parent.allocation.height \ or parent.allocation.width + if isinstance (parent, gtk.Notebook): + page = -1 + for i in range(0, parent.get_n_pages()): + if parent.get_nth_page(i) == widget.get_box(): + page = i + break + widget.get_box ().reparent (pane) + if pos in ("top", "left"): + pane.remove(widget.get_box ()) + pane.pack1 (terminal.get_box (), True, True) + pane.pack2 (widget.get_box (), True, True) + else: + pane.pack1 (widget.get_box (), True, True) + pane.pack2 (terminal.get_box (), True, True) + #parent.remove_page(page) + pane.show() + parent.insert_page(pane, None, page) + parent.set_tab_label_text(pane, widget._vte.get_window_title()) + parent.set_tab_label_packing(pane, True, True, gtk.PACK_START) + parent.set_current_page(page) + + + position = (vertical) and parent.allocation.height \ + or parent.allocation.width if isinstance (parent, gtk.Paned): # We are inside a split term position = (vertical) and widget.get_box().allocation.height \ @@ -996,7 +1035,54 @@ class Terminator: terminal._vte.grab_focus () return (terminal) + + def newtab(self,widget): + terminal = TerminatorTerm (self, self.profile, None, widget.get_cwd()) + widgetbox = widget.get_box () + parent = widgetbox.get_parent () + + if isinstance(parent, gtk.Paned): + #no notebook yet. + notebook = gtk.Notebook() + notebook.set_property('homogeneous', True) + if parent.get_child1() == widgetbox: + widgetbox.reparent(notebook) + parent.pack1(notebook) + notebook.set_tab_label_text(widgetbox, widget._vte.get_window_title()) + notebook. set_tab_label_packing(widgetbox, True, True, gtk.PACK_START) + else: + widgetbox.reparent(notebook) + notebook.set_tab_label_text(widgetbox, widget._vte.get_window_title()) + notebook. set_tab_label_packing(widgetbox, True, True, gtk.PACK_START) + parent.pack2(notebook) + elif isinstance(parent, gtk.Window): + notebook = gtk.Notebook() + notebook.set_property('homogeneous', True) + + widgetbox.reparent(notebook) + notebook.set_tab_label_text(widgetbox, widget._vte.get_window_title()) + notebook. set_tab_label_packing(widgetbox, True, True, gtk.PACK_START) + parent.add(notebook) + elif isinstance(parent, gtk.Notebook): + notebook = parent + else: + return (False) + + notebook.show() + #notebook.set_property('homogeneous', True) + notebook.append_page(terminal.get_box(),terminal._vte.get_window_title()) + notebook. set_tab_label_packing(terminal.get_box(), True, True, gtk.PACK_START) + notebook.set_current_page(-1) + index = self.term_list.index(widget) + self.term_list.insert (index + 1, terminal) + terminal.get_box ().show () + terminal._vte.grab_focus () + return (True) + + + return terminal + def splitaxis (self, widget, vertical=True): """ Split the provided widget on the horizontal or vertical axis. """ # create a new terminal and parent pane. @@ -1034,9 +1120,21 @@ class Terminator: return False parent.remove(widget.get_box()) - grandparent.remove (parent) - sibling.reparent (grandparent) - grandparent.resize_children() + if isinstance(grandparent, gtk.Notebook): + page = -1 + for i in range(0, grandparent.get_n_pages()): + if grandparent.get_nth_page(i) == parent: + page = i + break + parent.remove(sibling) + grandparent.remove_page(page) + grandparent.insert_page(sibling, None,page) + grandparent.set_tab_label_packing(sibling, True, True, gtk.PACK_START) + + else: + grandparent.remove (parent) + sibling.reparent (grandparent) + grandparent.resize_children() parent.destroy () self.term_list.remove (widget) @@ -1048,6 +1146,28 @@ class Terminator: else: if index == 0: index = 1 self.term_list[index - 1]._vte.grab_focus () + elif isinstance (parent, gtk.Notebook): + parent.remove(widget.get_box()) + nbpages = parent.get_n_pages() + index = self.term_list.index (widget) + self.term_list.remove (widget) + if nbpages == 1: + sibling = parent.get_nth_page(0) + parent.remove(sibling) + gdparent = parent.get_parent() + if isinstance(gdparent, gtk.Window): + gdparent.remove(parent) + gdparent.add(sibling) + elif isinstance(gdparent, gtk.Paned): + if gdparent.get_child1() == parent: + gdparent.remove(parent) + gdparent.pack1(sibling) + else: + gdparent.remove(parent) + gdparent.pack2(sibling) + parent.destroy() + if index == 0: index = 1 + self.term_list[index - 1]._vte.grab_focus () return True @@ -1066,7 +1186,24 @@ class Terminator: else: next += 1 - self.term_list[next]._vte.grab_focus () + + nextterm = self.term_list[next] + if isinstance(nextterm.get_box().get_parent(), gtk.Notebook): + box = nextterm.get_box() + parent = box.get_parent() + for i in range(0, parent.get_n_pages()): + if box == parent.get_nth_page(i): + parent.set_current_page(i) + break + notebookpage = self.get_first_notebook_page(nextterm.get_box()) + if notebookpage: + child = None + for i in range(0, notebookpage[0].get_n_pages()): + if notebookpage[0].get_nth_page(i) == notebookpage[1]: + notebookpage[0].set_current_page(i) + break + nextterm._vte.grab_focus () + def go_prev (self, term): current = self.term_list.index (term) @@ -1078,7 +1215,22 @@ class Terminator: previous -= 1 #self.window.set_title(self.term_list[previous]._vte.get_window_title()) - self.term_list[previous]._vte.grab_focus () + previousterm = self.term_list[previous] + if isinstance(previousterm.get_box().get_parent(), gtk.Notebook): + box = previousterm.get_box() + parent = box.get_parent() + for i in range(0, parent.get_n_pages()): + if box == parent.get_nth_page(i): + parent.set_current_page(i) + break + notebookpage = self.get_first_notebook_page(previousterm.get_box()) + if notebookpage: + child = None + for i in range(0, notebookpage[0].get_n_pages()): + if notebookpage[0].get_nth_page(i) == notebookpage[1]: + notebookpage[0].set_current_page(i) + break + previousterm._vte.grab_focus () @@ -1130,6 +1282,17 @@ class Terminator: elif isinstance (parent, gtk.HPaned) and not vertical: return parent return self.get_first_parent_paned(parent, vertical) + + def get_first_notebook_page(self, widget): + if isinstance (widget, gtk.Window): + return None + parent = widget.get_parent() + if isinstance (parent, gtk.Notebook): + page = -1 + for i in range(0, parent.get_n_pages()): + if parent.get_nth_page(i) == widget: + return (parent, widget) + return self.get_first_notebook_page(parent) if __name__ == '__main__': try: From 78c7918dd77b75f0bcf46898605d971b06b71b00 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Thu, 13 Mar 2008 17:48:24 +0000 Subject: [PATCH 22/28] adding Ctrl-Page_Up/Page_Down keybinding it will get the first notebook parent and will go to the previous/next tab --- terminator | 72 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/terminator b/terminator index 9c97afd1..31d06480 100755 --- a/terminator +++ b/terminator @@ -681,7 +681,17 @@ text/plain elif keyname in ('Up', 'Down', 'Left', 'Right'): self.terminator.resizeterm (self, keyname) return (True) - + + mask = gtk.gdk.CONTROL_MASK + if (event.state & mask) == mask: + if keyname == 'Page_Down': + self.terminator.next_tab(self) + return (True) + elif keyname == 'Page_Up': + self.terminator.previous_tab(self) + return (True) + + if keyname and (keyname == 'Tab' or keyname.endswith('_Tab')): if event.state == gtk.gdk.CONTROL_MASK: self.terminator.go_next (self) @@ -1035,44 +1045,45 @@ class Terminator: terminal._vte.grab_focus () return (terminal) - + def on_page_reordered(self, notebook, child, page_num): + print page_num + + + def newtab(self,widget): terminal = TerminatorTerm (self, self.profile, None, widget.get_cwd()) widgetbox = widget.get_box () parent = widgetbox.get_parent () - if isinstance(parent, gtk.Paned): + if isinstance(parent, gtk.Paned) or isinstance(parent, gtk.Window): #no notebook yet. notebook = gtk.Notebook() + notebook.connect('page-reordered',self.on_page_reordered) notebook.set_property('homogeneous', True) - if parent.get_child1() == widgetbox: - widgetbox.reparent(notebook) - parent.pack1(notebook) - notebook.set_tab_label_text(widgetbox, widget._vte.get_window_title()) - notebook. set_tab_label_packing(widgetbox, True, True, gtk.PACK_START) - else: - widgetbox.reparent(notebook) - notebook.set_tab_label_text(widgetbox, widget._vte.get_window_title()) - notebook. set_tab_label_packing(widgetbox, True, True, gtk.PACK_START) - parent.pack2(notebook) - elif isinstance(parent, gtk.Window): - notebook = gtk.Notebook() - notebook.set_property('homogeneous', True) - - widgetbox.reparent(notebook) - notebook.set_tab_label_text(widgetbox, widget._vte.get_window_title()) + notebook.set_tab_reorderable(widgetbox, True) + if isinstance(parent, gtk.Paned): + if parent.get_child1() == widgetbox: + widgetbox.reparent(notebook) + parent.pack1(notebook) + else: + widgetbox.reparent(notebook) + parent.pack2(notebook) + elif isinstance(parent, gtk.Window): + widgetbox.reparent(notebook) + parent.add(notebook) + notebook.set_tab_reorderable(widgetbox,True) + notebook.set_tab_label_text(widgetbox, widget._vte.get_window_title()) notebook. set_tab_label_packing(widgetbox, True, True, gtk.PACK_START) - parent.add(notebook) + notebook.show() elif isinstance(parent, gtk.Notebook): notebook = parent else: return (False) - notebook.show() - #notebook.set_property('homogeneous', True) notebook.append_page(terminal.get_box(),terminal._vte.get_window_title()) notebook. set_tab_label_packing(terminal.get_box(), True, True, gtk.PACK_START) + notebook.set_tab_reorderable(terminal.get_box(),True) notebook.set_current_page(-1) index = self.term_list.index(widget) self.term_list.insert (index + 1, terminal) @@ -1266,6 +1277,23 @@ class Terminator: parent.set_position(move) + def previous_tab(self, term): + notebook = self.get_first_parent_notebook(term.get_box()) + notebook.prev_page() + return + + def next_tab(self, term): + notebook = self.get_first_parent_notebook(term.get_box()) + notebook.next_page() + return + + def get_first_parent_notebook(self, widget): + if isinstance (widget, gtk.Window): + return None + parent = widget.get_parent() + if isinstance (parent, gtk.Notebook): + return parent + return self.get_first_parent_notebook(parent) def get_first_parent_paned (self, widget, vertical = None): """This method returns the first parent pane of a widget. From afde88d7dc6bf8711f1a2b034dd448247bc30e3f Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Tue, 8 Apr 2008 20:35:48 +0100 Subject: [PATCH 23/28] fix LP#213230 --- terminator | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/terminator b/terminator index 31d06480..adf82eb6 100755 --- a/terminator +++ b/terminator @@ -1060,8 +1060,8 @@ class Terminator: notebook = gtk.Notebook() notebook.connect('page-reordered',self.on_page_reordered) notebook.set_property('homogeneous', True) - notebook.set_tab_reorderable(widgetbox, True) + if isinstance(parent, gtk.Paned): if parent.get_child1() == widgetbox: widgetbox.reparent(notebook) @@ -1073,7 +1073,11 @@ class Terminator: widgetbox.reparent(notebook) parent.add(notebook) notebook.set_tab_reorderable(widgetbox,True) - notebook.set_tab_label_text(widgetbox, widget._vte.get_window_title()) + notebooklabel = "" + print widget._vte.get_window_title() + if widget._vte.get_window_title() is not None: + notebooklabel = widget._vte.get_window_title() + notebook.set_tab_label_text(widgetbox, notebooklabel) notebook. set_tab_label_packing(widgetbox, True, True, gtk.PACK_START) notebook.show() elif isinstance(parent, gtk.Notebook): From c5ff753e974274bf7ed473396feb1ac37216eb27 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Sat, 12 Apr 2008 13:10:34 +0100 Subject: [PATCH 24/28] Fixes titlebars not showing if disabled in user profile * fixes LP#216278 thanks GGLucas --- terminator | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/terminator b/terminator index adf82eb6..a063b977 100755 --- a/terminator +++ b/terminator @@ -196,10 +196,10 @@ class TerminatorTerm: self._box.show() self._box.pack_start(self._titlebox, False) self._box.pack_start(self._termbox) - if self.reconf('titlebars'): - self._titlebox.show() - else: - self._titlebox.hide() + self._titlebox.show() + + if not self.reconf('titlebars'): + self._title.set_property ('visible', False) self._scrollbar = gtk.VScrollbar (self._vte.get_adjustment ()) if self.scrollbar_position != "hidden" and self.scrollbar_position != "disabled": From a55d75f468fb15fca3b918dc9bdbccbed311c516 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Mon, 14 Apr 2008 10:20:52 +0100 Subject: [PATCH 25/28] removed useless print --- terminator | 1 - 1 file changed, 1 deletion(-) diff --git a/terminator b/terminator index a063b977..135b7717 100755 --- a/terminator +++ b/terminator @@ -1074,7 +1074,6 @@ class Terminator: parent.add(notebook) notebook.set_tab_reorderable(widgetbox,True) notebooklabel = "" - print widget._vte.get_window_title() if widget._vte.get_window_title() is not None: notebooklabel = widget._vte.get_window_title() notebook.set_tab_label_text(widgetbox, notebooklabel) From 04b62d18f4353f5285fbc01d775b7dbb45517c08 Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Mon, 12 May 2008 08:19:28 +0100 Subject: [PATCH 26/28] Fix redundant title when there is only one TerminatorTerm * closes LP#215210 https://bugs.launchpad.net/terminator/+bug/215210 --- terminator | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/terminator b/terminator index 135b7717..218c9ec6 100755 --- a/terminator +++ b/terminator @@ -196,11 +196,16 @@ class TerminatorTerm: self._box.show() self._box.pack_start(self._titlebox, False) self._box.pack_start(self._termbox) - self._titlebox.show() - - if not self.reconf('titlebars'): - self._title.set_property ('visible', False) + if self.reconf('titlebars'): + if len(self.terminator.term_list) > 0 and self.reconf('titlebars'): + if len(self.terminator.term_list) == 1: + self.terminator.term_list[0]._titlebox.show() + self._titlebox.show() + else: + self._titlebox.hide() + self._titlebox.set_property ('visible', False) + self._scrollbar = gtk.VScrollbar (self._vte.get_adjustment ()) if self.scrollbar_position != "hidden" and self.scrollbar_position != "disabled": self._scrollbar.show () @@ -626,10 +631,11 @@ text/plain self._scrollbar.show () def do_title_toggle (self): - if self._title.get_property ('visible'): - self._title.hide () + if self._titlebox.get_property ('visible'): + self._titlebox.hide () else: - self._title.show () + self._titlebox.show () + #self._title.show () #keybindings for the individual splited terminals (affects only the #the selected terminal) def on_vte_key_press (self, term, event): @@ -770,7 +776,7 @@ text/plain menu.append (item) item = gtk.CheckMenuItem (_("Show Title")) - item.set_active (self._title.get_property ('visible')) + item.set_active (self._titlebox.get_property ('visible')) item.connect ("toggled", lambda menu_item: self.do_title_toggle ()) menu.append (item) @@ -846,6 +852,7 @@ class Terminator: self.window = gtk.Window () self.window.set_title ("Terminator") + self.term_list = [] # FIXME: This really shouldn't be a hardcoded path try: @@ -1182,6 +1189,9 @@ class Terminator: parent.destroy() if index == 0: index = 1 self.term_list[index - 1]._vte.grab_focus () + + if len(self.term_list) == 1: + self.term_list[0]._titlebox.hide() return True From c35ebedfc2a7d22d6da0821aa2c04c08d2b99fc6 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 22 May 2008 01:39:01 +0100 Subject: [PATCH 27/28] remove triangle overlays --- terminator | 25 ++++--------------------- terminatorlib/config.py | 1 - 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/terminator b/terminator index 1d8d7410..f3c0b350 100755 --- a/terminator +++ b/terminator @@ -240,33 +240,16 @@ text/plain middle = (alloc.width/2, alloc.height/2) middleleft = (0, alloc.height/2) middleright = (alloc.width, alloc.height/2) - overlay_type = self.conf.overlay_type #print "%f %f %d %d" %(coef1, coef2, b1,b2) coord = () if pos == "right": - #print "right" - if overlay_type == "triangle": - coord = (topright, middle, bottomright) - else: - coord = (topright, topmiddle, bottommiddle, bottomright) + coord = (topright, topmiddle, bottommiddle, bottomright) if pos == "top": - #print "top" - if overlay_type == "triangle": - coord = (topleft, middle, topright) - else: - coord = (topleft, topright, middleright , middleleft) + coord = (topleft, topright, middleright , middleleft) if pos == "left": - #print "left" - if overlay_type == "triangle": - coord = (topleft, middle, bottomleft) - else: - coord = (topleft, topmiddle, bottommiddle, bottomleft) + coord = (topleft, topmiddle, bottommiddle, bottomleft) if pos == "bottom": - #print "bottom" - if overlay_type == "triangle": - coord = (bottomleft, middle, bottomright) - else: - coord = (bottomleft, bottomright, middleright , middleleft) + coord = (bottomleft, bottomright, middleright , middleleft) if len(coord) > 0 : context.move_to(coord[len(coord)-1][0],coord[len(coord)-1][1]) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 82dad7cf..8e945dc0 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -112,7 +112,6 @@ class TerminatorConfValuestore: 'ignore_hosts' : ['localhost','127.0.0.0/8','*.local'], 'encoding' : 'UTF-8', 'active_encodings' : ['UTF-8', 'ISO-8859-1'], - 'overlay_type' : 'rectangle', } def __getattr__ (self, keyname): From a6b4679c1f97bef78964c04a379485fe8c937b2c Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 22 May 2008 01:48:33 +0100 Subject: [PATCH 28/28] whitespace and remove duplicated function --- terminator | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/terminator b/terminator index f3c0b350..fb71689d 100755 --- a/terminator +++ b/terminator @@ -1012,6 +1012,7 @@ class Terminator: else: widget.reparent (pane) parent.pack2 (pane, True, True) + if pos in ("top", "left"): pane.remove(widget) pane.pack1 (terminal, True, True) @@ -1328,15 +1329,6 @@ class Terminator: if __name__ == '__main__': - def execute_cb (option, opt, value, parser): - assert value is None - value = [] - while parser.rargs: - arg = parser.rargs[0] - value.append (arg) - del (parser.rargs[0]) - setattr(parser.values, option.dest, value) - def execute_cb (option, opt, value, parser): assert value is None value = []