[glibmm] Do not install the schema of the gsettings example



commit 6fff182584c51288ddf07b5eebb770fcddc357be
Author: Daniel Elstner <danielk openismus com>
Date:   Mon Jun 7 16:24:06 2010 +0200

    Do not install the schema of the gsettings example
    
    * examples/Makefile.am: Do not install the schema file of the settings
    example to the user's system.  Instead, compile the binary shema cache
    in a local directory and have the example use that.  As a side effect,
    this also resolves the "make distcheck" failure when trying to install
    the schema.
    * examples/settings/settings.cc (main): Do not try to determine the
    schema directory from the executable name, as it depends too much on
    the libtool setup with the hidden .libs directory being part of the
    path name.  Requiring the user to change to the example directory is
    good enough.  Also, initialize the C++ locale on program startup, and
    call Gio::init() instead of Glib::init().
    (on_key_changed): Call ustring::raw() to suppress the locale-aware
    comparison ustring performs by default.

 ChangeLog                     |   18 ++++++++++++++++++
 examples/Makefile.am          |   25 +++++++++++++++----------
 examples/settings/settings.cc |   20 ++++++++++----------
 3 files changed, 43 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b0a1aef..5512586 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2010-06-07  Daniel Elstner  <danielk openismus com>
+
+	Do not install the schema of the gsettings example
+
+	* examples/Makefile.am: Do not install the schema file of the settings
+	example to the user's system.  Instead, compile the binary shema cache
+	in a local directory and have the example use that.  As a side effect,
+	this also resolves the "make distcheck" failure when trying to install
+	the schema.
+	* examples/settings/settings.cc (main): Do not try to determine the
+	schema directory from the executable name, as it depends too much on
+	the libtool setup with the hidden .libs directory being part of the
+	path name.  Requiring the user to change to the example directory is
+	good enough.  Also, initialize the C++ locale on program startup, and
+	call Gio::init() instead of Glib::init().
+	(on_key_changed): Call ustring::raw() to suppress the locale-aware
+	comparison ustring performs by default.
+
 2010-06-06  Murray Cumming  <murrayc murrayc com>
 
 	Documentation: Mention module names in Enums and Flags doxygen groups.
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 467e861..97967f9 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -24,8 +24,8 @@ check_PROGRAMS =			\
 	keyfile/example			\
 	markup/parser			\
 	network/resolver		\
-	network/socket-client	\
-	network/socket-server	\
+	network/socket-client		\
+	network/socket-server		\
 	options/example			\
 	properties/example		\
 	regex/example			\
@@ -72,14 +72,19 @@ thread_threadpool_SOURCES  = thread/threadpool.cc
 thread_threadpool_LDADD    = $(thread_ldadd)
 
 network_resolver_SOURCES   = network/resolver.cc
-network_resolver_LDADD     = $(giomm_ldadd) $(GTHREAD_LIBS)
-network_socket_client_SOURCES   = network/socket-client.cc
-network_socket_client_LDADD     = $(giomm_ldadd) $(GTHREAD_LIBS)
-network_socket_server_SOURCES   = network/socket-server.cc
-network_socket_server_LDADD     = $(giomm_ldadd) $(GTHREAD_LIBS)
-
-gsettings_SCHEMAS = $(wildcard settings/*.gschema.xml)
- GSETTINGS_RULES@
+network_resolver_LDADD     = $(giomm_ldadd)
+network_socket_client_SOURCES = network/socket-client.cc
+network_socket_client_LDADD   = $(giomm_ldadd)
+network_socket_server_SOURCES = network/socket-server.cc
+network_socket_server_LDADD   = $(giomm_ldadd)
 
 settings_settings_SOURCES = settings/settings.cc
 settings_settings_LDADD   = $(giomm_ldadd)
+
+dist_noinst_DATA = settings/org.gtkmm.demo.gschema.xml
+CLEANFILES = settings/gschemas.compiled
+
+settings/gschemas.compiled: $(srcdir)/settings/org.gtkmm.demo.gschema.xml
+	$(AM_V_GEN)glib-compile-schemas --targetdir=settings $(srcdir)/settings
+
+all-local: settings/gschemas.compiled
diff --git a/examples/settings/settings.cc b/examples/settings/settings.cc
index 6e08ae7..a42e106 100644
--- a/examples/settings/settings.cc
+++ b/examples/settings/settings.cc
@@ -22,36 +22,36 @@
 #include <giomm.h>
 #include <iostream>
 
-const char* STRING_KEY = "test-string";
-const char* INT_KEY = "test-int";
+const char *const STRING_KEY = "test-string";
+const char *const INT_KEY = "test-int";
 
 static void on_key_changed(const Glib::ustring& key, const Glib::RefPtr<Gio::Settings>& settings)
 {
     std::cout << Glib::ustring::compose("'%1' changed\n", key);
-    if (key == STRING_KEY)
+    if (key.raw() == STRING_KEY)
         std::cout << Glib::ustring::compose("New value of '%1': '%2'\n",
                                             key, settings->get_string(key));
-    else if (key == INT_KEY)
+    else if (key.raw() == INT_KEY)
         std::cout << Glib::ustring::compose("New value of '%1': '%2'\n",
                                             key, settings->get_int(key));
     else
         std::cerr << "Unknown key\n";
 }
 
-int main(int /* argc */, char** argv)
+int main(int, char**)
 {
-    Glib::init();
+    std::locale::global(std::locale(""));
+    Gio::init();
 
     // this is only a demo so we don't want to rely on an installed schema.
     // Instead we set some environment variables that allow us to test things
     // from the source directory.  We need to strip off the .libs/ directory
     // first (thus the '..').  Generally you would install your schemas to the system schema
     // directory
-    std::string dirname = Glib::build_filename(Glib::path_get_dirname(argv[0]), "..");
-    Glib::setenv ("GSETTINGS_SCHEMA_DIR", dirname, TRUE);
-    Glib::setenv ("GSETTINGS_BACKEND", "memory", TRUE);
+    Glib::setenv("GSETTINGS_SCHEMA_DIR", ".", true);
+    Glib::setenv("GSETTINGS_BACKEND", "memory", true);
 
-    Glib::RefPtr<Gio::Settings> settings =
+    const Glib::RefPtr<Gio::Settings> settings =
         Gio::Settings::create("org.gtkmm.demo");
 
     settings->signal_changed().connect(sigc::bind(sigc::ptr_fun(&on_key_changed), settings));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]