Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorgan Collett <morgan.collett@gmail.com>2007-11-22 18:32:43 (GMT)
committer Morgan Collett <morgan.collett@gmail.com>2007-11-22 18:32:43 (GMT)
commit3e3ef7c1f93904d9417f01baecb7232344d10d7e (patch)
tree5669ff9469b29a8577f938a4962dc73a55f0c86a
parent376cbc6522b6129e025b3ddcd8a03adcc48e6513 (diff)
#5080: add a copy to clipboard palette for URLs
-rw-r--r--NEWS1
-rw-r--r--chat.py22
2 files changed, 23 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 85a7a4d..578054e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,4 @@
+* #5080: add a "copy to clipboard" palette for URL's (cassidy)
* Updated translations: fr, es, el, de, ar (pootle)
28
diff --git a/chat.py b/chat.py
index b9a3783..c560171 100644
--- a/chat.py
+++ b/chat.py
@@ -31,6 +31,8 @@ from sugar.graphics.style import (Color, COLOR_BLACK, COLOR_WHITE,
FONT_BOLD, FONT_NORMAL)
from sugar.graphics.roundbox import CanvasRoundBox
from sugar.graphics.xocolor import XoColor
+from sugar.graphics.palette import Palette, CanvasInvoker
+from sugar.graphics.menuitem import MenuItem
from sugar.presence import presenceservice
from telepathy.client import Connection, Channel
@@ -258,6 +260,10 @@ class Chat(Activity):
attrs.insert(pango.AttrUnderline(pango.UNDERLINE_SINGLE, 0, 32767))
message.set_property("attributes", attrs)
message.connect('activated', self._link_activated_cb)
+
+ palette = URLMenu(url)
+ palette.props.invoker = CanvasInvoker(message)
+
rb.append(message)
text = text[match.end():]
match = regexp.search(text)
@@ -417,3 +423,19 @@ class TextChannelWrapper(object):
return self._activity._pservice.get_buddy_by_telepathy_handle(
tp_name, tp_path, handle)
+
+class URLMenu(Palette):
+ def __init__(self, url):
+ Palette.__init__(self, url)
+
+ self.url = url
+
+ menu_item = MenuItem(_('Copy to Clipboard'), 'edit-copy')
+ menu_item.connect('activate', self._copy_to_clipboard_cb)
+ self.menu.append(menu_item)
+ menu_item.show()
+
+ def _copy_to_clipboard_cb(self, menuitem):
+ logger.debug('Copy %s to clipboard', self.url)
+ clipboard = gtk.clipboard_get()
+ clipboard.set_text(self.url)