]> git.0d.be Git - empathy.git/commitdiff
Fix copy clipboard to show smileys and to show name and time when using themes other...
authorGabriel Millaire <millaire.gabriel@gmail.com>
Wed, 1 Jul 2009 17:17:00 +0000 (13:17 -0400)
committerGabriel Millaire <gabriel.millaire@collabora.co.uk>
Wed, 30 Sep 2009 18:14:10 +0000 (14:14 -0400)
Adds an association string to hbox for name and time in themes, adds an association string to pixbuf smiley

libempathy-gtk/empathy-chat-text-view.c
libempathy-gtk/empathy-smiley-manager.c
libempathy-gtk/empathy-theme-boxes.c

index d7ebda647f0bd763663728bbcb7e3c4315cbccf1..2e83cdfb80e284e40ef13f56a8a86eb7a079953a 100644 (file)
@@ -1159,14 +1159,59 @@ 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 flag_return = FALSE;
+
+       str = g_string_new ("");
 
        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)) {
+               iter = start;
+               while ((c = gtk_text_iter_get_char (&iter)) != 0 &&
+                       !gtk_text_iter_equal (&iter, &end)) {
+                       if (c == 0xFFFC) {
+                               flag_return = 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 (!flag_return) {
+                                       flag_return = TRUE;
+                                       str = g_string_append_unichar (str, c);
+                               }
+                       } else {
+                               flag_return = FALSE;
+                               str = g_string_append_unichar (str, c);
+                       }
+                       gtk_text_iter_forward_char (&iter);
+               }
+       }
+
+       gtk_clipboard_set_text (clipboard, g_string_free (str, FALSE), -1);
 }
 
 static void
index 900e9211c3953289421939f5a4dd9d6b5c647185..0d3e4c512f77689fe52949996a3e057272496174 100644 (file)
@@ -245,6 +245,8 @@ smiley_manager_add_valist (EmpathySmileyManager *manager,
        }
 
        /* We give the ownership of path to the smiley */
+       g_object_set_data_full (G_OBJECT (pixbuf), "smiley_str",
+                               g_strdup (first_str), g_free);
        smiley = smiley_new (pixbuf, g_strdup (first_str), path);
        priv->smileys = g_slist_prepend (priv->smileys, smiley);
 }
index f5224278caace526613ea0891e515e5fa2b0ac06..0c989ba11010d635ef8dec9c4b64fa0b8f19487f 100644 (file)
@@ -199,6 +199,7 @@ theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme,
        gboolean              color_set;
        GtkTextTagTable      *table;
        GtkTextTag           *tag;
+       GString              *str_obj;
 
        contact = empathy_message_get_sender (msg);
        name = empathy_contact_get_name (contact);
@@ -267,6 +268,12 @@ theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme,
                               "use-markup", TRUE,
                               "xalign", 1.0,
                               NULL);
+
+       str_obj = g_string_new ("\n- ");
+       str_obj = g_string_append (str_obj, name);
+       str_obj = g_string_append (str_obj, ", ");
+       str_obj = g_string_append (str_obj, tmp);
+       str_obj = g_string_append (str_obj, " -");
        g_free (tmp);
        g_free (str);
 
@@ -290,6 +297,10 @@ theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme,
        gtk_box_pack_start (GTK_BOX (box), label2, TRUE, TRUE, 0);
 
        /* Add the header box to the text view */
+       g_object_set_data_full (G_OBJECT (box),
+                               "str_obj",
+                               g_string_free (str_obj, FALSE),
+                               g_free);
        gtk_text_view_add_child_at_anchor (GTK_TEXT_VIEW (view),
                                           box,
                                           anchor);