1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2003-2007 Imendio AB
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Authors: Mikael Hallendal <micke@imendio.com>
21 * Richard Hult <richard@imendio.com>
22 * Martyn Russell <martyn@imendio.com>
29 #include <libempathy/gossip-paths.h>
31 #include "gossip-stock.h"
33 static GtkIconFactory *icon_factory = NULL;
34 static GtkWidget *main_widget = NULL;
36 static GtkStockItem stock_items[] = {
37 { GOSSIP_STOCK_OFFLINE, NULL },
38 { GOSSIP_STOCK_AVAILABLE, NULL },
39 { GOSSIP_STOCK_BUSY, NULL },
40 { GOSSIP_STOCK_AWAY, NULL },
41 { GOSSIP_STOCK_EXT_AWAY, NULL },
42 { GOSSIP_STOCK_PENDING, NULL },
43 { GOSSIP_STOCK_MESSAGE, NULL },
44 { GOSSIP_STOCK_TYPING, NULL },
45 { GOSSIP_STOCK_CONTACT_INFORMATION, NULL },
46 { GOSSIP_STOCK_GROUP_MESSAGE, NULL }
50 gossip_stock_init (GtkWidget *widget)
55 g_assert (icon_factory == NULL);
57 main_widget = g_object_ref (widget);
59 gtk_stock_add (stock_items, G_N_ELEMENTS (stock_items));
61 icon_factory = gtk_icon_factory_new ();
62 gtk_icon_factory_add_default (icon_factory);
63 g_object_unref (icon_factory);
65 for (i = 0; i < G_N_ELEMENTS (stock_items); i++) {
66 gchar *path, *filename;
69 filename = g_strdup_printf ("%s.png", stock_items[i].stock_id);
70 path = gossip_paths_get_image_path (filename);
71 pixbuf = gdk_pixbuf_new_from_file (path, NULL);
75 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
77 gtk_icon_factory_add (icon_factory,
78 stock_items[i].stock_id,
81 gtk_icon_set_unref (icon_set);
83 g_object_unref (pixbuf);
88 gossip_stock_finalize (void)
90 g_assert (icon_factory != NULL);
92 gtk_icon_factory_remove_default (icon_factory);
93 g_object_unref (main_widget);
100 gossip_stock_render (const gchar *stock,
103 return gtk_widget_render_icon (main_widget, stock, size, NULL);