[gnome-control-center] display: Show aspect ratios with resolutions



commit 520598e7625e14e5cda691553bd0e0d54b41736f
Author: Kees Cook <kees outflux net>
Date:   Tue Nov 9 14:02:57 2010 +0100

    display: Show aspect ratios with resolutions

 panels/display/xrandr-capplet.c |   40 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/panels/display/xrandr-capplet.c b/panels/display/xrandr-capplet.c
index fe771ee..cbb5db6 100644
--- a/panels/display/xrandr-capplet.c
+++ b/panels/display/xrandr-capplet.c
@@ -586,7 +586,45 @@ rebuild_on_off_radios (App *app)
 static char *
 make_resolution_string (int width, int height)
 {
-    return g_strdup_printf (_("%d x %d"), width, height);
+    int ratio;
+    const char *aspect = NULL;
+
+    if (width && height) {
+	if (width > height)
+	    ratio = width * 10 / height;
+	else
+	    ratio = height * 10 / width;
+
+	switch (ratio) {
+	case 13:
+	    aspect = "4:3";
+            break;
+        case 16:
+            aspect = "16:10";
+            break;
+        case 17:
+            aspect = "16:9";
+            break;
+        case 12:
+            aspect = "5:4";
+            break;
+	// This catches 1.5625 as well (1600x1024) when maybe it shouldn't.
+        case 15:
+            aspect = "3:2";
+            break;
+        case 18:
+            aspect = "9:5";
+            break;
+        case 10:
+            aspect = "1:1";
+            break;
+	}
+    }
+
+    if (aspect != NULL)
+        return g_strdup_printf (_("%d x %d (%s)"), width, height, aspect);
+    else
+        return g_strdup_printf (_("%d x %d"), width, height);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]