mirror of https://github.com/GNOME/gimp.git
libgimpwidgets: fix meson/mingw-w64 build and relocatable builds.
While passing the DATADIR macro works fine natively on Linux, it somehow failed with the mingw-w64 build with a very weird error: > <command-line>: error: expected identifier or '(' before string constant I could not understand what it means, as the '-DDATADIR="/some/path"' syntax is completely fine as far as I can see. Anyway since I see that DATAROOTDIR is already defined in meson config.h (but not in the autotools build, just the meson one!), and using datarootdir instead of datadir seems to be just fine (actually maybe even more appropriate when it comes to looking up the hicolor application icons), I just switched to using it. In the same time, I realized that my code using build-time macros won't work for relocatable builds anyway. So this commit also adds a bit of code path variant using gimp_installation_directory() in the case of ENABLE_RELOCATABLE_RESOURCES code path.
This commit is contained in:
parent
b7c2fbe6a8
commit
8025962a20
|
@ -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) \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue