Author: nick
Date: 2009-01-11 14:41:07 +0000 (Sun, 11 Jan 2009)
New Revision: 29153

Modified:
   xfce4-settings/trunk/NEWS
   xfce4-settings/trunk/dialogs/appearance-settings/main.c
Log:
- Set a DPI size based on a calculation when a custom DPI is disabled,
  this instead of the hard-coded 96 DPI.


Modified: xfce4-settings/trunk/NEWS
===================================================================
--- xfce4-settings/trunk/NEWS   2009-01-11 14:26:42 UTC (rev 29152)
+++ xfce4-settings/trunk/NEWS   2009-01-11 14:41:07 UTC (rev 29153)
@@ -15,6 +15,8 @@
 - Review strings.
 - Fully update the appearance dialog when the settings are changed in
   another dialog or with xfconf-query.
+- Set a DPI size based on a calculation when a custom DPI is disabled,
+  this instead of the hard-coded 96 DPI.
 - Translation updates: Basque, Brazilian Portuguese, Catalan, Czech, 
   Finnish, French, German, Greek, Hungarian, Indonesian, Japanese, 
   Norwegian Bokmal, Spanish, Swedish, Turkish, Ukrainian.

Modified: xfce4-settings/trunk/dialogs/appearance-settings/main.c
===================================================================
--- xfce4-settings/trunk/dialogs/appearance-settings/main.c     2009-01-11 
14:26:42 UTC (rev 29152)
+++ xfce4-settings/trunk/dialogs/appearance-settings/main.c     2009-01-11 
14:41:07 UTC (rev 29153)
@@ -43,6 +43,10 @@
 /* Increase this number if new gtk settings have been added */
 #define INITIALIZE_UINT (1)
 
+#define DPI_DEFAULT 96
+#define DPI_MIN     50
+#define DPI_MAX     500
+
 enum
 {
     COLUMN_THEME_NAME,
@@ -447,6 +451,36 @@
     }
 }
 
+static gdouble
+appearance_settings_get_dpi_from_x (void)
+{
+    GdkScreen *screen;
+    gdouble    height_dpi = 0, width_dpi = 0;
+    gint       height_mm, width_mm;
+
+    screen = gdk_screen_get_default ();
+    if (G_LIKELY (screen != NULL))
+    {
+        width_mm = gdk_screen_get_width_mm (screen);
+        if (width_mm >= 1)
+            width_dpi = gdk_screen_get_width (screen) / (width_mm / 25.4);
+        else
+            width_dpi = 0;
+
+        height_mm = gdk_screen_get_height_mm (screen);
+        if (height_mm >= 1)
+            height_dpi = gdk_screen_get_height (screen) / (height_mm / 25.4);
+        else
+            height_dpi = 0;
+    }
+
+    if (width_dpi < DPI_MIN || width_dpi > DPI_MAX
+        || height_dpi < DPI_MIN || height_dpi > DPI_MAX)
+        return DPI_DEFAULT;
+
+    return (width_dpi + height_dpi) / 2.00;
+}
+
 static void
 appearance_settings_from_gtk_settings (void)
 {
@@ -607,7 +641,7 @@
         {
             gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
             gtk_widget_set_sensitive (spin, FALSE);
-            gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), 96);
+            gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), 
appearance_settings_get_dpi_from_x ());
         }
         else
         {

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to