gdm r6425 - in trunk: . gui/simple-greeter



Author: mccann
Date: Mon Aug 25 17:10:34 2008
New Revision: 6425
URL: http://svn.gnome.org/viewvc/gdm?rev=6425&view=rev

Log:
2008-08-25  William Jon McCann  <jmccann redhat com>

	* gui/simple-greeter/gdm-chooser-widget.c (find_item),
	(translate_list_path_to_view_path), (get_list_path_to_active_row),
	(get_view_path_to_active_row), (get_active_item_id),
	(activate_from_item_id), (on_shrink_animation_step),
	(start_shrink_animation), (deactivate),
	(translate_view_path_to_list_path), (get_selected_list_path),
	(gdm_chooser_widget_activate_selected_item), (add_separator),
	(on_selection_changed), (gdm_chooser_widget_init):
	* gui/simple-greeter/gdm-greeter-login-window.c
	(on_gconf_key_changed):
	* gui/simple-greeter/gdm-language-chooser-dialog.c
	(gdm_language_chooser_dialog_class_init),
	(gdm_language_chooser_dialog_init):
	* gui/simple-greeter/gdm-language-option-widget.c
	(on_dialog_response), (gdm_language_option_widget_hide_dialog),
	(create_dialog), (gdm_language_option_widget_show_dialog),
	(gdm_language_option_widget_activated),
	(gdm_language_option_widget_init),
	(gdm_language_option_widget_finalize):
	* gui/simple-greeter/gdm-layout-chooser-dialog.c
	(gdm_layout_chooser_dialog_class_init), (respond),
	(gdm_layout_chooser_dialog_init):
	* gui/simple-greeter/gdm-layout-option-widget.c
	(gdm_layout_option_widget_set_layout_from_dialog),
	(on_dialog_response), (gdm_layout_option_widget_hide_dialog),
	(create_dialog), (gdm_layout_option_widget_show_dialog),
	(gdm_layout_option_widget_activated),
	(gdm_layout_option_widget_init),
	(gdm_layout_option_widget_finalize),
	(gdm_layout_option_widget_set_current_layout_name):
	Fix a number of problems in the chooser widgets.  Remove
	some unused code.  Drop handling activation as response
	for now.  Fix a leak.  Fix some bugs with tranlating
	child paths.
	Fixes #549223



Modified:
   trunk/ChangeLog
   trunk/gui/simple-greeter/gdm-chooser-widget.c
   trunk/gui/simple-greeter/gdm-greeter-login-window.c
   trunk/gui/simple-greeter/gdm-language-chooser-dialog.c
   trunk/gui/simple-greeter/gdm-language-option-widget.c
   trunk/gui/simple-greeter/gdm-layout-chooser-dialog.c
   trunk/gui/simple-greeter/gdm-layout-chooser-widget.c
   trunk/gui/simple-greeter/gdm-layout-option-widget.c

Modified: trunk/gui/simple-greeter/gdm-chooser-widget.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-chooser-widget.c	(original)
+++ trunk/gui/simple-greeter/gdm-chooser-widget.c	Mon Aug 25 17:10:34 2008
@@ -68,6 +68,7 @@
 
         GdkPixbuf                *is_in_use_pixbuf;
 
+        /* row for the list_store model */
         GtkTreeRowReference      *active_row;
         GtkTreeRowReference      *separator_row;
 
@@ -161,8 +162,11 @@
         do {
                 char *item_id;
 
-                gtk_tree_model_get (model, iter,
-                                    CHOOSER_ID_COLUMN, &item_id, -1);
+                gtk_tree_model_get (model,
+                                    iter,
+                                    CHOOSER_ID_COLUMN,
+                                    &item_id,
+                                    -1);
 
                 g_assert (item_id != NULL);
 
@@ -253,6 +257,56 @@
                                 &fdata);
 }
 
