1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
3 * arch-tag: Implementation of Rhythmbox icon loading
5 * Copyright (C) 2002 Jorn Baayen
6 * Copyright (C) 2003,2004 Colin Walters <walters@verbum.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "rb-file-helpers.h"
30 #include "rb-stock-icons.h"
32 static GtkIconFactory
*factory
= NULL
;
34 const char RB_APP_ICON
[] = "rhythmbox";
35 const char RB_STOCK_TRAY_ICON
[] = "rhythmbox-tray-icon";
36 const char RB_STOCK_SET_STAR
[] = "rhythmbox-set-star";
37 const char RB_STOCK_UNSET_STAR
[] = "rhythmbox-unset-star";
38 const char RB_STOCK_NO_STAR
[] = "rhythmbox-no-star";
39 const char RB_STOCK_PODCAST
[] = "rhythmbox-podcast";
40 const char RB_STOCK_BROWSER
[] = "stock_music-library";
41 const char GNOME_MEDIA_SHUFFLE
[] = "stock_shuffle";
42 const char GNOME_MEDIA_REPEAT
[] = "stock_repeat";
43 const char GNOME_MEDIA_PLAYLIST
[] = "stock_playlist";
44 const char GNOME_MEDIA_AUTO_PLAYLIST
[] = "stock_smart-playlist";
45 const char GNOME_MEDIA_EJECT
[] = "media-eject";
48 rb_stock_icons_init (void)
50 GtkIconTheme
*theme
= gtk_icon_theme_get_default ();
54 static const char* items
[] =
56 /* Rhythmbox custom icons */
63 /* gnome-icon-theme icons */
67 GNOME_MEDIA_AUTO_PLAYLIST
,
72 g_return_if_fail (factory
== NULL
);
74 factory
= gtk_icon_factory_new ();
75 gtk_icon_factory_add_default (factory
);
77 /* we should really add all the sizes */
78 gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR
, &icon_size
, NULL
);
80 for (i
= 0; i
< (int) G_N_ELEMENTS (items
); i
++) {
84 pixbuf
= gtk_icon_theme_load_icon (theme
,
93 fn
= g_strconcat (items
[i
], ".png", NULL
);
96 pixbuf
= gdk_pixbuf_new_from_file (path
, NULL
);
102 icon_set
= gtk_icon_set_new_from_pixbuf (pixbuf
);
103 gtk_icon_factory_add (factory
, items
[i
], icon_set
);
104 gtk_icon_set_unref (icon_set
);
106 g_object_unref (G_OBJECT (pixbuf
));
108 g_warning ("Unable to load icon %s", items
[i
]);
112 /* register the app icon as a builtin if the theme can't find it */
113 if (!gtk_icon_theme_has_icon (theme
, RB_APP_ICON
)) {
117 static char *search_paths
[] = {
118 #ifdef SHARE_UNINSTALLED_DIR
119 SHARE_UNINSTALLED_DIR
"/",
121 DATADIR
"/icons/hicolor/48x48/apps/",
124 for (i
= 0; i
< (int) G_N_ELEMENTS (search_paths
); i
++) {
125 path
= g_strconcat (search_paths
[i
], RB_APP_ICON
, ".png", NULL
);
126 if (g_file_test (path
, G_FILE_TEST_EXISTS
) == TRUE
)
133 pixbuf
= gdk_pixbuf_new_from_file (path
, NULL
);
135 gtk_icon_theme_add_builtin_icon (RB_APP_ICON
, icon_size
, pixbuf
);
144 rb_stock_icons_shutdown (void)
146 g_return_if_fail (factory
!= NULL
);
148 gtk_icon_factory_remove_default (factory
);
150 g_object_unref (G_OBJECT (factory
));