[gnome-games] libgames-support: Added a date field to the scores dialog
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] libgames-support: Added a date field to the scores dialog
- Date: Mon, 30 Jul 2012 14:54:20 +0000 (UTC)
commit b2f7657d05ce1c4f381d0d16f85f96df608ef70a
Author: Craig Duncan <bugzilla duncanc co uk>
Date: Mon Jul 30 16:54:15 2012 +0200
libgames-support: Added a date field to the scores dialog
libgames-support/games-scores-dialog.c | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/libgames-support/games-scores-dialog.c b/libgames-support/games-scores-dialog.c
index 4551a17..556a177 100644
--- a/libgames-support/games-scores-dialog.c
+++ b/libgames-support/games-scores-dialog.c
@@ -39,6 +39,7 @@ struct GamesScoresDialogPrivate {
GtkCellRenderer *namerenderer;
GtkTreeViewColumn *column;
GtkTreeViewColumn *namecolumn;
+ GtkTreeViewColumn *timecolumn;
GamesScores *scores;
GHashTable *categories;
GHashTable *catindices;
@@ -281,6 +282,9 @@ static void games_scores_dialog_redraw (GamesScoresDialog *self) {
const gchar *name;
gint score;
gchar *ss;
+ gint timestamp;
+ GDateTime *datetime;
+ gchar *time;
gdouble dscore;
GList *scorelist;
@@ -290,6 +294,10 @@ static void games_scores_dialog_redraw (GamesScoresDialog *self) {
while (scorelist) {
name = games_score_get_name ((GamesScore *)scorelist->data);
+ timestamp = games_score_get_time ((GamesScore *)scorelist->data);
+ datetime = g_date_time_new_from_unix_local (timestamp);
+ time = g_date_time_format (datetime,"%d/%m/%y");
+
switch (self->priv->style) {
case GAMES_SCORES_STYLE_TIME_ASCENDING:
case GAMES_SCORES_STYLE_TIME_DESCENDING:
@@ -306,8 +314,9 @@ static void games_scores_dialog_redraw (GamesScoresDialog *self) {
ss = g_strdup_printf ("%d", score);
}
gtk_list_store_append (self->priv->list, &iter);
- gtk_list_store_set (self->priv->list, &iter, 0, name, 1, ss, -1);
+ gtk_list_store_set (self->priv->list, &iter, 0, name, 1, time, 2, ss, -1);
g_free (ss);
+ g_free (time);
scorelist = g_list_next (scorelist);
}
@@ -478,7 +487,9 @@ static void games_scores_dialog_init (GamesScoresDialog *self)
GtkWidget *scroll;
GtkWidget *listview;
GtkTreeViewColumn *column;
+ GtkTreeViewColumn *timecolumn;
GtkCellRenderer *renderer;
+ GtkCellRenderer *timerenderer;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GAMES_TYPE_SCORES_DIALOG,
GamesScoresDialogPrivate);
@@ -543,7 +554,7 @@ static void games_scores_dialog_init (GamesScoresDialog *self)
g_signal_connect (G_OBJECT (self->priv->combo), "changed",
G_CALLBACK (games_scores_dialog_change_category), self);
- self->priv->list = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+ self->priv->list = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
listview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (self->priv->list));
self->priv->treeview = GTK_TREE_VIEW (listview);
@@ -563,8 +574,20 @@ static void games_scores_dialog_init (GamesScoresDialog *self)
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (listview),
GTK_TREE_VIEW_COLUMN (self->priv->namecolumn));
+
+ timerenderer = gtk_cell_renderer_text_new ();
+ timecolumn = gtk_tree_view_column_new_with_attributes (/* Score dialog column header for the date the score was recorded */
+ _("Date"),
+ timerenderer,
+ "text", 1,
+ NULL);
+ g_object_set (G_OBJECT (timerenderer), "xalign", 1.0, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (listview),
+ GTK_TREE_VIEW_COLUMN (timecolumn));
+ self->priv->timecolumn = timecolumn;
+
renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", 1, NULL);
+ column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", 2, NULL);
g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (listview),
GTK_TREE_VIEW_COLUMN (column));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]