[gnome-control-center] Only show monitor labels when display applet has focus



commit 3d91e4baaf4cf8977dd83549e979389eb3ba6935
Author: Robert Ancell <robert ancell canonical com>
Date:   Thu Mar 17 15:10:43 2011 +1100

    Only show monitor labels when display applet has focus
    
    https://bugzilla.gnome.org/show_bug.cgi?id=589562

 panels/display/xrandr-capplet.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/panels/display/xrandr-capplet.c b/panels/display/xrandr-capplet.c
index b4ce00d..bb84862 100644
--- a/panels/display/xrandr-capplet.c
+++ b/panels/display/xrandr-capplet.c
@@ -171,6 +171,8 @@ on_screen_changed (GnomeRRScreen *scr,
   }
 
   app->labeler = gnome_rr_labeler_new (app->current_configuration);
+  if (gtk_widget_has_focus (app->panel))
+     gnome_rr_labeler_show (app->labeler);
 
   select_current_output_from_dialog_position (app);
 }
@@ -2373,6 +2375,26 @@ get_output_for_window (GnomeRRConfig *configuration, GdkWindow *window)
 			       win_rect.y + win_rect.height / 2);
 }
 
+static gboolean
+dialog_focus_in_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+  App *app = data;
+
+  if (app->labeler)
+    gnome_rr_labeler_show (app->labeler);
+  return FALSE;
+}
+
+static gboolean
+dialog_focus_out_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+  App *app = data;
+
+  if (app->labeler)
+    gnome_rr_labeler_hide (app->labeler);
+  return FALSE;
+}
+
 static void
 on_toplevel_realized (GtkWidget *widget,
                       App       *app)
@@ -2476,6 +2498,10 @@ run_application (void)
   app->clock_settings = g_settings_new (CLOCK_SCHEMA);
 
   app->panel = _gtk_builder_get_widget (builder, "display-panel");
+  g_signal_connect_after (app->panel, "focus-in-event",
+                          G_CALLBACK (dialog_focus_in_cb), app);
+  g_signal_connect_after (app->panel, "focus-out-event",
+                          G_CALLBACK (dialog_focus_out_cb), app);
 
   if (!app->panel)
     g_warning ("Missing display-panel object");



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