diff options
| author | Jan Djärv | 2011-06-30 16:00:26 +0200 |
|---|---|---|
| committer | Jan Djärv | 2011-06-30 16:00:26 +0200 |
| commit | 9851bfc58dcf38d05e469112790c514c3fd6fbf7 (patch) | |
| tree | 1931ced33d357c5100d1ce73a3e0a07e28eb7b98 | |
| parent | 656e1aab13d416dc06ca1138997e6396317321bc (diff) | |
| download | emacs-9851bfc58dcf38d05e469112790c514c3fd6fbf7.tar.gz emacs-9851bfc58dcf38d05e469112790c514c3fd6fbf7.zip | |
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.
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | configure.in | 31 | ||||
| -rw-r--r-- | src/ChangeLog | 21 | ||||
| -rw-r--r-- | src/Makefile.in | 8 | ||||
| -rw-r--r-- | src/xsettings.c | 242 |
5 files changed, 275 insertions, 31 deletions
| @@ -1,3 +1,7 @@ | |||
| 1 | 2011-06-30 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * configure.in (gsettings): New option and check for GSettings. | ||
| 4 | |||
| 1 | 2011-06-29 Glenn Morris <rgm@gnu.org> | 5 | 2011-06-29 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * configure.in: Try to test for the required crt*.o files. | 7 | * configure.in: Try to test for the required crt*.o files. |
diff --git a/configure.in b/configure.in index d7e4efe51ed..ee091f3e2bc 100644 --- a/configure.in +++ b/configure.in | |||
| @@ -172,6 +172,7 @@ OPTION_DEFAULT_OFF([ns],[use NeXTstep (Cocoa or GNUstep) windowing system]) | |||
| 172 | OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console]) | 172 | OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console]) |
| 173 | OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support]) | 173 | OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support]) |
| 174 | OPTION_DEFAULT_ON([gconf],[don't compile with GConf support]) | 174 | OPTION_DEFAULT_ON([gconf],[don't compile with GConf support]) |
| 175 | OPTION_DEFAULT_ON([gsettings],[don't compile with GSettings support]) | ||
| 175 | OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support]) | 176 | OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support]) |
| 176 | OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support]) | 177 | OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support]) |
| 177 | 178 | ||
| @@ -1981,18 +1982,43 @@ if test "${with_dbus}" = "yes"; then | |||
| 1981 | fi | 1982 | fi |
| 1982 | AC_SUBST(DBUS_OBJ) | 1983 | AC_SUBST(DBUS_OBJ) |
| 1983 | 1984 | ||
| 1985 | dnl GSettings has been tested under GNU/Linux only. | ||
| 1986 | HAVE_GSETTINGS=no | ||
| 1987 | if test "${HAVE_X11}" = "yes" && test "${with_gsettings}" = "yes"; then | ||
| 1988 | PKG_CHECK_MODULES(GSETTINGS, glib-2.0 >= 2.26, HAVE_GSETTINGS=yes, HAVE_GSETTINGS=no) | ||
| 1989 | if test "$HAVE_GSETTINGS" = yes; then | ||
| 1990 | AC_DEFINE(HAVE_GSETTINGS, 1, [Define to 1 if using GSettings.]) | ||
| 1991 | SETTINGS_CFLAGS="$GSETTINGS_CFLAGS" | ||
| 1992 | SETTINGS_LIBS="$GSETTINGS_LIBS" | ||
| 1993 | fi | ||
| 1994 | fi | ||
| 1995 | |||
| 1984 | dnl GConf has been tested under GNU/Linux only. | 1996 | dnl GConf has been tested under GNU/Linux only. |
| 1985 | dnl The version is really arbitrary, it is about the same age as Gtk+ 2.6. | 1997 | dnl The version is really arbitrary, it is about the same age as Gtk+ 2.6. |
| 1986 | HAVE_GCONF=no | 1998 | HAVE_GCONF=no |
| 1987 | if test "${HAVE_X11}" = "yes" && test "${with_gconf}" = "yes"; then | 1999 | if test "${HAVE_GSETTINGS}" = "no" && "${HAVE_X11}" = "yes" && test "${with_gconf}" = "yes"; then |
| 1988 | PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.13, HAVE_GCONF=yes, HAVE_GCONF=no) | 2000 | PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.13, HAVE_GCONF=yes, HAVE_GCONF=no) |
| 1989 | if test "$HAVE_GCONF" = yes; then | 2001 | if test "$HAVE_GCONF" = yes; then |
| 1990 | AC_DEFINE(HAVE_GCONF, 1, [Define to 1 if using GConf.]) | 2002 | AC_DEFINE(HAVE_GCONF, 1, [Define to 1 if using GConf.]) |
| 1991 | dnl Newer GConf doesn't link with g_objects, so this is not defined. | 2003 | dnl Newer GConf doesn't link with g_objects, so this is not defined. |
| 1992 | AC_CHECK_FUNCS([g_type_init]) | 2004 | SETTINGS_CFLAGS="$GSETTINGS_CFLAGS" |
| 2005 | SETTINGS_LIBS="$GSETTINGS_LIBS" | ||
| 1993 | fi | 2006 | fi |
| 1994 | fi | 2007 | fi |
| 1995 | 2008 | ||
| 2009 | if test "$HAVE_GSETTINGS" = "yes" || "$HAVE_GCONF" = yes; then | ||
| 2010 | SAVE_CFLAGS="$CFLAGS" | ||
| 2011 | SAVE_LDFLAGS="$LDFLAGS" | ||
| 2012 | CFLAGS="$SETTINGS_CFLAGS $CFLAGS" | ||
| 2013 | LDFLAGS="$SETTINGS_LIBS $LDFLAGS" | ||
| 2014 | AC_CHECK_FUNCS([g_type_init]) | ||
| 2015 | CFLAGS="$SAVE_CFLAGS" | ||
| 2016 | LDFLAGS="$SAVE_LDFLAGS" | ||
| 2017 | fi | ||
| 2018 | AC_SUBST(SETTINGS_CFLAGS) | ||
| 2019 | AC_SUBST(SETTINGS_LIBS) | ||
| 2020 | |||
| 2021 | |||
| 1996 | dnl SELinux is available for GNU/Linux only. | 2022 | dnl SELinux is available for GNU/Linux only. |
| 1997 | HAVE_LIBSELINUX=no | 2023 | HAVE_LIBSELINUX=no |
| 1998 | LIBSELINUX_LIBS= | 2024 | LIBSELINUX_LIBS= |
| @@ -3674,6 +3700,7 @@ echo " Does Emacs use imagemagick? ${HAVE_IMAGEMAGI | |||
| 3674 | echo " Does Emacs use -lgpm? ${HAVE_GPM}" | 3700 | echo " Does Emacs use -lgpm? ${HAVE_GPM}" |
| 3675 | echo " Does Emacs use -ldbus? ${HAVE_DBUS}" | 3701 | echo " Does Emacs use -ldbus? ${HAVE_DBUS}" |
| 3676 | echo " Does Emacs use -lgconf? ${HAVE_GCONF}" | 3702 | echo " Does Emacs use -lgconf? ${HAVE_GCONF}" |
| 3703 | echo " Does Emacs use GSettings? ${HAVE_GSETTINGS}" | ||
| 3677 | echo " Does Emacs use -lselinux? ${HAVE_LIBSELINUX}" | 3704 | echo " Does Emacs use -lselinux? ${HAVE_LIBSELINUX}" |
| 3678 | echo " Does Emacs use -lgnutls (2.6.x or higher)? ${HAVE_GNUTLS}" | 3705 | echo " Does Emacs use -lgnutls (2.6.x or higher)? ${HAVE_GNUTLS}" |
| 3679 | echo " Does Emacs use -lxml2? ${HAVE_LIBXML2}" | 3706 | echo " Does Emacs use -lxml2? ${HAVE_LIBXML2}" |
diff --git a/src/ChangeLog b/src/ChangeLog index 000843f6c80..bd00b0f0a5b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,24 @@ | |||
| 1 | 2011-06-30 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * xsettings.c: Include glib.h if HAVE_GSETTINGS. | ||
| 4 | Let HAVE_GSETTINGS override HAVE_GCONF. | ||
| 5 | (store_monospaced_changed): New function. | ||
| 6 | (EMACS_SETTINGS): A new type derived from GObject to handle | ||
| 7 | GSettings notifications. | ||
| 8 | (emacs_settings_constructor, emacs_settings_get_property) | ||
| 9 | (emacs_settings_set_property, emacs_settings_class_init): | ||
| 10 | New functions. | ||
| 11 | (gsettings_client, gsettings_obj): New variables. | ||
| 12 | (GSETTINGS_SCHEMA): New define. | ||
| 13 | (something_changedCB): Call store_monospaced_changed. | ||
| 14 | (init_gsettings): New function. | ||
| 15 | (xsettings_initialize): Call init_gsettings. | ||
| 16 | (syms_of_xsettings): Initialize gsettings_client, gsettings_obj | ||
| 17 | to NULL. | ||
| 18 | |||
| 19 | * Makefile.in (SETTINGS_CFLAGS, SETTINGS_LIBS): Renamed from | ||
| 20 | GCONF_CFLAGS/LIBS. | ||
| 21 | |||
| 1 | 2011-06-29 Martin Rudalics <rudalics@gmx.at> | 22 | 2011-06-29 Martin Rudalics <rudalics@gmx.at> |
| 2 | 23 | ||
| 3 | * window.c (resize_root_window, grow_mini_window) | 24 | * window.c (resize_root_window, grow_mini_window) |
diff --git a/src/Makefile.in b/src/Makefile.in index c4250b90633..3f7953d16ba 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -152,8 +152,8 @@ DBUS_LIBS = @DBUS_LIBS@ | |||
| 152 | ## dbusbind.o if HAVE_DBUS, else empty. | 152 | ## dbusbind.o if HAVE_DBUS, else empty. |
| 153 | DBUS_OBJ = @DBUS_OBJ@ | 153 | DBUS_OBJ = @DBUS_OBJ@ |
| 154 | 154 | ||
| 155 | GCONF_CFLAGS = @GCONF_CFLAGS@ | 155 | SETTINGS_CFLAGS = @SETTINGS_CFLAGS@ |
| 156 | GCONF_LIBS = @GCONF_LIBS@ | 156 | SETTINGS_LIBS = @SETTINGS_CFLAGS@ |
| 157 | 157 | ||
| 158 | ## gtkutil.o if USE_GTK, else empty. | 158 | ## gtkutil.o if USE_GTK, else empty. |
| 159 | GTK_OBJ=@GTK_OBJ@ | 159 | GTK_OBJ=@GTK_OBJ@ |
| @@ -305,7 +305,7 @@ ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I$(srcdir) \ | |||
| 305 | $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ | 305 | $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ |
| 306 | $(C_SWITCH_X_SYSTEM) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \ | 306 | $(C_SWITCH_X_SYSTEM) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \ |
| 307 | $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \ | 307 | $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \ |
| 308 | $(GCONF_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ | 308 | $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ |
| 309 | $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) $(PROFILING_CFLAGS) \ | 309 | $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) $(PROFILING_CFLAGS) \ |
| 310 | $(LIBGNUTLS_CFLAGS) \ | 310 | $(LIBGNUTLS_CFLAGS) \ |
| 311 | $(C_WARNINGS_SWITCH) $(CFLAGS) | 311 | $(C_WARNINGS_SWITCH) $(CFLAGS) |
| @@ -381,7 +381,7 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \ | |||
| 381 | LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ | 381 | LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ |
| 382 | $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(DBUS_LIBS) \ | 382 | $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(DBUS_LIBS) \ |
| 383 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ | 383 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ |
| 384 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(GCONF_LIBS) $(LIBSELINUX_LIBS) \ | 384 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ |
| 385 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ | 385 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ |
| 386 | $(LIBGNUTLS_LIBS) \ | 386 | $(LIBGNUTLS_LIBS) \ |
| 387 | $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC) | 387 | $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC) |
diff --git a/src/xsettings.c b/src/xsettings.c index 5412cf426f8..09a5d31d01f 100644 --- a/src/xsettings.c +++ b/src/xsettings.c | |||
| @@ -34,9 +34,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 34 | 34 | ||
| 35 | #include <X11/Xproto.h> | 35 | #include <X11/Xproto.h> |
| 36 | 36 | ||
| 37 | #define HAVE_GSETTINGS | ||
| 38 | #ifdef HAVE_GSETTINGS | ||
| 39 | #include <glib.h> | ||
| 40 | #else | ||
| 37 | #ifdef HAVE_GCONF | 41 | #ifdef HAVE_GCONF |
| 38 | #include <gconf/gconf-client.h> | 42 | #include <gconf/gconf-client.h> |
| 39 | #endif | 43 | #endif |
| 44 | #endif | ||
| 45 | |||
| 40 | #ifdef HAVE_XFT | 46 | #ifdef HAVE_XFT |
| 41 | #include <X11/Xft/Xft.h> | 47 | #include <X11/Xft/Xft.h> |
| 42 | #endif | 48 | #endif |
| @@ -48,11 +54,6 @@ static Lisp_Object Qmonospace_font_name, Qfont_name, Qfont_render, | |||
| 48 | Qtool_bar_style; | 54 | Qtool_bar_style; |
| 49 | static Lisp_Object current_tool_bar_style; | 55 | static Lisp_Object current_tool_bar_style; |
| 50 | 56 | ||
| 51 | #ifdef HAVE_GCONF | ||
| 52 | static GConfClient *gconf_client; | ||
| 53 | #endif | ||
| 54 | |||
| 55 | |||
| 56 | static void | 57 | static void |
| 57 | store_config_changed_event (Lisp_Object arg, Lisp_Object display_name) | 58 | store_config_changed_event (Lisp_Object arg, Lisp_Object display_name) |
| 58 | { | 59 | { |
| @@ -64,6 +65,159 @@ store_config_changed_event (Lisp_Object arg, Lisp_Object display_name) | |||
| 64 | kbd_buffer_store_event (&event); | 65 | kbd_buffer_store_event (&event); |
| 65 | } | 66 | } |
| 66 | 67 | ||
| 68 | static void | ||
| 69 | store_monospaced_changed (void) | ||
| 70 | { | ||
| 71 | if (first_dpyinfo != NULL) | ||
| 72 | { | ||
| 73 | /* Check if display still open */ | ||
| 74 | struct x_display_info *dpyinfo; | ||
| 75 | int found = 0; | ||
| 76 | for (dpyinfo = x_display_list; !found && dpyinfo; dpyinfo = dpyinfo->next) | ||
| 77 | found = dpyinfo == first_dpyinfo; | ||
| 78 | |||
| 79 | if (found && use_system_font) | ||
| 80 | store_config_changed_event (Qmonospace_font_name, | ||
| 81 | XCAR (first_dpyinfo->name_list_element)); | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | |||
| 86 | #ifdef HAVE_GSETTINGS | ||
| 87 | |||
| 88 | #define EMACS_TYPE_SETTINGS (emacs_settings_get_type ()) | ||
| 89 | #define EMACS_SETTINGS(obj) \ | ||
| 90 | (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMACS_TYPE_SETTINGS, EmacsSettings)) | ||
| 91 | #define EMACS_IS_SETTINGS(obj) \ | ||
| 92 | (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMACS_TYPE_SETTINGS)) | ||
| 93 | #define EMACS_SETTINGS_CLASS(klass) \ | ||
| 94 | (G_TYPE_CHECK_CLASS_CAST ((klass), EMACS_TYPE_SETTINGS, EmacsSettingsClass)) | ||
| 95 | #define EMACS_IS_SETTINGS_CLASS(klass) \ | ||
| 96 | (G_TYPE_CHECK_CLASS_TYPE ((klass), EMACS_TYPE_SETTINGS)) | ||
| 97 | #define EMACS_SETTINGS_GET_CLASS(obj) \ | ||
| 98 | (G_TYPE_INSTANCE_GET_CLASS ((obj), EMACS_TYPE_SETTINGS, EmacsSettingsClass)) | ||
| 99 | |||
| 100 | typedef struct _EmacsSettings EmacsSettings; | ||
| 101 | typedef struct _EmacsSettingsClass EmacsSettingsClass; | ||
| 102 | |||
| 103 | struct _EmacsSettings | ||
| 104 | { | ||
| 105 | GObject parent_instance; | ||
| 106 | }; | ||
| 107 | |||
| 108 | struct _EmacsSettingsClass | ||
| 109 | { | ||
| 110 | GObjectClass parent_class; | ||
| 111 | }; | ||
| 112 | |||
| 113 | /* will create emacs_settings_get_type and set emacs_settings_parent_class */ | ||
| 114 | G_DEFINE_TYPE (EmacsSettings, emacs_settings, G_TYPE_OBJECT); | ||
| 115 | |||
| 116 | static GObject * | ||
| 117 | emacs_settings_constructor (GType gtype, | ||
| 118 | guint n_properties, | ||
| 119 | GObjectConstructParam *properties) | ||
| 120 | { | ||
| 121 | GObject *obj; | ||
| 122 | |||
| 123 | /* Always chain up to the parent constructor */ | ||
| 124 | obj = G_OBJECT_CLASS (emacs_settings_parent_class) | ||
| 125 | ->constructor (gtype, n_properties, properties); | ||
| 126 | |||
| 127 | /* update the object state depending on constructor properties */ | ||
| 128 | |||
| 129 | return obj; | ||
| 130 | } | ||
| 131 | |||
| 132 | enum { PROP_MONO = 1, PROP_FONT }; | ||
| 133 | |||
| 134 | static void | ||
| 135 | emacs_settings_get_property (GObject *object, | ||
| 136 | guint property_id, | ||
| 137 | GValue *value, | ||
| 138 | GParamSpec *pspec) | ||
| 139 | { | ||
| 140 | switch (property_id) | ||
| 141 | { | ||
| 142 | case PROP_MONO: | ||
| 143 | g_value_set_string (value, current_mono_font); | ||
| 144 | break; | ||
| 145 | case PROP_FONT: | ||
| 146 | g_value_set_string (value, current_font); | ||
| 147 | break; | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | static void | ||
| 152 | emacs_settings_set_property (GObject *object, | ||
| 153 | guint property_id, | ||
| 154 | const GValue *value, | ||
| 155 | GParamSpec *pspec) | ||
| 156 | { | ||
| 157 | const char *newfont; | ||
| 158 | switch (property_id) | ||
| 159 | { | ||
| 160 | case PROP_MONO: | ||
| 161 | xfree (current_mono_font); | ||
| 162 | newfont = g_value_get_string (value); | ||
| 163 | if (current_mono_font != NULL && strcmp (newfont, current_mono_font) == 0) | ||
| 164 | return; /* No change. */ | ||
| 165 | |||
| 166 | current_mono_font = xstrdup (newfont); | ||
| 167 | store_monospaced_changed (); | ||
| 168 | break; | ||
| 169 | |||
| 170 | case PROP_FONT: | ||
| 171 | xfree (current_font); | ||
| 172 | current_font = xstrdup (g_value_get_string (value)); | ||
| 173 | break; | ||
| 174 | } | ||
| 175 | } | ||
| 176 | |||
| 177 | static void | ||
| 178 | emacs_settings_class_init (EmacsSettingsClass *klass) | ||
| 179 | { | ||
| 180 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass); | ||
| 181 | |||
| 182 | gobject_class->constructor = emacs_settings_constructor; | ||
| 183 | gobject_class->set_property = emacs_settings_set_property; | ||
| 184 | gobject_class->get_property = emacs_settings_get_property; | ||
| 185 | |||
| 186 | g_object_class_install_property | ||
| 187 | (gobject_class, | ||
| 188 | PROP_MONO, | ||
| 189 | g_param_spec_string ("monospace-font", | ||
| 190 | "Monospace-font", | ||
| 191 | "System monospace font", | ||
| 192 | "", | ||
| 193 | G_PARAM_READWRITE)); | ||
| 194 | g_object_class_install_property | ||
| 195 | (gobject_class, | ||
| 196 | PROP_FONT, | ||
| 197 | g_param_spec_string ("font", | ||
| 198 | "Font", | ||
| 199 | "System font", | ||
| 200 | "", | ||
| 201 | G_PARAM_READWRITE)); | ||
| 202 | |||
| 203 | } | ||
| 204 | |||
| 205 | static void | ||
| 206 | emacs_settings_init (EmacsSettings *self) | ||
| 207 | { | ||
| 208 | } | ||
| 209 | |||
| 210 | |||
| 211 | static GSettings *gsettings_client; | ||
| 212 | static EmacsSettings *gsettings_obj; | ||
| 213 | |||
| 214 | #else | ||
| 215 | #ifdef HAVE_GCONF | ||
| 216 | static GConfClient *gconf_client; | ||
| 217 | #endif | ||
| 218 | #endif | ||
| 219 | |||
| 220 | |||
| 67 | #define XSETTINGS_FONT_NAME "Gtk/FontName" | 221 | #define XSETTINGS_FONT_NAME "Gtk/FontName" |
| 68 | #define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle" | 222 | #define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle" |
| 69 | 223 | ||
| @@ -91,10 +245,15 @@ struct xsettings | |||
| 91 | unsigned seen; | 245 | unsigned seen; |
| 92 | }; | 246 | }; |
| 93 | 247 | ||
| 94 | #ifdef HAVE_GCONF | 248 | #ifdef HAVE_GSETTINGS |
| 249 | #define GSETTINGS_SCHEMA "org.gnome.desktop.interface" | ||
| 250 | #define SYSTEM_MONO_FONT "monospace-font-name" | ||
| 251 | #define SYSTEM_FONT "font-name" | ||
| 95 | 252 | ||
| 96 | #define SYSTEM_MONO_FONT "/desktop/gnome/interface/monospace_font_name" | 253 | #else |
| 97 | #define SYSTEM_FONT "/desktop/gnome/interface/font_name" | 254 | #ifdef HAVE_GCONF |
| 255 | #define SYSTEM_MONO_FONT "/desktop/gnome/interface/monospace_font_name" | ||
| 256 | #define SYSTEM_FONT "/desktop/gnome/interface/font_name" | ||
| 98 | 257 | ||
| 99 | /* Callback called when something changed in GConf that we care about, | 258 | /* Callback called when something changed in GConf that we care about, |
| 100 | that is SYSTEM_MONO_FONT. */ | 259 | that is SYSTEM_MONO_FONT. */ |
| @@ -116,23 +275,12 @@ something_changedCB (GConfClient *client, | |||
| 116 | 275 | ||
| 117 | xfree (current_mono_font); | 276 | xfree (current_mono_font); |
| 118 | current_mono_font = xstrdup (value); | 277 | current_mono_font = xstrdup (value); |
| 119 | } | 278 | store_monospaced_changed (); |
| 120 | |||
| 121 | |||
| 122 | if (first_dpyinfo != NULL) | ||
| 123 | { | ||
| 124 | /* Check if display still open */ | ||
| 125 | struct x_display_info *dpyinfo; | ||
| 126 | int found = 0; | ||
| 127 | for (dpyinfo = x_display_list; !found && dpyinfo; dpyinfo = dpyinfo->next) | ||
| 128 | found = dpyinfo == first_dpyinfo; | ||
| 129 | |||
| 130 | if (found && use_system_font) | ||
| 131 | store_config_changed_event (Qmonospace_font_name, | ||
| 132 | XCAR (first_dpyinfo->name_list_element)); | ||
| 133 | } | 279 | } |
| 134 | } | 280 | } |
| 281 | |||
| 135 | #endif /* HAVE_GCONF */ | 282 | #endif /* HAVE_GCONF */ |
| 283 | #endif /* ! HAVE_GSETTINGS */ | ||
| 136 | 284 | ||
| 137 | #ifdef HAVE_XFT | 285 | #ifdef HAVE_XFT |
| 138 | 286 | ||
| @@ -632,9 +780,47 @@ xft_settings_event (struct x_display_info *dpyinfo, XEvent *event) | |||
| 632 | 780 | ||
| 633 | 781 | ||
| 634 | static void | 782 | static void |
| 783 | init_gsettings (void) | ||
| 784 | { | ||
| 785 | #ifdef HAVE_GSETTINGS | ||
| 786 | GVariant *val; | ||
| 787 | #ifdef HAVE_G_TYPE_INIT | ||
| 788 | g_type_init (); | ||
| 789 | #endif | ||
| 790 | |||
| 791 | gsettings_client = g_settings_new (GSETTINGS_SCHEMA); | ||
| 792 | if (!gsettings_client) return; | ||
| 793 | g_object_ref_sink (G_OBJECT (gsettings_client)); | ||
| 794 | |||
| 795 | gsettings_obj = g_object_new (EMACS_TYPE_SETTINGS, NULL); | ||
| 796 | if (!gsettings_obj) | ||
| 797 | { | ||
| 798 | g_object_unref (G_OBJECT (gsettings_client)); | ||
| 799 | return; | ||
| 800 | } | ||
| 801 | g_object_ref_sink (G_OBJECT (gsettings_obj)); | ||
| 802 | |||
| 803 | val = g_settings_get_value (gsettings_client, SYSTEM_MONO_FONT); | ||
| 804 | if (val) | ||
| 805 | { | ||
| 806 | g_variant_ref_sink (val); | ||
| 807 | if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING)) | ||
| 808 | current_mono_font = xstrdup (g_variant_get_string (val, NULL)); | ||
| 809 | g_variant_unref (val); | ||
| 810 | } | ||
| 811 | |||
| 812 | g_settings_bind (gsettings_client, SYSTEM_MONO_FONT, gsettings_obj, | ||
| 813 | "monospace-font", G_SETTINGS_BIND_GET); | ||
| 814 | g_settings_bind (gsettings_client, SYSTEM_FONT, gsettings_obj, | ||
| 815 | "font", G_SETTINGS_BIND_GET); | ||
| 816 | #endif /* HAVE_GSETTINGS */ | ||
| 817 | } | ||
| 818 | |||
| 819 | |||
| 820 | static void | ||
| 635 | init_gconf (void) | 821 | init_gconf (void) |
| 636 | { | 822 | { |
| 637 | #if defined (HAVE_GCONF) && defined (HAVE_XFT) | 823 | #if defined (HAVE_GCONF) && defined (HAVE_XFT) && ! defined (HAVE_GSETTINGS) |
| 638 | char *s; | 824 | char *s; |
| 639 | 825 | ||
| 640 | #ifdef HAVE_G_TYPE_INIT | 826 | #ifdef HAVE_G_TYPE_INIT |
| @@ -662,7 +848,7 @@ init_gconf (void) | |||
| 662 | SYSTEM_MONO_FONT, | 848 | SYSTEM_MONO_FONT, |
| 663 | something_changedCB, | 849 | something_changedCB, |
| 664 | NULL, NULL, NULL); | 850 | NULL, NULL, NULL); |
| 665 | #endif /* HAVE_GCONF && HAVE_XFT */ | 851 | #endif /* HAVE_GCONF && HAVE_XFT && ! HAVE_GSETTINGS */ |
| 666 | } | 852 | } |
| 667 | 853 | ||
| 668 | static void | 854 | static void |
| @@ -687,6 +873,7 @@ void | |||
| 687 | xsettings_initialize (struct x_display_info *dpyinfo) | 873 | xsettings_initialize (struct x_display_info *dpyinfo) |
| 688 | { | 874 | { |
| 689 | if (first_dpyinfo == NULL) first_dpyinfo = dpyinfo; | 875 | if (first_dpyinfo == NULL) first_dpyinfo = dpyinfo; |
| 876 | init_gsettings (); | ||
| 690 | init_gconf (); | 877 | init_gconf (); |
| 691 | init_xsettings (dpyinfo); | 878 | init_xsettings (dpyinfo); |
| 692 | } | 879 | } |
| @@ -746,9 +933,14 @@ syms_of_xsettings (void) | |||
| 746 | current_mono_font = NULL; | 933 | current_mono_font = NULL; |
| 747 | current_font = NULL; | 934 | current_font = NULL; |
| 748 | first_dpyinfo = NULL; | 935 | first_dpyinfo = NULL; |
| 936 | #ifdef HAVE_GSETTINGS | ||
| 937 | gsettings_client = NULL; | ||
| 938 | gsettings_obj = NULL; | ||
| 939 | #else | ||
| 749 | #ifdef HAVE_GCONF | 940 | #ifdef HAVE_GCONF |
| 750 | gconf_client = NULL; | 941 | gconf_client = NULL; |
| 751 | #endif | 942 | #endif |
| 943 | #endif | ||
| 752 | 944 | ||
| 753 | DEFSYM (Qmonospace_font_name, "monospace-font-name"); | 945 | DEFSYM (Qmonospace_font_name, "monospace-font-name"); |
| 754 | DEFSYM (Qfont_name, "font-name"); | 946 | DEFSYM (Qfont_name, "font-name"); |
| @@ -769,7 +961,7 @@ If this variable is nil, Emacs ignores system font changes. */); | |||
| 769 | 961 | ||
| 770 | #ifdef HAVE_XFT | 962 | #ifdef HAVE_XFT |
| 771 | Fprovide (intern_c_string ("font-render-setting"), Qnil); | 963 | Fprovide (intern_c_string ("font-render-setting"), Qnil); |
| 772 | #ifdef HAVE_GCONF | 964 | #if defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) |
| 773 | Fprovide (intern_c_string ("system-font-setting"), Qnil); | 965 | Fprovide (intern_c_string ("system-font-setting"), Qnil); |
| 774 | #endif | 966 | #endif |
| 775 | #endif | 967 | #endif |