diff --git a/libgimpwidgets/Makefile.am b/libgimpwidgets/Makefile.am index d1a7726edd..2e99f00721 100644 --- a/libgimpwidgets/Makefile.am +++ b/libgimpwidgets/Makefile.am @@ -56,7 +56,7 @@ libgimpwidgetsincludedir = $(includedir)/gimp-$(GIMP_API_VERSION)/libgimpwidgets AM_CPPFLAGS = \ -DG_LOG_DOMAIN=\"LibGimpWidgets\" \ -DGIMP_WIDGETS_COMPILATION \ - -DDATADIR=\""$(datadir)"\" \ + -DDATAROOTDIR=\""$(datarootdir)"\" \ -I$(top_srcdir) \ $(GEGL_CFLAGS) \ $(GTK_CFLAGS) \ diff --git a/libgimpwidgets/gimpwidgets-private.c b/libgimpwidgets/gimpwidgets-private.c index 83c46b6e90..f435c35b34 100644 --- a/libgimpwidgets/gimpwidgets-private.c +++ b/libgimpwidgets/gimpwidgets-private.c @@ -65,8 +65,9 @@ gimp_widgets_init (GimpHelpFunc standard_help_func, GimpGetColorFunc get_background_func, GimpEnsureModulesFunc ensure_modules_func) { - const gchar *svg_icon = DATADIR "/icons/hicolor/scalable/apps/gimp.svg"; GList *icons = NULL; + gchar *base_dir; + gchar *path; GdkPixbuf *pixbuf; g_return_if_fail (standard_help_func != NULL); @@ -83,6 +84,12 @@ gimp_widgets_init (GimpHelpFunc standard_help_func, gimp_icons_init (); +#ifdef ENABLE_RELOCATABLE_RESOURCES + base_dir = g_build_filename (gimp_installation_directory (), "share", "icons", "hicolor", NULL); +#else + base_dir = g_build_filename (DATAROOTDIR, "icons", "hicolor", NULL); +#endif + /* Loading the application icons. Unfortunately GTK doesn't know how * to load any size from a single SVG, so we have to generate common * sizes ourselves. @@ -90,31 +97,40 @@ gimp_widgets_init (GimpHelpFunc standard_help_func, * then the application icon is dependant to the theme and for now at * least, we want the installed icon. */ - pixbuf = gdk_pixbuf_new_from_file (DATADIR "/icons/hicolor/16x16/apps/gimp.png", NULL); + path = g_build_filename (base_dir, "16x16/apps/gimp.png", NULL); + pixbuf = gdk_pixbuf_new_from_file (DATAROOTDIR "/icons/hicolor/16x16/apps/gimp.png", NULL); if (pixbuf) icons = g_list_prepend (icons, pixbuf); else - g_warning ("Application icon missing: %s", DATADIR "/icons/hicolor/16x16/apps/gimp.png"); + g_warning ("Application icon missing: %s", path); + g_free (path); - pixbuf = gdk_pixbuf_new_from_file (DATADIR "/icons/hicolor/32x32/apps/gimp.png", NULL); + path = g_build_filename (base_dir, "32x32/apps/gimp.png", NULL); + pixbuf = gdk_pixbuf_new_from_file (DATAROOTDIR "/icons/hicolor/32x32/apps/gimp.png", NULL); if (pixbuf) icons = g_list_prepend (icons, pixbuf); else - g_warning ("Application icon missing: %s", DATADIR "/icons/hicolor/32x32/apps/gimp.png"); + g_warning ("Application icon missing: %s", path); + g_free (path); - pixbuf = gdk_pixbuf_new_from_file (DATADIR "/icons/hicolor/48x48/apps/gimp.png", NULL); + path = g_build_filename (base_dir, "48x48/apps/gimp.png", NULL); + pixbuf = gdk_pixbuf_new_from_file (DATAROOTDIR "/icons/hicolor/48x48/apps/gimp.png", NULL); if (pixbuf) icons = g_list_prepend (icons, pixbuf); else - g_warning ("Application icon missing: %s", DATADIR "/icons/hicolor/48x48/apps/gimp.png"); + g_warning ("Application icon missing: %s", path); + g_free (path); - pixbuf = gdk_pixbuf_new_from_file (DATADIR "/icons/hicolor/64x64/apps/gimp.png", NULL); + path = g_build_filename (base_dir, "64x64/apps/gimp.png", NULL); + pixbuf = gdk_pixbuf_new_from_file (DATAROOTDIR "/icons/hicolor/64x64/apps/gimp.png", NULL); if (pixbuf) icons = g_list_prepend (icons, pixbuf); else - g_warning ("Application icon missing: %s", DATADIR "/icons/hicolor/64x64/apps/gimp.png"); + g_warning ("Application icon missing: %s", path); + g_free (path); - pixbuf = gdk_pixbuf_new_from_file_at_size (svg_icon, 128, 128, NULL); + path = g_build_filename (base_dir, "scalable/apps/gimp.svg", NULL); + pixbuf = gdk_pixbuf_new_from_file_at_size (path, 128, 128, NULL); if (pixbuf) { /* Various common sizes from the same SVG. Why I go into such @@ -124,31 +140,34 @@ gimp_widgets_init (GimpHelpFunc standard_help_func, */ icons = g_list_prepend (icons, pixbuf); - pixbuf = gdk_pixbuf_new_from_file_at_size (svg_icon, 144, 144, NULL); + pixbuf = gdk_pixbuf_new_from_file_at_size (path, 144, 144, NULL); icons = g_list_prepend (icons, pixbuf); - pixbuf = gdk_pixbuf_new_from_file_at_size (svg_icon, 160, 160, NULL); + pixbuf = gdk_pixbuf_new_from_file_at_size (path, 160, 160, NULL); icons = g_list_prepend (icons, pixbuf); - pixbuf = gdk_pixbuf_new_from_file_at_size (svg_icon, 176, 176, NULL); + pixbuf = gdk_pixbuf_new_from_file_at_size (path, 176, 176, NULL); icons = g_list_prepend (icons, pixbuf); - pixbuf = gdk_pixbuf_new_from_file_at_size (svg_icon, 192, 192, NULL); + pixbuf = gdk_pixbuf_new_from_file_at_size (path, 192, 192, NULL); icons = g_list_prepend (icons, pixbuf); - pixbuf = gdk_pixbuf_new_from_file_at_size (svg_icon, 224, 224, NULL); + pixbuf = gdk_pixbuf_new_from_file_at_size (path, 224, 224, NULL); icons = g_list_prepend (icons, pixbuf); } else { - g_warning ("Application icon missing: %s", svg_icon); + g_warning ("Application icon missing: %s", path); } + g_free (path); - pixbuf = gdk_pixbuf_new_from_file (DATADIR "/icons/hicolor/256x256/apps/gimp.png", NULL); + path = g_build_filename (base_dir, "256x256/apps/gimp.png", NULL); + pixbuf = gdk_pixbuf_new_from_file (DATAROOTDIR "/icons/hicolor/256x256/apps/gimp.png", NULL); if (pixbuf) icons = g_list_prepend (icons, pixbuf); else - g_warning ("Application icon missing: %s", DATADIR "/icons/hicolor/256x256/apps/gimp.png"); + g_warning ("Application icon missing: %s", path); + g_free (path); gtk_window_set_default_icon_list (icons); g_list_free_full (icons, g_object_unref); @@ -156,6 +175,7 @@ gimp_widgets_init (GimpHelpFunc standard_help_func, gimp_widgets_init_foreign_enums (); gimp_widgets_initialized = TRUE; + g_free (base_dir); } /* clean up babl (in particular, so that the fish cache is constructed) if the diff --git a/libgimpwidgets/meson.build b/libgimpwidgets/meson.build index 3cf15959c8..488ce7ad5f 100644 --- a/libgimpwidgets/meson.build +++ b/libgimpwidgets/meson.build @@ -189,9 +189,7 @@ libgimpwidgets = library('gimpwidgets-'+ gimp_api_version, dependencies: [ gegl, gtk3, lcms, math ], - c_args: [ '-DG_LOG_DOMAIN="LibGimpWidgets"', '-DGIMP_WIDGETS_COMPILATION', - '-DDATADIR="@0@"'.format(prefix / get_option('datadir')), - ], + c_args: [ '-DG_LOG_DOMAIN="LibGimpWidgets"', '-DGIMP_WIDGETS_COMPILATION', ], link_with: [ libgimpbase, libgimpcolor,