Add GSettings support (GConf is going away).
* configure.in (gsettings): New option and check for GSettings. * src/Makefile.in (SETTINGS_CFLAGS, SETTINGS_LIBS): Renamed from GCONF_CFLAGS/LIBS. * src/xsettings.c: Include glib.h if HAVE_GSETTINGS. Let HAVE_GSETTINGS override HAVE_GCONF. (store_monospaced_changed): New function. (EMACS_SETTINGS): A new type derived from GObject to handle GSettings notifications. (emacs_settings_constructor, emacs_settings_get_property) (emacs_settings_set_property, emacs_settings_class_init): New functions. (gsettings_client, gsettings_obj): New variables. (GSETTINGS_SCHEMA): New define. (something_changedCB): Call store_monospaced_changed. (init_gsettings): New function. (xsettings_initialize): Call init_gsettings. (syms_of_xsettings): Initialize gsettings_client, gsettings_obj to NULL.
This commit is contained in:
parent
656e1aab13
commit
9851bfc58d
5 changed files with 275 additions and 31 deletions
|
@ -1,3 +1,7 @@
|
|||
2011-06-30 Jan Djärv <jan.h.d@swipnet.se>
|
||||
|
||||
* configure.in (gsettings): New option and check for GSettings.
|
||||
|
||||
2011-06-29 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* configure.in: Try to test for the required crt*.o files.
|
||||
|
|
31
configure.in
31
configure.in
|
@ -172,6 +172,7 @@ OPTION_DEFAULT_OFF([ns],[use NeXTstep (Cocoa or GNUstep) windowing system])
|
|||
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])
|
||||
|
||||
|
@ -1981,18 +1982,43 @@ if test "${with_dbus}" = "yes"; then
|
|||
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=
|
||||
|
@ -3674,6 +3700,7 @@ echo " Does Emacs use imagemagick? ${HAVE_IMAGEMAGI
|
|||
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}"
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
2011-06-30 Jan Djärv <jan.h.d@swipnet.se>
|
||||
|
||||
* xsettings.c: Include glib.h if HAVE_GSETTINGS.
|
||||
Let HAVE_GSETTINGS override HAVE_GCONF.
|
||||
(store_monospaced_changed): New function.
|
||||
(EMACS_SETTINGS): A new type derived from GObject to handle
|
||||
GSettings notifications.
|
||||
(emacs_settings_constructor, emacs_settings_get_property)
|
||||
(emacs_settings_set_property, emacs_settings_class_init):
|
||||
New functions.
|
||||
(gsettings_client, gsettings_obj): New variables.
|
||||
(GSETTINGS_SCHEMA): New define.
|
||||
(something_changedCB): Call store_monospaced_changed.
|
||||
(init_gsettings): New function.
|
||||
(xsettings_initialize): Call init_gsettings.
|
||||
(syms_of_xsettings): Initialize gsettings_client, gsettings_obj
|
||||
to NULL.
|
||||
|
||||
* Makefile.in (SETTINGS_CFLAGS, SETTINGS_LIBS): Renamed from
|
||||
GCONF_CFLAGS/LIBS.
|
||||
|
||||
2011-06-29 Martin Rudalics <rudalics@gmx.at>
|
||||
|
||||
* window.c (resize_root_window, grow_mini_window)
|
||||
|
|
|
@ -152,8 +152,8 @@ DBUS_LIBS = @DBUS_LIBS@
|
|||
## dbusbind.o if HAVE_DBUS, else empty.
|
||||
DBUS_OBJ = @DBUS_OBJ@
|
||||
|
||||
GCONF_CFLAGS = @GCONF_CFLAGS@
|
||||
GCONF_LIBS = @GCONF_LIBS@
|
||||
SETTINGS_CFLAGS = @SETTINGS_CFLAGS@
|
||||
SETTINGS_LIBS = @SETTINGS_CFLAGS@
|
||||
|
||||
## gtkutil.o if USE_GTK, else empty.
|
||||
GTK_OBJ=@GTK_OBJ@
|
||||
|
@ -305,7 +305,7 @@ ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I$(srcdir) \
|
|||
$(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \
|
||||
$(C_SWITCH_X_SYSTEM) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \
|
||||
$(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \
|
||||
$(GCONF_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \
|
||||
$(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \
|
||||
$(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) $(PROFILING_CFLAGS) \
|
||||
$(LIBGNUTLS_CFLAGS) \
|
||||
$(C_WARNINGS_SWITCH) $(CFLAGS)
|
||||
|
@ -381,7 +381,7 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \
|
|||
LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \
|
||||
$(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(DBUS_LIBS) \
|
||||
$(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
|
||||
$(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(GCONF_LIBS) $(LIBSELINUX_LIBS) \
|
||||
$(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
|
||||
$(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
|
||||
$(LIBGNUTLS_LIBS) \
|
||||
$(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC)
|
||||
|
|
242
src/xsettings.c
242
src/xsettings.c
|
@ -34,9 +34,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
|||
|
||||
#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
|
||||
|
@ -48,11 +54,6 @@ static Lisp_Object Qmonospace_font_name, Qfont_name, Qfont_render,
|
|||
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)
|
||||
{
|
||||
|
@ -64,6 +65,159 @@ 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"
|
||||
|
||||
|
@ -91,10 +245,15 @@ struct xsettings
|
|||
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. */
|
||||
|
@ -116,23 +275,12 @@ something_changedCB (GConfClient *client,
|
|||
|
||||
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
|
||||
|
||||
|
@ -631,10 +779,48 @@ xft_settings_event (struct x_display_info *dpyinfo, XEvent *event)
|
|||
}
|
||||
|
||||
|
||||
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
|
||||
|
@ -662,7 +848,7 @@ init_gconf (void)
|
|||
SYSTEM_MONO_FONT,
|
||||
something_changedCB,
|
||||
NULL, NULL, NULL);
|
||||
#endif /* HAVE_GCONF && HAVE_XFT */
|
||||
#endif /* HAVE_GCONF && HAVE_XFT && ! HAVE_GSETTINGS */
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -687,6 +873,7 @@ void
|
|||
xsettings_initialize (struct x_display_info *dpyinfo)
|
||||
{
|
||||
if (first_dpyinfo == NULL) first_dpyinfo = dpyinfo;
|
||||
init_gsettings ();
|
||||
init_gconf ();
|
||||
init_xsettings (dpyinfo);
|
||||
}
|
||||
|
@ -746,8 +933,13 @@ syms_of_xsettings (void)
|
|||
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");
|
||||
|
@ -769,7 +961,7 @@ If this variable is nil, Emacs ignores system font changes. */);
|
|||
|
||||
#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
|
||||
|
|
Loading…
Add table
Reference in a new issue