~ubuntu-branches/ubuntu/saucy/sflphone/saucy

« back to all changes in this revision

Viewing changes to sflphone-client-gnome/src/icons/icon_factory.c

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2010-12-24 16:33:55 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101224163355-tkvvikqxbrbav6up
Tags: 0.9.11-1
* New upstream release
* Add new build dependencies on libwebkit-dev and libyaml-dev

* Bump Standards-Version up to 3.9.1
* Bump debhelper compatibility to 8
* Patch another typo in the upstream code (lintian notice)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 */
30
30
 
31
31
#include "icon_factory.h"
 
32
#include "icons/pixmap_data.h"
 
33
 
32
34
 
33
35
static GtkIconFactory *icon_factory = NULL;
34
36
 
35
37
void add_icon (GtkIconFactory *factory, const gchar *stock_id, const guint8 *icon_data, GtkIconSize size)
36
38
{
37
 
        GtkIconSet *icons;
38
 
        GtkIconSource *source;
39
 
        GdkPixbuf *pixbuf;
40
 
 
41
 
        icons = gtk_icon_factory_lookup (factory, stock_id);
42
 
        if (!icons)
43
 
        {
44
 
                pixbuf = gdk_pixbuf_new_from_inline (-1, icon_data, FALSE, NULL);
45
 
                source = gtk_icon_source_new ();
46
 
                gtk_icon_source_set_pixbuf (source, pixbuf);
47
 
                gtk_icon_source_set_size (source, size);
48
 
 
49
 
                icons = gtk_icon_set_new ();
50
 
                gtk_icon_set_add_source (icons, source);
51
 
 
52
 
                gtk_icon_factory_add (factory, stock_id, icons);
53
 
 
54
 
                g_object_unref (G_OBJECT (pixbuf));
55
 
                gtk_icon_source_free (source);
56
 
                gtk_icon_set_unref (icons);
57
 
        }
58
 
        else
59
 
                DEBUG ("Icon %s already exists in factory\n", stock_id);
 
39
    GtkIconSet *icons;
 
40
    GtkIconSource *source;
 
41
    GdkPixbuf *pixbuf;
 
42
 
 
43
    icons = gtk_icon_factory_lookup (factory, stock_id);
 
44
 
 
45
    if (!icons) {
 
46
        pixbuf = gdk_pixbuf_new_from_inline (-1, icon_data, FALSE, NULL);
 
47
        source = gtk_icon_source_new ();
 
48
        gtk_icon_source_set_pixbuf (source, pixbuf);
 
49
        gtk_icon_source_set_size (source, size);
 
50
 
 
51
        icons = gtk_icon_set_new ();
 
52
        gtk_icon_set_add_source (icons, source);
 
53
 
 
54
        gtk_icon_factory_add (factory, stock_id, icons);
 
55
 
 
56
        g_object_unref (G_OBJECT (pixbuf));
 
57
        gtk_icon_source_free (source);
 
58
        gtk_icon_set_unref (icons);
 
59
    } else
 
60
        DEBUG ("Icon %s already exists in factory\n", stock_id);
 
61
}
 
62
 
 
63
GtkIconSet* lookup_sflphone_factory (const gchar *stock_id)
 
64
{
 
65
 
 
66
    return gtk_icon_factory_lookup (icon_factory, stock_id);
60
67
}
61
68
 
62
69
void register_sflphone_stock_icons (GtkIconFactory *factory)
63
70
{
64
 
        add_icon (factory, GTK_STOCK_PICKUP, gnome_stock_pickup, GTK_ICON_SIZE_SMALL_TOOLBAR);  
65
 
        add_icon (factory, GTK_STOCK_HANGUP, gnome_stock_hangup, GTK_ICON_SIZE_SMALL_TOOLBAR);  
66
 
        add_icon (factory, GTK_STOCK_DIAL, gnome_stock_dial, GTK_ICON_SIZE_SMALL_TOOLBAR);      
67
 
        add_icon (factory, GTK_STOCK_TRANSFER, gnome_stock_transfer, GTK_ICON_SIZE_SMALL_TOOLBAR);      
68
 
        add_icon (factory, GTK_STOCK_ONHOLD, gnome_stock_onhold, GTK_ICON_SIZE_SMALL_TOOLBAR);  
69
 
        add_icon (factory, GTK_STOCK_OFFHOLD, gnome_stock_offhold, GTK_ICON_SIZE_SMALL_TOOLBAR);        
70
 
        add_icon (factory, GTK_STOCK_CALL_CURRENT, gnome_stock_call_current, GTK_ICON_SIZE_SMALL_TOOLBAR);      
71
 
        add_icon (factory, GTK_STOCK_ADDRESSBOOK, gnome_stock_addressbook, GTK_ICON_SIZE_SMALL_TOOLBAR);        
72
 
        add_icon (factory, GTK_STOCK_CALLS, gnome_stock_calls, GTK_ICON_SIZE_SMALL_TOOLBAR);    
 
71
    add_icon (factory, GTK_STOCK_PICKUP, gnome_stock_pickup, GTK_ICON_SIZE_SMALL_TOOLBAR);
 
72
    add_icon (factory, GTK_STOCK_HANGUP, gnome_stock_hangup, GTK_ICON_SIZE_SMALL_TOOLBAR);
 
73
    add_icon (factory, GTK_STOCK_DIAL, gnome_stock_dial, GTK_ICON_SIZE_SMALL_TOOLBAR);
 
74
    add_icon (factory, GTK_STOCK_TRANSFER, gnome_stock_transfer, GTK_ICON_SIZE_SMALL_TOOLBAR);
 
75
    add_icon (factory, GTK_STOCK_ONHOLD, gnome_stock_onhold, GTK_ICON_SIZE_SMALL_TOOLBAR);
 
76
    add_icon (factory, GTK_STOCK_OFFHOLD, gnome_stock_offhold, GTK_ICON_SIZE_SMALL_TOOLBAR);
 
77
    add_icon (factory, GTK_STOCK_IM, gnome_stock_im, GTK_ICON_SIZE_SMALL_TOOLBAR);
 
78
    add_icon (factory, GTK_STOCK_CALL_CURRENT, gnome_stock_call_current, GTK_ICON_SIZE_SMALL_TOOLBAR);
 
79
    add_icon (factory, GTK_STOCK_ADDRESSBOOK, gnome_stock_addressbook, GTK_ICON_SIZE_SMALL_TOOLBAR);
 
80
    add_icon (factory, GTK_STOCK_CALLS, gnome_stock_calls, GTK_ICON_SIZE_SMALL_TOOLBAR);
 
81
    add_icon (factory, GTK_STOCK_SFLPHONE, gnome_stock_sflphone, GTK_ICON_SIZE_SMALL_TOOLBAR);
 
82
    add_icon (factory, GTK_STOCK_FAIL, gnome_stock_fail, GTK_ICON_SIZE_SMALL_TOOLBAR);
 
83
    add_icon (factory, GTK_STOCK_USER, gnome_stock_user, GTK_ICON_SIZE_SMALL_TOOLBAR);
73
84
}
74
85
 
75
86
void init_icon_factory (void)
76
87
{
77
 
        // Init the factory
78
 
        icon_factory = gtk_icon_factory_new ();
79
 
 
80
 
        // Load icons
81
 
        register_sflphone_stock_icons (icon_factory);
82
 
 
83
 
        // Specify a default icon set
84
 
        gtk_icon_factory_add_default (icon_factory);
 
88
    // Init the factory
 
89
    icon_factory = gtk_icon_factory_new ();
 
90
 
 
91
    // Load icons
 
92
    register_sflphone_stock_icons (icon_factory);
 
93
 
 
94
    // Specify a default icon set
 
95
    gtk_icon_factory_add_default (icon_factory);
85
96
}
86
97
 
87
98