diff options
author | Daniel Elstner <danielk@openismus.com> | 2010-06-07 16:24:06 +0200 |
---|---|---|
committer | Daniel Elstner <danielk@openismus.com> | 2010-06-07 17:43:37 +0200 |
commit | 6fff182584c51288ddf07b5eebb770fcddc357be (patch) | |
tree | 8a16c4598a6a8685f37da867ca77db079cb26287 /examples | |
parent | 8bb88cdb945c78b64816252ba2b086617d4ba64c (diff) | |
download | glibmm-6fff182584c51288ddf07b5eebb770fcddc357be.tar.gz |
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.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile.am | 25 | ||||
-rw-r--r-- | examples/settings/settings.cc | 20 |
2 files changed, 25 insertions, 20 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am index 467e8616..97967f90 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 6e08ae78..a42e1061 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)); |