1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- |
---|
2 | * |
---|
3 | * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu> |
---|
4 | * |
---|
5 | * This program is free software; you can redistribute it and/or modify |
---|
6 | * it under the terms of the GNU General Public License as published by |
---|
7 | * the Free Software Foundation; either version 2 of the License, or |
---|
8 | * (at your option) any later version. |
---|
9 | * |
---|
10 | * This program is distributed in the hope that it will be useful, |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | * GNU General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU General Public License |
---|
16 | * along with this program; if not, write to the Free Software |
---|
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
18 | */ |
---|
19 | |
---|
20 | #include "config.h" |
---|
21 | |
---|
22 | #include <stdlib.h> |
---|
23 | #include <libintl.h> |
---|
24 | #include <locale.h> |
---|
25 | #include <string.h> |
---|
26 | #include <unistd.h> |
---|
27 | #include <signal.h> |
---|
28 | #include <errno.h> |
---|
29 | |
---|
30 | #include <glib/gi18n.h> |
---|
31 | #include <gtk/gtk.h> |
---|
32 | |
---|
33 | #include "gdm-user-manager.h" |
---|
34 | |
---|
35 | static GdmUserManager *manager = NULL; |
---|
36 | |
---|
37 | static void |
---|
38 | on_users_loaded (GdmUserManager *manager, |
---|
39 | gpointer data) |
---|
40 | { |
---|
41 | GSList *users; |
---|
42 | |
---|
43 | g_debug ("Users loaded"); |
---|
44 | |
---|
45 | users = gdm_user_manager_list_users (manager); |
---|
46 | while (users != NULL) { |
---|
47 | g_print ("User: %s\n", gdm_user_get_user_name (users->data)); |
---|
48 | users = g_slist_delete_link (users, users); |
---|
49 | } |
---|
50 | |
---|
51 | } |
---|
52 | |
---|
53 | static void |
---|
54 | on_user_added (GdmUserManager *manager, |
---|
55 | GdmUser *user, |
---|
56 | gpointer data) |
---|
57 | { |
---|
58 | g_debug ("User added: %s", gdm_user_get_user_name (user)); |
---|
59 | } |
---|
60 | |
---|
61 | static void |
---|
62 | on_user_removed (GdmUserManager *manager, |
---|
63 | GdmUser *user, |
---|
64 | gpointer data) |
---|
65 | { |
---|
66 | g_debug ("User removed: %s", gdm_user_get_user_name (user)); |
---|
67 | } |
---|
68 | |
---|
69 | int |
---|
70 | main (int argc, char *argv[]) |
---|
71 | { |
---|
72 | |
---|
73 | bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); |
---|
74 | bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); |
---|
75 | textdomain (GETTEXT_PACKAGE); |
---|
76 | |
---|
77 | setlocale (LC_ALL, ""); |
---|
78 | |
---|
79 | gtk_init (&argc, &argv); |
---|
80 | |
---|
81 | manager = gdm_user_manager_ref_default (); |
---|
82 | g_signal_connect (manager, |
---|
83 | "users-loaded", |
---|
84 | G_CALLBACK (on_users_loaded), |
---|
85 | NULL); |
---|
86 | g_signal_connect (manager, |
---|
87 | "user-added", |
---|
88 | G_CALLBACK (on_user_added), |
---|
89 | NULL); |
---|
90 | g_signal_connect (manager, |
---|
91 | "user-removed", |
---|
92 | G_CALLBACK (on_user_removed), |
---|
93 | NULL); |
---|
94 | |
---|
95 | gtk_main (); |
---|
96 | |
---|
97 | return 0; |
---|
98 | } |
---|