/pidgin/main: a7f91bd51911: Drop purple_smiley_get_path in favor...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Sat Apr 12 19:56:31 EDT 2014
Changeset: a7f91bd519111b9e07b392c7c6a1976c4e0968bc
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-04-13 01:56 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/a7f91bd51911
Description:
Drop purple_smiley_get_path in favor of purple_image_get_path (or don't use it at all)
diffstat:
libpurple/protocols/msn/msn.c | 4 +++-
libpurple/protocols/msn/slpcall.c | 2 +-
libpurple/smiley-custom.c | 9 ++++++---
libpurple/smiley-list.c | 14 ++++++++++----
libpurple/smiley.c | 2 +-
libpurple/smiley.h | 17 -----------------
pidgin/gtksmiley-manager.c | 14 ++++++--------
pidgin/gtkwebviewtoolbar.c | 4 ++--
8 files changed, 29 insertions(+), 37 deletions(-)
diffs (201 lines):
diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -1486,8 +1486,10 @@ static GSList* msn_msg_grab_emoticons(co
emoticon = g_new0(MsnEmoticon, 1);
emoticon->smile = g_strdup(purple_smiley_get_shortcut(smiley));
emoticon->ps = smiley;
+ /* TODO: we are leaking file location, consider using
+ * purple_image_get_friendly_filename. */
emoticon->obj = msn_object_new_from_image(img,
- purple_smiley_get_path(smiley),
+ purple_image_get_path(purple_smiley_get_image(smiley)),
username, MSN_OBJECT_EMOTICON);
list = g_slist_prepend(list, emoticon);
diff --git a/libpurple/protocols/msn/slpcall.c b/libpurple/protocols/msn/slpcall.c
--- a/libpurple/protocols/msn/slpcall.c
+++ b/libpurple/protocols/msn/slpcall.c
@@ -248,7 +248,7 @@ find_valid_emoticon(PurpleAccount *accou
for (it = smileys; it; it = g_list_next(it)) {
PurpleSmiley *smiley = it->data;
- if (g_strcmp0(path, purple_smiley_get_path(smiley)) == 0) {
+ if (g_strcmp0(path, purple_image_get_path(purple_smiley_get_image(smiley))) == 0) {
PurpleImage *img;
g_list_free(smileys);
diff --git a/libpurple/smiley-custom.c b/libpurple/smiley-custom.c
--- a/libpurple/smiley-custom.c
+++ b/libpurple/smiley-custom.c
@@ -126,7 +126,8 @@ smileys_to_xmlnode(void)
purple_xmlnode_set_attrib(smiley_node, "shortcut",
purple_smiley_get_shortcut(smiley));
purple_xmlnode_set_attrib(smiley_node, "filename",
- g_path_get_basename(purple_smiley_get_path(smiley)));
+ g_path_get_basename(purple_image_get_path(
+ purple_smiley_get_image(smiley))));
}
return root_node;
@@ -253,13 +254,15 @@ purple_smiley_custom_remove(PurpleSmiley
g_object_ref(smiley);
purple_smiley_list_remove(smileys_list, smiley);
- path = purple_smiley_get_path(smiley);
+ path = purple_image_get_path(purple_smiley_get_image(smiley));
other_smileys = purple_smiley_list_get_unique(smileys_list);
is_unique = TRUE;
for (it = other_smileys; it; it = g_list_next(it)) {
PurpleSmiley *other = it->data;
- if (g_strcmp0(purple_smiley_get_path(other), path) == 0) {
+ const gchar *other_path = purple_image_get_path(
+ purple_smiley_get_image(other));
+ if (g_strcmp0(other_path, path) == 0) {
is_unique = FALSE;
break;
}
diff --git a/libpurple/smiley-list.c b/libpurple/smiley-list.c
--- a/libpurple/smiley-list.c
+++ b/libpurple/smiley-list.c
@@ -86,6 +86,12 @@ static void
*head_p = g_list_delete_link(head, link);
}
+static const gchar *
+smiley_get_uniqid(PurpleSmiley *smiley)
+{
+ return purple_image_get_path(purple_smiley_get_image(smiley));
+}
+
/*******************************************************************************
* API implementation
******************************************************************************/
@@ -158,7 +164,7 @@ purple_smiley_list_add(PurpleSmileyList
G_CALLBACK(remote_smiley_failed), list, 0);
}
- smiley_path = purple_smiley_get_path(smiley);
+ smiley_path = smiley_get_uniqid(smiley);
/* TODO: add to the table, when the smiley sets the path */
if (!smiley_path)
@@ -192,7 +198,7 @@ purple_smiley_list_remove(PurpleSmileyLi
"purple-smiley-list-elem");
shortcut = purple_smiley_get_shortcut(smiley);
- path = purple_smiley_get_path(smiley);
+ path = smiley_get_uniqid(smiley);
g_hash_table_remove(priv->shortcut_map, shortcut);
if (path)
@@ -208,7 +214,7 @@ purple_smiley_list_remove(PurpleSmileyLi
for (it = priv->smileys; it && path; it = g_list_next(it)) {
PurpleSmiley *smiley = it->data;
- if (g_strcmp0(purple_smiley_get_path(smiley), path) == 0) {
+ if (g_strcmp0(smiley_get_uniqid(smiley), path) == 0) {
g_hash_table_insert(priv->path_map,
g_strdup(path), smiley);
break;
@@ -267,7 +273,7 @@ purple_smiley_list_get_unique(PurpleSmil
for (it = priv->smileys; it; it = g_list_next(it)) {
PurpleSmiley *smiley = it->data;
- const gchar *path = purple_smiley_get_path(smiley);
+ const gchar *path = smiley_get_uniqid(smiley);
if (g_hash_table_lookup(unique_map, path))
continue;
diff --git a/libpurple/smiley.c b/libpurple/smiley.c
--- a/libpurple/smiley.c
+++ b/libpurple/smiley.c
@@ -91,7 +91,7 @@ purple_smiley_get_shortcut(const PurpleS
return priv->shortcut;
}
-const gchar *
+static const gchar *
purple_smiley_get_path(PurpleSmiley *smiley)
{
PurpleSmileyPrivate *priv = PURPLE_SMILEY_GET_PRIVATE(smiley);
diff --git a/libpurple/smiley.h b/libpurple/smiley.h
--- a/libpurple/smiley.h
+++ b/libpurple/smiley.h
@@ -126,23 +126,6 @@ const gchar *
purple_smiley_get_shortcut(const PurpleSmiley *smiley);
/**
- * purple_smiley_get_path:
- * @smiley: the smiley.
- *
- * Returns a full path to a @smiley image file.
- *
- * A @smiley may not be saved to disk (the path will be NULL), but could still be
- * accessible using #purple_smiley_get_data.
- *
- * TODO: I think we don't need it too.
- *
- * Returns: a full path to the file, or %NULL if it's not stored to the disk
- * or an error occured.
- */
-const gchar *
-purple_smiley_get_path(PurpleSmiley *smiley);
-
-/**
* purple_smiley_get_image:
* @smiley: the smiley.
*
diff --git a/pidgin/gtksmiley-manager.c b/pidgin/gtksmiley-manager.c
--- a/pidgin/gtksmiley-manager.c
+++ b/pidgin/gtksmiley-manager.c
@@ -249,10 +249,8 @@ edit_dialog_save(SmileyEditDialog *edit_
}
if (edit_dialog->new_image == NULL) {
- /* We're reading the file and then writing it back - it's not
- * efficient, but it's also not really important here. */
- edit_dialog->new_image = purple_image_new_from_file(
- purple_smiley_get_path(edit_dialog->smiley), TRUE);
+ edit_dialog->new_image =
+ purple_smiley_get_image(edit_dialog->smiley);
g_return_if_fail(edit_dialog->new_image);
}
@@ -428,8 +426,8 @@ edit_dialog_show(SmileyManager *manager,
gtk_widget_show(GTK_WIDGET(edit_dialog->window));
if (smiley) {
- edit_dialog->filename =
- g_strdup(purple_smiley_get_path(smiley));
+ edit_dialog->filename = g_strdup(purple_image_get_path(
+ purple_smiley_get_image(smiley)));
gtk_entry_set_text(edit_dialog->shortcut,
purple_smiley_get_shortcut(smiley));
}
@@ -624,8 +622,8 @@ manager_list_add(SmileyManager *manager,
smiley_image = g_object_get_data(G_OBJECT(smiley),
"pidgin-smiley-manager-list-thumb");
if (smiley_image == NULL) {
- smiley_image = pidgin_pixbuf_new_from_file(
- purple_smiley_get_path(smiley));
+ smiley_image = pidgin_pixbuf_from_image(
+ purple_smiley_get_image(smiley));
smiley_image = pidgin_pixbuf_scale_down(smiley_image,
22, 22, GDK_INTERP_BILINEAR, TRUE);
g_object_set_data_full(G_OBJECT(smiley),
diff --git a/pidgin/gtkwebviewtoolbar.c b/pidgin/gtkwebviewtoolbar.c
--- a/pidgin/gtkwebviewtoolbar.c
+++ b/pidgin/gtkwebviewtoolbar.c
@@ -752,8 +752,8 @@ smileys_load_button_thumbs(GList *smiley
continue;
}
- pixbuf = pidgin_pixbuf_new_from_file(
- purple_smiley_get_path(smiley));
+ pixbuf = pidgin_pixbuf_from_image(
+ purple_smiley_get_image(smiley));
pixbuf = pidgin_pixbuf_scale_down(pixbuf,
24, 24, GDK_INTERP_BILINEAR, TRUE);
More information about the Commits
mailing list