No issues found
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2002 Jorn Baayen
4 * Copyright (C) 2003,2004 Colin Walters <walters@verbum.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * The Rhythmbox authors hereby grant permission for non-GPL compatible
12 * GStreamer plugins to be used and distributed together with GStreamer
13 * and Rhythmbox. This permission is above and beyond the permissions granted
14 * by the GPL license by which Rhythmbox is covered. If you modify this code
15 * you may extend this exception to your version of the code, but you are not
16 * obligated to do so. If you do not wish to do so, delete this exception
17 * statement from your version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 *
28 */
29
30 #include "config.h"
31
32 #include <gtk/gtk.h>
33 #include <glib.h>
34 #include <stdio.h>
35 #include <string.h>
36
37 #include "rb-file-helpers.h"
38 #include "rb-stock-icons.h"
39
40 /* inline pixbuf data */
41 #include "rhythmbox-set-star-inline.h"
42 #include "rhythmbox-unset-star-inline.h"
43 #include "rhythmbox-no-star-inline.h"
44
45 typedef struct {
46 const guint8 *data;
47 const char *name;
48 } RBInlineIconData;
49
50 const char RB_APP_ICON[] = "rhythmbox";
51 const char RB_STOCK_TRAY_ICON[] = "rhythmbox";
52 const char RB_STOCK_SET_STAR[] = "rhythmbox-set-star";
53 const char RB_STOCK_UNSET_STAR[] = "rhythmbox-unset-star";
54 const char RB_STOCK_NO_STAR[] = "rhythmbox-no-star";
55 const char RB_STOCK_PODCAST[] = "library-podcast";
56 const char RB_STOCK_PODCAST_NEW[] = "podcast-new";
57 const char RB_STOCK_BROWSER[] = "music-library";
58 const char RB_STOCK_PLAYLIST[] = "playlist";
59 const char RB_STOCK_PLAYLIST_NEW[] = "playlist-new";
60 const char RB_STOCK_AUTO_PLAYLIST[] = "playlist-automatic";
61 const char RB_STOCK_AUTO_PLAYLIST_NEW[] = "playlist-automatic-new";
62 const char RB_STOCK_MISSING_ARTWORK[] = "rhythmbox-missing-artwork";
63 const char GNOME_MEDIA_SHUFFLE[] = "media-playlist-shuffle";
64 const char GNOME_MEDIA_REPEAT[] = "media-playlist-repeat";
65 const char GNOME_MEDIA_EJECT[] = "media-eject";
66
67 static RBInlineIconData inline_icons[] = {
68 { rhythmbox_set_star_inline, RB_STOCK_SET_STAR },
69 { rhythmbox_unset_star_inline, RB_STOCK_UNSET_STAR },
70 { rhythmbox_no_star_inline, RB_STOCK_NO_STAR }
71 };
72
73 /**
74 * rb_stock_icons_init:
75 *
76 * Initializes the stock icons, adding the necessary filesystem
77 * locations to the GTK icon search path. Must be called on startup.
78 */
79 void
80 rb_stock_icons_init (void)
81 {
82 GtkIconTheme *theme = gtk_icon_theme_get_default ();
83 int i;
84 int icon_size;
85 char *dot_icon_dir;
86
87 /* add our icon search paths */
88 dot_icon_dir = g_build_filename (rb_user_data_dir (), "icons", NULL);
89 gtk_icon_theme_append_search_path (theme, dot_icon_dir);
90 g_free (dot_icon_dir);
91
92 gtk_icon_theme_append_search_path (theme, SHARE_DIR G_DIR_SEPARATOR_S "icons");
93 #ifdef USE_UNINSTALLED_DIRS
94 gtk_icon_theme_append_search_path (theme, SHARE_UNINSTALLED_DIR G_DIR_SEPARATOR_S "icons");
95 #endif
96
97 /* add inline icons */
98 gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &icon_size, NULL);
99 for (i = 0; i < (int) G_N_ELEMENTS (inline_icons); i++) {
100 GdkPixbuf *pixbuf;
101
102 pixbuf = gdk_pixbuf_new_from_inline (-1,
103 inline_icons[i].data,
104 FALSE,
105 NULL);
106 g_assert (pixbuf);
107
108 gtk_icon_theme_add_builtin_icon (inline_icons[i].name,
109 icon_size,
110 pixbuf);
111 }
112 }
113
114 /**
115 * rb_stock_icons_shutdown:
116 *
117 * If anything was necessary to clean up the stock icons, this function
118 * would do it. Doesn't do anything, but should be called on shutdown
119 * anyway.
120 */
121 void
122 rb_stock_icons_shutdown (void)
123 {
124 /* do nothing */
125 }