+static void
+translate_list_path_to_view_path (GdmChooserWidget  *widget,
+                                  GtkTreePath      **path)
+{
+        GtkTreePath *filtered_path;
+        GtkTreePath *sorted_path;
+
+        /* the child model is the source for the filter */
+        filtered_path = gtk_tree_model_filter_convert_child_path_to_path (widget->priv->model_filter,
+                                                                          *path);
+        sorted_path = gtk_tree_model_sort_convert_child_path_to_path (widget->priv->model_sorter,
+                                                                      filtered_path);
+        gtk_tree_path_free (filtered_path);
+
+        gtk_tree_path_free (*path);
+        *path = sorted_path;
+}
+
+static GtkTreePath *
+get_list_path_to_active_row (GdmChooserWidget *widget)
+{
+        GtkTreePath *path;
+
+        if (widget->priv->active_row == NULL) {
+                return NULL;
+        }
+
+        path = gtk_tree_row_reference_get_path (widget->priv->active_row);
+        if (path == NULL) {
+                return NULL;
+        }
+
+        return path;
+}
+
+static GtkTreePath *
+get_view_path_to_active_row (GdmChooserWidget *widget)
+{
+        GtkTreePath *path;
+
+        path = get_list_path_to_active_row (widget);
+        if (path == NULL) {
+                return NULL;
+        }
+
+        translate_list_path_to_view_path (widget, &path);
+
+        return path;
+}
+
 static char *
 get_active_item_id (GdmChooserWidget *widget,
                     GtkTreeIter      *iter)
@@ -270,10 +324,17 @@
                 return NULL;
         }
 
-        path = gtk_tree_row_reference_get_path (widget->priv->active_row);
+        path = get_list_path_to_active_row (widget);
+        if (path == NULL) {
+                return NULL;
+        }
+
         if (gtk_tree_model_get_iter (model, iter, path)) {
-                gtk_tree_model_get (model, iter,
-                                    CHOOSER_ID_COLUMN, &item_id, -1);
+                gtk_tree_model_get (model,
+                                    iter,
+                                    CHOOSER_ID_COLUMN,
+                                    &item_id,
+                                    -1);
         };
         gtk_tree_path_free (path);
 
@@ -289,42 +350,6 @@
 }
 
 static void
-translate_view_path_to_list_path (GdmChooserWidget  *widget,
-                                  GtkTreePath      **path)
-{
-        GtkTreePath *filtered_path;
-        GtkTreePath *sorted_path;
-
-        /* the child model is the source for the filter */
-        filtered_path = gtk_tree_model_filter_convert_path_to_child_path (widget->priv->model_filter,
-                                                                          *path);
-        sorted_path = gtk_tree_model_sort_convert_child_path_to_path (widget->priv->model_sorter,
-                                                                      filtered_path);
-        gtk_tree_path_free (filtered_path);
-
-        gtk_tree_path_free (*path);
-        *path = sorted_path;
-}
-
-static void
-translate_list_path_to_view_path (GdmChooserWidget  *widget,
-                                  GtkTreePath      **path)
-{
-        GtkTreePath *filtered_path;
-        GtkTreePath *sorted_path;
-
-        /* the child model is the source for the filter */
-        filtered_path = gtk_tree_model_filter_convert_child_path_to_path (widget->priv->model_filter,
-                                                                          *path);
-        sorted_path = gtk_tree_model_sort_convert_child_path_to_path (widget->priv->model_sorter,
-                                                                      filtered_path);
-        gtk_tree_path_free (filtered_path);
-
-        gtk_tree_path_free (*path);
-        *path = sorted_path;
-}
-
-static void
 activate_from_item_id (GdmChooserWidget *widget,
                        const char       *item_id)
 {
@@ -340,18 +365,18 @@
                 path = gtk_tree_model_get_path (model, &iter);
 
                 path_str = gtk_tree_path_to_string (path);
-                g_debug ("GdmChooserWidget: got path '%s'", path_str);
+                g_debug ("GdmChooserWidget: got list path '%s'", path_str);
                 g_free (path_str);
 
                 translate_list_path_to_view_path (widget, &path);
 
                 path_str = gtk_tree_path_to_string (path);
-                g_debug ("GdmChooserWidget: translated to path '%s'", path_str);
+                g_debug ("GdmChooserWidget: translated to view path '%s'", path_str);
                 g_free (path_str);
         }
 
         if (path == NULL) {
-                g_debug ("GdmChooserWidget: unable to activate - path for item not found");
+                g_debug ("GdmChooserWidget: unable to activate - path for item '%s' not found", item_id);
                 return;
         }
 
@@ -405,26 +430,6 @@
         }
 }
 
