From bc8fd91eed538ddb9a3fdd3b7e05c9ac16a61c97 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Tue, 12 May 2009 09:28:53 +0000 Subject: Move stock icons from libmisc to libview and make the API public --- diff --git a/evince-view.h b/evince-view.h index 74e78a8..ed88853 100644 --- a/evince-view.h +++ b/evince-view.h @@ -26,6 +26,7 @@ #include #include #include +#include #undef __EV_EVINCE_VIEW_H_INSIDE__ diff --git a/libmisc/Makefile.am b/libmisc/Makefile.am index 900e401..481caea 100644 --- a/libmisc/Makefile.am +++ b/libmisc/Makefile.am @@ -4,9 +4,7 @@ libevmisc_la_SOURCES = \ ev-page-action.c \ ev-page-action.h \ ev-page-action-widget.c \ - ev-page-action-widget.h \ - ev-stock-icons.c \ - ev-stock-icons.h + ev-page-action-widget.h libevmisc_la_CFLAGS = \ -DDATADIR=\"$(pkgdatadir)\" \ diff --git a/libview/Makefile.am b/libview/Makefile.am index edfacef..d59de19 100644 --- a/libview/Makefile.am +++ b/libview/Makefile.am @@ -12,6 +12,7 @@ INST_H_FILES = \ ev-jobs.h \ ev-job-scheduler.h \ ev-page-cache.h \ + ev-stock-icons.h \ ev-view.h \ ev-view-type-builtins.h @@ -23,6 +24,7 @@ libevview_la_SOURCES = \ ev-job-scheduler.c \ ev-page-cache.c \ ev-pixbuf-cache.c \ + ev-stock-icons.c \ ev-timeline.c \ ev-transition-animation.c \ ev-view.c \ @@ -33,6 +35,7 @@ libevview_la_SOURCES = \ $(INST_H_FILES) libevview_la_CPPFLAGS = \ + -DDATADIR=\"$(pkgdatadir)\" \ -DG_LOG_DOMAIN=\"EvinceView\" \ -DGNOMELOCALEDIR=\"$(datadir)/locale\" \ -DEVINCE_COMPILATION \ diff --git a/libmisc/ev-stock-icons.c b/libview/ev-stock-icons.c index 8b121e9..09aa89e 100644 --- a/libmisc/ev-stock-icons.c +++ b/libview/ev-stock-icons.c @@ -24,7 +24,6 @@ #include #include -#include #include "ev-stock-icons.h" @@ -48,6 +47,36 @@ static const EvStockIcon stock_icons [] = { static gchar *ev_icons_path; +static void +ev_stock_icons_add_icons_path_for_screen (GdkScreen *screen) +{ + GtkIconTheme *icon_theme; + + g_return_if_fail (ev_icons_path != NULL); + + icon_theme = screen ? gtk_icon_theme_get_for_screen (screen) : gtk_icon_theme_get_default (); + if (icon_theme) { + gchar **path = NULL; + gint n_paths; + gint i; + + /* GtkIconTheme will then look in Evince custom hicolor dir + * for icons as well as the standard search paths + */ + gtk_icon_theme_get_search_path (icon_theme, &path, &n_paths); + for (i = n_paths - 1; i >= 0; i--) { + if (g_ascii_strcasecmp (ev_icons_path, path[i]) == 0) + break; + } + + if (i < 0) + gtk_icon_theme_append_search_path (icon_theme, + ev_icons_path); + + g_strfreev (path); + } +} + /** * ev_stock_icons_init: * @@ -83,43 +112,21 @@ ev_stock_icons_init (void) g_object_unref (G_OBJECT (factory)); - ev_stock_icons_add_icons_path (); + ev_stock_icons_add_icons_path_for_screen (gdk_screen_get_default ()); } void -ev_stock_icons_shutdown (void) +ev_stock_icons_set_screen (GdkScreen *screen) { - g_free (ev_icons_path); + g_return_if_fail (GDK_IS_SCREEN (screen)); + + ev_stock_icons_add_icons_path_for_screen (screen); } void -ev_stock_icons_add_icons_path_for_screen (GdkScreen *screen) +ev_stock_icons_shutdown (void) { - GtkIconTheme *icon_theme; - - g_return_if_fail (ev_icons_path != NULL); - - icon_theme = screen ? gtk_icon_theme_get_for_screen (screen) : gtk_icon_theme_get_default (); - if (icon_theme) { - gchar **path = NULL; - gint n_paths; - gint i; - - /* GtkIconTheme will then look in Evince custom hicolor dir - * for icons as well as the standard search paths - */ - gtk_icon_theme_get_search_path (icon_theme, &path, &n_paths); - for (i = n_paths - 1; i >= 0; i--) { - if (g_ascii_strcasecmp (ev_icons_path, path[i]) == 0) - break; - } - - if (i < 0) - gtk_icon_theme_append_search_path (icon_theme, - ev_icons_path); - - g_strfreev (path); - } + g_free (ev_icons_path); } void diff --git a/libmisc/ev-stock-icons.h b/libview/ev-stock-icons.h index 793314d..c49dc17 100644 --- a/libmisc/ev-stock-icons.h +++ b/libview/ev-stock-icons.h @@ -21,17 +21,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ +#if !defined (__EV_EVINCE_VIEW_H_INSIDE__) && !defined (EVINCE_COMPILATION) +#error "Only can be included directly." +#endif + #ifndef __EV_STOCK_ICONS_H__ #define __EV_STOCK_ICONS_H__ -#include +#include G_BEGIN_DECLS /* Evince stock icons */ #define EV_STOCK_ZOOM "zoom" -#define EV_STOCK_ZOOM_PAGE "zoom-fit-page" -#define EV_STOCK_ZOOM_WIDTH "zoom-fit-width" +#define EV_STOCK_ZOOM_PAGE "zoom-fit-page" +#define EV_STOCK_ZOOM_WIDTH "zoom-fit-width" #define EV_STOCK_VIEW_DUAL "view-page-facing" #define EV_STOCK_VIEW_CONTINUOUS "view-page-continuous" #define EV_STOCK_ROTATE_LEFT "object-rotate-left" @@ -39,10 +43,9 @@ G_BEGIN_DECLS #define EV_STOCK_RUN_PRESENTATION "x-office-presentation" #define EV_STOCK_VISIBLE "eye" -void ev_stock_icons_init (void); -void ev_stock_icons_shutdown (void); -void ev_stock_icons_add_icons_path (void); -void ev_stock_icons_add_icons_path_for_screen (GdkScreen *screen); +void ev_stock_icons_init (void); +void ev_stock_icons_shutdown (void); +void ev_stock_icons_set_screen (GdkScreen *screen); G_END_DECLS diff --git a/previewer/ev-previewer-window.c b/previewer/ev-previewer-window.c index cbddbd8..8da5871 100644 --- a/previewer/ev-previewer-window.c +++ b/previewer/ev-previewer-window.c @@ -23,7 +23,6 @@ #include #include #include -#include "ev-stock-icons.h" #include "ev-page-action.h" #include "ev-previewer-window.h" diff --git a/previewer/ev-previewer.c b/previewer/ev-previewer.c index a425037..afe2127 100644 --- a/previewer/ev-previewer.c +++ b/previewer/ev-previewer.c @@ -24,7 +24,6 @@ #include #include #include -#include "ev-stock-icons.h" #include "ev-previewer-window.h" diff --git a/shell/ev-application.c b/shell/ev-application.c index 56824e8..83cbcf5 100644 --- a/shell/ev-application.c +++ b/shell/ev-application.c @@ -412,7 +412,7 @@ ev_application_open_window (EvApplication *application, } if (screen) { - ev_stock_icons_add_icons_path_for_screen (screen); + ev_stock_icons_set_screen (screen); gtk_window_set_screen (GTK_WINDOW (new_window), screen); } @@ -536,7 +536,7 @@ ev_application_open_uri_at_dest (EvApplication *application, } if (screen) { - ev_stock_icons_add_icons_path_for_screen (screen); + ev_stock_icons_set_screen (screen); gtk_window_set_screen (GTK_WINDOW (new_window), screen); } -- cgit v0.9.1