~ubuntu-branches/ubuntu/utopic/rhythmbox/utopic-proposed

« back to all changes in this revision

Viewing changes to lib/rb-stock-icons.c

Tags: upstream-0.9.2
ImportĀ upstreamĀ versionĀ 0.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
static GtkIconFactory *factory = NULL;
32
32
 
 
33
const char RB_STOCK_TRAY_ICON[] = "rhythmbox-tray-icon";
 
34
const char RB_STOCK_SET_STAR[] = "rhythmbox-set-star";
 
35
const char RB_STOCK_UNSET_STAR[] = "rhythmbox-unset-star";
 
36
const char RB_STOCK_NO_STAR[] = "rhythmbox-no-star";
 
37
const char RB_STOCK_PODCAST[] = "rhythmbox-podcast";
 
38
const char GNOME_MEDIA_SHUFFLE[] = "stock_shuffle";
 
39
const char GNOME_MEDIA_REPEAT[] = "stock_repeat";
 
40
const char GNOME_MEDIA_PLAYLIST[] = "stock_playlist";
 
41
const char GNOME_MEDIA_AUTO_PLAYLIST[] = "stock_smart-playlist";
 
42
 
 
43
typedef struct {
 
44
        const char *name;
 
45
        gboolean custom;
 
46
} RBStockIcon;
 
47
 
33
48
void
34
49
rb_stock_icons_init (void)
35
50
{
 
51
        GtkIconTheme *theme = gtk_icon_theme_get_default ();
36
52
        int i;
37
53
 
38
 
        static const char *items[] =
 
54
        static const RBStockIcon items[] =
39
55
        {
40
 
                RB_STOCK_PLAY,
41
 
                RB_STOCK_PAUSE,
42
 
                RB_STOCK_STOP,
43
 
                RB_STOCK_PREVIOUS,
44
 
                RB_STOCK_NEXT,
45
 
                RB_STOCK_REWIND,
46
 
                RB_STOCK_SHUFFLE,
47
 
                RB_STOCK_REPEAT,
48
 
                RB_STOCK_VISUALS,
49
 
                RB_STOCK_PLAYLIST,
50
 
                RB_STOCK_PLAYLIST_MENU,
51
 
                RB_STOCK_LIBRARY,
52
 
                RB_STOCK_IRADIO,
53
 
                RB_STOCK_PLAYING,
54
 
                RB_STOCK_PAUSED,
55
 
                RB_STOCK_ALBUM,
56
 
                RB_STOCK_VOLUME_ZERO,
57
 
                RB_STOCK_VOLUME_MIN,
58
 
                RB_STOCK_VOLUME_MEDIUM,
59
 
                RB_STOCK_VOLUME_MAX,
60
 
                RB_STOCK_VOLUME_MUTE,
61
 
                RB_STOCK_TRAY_ICON,
62
 
                RB_STOCK_SET_STAR,
63
 
                RB_STOCK_AUTOMATIC_PLAYLIST,
64
 
                RB_STOCK_UNSET_STAR,
65
 
                RB_STOCK_NO_STAR,
66
 
                RB_STOCK_DND_ICON,
67
 
                RB_STOCK_AUDIOCD,
68
 
                RB_STOCK_IPOD
 
56
                /* Rhythmbox custom icons */
 
57
                {RB_STOCK_TRAY_ICON, TRUE},
 
58
                {RB_STOCK_SET_STAR, TRUE},
 
59
                {RB_STOCK_UNSET_STAR, TRUE},
 
60
                {RB_STOCK_PODCAST, TRUE},
 
61
                {RB_STOCK_NO_STAR, TRUE},
 
62
                
 
63
                /* gnome-icon-theme icons */
 
64
                {GNOME_MEDIA_SHUFFLE, FALSE},
 
65
                {GNOME_MEDIA_REPEAT, FALSE},
 
66
                {GNOME_MEDIA_PLAYLIST, FALSE},
 
67
                {GNOME_MEDIA_AUTO_PLAYLIST, FALSE},
69
68
        };
70
69
 
71
70
        g_return_if_fail (factory == NULL);
76
75
        for (i = 0; i < (int) G_N_ELEMENTS (items); i++) {
77
76
                GtkIconSet *icon_set;
78
77
                GdkPixbuf *pixbuf;
79
 
                char *fn;
80
 
 
81
 
                fn = g_strconcat (items[i], ".png", NULL);
82
 
                pixbuf = gdk_pixbuf_new_from_file (rb_file (fn), NULL);
83
 
                g_free (fn);
84
 
 
85
 
                icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
86
 
                gtk_icon_factory_add (factory, items[i], icon_set);
87
 
                gtk_icon_set_unref (icon_set);
88
 
                
89
 
                g_object_unref (G_OBJECT (pixbuf));
 
78
 
 
79
                if (items[i].custom) {
 
80
                        char *fn = g_strconcat (items[i].name, ".png", NULL);
 
81
                        pixbuf = gdk_pixbuf_new_from_file (rb_file (fn), NULL);
 
82
                        g_free (fn);
 
83
                } else {
 
84
                        /* we should really add all the sizes */
 
85
                        gint size;
 
86
                        gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &size, NULL);
 
87
                        pixbuf = gtk_icon_theme_load_icon (theme,
 
88
                                                           items[i].name,
 
89
                                                           size,
 
90
                                                           0,
 
91
                                                           NULL);
 
92
                }
 
93
 
 
94
                if (pixbuf) {
 
95
                        icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
 
96
                        gtk_icon_factory_add (factory, items[i].name, icon_set);
 
97
                        gtk_icon_set_unref (icon_set);
 
98
                        
 
99
                        g_object_unref (G_OBJECT (pixbuf));
 
100
                } else {
 
101
                        g_warning ("Unable to load icon %s", items[i].name);
 
102
                }
90
103
        }
91
104
}
92
105