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



commit 201714d99a8219ccb4d7470769fb953fcbfebe57
Author: Robert Ancell <robert ancell canonical com>
Date:   Mon May 2 15:59:50 2011 +1000

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

 panels/display/xrandr-capplet.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/panels/display/xrandr-capplet.c b/panels/display/xrandr-capplet.c
index b4ce00d..e29c2fd 100644
--- a/panels/display/xrandr-capplet.c
+++ b/panels/display/xrandr-capplet.c
@@ -171,6 +171,10 @@ 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);
+  else
+     gnome_rr_labeler_hide (app->labeler);
 
   select_current_output_from_dialog_position (app);
 }
@@ -2373,6 +2377,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 +2500,10 @@ run_application (void)
   app->clock_settings = g_settings_new (CLOCK_SCHEMA);
 
   app->panel = _gtk_builder_get_widget (builder, "display-panel");
+  g_signal_connect (app->panel, "focus-in-event",
+                    G_CALLBACK (dialog_focus_in_cb), app);
+  g_signal_connect (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]