Show which monitor is being edited in the 'Monitor' label

2008-12-15  Federico Mena Quintero  <federico@novell.com>

	* display-capplet.glade: Put the "Monitor" label inside an event
	box, so we can change the background color of the event box.  Give
	names to both widgets: current_monitor_label,
	current_monitor_event_box.

	* xrandr-capplet.c (rebuild_gui): When a monitor is selected,
	update the "Monitor" label to include the monitor's name and color
	so the user will know which monitor he is editing.
	(rebuild_current_monitor_label): New function.
	(struct App): New fields current_monitor_label,
	current_monitor_event_box.

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

svn path=/trunk/; revision=9168
This commit is contained in:
Federico Mena Quintero 2008-12-15 18:59:57 +00:00 committed by Federico Mena Quintero
parent ded9c324a5
commit 42da2562f5
3 changed files with 76 additions and 15 deletions

View file

@ -1,3 +1,17 @@
2008-12-15 Federico Mena Quintero <federico@novell.com>
* display-capplet.glade: Put the "Monitor" label inside an event
box, so we can change the background color of the event box. Give
names to both widgets: current_monitor_label,
current_monitor_event_box.
* xrandr-capplet.c (rebuild_gui): When a monitor is selected,
update the "Monitor" label to include the monitor's name and color
so the user will know which monitor he is editing.
(rebuild_current_monitor_label): New function.
(struct App): New fields current_monitor_label,
current_monitor_event_box.
2008-12-12 Federico Mena Quintero <federico@novell.com> 2008-12-12 Federico Mena Quintero <federico@novell.com>
https://bugzilla.novell.com/show_bug.cgi?id=381030 - Prettify the https://bugzilla.novell.com/show_bug.cgi?id=381030 - Prettify the

View file

@ -183,22 +183,30 @@
</child> </child>
<child> <child>
<widget class="GtkLabel" id="label7"> <widget class="GtkEventBox" id="current_monitor_event_box">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Monitor&lt;/b&gt;</property> <property name="visible_window">True</property>
<property name="use_underline">False</property> <property name="above_child">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <child>
<property name="wrap">False</property> <widget class="GtkLabel" id="current_monitor_label">
<property name="selectable">False</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="label" translatable="yes">&lt;b&gt;Monitor&lt;/b&gt;</property>
<property name="yalign">0.5</property> <property name="use_underline">False</property>
<property name="xpad">0</property> <property name="use_markup">True</property>
<property name="ypad">0</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> <property name="wrap">False</property>
<property name="width_chars">-1</property> <property name="selectable">False</property>
<property name="single_line_mode">False</property> <property name="xalign">0</property>
<property name="angle">0</property> <property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>

View file

@ -47,6 +47,8 @@ struct App
GnomeOutputInfo *current_output; GnomeOutputInfo *current_output;
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *current_monitor_event_box;
GtkWidget *current_monitor_label;
GtkListStore *resolution_store; GtkListStore *resolution_store;
GtkWidget *resolution_combo; GtkWidget *resolution_combo;
GtkWidget *refresh_combo; GtkWidget *refresh_combo;
@ -446,6 +448,39 @@ count_all_outputs (GnomeRRConfig *config)
} }
#endif #endif
static void
rebuild_current_monitor_label (App *app)
{
char *str;
gboolean free_str;
GdkColor color;
gboolean use_color;
if (app->current_output)
{
str = g_strdup_printf (_("<b>Monitor: %s</b>"), app->current_output->display_name);
free_str = TRUE;
gnome_rr_labeler_get_color_for_output (app->labeler, app->current_output, &color);
use_color = TRUE;
}
else
{
str = _("<b>Monitor</b>");
free_str = FALSE;
use_color = FALSE;
}
gtk_label_set_markup (GTK_LABEL (app->current_monitor_label), str);
if (free_str)
g_free (str);
if (use_color)
gtk_widget_modify_bg (app->current_monitor_event_box, app->current_monitor_event_box->state, &color);
gtk_event_box_set_visible_window (GTK_EVENT_BOX (app->current_monitor_event_box), use_color);
}
static void static void
rebuild_resolution_combo (App *app) rebuild_resolution_combo (App *app)
{ {
@ -520,6 +555,7 @@ rebuild_gui (App *app)
g_debug ("rebuild gui, is on: %d", app->current_output->on); g_debug ("rebuild gui, is on: %d", app->current_output->on);
#endif #endif
rebuild_current_monitor_label (app);
rebuild_resolution_combo (app); rebuild_resolution_combo (app);
rebuild_rate_combo (app); rebuild_rate_combo (app);
rebuild_rotation_combo (app); rebuild_rotation_combo (app);
@ -1722,6 +1758,9 @@ run_application (App *app)
gtk_window_set_icon_name (GTK_WINDOW (app->dialog), gtk_window_set_icon_name (GTK_WINDOW (app->dialog),
"gnome-display-properties"); "gnome-display-properties");
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->resolution_combo = glade_xml_get_widget (xml, "resolution_combo"); app->resolution_combo = glade_xml_get_widget (xml, "resolution_combo");
g_signal_connect (app->resolution_combo, "changed", g_signal_connect (app->resolution_combo, "changed",
G_CALLBACK (on_resolution_changed), app); G_CALLBACK (on_resolution_changed), app);