[devhelp/gsettings] broken migration to GSettings
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp/gsettings] broken migration to GSettings
- Date: Wed, 21 Jul 2010 17:18:54 +0000 (UTC)
commit 6c58217e5b6f7b8a4803ed5382dbf29c383c2107
Author: Ryan Lortie <desrt desrt ca>
Date: Sat Sep 19 15:31:06 2009 -0400
broken migration to GSettings
configure.ac | 13 +-
data/Makefile.am | 29 +--
data/devhelp.schemas.in | 178 -----------------
data/org.gnome.Devhelp.gschema.xml | 105 ++++++++++
po/POTFILES.in | 1 -
src/Makefile.am | 12 -
src/dh-assistant.c | 3 +-
src/dh-base.c | 8 -
src/dh-preferences.c | 139 ++------------
src/dh-util.c | 257 ++++++++++---------------
src/dh-util.h | 15 +-
src/dh-window.c | 8 +-
src/ige-conf-gconf.c | 387 ------------------------------------
src/ige-conf-mac.c | 342 -------------------------------
src/ige-conf-private.h | 54 -----
src/ige-conf.c | 337 -------------------------------
src/ige-conf.h | 87 --------
17 files changed, 240 insertions(+), 1735 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b3ba2e7..543dd46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,23 +32,21 @@ AM_PROG_CC_C_O
IT_PROG_INTLTOOL([0.40.0])
PKG_PROG_PKG_CONFIG
-AM_GCONF_SOURCE_2
GNOME_COMPILE_WARNINGS
+GLIB_GSETTINGS
dnl -----------------------------------------------------------
dnl Platform (GTK+ X11 or GTK OS X)
dnl -----------------------------------------------------------
IGE_PLATFORM_CHECK
if test "x$IGE_PLATFORM" = xx11; then
- gconf_pkgconfig="gconf-2.0 >= 2.6.0"
- libwnck_pkgconfig=
+ libwnck_pkgconfig="libwnck-1.0 >= 2.10.0"
igemacintegration_pkgconfig=
REQUIRES_LIBWNCK=
PLATFORM_CFLAGS=
PLATFORM_LDFLAGS=
HAVE_WNCK=no
else
- gconf_pkgconfig=
libwnck_pkgconfig=
igemacintegration_pkgconfig="ige-mac-integration >= 0.8.2"
REQUIRES_LIBWNCK=
@@ -56,7 +54,6 @@ else
PLATFORM_LDFLAGS=
HAVE_WNCK=no
fi
-AM_CONDITIONAL(GCONF_SCHEMAS_INSTALL, test "x$IGE_PLATFORM" = xx11)
AC_SUBST(PLATFORM_CFLAGS)
AC_SUBST(PLATFORM_LDFLAGS)
AC_SUBST(REQUIRES_LIBWNCK)
@@ -64,17 +61,17 @@ AC_SUBST(REQUIRES_LIBWNCK)
PKG_CHECK_MODULES(DEVHELP, [
gthread-2.0 >= 2.10.0
gtk+-3.0
- webkitgtk-3.0
- unique-3.0
])
+ #webkitgtk-3.0
+ #unique-3.0
PKG_CHECK_MODULES(LIBDEVHELP, [
gtk+-3.0
$gconf_pkgconfig
$libwnck_pkgconfig
$igemacintegration_pkgconfig
- webkitgtk-3.0
])
+ #webkitgtk-3.0
if test "x$HAVE_WNCK" = "xyes" ; then
AC_DEFINE(HAVE_WNCK, 1, [Defined if libwnck is available])
diff --git a/data/Makefile.am b/data/Makefile.am
index 31d10fc..02038b3 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -14,36 +14,19 @@ desktopdir = $(datadir)/applications
desktop_in_files = devhelp.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
-schemasdir = $(GCONF_SCHEMA_FILE_DIR)
-schemas_in_files = devhelp.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
- INTLTOOL_SCHEMAS_RULE@
-
-defaultsdir = $(datadir)/devhelp
-defaults_DATA = devhelp.defaults
-devhelp.defaults: devhelp.schemas.in
- cp $(top_srcdir)/data/devhelp.schemas.in $(top_builddir)/data/devhelp.defaults
+gsettings_SCHEMAS = org.gnome.Devhelp.gschema.xml
+ GSETTINGS_RULES@
EXTRA_DIST = \
- libdevhelp-3.0.pc.in \
+ org.gnome.Devhelp.gschema.xml \
+ libdevhelp-3.0.pc.in \
$(desktop_in_files) \
- $(schemas_in_files) \
- $(schemas_DATA) \
$(assistant_DATA)
-install-data-local: $(schema_DATA)
-if GCONF_SCHEMAS_INSTALL
- if test -z "$(DESTDIR)" ; then \
- for p in $^ ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $$p >&1 > /dev/null; \
- done \
- fi
-endif
-
CLEANFILES = \
$(DESKTOP_FILES) \
+ $(gsettingsschema_DATA) \
$(defaults_DATA)
DISTCLEANFILES = \
- $(desktop_DATA) \
- $(schemas_DATA)
+ $(desktop_DATA)
diff --git a/data/org.gnome.Devhelp.gschema.xml b/data/org.gnome.Devhelp.gschema.xml
new file mode 100644
index 0000000..0a73708
--- /dev/null
+++ b/data/org.gnome.Devhelp.gschema.xml
@@ -0,0 +1,105 @@
+<schemalist>
+ <schema id='org.gnome.Devhelp' path='/apps/devhelp/'>
+ <child name='state' schema='org.gnome.Devhelp.state'/>
+ <child name='ui' schema='org.gnome.Devhelp.ui'/>
+ </schema>
+
+ <schema id='org.gnome.Devhelp.state'>
+ <child name='assistant' schema='org.gnome.Devhelp.AssistantState'/>
+ <child name='main' schema='org.gnome.Devhelp.MainState'/>
+ </schema>
+
+ <schema id='org.gnome.Devhelp.WindowState'>
+ <key name='maximized' type='b'>
+ <summary>If the window is maximized</summary>
+ <description>
+ TRUE if the window is maximized. Otherwise, the size and
+ position of the window are determined by the size and position
+ keys.
+ </description>
+ <default>false</default>
+ </key>
+
+ <key name='size' type='(ii)'>
+ <summary>The size of the window</summary>
+ <description>
+ The size of the window, if not maximized. (0, 0) indicates no
+ specific initial size.
+ </description>
+ <default>(0, 0)</default>
+ </key>
+
+ <key name='position' type='(ii)'>
+ <summary>The initial position of the window</summary>
+ <description>
+ The initial position of the window, if not maximized. (-1, -1)
+ specifies no specific initial position (ie: allow the window
+ maanger to decide).
+ </description>
+ <default>(-1, -1)</default>
+ </key>
+ </schema>
+
+ <schema id='org.gnome.Devhelp.AssistantState'
+ extends='org.gnome.Devhelp.WindowState'>
+ <override name='size'>(350, 400)</override>
+ </schema>
+
+ <schema id='org.gnome.Devhelp.MainState'
+ extends='org.gnome.Devhelp.WindowState'>
+ <override name='size'>(700, 500)</override>
+
+ <key name='selected-tab' type='s'>
+ <summary>The selected tab</summary>
+ <description>
+ The initially selected tab in the sidebar of the main window.
+ </description>
+ <choices>
+ <choice value='content'/>
+ <choice value='search'/>
+ </choices>
+ <default>'content'</default>
+ </key>
+
+ <key name='paned-position' type='i'>
+ <summary>The position of the pane divider</summary>
+ <description>
+ The position of the pane divider. This is how many pixels are
+ allocated to the search/contents notebook sidebar.
+ </description>
+ <default>250</default>
+ </key>
+ </schema>
+
+ <schema id='org.gnome.Devhelp.ui'>
+ <key name='fixed-font' type='s'>
+ <summary>The monospace font to use</summary>
+ <description>
+ The monospace font used by devhelp when displaying documentation.
+ </description>
+ <default>'Monospace 12'</default>
+ </key>
+
+ <key name='variable-font' type='s'>
+ <summary>The variable-width font to use</summary>
+ <description>
+ The variable width font used by devhelp when displaying
+ documentation. This does not impact the Gtk UI of devhelp.
+ </description>
+ <default>'Sans 12'</default>
+ </key>
+
+ <key name='use-system-fonts' type='b'>
+ <summary>If devhelp should use system fonts</summary>
+ <description>
+ If this is set to TRUE then Devhelp will use the system fonts
+ for rendering the documentation.
+
+ If this is set to FALSE then Devhelp will use the fonts
+ specified here.
+ </description>
+ <default>false</default>
+ </key>
+ </schema>
+
+</schemalist>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ee2c12f..def4637 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,7 +1,6 @@
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
data/devhelp.desktop.in.in
-data/devhelp.schemas.in
data/ui/devhelp.builder
misc/gedit-plugin/devhelp.desktop.in
misc/gedit-plugin/devhelp/devhelp.py
diff --git a/src/Makefile.am b/src/Makefile.am
index 1dae47b..2040bf2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -87,9 +87,6 @@ libdevhelp_3_la_SOURCES = \
dh-util.h \
eggfindbar.c \
eggfindbar.h \
- ige-conf.c \
- ige-conf.h \
- ige-conf-private.h \
$(conf_platform_sources)
libdevhelp_3_la_CPPFLAGS = \
@@ -114,12 +111,3 @@ dh-enum-types.h: dh-enum-types.h.template $(INST_H_FILES) $(GLIB_MKENUMS)
dh-enum-types.c: dh-enum-types.c.template $(INST_H_FILES) $(GLIB_MKENUMS)
$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template dh-enum-types.c.template $(INST_H_FILES)) > $@
-
-if HAVE_PLATFORM_OSX
-conf_platform_sources = ige-conf-mac.c
-libdevhelp_3_la_CPPFLAGS += -xobjective-c
-endif
-if HAVE_PLATFORM_X11
-conf_platform_sources = ige-conf-gconf.c
-endif
-
diff --git a/src/dh-assistant.c b/src/dh-assistant.c
index bd19d88..ef0ae57 100644
--- a/src/dh-assistant.c
+++ b/src/dh-assistant.c
@@ -91,8 +91,7 @@ dh_assistant_init (DhAssistant *assistant)
gtk_box_pack_start (GTK_BOX (priv->main_box),
scrolled_window, TRUE, TRUE, 0);
- dh_util_state_manage_window (GTK_WINDOW (assistant),
- "assistant/window");
+ dh_util_state_manage_window (GTK_WINDOW (assistant), "assistant");
}
GtkWidget *
diff --git a/src/dh-base.c b/src/dh-base.c
index bc1c954..dfcf0c8 100644
--- a/src/dh-base.c
+++ b/src/dh-base.c
@@ -39,7 +39,6 @@
#include "dh-preferences.h"
#include "dh-assistant.h"
#include "dh-util.h"
-#include "ige-conf.h"
#include "dh-base.h"
#include "dh-book-manager.h"
@@ -94,13 +93,6 @@ static void
dh_base_init (DhBase *base)
{
DhBasePriv *priv = GET_PRIVATE (base);
- IgeConf *conf;
- gchar *path;
-
- conf = ige_conf_get ();
- path = dh_util_build_data_filename ("devhelp", "devhelp.defaults", NULL);
- ige_conf_add_defaults (conf, path);
- g_free (path);
priv->book_manager = dh_book_manager_new ();
dh_book_manager_populate (priv->book_manager);
diff --git a/src/dh-preferences.c b/src/dh-preferences.c
index 4d50a6d..e083d88 100644
--- a/src/dh-preferences.c
+++ b/src/dh-preferences.c
@@ -24,10 +24,10 @@
#include <string.h>
#include "dh-util.h"
#include "dh-preferences.h"
-#include "ige-conf.h"
#include "dh-base.h"
typedef struct {
+ GSettings *settings;
GtkWidget *dialog;
/* Fonts tab */
@@ -64,26 +64,6 @@ static void preferences_fonts_use_system_font_notify_cb (IgeConf *c
gpointer user_data);
static void preferences_connect_conf_listeners (void);
#endif
-static void preferences_fonts_get_font_names (gboolean use_system_fonts,
- gchar **variable,
- gchar **fixed);
-
-/* Bookshelf-tab related */
-static void preferences_bookshelf_tree_selection_toggled_cb (GtkCellRendererToggle *cell_renderer,
- gchar *path,
- gpointer user_data);
-static void preferences_bookshelf_populate_store (void);
-
-/* Common */
-static void preferences_close_cb (GtkButton *button,
- gpointer user_data);
-
-#define DH_CONF_PATH "/apps/devhelp"
-#define DH_CONF_USE_SYSTEM_FONTS DH_CONF_PATH "/ui/use_system_fonts"
-#define DH_CONF_VARIABLE_FONT DH_CONF_PATH "/ui/variable_font"
-#define DH_CONF_FIXED_FONT DH_CONF_PATH "/ui/fixed_font"
-#define DH_CONF_SYSTEM_VARIABLE_FONT "/desktop/gnome/interface/font_name"
-#define DH_CONF_SYSTEM_FIXED_FONT "/desktop/gnome/interface/monospace_font_name"
/* Book list store columns... */
#define LTCOLUMN_ENABLED 0
@@ -98,6 +78,7 @@ preferences_init (void)
if (!prefs) {
prefs = g_new0 (DhPreferences, 1);
prefs->book_manager = dh_base_get_book_manager (dh_base_get ());
+ prefs->settings = dh_util_get_ui_settings ();
}
}
@@ -116,6 +97,12 @@ preferences_close_cb (GtkButton *button, gpointer user_data)
prefs->booklist_treeview = NULL;
prefs->booklist_store = NULL;
+
+ if (GTK_WIDGET (button) == prefs->variable_font_button) {
+ g_settings_set (prefs->settings, "variable_font", "s", font_name);
+ } else {
+ g_settings_set (prefs->settings, "fixed_font", "s", font_name);
+ }
}
static void
@@ -124,17 +111,14 @@ preferences_fonts_font_set_cb (GtkFontButton *button,
{
DhPreferences *prefs = user_data;
const gchar *font_name;
- const gchar *key;
font_name = gtk_font_button_get_font_name (button);
if (GTK_WIDGET (button) == prefs->variable_font_button) {
- key = DH_CONF_VARIABLE_FONT;
+ g_settings_set (prefs->settings, "variable_font", font_name);
} else {
- key = DH_CONF_FIXED_FONT;
+ g_settings_set (prefs->settings, "fixed_font", font_name);
}
-
- ige_conf_set_string (ige_conf_get (), key, font_name);
}
static void
@@ -146,10 +130,7 @@ preferences_fonts_system_fonts_toggled_cb (GtkToggleButton *button,
active = gtk_toggle_button_get_active (button);
- ige_conf_set_bool (ige_conf_get (),
- DH_CONF_USE_SYSTEM_FONTS,
- active);
-
+ g_settings_set (prefs->settings, "use_system_fonts", "b", active);
gtk_widget_set_sensitive (prefs->fonts_table, !active);
}
@@ -254,97 +235,6 @@ preferences_connect_conf_listeners (void)
}
#endif
-/* FIXME: Use the functions in dh-util.c for this. */
-static void
-preferences_fonts_get_font_names (gboolean use_system_fonts,
- gchar **variable,
- gchar **fixed)
-{
- gchar *var_font_name, *fixed_font_name;
- IgeConf *conf;
-
- conf = ige_conf_get ();
-
- if (use_system_fonts) {
-#ifdef GDK_WINDOWING_QUARTZ
- var_font_name = g_strdup ("Lucida Grande 14");
- fixed_font_name = g_strdup ("Monaco 14");
-#else
- ige_conf_get_string (conf,
- DH_CONF_SYSTEM_VARIABLE_FONT,
- &var_font_name);
- ige_conf_get_string (conf,
- DH_CONF_SYSTEM_FIXED_FONT,
- &fixed_font_name);
-#endif
- } else {
- ige_conf_get_string (conf,
- DH_CONF_VARIABLE_FONT,
- &var_font_name);
- ige_conf_get_string (conf,
- DH_CONF_FIXED_FONT,
- &fixed_font_name);
- }
-
- *variable = var_font_name;
- *fixed = fixed_font_name;
-}
-
-static void
-preferences_bookshelf_tree_selection_toggled_cb (GtkCellRendererToggle *cell_renderer,
- gchar *path,
- gpointer user_data)
-{
- GtkTreeIter iter;
-
- if (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (prefs->booklist_store),
- &iter,
- path))
- {
- gpointer book = NULL;
- gboolean enabled;
-
- gtk_tree_model_get (GTK_TREE_MODEL (prefs->booklist_store),
- &iter,
- LTCOLUMN_BOOK, &book,
- LTCOLUMN_ENABLED, &enabled,
- -1);
-
- if (book) {
- /* Update book conf */
- dh_book_set_enabled (book, !enabled);
-
- gtk_list_store_set (prefs->booklist_store, &iter,
- LTCOLUMN_ENABLED, !enabled,
- -1);
-
- dh_book_manager_update (prefs->book_manager);
- }
- }
-}
-
-static void
-preferences_bookshelf_populate_store (void)
-{
- GList *l;
-
- for (l = dh_book_manager_get_books (prefs->book_manager);
- l;
- l = g_list_next (l)) {
- GtkTreeIter iter;
- DhBook *book;
-
- book = DH_BOOK (l->data);
-
- gtk_list_store_append (prefs->booklist_store, &iter);
- gtk_list_store_set (prefs->booklist_store, &iter,
- LTCOLUMN_ENABLED, dh_book_get_enabled (book),
- LTCOLUMN_TITLE, dh_book_get_title (book),
- LTCOLUMN_BOOK, book,
- -1);
- }
-}
-
void
dh_preferences_show_dialog (GtkWindow *parent)
{
@@ -387,14 +277,13 @@ dh_preferences_show_dialog (GtkWindow *parent)
"preferences_close_button", "clicked", preferences_close_cb,
NULL);
- ige_conf_get_bool (ige_conf_get (),
- DH_CONF_USE_SYSTEM_FONTS,
- &use_system_fonts);
+ g_settings_get (prefs->settings, "use_system_fonts", "b", &use_system_fonts);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs->system_fonts_button),
use_system_fonts);
gtk_widget_set_sensitive (prefs->fonts_table, !use_system_fonts);
- preferences_fonts_get_font_names (FALSE, &var_font_name, &fixed_font_name);
+ g_settings_get (prefs->settings, "variable_font", "s", &var_font_name);
+ g_settings_get (prefs->settings, "fixed_font", "s", &fixed_font_name);
if (var_font_name) {
gtk_font_button_set_font_name (GTK_FONT_BUTTON (prefs->variable_font_button),
diff --git a/src/dh-util.c b/src/dh-util.c
index 85a25d6..4070d9f 100644
--- a/src/dh-util.c
+++ b/src/dh-util.c
@@ -26,9 +26,13 @@
#ifdef GDK_WINDOWING_QUARTZ
#include <CoreFoundation/CoreFoundation.h>
#endif
-#include "ige-conf.h"
#include "dh-util.h"
+#ifndef GDK_WINDOWING_QUARTZ
+static GSettings *desktop_settings;
+#endif
+static GSettings *state_settings;
+static GSettings *ui_settings;
static GList *views;
static GtkBuilder *
@@ -222,15 +226,53 @@ dh_util_build_data_filename (const gchar *first_part,
return ret;
}
+static void font_notify_cb (void);
+static void
+dh_util_settings_init (void)
+{
+ GSettings *toplevel;
+
+ /* just once */
+ if (ui_settings != NULL) {
+ return;
+ }
+
+ toplevel = g_settings_new ("org.gnome.Devhelp");
+ ui_settings = g_settings_get_child (toplevel, "ui");
+ g_signal_connect (ui_settings, "changed", font_notify_cb, NULL);
+ state_settings = g_settings_get_child (toplevel, "state");
+ g_object_unref (toplevel);
+
+#ifndef GDK_WINDOWING_QUARTZ
+ desktop_settings = g_settings_new ("org.gnome.Desktop.Interface");
+ g_signal_connect (desktop_settings, "changed", font_notify_cb, NULL);
+#endif
+}
+
+static GSettings *
+util_get_settings_for_widget (const gchar *component,
+ const gchar *widget)
+{
+ GSettings *component_settings, *widget_settings;
+
+ dh_util_settings_init ();
+
+ component_settings = g_settings_get_child (state_settings, component);
+ widget_settings = g_settings_get_child (component_settings, widget);
+ g_object_unref (component_settings);
+
+ return widget_settings;
+}
+
typedef struct {
- gchar *name;
+ GSettings *settings;
guint timeout_id;
} DhUtilStateItem;
static void
util_state_item_free (DhUtilStateItem *item)
{
- g_free (item->name);
+ g_object_unref (item->settings);
if (item->timeout_id) {
g_source_remove (item->timeout_id);
}
@@ -238,13 +280,13 @@ util_state_item_free (DhUtilStateItem *item)
}
static void
-util_state_setup_widget (GtkWidget *widget,
- const gchar *name)
+util_state_setup_widget (GtkWidget *widget,
+ GSettings *settings)
{
DhUtilStateItem *item;
item = g_slice_new0 (DhUtilStateItem);
- item->name = g_strdup (name);
+ item->settings = g_object_ref (settings);
g_object_set_data_full (G_OBJECT (widget),
"dh-util-state",
@@ -252,13 +294,6 @@ util_state_setup_widget (GtkWidget *widget,
(GDestroyNotify) util_state_item_free);
}
-static gchar *
-util_state_get_key (const gchar *name,
- const gchar *key)
-{
- return g_strdup_printf ("/apps/devhelp/state/%s/%s", name, key);
-}
-
static void
util_state_schedule_save (GtkWidget *widget,
GSourceFunc func)
@@ -277,10 +312,9 @@ util_state_schedule_save (GtkWidget *widget,
}
static void
-util_state_save_window (GtkWindow *window,
- const gchar *name)
+util_state_save_window (GtkWindow *window,
+ GSettings *settings)
{
- gchar *key;
GdkWindowState state;
gboolean maximized;
gint width, height;
@@ -291,15 +325,14 @@ util_state_save_window (GtkWindow *window,
#else
state = gdk_window_get_state (GTK_WIDGET (window)->window);
#endif
+
if (state & GDK_WINDOW_STATE_MAXIMIZED) {
maximized = TRUE;
} else {
maximized = FALSE;
}
- key = util_state_get_key (name, "maximized");
- ige_conf_set_bool (ige_conf_get (), key, maximized);
- g_free (key);
+ g_settings_set (settings, "maximized", "b", maximized);
/* If maximized don't save the size and position. */
if (maximized) {
@@ -307,52 +340,25 @@ util_state_save_window (GtkWindow *window,
}
gtk_window_get_size (GTK_WINDOW (window), &width, &height);
-
- key = util_state_get_key (name, "width");
- ige_conf_set_int (ige_conf_get (), key, width);
- g_free (key);
-
- key = util_state_get_key (name, "height");
- ige_conf_set_int (ige_conf_get (), key, height);
- g_free (key);
+ g_settings_set (settings, "size", "(ii)", width, height);
gtk_window_get_position (GTK_WINDOW (window), &x, &y);
-
- key = util_state_get_key (name, "x_position");
- ige_conf_set_int (ige_conf_get (), key, x);
- g_free (key);
-
- key = util_state_get_key (name, "y_position");
- ige_conf_set_int (ige_conf_get (), key, y);
- g_free (key);
+ g_settings_set (settings, "position", "(ii)", x, y);
}
static void
util_state_restore_window (GtkWindow *window,
- const gchar *name)
+ GSettings *settings)
{
- gchar *key;
gboolean maximized;
gint width, height;
gint x, y;
GdkScreen *screen;
gint max_width, max_height;
- key = util_state_get_key (name, "width");
- ige_conf_get_int (ige_conf_get (), key, &width);
- g_free (key);
-
- key = util_state_get_key (name, "height");
- ige_conf_get_int (ige_conf_get (), key, &height);
- g_free (key);
-
- key = util_state_get_key (name, "x_position");
- ige_conf_get_int (ige_conf_get (), key, &x);
- g_free (key);
-
- key = util_state_get_key (name, "y_position");
- ige_conf_get_int (ige_conf_get (), key, &y);
- g_free (key);
+ g_settings_get (settings, "maximized", "b", &maximized);
+ g_settings_get (settings, "size", "(ii)", &width, &height);
+ g_settings_get (settings, "position", "(ii)", &x, &y);
if (width > 1 && height > 1) {
screen = gtk_widget_get_screen (GTK_WIDGET (window));
@@ -370,10 +376,6 @@ util_state_restore_window (GtkWindow *window,
gtk_window_move (window, x, y);
- key = util_state_get_key (name, "maximized");
- ige_conf_get_bool (ige_conf_get (), key, &maximized);
- g_free (key);
-
if (maximized) {
gtk_window_maximize (window);
}
@@ -387,7 +389,7 @@ util_state_window_timeout_cb (gpointer window)
item = g_object_get_data (window, "dh-util-state");
if (item) {
item->timeout_id = 0;
- util_state_save_window (window, item->name);
+ util_state_save_window (window, item->settings);
}
return FALSE;
@@ -409,15 +411,10 @@ util_state_paned_timeout_cb (gpointer paned)
item = g_object_get_data (paned, "dh-util-state");
if (item) {
- gchar *key;
-
item->timeout_id = 0;
- key = util_state_get_key (item->name, "position");
- ige_conf_set_int (ige_conf_get (),
- key,
- gtk_paned_get_position (paned));
- g_free (key);
+ g_settings_set (item->settings, "position", "i",
+ gtk_paned_get_position (paned));
}
return FALSE;
@@ -433,31 +430,33 @@ util_state_paned_changed_cb (GtkWidget *paned,
void
dh_util_state_manage_window (GtkWindow *window,
- const gchar *name)
+ const gchar *component)
{
- util_state_setup_widget (GTK_WIDGET (window), name);
+ GSettings *settings;
+
+ settings = util_get_settings_for_widget (component, "window");
+
+ util_state_setup_widget (GTK_WIDGET (window), settings);
g_signal_connect (window, "configure-event",
G_CALLBACK (util_state_window_configure_event_cb),
NULL);
- util_state_restore_window (window, name);
+ util_state_restore_window (window, settings);
}
void
dh_util_state_manage_paned (GtkPaned *paned,
- const gchar *name)
+ const gchar *component)
{
- gchar *key;
- gint position;
+ GSettings *settings;
+ gint position;
- util_state_setup_widget (GTK_WIDGET (paned), name);
+ settings = util_get_settings_for_widget (component, "paned");
- key = util_state_get_key (name, "position");
- if (ige_conf_get_int (ige_conf_get (), key, &position)) {
- gtk_paned_set_position (paned, position);
- }
- g_free (key);
+ util_state_setup_widget (GTK_WIDGET (paned), settings);
+ g_settings_get (settings, "position", "i", &position);
+ gtk_paned_set_position (paned, position);
g_signal_connect (paned, "notify::position",
G_CALLBACK (util_state_paned_changed_cb),
@@ -504,11 +503,7 @@ util_state_notebook_timeout_cb (gpointer notebook)
gtk_notebook_get_current_page (notebook));
page_name = dh_util_state_get_notebook_page_name (page);
if (page_name) {
- gchar *key;
-
- key = util_state_get_key (item->name, "selected_tab");
- ige_conf_set_string (ige_conf_get (), key, page_name);
- g_free (key);
+ g_settings_set (item->settings, "selected_tab", "s", page_name);
}
}
@@ -543,20 +538,17 @@ dh_util_state_get_notebook_page_name (GtkWidget *page)
void
dh_util_state_manage_notebook (GtkNotebook *notebook,
- const gchar *name,
- const gchar *default_tab)
+ const gchar *component)
{
- gchar *key;
+ GSettings *settings;
gchar *tab;
gint i;
- util_state_setup_widget (GTK_WIDGET (notebook), name);
+ settings = util_get_settings_for_widget (component,
+ "search_notebook");
- key = util_state_get_key (name, "selected_tab");
- if (!ige_conf_get_string (ige_conf_get (), key, &tab)) {
- tab = g_strdup (default_tab);
- }
- g_free (key);
+ util_state_setup_widget (GTK_WIDGET (notebook), settings);
+ g_settings_get (settings, "selected_tab", "s", &tab);
for (i = 0; i < gtk_notebook_get_n_pages (notebook); i++) {
GtkWidget *page;
@@ -604,35 +596,23 @@ split_font_string (const gchar *name_and_size,
return retval;
}
-#define DH_CONF_PATH "/apps/devhelp"
-#define DH_CONF_USE_SYSTEM_FONTS DH_CONF_PATH "/ui/use_system_fonts"
-#define DH_CONF_VARIABLE_FONT DH_CONF_PATH "/ui/variable_font"
-#define DH_CONF_FIXED_FONT DH_CONF_PATH "/ui/fixed_font"
-#define DH_CONF_SYSTEM_VARIABLE_FONT "/desktop/gnome/interface/font_name"
-#define DH_CONF_SYSTEM_FIXED_FONT "/desktop/gnome/interface/monospace_font_name"
-
-void
+static void
dh_util_font_get_variable (gchar **name,
gdouble *size,
gboolean use_system_fonts)
{
- IgeConf *conf;
gchar *name_and_size;
- conf = ige_conf_get ();
-
if (use_system_fonts) {
#ifdef GDK_WINDOWING_QUARTZ
name_and_size = g_strdup ("Lucida Grande 14");
#else
- ige_conf_get_string (conf,
- DH_CONF_SYSTEM_VARIABLE_FONT,
- &name_and_size);
+ g_settings_get (desktop_settings,
+ "font_name", "s", &name_and_size);
#endif
} else {
- ige_conf_get_string (conf,
- DH_CONF_VARIABLE_FONT,
- &name_and_size);
+ g_settings_get (ui_settings,
+ "variable_font", "s", &name_and_size);
}
if (!split_font_string (name_and_size, name, size)) {
@@ -643,28 +623,22 @@ dh_util_font_get_variable (gchar **name,
g_free (name_and_size);
}
-void
+static void
dh_util_font_get_fixed (gchar **name,
gdouble *size,
gboolean use_system_fonts)
{
- IgeConf *conf;
gchar *name_and_size;
- conf = ige_conf_get ();
-
if (use_system_fonts) {
#ifdef GDK_WINDOWING_QUARTZ
name_and_size = g_strdup ("Monaco 14");
#else
- ige_conf_get_string (conf,
- DH_CONF_SYSTEM_FIXED_FONT,
- &name_and_size);
+ g_settings_get (desktop_settings,
+ "monospace_font_name", "s", &name_and_size);
#endif
} else {
- ige_conf_get_string (conf,
- DH_CONF_FIXED_FONT,
- &name_and_size);
+ g_settings_get (ui_settings, "fixed_font", "s", &name_and_size);
}
if (!split_font_string (name_and_size, name, size)) {
@@ -685,7 +659,6 @@ view_destroy_cb (GtkWidget *view,
static void
view_setup_fonts (WebKitWebView *view)
{
- IgeConf *conf;
WebKitWebSettings *settings;
gboolean use_system_fonts;
gchar *variable_name;
@@ -693,13 +666,9 @@ view_setup_fonts (WebKitWebView *view)
gchar *fixed_name;
gdouble fixed_size;
- conf = ige_conf_get ();
-
settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (view));
- ige_conf_get_bool (conf,
- DH_CONF_USE_SYSTEM_FONTS,
- &use_system_fonts);
+ g_settings_get (ui_settings, "use_system_fonts", "b", &use_system_fonts);
dh_util_font_get_variable (&variable_name, &variable_size,
use_system_fonts);
@@ -719,9 +688,7 @@ view_setup_fonts (WebKitWebView *view)
}
static void
-font_notify_cb (IgeConf *conf,
- const gchar *path,
- gpointer user_data)
+font_notify_cb (void)
{
GList *l;
@@ -733,36 +700,7 @@ font_notify_cb (IgeConf *conf,
void
dh_util_font_add_web_view (WebKitWebView *view)
{
- static gboolean setup;
-
- if (!setup) {
- IgeConf *conf;
-
- conf = ige_conf_get ();
-
- ige_conf_notify_add (conf,
- DH_CONF_USE_SYSTEM_FONTS,
- font_notify_cb,
- NULL);
- ige_conf_notify_add (conf,
- DH_CONF_SYSTEM_VARIABLE_FONT,
- font_notify_cb,
- NULL);
- ige_conf_notify_add (conf,
- DH_CONF_SYSTEM_FIXED_FONT,
- font_notify_cb,
- NULL);
- ige_conf_notify_add (conf,
- DH_CONF_VARIABLE_FONT,
- font_notify_cb,
- NULL);
- ige_conf_notify_add (conf,
- DH_CONF_FIXED_FONT,
- font_notify_cb,
- NULL);
-
- setup = TRUE;
- }
+ dh_util_settings_init ();
views = g_list_prepend (views, view);
@@ -810,3 +748,10 @@ dh_util_cmp_book (DhLink *a, DhLink *b)
return rc;
}
+GSettings *
+dh_util_get_ui_settings (void)
+{
+ dh_util_settings_init ();
+
+ return g_object_ref (ui_settings);
+}
diff --git a/src/dh-util.h b/src/dh-util.h
index 5e3de88..f6e0f8d 100644
--- a/src/dh-util.h
+++ b/src/dh-util.h
@@ -40,28 +40,23 @@ void dh_util_builder_connect (GtkBuilder *gui,
gchar * dh_util_build_data_filename (const gchar *first_part,
...);
void dh_util_state_manage_window (GtkWindow *window,
- const gchar *name);
+ const gchar *component);
void dh_util_state_manage_paned (GtkPaned *paned,
- const gchar *name);
+ const gchar *component);
void dh_util_state_manage_notebook (GtkNotebook *notebook,
- const gchar *name,
- const gchar *default_tab);
+ const gchar *component);
void dh_util_state_set_notebook_page_name (GtkWidget *page,
const gchar *page_name);
const gchar *dh_util_state_get_notebook_page_name (GtkWidget *page);
GSList * dh_util_state_load_disabled_books (void);
void dh_util_state_store_disabled_books (GSList *disabled_books);
-void dh_util_font_get_variable (gchar **name,
- gdouble *size,
- gboolean use_system_font);
-void dh_util_font_get_fixed (gchar **name,
- gdouble *size,
- gboolean use_system_font);
void dh_util_font_add_web_view (WebKitWebView *view);
gint dh_util_cmp_book (DhLink *a,
DhLink *b);
+GSettings * dh_util_get_ui_settings (void);
+
G_END_DECLS
#endif /* __DH_UTIL_H__ */
diff --git a/src/dh-window.c b/src/dh-window.c
index 2fcec5f..37e11b9 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -46,7 +46,6 @@
#include "dh-marshal.h"
#include "dh-enum-types.h"
#include "eggfindbar.h"
-#include "ige-conf.h"
#define FULLSCREEN_ANIMATION_SPEED 4
@@ -1942,11 +1941,10 @@ dh_window_new (DhBase *base)
gtk_window_set_icon_name (GTK_WINDOW (window), "devhelp");
- dh_util_state_manage_window (GTK_WINDOW (window), "main/window");
- dh_util_state_manage_paned (GTK_PANED (priv->hpaned), "main/paned");
+ dh_util_state_manage_window (GTK_WINDOW (window), "main");
+ dh_util_state_manage_paned (GTK_PANED (priv->hpaned), "main");
dh_util_state_manage_notebook (GTK_NOTEBOOK (priv->control_notebook),
- "main/search_notebook",
- "content");
+ "main");
return GTK_WIDGET (window);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]