unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Make reading GNOME settings optional
@ 2021-01-31 22:22 Misha Gusarov
  2021-01-31 22:23 ` Misha Gusarov
  0 siblings, 1 reply; 3+ messages in thread
From: Misha Gusarov @ 2021-01-31 22:22 UTC (permalink / raw)
  To: emacs-devel; +Cc: Misha Gusarov

* src/pgtkterm.c (pgtk_term_init):
Make reading GNOME settings optional.
---
 src/pgtkterm.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index 437249abeb..b1babad297 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -6798,6 +6798,26 @@ same_x_server (const char *name1, const char *name2)
 	  && (*name2 == '.' || *name2 == '\0'));
 }
 
+#define GNOME_INTERFACE_SCHEMA "org.gnome.desktop.interface"
+
+static gdouble pkgt_text_scaling_factor(void)
+{
+  GSettingsSchemaSource *schema_source = g_settings_schema_source_get_default ();
+  if (schema_source != NULL)
+    {
+      GSettingsSchema *schema = g_settings_schema_source_lookup (schema_source,
+	  GNOME_INTERFACE_SCHEMA, true);
+      if (schema != NULL)
+        {
+	  g_settings_schema_unref (schema);
+	  GSettings *set = g_settings_new (GNOME_INTERFACE_SCHEMA);
+	  return g_settings_get_double (set, "text-scaling-factor");
+	}
+    }
+  return 1;
+}
+
+
 /* Open a connection to X display DISPLAY_NAME, and return
    the structure that describes the open display.
    If we cannot contact the display, return null.  */
@@ -6969,11 +6989,7 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name)
   {
     GdkScreen *gscr = gdk_display_get_default_screen (dpyinfo->gdpy);
 
-    GSettings *set = g_settings_new ("org.gnome.desktop.interface");
-    gdouble x = g_settings_get_double (set, "text-scaling-factor");
-    gdouble dpi = 0;
-
-    dpi = 96.0 * x;
+    dpi = 96.0 * pgtk_text_scaling_factor();
     gdk_screen_set_resolution (gscr, dpi);
     dpyinfo->resx = dpi;
     dpyinfo->resy = dpi;
-- 
2.28.0




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Make reading GNOME settings optional
  2021-01-31 22:22 [PATCH] Make reading GNOME settings optional Misha Gusarov
@ 2021-01-31 22:23 ` Misha Gusarov
  2021-01-31 22:28   ` Misha Gusarov
  0 siblings, 1 reply; 3+ messages in thread
From: Misha Gusarov @ 2021-01-31 22:23 UTC (permalink / raw)
  To: emacs-devel; +Cc: Misha Gusarov

Hello.

This patch is for feature/pgtk branch. Without it Emacs crashes
on startup if gsettings-desktop-schemas are not installed.

On 31 Jan 2021, at 23:22, Misha Gusarov wrote:

> * src/pgtkterm.c (pgtk_term_init):
> Make reading GNOME settings optional.
> ---
>  src/pgtkterm.c | 26 +++++++++++++++++++++-----
>  1 file changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/src/pgtkterm.c b/src/pgtkterm.c
> index 437249abeb..b1babad297 100644
> --- a/src/pgtkterm.c
> +++ b/src/pgtkterm.c
> @@ -6798,6 +6798,26 @@ same_x_server (const char *name1, const char 
> *name2)
>  	  && (*name2 == '.' || *name2 == '\0'));
>  }
>
> +#define GNOME_INTERFACE_SCHEMA "org.gnome.desktop.interface"
> +
> +static gdouble pkgt_text_scaling_factor(void)
> +{
> +  GSettingsSchemaSource *schema_source = 
> g_settings_schema_source_get_default ();
> +  if (schema_source != NULL)
> +    {
> +      GSettingsSchema *schema = g_settings_schema_source_lookup 
> (schema_source,
> +	  GNOME_INTERFACE_SCHEMA, true);
> +      if (schema != NULL)
> +        {
> +	  g_settings_schema_unref (schema);
> +	  GSettings *set = g_settings_new (GNOME_INTERFACE_SCHEMA);
> +	  return g_settings_get_double (set, "text-scaling-factor");
> +	}
> +    }
> +  return 1;
> +}
> +
> +
>  /* Open a connection to X display DISPLAY_NAME, and return
>     the structure that describes the open display.
>     If we cannot contact the display, return null.  */
> @@ -6969,11 +6989,7 @@ pgtk_term_init (Lisp_Object display_name, char 
> *resource_name)
>    {
>      GdkScreen *gscr = gdk_display_get_default_screen (dpyinfo->gdpy);
>
> -    GSettings *set = g_settings_new ("org.gnome.desktop.interface");
> -    gdouble x = g_settings_get_double (set, "text-scaling-factor");
> -    gdouble dpi = 0;
> -
> -    dpi = 96.0 * x;
> +    dpi = 96.0 * pgtk_text_scaling_factor();
>      gdk_screen_set_resolution (gscr, dpi);
>      dpyinfo->resx = dpi;
>      dpyinfo->resy = dpi;
> -- 
> 2.28.0

Best,
Misha.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Make reading GNOME settings optional
  2021-01-31 22:23 ` Misha Gusarov
@ 2021-01-31 22:28   ` Misha Gusarov
  0 siblings, 0 replies; 3+ messages in thread
From: Misha Gusarov @ 2021-01-31 22:28 UTC (permalink / raw)
  To: emacs-devel; +Cc: Misha Gusarov

On 31 Jan 2021, at 23:23, Misha Gusarov wrote:

> This patch is for feature/pgtk branch. Without it Emacs crashes
> on startup if gsettings-desktop-schemas are not installed.

Please ignore, it does not work — wrong commit posted. Will send 
updated one soon.

Best,
Misha.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-31 22:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-31 22:22 [PATCH] Make reading GNOME settings optional Misha Gusarov
2021-01-31 22:23 ` Misha Gusarov
2021-01-31 22:28   ` Misha Gusarov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).