-static GtkTreePath *
-get_path_to_active_row (GdmChooserWidget *widget)
-{
-        GtkTreePath *path;
-
-        if (widget->priv->active_row == NULL) {
-                return NULL;
-        }
-
-        path = gtk_tree_row_reference_get_path (widget->priv->active_row);
-
-        if (path == NULL) {
-                return NULL;
-        }
-
-        translate_list_path_to_view_path (widget, &path);
-
-        return path;
-}
-
 static void
 on_shrink_animation_step (GdmScrollableWidget *scrollable_widget,
                           double               progress,
@@ -434,7 +439,7 @@
         const double   final_alignment = 0.5;
         double         row_alignment;
 
-        active_row_path = get_path_to_active_row (widget);
+        active_row_path = get_view_path_to_active_row (widget);
         row_alignment = widget->priv->active_row_normalized_position + progress * (final_alignment - widget->priv->active_row_normalized_position);
 
         gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (widget->priv->items_view),
@@ -593,7 +598,7 @@
                return;
        }
 
-       active_row_path = get_path_to_active_row (widget);
+       active_row_path = get_view_path_to_active_row (widget);
        active_row_height = get_height_of_row_at_path (widget, active_row_path);
        widget->priv->active_row_normalized_position = get_normalized_position_of_row_at_path (widget, active_row_path);
        gtk_tree_path_free (active_row_path);
@@ -899,7 +904,7 @@
                 return;
         }
 
-        path = get_path_to_active_row (widget);
+        path = get_view_path_to_active_row (widget);
 
         gtk_tree_row_reference_free (widget->priv->active_row);
         widget->priv->active_row = NULL;
@@ -916,8 +921,27 @@
 }
 
 static void
-get_selected_path (GdmChooserWidget *widget,
-                   GtkTreePath     **pathp)
+translate_view_path_to_list_path (GdmChooserWidget  *widget,
+                                  GtkTreePath      **path)
+{
+        GtkTreePath *filtered_path;
+        GtkTreePath *list_path;
+
+        /* the child model is the source for the filter */
+        filtered_path = gtk_tree_model_sort_convert_path_to_child_path (widget->priv->model_sorter,
+                                                                        *path);
+
+        list_path = gtk_tree_model_filter_convert_path_to_child_path (widget->priv->model_filter,
+                                                                      filtered_path);
+        gtk_tree_path_free (filtered_path);
+
+        gtk_tree_path_free (*path);
+        *path = list_path;
+}
+
+static void
+get_selected_list_path (GdmChooserWidget *widget,
+                        GtkTreePath     **pathp)
 {
         GtkTreeSelection    *selection;
         GtkTreeModel        *sort_model;
@@ -932,6 +956,7 @@
                 g_assert (sort_model == GTK_TREE_MODEL (widget->priv->model_sorter));
 
                 path = gtk_tree_model_get_path (sort_model, &sorted_iter);
+
                 translate_view_path_to_list_path (widget, &path);
         } else {
                 g_debug ("GdmChooserWidget: no rows selected");
@@ -954,8 +979,7 @@
 
         path = NULL;
 
-        get_selected_path (widget, &path);
-
+        get_selected_list_path (widget, &path);
         if (path == NULL) {
                 g_debug ("GdmChooserWidget: no row selected");
                 return;
@@ -966,7 +990,7 @@
 
                 active_path = gtk_tree_row_reference_get_path (widget->priv->active_row);
 
-                if (gtk_tree_path_compare  (path, active_path) == 0) {
+                if (gtk_tree_path_compare (path, active_path) == 0) {
                         is_already_active = TRUE;
                 }
                 gtk_tree_path_free (active_path);
@@ -1483,8 +1507,7 @@
                                            &iter, 0,
                                            CHOOSER_ID_COLUMN, "-", -1);
         path = gtk_tree_model_get_path (model, &iter);
-        widget->priv->separator_row =
-            gtk_tree_row_reference_new (model, path);
+        widget->priv->separator_row = gtk_tree_row_reference_new (model, path);
         gtk_tree_path_free (path);
 }
 
@@ -1643,11 +1666,11 @@
 {
         GtkTreePath *path;
 
-        get_selected_path (widget, &path);
+        get_selected_list_path (widget, &path);
         if (path != NULL) {
                 char *path_str;
                 path_str = gtk_tree_path_to_string (path);
-                g_debug ("GdmChooserWidget: selection change to path '%s'", path_str);
+                g_debug ("GdmChooserWidget: selection change to list path '%s'", path_str);
                 g_free (path_str);
         } else {
                 g_debug ("GdmChooserWidget: selection cleared");
@@ -1749,11 +1772,6 @@
 
         /* IMAGE COLUMN */
         renderer = gtk_cell_renderer_pixbuf_new ();
-#if 0
-        gtk_cell_renderer_set_fixed_size (renderer,
-                                          GDM_CHOOSER_WIDGET_DEFAULT_ICON_SIZE,
-                                          GDM_CHOOSER_WIDGET_DEFAULT_ICON_SIZE);
-#endif
         column = gtk_tree_view_column_new ();
         gtk_tree_view_column_pack_start (column, renderer, FALSE);
         gtk_tree_view_append_column (GTK_TREE_VIEW (widget->priv->items_view), column);

Modified: trunk/gui/simple-greeter/gdm-greeter-login-window.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-greeter-login-window.c	(original)
+++ trunk/gui/simple-greeter/gdm-greeter-login-window.c	Mon Aug 25 17:10:34 2008
@@ -1931,7 +1931,7 @@
                         update_banner_message (login_window);
                 }
         } else {
-                g_debug ("Config key not handled: %s", key);
+                g_debug ("GdmGreeterLoginWindow: Config key not handled: %s", key);
         }
 }
 

