]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-stock-icons.c
Simplify image format selection on save.
[evince.git] / shell / ev-stock-icons.c
index 17793f37e3a9fb87aaded5b5c6024550bace3fb3..ce15dc65d5a346339f5d77947105f00c1950974b 100644 (file)
  */
 
 #include <config.h>
-
 #include "ev-stock-icons.h"
 
 #include <gtk/gtkiconfactory.h>
 #include <gtk/gtkstock.h>
 #include <gdk/gdkpixbuf.h>
 
-/* Toolbar icons files */
-#define STOCK_ZOOM_FIT_WIDTH_FILE "ev-stock-zoom-fit-width.png"
-
-#define EV_ADD_STOCK_ICON(id, file, def_id)                                    \
-{                                                                              \
-       GdkPixbuf *pixbuf;                                                      \
-       GtkIconSet *icon_set = NULL;                                            \
-        pixbuf = gdk_pixbuf_new_from_file (GNOMEICONDIR "/evince/" file, NULL); \
-        if (pixbuf) {                                                          \
-               icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);               \
-       } else if (def_id) {                                                    \
-               icon_set = gtk_icon_factory_lookup_default (def_id);            \
-               gtk_icon_set_ref (icon_set);                                    \
-       }                                                                       \
-        gtk_icon_factory_add (factory, id, icon_set);                          \
-        gtk_icon_set_unref (icon_set);                                         \
-}
+typedef struct {
+       char *stock_id;
+       char *icon;
+} EvStockIcon;
+
+/* Evince stock icons */
+static const EvStockIcon stock_icons [] = {
+       { EV_STOCK_ZOOM,             "zoom" },
+       { EV_STOCK_ZOOM_PAGE,        "zoom-fit-page" },
+       { EV_STOCK_ZOOM_WIDTH,       "zoom-fit-width" },
+       { EV_STOCK_VIEW_DUAL,        "view-page-facing" },
+       { EV_STOCK_VIEW_CONTINUOUS,  "view-page-continuous" },
+       { EV_STOCK_ROTATE_LEFT,      "object-rotate-left"},
+       { EV_STOCK_ROTATE_RIGHT,     "object-rotate-right"},
+       { EV_STOCK_RUN_PRESENTATION, "x-office-presentation"},
+};
 
+/**
+ * ev_stock_icons_init:
+ *
+ * Creates a new icon factory, adding the base stock icons to it.
+ */
 void
 ev_stock_icons_init (void)
 {
-        GtkIconFactory *factory;
+       GtkIconFactory *factory;
+       GtkIconSource *source;
+       gint i;
 
         factory = gtk_icon_factory_new ();
         gtk_icon_factory_add_default (factory);
 
-       /* fitwidth stock icon */
-       EV_ADD_STOCK_ICON (EV_STOCK_ZOOM_FIT_WIDTH, STOCK_ZOOM_FIT_WIDTH_FILE, GTK_STOCK_ZOOM_FIT);
-       
+       source = gtk_icon_source_new ();
+
+       for (i = 0; i < G_N_ELEMENTS (stock_icons); i++) {
+               GtkIconSet *set;
+
+               gtk_icon_source_set_icon_name (source, stock_icons [i].icon);
+
+               set = gtk_icon_set_new ();
+               gtk_icon_set_add_source (set, source);
+
+               gtk_icon_factory_add (factory, stock_icons [i].stock_id, set);
+               gtk_icon_set_unref (set);
+       }
+
+       gtk_icon_source_free (source);
+
        g_object_unref (G_OBJECT (factory));
 }