pidgin: 67e253d9: Abstract an "image loading function" (wi...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Wed Jun 24 23:15:27 EDT 2009
-----------------------------------------------------------------
Revision: 67e253d9bff41f028ffc609c776f70dae52b614b
Ancestor: 99d06edb8217be8d94a7c9fc3f4d9c75835ff9d6
Author: darkrain42 at pidgin.im
Date: 2009-06-25T03:10:46
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/67e253d9bff41f028ffc609c776f70dae52b614b
Modified files:
pidgin/plugins/disco/gtkdisco.c
ChangeLog:
Abstract an "image loading function" (will be used for the tooltip in a sec)
-------------- next part --------------
============================================================
--- pidgin/plugins/disco/gtkdisco.c c464f2b3aa33bcdcffe351292415befbd61c91b0
+++ pidgin/plugins/disco/gtkdisco.c 1477e4d0c2fcaa0eaa38c7e6024c267d564d83dd
@@ -108,6 +108,34 @@ void pidgin_disco_list_set_in_progress(P
}
}
+static GdkPixbuf *
+pidgin_disco_load_icon(XmppDiscoService *service, const char *size)
+{
+ GdkPixbuf *pixbuf = NULL;
+ char *filename;
+
+ g_return_val_if_fail(service != NULL, NULL);
+ g_return_val_if_fail(size != NULL, NULL);
+
+ if (service->type == XMPP_DISCO_SERVICE_TYPE_GATEWAY && service->gateway_type) {
+ char *tmp = g_strconcat(service->gateway_type, ".png", NULL);
+ filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", size, tmp, NULL);
+ g_free(tmp);
+#if 0
+ } else if (service->type == XMPP_DISCO_SERVICE_TYPE_USER) {
+ filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "status", size, "person.png", NULL);
+#endif
+ } else if (service->type == XMPP_DISCO_SERVICE_TYPE_CHAT)
+ filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "status", size, "chat.png", NULL);
+
+ if (filename) {
+ pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
+ g_free(filename);
+ }
+
+ return pixbuf;
+}
+
static void pidgin_disco_create_tree(PidginDiscoList *pdl);
static void dialog_select_account_cb(GObject *w, PurpleAccount *account,
@@ -667,7 +695,6 @@ void pidgin_disco_add_service(PidginDisc
{
PidginDiscoDialog *dialog;
GtkTreeIter iter, parent_iter, child;
- char *filename = NULL;
GdkPixbuf *pixbuf = NULL;
gboolean append = TRUE;
@@ -725,22 +752,8 @@ void pidgin_disco_add_service(PidginDisc
gtk_tree_path_free(path);
}
- if (service->type == XMPP_DISCO_SERVICE_TYPE_GATEWAY && service->gateway_type) {
- char *tmp = g_strconcat(service->gateway_type, ".png", NULL);
- filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", "16", tmp, NULL);
- g_free(tmp);
-#if 0
- } else if (service->type == XMPP_DISCO_SERVICE_TYPE_USER) {
- filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "status", "16", "person.png", NULL);
-#endif
- } else if (service->type == XMPP_DISCO_SERVICE_TYPE_CHAT)
- filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "status", "16", "chat.png", NULL);
+ pixbuf = pidgin_disco_load_icon(service, "16");
- if (filename) {
- pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
- g_free(filename);
- }
-
gtk_tree_store_set(pdl->model, &iter,
PIXBUF_COLUMN, pixbuf,
NAME_COLUMN, service->name,
More information about the Commits
mailing list