aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog23
-rw-r--r--src/process.c6
-rw-r--r--src/xgselect.c10
-rw-r--r--src/xsettings.c189
4 files changed, 72 insertions, 156 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 85cf1d2a255..bf9f7be831e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,26 @@
12011-07-01 Jan Djärv <jan.h.d@swipnet.se>
2
3 * xsettings.c (store_monospaced_changed): Take new font as arg and
4 check for change against current_mono_font.
5 (EMACS_TYPE_SETTINGS): Remove this and related defines.
6 (emacs_settings_constructor, emacs_settings_get_property)
7 (emacs_settings_set_property, emacs_settings_class_init)
8 (emacs_settings_init, gsettings_obj): Remove.
9 (something_changedCB): New function for HAVE_GSETTINGS.
10 (something_changedCB): HAVE_GCONF: Call store_monospaced_changed
11 with value as argument.
12 (init_gsettings): Check that GSETTINGS_SCHEMA exists before calling
13 g_settings_new (Bug#8967). Do not create gsettings_obj.
14 Remove calls to g_settings_bind. Connect something_changedCB to
15 "changed".
16
17 * xgselect.c: Add defined (HAVE_GSETTINGS).
18 (xgselect_initialize): Ditto.
19
20 * process.c: Add defined (HAVE_GSETTINGS) for xgselect.h
21 (wait_reading_process_output): Add defined (HAVE_GSETTINGS) for
22 xg_select.
23
12011-07-01 Paul Eggert <eggert@cs.ucla.edu> 242011-07-01 Paul Eggert <eggert@cs.ucla.edu>
2 25
3 * eval.c (struct backtrace): Simplify and port the data structure. 26 * eval.c (struct backtrace): Simplify and port the data structure.
diff --git a/src/process.c b/src/process.c
index 0fe7068af3b..6bd168d8840 100644
--- a/src/process.c
+++ b/src/process.c
@@ -102,9 +102,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
102#include "gnutls.h" 102#include "gnutls.h"
103#endif 103#endif
104 104
105#if defined (USE_GTK) || defined (HAVE_GCONF) 105#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
106#include "xgselect.h" 106#include "xgselect.h"
107#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */ 107#endif
108#ifdef HAVE_NS 108#ifdef HAVE_NS
109#include "nsterm.h" 109#include "nsterm.h"
110#endif 110#endif
@@ -4527,7 +4527,7 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
4527 process_output_skip = 0; 4527 process_output_skip = 0;
4528 } 4528 }
4529#endif 4529#endif
4530#if defined (USE_GTK) || defined (HAVE_GCONF) 4530#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
4531 nfds = xg_select 4531 nfds = xg_select
4532#elif defined (HAVE_NS) 4532#elif defined (HAVE_NS)
4533 nfds = ns_select 4533 nfds = ns_select
diff --git a/src/xgselect.c b/src/xgselect.c
index 0d154f6496a..9ccdd37489f 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -15,14 +15,14 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details. 15GNU General Public License for more details.
16 16
17You should have received a copy of the GNU General Public License 17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 18along with GNU Emacs. If not, see <http§://www.gnu.org/licenses/>. */
19 19
20#include <config.h> 20#include <config.h>
21 21
22#include <setjmp.h> 22#include <setjmp.h>
23#include "xgselect.h" 23#include "xgselect.h"
24 24
25#if defined (USE_GTK) || defined (HAVE_GCONF) 25#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
26 26
27#include <glib.h> 27#include <glib.h>
28#include <errno.h> 28#include <errno.h>
@@ -149,13 +149,13 @@ xg_select (int max_fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
149 149
150 return retval; 150 return retval;
151} 151}
152#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */ 152#endif /* USE_GTK || HAVE_GCONF || HAVE_GSETTINGS */
153 153
154void 154void
155xgselect_initialize (void) 155xgselect_initialize (void)
156{ 156{
157#if defined (USE_GTK) || defined (HAVE_GCONF) 157#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
158 gfds_size = 128; 158 gfds_size = 128;
159 gfds = xmalloc (sizeof (*gfds)*gfds_size); 159 gfds = xmalloc (sizeof (*gfds)*gfds_size);
160#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */ 160#endif
161} 161}
diff --git a/src/xsettings.c b/src/xsettings.c
index 5df05e3e50e..4162912f2c1 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -66,9 +66,15 @@ store_config_changed_event (Lisp_Object arg, Lisp_Object display_name)
66} 66}
67 67
68static void 68static void
69store_monospaced_changed (void) 69store_monospaced_changed (const char *newfont)
70{ 70{
71 if (first_dpyinfo != NULL) 71 if (current_mono_font != NULL && strcmp (newfont, current_mono_font) == 0)
72 return; /* No change. */
73
74 xfree (current_mono_font);
75 current_mono_font = xstrdup (newfont);
76
77 if (first_dpyinfo != NULL && use_system_font)
72 { 78 {
73 /* Check if display still open */ 79 /* Check if display still open */
74 struct x_display_info *dpyinfo; 80 struct x_display_info *dpyinfo;
@@ -76,7 +82,7 @@ store_monospaced_changed (void)
76 for (dpyinfo = x_display_list; !found && dpyinfo; dpyinfo = dpyinfo->next) 82 for (dpyinfo = x_display_list; !found && dpyinfo; dpyinfo = dpyinfo->next)
77 found = dpyinfo == first_dpyinfo; 83 found = dpyinfo == first_dpyinfo;
78 84
79 if (found && use_system_font) 85 if (found)
80 store_config_changed_event (Qmonospace_font_name, 86 store_config_changed_event (Qmonospace_font_name,
81 XCAR (first_dpyinfo->name_list_element)); 87 XCAR (first_dpyinfo->name_list_element));
82 } 88 }
@@ -84,133 +90,7 @@ store_monospaced_changed (void)
84 90
85 91
86#ifdef HAVE_GSETTINGS 92#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
100typedef struct _EmacsSettings EmacsSettings;
101typedef struct _EmacsSettingsClass EmacsSettingsClass;
102
103struct _EmacsSettings
104{
105 GObject parent_instance;
106};
107
108struct _EmacsSettingsClass
109{
110 GObjectClass parent_class;
111};
112
113/* will create emacs_settings_get_type and set emacs_settings_parent_class */
114G_DEFINE_TYPE (EmacsSettings, emacs_settings, G_TYPE_OBJECT);
115
116static GObject *
117emacs_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
132enum { PROP_MONO = 1, PROP_FONT };
133
134static void
135emacs_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
151static void
152emacs_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
177static void
178emacs_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
205static void
206emacs_settings_init (EmacsSettings *self)
207{
208}
209
210
211static GSettings *gsettings_client; 93static GSettings *gsettings_client;
212static EmacsSettings *gsettings_obj;
213
214#else 94#else
215#ifdef HAVE_GCONF 95#ifdef HAVE_GCONF
216static GConfClient *gconf_client; 96static GConfClient *gconf_client;
@@ -250,6 +130,26 @@ struct xsettings
250#define SYSTEM_MONO_FONT "monospace-font-name" 130#define SYSTEM_MONO_FONT "monospace-font-name"
251#define SYSTEM_FONT "font-name" 131#define SYSTEM_FONT "font-name"
252 132
133static void
134something_changedCB (GSettings *settings,
135 gchar *key,
136 gpointer user_data)
137{
138 GVariant *val;
139 if (strcmp (key, SYSTEM_MONO_FONT) != 0) return;
140 val = g_settings_get_value (settings, SYSTEM_MONO_FONT);
141 if (val)
142 {
143 g_variant_ref_sink (val);
144 if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))
145 {
146 const gchar *newfont = g_variant_get_string (val, NULL);
147 store_monospaced_changed (newfont);
148 }
149 g_variant_unref (val);
150 }
151}
152
253#else 153#else
254#ifdef HAVE_GCONF 154#ifdef HAVE_GCONF
255#define SYSTEM_MONO_FONT "/desktop/gnome/interface/monospace_font_name" 155#define SYSTEM_MONO_FONT "/desktop/gnome/interface/monospace_font_name"
@@ -270,12 +170,7 @@ something_changedCB (GConfClient *client,
270 if (v->type == GCONF_VALUE_STRING) 170 if (v->type == GCONF_VALUE_STRING)
271 { 171 {
272 const char *value = gconf_value_get_string (v); 172 const char *value = gconf_value_get_string (v);
273 if (current_mono_font != NULL && strcmp (value, current_mono_font) == 0) 173 store_monospaced_changed (value);
274 return; /* No change. */
275
276 xfree (current_mono_font);
277 current_mono_font = xstrdup (value);
278 store_monospaced_changed ();
279 } 174 }
280} 175}
281 176
@@ -784,22 +679,23 @@ init_gsettings (void)
784{ 679{
785#ifdef HAVE_GSETTINGS 680#ifdef HAVE_GSETTINGS
786 GVariant *val; 681 GVariant *val;
682 const gchar *const *schemas;
683 int schema_found = 0;
684
787#ifdef HAVE_G_TYPE_INIT 685#ifdef HAVE_G_TYPE_INIT
788 g_type_init (); 686 g_type_init ();
789#endif 687#endif
790 688
689 schemas = g_settings_list_schemas();
690 if (schemas == NULL) return;
691 while (! schema_found && *schemas != NULL)
692 schema_found = strcmp (*schemas++, GSETTINGS_SCHEMA) == 0;
693 if (!schema_found) return;
694
791 gsettings_client = g_settings_new (GSETTINGS_SCHEMA); 695 gsettings_client = g_settings_new (GSETTINGS_SCHEMA);
792 if (!gsettings_client) return; 696 if (!gsettings_client) return;
793 g_object_ref_sink (G_OBJECT (gsettings_client)); 697 g_object_ref_sink (G_OBJECT (gsettings_client));
794 698
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); 699 val = g_settings_get_value (gsettings_client, SYSTEM_MONO_FONT);
804 if (val) 700 if (val)
805 { 701 {
@@ -809,10 +705,8 @@ init_gsettings (void)
809 g_variant_unref (val); 705 g_variant_unref (val);
810 } 706 }
811 707
812 g_settings_bind (gsettings_client, SYSTEM_MONO_FONT, gsettings_obj, 708 g_signal_connect (G_OBJECT (gsettings_client), "changed",
813 "monospace-font", G_SETTINGS_BIND_GET); 709 G_CALLBACK (something_changedCB), NULL);
814 g_settings_bind (gsettings_client, SYSTEM_FONT, gsettings_obj,
815 "font", G_SETTINGS_BIND_GET);
816#endif /* HAVE_GSETTINGS */ 710#endif /* HAVE_GSETTINGS */
817} 711}
818 712
@@ -935,7 +829,6 @@ syms_of_xsettings (void)
935 first_dpyinfo = NULL; 829 first_dpyinfo = NULL;
936#ifdef HAVE_GSETTINGS 830#ifdef HAVE_GSETTINGS
937 gsettings_client = NULL; 831 gsettings_client = NULL;
938 gsettings_obj = NULL;
939#else 832#else
940#ifdef HAVE_GCONF 833#ifdef HAVE_GCONF
941 gconf_client = NULL; 834 gconf_client = NULL;