Modified: trunk/gui/simple-greeter/gdm-language-chooser-dialog.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-language-chooser-dialog.c	(original)
+++ trunk/gui/simple-greeter/gdm-language-chooser-dialog.c	Mon Aug 25 17:10:34 2008
@@ -97,19 +97,6 @@
 }
 
 static void
-gdm_language_chooser_dialog_response (GtkDialog *dialog,
-                                      int        response_id)
-{
-        GdmLanguageChooserDialog *chooser_dialog;
-
-        chooser_dialog = GDM_LANGUAGE_CHOOSER_DIALOG (dialog);
-
-        if (response_id == GTK_RESPONSE_OK) {
-                gdm_chooser_widget_activate_selected_item (GDM_CHOOSER_WIDGET (chooser_dialog->priv->chooser_widget));
-        }
-}
-
-static void
 gdm_language_chooser_dialog_realize (GtkWidget *widget)
 {
         GdmLanguageChooserDialog *chooser_dialog;
@@ -137,16 +124,10 @@
 {
         GObjectClass   *object_class = G_OBJECT_CLASS (klass);
         GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-#ifdef I_COULD_GO_BACK_IN_TIME_AND_MAKE_RESPONSE_RUN_FIRST
-        GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
-#endif
 
         object_class->finalize = gdm_language_chooser_dialog_finalize;
         widget_class->size_request = gdm_language_chooser_dialog_size_request;
         widget_class->realize = gdm_language_chooser_dialog_realize;
-#ifdef I_COULD_GO_BACK_IN_TIME_AND_MAKE_RESPONSE_RUN_FIRST
-        dialog_class->response = gdm_language_chooser_dialog_response;
-#endif
 
         g_type_class_add_private (klass, sizeof (GdmLanguageChooserDialogPrivate));
 }
@@ -174,17 +155,15 @@
         gdm_chooser_widget_set_hide_inactive_items (GDM_CHOOSER_WIDGET (dialog->priv->chooser_widget),
                                                     FALSE);
 
-#ifndef I_COULD_GO_BACK_IN_TIME_AND_MAKE_RESPONSE_RUN_FIRST
-        g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (gdm_language_chooser_dialog_response), NULL);
-#endif
-
         gdm_language_chooser_widget_set_current_language_name (GDM_LANGUAGE_CHOOSER_WIDGET (dialog->priv->chooser_widget),
                                                                setlocale (LC_MESSAGES, NULL));
         gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->priv->chooser_widget);
 
+#if 0
         g_signal_connect_swapped (G_OBJECT (dialog->priv->chooser_widget),
                                   "activated", G_CALLBACK (queue_response),
                                   dialog);
