diff options
author | William Jon McCann <jmccann@redhat.com> | 2008-09-09 00:20:37 +0000 |
---|---|---|
committer | William Jon McCann <mccann@src.gnome.org> | 2008-09-09 00:20:37 +0000 |
commit | d994afb0e6fc722c3e8c5ea9119c59d44daca776 (patch) | |
tree | 8fed84a09fb9c61a9c98777429484f6a1f49cedf /gui | |
parent | 3d19056cb02d0619e52e6d1cbf308525c6279287 (diff) | |
download | gdm-d994afb0e6fc722c3e8c5ea9119c59d44daca776.tar.gz |
Use the selected item instead of the active item for the language and
2008-09-08 William Jon McCann <jmccann@redhat.com>
* gui/simple-greeter/gdm-chooser-widget.c
(translate_view_path_to_list_path), (get_active_item_id),
(get_selected_list_path), (gdm_chooser_widget_get_selected_item):
* gui/simple-greeter/gdm-chooser-widget.h:
* gui/simple-greeter/gdm-language-chooser-widget.c
(gdm_language_chooser_widget_get_current_language_name):
* gui/simple-greeter/gdm-layout-chooser-widget.c
(gdm_layout_chooser_widget_get_current_layout_name):
Use the selected item instead of the active item for the
language and layout choosers. We don't do this for the
user chooser because we change the selection of it in order
to work around the widget using the selection color.
svn path=/trunk/; revision=6484
Diffstat (limited to 'gui')
-rw-r--r-- | gui/simple-greeter/gdm-chooser-widget.c | 120 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-chooser-widget.h | 2 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-language-chooser-widget.c | 2 | ||||
-rw-r--r-- | gui/simple-greeter/gdm-layout-chooser-widget.c | 2 |
4 files changed, 78 insertions, 48 deletions
diff --git a/gui/simple-greeter/gdm-chooser-widget.c b/gui/simple-greeter/gdm-chooser-widget.c index 0ff7ad2f..c8a1a695 100644 --- a/gui/simple-greeter/gdm-chooser-widget.c +++ b/gui/simple-greeter/gdm-chooser-widget.c @@ -275,6 +275,26 @@ translate_list_path_to_view_path (GdmChooserWidget *widget, *path = sorted_path; } + +static void +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 GtkTreePath * get_list_path_to_active_row (GdmChooserWidget *widget) { @@ -335,7 +355,7 @@ get_active_item_id (GdmChooserWidget *widget, CHOOSER_ID_COLUMN, &item_id, -1); - }; + } gtk_tree_path_free (path); return item_id; @@ -350,6 +370,59 @@ gdm_chooser_widget_get_active_item (GdmChooserWidget *widget) } static void +get_selected_list_path (GdmChooserWidget *widget, + GtkTreePath **pathp) +{ + GtkTreeSelection *selection; + GtkTreeModel *sort_model; + GtkTreeIter sorted_iter; + GtkTreePath *path; + + path = NULL; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget->priv->items_view)); + if (gtk_tree_selection_get_selected (selection, &sort_model, &sorted_iter)) { + + 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"); + } + + *pathp = path; +} + +char * +gdm_chooser_widget_get_selected_item (GdmChooserWidget *widget) +{ + GtkTreeIter iter; + GtkTreeModel *model; + GtkTreePath *path; + char *id; + + id = NULL; + + get_selected_list_path (widget, &path); + + model = GTK_TREE_MODEL (widget->priv->list_store); + + if (gtk_tree_model_get_iter (model, &iter, path)) { + gtk_tree_model_get (model, + &iter, + CHOOSER_ID_COLUMN, + &id, + -1); + } + + gtk_tree_path_free (path); + + return id; +} + +static void activate_from_item_id (GdmChooserWidget *widget, const char *item_id) { @@ -920,51 +993,6 @@ deactivate (GdmChooserWidget *widget) g_signal_emit (widget, signals[DEACTIVATED], 0); } -static void -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; - GtkTreeIter sorted_iter; - GtkTreePath *path; - - path = NULL; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget->priv->items_view)); - if (gtk_tree_selection_get_selected (selection, &sort_model, &sorted_iter)) { - - 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"); - } - - *pathp = path; -} - void gdm_chooser_widget_activate_selected_item (GdmChooserWidget *widget) { diff --git a/gui/simple-greeter/gdm-chooser-widget.h b/gui/simple-greeter/gdm-chooser-widget.h index a8ce4946..73bfc87b 100644 --- a/gui/simple-greeter/gdm-chooser-widget.h +++ b/gui/simple-greeter/gdm-chooser-widget.h @@ -105,6 +105,8 @@ gboolean gdm_chooser_widget_lookup_item (GdmChooserWidget gboolean *is_in_use, gboolean *is_separate); +char * gdm_chooser_widget_get_selected_item (GdmChooserWidget *widget); + char * gdm_chooser_widget_get_active_item (GdmChooserWidget *widget); void gdm_chooser_widget_set_active_item (GdmChooserWidget *widget, const char *item); diff --git a/gui/simple-greeter/gdm-language-chooser-widget.c b/gui/simple-greeter/gdm-language-chooser-widget.c index e2687920..4699a7e8 100644 --- a/gui/simple-greeter/gdm-language-chooser-widget.c +++ b/gui/simple-greeter/gdm-language-chooser-widget.c @@ -66,7 +66,7 @@ gdm_language_chooser_widget_get_current_language_name (GdmLanguageChooserWidget g_return_val_if_fail (GDM_IS_LANGUAGE_CHOOSER_WIDGET (widget), NULL); - language_name = gdm_chooser_widget_get_active_item (GDM_CHOOSER_WIDGET (widget)); + language_name = gdm_chooser_widget_get_selected_item (GDM_CHOOSER_WIDGET (widget)); if (language_name == NULL) { language_name = g_strdup (setlocale (LC_MESSAGES, NULL)); diff --git a/gui/simple-greeter/gdm-layout-chooser-widget.c b/gui/simple-greeter/gdm-layout-chooser-widget.c index 1feff6b9..53feea99 100644 --- a/gui/simple-greeter/gdm-layout-chooser-widget.c +++ b/gui/simple-greeter/gdm-layout-chooser-widget.c @@ -66,7 +66,7 @@ gdm_layout_chooser_widget_get_current_layout_name (GdmLayoutChooserWidget *widge g_return_val_if_fail (GDM_IS_LAYOUT_CHOOSER_WIDGET (widget), NULL); - id = gdm_chooser_widget_get_active_item (GDM_CHOOSER_WIDGET (widget)); + id = gdm_chooser_widget_get_selected_item (GDM_CHOOSER_WIDGET (widget)); if (id == NULL) { id = g_strdup ("us"); |