Commit 7b2080c2 authored by William Jon McCann's avatar William Jon McCann Committed by William Jon McCann

Add basic user monitoring. Hook up to user-list.

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

	* configure.ac:
	* gui/simple-greeter/Makefile.am:
	* gui/simple-greeter/gdm-user-chooser-widget.c: (populate_model),
	(on_user_added), (on_user_removed), (gdm_user_chooser_widget_init):
	* gui/simple-greeter/gdm-user-manager.c:
	(gdm_user_manager_error_quark), (gdm_user_manager_get_user),
	(listify_hash_values_hfunc), (gdm_user_manager_list_users),
	(reload_passwd), (reload_shells), (shells_monitor_cb),
	(passwd_monitor_cb), (gdm_user_manager_class_init),
	(reload_passwd_timeout), (queue_reload_passwd),
	(gdm_user_manager_init), (gdm_user_manager_finalize),
	(gdm_user_manager_ref_default):
	* gui/simple-greeter/gdm-user-manager.h:
	* gui/simple-greeter/gdm-user.c: (gdm_user_class_init),
	(gdm_user_init), (gdm_user_set_property), (gdm_user_get_property),
	(gdm_user_finalize), (_gdm_user_update), (_gdm_user_add_session),
	(_gdm_user_remove_session), (_gdm_user_icon_changed),
	(gdm_user_get_uid), (gdm_user_get_real_name),
	(gdm_user_get_user_name), (gdm_user_get_home_directory),
	(gdm_user_get_shell), (gdm_user_get_sessions),
	(gdm_user_get_n_sessions), (gdm_user_collate):
	* gui/simple-greeter/gdm-user.h:
	* gui/simple-greeter/test-user-chooser.c: (main):
	* gui/simple-greeter/test-user-manager.c: (on_user_added),
	(on_user_removed), (main):
	Add basic user monitoring.  Hook up to user-list.


