TnyAccount *account = TNY_ACCOUNT(folder_store);
time_t last_updated;
- gchar *last_updated_string;
+ const gchar *last_updated_string;
/* Get last updated from configuration */
last_updated = modest_account_mgr_get_last_updated (modest_runtime_get_account_mgr (),
tny_account_get_id (account));
label_w = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label_w), label);
gtk_box_pack_start (GTK_BOX (vbox), label_w, FALSE, FALSE, 0);
- g_free (last_updated_string);
g_free (label);
}
iter = tny_list_create_iterator (header_list);
while (!tny_iterator_is_done (iter)) {
- gchar *url = NULL, *display_address = NULL, *display_date = NULL, *summary = NULL;
+ gchar *url = NULL, *display_address = NULL, *summary = NULL;
+ const gchar *display_date;
TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter));
TnyFolder *folder = tny_header_get_folder (header);
gboolean first_notification = TRUE;
gint notif_id;
-
+
+ /* constant string, don't free */
display_date = modest_text_utils_get_display_date (tny_header_get_date_received (header));
display_address = g_strdup(tny_header_get_from (header));
tny_header_get_subject (header),
"qgn_list_messagin",
"email.arrive");
-
/* Create the message URL */
url = g_strdup_printf ("%s/%s", tny_folder_get_url_string (folder),
tny_header_get_uid (header));
not to store the list in gconf */
/* Free & carry on */
- g_free (display_date);
g_free (display_address);
g_free (summary);
g_free (url);
}
-gchar*
+const gchar*
modest_text_utils_get_display_date (time_t date)
{
time_t now;
- static const guint BUF_SIZE = 64;
+#define DATE_BUF_SIZE 64
static const guint ONE_DAY = 24 * 60 * 60; /* seconds in one day */
- gchar date_buf[BUF_SIZE];
- gchar today_buf [BUF_SIZE];
+ static gchar date_buf[DATE_BUF_SIZE];
+
+ gchar today_buf [DATE_BUF_SIZE];
- modest_text_utils_strftime (date_buf, BUF_SIZE, "%x", date);
+ modest_text_utils_strftime (date_buf, DATE_BUF_SIZE, "%x", date);
now = time (NULL);
/* it's within the last 24 hours, but double check */
/* use the localized dates */
- modest_text_utils_strftime (today_buf, BUF_SIZE, "%x", now);
+ modest_text_utils_strftime (today_buf, DATE_BUF_SIZE, "%x", now);
/* if it's today, use the time instead */
if (strcmp (date_buf, today_buf) == 0)
- modest_text_utils_strftime (date_buf, BUF_SIZE, "%X", date);
+ modest_text_utils_strftime (date_buf, DATE_BUF_SIZE, "%X", date);
}
- return g_strdup(date_buf);
+ return date_buf;
}
+
gboolean
modest_text_utils_validate_folder_name (const gchar *folder_name)
{
*
* get a string representation for a date.
*
- * Returns: the new display date, as a newly allocated string;
- * free with g_free
+ * Returns: the new display date, as a *static* string.
+ * This string should not be modified, and will change
+ * upon recalling this function. g_strdup it if you to
+ * do so.
+ *
*/
-gchar* modest_text_utils_get_display_date (time_t date);
+const gchar* modest_text_utils_get_display_date (time_t date);
/**
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
-/* Get the string for the last updated time. Result must be g_freed */
-static gchar*
+/* Get the string for the last updated time. Result must NOT be g_freed */
+static const gchar*
get_last_updated_string(ModestAccountMgr* account_mgr, ModestAccountData *account_data)
{
/* FIXME: let's assume that 'last update' applies to the store account... */
- gchar* last_updated_string;
+ const gchar* last_updated_string;
time_t last_updated = account_data->store_account->last_updated;
if (!modest_account_mgr_account_is_busy(account_mgr, account_data->account_name)) {
if (last_updated > 0)
last_updated_string = modest_text_utils_get_display_date(last_updated);
else
- last_updated_string = g_strdup (_("mcen_va_never"));
+ last_updated_string = _("mcen_va_never");
} else {
/* FIXME: There should be a logical name in the UI specs */
- last_updated_string = g_strdup(_("mcen_va_refreshing"));
+ last_updated_string = _("mcen_va_refreshing");
}
+
return last_updated_string;
}
if (account_data->store_account) {
GtkTreeIter iter;
-
- gchar *last_updated_string = get_last_updated_string(account_mgr, account_data);
+
+ /* don't free */
+ const gchar *last_updated_string = get_last_updated_string(account_mgr, account_data);
if (account_data->is_enabled) {
const gchar *proto_name;
MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, last_updated_string,
-1);
}
- g_free (last_updated_string);
}
modest_account_mgr_free_account_data (account_mgr, account_data);
g_free (cur_name);
return;
}
- gchar* last_updated_string = get_last_updated_string(account_mgr, account_data);
+ const gchar* last_updated_string = get_last_updated_string(account_mgr, account_data);
gtk_list_store_set(model, &iter,
MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, last_updated_string,
-1);
- g_free (last_updated_string);
modest_account_mgr_free_account_data (account_mgr, account_data);
found = TRUE;
}
{
TnyHeaderFlags flags;
guint date, date_col;
- gchar *display_date = NULL;
gboolean received = GPOINTER_TO_INT(user_data);
if (received)
date_col, &date,
-1);
- display_date = modest_text_utils_get_display_date (date);
- g_object_set (G_OBJECT(renderer), "text", display_date, NULL);
+ g_object_set (G_OBJECT(renderer), "text", modest_text_utils_get_display_date (date),
+ NULL);
set_common_flags (renderer, flags);
- g_free (display_date);
}
void
_modest_header_view_compact_header_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer user_data)
{
- g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (column));
- g_return_if_fail (GTK_IS_CELL_RENDERER (renderer));
- g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
-
/* Note that GtkTreeModel is a GtkTreeModelFilter. */
/* printf ("DEBUG: %s: tree_model gtype=%s\n", __FUNCTION__, G_OBJECT_TYPE_NAME (tree_model)); */
gchar *address = NULL;
gchar *subject = NULL;
gchar *header = NULL;
- time_t date = 0;
+ time_t date;
GtkCellRenderer *recipient_cell, *date_or_status_cell, *subject_cell,
*attach_cell, *priority_cell,
gchar *display_date = NULL, *tmp_date = NULL;
TnyHeaderFlags prio = 0;
+
+ g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (column));
+ g_return_if_fail (GTK_IS_CELL_RENDERER (renderer));
+ g_return_if_fail (GTK_IS_TREE_MODEL (tree_model));
+
recipient_box = GTK_CELL_RENDERER (g_object_get_data (G_OBJECT (renderer), "recpt-box-renderer"));
subject_box = GTK_CELL_RENDERER (g_object_get_data (G_OBJECT (renderer), "subject-box-renderer"));
priority_cell = GTK_CELL_RENDERER (g_object_get_data (G_OBJECT (subject_box), "priority-renderer"));
g_free (header);
header = NULL;
set_common_flags (recipient_cell, flags);
-
+
if (header_mode == MODEST_HEADER_VIEW_COMPACT_HEADER_MODE_OUTBOX) {
ModestTnySendQueueStatus status = MODEST_TNY_SEND_QUEUE_UNKNOWN;
const gchar *status_str = "";
NULL);
g_free (display_date);
display_date = NULL;
- } else {
- /* in some rare cases, mail might have no Date: field. it case,
- * don't show the date, instead of bogus 1/1/1970
- */
- if (date)
- tmp_date = modest_text_utils_get_display_date (date);
- else
- tmp_date = g_strdup ("");
-
- display_date = g_strdup_printf ("<span size='small' foreground='#666666'>%s</span>", tmp_date);
+ } else {
+ display_date = g_strdup_printf ("<span size='small' foreground='#666666'>%s</span>",
+ date ? modest_text_utils_get_display_date (date) : "");
g_object_set (G_OBJECT (date_or_status_cell),
"markup", display_date,
NULL);