diff options
author | Bastien Nocera <hadess@hadess.net> | 2014-04-25 18:22:04 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2014-04-25 18:29:39 +0200 |
commit | d160aac0d96c627b79212c15a426a8dab417b6b5 (patch) | |
tree | 0fa797eb5648dcf16b852c1d32d7838853614f20 /libgnome-desktop | |
parent | e6ba67b4de48db96a006829e9d326b06c9d4ba9f (diff) | |
download | gnome-desktop-d160aac0d96c627b79212c15a426a8dab417b6b5.tar.gz |
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
Diffstat (limited to 'libgnome-desktop')
-rw-r--r-- | 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 2f2bec4f..6d808cb0 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; |