2712: middle click copy paste not working in notes
svn: r12653
This commit is contained in:
parent
72838423a0
commit
705fbf4007
@ -174,6 +174,9 @@ class StyledTextEditor(gtk.TextView):
|
|||||||
settings = gtk.settings_get_default()
|
settings = gtk.settings_get_default()
|
||||||
self.show_unicode = settings.get_property('gtk-show-unicode-menu')
|
self.show_unicode = settings.get_property('gtk-show-unicode-menu')
|
||||||
settings.set_property('gtk-show-unicode-menu', False)
|
settings.set_property('gtk-show-unicode-menu', False)
|
||||||
|
|
||||||
|
# variable to not copy to clipboard on double/triple click
|
||||||
|
self.selclick = False
|
||||||
|
|
||||||
# virtual methods
|
# virtual methods
|
||||||
|
|
||||||
@ -262,12 +265,26 @@ class StyledTextEditor(gtk.TextView):
|
|||||||
self.window.get_pointer()
|
self.window.get_pointer()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def on_button_release_event(self, widget, event):
|
||||||
|
"""
|
||||||
|
Copy selection to clipboard for left click if selection given
|
||||||
|
"""
|
||||||
|
if (event.type == gtk.gdk.BUTTON_RELEASE and self.selclick and
|
||||||
|
event.button == 1):
|
||||||
|
bounds = self.textbuffer.get_selection_bounds()
|
||||||
|
if bounds:
|
||||||
|
clip = gtk.Clipboard(selection="PRIMARY")
|
||||||
|
clip.set_text(str(self.textbuffer.get_text(bounds[0],
|
||||||
|
bounds[1])))
|
||||||
|
return False
|
||||||
|
|
||||||
def on_button_press_event(self, widget, event):
|
def on_button_press_event(self, widget, event):
|
||||||
"""Signal handler.
|
"""Signal handler.
|
||||||
|
|
||||||
Handles the <CTRL> + Left click over a URL match.
|
Handles the <CTRL> + Left click over a URL match.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
self.selclick=False
|
||||||
if ((event.type == gtk.gdk.BUTTON_PRESS) and
|
if ((event.type == gtk.gdk.BUTTON_PRESS) and
|
||||||
(event.button == 1) and
|
(event.button == 1) and
|
||||||
(event.state and gtk.gdk.CONTROL_MASK) and
|
(event.state and gtk.gdk.CONTROL_MASK) and
|
||||||
@ -276,9 +293,12 @@ class StyledTextEditor(gtk.TextView):
|
|||||||
flavor = self.url_match[MATCH_FLAVOR]
|
flavor = self.url_match[MATCH_FLAVOR]
|
||||||
url = self.url_match[MATCH_STRING]
|
url = self.url_match[MATCH_STRING]
|
||||||
self._open_url_cb(None, url, flavor)
|
self._open_url_cb(None, url, flavor)
|
||||||
|
elif (event.type == gtk.gdk.BUTTON_PRESS and event.button == 1) :
|
||||||
|
#on release we will copy selected data to clipboard
|
||||||
|
self.selclick = True
|
||||||
|
#propagate click
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def on_populate_popup(self, widget, menu):
|
def on_populate_popup(self, widget, menu):
|
||||||
"""Signal handler.
|
"""Signal handler.
|
||||||
|
|
||||||
@ -323,6 +343,7 @@ class StyledTextEditor(gtk.TextView):
|
|||||||
self.connect('paste-clipboard', self.on_paste_clipboard)
|
self.connect('paste-clipboard', self.on_paste_clipboard)
|
||||||
self.connect('motion-notify-event', self.on_motion_notify_event)
|
self.connect('motion-notify-event', self.on_motion_notify_event)
|
||||||
self.connect('button-press-event', self.on_button_press_event)
|
self.connect('button-press-event', self.on_button_press_event)
|
||||||
|
self.connect('button-release-event', self.on_button_release_event)
|
||||||
self.connect('populate-popup', self.on_populate_popup)
|
self.connect('populate-popup', self.on_populate_popup)
|
||||||
self.connect('unrealize', self.on_unrealize)
|
self.connect('unrealize', self.on_unrealize)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user