Fequal_including_properties fix
[bpt/emacs.git] / src / xsettings.c
index cff0c99..e9cc960 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions for handling font and other changes dynamically.
 
-Copyright (C) 2009-2013 Free Software Foundation, Inc.
+Copyright (C) 2009-2014 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -91,8 +91,7 @@ store_monospaced_changed (const char *newfont)
   if (current_mono_font != NULL && strcmp (newfont, current_mono_font) == 0)
     return; /* No change. */
 
-  xfree (current_mono_font);
-  current_mono_font = xstrdup (newfont);
+  dupstring (&current_mono_font, newfont);
 
   if (dpyinfo_valid (first_dpyinfo) && use_system_font)
     {
@@ -111,8 +110,7 @@ store_font_name_changed (const char *newfont)
   if (current_font != NULL && strcmp (newfont, current_font) == 0)
     return; /* No change. */
 
-  xfree (current_font);
-  current_font = xstrdup (newfont);
+  dupstring (&current_font, newfont);
 
   if (dpyinfo_valid (first_dpyinfo))
     {
@@ -492,13 +490,13 @@ parse_settings (unsigned char *prop,
           ++settings_seen;
           if (strcmp (name, XSETTINGS_TOOL_BAR_STYLE) == 0)
             {
-              settings->tb_style = xstrdup (sval);
+              dupstring (&settings->tb_style, sval);
               settings->seen |= SEEN_TB_STYLE;
             }
 #ifdef HAVE_XFT
           else if (strcmp (name, XSETTINGS_FONT_NAME) == 0)
             {
-              settings->font = xstrdup (sval);
+              dupstring (&settings->font, sval);
               settings->seen |= SEEN_FONT;
             }
           else if (strcmp (name, "Xft/Antialias") == 0)
@@ -742,10 +740,7 @@ read_and_apply_settings (struct x_display_info *dpyinfo, int send_event_p)
       if (send_event_p)
         store_font_name_changed (settings.font);
       else
-        {
-          xfree (current_font);
-          current_font = xstrdup (settings.font);
-        }
+       dupstring (&current_font, settings.font);
       xfree (settings.font);
     }
 #endif
@@ -800,17 +795,29 @@ init_gsettings (void)
 {
 #ifdef HAVE_GSETTINGS
   GVariant *val;
-  const gchar *const *schemas;
   int schema_found = 0;
 
 #if ! GLIB_CHECK_VERSION (2, 36, 0)
   g_type_init ();
 #endif
 
-  schemas = g_settings_list_schemas ();
-  if (schemas == NULL) return;
-  while (! schema_found && *schemas != NULL)
-    schema_found = strcmp (*schemas++, GSETTINGS_SCHEMA) == 0;
+#if GLIB_CHECK_VERSION (2, 32, 0)
+  {
+    GSettingsSchema *sc = g_settings_schema_source_lookup
+      (g_settings_schema_source_get_default (),
+       GSETTINGS_SCHEMA,
+       TRUE);
+    schema_found = sc != NULL;
+    if (sc) g_settings_schema_unref (sc);
+  }
+#else
+  {
+    const gchar *const *schemas = g_settings_list_schemas ();
+    if (schemas == NULL) return;
+    while (! schema_found && *schemas != NULL)
+      schema_found = strcmp (*schemas++, GSETTINGS_SCHEMA) == 0;
+  }
+#endif
   if (!schema_found) return;
 
   gsettings_client = g_settings_new (GSETTINGS_SCHEMA);
@@ -835,7 +842,7 @@ init_gsettings (void)
     {
       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));
+       dupstring (&current_mono_font, g_variant_get_string (val, NULL));
       g_variant_unref (val);
     }
 
@@ -844,7 +851,7 @@ init_gsettings (void)
     {
       g_variant_ref_sink (val);
       if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))
-        current_font = xstrdup (g_variant_get_string (val, NULL));
+        dupstring (&current_font, g_variant_get_string (val, NULL));
       g_variant_unref (val);
     }
 #endif /* HAVE_XFT */
@@ -886,13 +893,13 @@ init_gconf (void)
   s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL);
   if (s)
     {
-      current_mono_font = xstrdup (s);
+      dupstring (&current_mono_font, s);
       g_free (s);
     }
   s = gconf_client_get_string (gconf_client, GCONF_FONT_NAME, NULL);
   if (s)
     {
-      current_font = xstrdup (s);
+      dupstring (&current_font, s);
       g_free (s);
     }
   gconf_client_add_dir (gconf_client,
@@ -1002,6 +1009,8 @@ known style.  Otherwise return image.  */)
 void
 syms_of_xsettings (void)
 {
+#include "xsettings.x"
+
   current_mono_font = NULL;
   current_font = NULL;
   first_dpyinfo = NULL;
@@ -1015,8 +1024,6 @@ syms_of_xsettings (void)
   DEFSYM (Qmonospace_font_name, "monospace-font-name");
   DEFSYM (Qfont_name, "font-name");
   DEFSYM (Qfont_render, "font-render");
-  defsubr (&Sfont_get_system_font);
-  defsubr (&Sfont_get_system_normal_font);
 
   DEFVAR_BOOL ("font-use-system-font", use_system_font,
     doc: /* Non-nil means to apply the system defined font dynamically.
@@ -1038,7 +1045,6 @@ If this variable is nil, Emacs ignores system font changes.  */);
 
   current_tool_bar_style = Qnil;
   DEFSYM (Qtool_bar_style, "tool-bar-style");
-  defsubr (&Stool_bar_get_system_style);
 
   Fprovide (intern_c_string ("dynamic-setting"), Qnil);
 }