[gnome-control-center/wip/benzea/display-settings-widget: 16/18] display: Track currently applied configuration



commit c48c6d95daa85d7e63f69179943bff163de241ab
Author: Benjamin Berg <bberg redhat com>
Date:   Tue Jan 22 13:50:03 2019 +0100

    display: Track currently applied configuration
    
    This is going to be used to do reasonably accurate display scaling
    previews.

 panels/display/cc-display-panel.c    | 11 +++++++----
 panels/display/cc-display-settings.c | 35 +++++++++++++++++++++++++++++++++++
 panels/display/cc-display-settings.h |  3 +++
 3 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index bb574c5c9..f0408d3b9 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -61,6 +61,7 @@ struct _CcDisplayPanel
 
   CcDisplayConfigManager *manager;
   CcDisplayConfig *current_config;
+  CcDisplayConfig *applied_config;
   CcDisplayMonitor *current_output;
 
   gboolean              rebuilding;
@@ -441,6 +442,7 @@ cc_display_panel_dispose (GObject *object)
     }
 
   g_clear_object (&self->manager);
+  g_clear_object (&self->applied_config);
   g_clear_object (&self->current_config);
   g_clear_object (&self->up_client);
   g_clear_object (&self->settings_color);
@@ -845,6 +847,10 @@ on_screen_changed (CcDisplayPanel *panel)
 
   reset_titlebar (panel);
 
+  g_clear_object (&panel->applied_config);
+  panel->applied_config = cc_display_config_manager_get_current (panel->manager);
+  cc_display_settings_set_applied_config (panel->settings, panel->applied_config);
+
   reset_current_config (panel);
   rebuild_ui (panel);
 
@@ -924,12 +930,9 @@ static void
 update_apply_button (CcDisplayPanel *panel)
 {
   gboolean config_equal;
-  g_autoptr(CcDisplayConfig) applied_config = NULL;
-
-  applied_config = cc_display_config_manager_get_current (panel->manager);
 
   config_equal = cc_display_config_equal (panel->current_config,
-                                          applied_config);
+                                          panel->applied_config);
 
   if (config_equal)
     reset_titlebar (panel);
diff --git a/panels/display/cc-display-settings.c b/panels/display/cc-display-settings.c
index 58a308e2b..78ae077b5 100644
--- a/panels/display/cc-display-settings.c
+++ b/panels/display/cc-display-settings.c
@@ -41,6 +41,7 @@ struct _CcDisplaySettings
 
   gboolean          has_accelerometer;
   CcDisplayConfig  *config;
+  CcDisplayConfig  *applied_config;
   CcDisplayMonitor *selected_output;
 
   GListStore       *orientation_list;
@@ -63,6 +64,7 @@ enum {
   PROP_0,
   PROP_HAS_ACCELEROMETER,
   PROP_CONFIG,
+  PROP_APPLIED_CONFIG,
   PROP_SELECTED_OUTPUT,
   PROP_LAST
 };
@@ -566,6 +568,10 @@ cc_display_settings_get_property (GObject    *object,
       g_value_set_object (value, self->config);
       break;
 
+    case PROP_APPLIED_CONFIG:
+      g_value_set_object (value, self->applied_config);
+      break;
+
     case PROP_SELECTED_OUTPUT:
       g_value_set_object (value, self->selected_output);
       break;
@@ -593,6 +599,10 @@ cc_display_settings_set_property (GObject      *object,
       cc_display_settings_set_config (self, g_value_get_object (value));
       break;
 
+    case PROP_APPLIED_CONFIG:
+      cc_display_settings_set_applied_config (self, g_value_get_object (value));
+      break;
+
     case PROP_SELECTED_OUTPUT:
       cc_display_settings_set_selected_output (self, g_value_get_object (value));
       break;
@@ -608,6 +618,7 @@ cc_display_settings_finalize (GObject *object)
   CcDisplaySettings *self = CC_DISPLAY_SETTINGS (object);
 
   g_clear_object (&self->config);
+  g_clear_object (&self->applied_config);
 
   g_clear_object (&self->orientation_list);
   g_clear_object (&self->refresh_rate_list);
@@ -645,6 +656,12 @@ cc_display_settings_class_init (CcDisplaySettingsClass *klass)
                          CC_TYPE_DISPLAY_CONFIG,
                          G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
 
+  props[PROP_APPLIED_CONFIG] =
+    g_param_spec_object ("applied-config", "Applied Display Config",
+                         "The currently active display configuration",
+                         CC_TYPE_DISPLAY_CONFIG,
+                         G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+
   props[PROP_SELECTED_OUTPUT] =
     g_param_spec_object ("selected-output", "Selected Output",
                          "The output that is currently selected on the configuration",
@@ -780,6 +797,24 @@ cc_display_settings_set_config (CcDisplaySettings *self,
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CONFIG]);
 }
 
+CcDisplayConfig*
+cc_display_settings_get_applied_config (CcDisplaySettings *self)
+{
+  return self->applied_config;
+}
+
+void
+cc_display_settings_set_applied_config (CcDisplaySettings *self,
+                                        CcDisplayConfig   *config)
+{
+  g_clear_object (&self->applied_config);
+  self->applied_config = g_object_ref (config);
+
+  cc_display_settings_rebuild_ui (self);
+
+  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_APPLIED_CONFIG]);
+}
+
 CcDisplayMonitor*
 cc_display_settings_get_selected_output (CcDisplaySettings *self)
 {
diff --git a/panels/display/cc-display-settings.h b/panels/display/cc-display-settings.h
index 58709ddf7..31982d934 100644
--- a/panels/display/cc-display-settings.h
+++ b/panels/display/cc-display-settings.h
@@ -36,6 +36,9 @@ void                cc_display_settings_set_has_accelerometer (CcDisplaySettings
 CcDisplayConfig*    cc_display_settings_get_config            (CcDisplaySettings    *settings);
 void                cc_display_settings_set_config            (CcDisplaySettings    *settings,
                                                                CcDisplayConfig      *config);
+CcDisplayConfig*    cc_display_settings_get_applied_config    (CcDisplaySettings    *settings);
+void                cc_display_settings_set_applied_config    (CcDisplaySettings    *settings,
+                                                               CcDisplayConfig      *config);
 CcDisplayMonitor*   cc_display_settings_get_selected_output   (CcDisplaySettings    *settings);
 void                cc_display_settings_set_selected_output   (CcDisplaySettings    *settings,
                                                                CcDisplayMonitor     *output);


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