Blob Blame History Raw
From 01e6bb8657fbc6571c5c550d7d0053e0b2381ed9 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@redhat.com>
Date: Thu, 27 Mar 2014 17:24:33 +0100
Subject: [PATCH] display: Make the Apply button insensitive for invalid
 configuration

If the configuration is not applicable, due to HW constraints we know
about, make the button insensitive, to avoid an error dialog later on.

https://bugzilla.redhat.com/show_bug.cgi?id=840913
---
 panels/display/cc-display-panel.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 8210750..db046f2 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -88,6 +88,7 @@ struct _CcDisplayPanelPrivate
   GtkWidget      *clone_checkbox;
   GtkWidget      *clone_label;
   GtkWidget      *show_icon_checkbox;
+  GtkWidget      *apply_button;
 
   /* We store the event timestamp when the Apply button is clicked */
   guint32         apply_button_clicked_timestamp;
@@ -864,6 +865,8 @@ rebuild_resolution_combo (CcDisplayPanel *self)
 static void
 rebuild_gui (CcDisplayPanel *self)
 {
+  gboolean apply_sensitive;
+
   /* We would break spectacularly if we recursed, so
    * just assert if that happens
    */
@@ -877,6 +880,9 @@ rebuild_gui (CcDisplayPanel *self)
   rebuild_resolution_combo (self);
   rebuild_rotation_combo (self);
 
+  apply_sensitive = gnome_rr_config_applicable (self->priv->current_configuration, self->priv->screen, NULL);
+  gtk_widget_set_sensitive (self->priv->apply_button, apply_sensitive);
+
   self->priv->ignore_gui_changes = FALSE;
 }
 
@@ -2735,7 +2741,8 @@ cc_display_panel_constructor (GType                  gtype,
 
   on_screen_changed (self->priv->screen, self);
 
-  g_signal_connect_swapped (WID ("apply_button"),
+  self->priv->apply_button = WID ("apply_button");
+  g_signal_connect_swapped (self->priv->apply_button,
                             "clicked", G_CALLBACK (apply), self);
 
   gtk_widget_show (self->priv->panel);
-- 
1.8.5.3