aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-07-06 16:34:39 -0700
committerPaul Eggert2011-07-06 16:34:39 -0700
commit59361254a6ea5fcfc2f1ec344665aa719fbb936f (patch)
tree6471eaf76563f8b2f7aab90bf07ff0dd73470599 /src
parent9cfdb3ec08672f13088ebd133bbc794c04a66b05 (diff)
parent8a5c77bba5e38c62605f0f053670a7955130fcc7 (diff)
downloademacs-59361254a6ea5fcfc2f1ec344665aa719fbb936f.tar.gz
emacs-59361254a6ea5fcfc2f1ec344665aa719fbb936f.zip
Merge from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog62
-rw-r--r--src/alloc.c3
-rw-r--r--src/buffer.c12
-rw-r--r--src/buffer.h4
-rw-r--r--src/eval.c2
-rw-r--r--src/gnutls.c2
-rw-r--r--src/xsettings.c372
7 files changed, 343 insertions, 114 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 22d70bf54eb..b0fb0f213ab 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,4 @@
12011-07-05 Paul Eggert <eggert@cs.ucla.edu> 12011-07-06 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Assume support for memcmp, memcpy, memmove, memset. 3 Assume support for memcmp, memcpy, memmove, memset.
4 * lisp.h, sysdep.c (memcmp, memcpy, memmove, memset): 4 * lisp.h, sysdep.c (memcmp, memcpy, memmove, memset):
@@ -12,6 +12,52 @@
12 Use EMACS_INT, not EMACS_UINT, for sizes. The code works equally 12 Use EMACS_INT, not EMACS_UINT, for sizes. The code works equally
13 well either way, and we prefer signed to unsigned. 13 well either way, and we prefer signed to unsigned.
14 14
152011-07-06 Paul Eggert <eggert@cs.ucla.edu>
16
17 Remove unportable assumption about struct layout (Bug#8884).
18 * alloc.c (mark_buffer):
19 * buffer.c (reset_buffer_local_variables, Fbuffer_local_variables)
20 (clone_per_buffer_values): Don't assume that
21 sizeof (struct buffer) is a multiple of sizeof (Lisp_Object).
22 This isn't true in general, and it's particularly not true
23 if Emacs is configured with --with-wide-int.
24 * buffer.h (FIRST_FIELD_PER_BUFFER, LAST_FIELD_PER_BUFFER):
25 New macros, used in the buffer.c change.
26
272011-07-05 Jan Djärv <jan.h.d@swipnet.se>
28
29 * xsettings.c: Use both GConf and GSettings if both are available.
30 (store_config_changed_event): Add comment.
31 (dpyinfo_valid, store_font_name_changed, map_tool_bar_style)
32 (store_tool_bar_style_changed): New functions.
33 (store_monospaced_changed): Add comment. Call dpyinfo_valid.
34 (struct xsettings): Move font inside HAVE_XFT.
35 (GSETTINGS_TOOL_BAR_STYLE, GSETTINGS_FONT_NAME): New defines.
36 (GSETTINGS_MONO_FONT): Renamed from SYSTEM_MONO_FONT.
37 Move inside HAVE_XFT.
38 (something_changed_gsettingsCB): Renamed from something_changedCB.
39 Check for changes in GSETTINGS_TOOL_BAR_STYLE and GSETTINGS_FONT_NAME
40 also.
41 (GCONF_TOOL_BAR_STYLE, GCONF_FONT_NAME): New defines.
42 (GCONF_MONO_FONT): Renamed from SYSTEM_MONO_FONT. Move inside HAVE_XFT.
43 (something_changed_gconfCB): Renamed from something_changedCB.
44 Check for changes in GCONF_TOOL_BAR_STYLE and GCONF_FONT_NAME also.
45 (parse_settings): Move check for font inside HAVE_XFT.
46 (read_settings, apply_xft_settings): Add comment.
47 (read_and_apply_settings): Add comment. Call map_tool_bar_style and
48 store_tool_bar_style_changed. Move check for font inside HAVE_XFT and
49 call store_font_name_changed.
50 (xft_settings_event): Add comment.
51 (init_gsettings): Add comment. Get values for GSETTINGS_TOOL_BAR_STYLE
52 and GSETTINGS_FONT_NAME. Move check for fonts within HAVE_XFT.
53 (init_gconf): Add comment. Get values for GCONF_TOOL_BAR_STYLE
54 and GCONF_FONT_NAME. Move check for fonts within HAVE_XFT.
55 (xsettings_initialize): Call init_gsettings last.
56 (xsettings_get_system_font, xsettings_get_system_normal_font): Add
57 comment.
58
592011-07-05 Paul Eggert <eggert@cs.ucla.edu>
60
15 Random fixes. E.g., (random) never returned negative values. 61 Random fixes. E.g., (random) never returned negative values.
16 * fns.c (Frandom): Use GET_EMACS_TIME for random seed, and add the 62 * fns.c (Frandom): Use GET_EMACS_TIME for random seed, and add the
17 subseconds part to the entropy, as that's a bit more random. 63 subseconds part to the entropy, as that's a bit more random.
@@ -153,7 +199,7 @@
153 with value as argument. 199 with value as argument.
154 (init_gsettings): Check that GSETTINGS_SCHEMA exists before calling 200 (init_gsettings): Check that GSETTINGS_SCHEMA exists before calling
155 g_settings_new (Bug#8967). Do not create gsettings_obj. 201 g_settings_new (Bug#8967). Do not create gsettings_obj.
156 Remove calls to g_settings_bind. Connect something_changedCB to 202 Remove calls to g_settings_bind. Connect something_changedCB to
157 "changed". 203 "changed".
158 204
159 * xgselect.c: Add defined (HAVE_GSETTINGS). 205 * xgselect.c: Add defined (HAVE_GSETTINGS).
@@ -250,8 +296,8 @@
250 min_width/height (Bug#8919). 296 min_width/height (Bug#8919).
251 297
252 * gtkutil.c (xg_create_frame_widgets): Pass f to emacs_fixed_new. 298 * gtkutil.c (xg_create_frame_widgets): Pass f to emacs_fixed_new.
253 (x_wm_set_size_hint): Remove call to emacs_fixed_set_min_size. Fix 299 (x_wm_set_size_hint): Remove call to emacs_fixed_set_min_size.
254 indentation. 300 Fix indentation.
255 301
2562011-06-26 Eli Zaretskii <eliz@gnu.org> 3022011-06-26 Eli Zaretskii <eliz@gnu.org>
257 303
@@ -1812,7 +1858,7 @@
1812 and %.0c. Fix bug with strchr succeeding on '\0' when looking for 1858 and %.0c. Fix bug with strchr succeeding on '\0' when looking for
1813 flags. Fix bug with (format "%c" 256.0). Avoid integer overflow when 1859 flags. Fix bug with (format "%c" 256.0). Avoid integer overflow when
1814 formatting out-of-range floating point numbers with int 1860 formatting out-of-range floating point numbers with int
1815 formats. (Bug#8668) 1861 formats. (Bug#8668)
1816 1862
1817 * lisp.h (FIXNUM_OVERFLOW_P): Work even if arg is a NaN. 1863 * lisp.h (FIXNUM_OVERFLOW_P): Work even if arg is a NaN.
1818 1864
@@ -2776,9 +2822,9 @@
2776 :verify-hostname-error, :verify-error, and :verify-flags 2822 :verify-hostname-error, :verify-error, and :verify-flags
2777 parameters of `gnutls-boot' and documented those parameters in the 2823 parameters of `gnutls-boot' and documented those parameters in the
2778 docstring. Start callback support. 2824 docstring. Start callback support.
2779 (emacs_gnutls_handshake): Add Woe32 support. Retry handshake 2825 (emacs_gnutls_handshake): Add Woe32 support. Retry handshake
2780 unless a fatal error occured. Call gnutls_alert_send_appropriate 2826 unless a fatal error occurred. Call gnutls_alert_send_appropriate
2781 on error. Return error code. 2827 on error. Return error code.
2782 (emacs_gnutls_write): Call emacs_gnutls_handle_error. 2828 (emacs_gnutls_write): Call emacs_gnutls_handle_error.
2783 (emacs_gnutls_read): Likewise. 2829 (emacs_gnutls_read): Likewise.
2784 (Fgnutls_boot): Return handshake error code. 2830 (Fgnutls_boot): Return handshake error code.
diff --git a/src/alloc.c b/src/alloc.c
index 43befd722bb..f679787e95c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5619,7 +5619,8 @@ mark_buffer (Lisp_Object buf)
5619 /* buffer-local Lisp variables start at `undo_list', 5619 /* buffer-local Lisp variables start at `undo_list',
5620 tho only the ones from `name' on are GC'd normally. */ 5620 tho only the ones from `name' on are GC'd normally. */
5621 for (ptr = &buffer->BUFFER_INTERNAL_FIELD (name); 5621 for (ptr = &buffer->BUFFER_INTERNAL_FIELD (name);
5622 (char *)ptr < (char *)buffer + sizeof (struct buffer); 5622 ptr <= &PER_BUFFER_VALUE (buffer,
5623 PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER));
5623 ptr++) 5624 ptr++)
5624 mark_object (*ptr); 5625 mark_object (*ptr);
5625 5626
diff --git a/src/buffer.c b/src/buffer.c
index 2339416eb36..e2f34d629e9 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -471,8 +471,8 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to)
471 471
472 /* buffer-local Lisp variables start at `undo_list', 472 /* buffer-local Lisp variables start at `undo_list',
473 tho only the ones from `name' on are GC'd normally. */ 473 tho only the ones from `name' on are GC'd normally. */
474 for (offset = PER_BUFFER_VAR_OFFSET (undo_list); 474 for (offset = PER_BUFFER_VAR_OFFSET (FIRST_FIELD_PER_BUFFER);
475 offset < sizeof *to; 475 offset <= PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER);
476 offset += sizeof (Lisp_Object)) 476 offset += sizeof (Lisp_Object))
477 { 477 {
478 Lisp_Object obj; 478 Lisp_Object obj;
@@ -830,8 +830,8 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too)
830 830
831 /* buffer-local Lisp variables start at `undo_list', 831 /* buffer-local Lisp variables start at `undo_list',
832 tho only the ones from `name' on are GC'd normally. */ 832 tho only the ones from `name' on are GC'd normally. */
833 for (offset = PER_BUFFER_VAR_OFFSET (undo_list); 833 for (offset = PER_BUFFER_VAR_OFFSET (FIRST_FIELD_PER_BUFFER);
834 offset < sizeof *b; 834 offset <= PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER);
835 offset += sizeof (Lisp_Object)) 835 offset += sizeof (Lisp_Object))
836 { 836 {
837 int idx = PER_BUFFER_IDX (offset); 837 int idx = PER_BUFFER_IDX (offset);
@@ -1055,8 +1055,8 @@ No argument or nil as argument means use current buffer as BUFFER. */)
1055 1055
1056 /* buffer-local Lisp variables start at `undo_list', 1056 /* buffer-local Lisp variables start at `undo_list',
1057 tho only the ones from `name' on are GC'd normally. */ 1057 tho only the ones from `name' on are GC'd normally. */
1058 for (offset = PER_BUFFER_VAR_OFFSET (undo_list); 1058 for (offset = PER_BUFFER_VAR_OFFSET (FIRST_FIELD_PER_BUFFER);
1059 offset < sizeof (struct buffer); 1059 offset <= PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER);
1060 /* sizeof EMACS_INT == sizeof Lisp_Object */ 1060 /* sizeof EMACS_INT == sizeof Lisp_Object */
1061 offset += (sizeof (EMACS_INT))) 1061 offset += (sizeof (EMACS_INT)))
1062 { 1062 {
diff --git a/src/buffer.h b/src/buffer.h
index 4643e0d9d0e..06864dd5789 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -612,6 +612,7 @@ struct buffer
612 /* Everything from here down must be a Lisp_Object. */ 612 /* Everything from here down must be a Lisp_Object. */
613 /* buffer-local Lisp variables start at `undo_list', 613 /* buffer-local Lisp variables start at `undo_list',
614 tho only the ones from `name' on are GC'd normally. */ 614 tho only the ones from `name' on are GC'd normally. */
615 #define FIRST_FIELD_PER_BUFFER undo_list
615 616
616 /* Changes in the buffer are recorded here for undo. 617 /* Changes in the buffer are recorded here for undo.
617 t means don't record anything. 618 t means don't record anything.
@@ -846,6 +847,9 @@ struct buffer
846 t means to use hollow box cursor. 847 t means to use hollow box cursor.
847 See `cursor-type' for other values. */ 848 See `cursor-type' for other values. */
848 Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows); 849 Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows);
850
851 /* This must be the last field in the above list. */
852 #define LAST_FIELD_PER_BUFFER cursor_in_non_selected_windows
849}; 853};
850 854
851 855
diff --git a/src/eval.c b/src/eval.c
index e8a3f947f9d..90d0df61858 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -3162,7 +3162,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
3162 shouldn't bind any arguments, instead just call the byte-code 3162 shouldn't bind any arguments, instead just call the byte-code
3163 interpreter directly; it will push arguments as necessary. 3163 interpreter directly; it will push arguments as necessary.
3164 3164
3165 Byte-code objects with either a non-existant, or a nil value for 3165 Byte-code objects with either a non-existent, or a nil value for
3166 the `push args' slot (the default), have dynamically-bound 3166 the `push args' slot (the default), have dynamically-bound
3167 arguments, and use the argument-binding code below instead (as do 3167 arguments, and use the argument-binding code below instead (as do
3168 all interpreted functions, even lexically bound ones). */ 3168 all interpreted functions, even lexically bound ones). */
diff --git a/src/gnutls.c b/src/gnutls.c
index 55c7ff01c0c..76cfa5dcc98 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -379,7 +379,7 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, EMACS_INT nbyte)
379 /* non-fatal error */ 379 /* non-fatal error */
380 return -1; 380 return -1;
381 else { 381 else {
382 /* a fatal error occured */ 382 /* a fatal error occurred */
383 return 0; 383 return 0;
384 } 384 }
385} 385}
diff --git a/src/xsettings.c b/src/xsettings.c
index 5411d3fc7fb..06718df5a3c 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -37,11 +37,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
37#ifdef HAVE_GSETTINGS 37#ifdef HAVE_GSETTINGS
38#include <glib-object.h> 38#include <glib-object.h>
39#include <gio/gio.h> 39#include <gio/gio.h>
40#else 40#endif
41
41#ifdef HAVE_GCONF 42#ifdef HAVE_GCONF
42#include <gconf/gconf-client.h> 43#include <gconf/gconf-client.h>
43#endif 44#endif
44#endif
45 45
46#ifdef HAVE_XFT 46#ifdef HAVE_XFT
47#include <X11/Xft/Xft.h> 47#include <X11/Xft/Xft.h>
@@ -54,6 +54,8 @@ static Lisp_Object Qmonospace_font_name, Qfont_name, Qfont_render,
54 Qtool_bar_style; 54 Qtool_bar_style;
55static Lisp_Object current_tool_bar_style; 55static Lisp_Object current_tool_bar_style;
56 56
57/* Store an config changed event in to the event queue. */
58
57static void 59static void
58store_config_changed_event (Lisp_Object arg, Lisp_Object display_name) 60store_config_changed_event (Lisp_Object arg, Lisp_Object display_name)
59{ 61{
@@ -65,6 +67,23 @@ store_config_changed_event (Lisp_Object arg, Lisp_Object display_name)
65 kbd_buffer_store_event (&event); 67 kbd_buffer_store_event (&event);
66} 68}
67 69
70/* Return non-zero if DPYINFO is still valid. */
71static int
72dpyinfo_valid (struct x_display_info *dpyinfo)
73{
74 int found = 0;
75 if (dpyinfo != NULL)
76 {
77 struct x_display_info *d;
78 for (d = x_display_list; !found && d; d = d->next)
79 found = d == dpyinfo && d->display == dpyinfo->display;
80 }
81 return found;
82}
83
84/* Store a monospace font change event if the monospaced font changed. */
85
86#ifdef HAVE_XFT
68static void 87static void
69store_monospaced_changed (const char *newfont) 88store_monospaced_changed (const char *newfont)
70{ 89{
@@ -74,28 +93,69 @@ store_monospaced_changed (const char *newfont)
74 xfree (current_mono_font); 93 xfree (current_mono_font);
75 current_mono_font = xstrdup (newfont); 94 current_mono_font = xstrdup (newfont);
76 95
77 if (first_dpyinfo != NULL && use_system_font) 96 if (dpyinfo_valid (first_dpyinfo) && use_system_font)
78 { 97 {
79 /* Check if display still open */ 98 store_config_changed_event (Qmonospace_font_name,
80 struct x_display_info *dpyinfo; 99 XCAR (first_dpyinfo->name_list_element));
81 int found = 0;
82 for (dpyinfo = x_display_list; !found && dpyinfo; dpyinfo = dpyinfo->next)
83 found = dpyinfo == first_dpyinfo;
84
85 if (found)
86 store_config_changed_event (Qmonospace_font_name,
87 XCAR (first_dpyinfo->name_list_element));
88 } 100 }
89} 101}
90 102
103/* Store a font name change event if the font name changed. */
91 104
92#ifdef HAVE_GSETTINGS 105static void
93static GSettings *gsettings_client; 106store_font_name_changed (const char *newfont)
94#else 107{
95#ifdef HAVE_GCONF 108 if (current_font != NULL && strcmp (newfont, current_font) == 0)
96static GConfClient *gconf_client; 109 return; /* No change. */
97#endif 110
98#endif 111 xfree (current_font);
112 current_font = xstrdup (newfont);
113
114 if (dpyinfo_valid (first_dpyinfo))
115 {
116 store_config_changed_event (Qfont_name,
117 XCAR (first_dpyinfo->name_list_element));
118 }
119}
120#endif /* HAVE_XFT */
121
122/* Map TOOL_BAR_STYLE from a string to its correspinding Lisp value.
123 Return Qnil if TOOL_BAR_STYLE is not known. */
124
125static Lisp_Object
126map_tool_bar_style (const char *tool_bar_style)
127{
128 Lisp_Object style = Qnil;
129 if (tool_bar_style)
130 {
131 if (strcmp (tool_bar_style, "both") == 0)
132 style = Qboth;
133 else if (strcmp (tool_bar_style, "both-horiz") == 0)
134 style = Qboth_horiz;
135 else if (strcmp (tool_bar_style, "icons") == 0)
136 style = Qimage;
137 else if (strcmp (tool_bar_style, "text") == 0)
138 style = Qtext;
139 }
140
141 return style;
142}
143
144/* Store a tool bar style change event if the tool bar style changed. */
145
146static void
147store_tool_bar_style_changed (const char *newstyle,
148 struct x_display_info *dpyinfo)
149{
150 Lisp_Object style = map_tool_bar_style (newstyle);
151 if (EQ (current_tool_bar_style, style))
152 return; /* No change. */
153
154 current_tool_bar_style = style;
155 if (dpyinfo_valid (dpyinfo))
156 store_config_changed_event (Qtool_bar_style,
157 XCAR (dpyinfo->name_list_element));
158}
99 159
100 160
101#define XSETTINGS_FONT_NAME "Gtk/FontName" 161#define XSETTINGS_FONT_NAME "Gtk/FontName"
@@ -117,67 +177,129 @@ struct xsettings
117 FcBool aa, hinting; 177 FcBool aa, hinting;
118 int rgba, lcdfilter, hintstyle; 178 int rgba, lcdfilter, hintstyle;
119 double dpi; 179 double dpi;
120#endif
121 180
122 char *font; 181 char *font;
182#endif
183
123 char *tb_style; 184 char *tb_style;
124 185
125 unsigned seen; 186 unsigned seen;
126}; 187};
127 188
128#ifdef HAVE_GSETTINGS 189#ifdef HAVE_GSETTINGS
129#define GSETTINGS_SCHEMA "org.gnome.desktop.interface" 190#define GSETTINGS_SCHEMA "org.gnome.desktop.interface"
130#define SYSTEM_MONO_FONT "monospace-font-name" 191#define GSETTINGS_TOOL_BAR_STYLE "toolbar-style"
192
193#ifdef HAVE_XFT
194#define GSETTINGS_MONO_FONT "monospace-font-name"
195#define GSETTINGS_FONT_NAME "font-name"
196#endif
197
198
199/* The single GSettings instance, or NULL if not connected to GSettings. */
200
201static GSettings *gsettings_client;
202
203/* Callback called when something changed in GSettings. */
131 204
132static void 205static void
133something_changedCB (GSettings *settings, 206something_changed_gsettingsCB (GSettings *settings,
134 gchar *key, 207 gchar *key,
135 gpointer user_data) 208 gpointer user_data)
136{ 209{
137 GVariant *val; 210 GVariant *val;
138 if (strcmp (key, SYSTEM_MONO_FONT) != 0) return; 211
139 val = g_settings_get_value (settings, SYSTEM_MONO_FONT); 212 if (strcmp (key, GSETTINGS_TOOL_BAR_STYLE) == 0)
140 if (val)
141 { 213 {
142 g_variant_ref_sink (val); 214 val = g_settings_get_value (settings, GSETTINGS_TOOL_BAR_STYLE);
143 if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING)) 215 if (val)
144 { 216 {
145 const gchar *newfont = g_variant_get_string (val, NULL); 217 g_variant_ref_sink (val);
146 store_monospaced_changed (newfont); 218 if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))
219 {
220 const gchar *newstyle = g_variant_get_string (val, NULL);
221 store_tool_bar_style_changed (newstyle, first_dpyinfo);
222 }
223 g_variant_unref (val);
224 }
225 }
226#ifdef HAVE_XFT
227 else if (strcmp (key, GSETTINGS_MONO_FONT) == 0)
228 {
229 val = g_settings_get_value (settings, GSETTINGS_MONO_FONT);
230 if (val)
231 {
232 g_variant_ref_sink (val);
233 if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))
234 {
235 const gchar *newfont = g_variant_get_string (val, NULL);
236 store_monospaced_changed (newfont);
237 }
238 g_variant_unref (val);
147 } 239 }
148 g_variant_unref (val);
149 } 240 }
241 else if (strcmp (key, GSETTINGS_FONT_NAME) == 0)
242 {
243 val = g_settings_get_value (settings, GSETTINGS_FONT_NAME);
244 if (val)
245 {
246 g_variant_ref_sink (val);
247 if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))
248 {
249 const gchar *newfont = g_variant_get_string (val, NULL);
250 store_font_name_changed (newfont);
251 }
252 g_variant_unref (val);
253 }
254 }
255#endif /* HAVE_XFT */
150} 256}
151 257
152#else 258#endif /* HAVE_GSETTINGS */
153#ifdef HAVE_GCONF
154#define SYSTEM_MONO_FONT "/desktop/gnome/interface/monospace_font_name"
155 259
260#ifdef HAVE_GCONF
261#define GCONF_TOOL_BAR_STYLE "/desktop/gnome/interface/toolbar_style"
156#ifdef HAVE_XFT 262#ifdef HAVE_XFT
157# define SYSTEM_FONT "/desktop/gnome/interface/font_name" 263#define GCONF_MONO_FONT "/desktop/gnome/interface/monospace_font_name"
264#define GCONF_FONT_NAME "/desktop/gnome/interface/font_name"
158#endif 265#endif
159 266
160/* Callback called when something changed in GConf that we care about, 267/* The single GConf instance, or NULL if not connected to GConf. */
161 that is SYSTEM_MONO_FONT. */ 268
269static GConfClient *gconf_client;
270
271/* Callback called when something changed in GConf that we care about. */
162 272
163static void 273static void
164something_changedCB (GConfClient *client, 274something_changed_gconfCB (GConfClient *client,
165 guint cnxn_id, 275 guint cnxn_id,
166 GConfEntry *entry, 276 GConfEntry *entry,
167 gpointer user_data) 277 gpointer user_data)
168{ 278{
169 GConfValue *v = gconf_entry_get_value (entry); 279 GConfValue *v = gconf_entry_get_value (entry);
280 const char *key = gconf_entry_get_key (entry);
170 281
171 if (!v) return; 282 if (!v || v->type != GCONF_VALUE_STRING || ! key) return;
172 if (v->type == GCONF_VALUE_STRING) 283 if (strcmp (key, GCONF_TOOL_BAR_STYLE) == 0)
284 {
285 const char *value = gconf_value_get_string (v);
286 store_tool_bar_style_changed (value, first_dpyinfo);
287 }
288#ifdef HAVE_XFT
289 else if (strcmp (key, GCONF_MONO_FONT) == 0)
173 { 290 {
174 const char *value = gconf_value_get_string (v); 291 const char *value = gconf_value_get_string (v);
175 store_monospaced_changed (value); 292 store_monospaced_changed (value);
176 } 293 }
294 else if (strcmp (key, GCONF_FONT_NAME) == 0)
295 {
296 const char *value = gconf_value_get_string (v);
297 store_font_name_changed (value);
298 }
299#endif /* HAVE_XFT */
177} 300}
178 301
179#endif /* HAVE_GCONF */ 302#endif /* HAVE_GCONF */
180#endif /* ! HAVE_GSETTINGS */
181 303
182#ifdef HAVE_XFT 304#ifdef HAVE_XFT
183 305
@@ -319,14 +441,14 @@ parse_settings (unsigned char *prop,
319 bytes_parsed += 4; /* Skip serial for this value */ 441 bytes_parsed += 4; /* Skip serial for this value */
320 if (bytes_parsed > bytes) return BadLength; 442 if (bytes_parsed > bytes) return BadLength;
321 443
322 want_this = 444 want_this =
323#ifdef HAVE_XFT 445#ifdef HAVE_XFT
324 (nlen > 6 && strncmp (name, "Xft/", 4) == 0) 446 (nlen > 6 && strncmp (name, "Xft/", 4) == 0)
447 || strcmp (XSETTINGS_FONT_NAME, name) == 0
325 || 448 ||
326#endif 449#endif
327 (strcmp (XSETTINGS_FONT_NAME, name) == 0) 450 strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0;
328 || (strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0); 451
329
330 switch (type) 452 switch (type)
331 { 453 {
332 case 0: /* Integer */ 454 case 0: /* Integer */
@@ -367,17 +489,17 @@ parse_settings (unsigned char *prop,
367 if (want_this) 489 if (want_this)
368 { 490 {
369 ++settings_seen; 491 ++settings_seen;
370 if (strcmp (name, XSETTINGS_FONT_NAME) == 0) 492 if (strcmp (name, XSETTINGS_TOOL_BAR_STYLE) == 0)
371 {
372 settings->font = xstrdup (sval);
373 settings->seen |= SEEN_FONT;
374 }
375 else if (strcmp (name, XSETTINGS_TOOL_BAR_STYLE) == 0)
376 { 493 {
377 settings->tb_style = xstrdup (sval); 494 settings->tb_style = xstrdup (sval);
378 settings->seen |= SEEN_TB_STYLE; 495 settings->seen |= SEEN_TB_STYLE;
379 } 496 }
380#ifdef HAVE_XFT 497#ifdef HAVE_XFT
498 else if (strcmp (name, XSETTINGS_FONT_NAME) == 0)
499 {
500 settings->font = xstrdup (sval);
501 settings->seen |= SEEN_FONT;
502 }
381 else if (strcmp (name, "Xft/Antialias") == 0) 503 else if (strcmp (name, "Xft/Antialias") == 0)
382 { 504 {
383 settings->seen |= SEEN_AA; 505 settings->seen |= SEEN_AA;
@@ -442,6 +564,10 @@ parse_settings (unsigned char *prop,
442 return settings_seen; 564 return settings_seen;
443} 565}
444 566
567/* Read settings from the XSettings property window on display for DPYINFO.
568 Store settings read in SETTINGS.
569 Return non-zero if successful, zero if not. */
570
445static int 571static int
446read_settings (struct x_display_info *dpyinfo, struct xsettings *settings) 572read_settings (struct x_display_info *dpyinfo, struct xsettings *settings)
447{ 573{
@@ -471,6 +597,8 @@ read_settings (struct x_display_info *dpyinfo, struct xsettings *settings)
471 return rc != 0; 597 return rc != 0;
472} 598}
473 599
600/* Apply Xft settings in SETTINGS to the Xft library.
601 If SEND_EVENT_P is non-zero store a Lisp event that Xft settings changed. */
474 602
475static void 603static void
476apply_xft_settings (struct x_display_info *dpyinfo, 604apply_xft_settings (struct x_display_info *dpyinfo,
@@ -489,9 +617,9 @@ apply_xft_settings (struct x_display_info *dpyinfo,
489 pat); 617 pat);
490 FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa); 618 FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa);
491 FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting); 619 FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting);
492# ifdef FC_HINT_STYLE 620#ifdef FC_HINT_STYLE
493 FcPatternGetInteger (pat, FC_HINT_STYLE, 0, &oldsettings.hintstyle); 621 FcPatternGetInteger (pat, FC_HINT_STYLE, 0, &oldsettings.hintstyle);
494# endif 622#endif
495 FcPatternGetInteger (pat, FC_LCD_FILTER, 0, &oldsettings.lcdfilter); 623 FcPatternGetInteger (pat, FC_LCD_FILTER, 0, &oldsettings.lcdfilter);
496 FcPatternGetInteger (pat, FC_RGBA, 0, &oldsettings.rgba); 624 FcPatternGetInteger (pat, FC_RGBA, 0, &oldsettings.rgba);
497 FcPatternGetDouble (pat, FC_DPI, 0, &oldsettings.dpi); 625 FcPatternGetDouble (pat, FC_DPI, 0, &oldsettings.dpi);
@@ -530,7 +658,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
530 oldsettings.lcdfilter = settings->lcdfilter; 658 oldsettings.lcdfilter = settings->lcdfilter;
531 } 659 }
532 660
533# ifdef FC_HINT_STYLE 661#ifdef FC_HINT_STYLE
534 if ((settings->seen & SEEN_HINTSTYLE) != 0 662 if ((settings->seen & SEEN_HINTSTYLE) != 0
535 && oldsettings.hintstyle != settings->hintstyle) 663 && oldsettings.hintstyle != settings->hintstyle)
536 { 664 {
@@ -539,7 +667,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
539 ++changed; 667 ++changed;
540 oldsettings.hintstyle = settings->hintstyle; 668 oldsettings.hintstyle = settings->hintstyle;
541 } 669 }
542# endif 670#endif
543 671
544 if ((settings->seen & SEEN_DPI) != 0 && oldsettings.dpi != settings->dpi 672 if ((settings->seen & SEEN_DPI) != 0 && oldsettings.dpi != settings->dpi
545 && settings->dpi > 0) 673 && settings->dpi > 0)
@@ -590,11 +718,13 @@ apply_xft_settings (struct x_display_info *dpyinfo,
590#endif /* HAVE_XFT */ 718#endif /* HAVE_XFT */
591} 719}
592 720
721/* Read XSettings from the display for DPYINFO.
722 If SEND_EVENT_P is non-zero store a Lisp event settings that changed. */
723
593static void 724static void
594read_and_apply_settings (struct x_display_info *dpyinfo, int send_event_p) 725read_and_apply_settings (struct x_display_info *dpyinfo, int send_event_p)
595{ 726{
596 struct xsettings settings; 727 struct xsettings settings;
597 Lisp_Object dpyname = XCAR (dpyinfo->name_list_element);
598 728
599 if (!read_settings (dpyinfo, &settings)) 729 if (!read_settings (dpyinfo, &settings))
600 return; 730 return;
@@ -602,38 +732,29 @@ read_and_apply_settings (struct x_display_info *dpyinfo, int send_event_p)
602 apply_xft_settings (dpyinfo, True, &settings); 732 apply_xft_settings (dpyinfo, True, &settings);
603 if (settings.seen & SEEN_TB_STYLE) 733 if (settings.seen & SEEN_TB_STYLE)
604 { 734 {
605 Lisp_Object style = Qnil; 735 if (send_event_p)
606 if (strcmp (settings.tb_style, "both") == 0) 736 store_tool_bar_style_changed (settings.tb_style, dpyinfo);
607 style = Qboth; 737 else
608 else if (strcmp (settings.tb_style, "both-horiz") == 0) 738 current_tool_bar_style = map_tool_bar_style (settings.tb_style);
609 style = Qboth_horiz;
610 else if (strcmp (settings.tb_style, "icons") == 0)
611 style = Qimage;
612 else if (strcmp (settings.tb_style, "text") == 0)
613 style = Qtext;
614 if (!NILP (style) && !EQ (style, current_tool_bar_style))
615 {
616 current_tool_bar_style = style;
617 if (send_event_p)
618 store_config_changed_event (Qtool_bar_style, dpyname);
619 }
620 xfree (settings.tb_style); 739 xfree (settings.tb_style);
621 } 740 }
622 741#ifdef HAVE_XFT
623 if (settings.seen & SEEN_FONT) 742 if (settings.seen & SEEN_FONT)
624 { 743 {
625 if (!current_font || strcmp (current_font, settings.font) != 0) 744 if (send_event_p)
745 store_font_name_changed (settings.font);
746 else
626 { 747 {
627 xfree (current_font); 748 xfree (current_font);
628 current_font = settings.font; 749 current_font = xstrdup (settings.font);
629 if (send_event_p)
630 store_config_changed_event (Qfont_name, dpyname);
631 } 750 }
632 else 751 xfree (settings.font);
633 xfree (settings.font);
634 } 752 }
753#endif
635} 754}
636 755
756/* Check if EVENT for the display in DPYINFO is XSettings related. */
757
637void 758void
638xft_settings_event (struct x_display_info *dpyinfo, XEvent *event) 759xft_settings_event (struct x_display_info *dpyinfo, XEvent *event)
639{ 760{
@@ -675,6 +796,7 @@ xft_settings_event (struct x_display_info *dpyinfo, XEvent *event)
675 read_and_apply_settings (dpyinfo, True); 796 read_and_apply_settings (dpyinfo, True);
676} 797}
677 798
799/* Initialize GSettings and read startup values. */
678 800
679static void 801static void
680init_gsettings (void) 802init_gsettings (void)
@@ -697,8 +819,21 @@ init_gsettings (void)
697 gsettings_client = g_settings_new (GSETTINGS_SCHEMA); 819 gsettings_client = g_settings_new (GSETTINGS_SCHEMA);
698 if (!gsettings_client) return; 820 if (!gsettings_client) return;
699 g_object_ref_sink (G_OBJECT (gsettings_client)); 821 g_object_ref_sink (G_OBJECT (gsettings_client));
822 g_signal_connect (G_OBJECT (gsettings_client), "changed",
823 G_CALLBACK (something_changed_gsettingsCB), NULL);
824
825 val = g_settings_get_value (gsettings_client, GSETTINGS_TOOL_BAR_STYLE);
826 if (val)
827 {
828 g_variant_ref_sink (val);
829 if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))
830 current_tool_bar_style
831 = map_tool_bar_style (g_variant_get_string (val, NULL));
832 g_variant_unref (val);
833 }
700 834
701 val = g_settings_get_value (gsettings_client, SYSTEM_MONO_FONT); 835#ifdef HAVE_XFT
836 val = g_settings_get_value (gsettings_client, GSETTINGS_MONO_FONT);
702 if (val) 837 if (val)
703 { 838 {
704 g_variant_ref_sink (val); 839 g_variant_ref_sink (val);
@@ -707,46 +842,84 @@ init_gsettings (void)
707 g_variant_unref (val); 842 g_variant_unref (val);
708 } 843 }
709 844
710 g_signal_connect (G_OBJECT (gsettings_client), "changed", 845 val = g_settings_get_value (gsettings_client, GSETTINGS_FONT_NAME);
711 G_CALLBACK (something_changedCB), NULL); 846 if (val)
847 {
848 g_variant_ref_sink (val);
849 if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))
850 current_font = xstrdup (g_variant_get_string (val, NULL));
851 g_variant_unref (val);
852 }
853#endif /* HAVE_XFT */
854
712#endif /* HAVE_GSETTINGS */ 855#endif /* HAVE_GSETTINGS */
713} 856}
714 857
858/* Init GConf and read startup values. */
715 859
716static void 860static void
717init_gconf (void) 861init_gconf (void)
718{ 862{
719#if defined (HAVE_GCONF) && defined (HAVE_XFT) && ! defined (HAVE_GSETTINGS) 863#if defined (HAVE_GCONF)
720 char *s; 864 char *s;
721 865
722#ifdef HAVE_G_TYPE_INIT 866#ifdef HAVE_G_TYPE_INIT
723 g_type_init (); 867 g_type_init ();
724#endif 868#endif
869
725 gconf_client = gconf_client_get_default (); 870 gconf_client = gconf_client_get_default ();
726 s = gconf_client_get_string (gconf_client, SYSTEM_MONO_FONT, NULL); 871 gconf_client_set_error_handling (gconf_client, GCONF_CLIENT_HANDLE_NONE);
872 gconf_client_add_dir (gconf_client,
873 GCONF_TOOL_BAR_STYLE,
874 GCONF_CLIENT_PRELOAD_ONELEVEL,
875 NULL);
876 gconf_client_notify_add (gconf_client,
877 GCONF_TOOL_BAR_STYLE,
878 something_changed_gconfCB,
879 NULL, NULL, NULL);
880
881 s = gconf_client_get_string (gconf_client, GCONF_TOOL_BAR_STYLE, NULL);
882 if (s)
883 {
884 current_tool_bar_style = map_tool_bar_style (s);
885 g_free (s);
886 }
887
888#ifdef HAVE_XFT
889 s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL);
727 if (s) 890 if (s)
728 { 891 {
729 current_mono_font = xstrdup (s); 892 current_mono_font = xstrdup (s);
730 g_free (s); 893 g_free (s);
731 } 894 }
732 s = gconf_client_get_string (gconf_client, SYSTEM_FONT, NULL); 895 s = gconf_client_get_string (gconf_client, GCONF_FONT_NAME, NULL);
733 if (s) 896 if (s)
734 { 897 {
735 current_font = xstrdup (s); 898 current_font = xstrdup (s);
736 g_free (s); 899 g_free (s);
737 } 900 }
738 gconf_client_set_error_handling (gconf_client, GCONF_CLIENT_HANDLE_NONE);
739 gconf_client_add_dir (gconf_client, 901 gconf_client_add_dir (gconf_client,
740 SYSTEM_MONO_FONT, 902 GCONF_MONO_FONT,
741 GCONF_CLIENT_PRELOAD_ONELEVEL, 903 GCONF_CLIENT_PRELOAD_ONELEVEL,
742 NULL); 904 NULL);
743 gconf_client_notify_add (gconf_client, 905 gconf_client_notify_add (gconf_client,
744 SYSTEM_MONO_FONT, 906 GCONF_MONO_FONT,
745 something_changedCB, 907 something_changed_gconfCB,
746 NULL, NULL, NULL); 908 NULL, NULL, NULL);
747#endif /* HAVE_GCONF && HAVE_XFT && ! HAVE_GSETTINGS */ 909 gconf_client_add_dir (gconf_client,
910 GCONF_FONT_NAME,
911 GCONF_CLIENT_PRELOAD_ONELEVEL,
912 NULL);
913 gconf_client_notify_add (gconf_client,
914 GCONF_FONT_NAME,
915 something_changed_gconfCB,
916 NULL, NULL, NULL);
917#endif /* HAVE_XFT */
918#endif /* HAVE_GCONF */
748} 919}
749 920
921/* Init Xsettings and read startup values. */
922
750static void 923static void
751init_xsettings (struct x_display_info *dpyinfo) 924init_xsettings (struct x_display_info *dpyinfo)
752{ 925{
@@ -769,11 +942,14 @@ void
769xsettings_initialize (struct x_display_info *dpyinfo) 942xsettings_initialize (struct x_display_info *dpyinfo)
770{ 943{
771 if (first_dpyinfo == NULL) first_dpyinfo = dpyinfo; 944 if (first_dpyinfo == NULL) first_dpyinfo = dpyinfo;
772 init_gsettings ();
773 init_gconf (); 945 init_gconf ();
774 init_xsettings (dpyinfo); 946 init_xsettings (dpyinfo);
947 init_gsettings ();
775} 948}
776 949
950/* Return the system monospaced font.
951 May be NULL if not known. */
952
777const char * 953const char *
778xsettings_get_system_font (void) 954xsettings_get_system_font (void)
779{ 955{
@@ -781,6 +957,9 @@ xsettings_get_system_font (void)
781} 957}
782 958
783#ifdef USE_LUCID 959#ifdef USE_LUCID
960/* Return the system font.
961 May be NULL if not known. */
962
784const char * 963const char *
785xsettings_get_system_normal_font (void) 964xsettings_get_system_normal_font (void)
786{ 965{
@@ -831,11 +1010,10 @@ syms_of_xsettings (void)
831 first_dpyinfo = NULL; 1010 first_dpyinfo = NULL;
832#ifdef HAVE_GSETTINGS 1011#ifdef HAVE_GSETTINGS
833 gsettings_client = NULL; 1012 gsettings_client = NULL;
834#else 1013#endif
835#ifdef HAVE_GCONF 1014#ifdef HAVE_GCONF
836 gconf_client = NULL; 1015 gconf_client = NULL;
837#endif 1016#endif
838#endif
839 1017
840 DEFSYM (Qmonospace_font_name, "monospace-font-name"); 1018 DEFSYM (Qmonospace_font_name, "monospace-font-name");
841 DEFSYM (Qfont_name, "font-name"); 1019 DEFSYM (Qfont_name, "font-name");