gnome-control-center r9186 - trunk/capplets/display



Author: federico
Date: Wed Jan  7 23:27:49 2009
New Revision: 9186
URL: http://svn.gnome.org/viewvc/gnome-control-center?rev=9186&view=rev

Log:
bnc433939 - Add On/Off radio buttons for the monitors
2008-12-18  Federico Mena Quintero  <federico novell com>

	https://bugzilla.novell.com/show_bug.cgi?id=433939 - It's not
	obvious how to turn on a new monitor.

	* display-capplet.glade: Add On/Off radio buttons for the selected
	monitor, as it is hard to find that the on/off state is actually
	set by the Resolution combo.

	* xrandr-capplet.c (rebuild_gui): Don't set sensitivity of
	resolution_combo here...
	(rebuild_resolution_combo): ... but do it here instead.  This is
	so that we can match the state of the monitor on/off buttons.
	(rebuild_on_off_radios): New function.  We set the on/off radio
	buttons based on the "on" state of the current output.
	(monitor_on_off_toggled_cb): New callback; we toggle the current
	output's on/off state.

Signed-off-by: Federico Mena Quintero <federico novell com>

Modified:
   trunk/capplets/display/ChangeLog
   trunk/capplets/display/display-capplet.glade
   trunk/capplets/display/xrandr-capplet.c

Modified: trunk/capplets/display/display-capplet.glade
==============================================================================
--- trunk/capplets/display/display-capplet.glade	(original)
+++ trunk/capplets/display/display-capplet.glade	Wed Jan  7 23:27:49 2009
@@ -218,7 +218,7 @@
 	  <child>
 	    <widget class="GtkTable" id="table1">
 	      <property name="visible">True</property>
-	      <property name="n_rows">2</property>
+	      <property name="n_rows">3</property>
 	      <property name="n_columns">5</property>
 	      <property name="homogeneous">False</property>
 	      <property name="row_spacing">6</property>
@@ -238,8 +238,8 @@
 		<packing>
 		  <property name="left_attach">3</property>
 		  <property name="right_attach">5</property>
-		  <property name="top_attach">0</property>
-		  <property name="bottom_attach">1</property>
+		  <property name="top_attach">1</property>
+		  <property name="bottom_attach">2</property>
 		  <property name="x_options">shrink|fill</property>
 		  <property name="y_options"></property>
 		</packing>
@@ -266,8 +266,8 @@
 		<packing>
 		  <property name="left_attach">1</property>
 		  <property name="right_attach">2</property>
-		  <property name="top_attach">0</property>
-		  <property name="bottom_attach">1</property>
+		  <property name="top_attach">1</property>
+		  <property name="bottom_attach">2</property>
 		  <property name="x_options">shrink|fill</property>
 		  <property name="y_options"></property>
 		</packing>
@@ -294,8 +294,8 @@
 		<packing>
 		  <property name="left_attach">1</property>
 		  <property name="right_attach">2</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
+		  <property name="top_attach">2</property>
+		  <property name="bottom_attach">3</property>
 		  <property name="x_options">shrink|fill</property>
 		  <property name="y_options"></property>
 		</packing>
@@ -322,8 +322,8 @@
 		<packing>
 		  <property name="left_attach">3</property>
 		  <property name="right_attach">4</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
+		  <property name="top_attach">2</property>
+		  <property name="bottom_attach">3</property>
 		  <property name="x_options">shrink|fill</property>
 		  <property name="y_options"></property>
 		</packing>
@@ -338,8 +338,8 @@
 		<packing>
 		  <property name="left_attach">2</property>
 		  <property name="right_attach">3</property>
-		  <property name="top_attach">0</property>
-		  <property name="bottom_attach">1</property>
+		  <property name="top_attach">1</property>
+		  <property name="bottom_attach">2</property>
 		  <property name="x_options">expand|shrink|fill</property>
 		  <property name="y_options"></property>
 		</packing>
@@ -354,8 +354,8 @@
 		<packing>
 		  <property name="left_attach">2</property>
 		  <property name="right_attach">3</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
+		  <property name="top_attach">2</property>
+		  <property name="bottom_attach">3</property>
 		  <property name="y_options"></property>
 		</packing>
 	      </child>
@@ -374,8 +374,8 @@
 		<packing>
 		  <property name="left_attach">4</property>
 		  <property name="right_attach">5</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
+		  <property name="top_attach">2</property>
+		  <property name="bottom_attach">3</property>
 		  <property name="y_options"></property>
 		</packing>
 	      </child>
@@ -400,7 +400,62 @@
 		  <property name="left_attach">0</property>
 		  <property name="right_attach">1</property>
 		  <property name="top_attach">0</property>
-		  <property name="bottom_attach">2</property>
+		  <property name="bottom_attach">3</property>
+		  <property name="y_options">fill</property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkHBox" id="hbox2">
+		  <property name="visible">True</property>
+		  <property name="homogeneous">False</property>
+		  <property name="spacing">12</property>
+
+		  <child>
+		    <widget class="GtkRadioButton" id="monitor_on_radio">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes">On</property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkRadioButton" id="monitor_off_radio">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes">Off</property>
+		      <property name="use_underline">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+		      <property name="active">False</property>
+		      <property name="inconsistent">False</property>
+		      <property name="draw_indicator">True</property>
+		      <property name="group">monitor_on_radio</property>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">5</property>
+		  <property name="top_attach">0</property>
+		  <property name="bottom_attach">1</property>
+		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
 	      </child>

