[gdm] Fix showing the correct options for non local displays



commit cdc8f372681dc1430b51130d4fd45ca40e3bae47
Author: William Jon McCann <jmccann redhat com>
Date:   Mon Jun 21 21:15:45 2010 -0400

    Fix showing the correct options for non local displays
    
    Don't use properties in _init before they are set at construction.
    Correct the wrong sense in a conditional.
    
    Fixes bugs introduced by e53b45310bc0b83ab14fdfde1cac6e6ea22d82b7
    https://bugzilla.gnome.org/show_bug.cgi?id=622337

 gui/simple-greeter/gdm-greeter-login-window.c |    3 -
 gui/simple-greeter/gdm-greeter-panel.c        |  212 +++++++++++++------------
 2 files changed, 113 insertions(+), 102 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-greeter-login-window.c b/gui/simple-greeter/gdm-greeter-login-window.c
index 47a8eb6..f4794c8 100644
--- a/gui/simple-greeter/gdm-greeter-login-window.c
+++ b/gui/simple-greeter/gdm-greeter-login-window.c
@@ -486,8 +486,6 @@ switch_mode (GdmGreeterLoginWindow *login_window,
 
                 show_widget (login_window, "auth-input-box", FALSE);
 
-                sensitize_widget (login_window, "disconnect-button", FALSE);
-
                 /*
                  * Although the cancel button is not shown in the selection
                  * dialog, the show_cancel_button flag manages when the
@@ -499,7 +497,6 @@ switch_mode (GdmGreeterLoginWindow *login_window,
                 login_window->priv->show_cancel_button = TRUE;
                 break;
         case MODE_AUTHENTICATION:
-                show_widget (login_window, "disconnect-button", FALSE);
                 default_name = "log-in-button";
                 break;
         default:
diff --git a/gui/simple-greeter/gdm-greeter-panel.c b/gui/simple-greeter/gdm-greeter-panel.c
index 021cd01..f46829e 100644
--- a/gui/simple-greeter/gdm-greeter-panel.c
+++ b/gui/simple-greeter/gdm-greeter-panel.c
@@ -134,10 +134,13 @@ gdm_greeter_panel_set_monitor (GdmGreeterPanel *panel,
 }
 
 static void
-_gdm_greeter_panel_set_display_is_local (GdmGreeterPanel       *panel,
-                                         gboolean               is)
+_gdm_greeter_panel_set_display_is_local (GdmGreeterPanel *panel,
+                                         gboolean         is)
 {
-        panel->priv->display_is_local = is;
+        if (panel->priv->display_is_local != is) {
+                panel->priv->display_is_local = is;
+                g_object_notify (G_OBJECT (panel), "is-local");
+        }
 }
 
 static void
@@ -186,24 +189,6 @@ gdm_greeter_panel_get_property (GObject        *object,
         }
 }
 
-static GObject *
-gdm_greeter_panel_constructor (GType                  type,
-                               guint                  n_construct_properties,
-                               GObjectConstructParam *construct_properties)
-{
-        GdmGreeterPanel      *greeter_panel;
-
-        gdm_profile_start (NULL);
-
-        greeter_panel = GDM_GREETER_PANEL (G_OBJECT_CLASS (gdm_greeter_panel_parent_class)->constructor (type,
-                                                                                                         n_construct_properties,
-                                                                                                         construct_properties));
-
-        gdm_profile_end (NULL);
-
-        return G_OBJECT (greeter_panel);
-}
-
 static void
 gdm_greeter_panel_dispose (GObject *object)
 {
@@ -450,77 +435,6 @@ gdm_greeter_panel_real_hide (GtkWidget *widget)
 }
 
 static void
-gdm_greeter_panel_class_init (GdmGreeterPanelClass *klass)
-{
-        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
-        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
-        object_class->get_property = gdm_greeter_panel_get_property;
-        object_class->set_property = gdm_greeter_panel_set_property;
-        object_class->constructor = gdm_greeter_panel_constructor;
-        object_class->dispose = gdm_greeter_panel_dispose;
-        object_class->finalize = gdm_greeter_panel_finalize;
-
-        widget_class->realize = gdm_greeter_panel_real_realize;
-        widget_class->unrealize = gdm_greeter_panel_real_unrealize;
-        widget_class->size_request = gdm_greeter_panel_real_size_request;
-        widget_class->show = gdm_greeter_panel_real_show;
-        widget_class->hide = gdm_greeter_panel_real_hide;
-
-        signals[LANGUAGE_SELECTED] =
-                g_signal_new ("language-selected",
-                              G_TYPE_FROM_CLASS (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GdmGreeterPanelClass, language_selected),
-                              NULL,
-                              NULL,
-                              g_cclosure_marshal_VOID__STRING,
-                              G_TYPE_NONE,
-                              1, G_TYPE_STRING);
-
-        signals[LAYOUT_SELECTED] =
-                g_signal_new ("layout-selected",
-                              G_TYPE_FROM_CLASS (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GdmGreeterPanelClass, layout_selected),
-                              NULL,
-                              NULL,
-                              g_cclosure_marshal_VOID__STRING,
-                              G_TYPE_NONE,
-                              1, G_TYPE_STRING);
-
-        signals[SESSION_SELECTED] =
-                g_signal_new ("session-selected",
-                              G_TYPE_FROM_CLASS (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GdmGreeterPanelClass, session_selected),
-                              NULL,
-                              NULL,
-                              g_cclosure_marshal_VOID__STRING,
-                              G_TYPE_NONE,
-                              1, G_TYPE_STRING);
-
-        g_object_class_install_property (object_class,
-                                         PROP_MONITOR,
-                                         g_param_spec_int ("monitor",
-                                                           "Xinerama monitor",
-                                                           "The monitor (in terms of Xinerama) which the window is on",
-                                                           0,
-                                                           G_MAXINT,
-                                                           0,
-                                                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-        g_object_class_install_property (object_class,
-                                         PROP_DISPLAY_IS_LOCAL,
-                                         g_param_spec_boolean ("display-is-local",
-                                                               "display is local",
-                                                               "display is local",
-                                                               FALSE,
-                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
-        g_type_class_add_private (klass, sizeof (GdmGreeterPanelPrivate));
-}
-
-static void
 on_language_activated (GdmLanguageOptionWidget *widget,
                        GdmGreeterPanel         *panel)
 {
@@ -808,16 +722,14 @@ on_shutdown_menu_deactivate (GdmGreeterPanel *panel)
 }
 
 static void
-gdm_greeter_panel_init (GdmGreeterPanel *panel)
+setup_panel (GdmGreeterPanel *panel)
 {
         NaTray    *tray;
         GtkWidget *spacer;
-        int padding;
+        int        padding;
 
         gdm_profile_start (NULL);
 
-        panel->priv = GDM_GREETER_PANEL_GET_PRIVATE (panel);
-
         gtk_widget_set_can_focus (GTK_WIDGET (panel), TRUE);
 
         panel->priv->geometry.x      = -1;
@@ -848,7 +760,7 @@ gdm_greeter_panel_init (GdmGreeterPanel *panel)
         spacer = gtk_label_new ("");
         gtk_box_pack_start (GTK_BOX (panel->priv->option_hbox), spacer, TRUE, TRUE, 6);
         gtk_widget_show (spacer);
-    
+
         panel->priv->client = gconf_client_get_default ();
 
         gdm_profile_start ("creating option widget");
@@ -906,7 +818,7 @@ gdm_greeter_panel_init (GdmGreeterPanel *panel)
                 gtk_widget_show (image);
                 gtk_container_add (GTK_CONTAINER (panel->priv->shutdown_button), image);
 
-                if (panel->priv->display_is_local) {
+                if (! panel->priv->display_is_local) {
                         menu_item = gtk_menu_item_new_with_label ("Disconnect");
                         g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (do_disconnect), NULL);
                         gtk_menu_shell_append (GTK_MENU_SHELL (panel->priv->shutdown_menu), menu_item);
@@ -955,6 +867,33 @@ gdm_greeter_panel_init (GdmGreeterPanel *panel)
         gdm_profile_end (NULL);
 }
 
+static GObject *
+gdm_greeter_panel_constructor (GType                  type,
+                               guint                  n_construct_properties,
+                               GObjectConstructParam *construct_properties)
+{
+        GdmGreeterPanel      *greeter_panel;
+
+        gdm_profile_start (NULL);
+
+        greeter_panel = GDM_GREETER_PANEL (G_OBJECT_CLASS (gdm_greeter_panel_parent_class)->constructor (type,
+                                                                                                         n_construct_properties,
+                                                                                                         construct_properties));
+
+        setup_panel (greeter_panel);
+
+        gdm_profile_end (NULL);
+
+        return G_OBJECT (greeter_panel);
+}
+
+static void
+gdm_greeter_panel_init (GdmGreeterPanel *panel)
+{
+        panel->priv = GDM_GREETER_PANEL_GET_PRIVATE (panel);
+
+}
+
 static void
 gdm_greeter_panel_finalize (GObject *object)
 {
@@ -970,9 +909,84 @@ gdm_greeter_panel_finalize (GObject *object)
         g_signal_handlers_disconnect_by_func (object, on_animation_tick, greeter_panel);
         g_object_unref (greeter_panel->priv->animation_timer);
 
+        if (greeter_panel->priv->client != NULL) {
+                g_object_unref (greeter_panel->priv->client);
+        }
+
         G_OBJECT_CLASS (gdm_greeter_panel_parent_class)->finalize (object);
 }
 
+static void
+gdm_greeter_panel_class_init (GdmGreeterPanelClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+        object_class->get_property = gdm_greeter_panel_get_property;
+        object_class->set_property = gdm_greeter_panel_set_property;
+        object_class->constructor = gdm_greeter_panel_constructor;
+        object_class->dispose = gdm_greeter_panel_dispose;
+        object_class->finalize = gdm_greeter_panel_finalize;
+
+        widget_class->realize = gdm_greeter_panel_real_realize;
+        widget_class->unrealize = gdm_greeter_panel_real_unrealize;
+        widget_class->size_request = gdm_greeter_panel_real_size_request;
+        widget_class->show = gdm_greeter_panel_real_show;
+        widget_class->hide = gdm_greeter_panel_real_hide;
+
+        signals[LANGUAGE_SELECTED] =
+                g_signal_new ("language-selected",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GdmGreeterPanelClass, language_selected),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__STRING,
+                              G_TYPE_NONE,
+                              1, G_TYPE_STRING);
+
+        signals[LAYOUT_SELECTED] =
+                g_signal_new ("layout-selected",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GdmGreeterPanelClass, layout_selected),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__STRING,
+                              G_TYPE_NONE,
+                              1, G_TYPE_STRING);
+
+        signals[SESSION_SELECTED] =
+                g_signal_new ("session-selected",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GdmGreeterPanelClass, session_selected),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__STRING,
+                              G_TYPE_NONE,
+                              1, G_TYPE_STRING);
+
+        g_object_class_install_property (object_class,
+                                         PROP_MONITOR,
+                                         g_param_spec_int ("monitor",
+                                                           "Xinerama monitor",
+                                                           "The monitor (in terms of Xinerama) which the window is on",
+                                                           0,
+                                                           G_MAXINT,
+                                                           0,
+                                                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_DISPLAY_IS_LOCAL,
+                                         g_param_spec_boolean ("display-is-local",
+                                                               "display is local",
+                                                               "display is local",
+                                                               FALSE,
+                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+        g_type_class_add_private (klass, sizeof (GdmGreeterPanelPrivate));
+}
+
 GtkWidget *
 gdm_greeter_panel_new (GdkScreen *screen,
                        int        monitor,
@@ -983,7 +997,7 @@ gdm_greeter_panel_new (GdkScreen *screen,
         object = g_object_new (GDM_TYPE_GREETER_PANEL,
                                "screen", screen,
                                "monitor", monitor,
-                               "display-is-local", is_local,                               
+                               "display-is-local", is_local,
                                NULL);
 
         return GTK_WIDGET (object);



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