]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
hello-c-gnome3: Fix an error "Settings schema 'org.gnu.gettext.examples.hello' is...
authorBruno Haible <bruno@clisp.org>
Mon, 16 Dec 2024 13:58:07 +0000 (14:58 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 31 Dec 2024 10:09:37 +0000 (11:09 +0100)
* gettext-tools/examples/hello-c-gnome3/configure.ac: Invoke
gl_BUILD_TO_HOST_LOCALEDIR, gl_BUILD_TO_HOST_PKGDATADIR.
* gettext-tools/examples/hello-c-gnome3/Makefile.am (DEFS): Define also
PKGDATADIR.
(pkgdata_DATA): New variable.
* gettext-tools/examples/hello-c-gnome3/hello.c (main): Add PKGDATADIR to the
GSETTINGS_SCHEMA_DIR value.

gettext-tools/examples/hello-c-gnome3/Makefile.am
gettext-tools/examples/hello-c-gnome3/configure.ac
gettext-tools/examples/hello-c-gnome3/hello.c

index d7168bce855f511f0fa484dbbfbff52b662f1704..39f3b03170a5f5c17b6ee3b9fb473e9caefd6ec3 100644 (file)
@@ -16,8 +16,12 @@ bin_PROGRAMS = hello
 # The source files of the 'hello' program.
 hello_SOURCES = hello.c resources.c
 
-# Define a C macro LOCALEDIR indicating where catalogs will be installed.
-DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
+# Define a C macro LOCALEDIR indicating where catalogs will be installed
+# and a C macro PKGDATADIR indicating a package-specific location.
+DEFS = \
+  -DLOCALEDIR=$(localedir_c_make) \
+  -DPKGDATADIR=$(pkgdatadir_c_make) \
+  @DEFS@
 
 # Make sure the gnome.h include file is found.
 AM_CPPFLAGS = $(GTK_CFLAGS)
@@ -36,6 +40,10 @@ resources.c: hello.gresource.xml hello.ui
        $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ \
                --sourcedir=$(srcdir) --generate-source
 
+# Install the compiled GSettings schema in a package-specific location
+# (so that "make install" works with a --prefix other than /usr).
+pkgdata_DATA = gschemas.compiled
+
 desktopdir = $(datadir)/applications
 desktop_DATA = hello.desktop
 
index def954606a602348c048b9c56354682fae543b65..209a6046bdae22b12e6d533b1fcc7acc9b588c5a 100644 (file)
@@ -11,6 +11,11 @@ AC_PROG_CC
 AM_GNU_GETTEXT([external])
 AM_GNU_GETTEXT_VERSION([0.23])
 
+dnl Define localedir_c and localedir_c_make.
+gl_BUILD_TO_HOST_LOCALEDIR
+dnl Define pkgdatadir_c and pkgdatadir_c_make.
+gl_BUILD_TO_HOST_PKGDATADIR
+
 dnl Check GNOME specific stuff.
 dnl
 dnl If you have full GNOME development environment installed on your
index 2683012bf3a4352917c3404b824df6cb74646c0b..f7a7a801cc64308a8b99c819d126bfdb492617ed 100644 (file)
@@ -170,8 +170,12 @@ main (int argc, char *argv[])
   GApplication *application;
   int status;
 
-  /* Load the GSettings schema from the current directory.  */
-  g_setenv ("GSETTINGS_SCHEMA_DIR", ".", FALSE);
+  /* Load the compiled GSettings schema
+     - from PKGDATADIR (so that it works after "make install"),
+     - from the current directory (so that it works in the build directory,
+       before "make install").  */
+  g_setenv ("GSETTINGS_SCHEMA_DIR", PKGDATADIR G_SEARCHPATH_SEPARATOR_S ".",
+            FALSE);
 
   /* Initializations.  */
   textdomain ("hello-c-gnome3");