+#endif
         gtk_dialog_add_buttons (GTK_DIALOG (dialog),
                                 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                 GTK_STOCK_OK, GTK_RESPONSE_OK,

Modified: trunk/gui/simple-greeter/gdm-language-option-widget.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-language-option-widget.c	(original)
+++ trunk/gui/simple-greeter/gdm-language-option-widget.c	Mon Aug 25 17:10:34 2008
@@ -57,7 +57,8 @@
 
 static void     gdm_language_option_widget_class_init  (GdmLanguageOptionWidgetClass *klass);
 static void     gdm_language_option_widget_init        (GdmLanguageOptionWidget      *language_option_widget);
-static void     gdm_language_option_widget_finalize    (GObject                     *object);
+static void     gdm_language_option_widget_finalize    (GObject                      *object);
+static void     gdm_language_option_widget_hide_dialog (GdmLanguageOptionWidget      *widget);
 
 G_DEFINE_TYPE (GdmLanguageOptionWidget, gdm_language_option_widget, GDM_TYPE_RECENT_OPTION_WIDGET)
 
@@ -79,19 +80,51 @@
         switch (response_id) {
                 case GTK_RESPONSE_OK:
                         gdm_language_option_widget_set_language_from_dialog (widget);
-                break;
+                        break;
 
                 default:
-                break;
+                        break;
         }
-        gtk_widget_hide (GTK_WIDGET (dialog));
+
+        gdm_language_option_widget_hide_dialog (widget);
 }
 
 static void
-gdm_language_option_widget_show_dialog (GdmLanguageOptionWidget *widget)
+gdm_language_option_widget_hide_dialog (GdmLanguageOptionWidget *widget)
 {
-        gdm_language_option_widget_set_language_from_dialog (widget);
+        gtk_widget_destroy (widget->priv->dialog);
+        widget->priv->dialog = NULL;
+}
+
+static void
+create_dialog (GdmLanguageOptionWidget *widget)
+{
+        gdm_profile_start (NULL);
+
+        g_assert (widget->priv->dialog == NULL);
+
+        widget->priv->dialog = gdm_language_chooser_dialog_new ();
+
+        gdm_profile_end (NULL);
+}
+
+static void
+gdm_language_option_widget_show_dialog (GdmLanguageOptionWidget *widget,
+                                        const char              *active_item_id)
+{
+        if (widget->priv->dialog == NULL) {
+                create_dialog (widget);
+        }
+
+        g_signal_connect (GTK_DIALOG (widget->priv->dialog),
+                          "response",
+                          G_CALLBACK (on_dialog_response),
+                          widget);
+
         gtk_widget_show_all (GTK_WIDGET (widget->priv->dialog));
+
+        gdm_language_chooser_dialog_set_current_language_name (GDM_LANGUAGE_CHOOSER_DIALOG (GDM_LANGUAGE_OPTION_WIDGET (widget)->priv->dialog),
+                                                               active_item_id);
 }
 
 static void
@@ -105,20 +138,22 @@
         }
 
         if (strcmp (active_item_id, "__other") == 0) {
-                gdm_language_option_widget_show_dialog (GDM_LANGUAGE_OPTION_WIDGET (widget));
-                return;
-        }
+                g_free (active_item_id);
 
-        gdm_language_chooser_dialog_set_current_language_name (GDM_LANGUAGE_CHOOSER_DIALOG (GDM_LANGUAGE_OPTION_WIDGET (widget)->priv->dialog),
-                                                               active_item_id);
+                active_item_id = gdm_option_widget_get_default_item (widget);
+                gdm_language_option_widget_set_current_language_name (GDM_LANGUAGE_OPTION_WIDGET (widget), active_item_id);
+                gdm_language_option_widget_show_dialog (GDM_LANGUAGE_OPTION_WIDGET (widget), active_item_id);
+        }
 
         g_signal_emit (G_OBJECT (widget), signals[LANGUAGE_ACTIVATED], 0);
+
+        g_free (active_item_id);
 }
 
 static void
 gdm_language_option_widget_class_init (GdmLanguageOptionWidgetClass *klass)
 {
-        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+        GObjectClass         *object_class = G_OBJECT_CLASS (klass);
         GdmOptionWidgetClass *option_widget_class = GDM_OPTION_WIDGET_CLASS (klass);
 
         object_class->finalize = gdm_language_option_widget_finalize;
@@ -166,23 +201,6 @@
 }
 
 static void
