Improve clipboard support. If you right click a URL and don't have some text selected, you can copy the URL.
This commit is contained in:
parent
f96f64c8d2
commit
01db4e96b2
21
termiator.py
21
termiator.py
|
@ -5,6 +5,7 @@ import gtk
|
||||||
import vte
|
import vte
|
||||||
import gconf
|
import gconf
|
||||||
import pango
|
import pango
|
||||||
|
import gnome
|
||||||
|
|
||||||
class TerminatorTerm:
|
class TerminatorTerm:
|
||||||
# Our settings
|
# Our settings
|
||||||
|
@ -46,6 +47,8 @@ class TerminatorTerm:
|
||||||
self.gconf_client = gconf.client_get_default ()
|
self.gconf_client = gconf.client_get_default ()
|
||||||
self.gconf_client.add_dir (self.profile, gconf.CLIENT_PRELOAD_RECURSIVE)
|
self.gconf_client.add_dir (self.profile, gconf.CLIENT_PRELOAD_RECURSIVE)
|
||||||
|
|
||||||
|
self.clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
|
||||||
|
|
||||||
self._vte = vte.Terminal ()
|
self._vte = vte.Terminal ()
|
||||||
self.reconfigure_vte ()
|
self.reconfigure_vte ()
|
||||||
self._vte.show ()
|
self._vte.show ()
|
||||||
|
@ -148,6 +151,19 @@ class TerminatorTerm:
|
||||||
def create_popup_menu (self, event):
|
def create_popup_menu (self, event):
|
||||||
menu = gtk.Menu ()
|
menu = gtk.Menu ()
|
||||||
|
|
||||||
|
url = self._vte.match_check (int(event.x / self._vte.get_char_width ()), int(event.y / self._vte.get_char_height()))
|
||||||
|
if url:
|
||||||
|
item = gtk.ImageMenuItem (gtk.STOCK_OPEN)
|
||||||
|
item.connect ("activate", lambda menu_item: gnome.url_show (url[0]))
|
||||||
|
menu.append (item)
|
||||||
|
|
||||||
|
if not self._vte.get_has_selection():
|
||||||
|
item = gtk.ImageMenuItem (gtk.STOCK_COPY)
|
||||||
|
item.connect ("activate", lambda menu_item: self.clipboard.set_text (url[0]))
|
||||||
|
menu.append (item)
|
||||||
|
donecopy = 1
|
||||||
|
|
||||||
|
if donecopy != 1:
|
||||||
item = gtk.ImageMenuItem (gtk.STOCK_COPY)
|
item = gtk.ImageMenuItem (gtk.STOCK_COPY)
|
||||||
item.connect ("activate", lambda menu_item: self._vte.copy_clipboard ())
|
item.connect ("activate", lambda menu_item: self._vte.copy_clipboard ())
|
||||||
item.set_sensitive (self._vte.get_has_selection ())
|
item.set_sensitive (self._vte.get_has_selection ())
|
||||||
|
@ -162,11 +178,6 @@ class TerminatorTerm:
|
||||||
item.connect ("toggled", lambda menu_item: self.do_scrollbar_toggle ())
|
item.connect ("toggled", lambda menu_item: self.do_scrollbar_toggle ())
|
||||||
menu.append (item)
|
menu.append (item)
|
||||||
|
|
||||||
print "Checking %d,%d"%(event.x, event.y)
|
|
||||||
url = self._vte.match_check (int(event.x / self._vte.get_char_width ()), int(event.y / self._vte.get_char_height()))
|
|
||||||
if url:
|
|
||||||
print "over a url: " + url[0]
|
|
||||||
|
|
||||||
menu.show_all ()
|
menu.show_all ()
|
||||||
return menu
|
return menu
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue