OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console])
OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support])
OPTION_DEFAULT_ON([gconf],[don't compile with GConf support])
+OPTION_DEFAULT_ON([gsettings],[don't compile with GSettings support])
OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support])
OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support])
fi
AC_SUBST(DBUS_OBJ)
+dnl GSettings has been tested under GNU/Linux only.
+HAVE_GSETTINGS=no
+if test "${HAVE_X11}" = "yes" && test "${with_gsettings}" = "yes"; then
+ PKG_CHECK_MODULES(GSETTINGS, glib-2.0 >= 2.26, HAVE_GSETTINGS=yes, HAVE_GSETTINGS=no)
+ if test "$HAVE_GSETTINGS" = yes; then
+ AC_DEFINE(HAVE_GSETTINGS, 1, [Define to 1 if using GSettings.])
+ SETTINGS_CFLAGS="$GSETTINGS_CFLAGS"
+ SETTINGS_LIBS="$GSETTINGS_LIBS"
+ fi
+fi
+
dnl GConf has been tested under GNU/Linux only.
dnl The version is really arbitrary, it is about the same age as Gtk+ 2.6.
HAVE_GCONF=no
-if test "${HAVE_X11}" = "yes" && test "${with_gconf}" = "yes"; then
+if test "${HAVE_GSETTINGS}" = "no" && "${HAVE_X11}" = "yes" && test "${with_gconf}" = "yes"; then
PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.13, HAVE_GCONF=yes, HAVE_GCONF=no)
if test "$HAVE_GCONF" = yes; then
AC_DEFINE(HAVE_GCONF, 1, [Define to 1 if using GConf.])
dnl Newer GConf doesn't link with g_objects, so this is not defined.
- AC_CHECK_FUNCS([g_type_init])
+ SETTINGS_CFLAGS="$GSETTINGS_CFLAGS"
+ SETTINGS_LIBS="$GSETTINGS_LIBS"
fi
fi
+if test "$HAVE_GSETTINGS" = "yes" || "$HAVE_GCONF" = yes; then
+ SAVE_CFLAGS="$CFLAGS"
+ SAVE_LDFLAGS="$LDFLAGS"
+ CFLAGS="$SETTINGS_CFLAGS $CFLAGS"
+ LDFLAGS="$SETTINGS_LIBS $LDFLAGS"
+ AC_CHECK_FUNCS([g_type_init])
+ CFLAGS="$SAVE_CFLAGS"
+ LDFLAGS="$SAVE_LDFLAGS"
+fi
+AC_SUBST(SETTINGS_CFLAGS)
+AC_SUBST(SETTINGS_LIBS)
+
+
dnl SELinux is available for GNU/Linux only.
HAVE_LIBSELINUX=no
LIBSELINUX_LIBS=
echo " Does Emacs use -lgpm? ${HAVE_GPM}"
echo " Does Emacs use -ldbus? ${HAVE_DBUS}"
echo " Does Emacs use -lgconf? ${HAVE_GCONF}"
+echo " Does Emacs use GSettings? ${HAVE_GSETTINGS}"
echo " Does Emacs use -lselinux? ${HAVE_LIBSELINUX}"
echo " Does Emacs use -lgnutls (2.6.x or higher)? ${HAVE_GNUTLS}"
echo " Does Emacs use -lxml2? ${HAVE_LIBXML2}"
#include <X11/Xproto.h>
+#define HAVE_GSETTINGS
+#ifdef HAVE_GSETTINGS
+#include <glib.h>
+#else
#ifdef HAVE_GCONF
#include <gconf/gconf-client.h>
#endif
+#endif
+
#ifdef HAVE_XFT
#include <X11/Xft/Xft.h>
#endif
Qtool_bar_style;
static Lisp_Object current_tool_bar_style;
-#ifdef HAVE_GCONF
-static GConfClient *gconf_client;
-#endif
-
-
static void
store_config_changed_event (Lisp_Object arg, Lisp_Object display_name)
{
kbd_buffer_store_event (&event);
}
+static void
+store_monospaced_changed (void)
+{
+ if (first_dpyinfo != NULL)
+ {
+ /* Check if display still open */
+ struct x_display_info *dpyinfo;
+ int found = 0;
+ for (dpyinfo = x_display_list; !found && dpyinfo; dpyinfo = dpyinfo->next)
+ found = dpyinfo == first_dpyinfo;
+
+ if (found && use_system_font)
+ store_config_changed_event (Qmonospace_font_name,
+ XCAR (first_dpyinfo->name_list_element));
+ }
+}
+
+
+#ifdef HAVE_GSETTINGS
+
+#define EMACS_TYPE_SETTINGS (emacs_settings_get_type ())
+#define EMACS_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMACS_TYPE_SETTINGS, EmacsSettings))
+#define EMACS_IS_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMACS_TYPE_SETTINGS))
+#define EMACS_SETTINGS_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), EMACS_TYPE_SETTINGS, EmacsSettingsClass))
+#define EMACS_IS_SETTINGS_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), EMACS_TYPE_SETTINGS))
+#define EMACS_SETTINGS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), EMACS_TYPE_SETTINGS, EmacsSettingsClass))
+
+typedef struct _EmacsSettings EmacsSettings;
+typedef struct _EmacsSettingsClass EmacsSettingsClass;
+
+struct _EmacsSettings
+{
+ GObject parent_instance;
+};
+
+struct _EmacsSettingsClass
+{
+ GObjectClass parent_class;
+};
+
+/* will create emacs_settings_get_type and set emacs_settings_parent_class */
+G_DEFINE_TYPE (EmacsSettings, emacs_settings, G_TYPE_OBJECT);
+
+static GObject *
+emacs_settings_constructor (GType gtype,
+ guint n_properties,
+ GObjectConstructParam *properties)
+{
+ GObject *obj;
+
+ /* Always chain up to the parent constructor */
+ obj = G_OBJECT_CLASS (emacs_settings_parent_class)
+ ->constructor (gtype, n_properties, properties);
+
+ /* update the object state depending on constructor properties */
+
+ return obj;
+}
+
+enum { PROP_MONO = 1, PROP_FONT };
+
+static void
+emacs_settings_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ case PROP_MONO:
+ g_value_set_string (value, current_mono_font);
+ break;
+ case PROP_FONT:
+ g_value_set_string (value, current_font);
+ break;
+ }
+}
+
+static void
+emacs_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ const char *newfont;
+ switch (property_id)
+ {
+ case PROP_MONO:
+ xfree (current_mono_font);
+ newfont = g_value_get_string (value);
+ if (current_mono_font != NULL && strcmp (newfont, current_mono_font) == 0)
+ return; /* No change. */
+
+ current_mono_font = xstrdup (newfont);
+ store_monospaced_changed ();
+ break;
+
+ case PROP_FONT:
+ xfree (current_font);
+ current_font = xstrdup (g_value_get_string (value));
+ break;
+ }
+}
+
+static void
+emacs_settings_class_init (EmacsSettingsClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->constructor = emacs_settings_constructor;
+ gobject_class->set_property = emacs_settings_set_property;
+ gobject_class->get_property = emacs_settings_get_property;
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_MONO,
+ g_param_spec_string ("monospace-font",
+ "Monospace-font",
+ "System monospace font",
+ "",
+ G_PARAM_READWRITE));
+ g_object_class_install_property
+ (gobject_class,
+ PROP_FONT,
+ g_param_spec_string ("font",
+ "Font",
+ "System font",
+ "",
+ G_PARAM_READWRITE));
+
+}
+
+static void
+emacs_settings_init (EmacsSettings *self)
+{
+}
+
+
+static GSettings *gsettings_client;
+static EmacsSettings *gsettings_obj;
+
+#else
+#ifdef HAVE_GCONF
+static GConfClient *gconf_client;
+#endif
+#endif
+
+
#define XSETTINGS_FONT_NAME "Gtk/FontName"
#define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle"
unsigned seen;
};
-#ifdef HAVE_GCONF
+#ifdef HAVE_GSETTINGS
+#define GSETTINGS_SCHEMA "org.gnome.desktop.interface"
+#define SYSTEM_MONO_FONT "monospace-font-name"
+#define SYSTEM_FONT "font-name"
-#define SYSTEM_MONO_FONT "/desktop/gnome/interface/monospace_font_name"
-#define SYSTEM_FONT "/desktop/gnome/interface/font_name"
+#else
+#ifdef HAVE_GCONF
+#define SYSTEM_MONO_FONT "/desktop/gnome/interface/monospace_font_name"
+#define SYSTEM_FONT "/desktop/gnome/interface/font_name"
/* Callback called when something changed in GConf that we care about,
that is SYSTEM_MONO_FONT. */
xfree (current_mono_font);
current_mono_font = xstrdup (value);
- }
-
-
- if (first_dpyinfo != NULL)
- {
- /* Check if display still open */
- struct x_display_info *dpyinfo;
- int found = 0;
- for (dpyinfo = x_display_list; !found && dpyinfo; dpyinfo = dpyinfo->next)
- found = dpyinfo == first_dpyinfo;
-
- if (found && use_system_font)
- store_config_changed_event (Qmonospace_font_name,
- XCAR (first_dpyinfo->name_list_element));
+ store_monospaced_changed ();
}
}
+
#endif /* HAVE_GCONF */
+#endif /* ! HAVE_GSETTINGS */
#ifdef HAVE_XFT
}
+static void
+init_gsettings (void)
+{
+#ifdef HAVE_GSETTINGS
+ GVariant *val;
+#ifdef HAVE_G_TYPE_INIT
+ g_type_init ();
+#endif
+
+ gsettings_client = g_settings_new (GSETTINGS_SCHEMA);
+ if (!gsettings_client) return;
+ g_object_ref_sink (G_OBJECT (gsettings_client));
+
+ gsettings_obj = g_object_new (EMACS_TYPE_SETTINGS, NULL);
+ if (!gsettings_obj)
+ {
+ g_object_unref (G_OBJECT (gsettings_client));
+ return;
+ }
+ g_object_ref_sink (G_OBJECT (gsettings_obj));
+
+ val = g_settings_get_value (gsettings_client, SYSTEM_MONO_FONT);
+ if (val)
+ {
+ g_variant_ref_sink (val);
+ if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))
+ current_mono_font = xstrdup (g_variant_get_string (val, NULL));
+ g_variant_unref (val);
+ }
+
+ g_settings_bind (gsettings_client, SYSTEM_MONO_FONT, gsettings_obj,
+ "monospace-font", G_SETTINGS_BIND_GET);
+ g_settings_bind (gsettings_client, SYSTEM_FONT, gsettings_obj,
+ "font", G_SETTINGS_BIND_GET);
+#endif /* HAVE_GSETTINGS */
+}
+
+
static void
init_gconf (void)
{
-#if defined (HAVE_GCONF) && defined (HAVE_XFT)
+#if defined (HAVE_GCONF) && defined (HAVE_XFT) && ! defined (HAVE_GSETTINGS)
char *s;
#ifdef HAVE_G_TYPE_INIT
SYSTEM_MONO_FONT,
something_changedCB,
NULL, NULL, NULL);
-#endif /* HAVE_GCONF && HAVE_XFT */
+#endif /* HAVE_GCONF && HAVE_XFT && ! HAVE_GSETTINGS */
}
static void
xsettings_initialize (struct x_display_info *dpyinfo)
{
if (first_dpyinfo == NULL) first_dpyinfo = dpyinfo;
+ init_gsettings ();
init_gconf ();
init_xsettings (dpyinfo);
}
current_mono_font = NULL;
current_font = NULL;
first_dpyinfo = NULL;
+#ifdef HAVE_GSETTINGS
+ gsettings_client = NULL;
+ gsettings_obj = NULL;
+#else
#ifdef HAVE_GCONF
gconf_client = NULL;
+#endif
#endif
DEFSYM (Qmonospace_font_name, "monospace-font-name");
#ifdef HAVE_XFT
Fprovide (intern_c_string ("font-render-setting"), Qnil);
-#ifdef HAVE_GCONF
+#if defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
Fprovide (intern_c_string ("system-font-setting"), Qnil);
#endif
#endif