-create_dialog (GdmLanguageOptionWidget *widget)
-{
-        gdm_profile_start (NULL);
-
-        g_assert (widget->priv->dialog == NULL);
-
-        widget->priv->dialog = gdm_language_chooser_dialog_new ();
-
-        g_signal_connect (GTK_DIALOG (widget->priv->dialog),
-                          "response",
-                          G_CALLBACK (on_dialog_response),
-                          widget);
-
-        gdm_profile_end (NULL);
-}
-
-static void
 gdm_language_option_widget_init (GdmLanguageOptionWidget *widget)
 {
         GError *error;
@@ -207,8 +225,6 @@
                                     _("Choose a language from the "
                                       "full list of available languages."),
                                     GDM_OPTION_WIDGET_POSITION_BOTTOM);
-
-        create_dialog (widget);
 }
 
 static void
@@ -223,6 +239,10 @@
 
         g_return_if_fail (language_option_widget->priv != NULL);
 
+        if (language_option_widget->priv->dialog != NULL) {
+                gtk_widget_destroy (language_option_widget->priv->dialog);
+        }
+
         G_OBJECT_CLASS (gdm_language_option_widget_parent_class)->finalize (object);
 }
 

Modified: trunk/gui/simple-greeter/gdm-layout-chooser-dialog.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-layout-chooser-dialog.c	(original)
+++ trunk/gui/simple-greeter/gdm-layout-chooser-dialog.c	Mon Aug 25 17:10:34 2008
@@ -63,7 +63,7 @@
 
 void
 gdm_layout_chooser_dialog_set_current_layout_name (GdmLayoutChooserDialog *dialog,
-                                                       const char               *layout_name)
+                                                   const char             *layout_name)
 {
 
         g_return_if_fail (GDM_IS_LAYOUT_CHOOSER_DIALOG (dialog));
@@ -73,7 +73,7 @@
 
 static void
 gdm_layout_chooser_dialog_size_request (GtkWidget      *widget,
-                                       GtkRequisition *requisition)
+                                        GtkRequisition *requisition)
 {
         int            screen_w;
         int            screen_h;
@@ -97,19 +97,6 @@
 }
 
 static void
-gdm_layout_chooser_dialog_response (GtkDialog *dialog,
-                                    int        response_id)
-{
-        GdmLayoutChooserDialog *chooser_dialog;
-
-        chooser_dialog = GDM_LAYOUT_CHOOSER_DIALOG (dialog);
-
-        if (response_id == GTK_RESPONSE_OK) {
-                gdm_chooser_widget_activate_selected_item (GDM_CHOOSER_WIDGET (chooser_dialog->priv->chooser_widget));
-        }
-}
-
-static void
 gdm_layout_chooser_dialog_realize (GtkWidget *widget)
 {
         GdmLayoutChooserDialog *chooser_dialog;
@@ -126,16 +113,10 @@
 {
         GObjectClass   *object_class = G_OBJECT_CLASS (klass);
         GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-#ifdef I_COULD_GO_BACK_IN_TIME_AND_MAKE_RESPONSE_RUN_FIRST
-        GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
-#endif
 
         object_class->finalize = gdm_layout_chooser_dialog_finalize;
         widget_class->size_request = gdm_layout_chooser_dialog_size_request;
         widget_class->realize = gdm_layout_chooser_dialog_realize;
-#ifdef I_COULD_GO_BACK_IN_TIME_AND_MAKE_RESPONSE_RUN_FIRST
-        dialog_class->response = gdm_layout_chooser_dialog_response;
-#endif
 
         g_type_class_add_private (klass, sizeof (GdmLayoutChooserDialogPrivate));
 }
@@ -144,6 +125,7 @@
 respond (GdmLayoutChooserDialog *dialog)
 {
         gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
         return FALSE;
 }
 
@@ -163,17 +145,14 @@
         gdm_chooser_widget_set_hide_inactive_items (GDM_CHOOSER_WIDGET (dialog->priv->chooser_widget),
                                                     FALSE);
 
-#ifndef I_COULD_GO_BACK_IN_TIME_AND_MAKE_RESPONSE_RUN_FIRST
-        g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (gdm_layout_chooser_dialog_response), NULL);
-#endif
-
         gdm_layout_chooser_widget_set_current_layout_name (GDM_LAYOUT_CHOOSER_WIDGET (dialog->priv->chooser_widget),
                                                                setlocale (LC_MESSAGES, NULL));
         gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->priv->chooser_widget);
-
+#if 0
         g_signal_connect_swapped (G_OBJECT (dialog->priv->chooser_widget),
                                   "activated", G_CALLBACK (queue_response),
                                   dialog);
