]> www.fi.muni.cz Git - evince.git/blob - shell/ev-stock-icons.c
A data/evince.schemas.in:
[evince.git] / shell / ev-stock-icons.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* Stock icons for Evince
3  *
4  * Copyright (C) 2003 Martin Kretzschmar
5  *
6  * Author:
7  *   Martin Kretzschmar <Martin.Kretzschmar@inf.tu-dresden.de>
8  *
9  * GPdf is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * GPdf is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  */
23
24 #include <config.h>
25
26 #include "ev-stock-icons.h"
27
28 #include <gtk/gtkiconfactory.h>
29 #include <gtk/gtkstock.h>
30 #include <gdk/gdkpixbuf.h>
31
32 /* Toolbar icons files */
33 #define STOCK_ZOOM_FIT_WIDTH_FILE "ev-stock-zoom-fit-width.png"
34
35 #define EV_ADD_STOCK_ICON(id, file, def_id)                                     \
36 {                                                                               \
37         GdkPixbuf *pixbuf;                                                      \
38         GtkIconSet *icon_set = NULL;                                            \
39         pixbuf = gdk_pixbuf_new_from_file (GNOMEICONDIR "/evince/" file, NULL); \
40         if (pixbuf) {                                                           \
41                 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);               \
42         } else if (def_id) {                                                    \
43                 icon_set = gtk_icon_factory_lookup_default (def_id);            \
44                 gtk_icon_set_ref (icon_set);                                    \
45         }                                                                       \
46         gtk_icon_factory_add (factory, id, icon_set);                           \
47         gtk_icon_set_unref (icon_set);                                          \
48 }
49
50 void
51 ev_stock_icons_init (void)
52 {
53         static const char *icon_theme_items[] = {
54                 EV_STOCK_LEAVE_FULLSCREEN
55         };
56         GtkIconFactory *factory;
57         guint i;
58
59         factory = gtk_icon_factory_new ();
60         gtk_icon_factory_add_default (factory);
61
62         /* fitwidth stock icon */
63         EV_ADD_STOCK_ICON (EV_STOCK_ZOOM_FIT_WIDTH, STOCK_ZOOM_FIT_WIDTH_FILE, GTK_STOCK_ZOOM_FIT);
64
65         for (i = 0; i < G_N_ELEMENTS (icon_theme_items); i++) {
66                 GtkIconSet *icon_set;
67                 GtkIconSource *icon_source;
68
69                 icon_set = gtk_icon_set_new ();
70                 icon_source = gtk_icon_source_new ();
71                 gtk_icon_source_set_icon_name (icon_source, icon_theme_items[i]);
72                 gtk_icon_set_add_source (icon_set, icon_source);
73                 gtk_icon_factory_add (factory, icon_theme_items[i], icon_set);
74                 gtk_icon_set_unref (icon_set);
75                 gtk_icon_source_free (icon_source);
76         }
77
78         g_object_unref (G_OBJECT (factory));
79 }