Mercurial > pidgin.yaz
comparison src/gtkimhtml.c @ 10526:55e7d72fc09a
[gaim-migrate @ 11843]
maquina writes:
This patch implements a custom smiley API, and it also
implements custom smileys for the msn protocol. As it
stands, it is not able to cache custom smileys, and is
not able to redefine a custom smiley without opening a
new conversation.
I modified it quite a bit, and didn't test it at all, so it probably
doesn't work anymore. I'm not quite done with it yet either.
Also, this is just receiving custom smileys.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Tue, 18 Jan 2005 18:31:32 +0000 |
parents | ddea15f4cbc2 |
children | 74180743304a |
comparison
equal
deleted
inserted
replaced
10525:ddea15f4cbc2 | 10526:55e7d72fc09a |
---|---|
1528 | 1528 |
1529 *len = gtk_smiley_tree_lookup (tree, text); | 1529 *len = gtk_smiley_tree_lookup (tree, text); |
1530 return (*len > 0); | 1530 return (*len > 0); |
1531 } | 1531 } |
1532 | 1532 |
1533 GdkPixbufAnimation * | 1533 GtkIMHtmlSmiley * |
1534 gtk_smiley_tree_image (GtkIMHtml *imhtml, | 1534 gtk_imhtml_smiley_get(GtkIMHtml *imhtml, |
1535 const gchar *sml, | 1535 const gchar *sml, |
1536 const gchar *text) | 1536 const gchar *text) |
1537 { | 1537 { |
1538 GtkSmileyTree *t; | 1538 GtkSmileyTree *t; |
1539 const gchar *x = text; | 1539 const gchar *x = text; |
1540 if (sml == NULL) | 1540 if (sml == NULL) |
1541 t = imhtml->default_smilies; | 1541 t = imhtml->default_smilies; |
1542 else | 1542 else |
1543 t = g_hash_table_lookup(imhtml->smiley_data, sml); | 1543 t = g_hash_table_lookup(imhtml->smiley_data, sml); |
1544 | 1544 |
1545 | 1545 |
1546 if (t == NULL) | 1546 if (t == NULL) |
1547 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL; | 1547 return sml ? gtk_imhtml_smiley_get(imhtml, NULL, text) : NULL; |
1548 | 1548 |
1549 while (*x) { | 1549 while (*x) { |
1550 gchar *pos; | 1550 gchar *pos; |
1551 | 1551 |
1552 if (!t->values) { | 1552 if (!t->values) { |
1553 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL; | 1553 return sml ? gtk_imhtml_smiley_get(imhtml, NULL, text) : NULL; |
1554 } | 1554 } |
1555 | 1555 |
1556 pos = strchr (t->values->str, *x); | 1556 pos = strchr (t->values->str, *x); |
1557 if (pos) { | 1557 if (pos) { |
1558 t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; | 1558 t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
1559 } else { | 1559 } else { |
1560 return sml ? gtk_smiley_tree_image(imhtml, NULL, text) : NULL; | 1560 return sml ? gtk_imhtml_smiley_get(imhtml, NULL, text) : NULL; |
1561 } | 1561 } |
1562 x++; | 1562 x++; |
1563 } | 1563 } |
1564 | 1564 |
1565 if (!t->image->file) | 1565 return t->image; |
1566 } | |
1567 | |
1568 GdkPixbufAnimation * | |
1569 gtk_smiley_tree_image (GtkIMHtml *imhtml, | |
1570 const gchar *sml, | |
1571 const gchar *text) | |
1572 { | |
1573 | |
1574 GtkIMHtmlSmiley *smiley; | |
1575 | |
1576 smiley = gtk_imhtml_smiley_get(imhtml,sml,text); | |
1577 | |
1578 if (!smiley) | |
1566 return NULL; | 1579 return NULL; |
1567 | 1580 |
1568 if (!t->image->icon) | 1581 if (!smiley->icon && smiley->file) { |
1569 t->image->icon = gdk_pixbuf_animation_new_from_file(t->image->file, NULL); | 1582 smiley->icon = gdk_pixbuf_animation_new_from_file(smiley->file, NULL); |
1570 | 1583 } else if (!smiley->icon && smiley->loader) { |
1571 return t->image->icon; | 1584 smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); |
1585 if (smiley->icon) | |
1586 g_object_ref(G_OBJECT(smiley->icon)); | |
1587 } | |
1588 | |
1589 return smiley->icon; | |
1572 } | 1590 } |
1573 | 1591 |
1574 #define VALID_TAG(x) if (!g_ascii_strncasecmp (string, x ">", strlen (x ">"))) { \ | 1592 #define VALID_TAG(x) if (!g_ascii_strncasecmp (string, x ">", strlen (x ">"))) { \ |
1575 *tag = g_strndup (string, strlen (x)); \ | 1593 *tag = g_strndup (string, strlen (x)); \ |
1576 *len = strlen (x) + 1; \ | 1594 *len = strlen (x) + 1; \ |
3837 GdkPixbufAnimation *annipixbuf = NULL; | 3855 GdkPixbufAnimation *annipixbuf = NULL; |
3838 GtkWidget *icon = NULL; | 3856 GtkWidget *icon = NULL; |
3839 GtkTextChildAnchor *anchor; | 3857 GtkTextChildAnchor *anchor; |
3840 char *unescaped = gaim_unescape_html(smiley); | 3858 char *unescaped = gaim_unescape_html(smiley); |
3841 | 3859 |
3842 if (imhtml->format_functions & GTK_IMHTML_SMILEY) | 3860 if (imhtml->format_functions & GTK_IMHTML_SMILEY) { |
3843 { | |
3844 annipixbuf = gtk_smiley_tree_image(imhtml, sml, unescaped); | 3861 annipixbuf = gtk_smiley_tree_image(imhtml, sml, unescaped); |
3845 if(annipixbuf) { | 3862 if (annipixbuf) { |
3846 if(gdk_pixbuf_animation_is_static_image(annipixbuf)) { | 3863 if (gdk_pixbuf_animation_is_static_image(annipixbuf)) { |
3847 pixbuf = gdk_pixbuf_animation_get_static_image(annipixbuf); | 3864 pixbuf = gdk_pixbuf_animation_get_static_image(annipixbuf); |
3848 if(pixbuf) | 3865 if (pixbuf) |
3849 icon = gtk_image_new_from_pixbuf(pixbuf); | 3866 icon = gtk_image_new_from_pixbuf(pixbuf); |
3850 } else { | 3867 } else { |
3851 icon = gtk_image_new_from_animation(annipixbuf); | 3868 icon = gtk_image_new_from_animation(annipixbuf); |
3852 } | 3869 } |
3853 } | 3870 } |
3854 } | 3871 } |
3872 #if 0 | |
3873 else { | |
3874 GtkIMHtmlSmiley *imhtml_smiley; | |
3875 | |
3876 if (imhtml_smiley->loader) { ; } | |
3877 icon = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU); | |
3878 imhtml_smiley = gtk_get_imhtml_smiley(imhtml, sml, unescaped); | |
3879 if (!imhtml_smiley) { | |
3880 gaim_debug_info("gtkimhtml", "geezz couldnt find smiley struct\n"); | |
3881 } | |
3882 imhtml_smiley->orphan = g_slist_append(imhtml_smiley->orphan, icon); | |
3883 } | |
3884 #endif | |
3855 | 3885 |
3856 if (icon) { | 3886 if (icon) { |
3857 anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); | 3887 anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
3858 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free); | 3888 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free); |
3859 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free); | 3889 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free); |