aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-chat-text-view.c
diff options
context:
space:
mode:
authorDafydd Harries <daf@rhydd.org>2009-10-01 22:32:28 +0800
committerDafydd Harries <daf@rhydd.org>2009-10-01 22:32:31 +0800
commit908127a87ff5647ff00aa54ece3ec85c48c7ffe3 (patch)
tree9be8a6999643a4d5fb2586115953f046258efffd /libempathy-gtk/empathy-chat-text-view.c
parent267e769eda9406c324b19c308330143fde287cc8 (diff)
parent0e914b5142f3ca7c6f283edbbfda986dd570deaa (diff)
downloadgsoc2013-empathy-908127a87ff5647ff00aa54ece3ec85c48c7ffe3.tar
gsoc2013-empathy-908127a87ff5647ff00aa54ece3ec85c48c7ffe3.tar.gz
gsoc2013-empathy-908127a87ff5647ff00aa54ece3ec85c48c7ffe3.tar.bz2
gsoc2013-empathy-908127a87ff5647ff00aa54ece3ec85c48c7ffe3.tar.lz
gsoc2013-empathy-908127a87ff5647ff00aa54ece3ec85c48c7ffe3.tar.xz
gsoc2013-empathy-908127a87ff5647ff00aa54ece3ec85c48c7ffe3.tar.zst
gsoc2013-empathy-908127a87ff5647ff00aa54ece3ec85c48c7ffe3.zip
Merge commit 'gabriel/fix-581488'
Diffstat (limited to 'libempathy-gtk/empathy-chat-text-view.c')
-rw-r--r--libempathy-gtk/empathy-chat-text-view.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c
index d7ebda647..5b0a35680 100644
--- a/libempathy-gtk/empathy-chat-text-view.c
+++ b/libempathy-gtk/empathy-chat-text-view.c
@@ -1159,14 +1159,58 @@ static void
chat_text_view_copy_clipboard (EmpathyChatView *view)
{
GtkTextBuffer *buffer;
+ GtkTextIter start, iter, end;
GtkClipboard *clipboard;
+ GdkPixbuf *pixbuf;
+ gunichar c;
+ GtkTextChildAnchor *anchor = NULL;
+ GString *str;
+ GList *list;
+ gboolean ignore_newlines = FALSE;
g_return_if_fail (EMPATHY_IS_CHAT_TEXT_VIEW (view));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
- gtk_text_buffer_copy_clipboard (buffer, clipboard);
+ if (!gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ return;
+
+ str = g_string_new ("");
+
+ for (iter = start; !gtk_text_iter_equal (&iter, &end); gtk_text_iter_forward_char (&iter)) {
+ c = gtk_text_iter_get_char (&iter);
+ if (c == 0xFFFC) {
+ ignore_newlines = FALSE;
+ if ((pixbuf = gtk_text_iter_get_pixbuf (&iter))) {
+ gchar *text;
+ text = g_object_get_data (G_OBJECT(pixbuf),
+ "smiley_str");
+ if (text)
+ str = g_string_append (str, text);
+ } else if ((anchor = gtk_text_iter_get_child_anchor (&iter))) {
+ gchar *text;
+ list = gtk_text_child_anchor_get_widgets (anchor);
+ if (list) {
+ text = g_object_get_data (G_OBJECT(list->data),
+ "str_obj");
+ if (text)
+ str = g_string_append (str, text);
+ }
+ g_list_free (list);
+ }
+ } else if (c == '\n') {
+ if (!ignore_newlines) {
+ ignore_newlines = TRUE;
+ str = g_string_append_unichar (str, c);
+ }
+ } else {
+ ignore_newlines = FALSE;
+ str = g_string_append_unichar (str, c);
+ }
+ }
+
+ gtk_clipboard_set_text (clipboard, g_string_free (str, FALSE), str->len);
}
static void