From 42da2562f54eb11f2ef1ebfffe545a3931163e12 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Mon, 15 Dec 2008 18:59:57 +0000 Subject: [PATCH] Show which monitor is being edited in the 'Monitor' label 2008-12-15 Federico Mena Quintero * 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 svn path=/trunk/; revision=9168 --- capplets/display/ChangeLog | 14 +++++++++ capplets/display/display-capplet.glade | 38 +++++++++++++++---------- capplets/display/xrandr-capplet.c | 39 ++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 15 deletions(-) diff --git a/capplets/display/ChangeLog b/capplets/display/ChangeLog index 8b5e91907..8f6a3e5ed 100644 --- a/capplets/display/ChangeLog +++ b/capplets/display/ChangeLog @@ -1,3 +1,17 @@ +2008-12-15 Federico Mena Quintero + + * 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 https://bugzilla.novell.com/show_bug.cgi?id=381030 - Prettify the diff --git a/capplets/display/display-capplet.glade b/capplets/display/display-capplet.glade index 55abf46d5..6c68f6c4b 100644 --- a/capplets/display/display-capplet.glade +++ b/capplets/display/display-capplet.glade @@ -183,22 +183,30 @@ - + True - <b>Monitor</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + True + False + + + + True + <b>Monitor</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + 0 diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c index bce2d3800..0177c43e4 100644 --- a/capplets/display/xrandr-capplet.c +++ b/capplets/display/xrandr-capplet.c @@ -47,6 +47,8 @@ struct App GnomeOutputInfo *current_output; GtkWidget *dialog; + GtkWidget *current_monitor_event_box; + GtkWidget *current_monitor_label; GtkListStore *resolution_store; GtkWidget *resolution_combo; GtkWidget *refresh_combo; @@ -446,6 +448,39 @@ count_all_outputs (GnomeRRConfig *config) } #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 (_("Monitor: %s"), 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 = _("Monitor"); + 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 rebuild_resolution_combo (App *app) { @@ -520,6 +555,7 @@ rebuild_gui (App *app) g_debug ("rebuild gui, is on: %d", app->current_output->on); #endif + rebuild_current_monitor_label (app); rebuild_resolution_combo (app); rebuild_rate_combo (app); rebuild_rotation_combo (app); @@ -1722,6 +1758,9 @@ run_application (App *app) gtk_window_set_icon_name (GTK_WINDOW (app->dialog), "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"); g_signal_connect (app->resolution_combo, "changed", G_CALLBACK (on_resolution_changed), app);