From 27ce2df1ef6f8606c082137a2132f4be535572f4 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 2 Jul 2015 19:11:27 +0200 Subject: gnome-rr: Add dpms-mode information in debug When the DPMS mode changes, print the new value. --- libgnome-desktop/gnome-rr-debug.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/libgnome-desktop/gnome-rr-debug.c b/libgnome-desktop/gnome-rr-debug.c index 682e721e..16d841e5 100644 --- a/libgnome-desktop/gnome-rr-debug.c +++ b/libgnome-desktop/gnome-rr-debug.c @@ -25,6 +25,25 @@ #include #include +static const char * +dpms_mode_to_str (GnomeRRDpmsMode mode) +{ + switch (mode) { + case GNOME_RR_DPMS_ON: + return "on"; + case GNOME_RR_DPMS_STANDBY: + return "standby"; + case GNOME_RR_DPMS_SUSPEND: + return "suspend"; + case GNOME_RR_DPMS_OFF: + return "off"; + case GNOME_RR_DPMS_UNKNOWN: + return "unknown"; + default: + g_assert_not_reached (); + } +} + static void print_output (GnomeRROutput *output, const char *message) { @@ -92,6 +111,16 @@ output_connected (GnomeRRScreen *screen, GnomeRROutput *output, gpointer user_da print_output (output, "connected"); } +static void +dpms_mode_changed (GnomeRRScreen *screen, GParamSpec *pspec, gpointer user_data) +{ + GnomeRRDpmsMode mode; + + gnome_rr_screen_get_dpms_mode (screen, &mode, NULL); + g_print ("DPMS mode changed to: %s\n", dpms_mode_to_str (mode)); + g_print ("\n"); +} + /** * main: **/ @@ -117,6 +146,7 @@ main (int argc, char *argv[]) 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); + g_signal_connect (screen, "notify::dpms-mode", G_CALLBACK (dpms_mode_changed), NULL); gtk_main (); -- cgit v1.2.1