svn path=/branches/mccann-gobject/; revision=5331
parent 33c755a0
2007-10-03 William Jon McCann <mccann@jhu.edu>
* configure.ac:
* gui/simple-greeter/Makefile.am:
* gui/simple-greeter/gdm-user-chooser-widget.c: (populate_model),
(on_user_added), (on_user_removed), (gdm_user_chooser_widget_init):
* gui/simple-greeter/gdm-user-manager.c:
(gdm_user_manager_error_quark), (gdm_user_manager_get_user),
(listify_hash_values_hfunc), (gdm_user_manager_list_users),
(reload_passwd), (reload_shells), (shells_monitor_cb),
(passwd_monitor_cb), (gdm_user_manager_class_init),
(reload_passwd_timeout), (queue_reload_passwd),
(gdm_user_manager_init), (gdm_user_manager_finalize),
(gdm_user_manager_ref_default):
* gui/simple-greeter/gdm-user-manager.h:
* gui/simple-greeter/gdm-user.c: (gdm_user_class_init),
(gdm_user_init), (gdm_user_set_property), (gdm_user_get_property),
(gdm_user_finalize), (_gdm_user_update), (_gdm_user_add_session),
(_gdm_user_remove_session), (_gdm_user_icon_changed),
(gdm_user_get_uid), (gdm_user_get_real_name),
(gdm_user_get_user_name), (gdm_user_get_home_directory),
(gdm_user_get_shell), (gdm_user_get_sessions),
(gdm_user_get_n_sessions), (gdm_user_collate):
* gui/simple-greeter/gdm-user.h:
* gui/simple-greeter/test-user-chooser.c: (main):
* gui/simple-greeter/test-user-manager.c: (on_user_added),
(on_user_removed), (main):
Add basic user monitoring. Hook up to user-list.
2007-10-02 William Jon McCann <mccann@jhu.edu>
* daemon/gdm-factory-slave.c: (on_session_relay_info),
......
......@@ -26,7 +26,8 @@ GNOME_DOC_INIT
DBUS_GLIB_REQUIRED=0.74
GLIB_REQUIRED=2.13.0
GTK_REQUIRED=2.6.0
GTK_REQUIRED=2.10.0
GNOME_VFS_REQUIRED=2.18.0
PANGO_REQUIRED=1.3.0
LIBGLADE_REQUIRED=1.99.2
SCROLLKEEPER_REQUIRED=0.1.4
......@@ -169,7 +170,7 @@ PKG_CHECK_MODULES(DAEMON, gtk+-2.0 >= $GTK_REQUIRED)
AC_SUBST(DAEMON_CFLAGS)
AC_SUBST(DAEMON_LIBS)
PKG_CHECK_MODULES(GUI, gtk+-2.0 >= $GTK_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED)
PKG_CHECK_MODULES(GUI, gtk+-2.0 >= $GTK_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED)
AC_SUBST(GUI_CFLAGS)
AC_SUBST(GUI_LIBS)
......
......@@ -28,6 +28,7 @@ noinst_PROGRAMS = \
test-language-chooser \
test-session-chooser \
test-user-chooser \
test-user-manager \
$(NULL)
test_greeter_background_SOURCES = \
......@@ -83,12 +84,28 @@ test_user_chooser_SOURCES = \
gdm-user-chooser-widget.c \
gdm-user-chooser-dialog.h \
gdm-user-chooser-dialog.c \
gdm-user-manager.h \
gdm-user-manager.c \
gdm-user.h \
gdm-user.c \
$(NULL)
test_user_chooser_LDADD = \
$(GUI_LIBS) \
$(NULL)
test_user_manager_SOURCES = \
test-user-manager.c \
gdm-user-manager.h \
gdm-user-manager.c \
gdm-user.h \
gdm-user.c \
$(NULL)
test_user_manager_LDADD = \
$(GUI_LIBS) \
$(NULL)
libexec_PROGRAMS = \
gdm-simple-greeter
......@@ -102,6 +119,10 @@ gdm_simple_greeter_SOURCES = \
gdm-greeter-background.c \
gdm-user-chooser-widget.h \
gdm-user-chooser-widget.c \
gdm-user-manager.h \
gdm-user-manager.c \
gdm-user.h \
gdm-user.c \
$(NULL)
gdm_simple_greeter_LDADD = \
......
......@@ -33,6 +33,7 @@
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include "gdm-user-manager.h"
#include "gdm-user-chooser-widget.h"
enum {
......@@ -53,6 +54,7 @@ struct GdmUserChooserWidgetPrivate
{
GtkWidget *iconview;
GdmUserManager *manager;
GHashTable *available_users;
char *current_user;
};
......@@ -372,66 +374,6 @@ static void
populate_model (GdmUserChooserWidget *widget,
GtkTreeModel *model)
{
GtkTreeIter iter;
GdkPixbuf *pixbuf;
char *caption;
char *tooltip;
/* Add some fake entries */
caption = g_strdup_printf ("<span size=\"x-large\">%s</span>\n<i>%s</i>",
_("Guest User"),
_("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<i>%s</i>",
_("GNOME Test"),
_("Already logged in"));
tooltip = g_strdup_printf ("%s: %s",
_("Short Name"),
"gtest");
pixbuf = get_pixbuf_for_user (widget, "gtest");
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, "gtest",
-1);
g_free (caption);
g_free (tooltip);
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);
}
g_hash_table_foreach (widget->priv->available_users,
(GHFunc)add_user_to_model,
......@@ -520,6 +462,53 @@ compare_user (GtkTreeModel *model,
return result;
}
static void
on_user_added (GdmUserManager *manager,
GdmUser *user,
GdmUserChooserWidget *widget)
{
GtkTreeModel *model;
GtkTreeIter iter;
GdkPixbuf *pixbuf;
char *caption;
char *tooltip;
g_debug ("User added: %s", gdm_user_get_user_name (user));
pixbuf = get_pixbuf_for_user (widget, gdm_user_get_user_name (user));
caption = g_strdup_printf ("<span size=\"x-large\">%s</span>",
gdm_user_get_real_name (user));
tooltip = g_strdup_printf ("%s: %s",
_("Short Name"),
gdm_user_get_user_name (user));
model = gtk_icon_view_get_model (GTK_ICON_VIEW (widget->priv->iconview));
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, gdm_user_get_user_name (user),
-1);
g_free (caption);
g_free (tooltip);
if (pixbuf != NULL) {
g_object_unref (pixbuf);
}
}
static void
on_user_removed (GdmUserManager *manager,
GdmUser *user,
GdmUserChooserWidget *widget)
{
g_debug ("User removed: %s", gdm_user_get_user_name (user));
/* FIXME: */
}
static void
gdm_user_chooser_widget_init (GdmUserChooserWidget *widget)
{
......@@ -528,13 +517,24 @@ gdm_user_chooser_widget_init (GdmUserChooserWidget *widget)
widget->priv = GDM_USER_CHOOSER_WIDGET_GET_PRIVATE (widget);
widget->priv->manager = gdm_user_manager_ref_default ();
g_signal_connect (widget->priv->manager,
"user-added",
G_CALLBACK (on_user_added),
widget);
g_signal_connect (widget->priv->manager,
"user-removed",
G_CALLBACK (on_user_removed),
widget);
widget->priv->available_users = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)chooser_user_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_AUTOMATIC, GTK_POLICY_AUTOMATIC);
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (widget), scrolled, TRUE, TRUE, 0);
widget->priv->iconview = gtk_icon_view_new ();
......
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* 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_USER_MANAGER_H
#define __GDM_USER_MANAGER_H
#include <glib-object.h>
#include "gdm-user.h"
G_BEGIN_DECLS
#define GDM_TYPE_USER_MANAGER (gdm_user_manager_get_type ())
#define GDM_USER_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_USER_MANAGER, GdmUserManager))
#define GDM_USER_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_USER_MANAGER, GdmUserManagerClass))
#define GDM_IS_USER_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_USER_MANAGER))
#define GDM_IS_USER_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_USER_MANAGER))
#define GDM_USER_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_USER_MANAGER, GdmUserManagerClass))
typedef struct GdmUserManagerPrivate GdmUserManagerPrivate;
typedef struct
{
GObject parent;
GdmUserManagerPrivate *priv;
} GdmUserManager;
typedef struct
{
GObjectClass parent_class;
void (* user_added) (GdmUserManager *user_manager,
GdmUser *user);
void (* user_removed) (GdmUserManager *user_manager,
GdmUser *user);
} GdmUserManagerClass;
typedef enum
{
GDM_USER_MANAGER_ERROR_GENERAL,
GDM_USER_MANAGER_ERROR_KEY_NOT_FOUND
} GdmUserManagerError;
#define GDM_USER_MANAGER_ERROR gdm_user_manager_error_quark ()
GQuark gdm_user_manager_error_quark (void);
GType gdm_user_manager_get_type (void);
GdmUserManager * gdm_user_manager_ref_default (void);
GSList * gdm_user_manager_list_users (GdmUserManager *manager);
GdmUser * gdm_user_manager_get_user (GdmUserManager *manager,
const char *user_name);
G_END_DECLS
#endif /* __GDM_USER_MANAGER_H */
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2004-2005 James M. Cape <jcape@ignore-your.tv>.
*
* 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
*/
/*
* Facade object for user data, owned by GdmUserManager
*/
#ifndef __GDM_USER__
#define __GDM_USER__ 1
#include <sys/types.h>
#include <gtk/gtkwidget.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
G_BEGIN_DECLS
#define GDM_TYPE_USER (gdm_user_get_type ())
#define GDM_USER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDM_TYPE_USER, GdmUser))
#define GDM_IS_USER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDM_TYPE_USER))
typedef struct _GdmUser GdmUser;
GType gdm_user_get_type (void) G_GNUC_CONST;
uid_t gdm_user_get_uid (GdmUser *user);
G_CONST_RETURN gchar *gdm_user_get_user_name (GdmUser *user);
G_CONST_RETURN gchar *gdm_user_get_real_name (GdmUser *user);
G_CONST_RETURN gchar *gdm_user_get_home_directory (GdmUser *user);
G_CONST_RETURN gchar *gdm_user_get_shell (GdmUser *user);
GSList *gdm_user_get_sessions (GdmUser *user);
guint gdm_user_get_n_sessions (GdmUser *user);
GdkPixbuf *gdm_user_render_icon (GdmUser *user,
GtkWidget *widget,
gint icon_size);
gint gdm_user_collate (GdmUser *user1,
GdmUser *user2);
G_END_DECLS
#endif
......@@ -29,6 +29,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libgnomevfs/gnome-vfs-init.h>
#include "gdm-user-chooser-dialog.h"
......@@ -44,6 +45,7 @@ main (int argc, char *argv[])
setlocale (LC_ALL, "");
gtk_init (&argc, &argv);
gnome_vfs_init ();
dialog = gdm_user_chooser_dialog_new ();
/*gtk_widget_set_size_request (dialog, 480, 128);*/
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* 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
*/
#include "config.h"
#include <stdlib.h>
#include <libintl.h>
#include <locale.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libgnomevfs/gnome-vfs-init.h>
#include "gdm-user-manager.h"
static GdmUserManager *manager = NULL;
static void
on_user_added (GdmUserManager *manager,
GdmUser *user,
gpointer data)
{
g_debug ("User added: %s", gdm_user_get_user_name (user));
}
static void
on_user_removed (GdmUserManager *manager,
GdmUser *user,
gpointer data)
{
g_debug ("User removed: %s", gdm_user_get_user_name (user));
}
int
main (int argc, char *argv[])
{
GtkWidget *dialog;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
setlocale (LC_ALL, "");
gtk_init (&argc, &argv);
gnome_vfs_init ();
manager = gdm_user_manager_ref_default ();
g_signal_connect (manager,
"user-added",
G_CALLBACK (on_user_added),
NULL);
g_signal_connect (manager,
"user-removed",
G_CALLBACK (on_user_removed),
NULL);
gtk_main ();
return 0;
}
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