Modified: trunk/capplets/display/xrandr-capplet.c
==============================================================================
--- trunk/capplets/display/xrandr-capplet.c	(original)
+++ trunk/capplets/display/xrandr-capplet.c	Wed Jan  7 23:27:49 2009
@@ -49,6 +49,8 @@
     GtkWidget	   *dialog;
     GtkWidget      *current_monitor_event_box;
     GtkWidget      *current_monitor_label;
+    GtkWidget      *monitor_on_radio;
+    GtkWidget      *monitor_off_radio;
     GtkListStore   *resolution_store;
     GtkWidget	   *resolution_combo;
     GtkWidget	   *refresh_combo;
@@ -66,6 +68,7 @@
 static void on_rate_changed (GtkComboBox *box, gpointer data);
 static gboolean output_overlaps (GnomeOutputInfo *output, GnomeRRConfig *config);
 static void select_current_output_from_dialog_position (App *app);
+static void monitor_on_off_toggled_cb (GtkToggleButton *toggle, gpointer data);
 
 static void
 error_message (App *app, const char *primary_text, const char *secondary_text)
@@ -464,6 +467,45 @@
 }
 
 static void
+rebuild_on_off_radios (App *app)
+{
+    gboolean sensitive;
+    gboolean on_active;
+    gboolean off_active;
+
+    g_signal_handlers_block_by_func (app->monitor_on_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
+    g_signal_handlers_block_by_func (app->monitor_off_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
+
+    if (count_active_outputs (app) <= 1)
+    {
+	sensitive = FALSE;
+	on_active = app->current_output ? app->current_output->on : FALSE;
+	off_active = app->current_output ? !on_active : FALSE;
+    }
+    else if (app->current_output)
+    {
+	sensitive = TRUE;
+	on_active = app->current_output->on;
+	off_active = !on_active;
+    }
+    else
+    {
+	sensitive = FALSE;
+	on_active = FALSE;
+	off_active = FALSE;
+    }
+
+    gtk_widget_set_sensitive (app->monitor_on_radio, sensitive);
+    gtk_widget_set_sensitive (app->monitor_off_radio, sensitive);
+
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->monitor_on_radio), on_active);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->monitor_off_radio), off_active);
+
+    g_signal_handlers_unblock_by_func (app->monitor_on_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
+    g_signal_handlers_unblock_by_func (app->monitor_off_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
+}
+
+static void
 rebuild_resolution_combo (App *app)
 {
     int i;
@@ -474,7 +516,12 @@
     clear_combo (app->resolution_combo);
 
     if (!(modes = get_current_modes (app)))
+    {
+	gtk_widget_set_sensitive (app->resolution_combo, FALSE);
 	return;
+    }
+
+    gtk_widget_set_sensitive (app->resolution_combo, TRUE);
 
     best_w = 0;
     best_h = 0;
@@ -538,12 +585,11 @@
 #endif
 
     rebuild_current_monitor_label (app);
+    rebuild_on_off_radios (app);
     rebuild_resolution_combo (app);
     rebuild_rate_combo (app);
     rebuild_rotation_combo (app);
 
-    gtk_widget_set_sensitive (app->resolution_combo, sensitive);
-
 #if 0
     g_debug ("sensitive: %d, on: %d", sensitive, app->current_output->on);
 #endif
@@ -623,6 +669,34 @@
 }
 
 static void
+monitor_on_off_toggled_cb (GtkToggleButton *toggle, gpointer data)
+{
+    App *app = data;
+    gboolean is_on;
+
+    if (!app->current_output)
+	return;
+
+    if (!gtk_toggle_button_get_active (toggle))
+	return;
+
+    if (GTK_WIDGET (toggle) == app->monitor_on_radio)
+	is_on = TRUE;
+    else if (GTK_WIDGET (toggle) == app->monitor_off_radio)
+	is_on = FALSE;
+    else
+    {
+	g_assert_not_reached ();
+	return;
+    }
+
+    app->current_output->on = is_on;
+
+    rebuild_gui (app);
+    foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
+}
+
+static void
 on_resolution_changed (GtkComboBox *box, gpointer data)
 {
     App *app = data;
@@ -1901,6 +1975,13 @@
     app->current_monitor_event_box = glade_xml_get_widget (xml, "current_monitor_event_box");
     app->current_monitor_label = glade_xml_get_widget (xml, "current_monitor_label");
 
+    app->monitor_on_radio = glade_xml_get_widget (xml, "monitor_on_radio");
+    app->monitor_off_radio = glade_xml_get_widget (xml, "monitor_off_radio");
+    g_signal_connect (app->monitor_on_radio, "toggled",
+		      G_CALLBACK (monitor_on_off_toggled_cb), app);
+    g_signal_connect (app->monitor_off_radio, "toggled",
+		      G_CALLBACK (monitor_on_off_toggled_cb), app);
+
     app->resolution_combo = glade_xml_get_widget (xml, "resolution_combo");
     g_signal_connect (app->resolution_combo, "changed",
 		      G_CALLBACK (on_resolution_changed), app);



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