Commit 9bfb47bf authored by William Jon McCann's avatar William Jon McCann Committed by William Jon McCann

Revert last commit. Use simpler widget. Add tooltips and change

2007-10-02  William Jon McCann  <mccann@jhu.edu>

	* gui/simple-greeter/gdm-user-chooser-widget.c:
	(add_user_to_model), (populate_model),
	(gdm_user_chooser_widget_init):
	Revert last commit.  Use simpler widget.
	Add tooltips and change orientation.


svn path=/branches/mccann-gobject/; revision=5328
parent 169a989d
2007-10-02 William Jon McCann <mccann@jhu.edu>
* gui/simple-greeter/gdm-user-chooser-widget.c:
(add_user_to_model), (populate_model),
(gdm_user_chooser_widget_init):
Revert last commit. Use simpler widget.
Add tooltips and change orientation.
2007-10-02 William Jon McCann <mccann@jhu.edu>
* gui/simple-greeter/Makefile.am:
......
......@@ -83,8 +83,6 @@ test_user_chooser_SOURCES = \
gdm-user-chooser-widget.c \
gdm-user-chooser-dialog.h \
gdm-user-chooser-dialog.c \
gdm-icon-nav.h \
gdm-icon-nav.c \
$(NULL)
test_user_chooser_LDADD = \
......
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2006 The Free Software Foundation
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GDM_ICON_NAV_H__
#define __GDM_ICON_NAV_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
typedef struct _GdmIconNav GdmIconNav;
typedef struct _GdmIconNavClass GdmIconNavClass;
typedef struct _GdmIconNavPrivate GdmIconNavPrivate;
#define GDM_TYPE_ICON_NAV (gdm_icon_nav_get_type ())
#define GDM_ICON_NAV(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GDM_TYPE_ICON_NAV, GdmIconNav))
#define GDM_ICON_NAV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GDM_TYPE_ICON_NAV, GdmIconNavClass))
#define GDM_IS_ICON_NAV(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GDM_TYPE_ICON_NAV))
#define GDM_IS_ICON_NAV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GDM_TYPE_ICON_NAV))
#define GDM_ICON_NAV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GDM_TYPE_ICON_NAV, GdmIconNavClass))
typedef enum {
GDM_ICON_NAV_MODE_ONE_ROW,
GDM_ICON_NAV_MODE_ONE_COLUMN,
GDM_ICON_NAV_MODE_MULTIPLE_ROWS,
GDM_ICON_NAV_MODE_MULTIPLE_COLUMNS
} GdmIconNavMode;
struct _GdmIconNav {
GtkHBox base_instance;
GdmIconNavPrivate *priv;
};
struct _GdmIconNavClass {
GtkHBoxClass parent_class;
};
GType gdm_icon_nav_get_type (void) G_GNUC_CONST;
GtkWidget *gdm_icon_nav_new (GtkWidget *iconview,
GdmIconNavMode mode,
gboolean show_buttons);
gboolean gdm_icon_nav_get_show_buttons (GdmIconNav *nav);
void gdm_icon_nav_set_show_buttons (GdmIconNav *nav,
gboolean show_buttons);
GdmIconNavMode gdm_icon_nav_get_mode (GdmIconNav *nav);
void gdm_icon_nav_set_mode (GdmIconNav *nav,
GdmIconNavMode mode);
G_END_DECLS
#endif /* __GDM_ICON_NAV_H__ */
......@@ -80,6 +80,7 @@ G_DEFINE_TYPE (GdmUserChooserWidget, gdm_user_chooser_widget, GTK_TYPE_VBOX)
enum {
CHOOSER_LIST_PIXBUF_COLUMN = 0,
CHOOSER_LIST_CAPTION_COLUMN,
CHOOSER_LIST_TOOLTIP_COLUMN,
CHOOSER_LIST_ID_COLUMN
};
......@@ -328,6 +329,7 @@ add_user_to_model (const char *name,
GtkTreeModel *model;
GtkTreeIter iter;
char *caption;
char *tooltip;
if (user->flags & USER_NO_DISPLAY
|| user->flags & USER_ACCOUNT_DISABLED) {
......@@ -335,8 +337,10 @@ add_user_to_model (const char *name,
g_debug ("Not adding user to list: %s", user->name);
}
caption = g_strdup_printf ("<span size=\"x-large\">%s</span>\n(%s)",
user->realname,
caption = g_strdup_printf ("<span size=\"x-large\">%s</span>",
user->realname);
tooltip = g_strdup_printf ("%s: %s",
_("Short Name"),
user->name);
model = gtk_icon_view_get_model (GTK_ICON_VIEW (widget->priv->iconview));
......@@ -346,6 +350,7 @@ add_user_to_model (const char *name,
&iter,
CHOOSER_LIST_PIXBUF_COLUMN, user->pixbuf,
CHOOSER_LIST_CAPTION_COLUMN, caption,
CHOOSER_LIST_TOOLTIP_COLUMN, tooltip,
CHOOSER_LIST_ID_COLUMN, name,
-1);
g_free (caption);
......@@ -373,33 +378,42 @@ populate_model (GdmUserChooserWidget *widget,
GtkTreeIter iter;
GdkPixbuf *pixbuf;
char *caption;
char *tooltip;
/* Add some fake entries */
caption = g_strdup_printf ("<span size=\"x-large\">%s</span>\n<span size=\"small\">(%s)</span>\n<i>%s</i>",
caption = g_strdup_printf ("<span size=\"x-large\">%s</span>\n<i>%s</i>",
_("Guest User"),
"guest",
_("Already logged in"));
tooltip = g_strdup_printf ("%s: %s",
_("Short Name"),
"guest");
pixbuf = get_pixbuf_for_user (widget, "guest");
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
CHOOSER_LIST_PIXBUF_COLUMN, pixbuf,
CHOOSER_LIST_CAPTION_COLUMN, caption,
CHOOSER_LIST_TOOLTIP_COLUMN, tooltip,
CHOOSER_LIST_ID_COLUMN, "guest",
-1);
g_free (caption);
g_free (tooltip);
caption = g_strdup_printf ("<span size=\"x-large\">%s</span>\n<span size=\"small\">(%s)</span>",
_("Administrator"),
caption = g_strdup_printf ("<span size=\"x-large\">%s</span>",
_("Administrator"));
tooltip = g_strdup_printf ("%s: %s",
_("Short Name"),
"administrator");
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
CHOOSER_LIST_PIXBUF_COLUMN, pixbuf,
CHOOSER_LIST_CAPTION_COLUMN, caption,
CHOOSER_LIST_TOOLTIP_COLUMN, tooltip,
CHOOSER_LIST_ID_COLUMN, "administrator",
-1);
g_free (caption);
g_free (tooltip);
if (pixbuf != NULL) {
g_object_unref (pixbuf);
......@@ -503,7 +517,7 @@ gdm_user_chooser_widget_init (GdmUserChooserWidget *widget)
widget->priv->iconview = gtk_icon_view_new ();
gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (widget->priv->iconview), GTK_SELECTION_SINGLE);
gtk_icon_view_set_orientation (GTK_ICON_VIEW (widget->priv->iconview), GTK_ORIENTATION_VERTICAL);
gtk_icon_view_set_orientation (GTK_ICON_VIEW (widget->priv->iconview), GTK_ORIENTATION_HORIZONTAL);
g_signal_connect (widget->priv->iconview,
"item-activated",
G_CALLBACK (on_item_activated),
......@@ -518,14 +532,16 @@ gdm_user_chooser_widget_init (GdmUserChooserWidget *widget)
TRUE);
gtk_box_pack_start (GTK_BOX (widget), widget->priv->nav, TRUE, TRUE, 0);
model = (GtkTreeModel *)gtk_list_store_new (3,
model = (GtkTreeModel *)gtk_list_store_new (4,
GDK_TYPE_PIXBUF,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING);
gtk_icon_view_set_model (GTK_ICON_VIEW (widget->priv->iconview), model);
gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (widget->priv->iconview), CHOOSER_LIST_PIXBUF_COLUMN);
gtk_icon_view_set_markup_column (GTK_ICON_VIEW (widget->priv->iconview), CHOOSER_LIST_CAPTION_COLUMN);
gtk_icon_view_set_tooltip_column (GTK_ICON_VIEW (widget->priv->iconview), CHOOSER_LIST_TOOLTIP_COLUMN);
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model),
CHOOSER_LIST_CAPTION_COLUMN,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment