[Sugar-devel] [Fwd: [PATCH] Add dpi font support]

Bernie Innocenti bernie at codewiz.org
Fri Jun 18 20:15:43 EDT 2010


Oops, this was supposed to go also to the list.

--------- Mensaje reenviado --------
From: Jorge (jasg) Saldivar <jsaldivar at paraguayeduca.org>
To: sayamindu at laptop.org
Cc: bernie at codewiz.org, Jorge Saldivar <jsaldivar at paraguayeduca.org>
Subject: [PATCH] Add dpi font support
Date: Fri, 18 Jun 2010 12:51:06 -0400

From: Jorge Saldivar <jsaldivar at paraguayeduca.org>

---
 src/sugar-settings-manager.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/sugar-settings-manager.c b/src/sugar-settings-manager.c
index 1180334..52b8b89 100644
--- a/src/sugar-settings-manager.c
+++ b/src/sugar-settings-manager.c
@@ -21,6 +21,7 @@
  *
  * Authors:  Owen Taylor, Red Hat, Inc.
  *           Sayamindu Dasgupta <sayamindu at laptop.org>
+ *           Jorge Saldivar <jorgesaldivar at gmail.com>
  */
 
 #include <stdlib.h>
@@ -36,9 +37,11 @@
 #define SUGAR_FONT_DIR "/desktop/sugar/font"
 #define SUGAR_FONT_FACE_KEY "/desktop/sugar/font/default_face"
 #define SUGAR_FONT_SIZE_KEY "/desktop/sugar/font/default_size"
+#define SUGAR_FONT_DPI_KEY "/desktop/sugar/font/dpi"
 
 /* See http://freedesktop.org/wiki/Specifications/XSettingsRegistry */
 #define XSETTINGS_REGISTRY_GTK_FONT_NAME "Gtk/FontName"
+#define XSETTINGS_REGISTRY_XFT_DPI "Xft/DPI"
 
 XSettingsManager *manager;
 GConfClient *client;
@@ -77,6 +80,19 @@ void update_font()
     xsettings_manager_notify(manager);
 }
 
+void update_font_dpi()
+{
+    gint font_dpi;
+
+    font_dpi = gconf_client_get_int(client, SUGAR_FONT_DPI_KEY, NULL);
+    if (!font_dpi)
+	return;
+
+    xsettings_manager_set_int(manager, XSETTINGS_REGISTRY_XFT_DPI,
+				 font_dpi);
+    xsettings_manager_notify(manager);
+}
+
 void
 font_face_changed_callback(GConfClient * client,
 			   guint cnxn_id,
@@ -109,6 +125,21 @@ font_size_changed_callback(GConfClient * client,
     }
 }
 
+void
+font_dpi_changed_callback(GConfClient * client,
+			   guint cnxn_id,
+			   GConfEntry * entry, gpointer user_data)
+{
+    if (entry->value == NULL) {
+	return;
+    } else {
+	if (entry->value->type == GCONF_VALUE_INT) {
+	    update_font_dpi();
+	} else {
+	    return;
+	}
+    }
+}
 
 void setup_font()
 {
@@ -123,8 +154,12 @@ void setup_font()
     gconf_client_notify_add(client, SUGAR_FONT_SIZE_KEY,
 			    (GConfClientNotifyFunc)
 			    font_size_changed_callback, NULL, NULL, NULL);
+    gconf_client_notify_add(client, SUGAR_FONT_DPI_KEY,
+			    (GConfClientNotifyFunc)
+			    font_dpi_changed_callback, NULL, NULL, NULL);
 
     update_font();
+    update_font_dpi();
 }
 
 int main(int argc, char **argv)
-- 
1.7.0.4


-- 
   // Bernie Innocenti - http://codewiz.org/
 \X/  Sugar Labs       - http://sugarlabs.org/



More information about the Sugar-devel mailing list