[gnome-desktop/gnome-3-12] gnome-rr: Better debug application



commit 41afb698d1477060202f55c1e4731005dffa14e4
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Apr 25 18:22:04 2014 +0200

    gnome-rr: Better debug application
    
    This change will make the debug application listen for changes and print
    them as they occur.
    
    Conflicts:
        libgnome-desktop/gnome-rr-debug.c

 libgnome-desktop/gnome-rr-debug.c |   74 +++++++++++++++++++++++++++---------
 1 files changed, 55 insertions(+), 19 deletions(-)
---
diff --git a/libgnome-desktop/gnome-rr-debug.c b/libgnome-desktop/gnome-rr-debug.c
index 2f2bec4..6d808cb 100644
--- a/libgnome-desktop/gnome-rr-debug.c
+++ b/libgnome-desktop/gnome-rr-debug.c
@@ -25,14 +25,60 @@
 #include <gtk/gtk.h>
 #include <libgnome-desktop/gnome-rr.h>
 
+static void
+print_output (GnomeRROutput *output, const char *message)
+{
+       gsize len = 0;
+       const guint8 *result = NULL;
+       int width_mm, height_mm;
+
+       g_print ("[%s]", gnome_rr_output_get_name (output));
+       if (message)
+               g_print (" (%s)", message);
+       g_print ("\n");
+       g_print ("\tconnected: %i\n", 1);
+       g_print ("\tbuiltin (laptop): %i\n", gnome_rr_output_is_builtin_display (output));
+       g_print ("\tprimary: %i\n", gnome_rr_output_get_is_primary (output));
+       g_print ("\tid: %i\n", gnome_rr_output_get_id (output));
+       gnome_rr_output_get_physical_size (output, &width_mm, &height_mm);
+       g_print ("\tdimensions: %ix%i", width_mm, height_mm);
+
+       /* get EDID */
+        result = gnome_rr_output_get_edid_data (output, &len);
+       if (result != NULL) {
+               g_print ("\tedid: %" G_GSIZE_FORMAT " bytes [%i:%i:%i:%i]\n",
+                        len, result[0], result[1],
+                        result[2], result[3]);
+       }
+}
+
+static void
+screen_changed (GnomeRRScreen *screen, gpointer user_data)
+{
+       g_print ("Screen changed\n");
+}
+
+static void
+output_disconnected (GnomeRRScreen *screen, GnomeRROutput *output, gpointer user_data)
+{
+       print_output (output, "disconnected");
+}
+
+static void
+output_connected (GnomeRRScreen *screen, GnomeRROutput *output, gpointer user_data)
+{
+       print_output (output, "connected");
+}
+
+/**
+ * main:
+ **/
 int
 main (int argc, char *argv[])
 {
        GError *error = NULL;
        GnomeRROutput **outputs;
        GnomeRRScreen *screen;
-       gsize len = 0;
-       const guint8 *result = NULL;
        guint i;
 
        gtk_init (&argc, &argv);
@@ -43,25 +89,15 @@ main (int argc, char *argv[])
                goto out;
        }
        outputs = gnome_rr_screen_list_outputs (screen);
-       for (i = 0; outputs[i] != NULL; i++) {
-               int width_mm, height_mm;
+       for (i = 0; outputs[i] != NULL; i++)
+               print_output (outputs[i], NULL);
 
-               g_print ("[%s]\n", gnome_rr_output_get_name (outputs[i]));
-               g_print ("\tconnected: %i\n", 1);
-               g_print ("\tbuilt-in: %i\n", gnome_rr_output_is_builtin_display (outputs[i]));
-               g_print ("\tprimary: %i\n", gnome_rr_output_get_is_primary (outputs[i]));
-               g_print ("\tid: %i\n", gnome_rr_output_get_id (outputs[i]));
-               gnome_rr_output_get_physical_size (outputs[i], &width_mm, &height_mm);
-               g_print ("\tdimensions: %ix%i", width_mm, height_mm);
+       g_signal_connect (screen, "changed", G_CALLBACK (screen_changed), NULL);
+       g_signal_connect (screen, "output-disconnected", G_CALLBACK (output_disconnected), NULL);
+       g_signal_connect (screen, "output-connected", G_CALLBACK (output_connected), NULL);
+
+       gtk_main ();
 
-               /* get EDID (first try) */
-                result = gnome_rr_output_get_edid_data (outputs[i], &len);
-               if (result != NULL) {
-                       g_print ("\tedid: %" G_GSIZE_FORMAT " bytes [%i:%i:%i:%i]\n",
-                                len, result[0], result[1],
-                                result[2], result[3]);
-               }
-       }
 out:
        g_object_unref (screen);
        return 0;


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