From: Andrea Zagli Date: Sat, 7 Aug 2010 17:09:42 +0000 (+0200) Subject: Loaded users list. X-Git-Tag: 0.1.0~5 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=9ea09bef5007e5a4d273d1dd37a06ca63e61a5df;p=zakauthe%2Fplugins%2Fdb Loaded users list. --- diff --git a/data/libaute-db/gui/autedb.glade b/data/libaute-db/gui/autedb.glade index cb111e2..fdda131 100644 --- a/data/libaute-db/gui/autedb.glade +++ b/data/libaute-db/gui/autedb.glade @@ -225,6 +225,7 @@ True 5 vertical + 5 True diff --git a/src/aute_db.c b/src/aute_db.c index fe32796..c836fc1 100644 --- a/src/aute_db.c +++ b/src/aute_db.c @@ -23,6 +23,7 @@ #include #include #include +#include #ifdef HAVE_LIBCONFI #include @@ -37,6 +38,19 @@ static GtkWidget *exp_cambio; static GtkWidget *txt_password_nuova; static GtkWidget *txt_password_conferma; +static GtkTreeView *trv_users; +static GtkListStore *lstore_users; +static GtkTreeSelection *sel_users; + +enum +{ + COL_STATUS, + COL_CODE, + COL_NAME, + COL_LAST_ACCESS, + COL_PASSWORD_EXPIRATION +}; + /* PRIVATE */ #ifdef HAVE_LIBCONFI static gboolean @@ -195,7 +209,34 @@ static gchar static void autedb_load_users_list () { + gchar *sql; + GdaDataModel *dm; + + guint rows; + guint row; + GtkTreeIter iter; + gtk_list_store_clear (lstore_users); + + sql = g_strdup_printf ("SELECT * FROM users WHERE status <> 'E'"); + dm = gdaex_query (gdaex, sql); + if (dm != NULL) + { + rows = gda_data_model_get_n_rows (dm); + for (row = 0; row < rows; row++) + { + gtk_list_store_append (lstore_users, &iter); + gtk_list_store_set (lstore_users, &iter, + COL_STATUS, gdaex_data_model_get_field_value_stringify_at (dm, row, "status"), + COL_CODE, gdaex_data_model_get_field_value_stringify_at (dm, row, "code"), + COL_NAME, g_strdup_printf ("%s %s", + gdaex_data_model_get_field_value_stringify_at (dm, row, "surname"), + gdaex_data_model_get_field_value_stringify_at (dm, row, "name")), + COL_LAST_ACCESS, gdaex_data_model_get_field_value_stringify_at (dm, row, "last_access"), + COL_PASSWORD_EXPIRATION, gdaex_data_model_get_field_value_stringify_at (dm, row, "password_expiration"), + -1); + } + } } static void @@ -310,20 +351,25 @@ GtkWidget GUIDIR = g_build_filename (g_win32_get_package_installation_directory_of_module (NULL), "share", "libaute-db", "gu", NULL); #endif - if (!gtk_builder_add_from_file (gtkbuilder, g_build_filename (GUIDIR, "autedb.gui", NULL), &error)) + if (!gtk_builder_add_objects_from_file (gtkbuilder, g_build_filename (GUIDIR, "autedb.gui", NULL), + g_strsplit ("lstore_users|vbx_users_list", "|", -1), + &error)) { g_error ("Impossibile trovare il file di definizione dell'interfaccia utente."); return NULL; } w = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "vbx_users_list")); - if (w == NULL) { g_warning ("Unable to find the widget vbx_users_list."); return NULL; } + trv_users = GTK_TREE_VIEW (gtk_builder_get_object (gtkbuilder, "treeview1")); + lstore_users = GTK_LIST_STORE (gtk_builder_get_object (gtkbuilder, "lstore_users")); + sel_users = gtk_tree_view_get_selection (trv_users); + g_signal_connect (G_OBJECT (gtk_builder_get_object (gtkbuilder, "button1")), "clicked", G_CALLBACK (autedb_on_btn_new_clicked), NULL); g_signal_connect (G_OBJECT (gtk_builder_get_object (gtkbuilder, "button2")), "clicked",