Integrate GSettings, remember View settings.

The org.logdiag ID has been chosen as I haven't found any specific rules
and com.github.logdiag seems not to be future-proof. This domain remains
available so far, anyway.

The schemas are compiled only when installed directly to CMAKE_INSTALL_PREFIX
to the root filesystem. When invoking `make install` with DESTDIR, only
the XML files are copied over as the schemas would have to be recompiled
later anyway.
This commit is contained in:
Přemysl Eric Janouch 2011-06-10 18:18:58 +02:00
parent e1e9a6d319
commit b2223d6595
7 changed files with 80 additions and 3 deletions

View File

@ -256,7 +256,40 @@ if (GTK_DOC_FOUND)
HTML ${project_DOC_DIR}/html)
endif (GTK_DOC_FOUND)
# GSettings
find_program (GLIB_COMPILE_SCHEMAS_EXECUTABLE glib-compile-schemas)
if (NOT GLIB_COMPILE_SCHEMAS_EXECUTABLE)
message (FATAL_ERROR "glib-compile-schemas not found")
endif (NOT GLIB_COMPILE_SCHEMAS_EXECUTABLE)
set (GSETTINGS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/share")
set (GSETTINGS_SCHEMAS "${GSETTINGS_DIR}/org.logdiag.gschema.xml")
add_custom_target (logdiag_gschema_check
COMMAND ${GLIB_COMPILE_SCHEMAS_EXECUTABLE} --dry-run "${GSETTINGS_DIR}"
DEPENDS "${GSETTINGS_SCHEMAS}"
COMMENT "Checking GSettings schema files" VERBATIM)
if (OPTION_NOINSTALL)
set (GSETTINGS_COMPILED_SCHEMA "${CMAKE_CURRENT_BINARY_DIR}/gschemas.compiled")
add_custom_command (OUTPUT "${GSETTINGS_COMPILED_SCHEMA}"
COMMAND ${GLIB_COMPILE_SCHEMAS_EXECUTABLE}
"--targetdir=${CMAKE_CURRENT_BINARY_DIR}" "${GSETTINGS_DIR}"
DEPENDS "${GSETTINGS_SCHEMAS}"
COMMENT "Compiling GSettings schema files" VERBATIM)
add_custom_target (logdiag_gschema ALL DEPENDS "${GSETTINGS_COMPILED_SCHEMA}")
endif (OPTION_NOINSTALL)
# Installation
install (FILES ${GSETTINGS_SCHEMAS}
DESTINATION share/glib-2.0/schemas)
install (CODE " # DESTDIR is not in use on Windows
if (WIN32 OR \"\$ENV{DESTDIR}\" STREQUAL \"\")
execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS_EXECUTABLE}
\"\${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas\")
endif (WIN32 OR \"\$ENV{DESTDIR}\" STREQUAL \"\")")
install (DIRECTORY share/gui share/library
DESTINATION share/${CMAKE_PROJECT_NAME})
@ -266,7 +299,8 @@ if (WIN32)
${WIN32_DEPENDS_PATH}/bin/
DESTINATION .
FILES_MATCHING PATTERN "*.dll"
PATTERN "libgettext*" EXCLUDE)
PATTERN "libgettext*" EXCLUDE
PATTERN "libintl*" EXCLUDE)
install (DIRECTORY
${WIN32_DEPENDS_PATH}/etc/
DESTINATION etc)

1
NEWS
View File

@ -1,5 +1,6 @@
Version TBD
- Added scrolling using the middle mouse button.
- View menu settings are remembered.
- Fixed command line parsing on Windows,
it's not limited to the system ANSI codepage anymore.
- Fixed checking for the shift key when selecting.

View File

@ -67,8 +67,8 @@ set (pkg_mingw_lua_md5
set (pkg_opensuse_root "http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_11.4/noarch/")
set (pkg_opensuse_listing "${working_dir}/opensuse-listing")
set (pkg_opensuse_names
"mingw32-libjson-glib"
"mingw32-json-glib-devel")
"mingw32-libjson-glib" "mingw32-json-glib-devel"
"mingw32-glib2-tools" "mingw32-libintl")
set (pkg_opensuse_strip "usr/i686-w64-mingw32/sys-root/mingw")
# Stage 1: retrieve openSUSE package links

View File

@ -15,6 +15,7 @@
#if ${OPTION_NOINSTALL}
/* For developers. */
#define PROJECT_SHARE_DIR "${CMAKE_SOURCE_DIR}/share/"
#define PROJECT_GSETTINGS_DIR "${CMAKE_BINARY_DIR}"
#elif defined (_WIN32)
#define PROJECT_SHARE_DIR "share/${PROJECT_NAME}/"
#else

View File

@ -0,0 +1,17 @@
<schemalist>
<schema id="org.logdiag" path="/apps/logdiag/" gettext-domain="logdiag">
<key name="show-main-toolbar" type="b">
<default>true</default>
<summary>Whether to show the main toolbar</summary>
</key>
<key name="show-library-toolbar" type="b">
<default>true</default>
<summary>Whether to show the library toolbar</summary>
</key>
<key name="show-grid" type="b">
<default>true</default>
<summary>Whether to show the grid</summary>
</key>
</schema>
</schemalist>

View File

@ -18,6 +18,7 @@
struct _LdWindowMainPrivate
{
GSettings *settings;
GtkUIManager *ui_manager;
GtkActionGroup *action_group;
@ -353,6 +354,19 @@ ld_window_main_init (LdWindowMain *self)
/* Realize the window. */
gtk_widget_show_all (GTK_WIDGET (self));
/* Set up GSettings. */
priv->settings = g_settings_new ("org." PROJECT_NAME);
g_settings_bind (priv->settings, "show-main-toolbar",
gtk_action_group_get_action (priv->action_group,
"MainToolbar"), "active", G_SETTINGS_BIND_DEFAULT);
g_settings_bind (priv->settings, "show-library-toolbar",
gtk_action_group_get_action (priv->action_group,
"LibraryToolbar"), "active", G_SETTINGS_BIND_DEFAULT);
g_settings_bind (priv->settings, "show-grid",
gtk_action_group_get_action (priv->action_group,
"ShowGrid"), "active", G_SETTINGS_BIND_DEFAULT);
}
static void
@ -369,6 +383,7 @@ ld_window_main_finalize (GObject *gobject)
g_object_unref (self->priv->diagram);
g_object_unref (self->priv->ui_manager);
g_object_unref (self->priv->action_group);
g_object_unref (self->priv->settings);
if (self->priv->filename)
g_free (self->priv->filename);

View File

@ -131,6 +131,15 @@ main (int argc, char *argv[])
}
#endif
#ifdef PROJECT_GSETTINGS_DIR
/* This is enabled when the build is set up for developing, so the
* application can find it's schema. It might also find use when
* installing the application into a location that's missing from
* g_get_system_data_dirs(), for example /usr/local or ~/.local.
*/
g_setenv ("GSETTINGS_SCHEMA_DIR", PROJECT_GSETTINGS_DIR, 0);
#endif /* PROJECT_GSETTINGS_DIR */
gtk_window_set_default_icon_name (PROJECT_NAME);
/* TODO: Be able to open multiple files. */