[gnumeric] History dialog: render a proper last used column.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] History dialog: render a proper last used column.
- Date: Fri, 1 Mar 2013 01:25:54 +0000 (UTC)
commit e7d67b99ccaee44bcc855d6c2dad71e202228234
Author: Morten Welinder <terra gnome org>
Date: Thu Feb 28 20:25:25 2013 -0500
History dialog: render a proper last used column.
src/dialogs/dialog-recent.c | 25 ++++++++++++++++++++-----
src/dialogs/recent.ui | 3 ++-
2 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/src/dialogs/dialog-recent.c b/src/dialogs/dialog-recent.c
index ce69ad9..3a58064 100644
--- a/src/dialogs/dialog-recent.c
+++ b/src/dialogs/dialog-recent.c
@@ -120,12 +120,27 @@ age_renderer_func (GtkTreeViewColumn *tree_column,
gpointer user_data)
{
GtkRecentInfo *ri = NULL;
+ GDateTime *now = user_data;
+ GDateTime *last_used;
+ GTimeSpan age;
+ char *text;
gtk_tree_model_get (model, iter, RECENT_COL_INFO, &ri, -1);
+ last_used = g_date_time_new_from_unix_local (gtk_recent_info_get_modified (ri));
+ gtk_recent_info_unref (ri);
- g_object_set (cell, "text", "TBD", NULL);
+ age = g_date_time_difference (now, last_used);
+ if (age < G_TIME_SPAN_DAY &&
+ g_date_time_get_day_of_month (now) == g_date_time_get_day_of_month (last_used)) {
+ text = g_date_time_format (last_used, "%X");
+ } else {
+ text = g_date_time_format (last_used, "%x");
+ }
- gtk_recent_info_unref (ri);
+ g_object_set (cell, "text", text, NULL);
+ g_free (text);
+
+ g_date_time_unref (last_used);
}
static gint
@@ -209,8 +224,8 @@ dialog_recent_used (WBCGtk *wbcg)
(GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (gui, "age_column")),
GTK_CELL_RENDERER (gtk_builder_get_object (gui, "age_renderer")),
age_renderer_func,
- NULL,
- NULL);
+ g_date_time_new_now_local (),
+ (GDestroyNotify)g_date_time_unref);
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (cb_response), wbcg);
@@ -229,7 +244,7 @@ dialog_recent_used (WBCGtk *wbcg)
pango_layout_get_pixel_size (layout, &width, &height);
gtk_widget_set_size_request (go_gtk_builder_get_widget (gui, "docs_scrolledwindow"),
width * 60 / 4,
- (2 * height + vsep) * (4 + 1));
+ (2 * height + vsep) * (5 + 1));
g_object_unref (layout);
}
diff --git a/src/dialogs/recent.ui b/src/dialogs/recent.ui
index 3e62a6c..8772247 100644
--- a/src/dialogs/recent.ui
+++ b/src/dialogs/recent.ui
@@ -28,6 +28,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">recent_model</property>
+ <property name="rules_hint">True</property>
<property name="enable_search">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
@@ -44,7 +45,7 @@
<child>
<object class="GtkTreeViewColumn" id="age_column">
<property name="sizing">autosize</property>
- <property name="title" translatable="yes">Age</property>
+ <property name="title" translatable="yes">Last Used</property>
<child>
<object class="GtkCellRendererText" id="age_renderer"/>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]