+#endif
         gtk_dialog_add_buttons (GTK_DIALOG (dialog),
                                 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                 GTK_STOCK_OK, GTK_RESPONSE_OK,

Modified: trunk/gui/simple-greeter/gdm-layout-chooser-widget.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-layout-chooser-widget.c	(original)
+++ trunk/gui/simple-greeter/gdm-layout-chooser-widget.c	Mon Aug 25 17:10:34 2008
@@ -49,7 +49,7 @@
 
 static void     gdm_layout_chooser_widget_class_init  (GdmLayoutChooserWidgetClass *klass);
 static void     gdm_layout_chooser_widget_init        (GdmLayoutChooserWidget      *layout_chooser_widget);
-static void     gdm_layout_chooser_widget_finalize    (GObject                       *object);
+static void     gdm_layout_chooser_widget_finalize    (GObject                     *object);
 
 G_DEFINE_TYPE (GdmLayoutChooserWidget, gdm_layout_chooser_widget, GDM_TYPE_CHOOSER_WIDGET)
 

Modified: trunk/gui/simple-greeter/gdm-layout-option-widget.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-layout-option-widget.c	(original)
+++ trunk/gui/simple-greeter/gdm-layout-option-widget.c	Mon Aug 25 17:10:34 2008
@@ -58,6 +58,7 @@
 static void     gdm_layout_option_widget_class_init  (GdmLayoutOptionWidgetClass *klass);
 static void     gdm_layout_option_widget_init        (GdmLayoutOptionWidget      *layout_option_widget);
 static void     gdm_layout_option_widget_finalize    (GObject                     *object);
+static void     gdm_layout_option_widget_hide_dialog (GdmLayoutOptionWidget       *widget);
 
 G_DEFINE_TYPE (GdmLayoutOptionWidget, gdm_layout_option_widget, GDM_TYPE_RECENT_OPTION_WIDGET)
 
@@ -67,31 +68,66 @@
         char *layout_name;
 
         layout_name = gdm_layout_chooser_dialog_get_current_layout_name (GDM_LAYOUT_CHOOSER_DIALOG (widget->priv->dialog));
+        g_debug ("GdmLayoutOptionWidget: Setting layout from dialog: '%s'", layout_name);
+
         gdm_layout_option_widget_set_current_layout_name (widget, layout_name);
         g_free (layout_name);
 }
 
 static void
-on_dialog_response (GtkDialog               *dialog,
-                    int                      response_id,
+on_dialog_response (GtkDialog             *dialog,
+                    int                    response_id,
                     GdmLayoutOptionWidget *widget)
 {
+        g_debug ("GdmLayoutOptionWidget: Got response from dialog: '%d'", response_id);
+
         switch (response_id) {
                 case GTK_RESPONSE_OK:
                         gdm_layout_option_widget_set_layout_from_dialog (widget);
-                break;
-
+                        break;
                 default:
-                break;
+                        break;
         }
-        gtk_widget_hide (GTK_WIDGET (dialog));
+
+        gdm_layout_option_widget_hide_dialog (widget);
+}
+
+static void
+gdm_layout_option_widget_hide_dialog (GdmLayoutOptionWidget *widget)
+{
+        gtk_widget_destroy (widget->priv->dialog);
+        widget->priv->dialog = NULL;
+}
+
+static void
+create_dialog (GdmLayoutOptionWidget *widget)
+{
+        gdm_profile_start (NULL);
+
+        g_assert (widget->priv->dialog == NULL);
+
+        widget->priv->dialog = gdm_layout_chooser_dialog_new ();
+
+        gdm_profile_end (NULL);
 }
 
 static void
-gdm_layout_option_widget_show_dialog (GdmLayoutOptionWidget *widget)
+gdm_layout_option_widget_show_dialog (GdmLayoutOptionWidget *widget,
+                                      const char            *active_item_id)
 {
-        gdm_layout_option_widget_set_layout_from_dialog (widget);
+        if (widget->priv->dialog == NULL) {
+                create_dialog (widget);
+        }
+
+        g_signal_connect (GTK_DIALOG (widget->priv->dialog),
+                          "response",
+                          G_CALLBACK (on_dialog_response),
+                          widget);
+
         gtk_widget_show_all (GTK_WIDGET (widget->priv->dialog));
+
+        gdm_layout_chooser_dialog_set_current_layout_name (GDM_LAYOUT_CHOOSER_DIALOG (GDM_LAYOUT_OPTION_WIDGET (widget)->priv->dialog),
+                                                           active_item_id);
 }
 
 static void
@@ -105,20 +141,22 @@
         }
 
         if (strcmp (active_item_id, "__other") == 0) {
-                gdm_layout_option_widget_show_dialog (GDM_LAYOUT_OPTION_WIDGET (widget));
-                return;
-        }
+                g_free (active_item_id);
 
-        gdm_layout_chooser_dialog_set_current_layout_name (GDM_LAYOUT_CHOOSER_DIALOG (GDM_LAYOUT_OPTION_WIDGET (widget)->priv->dialog),
-                                                               active_item_id);
+                active_item_id = gdm_option_widget_get_default_item (widget);
+                gdm_layout_option_widget_set_current_layout_name (GDM_LAYOUT_OPTION_WIDGET (widget), active_item_id);
+                gdm_layout_option_widget_show_dialog (GDM_LAYOUT_OPTION_WIDGET (widget), active_item_id);
+        }
 
         g_signal_emit (G_OBJECT (widget), signals[LAYOUT_ACTIVATED], 0);
+
+        g_free (active_item_id);
 }
 
 static void
 gdm_layout_option_widget_class_init (GdmLayoutOptionWidgetClass *klass)
 {
-        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+        GObjectClass         *object_class = G_OBJECT_CLASS (klass);
         GdmOptionWidgetClass *option_widget_class = GDM_OPTION_WIDGET_CLASS (klass);
 
         object_class->finalize = gdm_layout_option_widget_finalize;
@@ -126,14 +164,14 @@
         option_widget_class->activated = gdm_layout_option_widget_activated;
 
         signals[LAYOUT_ACTIVATED] = g_signal_new ("layout-activated",
-                                                     G_TYPE_FROM_CLASS (object_class),
-                                                     G_SIGNAL_RUN_FIRST,
-                                                     G_STRUCT_OFFSET (GdmLayoutOptionWidgetClass, layout_activated),
-                                                     NULL,
-                                                     NULL,
-                                                     g_cclosure_marshal_VOID__VOID,
-                                                     G_TYPE_NONE,
-                                                     0);
+                                                  G_TYPE_FROM_CLASS (object_class),
+                                                  G_SIGNAL_RUN_FIRST,
+                                                  G_STRUCT_OFFSET (GdmLayoutOptionWidgetClass, layout_activated),
+                                                  NULL,
+                                                  NULL,
+                                                  g_cclosure_marshal_VOID__VOID,
+                                                  G_TYPE_NONE,
+                                                  0);
 
         g_type_class_add_private (klass, sizeof (GdmLayoutOptionWidgetPrivate));
 }
@@ -159,23 +197,6 @@
 }
 
 static void
-create_dialog (GdmLayoutOptionWidget *widget)
-{
-        gdm_profile_start (NULL);
-
-        g_assert (widget->priv->dialog == NULL);
-
-        widget->priv->dialog = gdm_layout_chooser_dialog_new ();
-
-        g_signal_connect (GTK_DIALOG (widget->priv->dialog),
-                          "response",
-                          G_CALLBACK (on_dialog_response),
-                          widget);
-
-        gdm_profile_end (NULL);
-}
-
-static void
 gdm_layout_option_widget_init (GdmLayoutOptionWidget *widget)
 {
         GError *error;
@@ -200,8 +221,6 @@
                                     _("Choose a keyboard layout from the "
                                       "full list of available layouts."),
                                     GDM_OPTION_WIDGET_POSITION_BOTTOM);
-
-        create_dialog (widget);
 }
 
 static void
@@ -216,6 +235,10 @@
 
         g_return_if_fail (layout_option_widget->priv != NULL);
 
+        if (layout_option_widget->priv->dialog != NULL) {
+                gtk_widget_destroy (layout_option_widget->priv->dialog);
+        }
+
         G_OBJECT_CLASS (gdm_layout_option_widget_parent_class)->finalize (object);
 }
 
@@ -263,6 +286,6 @@
                 gdm_recent_option_widget_add_item (GDM_RECENT_OPTION_WIDGET (widget),
                                                    id);
         }
-
+        g_debug ("GdmLayoutOptionWidget: Setting active item: '%s'", id);
         gdm_option_widget_set_active_item (GDM_OPTION_WIDGET (widget), id);
 }



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