From 7c89e30a4745d8c0486c9071dd11e65a8647f7db Mon Sep 17 00:00:00 2001 From: Rui Matos Date: Wed, 2 Aug 2017 22:44:50 +0200 Subject: [PATCH] display: Add some signals to the new configuration API These will be useful to keep track of changes across different places in the new UI. https://bugzilla.gnome.org/show_bug.cgi?id=785949 --- panels/display/cc-display-config-dbus.c | 14 +++++++++++++- panels/display/cc-display-config-rr.c | 14 +++++++++++--- panels/display/cc-display-config.c | 25 +++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/panels/display/cc-display-config-dbus.c b/panels/display/cc-display-config-dbus.c index ca657b090..d8f1798ac 100644 --- a/panels/display/cc-display-config-dbus.c +++ b/panels/display/cc-display-config-dbus.c @@ -448,6 +448,8 @@ cc_display_monitor_dbus_set_active (CcDisplayMonitor *pself, cc_display_monitor_dbus_set_logical_monitor (self, NULL); cc_display_config_dbus_ensure_gapless (self->config); } + + g_signal_emit_by_name (self, "active"); } static CcDisplayRotation @@ -476,6 +478,8 @@ cc_display_monitor_dbus_set_rotation (CcDisplayMonitor *pself, /* See comment in ensure_gapless() for why we disregard the existing layout here. */ cc_display_config_dbus_make_linear (self->config); + + g_signal_emit_by_name (self, "rotation"); } } @@ -662,6 +666,8 @@ cc_display_monitor_dbus_set_mode (CcDisplayMonitor *pself, if (!cc_display_mode_dbus_is_supported_scale (mode, cc_display_monitor_get_scale (pself))) cc_display_monitor_set_scale (pself, cc_display_mode_get_preferred_scale (mode)); + + g_signal_emit_by_name (self, "mode"); } static void @@ -1095,10 +1101,16 @@ cc_display_config_dbus_set_primary (CcDisplayConfigDBus *self, return; if (self->primary && self->primary->logical_monitor) - self->primary->logical_monitor->primary = FALSE; + { + self->primary->logical_monitor->primary = FALSE; + g_signal_emit_by_name (self->primary, "primary"); + } self->primary = new_primary; self->primary->logical_monitor->primary = TRUE; + + g_signal_emit_by_name (self->primary, "primary"); + g_signal_emit_by_name (self, "primary"); } static void diff --git a/panels/display/cc-display-config-rr.c b/panels/display/cc-display-config-rr.c index 87af97c51..945d30792 100644 --- a/panels/display/cc-display-config-rr.c +++ b/panels/display/cc-display-config-rr.c @@ -215,7 +215,8 @@ cc_display_monitor_rr_set_active (CcDisplayMonitor *pself, { CcDisplayMonitorRR *self = CC_DISPLAY_MONITOR_RR (pself); - return gnome_rr_output_info_set_active (self->output_info, active); + gnome_rr_output_info_set_active (self->output_info, active); + g_signal_emit_by_name (self, "active"); } static CcDisplayRotation @@ -237,8 +238,9 @@ cc_display_monitor_rr_set_rotation (CcDisplayMonitor *pself, { CcDisplayMonitorRR *self = CC_DISPLAY_MONITOR_RR (pself); - return gnome_rr_output_info_set_rotation (self->output_info, - rotation_map[rotation]); + gnome_rr_output_info_set_rotation (self->output_info, + rotation_map[rotation]); + g_signal_emit_by_name (self, "rotation"); } static gboolean @@ -339,6 +341,7 @@ cc_display_monitor_rr_set_mode (CcDisplayMonitor *pself, gnome_rr_output_info_set_refresh_rate (self->output_info, cc_display_mode_get_freq (mode)); + g_signal_emit_by_name (self, "mode"); } static void @@ -475,8 +478,13 @@ cc_display_config_rr_set_primary (CcDisplayConfigRR *self, return; gnome_rr_output_info_set_primary (self->primary->output_info, FALSE); + g_signal_emit_by_name (self->primary, "primary"); + self->primary = new_primary; gnome_rr_output_info_set_primary (self->primary->output_info, TRUE); + g_signal_emit_by_name (self->primary, "primary"); + + g_signal_emit_by_name (self, "primary"); } static void diff --git a/panels/display/cc-display-config.c b/panels/display/cc-display-config.c index 6a854d650..aee1efe06 100644 --- a/panels/display/cc-display-config.c +++ b/panels/display/cc-display-config.c @@ -82,6 +82,26 @@ cc_display_monitor_init (CcDisplayMonitor *self) static void cc_display_monitor_class_init (CcDisplayMonitorClass *klass) { + g_signal_new ("rotation", + CC_TYPE_DISPLAY_MONITOR, + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 0); + g_signal_new ("mode", + CC_TYPE_DISPLAY_MONITOR, + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 0); + g_signal_new ("primary", + CC_TYPE_DISPLAY_MONITOR, + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 0); + g_signal_new ("active", + CC_TYPE_DISPLAY_MONITOR, + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 0); } const char * @@ -237,6 +257,11 @@ cc_display_config_init (CcDisplayConfig *self) static void cc_display_config_class_init (CcDisplayConfigClass *klass) { + g_signal_new ("primary", + CC_TYPE_DISPLAY_CONFIG, + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 0); } GList *