- add session chooser to login screen

- add hoaky animations
This commit is contained in:
Ray Strode 2007-12-13 20:31:53 +00:00
parent 645b690cd5
commit d0e8d54990
7 changed files with 4889 additions and 1 deletions

1739
2-new-chooser-widget.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,880 @@
From 1a8e5634ea780869574072ce5d4b33048fb35698 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 13 Dec 2007 10:12:30 -0500
Subject: [PATCH] Change user-chooser-widget over to use new chooser widget
---
gui/simple-greeter/Makefile.am | 10 +
gui/simple-greeter/gdm-user-chooser-widget.c | 600 ++------------------------
gui/simple-greeter/gdm-user-chooser-widget.h | 11 +-
3 files changed, 59 insertions(+), 562 deletions(-)
diff --git a/gui/simple-greeter/Makefile.am b/gui/simple-greeter/Makefile.am
index a403f24..836c620 100644
--- a/gui/simple-greeter/Makefile.am
+++ b/gui/simple-greeter/Makefile.am
@@ -45,6 +45,8 @@ test_greeter_login_window_SOURCES = \
test-greeter-login-window.c \
gdm-greeter-login-window.h \
gdm-greeter-login-window.c \
+ gdm-chooser-widget.h \
+ gdm-chooser-widget.c \
gdm-user-chooser-widget.h \
gdm-user-chooser-widget.c \
gdm-user-chooser-dialog.h \
@@ -86,6 +88,8 @@ test_language_chooser_LDADD = \
test_session_chooser_SOURCES = \
test-session-chooser.c \
+ gdm-chooser-widget.h \
+ gdm-chooser-widget.c \
gdm-session-chooser-widget.h \
gdm-session-chooser-widget.c \
gdm-session-chooser-dialog.h \
@@ -98,6 +102,8 @@ test_session_chooser_LDADD = \
test_user_chooser_SOURCES = \
test-user-chooser.c \
+ gdm-chooser-widget.h \
+ gdm-chooser-widget.c \
gdm-user-chooser-widget.h \
gdm-user-chooser-widget.c \
gdm-user-chooser-dialog.h \
@@ -131,6 +137,8 @@ libexec_PROGRAMS = \
gdm_simple_greeter_SOURCES = \
greeter-main.c \
+ gdm-chooser-widget.h \
+ gdm-chooser-widget.c \
gdm-greeter-client.h \
gdm-greeter-client.c \
gdm-greeter-session.h \
@@ -145,6 +153,8 @@ gdm_simple_greeter_SOURCES = \
gdm-greeter-panel.c \
gdm-greeter-background.h \
gdm-greeter-background.c \
+ gdm-session-chooser-widget.h \
+ gdm-session-chooser-widget.c \
gdm-user-chooser-widget.h \
gdm-user-chooser-widget.c \
gdm-user-manager.h \
diff --git a/gui/simple-greeter/gdm-user-chooser-widget.c b/gui/simple-greeter/gdm-user-chooser-widget.c
index e8c0cdc..b8a9bb7 100644
--- a/gui/simple-greeter/gdm-user-chooser-widget.c
+++ b/gui/simple-greeter/gdm-user-chooser-widget.c
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2007 Ray Strode <rstrode@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -47,61 +48,23 @@ enum {
struct GdmUserChooserWidgetPrivate
{
- GtkWidget *treeview;
-
- GtkTreeModel *real_model;
- GtkTreeModel *filter_model;
- GtkTreeModel *sort_model;
-
GdmUserManager *manager;
GdkPixbuf *logged_in_pixbuf;
- char *chosen_user;
- gboolean show_only_chosen;
- gboolean show_other_user;
- gboolean show_guest_user;
- guint populate_id;
+ guint show_other_user : 1;
+ guint show_guest_user : 1;
};
enum {
PROP_0,
};
-enum {
- USER_CHOSEN,
- LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0, };
-
static void gdm_user_chooser_widget_class_init (GdmUserChooserWidgetClass *klass);
static void gdm_user_chooser_widget_init (GdmUserChooserWidget *user_chooser_widget);
static void gdm_user_chooser_widget_finalize (GObject *object);
-G_DEFINE_TYPE (GdmUserChooserWidget, gdm_user_chooser_widget, GTK_TYPE_VBOX)
-
-enum {
- CHOOSER_LIST_PIXBUF_COLUMN = 0,
- CHOOSER_LIST_NAME_COLUMN,
- CHOOSER_LIST_TOOLTIP_COLUMN,
- CHOOSER_LIST_IS_LOGGED_IN_COLUMN,
- CHOOSER_LIST_ID_COLUMN
-};
-
-void
-gdm_user_chooser_widget_set_show_only_chosen (GdmUserChooserWidget *widget,
- gboolean show_only)
-{
- g_return_if_fail (GDM_IS_USER_CHOOSER_WIDGET (widget));
-
- if (widget->priv->show_only_chosen != show_only) {
- widget->priv->show_only_chosen = show_only;
- if (widget->priv->filter_model != NULL) {
- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (widget->priv->filter_model));
- }
- }
-}
+G_DEFINE_TYPE (GdmUserChooserWidget, gdm_user_chooser_widget, GDM_TYPE_CHOOSER_WIDGET)
void
gdm_user_chooser_widget_set_show_other_user (GdmUserChooserWidget *widget,
@@ -111,9 +74,6 @@ gdm_user_chooser_widget_set_show_other_user (GdmUserChooserWidget *widget,
if (widget->priv->show_other_user != show_user) {
widget->priv->show_other_user = show_user;
- if (widget->priv->filter_model != NULL) {
- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (widget->priv->filter_model));
- }
}
}
@@ -125,122 +85,15 @@ gdm_user_chooser_widget_set_show_guest_user (GdmUserChooserWidget *widget,
if (widget->priv->show_guest_user != show_user) {
widget->priv->show_guest_user = show_user;
- if (widget->priv->filter_model != NULL) {
- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (widget->priv->filter_model));
- }
}
}
char *
gdm_user_chooser_widget_get_chosen_user_name (GdmUserChooserWidget *widget)
{
- char *user_name;
-
g_return_val_if_fail (GDM_IS_USER_CHOOSER_WIDGET (widget), NULL);
- user_name = NULL;
- if (widget->priv->chosen_user != NULL) {
- user_name = g_strdup (widget->priv->chosen_user);
- }
-
- return user_name;
-}
-
-static void
-activate_name (GdmUserChooserWidget *widget,
- const char *name)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreePath *path;
-
- path = NULL;
-
- model = widget->priv->real_model;
-
- if (name != NULL && gtk_tree_model_get_iter_first (model, &iter)) {
-
- do {
- char *id;
- gboolean found;
-
- id = NULL;
- gtk_tree_model_get (model,
- &iter,
- CHOOSER_LIST_ID_COLUMN, &id,
- -1);
- if (id == NULL) {
- continue;
- }
-
- found = (strcmp (id, name) == 0);
-
- if (found) {
- path = gtk_tree_model_get_path (model, &iter);
- break;
- }
-
- } while (gtk_tree_model_iter_next (model, &iter));
- }
-
- if (path != NULL) {
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (widget->priv->treeview),
- path,
- NULL,
- TRUE,
- 0.5,
- 0.0);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (widget->priv->treeview),
- path,
- NULL,
- FALSE);
-
- gtk_tree_view_row_activated (GTK_TREE_VIEW (widget->priv->treeview),
- path,
- NULL);
- gtk_tree_path_free (path);
- }
-}
-
-static void
-choose_user_id (GdmUserChooserWidget *widget,
- const char *id)
-{
-
- g_debug ("GdmUserChooserWidget: Selection changed from:'%s' to:'%s'",
- widget->priv->chosen_user ? widget->priv->chosen_user : "",
- id ? id : "");
-
- g_free (widget->priv->chosen_user);
- widget->priv->chosen_user = g_strdup (id);
-
- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (widget->priv->filter_model));
-}
-
-static void
-choose_selected_user (GdmUserChooserWidget *widget)
-{
- char *id;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- id = NULL;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget->priv->treeview));
- if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
- gtk_tree_model_get (model, &iter, CHOOSER_LIST_ID_COLUMN, &id, -1);
- }
-
- choose_user_id (widget, id);
-}
-
-static void
-clear_selection (GdmUserChooserWidget *widget)
-{
- GtkTreeSelection *selection;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget->priv->treeview));
- gtk_tree_selection_unselect_all (selection);
+ return gdm_chooser_widget_get_active_item (GDM_CHOOSER_WIDGET (widget));
}
void
@@ -249,14 +102,18 @@ gdm_user_chooser_widget_set_chosen_user_name (GdmUserChooserWidget *widget,
{
g_return_if_fail (GDM_IS_USER_CHOOSER_WIDGET (widget));
- if (name == NULL) {
- clear_selection (widget);
- choose_user_id (widget, NULL);
- } else {
- activate_name (widget, name);
- }
+ gdm_chooser_widget_set_active_item (GDM_CHOOSER_WIDGET (widget), name);
}
+void
+gdm_user_chooser_widget_set_show_only_chosen (GdmUserChooserWidget *widget,
+ gboolean show_only) {
+ g_return_if_fail (GDM_IS_USER_CHOOSER_WIDGET (widget));
+
+ gdm_chooser_widget_set_hide_inactive_items (GDM_CHOOSER_WIDGET (widget),
+ show_only);
+
+}
static void
gdm_user_chooser_widget_set_property (GObject *object,
guint prop_id,
@@ -315,55 +172,22 @@ gdm_user_chooser_widget_dispose (GObject *object)
widget = GDM_USER_CHOOSER_WIDGET (object);
- g_free (widget->priv->chosen_user);
- widget->priv->chosen_user = NULL;
-
G_OBJECT_CLASS (gdm_user_chooser_widget_parent_class)->dispose (object);
}
static void
gdm_user_chooser_widget_class_init (GdmUserChooserWidgetClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = gdm_user_chooser_widget_get_property;
object_class->set_property = gdm_user_chooser_widget_set_property;
object_class->constructor = gdm_user_chooser_widget_constructor;
object_class->dispose = gdm_user_chooser_widget_dispose;
object_class->finalize = gdm_user_chooser_widget_finalize;
- signals [USER_CHOSEN] = g_signal_new ("user-chosen",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmUserChooserWidgetClass, user_chosen),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
g_type_class_add_private (klass, sizeof (GdmUserChooserWidgetPrivate));
}
-static void
-on_selection_changed (GtkTreeSelection *selection,
- GdmUserChooserWidget *widget)
-{
-}
-
-static void
-on_row_activated (GtkTreeView *tree_view,
- GtkTreePath *tree_path,
- GtkTreeViewColumn *tree_column,
- GdmUserChooserWidget *widget)
-{
- choose_selected_user (widget);
-
- g_signal_emit (widget, signals[USER_CHOSEN], 0);
-
- clear_selection (widget);
-}
-
static GdkPixbuf *
get_pixbuf_for_user (GdmUserChooserWidget *widget,
const char *username)
@@ -394,107 +218,37 @@ get_logged_in_pixbuf (GdmUserChooserWidget *widget)
}
static gboolean
-populate_model (GdmUserChooserWidget *widget)
+add_special_users (GdmUserChooserWidget *widget)
{
- GtkTreeIter iter;
GdkPixbuf *pixbuf;
widget->priv->logged_in_pixbuf = get_logged_in_pixbuf (widget);
pixbuf = get_pixbuf_for_user (widget, NULL);
- /* Add some fake entries */
- gtk_list_store_append (GTK_LIST_STORE (widget->priv->real_model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (widget->priv->real_model), &iter,
- CHOOSER_LIST_PIXBUF_COLUMN, pixbuf,
- CHOOSER_LIST_NAME_COLUMN, _("Other..."),
- CHOOSER_LIST_TOOLTIP_COLUMN, _("Choose a different account"),
- CHOOSER_LIST_IS_LOGGED_IN_COLUMN, FALSE,
- CHOOSER_LIST_ID_COLUMN, GDM_USER_CHOOSER_USER_OTHER,
- -1);
-
- gtk_list_store_append (GTK_LIST_STORE (widget->priv->real_model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (widget->priv->real_model), &iter,
- CHOOSER_LIST_PIXBUF_COLUMN, pixbuf,
- CHOOSER_LIST_NAME_COLUMN, _("Guest"),
- CHOOSER_LIST_TOOLTIP_COLUMN, _("Login as a temporary guest"),
- CHOOSER_LIST_IS_LOGGED_IN_COLUMN, FALSE,
- CHOOSER_LIST_ID_COLUMN, GDM_USER_CHOOSER_USER_GUEST,
- -1);
-
+ gdm_chooser_widget_add_item (GDM_CHOOSER_WIDGET (widget),
+ GDM_USER_CHOOSER_USER_OTHER,
+ pixbuf, _("Other..."),
+ _("Choose a different account"), FALSE,
+ TRUE);
+
+ gdm_chooser_widget_add_item (GDM_CHOOSER_WIDGET (widget),
+ GDM_USER_CHOOSER_USER_GUEST,
+ pixbuf, _("Guest"),
+ _("Login as a temporary guest"), FALSE,
+ TRUE);
if (pixbuf != NULL) {
g_object_unref (pixbuf);
}
- widget->priv->populate_id = 0;
return FALSE;
}
-static int
-compare_user_names (char *name_a,
- char *name_b,
- char *id_a,
- char *id_b)
-{
-
- if (id_a == NULL) {
- return 1;
- } else if (id_b == NULL) {
- return -1;
- }
-
- if (strcmp (id_a, "__other") == 0) {
- return 1;
- } else if (strcmp (id_b, "__other") == 0) {
- return -1;
- } else if (strcmp (id_a, "__guest") == 0) {
- return 1;
- } else if (strcmp (id_b, "__guest") == 0) {
- return -1;
- }
-
- if (name_a == NULL) {
- return 1;
- } else if (name_b == NULL) {
- return -1;
- }
-
- return g_utf8_collate (name_a, name_b);
-}
-
-static int
-compare_user (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- gpointer user_data)
-{
- char *name_a;
- char *name_b;
- char *id_a;
- char *id_b;
- int result;
-
- gtk_tree_model_get (model, a, CHOOSER_LIST_NAME_COLUMN, &name_a, -1);
- gtk_tree_model_get (model, b, CHOOSER_LIST_NAME_COLUMN, &name_b, -1);
- gtk_tree_model_get (model, a, CHOOSER_LIST_ID_COLUMN, &id_a, -1);
- gtk_tree_model_get (model, b, CHOOSER_LIST_ID_COLUMN, &id_b, -1);
-
- result = compare_user_names (name_a, name_b, id_a, id_b);
-
- g_free (name_a);
- g_free (name_b);
- g_free (id_a);
- g_free (id_b);
-
- return result;
-}
-
static void
on_user_added (GdmUserManager *manager,
GdmUser *user,
GdmUserChooserWidget *widget)
{
- GtkTreeIter iter;
GdkPixbuf *pixbuf;
char *tooltip;
@@ -502,18 +256,13 @@ on_user_added (GdmUserManager *manager,
pixbuf = gdm_user_render_icon (user, GTK_WIDGET (widget), ICON_SIZE);
- tooltip = g_strdup_printf ("%s: %s",
- _("Short Name"),
+ tooltip = g_strdup_printf (_("Log in as %s"),
gdm_user_get_user_name (user));
- gtk_list_store_append (GTK_LIST_STORE (widget->priv->real_model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (widget->priv->real_model), &iter,
- CHOOSER_LIST_PIXBUF_COLUMN, pixbuf,
- CHOOSER_LIST_NAME_COLUMN, gdm_user_get_real_name (user),
- CHOOSER_LIST_TOOLTIP_COLUMN, tooltip,
- CHOOSER_LIST_IS_LOGGED_IN_COLUMN, gdm_user_get_num_sessions (user) > 0,
- CHOOSER_LIST_ID_COLUMN, gdm_user_get_user_name (user),
- -1);
+ gdm_chooser_widget_add_item (GDM_CHOOSER_WIDGET (widget),
+ gdm_user_get_user_name (user),
+ pixbuf, gdm_user_get_real_name (user),
+ tooltip, FALSE, FALSE);
g_free (tooltip);
if (pixbuf != NULL) {
@@ -526,41 +275,14 @@ on_user_removed (GdmUserManager *manager,
GdmUser *user,
GdmUserChooserWidget *widget)
{
- GtkTreeIter iter;
- gboolean found;
const char *user_name;
g_debug ("GdmUserChooserWidget: User removed: %s", gdm_user_get_user_name (user));
- found = FALSE;
-
user_name = gdm_user_get_user_name (user);
- if (gtk_tree_model_get_iter_first (widget->priv->real_model, &iter)) {
-
- do {
- char *id;
-
- id = NULL;
- gtk_tree_model_get (widget->priv->real_model,
- &iter,
- CHOOSER_LIST_ID_COLUMN, &id,
- -1);
- if (id == NULL) {
- continue;
- }
-
- found = (strcmp (id, user_name) == 0);
-
- if (found) {
- break;
- }
-
- } while (gtk_tree_model_iter_next (widget->priv->real_model, &iter));
- }
- if (found) {
- gtk_list_store_remove (GTK_LIST_STORE (widget->priv->real_model), &iter);
- }
+ gdm_chooser_widget_remove_item (GDM_CHOOSER_WIDGET (widget),
+ user_name);
}
static void
@@ -568,162 +290,28 @@ on_user_is_logged_in_changed (GdmUserManager *manager,
GdmUser *user,
GdmUserChooserWidget *widget)
{
- GtkTreeIter iter;
- gboolean found;
const char *user_name;
gboolean is_logged_in;
g_debug ("GdmUserChooserWidget: User logged in changed: %s", gdm_user_get_user_name (user));
- found = FALSE;
-
user_name = gdm_user_get_user_name (user);
is_logged_in = gdm_user_get_num_sessions (user) > 0;
- if (gtk_tree_model_get_iter_first (widget->priv->real_model, &iter)) {
-
- do {
- char *id;
-
- id = NULL;
- gtk_tree_model_get (widget->priv->real_model,
- &iter,
- CHOOSER_LIST_ID_COLUMN, &id,
- -1);
- if (id == NULL) {
- continue;
- }
-
- found = (strcmp (id, user_name) == 0);
-
- if (found) {
- break;
- }
-
- } while (gtk_tree_model_iter_next (widget->priv->real_model, &iter));
- }
-
- if (found) {
- gtk_list_store_set (GTK_LIST_STORE (widget->priv->real_model),
- &iter,
- CHOOSER_LIST_IS_LOGGED_IN_COLUMN, is_logged_in,
- -1);
- }
-}
-
-static gboolean
-user_visible_cb (GtkTreeModel *model,
- GtkTreeIter *iter,
- GdmUserChooserWidget *widget)
-{
- char *id;
- gboolean ret;
-
- ret = FALSE;
-
- id = NULL;
- gtk_tree_model_get (model, iter, CHOOSER_LIST_ID_COLUMN, &id, -1);
- if (id == NULL) {
- goto out;
- }
-
- /* if a user is chosen */
- if (widget->priv->chosen_user != NULL
- && widget->priv->show_only_chosen) {
-
- ret = (strcmp (id, widget->priv->chosen_user) == 0);
- goto out;
- }
-
- if (! widget->priv->show_other_user
- && strcmp (id, GDM_USER_CHOOSER_USER_OTHER) == 0) {
- ret = FALSE;
- goto out;
- }
- if (! widget->priv->show_guest_user
- && strcmp (id, GDM_USER_CHOOSER_USER_GUEST) == 0) {
- ret = FALSE;
- goto out;
- }
-
- ret = TRUE;
-
- out:
- g_free (id);
-
- return ret;
-}
-
-static void
-name_cell_data_func (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- GdmUserChooserWidget *widget)
-{
- gboolean logged_in;
- char *name;
- char *markup;
-
- name = NULL;
- gtk_tree_model_get (model,
- iter,
- CHOOSER_LIST_IS_LOGGED_IN_COLUMN, &logged_in,
- CHOOSER_LIST_NAME_COLUMN, &name,
- -1);
-
- if (logged_in) {
- markup = g_strdup_printf ("<b>%s</b>\n<i><span size=\"x-small\">%s</span></i>",
- name,
- _("Currently logged in"));
- } else {
- markup = g_strdup_printf ("<b>%s</b>", name);
- }
-
- g_object_set (cell,
- "markup", markup,
- NULL);
-
- g_free (markup);
- g_free (name);
-}
-
-static void
-check_cell_data_func (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- GdmUserChooserWidget *widget)
-{
- gboolean logged_in;
- GdkPixbuf *pixbuf;
-
- gtk_tree_model_get (model,
- iter,
- CHOOSER_LIST_IS_LOGGED_IN_COLUMN, &logged_in,
- -1);
-
- if (logged_in) {
- pixbuf = widget->priv->logged_in_pixbuf;
- } else {
- pixbuf = NULL;
- }
-
- g_object_set (cell,
- "pixbuf", pixbuf,
- NULL);
+ gdm_chooser_widget_set_item_in_use (GDM_CHOOSER_WIDGET (widget),
+ user_name, is_logged_in);
}
static void
gdm_user_chooser_widget_init (GdmUserChooserWidget *widget)
{
- GtkWidget *scrolled;
- GtkTreeViewColumn *column;
- GtkTreeSelection *selection;
- GtkCellRenderer *renderer;
-
widget->priv = GDM_USER_CHOOSER_WIDGET_GET_PRIVATE (widget);
+ gdm_chooser_widget_set_separator_position (GDM_CHOOSER_WIDGET (widget),
+ GDM_CHOOSER_WIDGET_POSITION_BOTTOM);
+ gdm_chooser_widget_set_in_use_message (GDM_CHOOSER_WIDGET (widget),
+ _("Currently logged in"));
+
widget->priv->manager = gdm_user_manager_ref_default ();
g_signal_connect (widget->priv->manager,
"user-added",
@@ -738,103 +326,7 @@ gdm_user_chooser_widget_init (GdmUserChooserWidget *widget)
G_CALLBACK (on_user_is_logged_in_changed),
widget);
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
- GTK_SHADOW_IN);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start (GTK_BOX (widget), scrolled, TRUE, TRUE, 0);
-
- widget->priv->treeview = gtk_tree_view_new ();
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget->priv->treeview), FALSE);
-
- g_signal_connect (widget->priv->treeview,
- "row-activated",
- G_CALLBACK (on_row_activated),
- widget);
- gtk_container_add (GTK_CONTAINER (scrolled), widget->priv->treeview);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget->priv->treeview));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
- g_signal_connect (selection, "changed",
- G_CALLBACK (on_selection_changed),
- widget);
-
- widget->priv->real_model = (GtkTreeModel *)gtk_list_store_new (5,
- GDK_TYPE_PIXBUF,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN,
- G_TYPE_STRING);
-
- widget->priv->filter_model = gtk_tree_model_filter_new (widget->priv->real_model, NULL);
-
- gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (widget->priv->filter_model),
- (GtkTreeModelFilterVisibleFunc) user_visible_cb,
- widget,
- NULL);
-
- widget->priv->sort_model = gtk_tree_model_sort_new_with_model (widget->priv->filter_model);
-
- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (widget->priv->sort_model),
- CHOOSER_LIST_NAME_COLUMN,
- compare_user,
- NULL, NULL);
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (widget->priv->sort_model),
- CHOOSER_LIST_NAME_COLUMN,
- GTK_SORT_ASCENDING);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (widget->priv->treeview), widget->priv->sort_model);
-
- /* CHECK COLUMN */
- renderer = gtk_cell_renderer_pixbuf_new ();
- 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->treeview), column);
- gtk_tree_view_column_set_cell_data_func (column,
- renderer,
- (GtkTreeCellDataFunc) check_cell_data_func,
- widget,
- NULL);
- g_object_set (renderer,
- "width", 96,
- "yalign", 0.5,
- "xalign", 0.5,
- NULL);
-
- /* FACE COLUMN */
- renderer = gtk_cell_renderer_pixbuf_new ();
- 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->treeview), column);
-
- gtk_tree_view_column_set_attributes (column,
- renderer,
- "pixbuf", CHOOSER_LIST_PIXBUF_COLUMN,
- NULL);
-
- g_object_set (renderer,
- "width", 64,
- "yalign", 0.5,
- "xalign", 1.0,
- NULL);
-
- /* NAME COLUMN */
- renderer = gtk_cell_renderer_text_new ();
- 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->treeview), column);
- gtk_tree_view_column_set_cell_data_func (column,
- renderer,
- (GtkTreeCellDataFunc) name_cell_data_func,
- widget,
- NULL);
-
- gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (widget->priv->treeview), CHOOSER_LIST_TOOLTIP_COLUMN);
-
- widget->priv->populate_id = g_idle_add ((GSourceFunc)populate_model, widget);
+ add_special_users (widget);
}
static void
@@ -849,10 +341,6 @@ gdm_user_chooser_widget_finalize (GObject *object)
g_return_if_fail (widget->priv != NULL);
- if (widget->priv->populate_id > 0) {
- g_source_remove (widget->priv->populate_id);
- }
-
G_OBJECT_CLASS (gdm_user_chooser_widget_parent_class)->finalize (object);
}
@@ -862,6 +350,8 @@ gdm_user_chooser_widget_new (void)
GObject *object;
object = g_object_new (GDM_TYPE_USER_CHOOSER_WIDGET,
+ "inactive-text", _("_Users:"),
+ "active-text", _("_User:"),
NULL);
return GTK_WIDGET (object);
diff --git a/gui/simple-greeter/gdm-user-chooser-widget.h b/gui/simple-greeter/gdm-user-chooser-widget.h
index 9c1ef6f..a117fb3 100644
--- a/gui/simple-greeter/gdm-user-chooser-widget.h
+++ b/gui/simple-greeter/gdm-user-chooser-widget.h
@@ -22,7 +22,8 @@
#define __GDM_USER_CHOOSER_WIDGET_H
#include <glib-object.h>
-#include <gtk/gtkvbox.h>
+
+#include "gdm-chooser-widget.h"
G_BEGIN_DECLS
@@ -37,16 +38,13 @@ typedef struct GdmUserChooserWidgetPrivate GdmUserChooserWidgetPrivate;
typedef struct
{
- GtkVBox parent;
+ GdmChooserWidget parent;
GdmUserChooserWidgetPrivate *priv;
} GdmUserChooserWidget;
typedef struct
{
- GtkVBoxClass parent_class;
-
- /* signals */
- void (* user_chosen) (GdmUserChooserWidget *widget);
+ GdmChooserWidgetClass parent_class;
} GdmUserChooserWidgetClass;
#define GDM_USER_CHOOSER_USER_OTHER "__other"
@@ -64,7 +62,6 @@ void gdm_user_chooser_widget_set_show_other_user (GdmUs
gboolean show_other);
void gdm_user_chooser_widget_set_show_guest_user (GdmUserChooserWidget *widget,
gboolean show_other);
-
G_END_DECLS
#endif /* __GDM_USER_CHOOSER_WIDGET_H */
--
1.5.3.6

View File

@ -0,0 +1,522 @@
From 62276dc527e60a27f951cf73ad8de3fb1c8ced8a Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 13 Dec 2007 10:14:33 -0500
Subject: [PATCH] Change session-chooser-widget over to use new chooser widget
---
gui/simple-greeter/gdm-session-chooser-widget.c | 352 +++--------------------
gui/simple-greeter/gdm-session-chooser-widget.h | 15 +-
2 files changed, 50 insertions(+), 317 deletions(-)
diff --git a/gui/simple-greeter/gdm-session-chooser-widget.c b/gui/simple-greeter/gdm-session-chooser-widget.c
index 7763da7..849be94 100644
--- a/gui/simple-greeter/gdm-session-chooser-widget.c
+++ b/gui/simple-greeter/gdm-session-chooser-widget.c
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2007 Ray Strode <rstrode@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -34,6 +35,7 @@
#include <gtk/gtk.h>
#include "gdm-session-chooser-widget.h"
+#include "gdm-chooser-widget.h"
enum {
DESKTOP_ENTRY_NO_DISPLAY = 1 << 0,
@@ -54,34 +56,18 @@ typedef struct _GdmChooserSession {
struct GdmSessionChooserWidgetPrivate
{
- GtkWidget *treeview;
-
GHashTable *available_sessions;
- char *current_session;
};
enum {
PROP_0,
};
-enum {
- SESSION_ACTIVATED,
- LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0, };
-
static void gdm_session_chooser_widget_class_init (GdmSessionChooserWidgetClass *klass);
static void gdm_session_chooser_widget_init (GdmSessionChooserWidget *session_chooser_widget);
static void gdm_session_chooser_widget_finalize (GObject *object);
-G_DEFINE_TYPE (GdmSessionChooserWidget, gdm_session_chooser_widget, GTK_TYPE_VBOX)
-
-enum {
- CHOOSER_LIST_NAME_COLUMN = 0,
- CHOOSER_LIST_COMMENT_COLUMN,
- CHOOSER_LIST_ID_COLUMN
-};
+G_DEFINE_TYPE (GdmSessionChooserWidget, gdm_session_chooser_widget, GDM_TYPE_CHOOSER_WIDGET)
static void
chooser_session_free (GdmChooserSession *session)
@@ -101,89 +87,28 @@ chooser_session_free (GdmChooserSession *session)
char *
gdm_session_chooser_widget_get_current_session_name (GdmSessionChooserWidget *widget)
{
- char *session_name;
-
g_return_val_if_fail (GDM_IS_SESSION_CHOOSER_WIDGET (widget), NULL);
-
- session_name = NULL;
- if (widget->priv->current_session != NULL) {
- session_name = g_strdup (widget->priv->current_session);
- }
-
- return session_name;
+ return gdm_chooser_widget_get_active_item (GDM_CHOOSER_WIDGET (widget));
}
-static void
-select_name (GdmSessionChooserWidget *widget,
- const char *name)
+void
+gdm_session_chooser_widget_set_current_session_name (GdmSessionChooserWidget *widget,
+ const char *name)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreePath *path;
-
- path = NULL;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget->priv->treeview));
-
- if (name != NULL && gtk_tree_model_get_iter_first (model, &iter)) {
-
- do {
- GdmChooserSession *session;
- char *id;
- gboolean found;
-
- session = NULL;
- id = NULL;
- gtk_tree_model_get (model,
- &iter,
- CHOOSER_LIST_ID_COLUMN, &id,
- -1);
- if (id != NULL) {
- session = g_hash_table_lookup (widget->priv->available_sessions, id);
- g_free (id);
- }
-
- found = (session != NULL
- && session->filename != NULL
- && strcmp (session->filename, name) == 0);
-
- if (found) {
- path = gtk_tree_model_get_path (model, &iter);
- break;
- }
-
- } while (gtk_tree_model_iter_next (model, &iter));
- }
+ g_return_if_fail (GDM_IS_SESSION_CHOOSER_WIDGET (widget));
- if (path != NULL) {
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (widget->priv->treeview),
- path,
- gtk_tree_view_get_column (GTK_TREE_VIEW (widget->priv->treeview), 0),
- TRUE, 0.5, 0.0);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (widget->priv->treeview),
- path,
- NULL,
- FALSE);
-
- gtk_tree_path_free (path);
- }
+ gdm_chooser_widget_set_active_item (GDM_CHOOSER_WIDGET (widget),
+ name);
}
void
-gdm_session_chooser_widget_set_current_session_name (GdmSessionChooserWidget *widget,
- const char *name)
+gdm_session_chooser_widget_set_show_only_chosen (GdmSessionChooserWidget *widget,
+ gboolean show_only)
{
- GtkTreeSelection *selection;
-
g_return_if_fail (GDM_IS_SESSION_CHOOSER_WIDGET (widget));
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget->priv->treeview));
-
- if (name == NULL) {
- gtk_tree_selection_unselect_all (selection);
- } else {
- select_name (widget, name);
- }
+ gdm_chooser_widget_set_hide_inactive_items (GDM_CHOOSER_WIDGET (widget),
+ show_only);
}
static void
@@ -249,9 +174,6 @@ gdm_session_chooser_widget_dispose (GObject *object)
widget->priv->available_sessions = NULL;
}
- g_free (widget->priv->current_session);
- widget->priv->current_session = NULL;
-
G_OBJECT_CLASS (gdm_session_chooser_widget_parent_class)->dispose (object);
}
@@ -266,39 +188,9 @@ gdm_session_chooser_widget_class_init (GdmSessionChooserWidgetClass *klass)
object_class->dispose = gdm_session_chooser_widget_dispose;
object_class->finalize = gdm_session_chooser_widget_finalize;
- signals [SESSION_ACTIVATED] = g_signal_new ("session-activated",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmSessionChooserWidgetClass, session_activated),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
g_type_class_add_private (klass, sizeof (GdmSessionChooserWidgetPrivate));
}
-static void
-on_session_selected (GtkTreeSelection *selection,
- GdmSessionChooserWidget *widget)
-{
- GtkTreeModel *model = NULL;
- GtkTreeIter iter = {0};
- char *id;
-
- id = NULL;
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
- gtk_tree_model_get (model, &iter, CHOOSER_LIST_ID_COLUMN, &id, -1);
- }
-
- g_free (widget->priv->current_session);
- widget->priv->current_session = g_strdup (id);
-
- g_free (id);
-}
-
/* adapted from gnome-menus desktop-entries.c */
static guint
get_flags_from_key_file (GKeyFile *key_file,
@@ -460,21 +352,13 @@ collect_sessions (GdmSessionChooserWidget *widget)
}
static void
-on_row_activated (GtkTreeView *tree_view,
- GtkTreePath *tree_path,
- GtkTreeViewColumn *tree_column,
- GdmSessionChooserWidget *widget)
-{
- g_signal_emit (widget, signals[SESSION_ACTIVATED], 0);
-}
-
-static void
-add_session_to_model (const char *name,
- GdmChooserSession *session,
- GdmSessionChooserWidget *widget)
+add_session (const char *name,
+ GdmChooserSession *session,
+ GdmSessionChooserWidget *widget)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
+ g_assert (name != NULL);
+ g_assert (session != NULL);
+ g_assert (GDM_IS_SESSION_CHOOSER_WIDGET (widget));
if (session->flags & DESKTOP_ENTRY_NO_DISPLAY
|| session->flags & DESKTOP_ENTRY_HIDDEN
@@ -483,197 +367,43 @@ add_session_to_model (const char *name,
g_debug ("Not adding session to list: %s", session->filename);
}
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget->priv->treeview));
-
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model),
- &iter,
- CHOOSER_LIST_NAME_COLUMN, session->translated_name,
- CHOOSER_LIST_COMMENT_COLUMN, session->translated_comment,
- CHOOSER_LIST_ID_COLUMN, name,
- -1);
+ gdm_chooser_widget_add_item (GDM_CHOOSER_WIDGET (widget), name,
+ NULL, session->translated_name,
+ session->translated_comment, FALSE, FALSE);
}
static void
-populate_model (GdmSessionChooserWidget *widget,
- GtkTreeModel *model)
+add_available_sessions (GdmSessionChooserWidget *widget)
{
- GtkTreeIter iter;
-
- /* Add some fake entries */
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- CHOOSER_LIST_NAME_COLUMN, _("Previous Session"),
- CHOOSER_LIST_ID_COLUMN, "__previous-session",
- -1);
-
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- CHOOSER_LIST_NAME_COLUMN, _("System Default"),
- CHOOSER_LIST_ID_COLUMN, "__default-session",
- -1);
-
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- CHOOSER_LIST_NAME_COLUMN, NULL,
- CHOOSER_LIST_ID_COLUMN, "__separator",
- -1);
+ gdm_chooser_widget_add_item (GDM_CHOOSER_WIDGET (widget),
+ GDM_SESSION_CHOOSER_SESSION_PREVIOUS,
+ NULL, _("Default"),
+ _("Login with the same session as "
+ "last time."),
+ FALSE, TRUE);
+ gdm_chooser_widget_add_item (GDM_CHOOSER_WIDGET (widget),
+ GDM_SESSION_CHOOSER_SESSION_DEFAULT,
+ NULL, _("Legacy"),
+ _("Login based on preset legacy configuration"),
+ FALSE, TRUE);
g_hash_table_foreach (widget->priv->available_sessions,
- (GHFunc)add_session_to_model,
+ (GHFunc) add_session,
widget);
}
-static gboolean
-separator_func (GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer data)
-{
- int column = GPOINTER_TO_INT (data);
- char *text;
-
- gtk_tree_model_get (model, iter, column, &text, -1);
-
- if (text != NULL && strcmp (text, "__separator") == 0) {
- return TRUE;
- }
-
- g_free (text);
-
- return FALSE;
-}
-
-static int
-compare_session_names (char *name_a,
- char *name_b,
- char *id_a,
- char *id_b)
-{
-
- if (id_a == NULL) {
- return 1;
- } else if (id_b == NULL) {
- return -1;
- }
-
- if (strcmp (id_a, "__previous-session") == 0) {
- return -1;
- } else if (strcmp (id_b, "__previous-session") == 0) {
- return 1;
- } else if (strcmp (id_a, "__default-session") == 0) {
- return -1;
- } else if (strcmp (id_b, "__default-session") == 0) {
- return 1;
- } else if (strcmp (id_a, "__separator") == 0) {
- return -1;
- } else if (strcmp (id_b, "__separator") == 0) {
- return 1;
- }
-
- if (name_a == NULL) {
- return 1;
- } else if (name_b == NULL) {
- return -1;
- }
-
- return g_utf8_collate (name_a, name_b);
-}
-
-static int
-compare_session (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- gpointer user_data)
-{
- char *name_a;
- char *name_b;
- char *id_a;
- char *id_b;
- int result;
-
- gtk_tree_model_get (model, a, CHOOSER_LIST_NAME_COLUMN, &name_a, -1);
- gtk_tree_model_get (model, b, CHOOSER_LIST_NAME_COLUMN, &name_b, -1);
- gtk_tree_model_get (model, a, CHOOSER_LIST_ID_COLUMN, &id_a, -1);
- gtk_tree_model_get (model, b, CHOOSER_LIST_ID_COLUMN, &id_b, -1);
-
- result = compare_session_names (name_a, name_b, id_a, id_b);
-
- g_free (name_a);
- g_free (name_b);
- g_free (id_a);
- g_free (id_b);
-
- return result;
-}
-
static void
gdm_session_chooser_widget_init (GdmSessionChooserWidget *widget)
{
- GtkWidget *scrolled;
- GtkTreeSelection *selection;
- GtkTreeViewColumn *column;
- GtkTreeModel *model;
-
widget->priv = GDM_SESSION_CHOOSER_WIDGET_GET_PRIVATE (widget);
+ gdm_chooser_widget_set_separator_position (GDM_CHOOSER_WIDGET (widget),
+ GDM_CHOOSER_WIDGET_POSITION_TOP);
widget->priv->available_sessions = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)chooser_session_free);
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
- GTK_SHADOW_IN);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start (GTK_BOX (widget), scrolled, TRUE, TRUE, 0);
-
- widget->priv->treeview = gtk_tree_view_new ();
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget->priv->treeview), FALSE);
- g_signal_connect (widget->priv->treeview,
- "row-activated",
- G_CALLBACK (on_row_activated),
- widget);
- gtk_container_add (GTK_CONTAINER (scrolled), widget->priv->treeview);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget->priv->treeview));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
- g_signal_connect (selection, "changed",
- G_CALLBACK (on_session_selected),
- widget);
-
- model = (GtkTreeModel *)gtk_list_store_new (3,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING);
- gtk_tree_view_set_model (GTK_TREE_VIEW (widget->priv->treeview), model);
-
- column = gtk_tree_view_column_new_with_attributes ("Session",
- gtk_cell_renderer_text_new (),
- "text", CHOOSER_LIST_NAME_COLUMN,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (widget->priv->treeview), column);
-
- column = gtk_tree_view_column_new_with_attributes ("Comment",
- gtk_cell_renderer_text_new (),
- "text", CHOOSER_LIST_COMMENT_COLUMN,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (widget->priv->treeview), column);
-
- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model),
- CHOOSER_LIST_NAME_COLUMN,
- compare_session,
- NULL, NULL);
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
- CHOOSER_LIST_NAME_COLUMN,
- GTK_SORT_ASCENDING);
-
- gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (widget->priv->treeview),
- separator_func,
- GINT_TO_POINTER (CHOOSER_LIST_ID_COLUMN),
- NULL);
-
collect_sessions (widget);
- populate_model (widget, model);
+ add_available_sessions (widget);
}
static void
@@ -696,7 +426,9 @@ gdm_session_chooser_widget_new (void)
{
GObject *object;
- object = g_object_new (GDM_TYPE_SESSION_CHOOSER_WIDGET,
+ object = g_object_new (GDM_TYPE_SESSION_CHOOSER_WIDGET,
+ "inactive-text", _("_Sessions:"),
+ "active-text", _("_Session:"),
NULL);
return GTK_WIDGET (object);
diff --git a/gui/simple-greeter/gdm-session-chooser-widget.h b/gui/simple-greeter/gdm-session-chooser-widget.h
index ec32b23..63ea466 100644
--- a/gui/simple-greeter/gdm-session-chooser-widget.h
+++ b/gui/simple-greeter/gdm-session-chooser-widget.h
@@ -22,7 +22,7 @@
#define __GDM_SESSION_CHOOSER_WIDGET_H
#include <glib-object.h>
-#include <gtk/gtkvbox.h>
+#include "gdm-chooser-widget.h"
G_BEGIN_DECLS
@@ -37,25 +37,26 @@ typedef struct GdmSessionChooserWidgetPrivate GdmSessionChooserWidgetPrivate;
typedef struct
{
- GtkVBox parent;
+ GdmChooserWidget parent;
GdmSessionChooserWidgetPrivate *priv;
} GdmSessionChooserWidget;
typedef struct
{
- GtkVBoxClass parent_class;
-
- /* signals */
- void (* session_activated) (GdmSessionChooserWidget *widget);
+ GdmChooserWidgetClass parent_class;
} GdmSessionChooserWidgetClass;
+#define GDM_SESSION_CHOOSER_SESSION_PREVIOUS "__previous-session"
+#define GDM_SESSION_CHOOSER_SESSION_DEFAULT "__default-session"
+
GType gdm_session_chooser_widget_get_type (void);
GtkWidget * gdm_session_chooser_widget_new (void);
char * gdm_session_chooser_widget_get_current_session_name (GdmSessionChooserWidget *widget);
void gdm_session_chooser_widget_set_current_session_name (GdmSessionChooserWidget *widget,
const char *session_name);
-
+void gdm_session_chooser_widget_set_show_only_chosen (GdmSessionChooserWidget *widget,
+ gboolean show_only);
G_END_DECLS
#endif /* __GDM_SESSION_CHOOSER_WIDGET_H */
--
1.5.3.6

View File

@ -0,0 +1,24 @@
From ed5e63fbb8cf281f8e7bfd8062b3f453fcb3d279 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 13 Dec 2007 10:16:37 -0500
Subject: [PATCH] Don't shrink to chosen item by by default for dialog
---
gui/simple-greeter/gdm-user-chooser-dialog.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/gui/simple-greeter/gdm-user-chooser-dialog.c b/gui/simple-greeter/gdm-user-chooser-dialog.c
index f3e83a2..4848177 100644
--- a/gui/simple-greeter/gdm-user-chooser-dialog.c
+++ b/gui/simple-greeter/gdm-user-chooser-dialog.c
@@ -154,7 +154,6 @@ gdm_user_chooser_dialog_init (GdmUserChooserDialog *dialog)
dialog->priv = GDM_USER_CHOOSER_DIALOG_GET_PRIVATE (dialog);
dialog->priv->chooser_widget = gdm_user_chooser_widget_new ();
- gdm_user_chooser_widget_set_show_only_chosen (GDM_USER_CHOOSER_WIDGET (dialog->priv->chooser_widget), TRUE);
gdm_user_chooser_widget_set_show_other_user (GDM_USER_CHOOSER_WIDGET (dialog->priv->chooser_widget), TRUE);
gdm_user_chooser_widget_set_show_guest_user (GDM_USER_CHOOSER_WIDGET (dialog->priv->chooser_widget), TRUE);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->priv->chooser_widget);
--
1.5.3.6

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,138 @@
From 33c2ba849b1f752deb38cf8715571eadbc4b323b Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 13 Dec 2007 14:38:16 -0500
Subject: [PATCH] add lame animation to greeter login window
---
gui/simple-greeter/gdm-greeter-login-window.c | 90 +++++++++++++++++++++++-
1 files changed, 86 insertions(+), 4 deletions(-)
diff --git a/gui/simple-greeter/gdm-greeter-login-window.c b/gui/simple-greeter/gdm-greeter-login-window.c
index ca14b38..ceb9e88 100644
--- a/gui/simple-greeter/gdm-greeter-login-window.c
+++ b/gui/simple-greeter/gdm-greeter-login-window.c
@@ -72,6 +72,8 @@ struct GdmGreeterLoginWindowPrivate
char *timeformat;
guint update_clock_id;
gboolean clock_show_seconds;
+
+ guint animation_timeout_id;
};
enum {
@@ -860,12 +862,60 @@ load_theme (GdmGreeterLoginWindow *login_window)
switch_mode (login_window, MODE_SELECTION);
}
+static gboolean
+fit_window_to_children (GdmGreeterLoginWindow *window)
+{
+ int x;
+ int y;
+ int width;
+ int height;
+ int height_step;
+ int width_step;
+
+ /* FIXME: this animation logic is really dumb
+ */
+
+ if (!GTK_WIDGET_REALIZED (GTK_WIDGET (window))) {
+ return FALSE;
+ }
+
+ gdk_window_get_geometry (GTK_WIDGET (window)->window,
+ &x, &y, &width, &height, NULL);
+
+ if (height == GTK_WIDGET (window)->requisition.height) {
+ return FALSE;
+ }
+
+ if (width < GTK_WIDGET (window)->requisition.width) {
+ width_step = MIN (1, GTK_WIDGET (window)->requisition.width - width);
+ } else if (width > GTK_WIDGET (window)->requisition.width) {
+ width_step = -1 * MIN (1, width - GTK_WIDGET (window)->requisition.width);
+ } else {
+ width_step = 0;
+ }
+
+ if (height < GTK_WIDGET (window)->requisition.height) {
+ height_step = MIN ((int) 25, GTK_WIDGET (window)->requisition.height - height);
+ } else if (height > GTK_WIDGET (window)->requisition.height) {
+ height_step = -1 * MIN ((int) 25, height - GTK_WIDGET (window)->requisition.height);
+ } else {
+ height_step = 0;
+ }
+
+ gdk_window_resize (GTK_WIDGET (window)->window,
+ width + width_step,
+ height + height_step);
+
+ return TRUE;
+}
+
static void
gdm_greeter_login_window_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
- int screen_w;
- int screen_h;
+ int screen_w;
+ int screen_h;
+ GtkRequisition child_requisition;
if (GTK_WIDGET_CLASS (gdm_greeter_login_window_parent_class)->size_request) {
GTK_WIDGET_CLASS (gdm_greeter_login_window_parent_class)->size_request (widget, requisition);
@@ -874,8 +924,39 @@ gdm_greeter_login_window_size_request (GtkWidget *widget,
screen_w = gdk_screen_get_width (gtk_widget_get_screen (widget));
screen_h = gdk_screen_get_height (gtk_widget_get_screen (widget));
- requisition->height = screen_h * 0.5;
- requisition->width = screen_w * 0.3;
+ gtk_widget_size_request (GTK_BIN (widget)->child, &child_requisition);
+ *requisition = child_requisition;
+
+ requisition->width += 2 * GTK_CONTAINER (widget)->border_width;
+ requisition->height += 2 * GTK_CONTAINER (widget)->border_width;
+
+ requisition->width = MIN (requisition->width, .50 * screen_w);
+ requisition->height = MIN (requisition->height, .80 * screen_h);
+}
+
+static void
+clear_animation_timeout_id (GdmGreeterLoginWindow *window)
+{
+ window->priv->animation_timeout_id = 0;
+}
+
+static void
+gdm_greeter_login_window_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GdmGreeterLoginWindow *window;
+
+ window = GDM_GREETER_LOGIN_WINDOW (widget);
+
+ if (window->priv->animation_timeout_id == 0) {
+ window->priv->animation_timeout_id =
+ g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 20,
+ (GSourceFunc) fit_window_to_children,
+ widget,
+ (GDestroyNotify) clear_animation_timeout_id);
+ }
+
+ GTK_WIDGET_CLASS (gdm_greeter_login_window_parent_class)->size_allocate (widget, allocation);
}
static GObject *
@@ -910,6 +991,7 @@ gdm_greeter_login_window_class_init (GdmGreeterLoginWindowClass *klass)
object_class->finalize = gdm_greeter_login_window_finalize;
widget_class->size_request = gdm_greeter_login_window_size_request;
+ widget_class->size_allocate = gdm_greeter_login_window_size_allocate;
signals [BEGIN_VERIFICATION] =
g_signal_new ("begin-verification",
--
1.5.3.6

View File

@ -16,7 +16,7 @@
Summary: The GNOME Display Manager
Name: gdm
Version: 2.21.2
Release: 0.2007.11.20.4%{?dist}
Release: 0.2007.11.20.5%{?dist}
Epoch: 1
License: GPLv2+
Group: User Interface/X
@ -82,6 +82,13 @@ Requires: audit-libs >= %{libauditver}
Patch0: gdm-2.21.2-use-metacity.patch
Patch1: gdm-2.21.2-fix-background.patch
Patch2: 2-new-chooser-widget.patch
Patch3: 3-switch-user-chooser-over.patch
Patch4: 4-switch-session-chooser-over.patch
Patch5: 5-dont-shrink-in-test-program.patch
Patch6: 6-session-chooser-in-login-window.patch
Patch7: 7-login-window-animation.patch
%description
Gdm (the GNOME Display Manager) is a highly configurable
@ -93,6 +100,12 @@ several different X sessions on your local machine at the same time.
%setup -q
%patch0 -p1 -b .use-metacity
%patch1 -p1 -b .fix-background
%patch2 -p1 -b .new-chooser-widget
%patch3 -p1 -b .switch-user-chooser-over
%patch4 -p1 -b .switch-session-chooser-over
%patch5 -p1 -b .dont-shrink-in-test-program
%patch6 -p1 -b .session-chooser-in-login-window
%patch7 -p1 -b .login-window-animation
%build
cp -f %{SOURCE1} data/gdm
@ -280,6 +293,10 @@ fi
%attr(1770, root, gdm) %dir %{_localstatedir}/lib/gdm
%changelog
* Thu Dec 13 2007 Ray Strode <rstrode@redhat.com> - 1:2.21.2-0.2007.11.20.5
- add session chooser to login screen
- add hoaky animations
* Fri Nov 30 2007 Matthias Clasen <mclasen@redhat.com> - 1:2.21.2-0.2007.11.20.4
- Use the new "substack" support in pam to make keyring unlocking work