#include <modest-text-utils.h>
#include <modest-runtime.h>
#include <glib/gi18n.h>
-
+#include <modest-platform.h>
static GdkPixbuf*
-get_cached_icon (const gchar *name)
-{
- GError *err = NULL;
- GdkPixbuf* pixbuf;
-
-#ifdef MODEST_PLATFORM_GNOME
- pixbuf = gdk_pixbuf_new_from_file (name, &err);
-#else
- GtkIconTheme *current_theme;
- current_theme = gtk_icon_theme_get_default ();
- pixbuf = gtk_icon_theme_load_icon (current_theme,
- name,
- 26,
- GTK_ICON_LOOKUP_NO_SVG,
- &err);
-#endif /*MODEST_PLATFORM_GNOME*/
-
- if (!pixbuf) {
- g_printerr ("modest: error in icon factory while loading '%s': %s\n",
- name, err->message);
- g_error_free (err);
- }
-
- return pixbuf;
-}
-
-
-/*
- * optimization
- */
-static GdkPixbuf*
get_pixbuf_for_flag (TnyHeaderFlags flag)
{
/* optimization */
- static GdkPixbuf *deleted_pixbuf = NULL;
- static GdkPixbuf *seen_pixbuf = NULL;
- static GdkPixbuf *unread_pixbuf = NULL;
- static GdkPixbuf *attachments_pixbuf = NULL;
+ static GdkPixbuf *deleted_pixbuf = NULL;
+ static GdkPixbuf *seen_pixbuf = NULL;
+ static GdkPixbuf *unread_pixbuf = NULL;
+ static GdkPixbuf *attachments_pixbuf = NULL;
switch (flag) {
case TNY_HEADER_FLAG_DELETED:
if (G_UNLIKELY(!deleted_pixbuf))
- deleted_pixbuf = get_cached_icon (MODEST_HEADER_ICON_DELETED);
+ deleted_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_DELETED);
return deleted_pixbuf;
case TNY_HEADER_FLAG_SEEN:
if (G_UNLIKELY(!seen_pixbuf))
- seen_pixbuf = get_cached_icon (MODEST_HEADER_ICON_READ);
+ seen_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_READ);
return seen_pixbuf;
case TNY_HEADER_FLAG_ATTACHMENTS:
if (G_UNLIKELY(!attachments_pixbuf))
- attachments_pixbuf = get_cached_icon (MODEST_HEADER_ICON_ATTACH);
+ attachments_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_ATTACH);
return attachments_pixbuf;
default:
if (G_UNLIKELY(!unread_pixbuf))
- unread_pixbuf = get_cached_icon (MODEST_HEADER_ICON_UNREAD);
+ unread_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_UNREAD);
return unread_pixbuf;
}
}
+static GdkPixbuf*
+get_pixbuf_for_compact_flag (TnyHeaderFlags flags)
+{
+ /* optimization */
+ static GdkPixbuf *high_attachments_pixbuf = NULL;
+ static GdkPixbuf *normal_attachments_pixbuf = NULL;
+ static GdkPixbuf *low_attachments_pixbuf = NULL;
+ static GdkPixbuf *high_pixbuf = NULL;
+ static GdkPixbuf *low_pixbuf = NULL;
+ TnyHeaderPriorityFlags prior;
+
+ prior = flags & TNY_HEADER_FLAG_PRIORITY;
+ switch (prior) {
+ case TNY_HEADER_FLAG_HIGH_PRIORITY:
+ if (flags & TNY_HEADER_FLAG_ATTACHMENTS) {
+ if (G_UNLIKELY(!high_attachments_pixbuf))
+ high_attachments_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_ATTACH_HIGH_PRIORITY);
+ return high_attachments_pixbuf;
+ } else {
+ if (G_UNLIKELY(!high_pixbuf))
+ high_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_HIGH_PRIORITY);
+ return high_pixbuf;
+ }
+ break;
+ case TNY_HEADER_FLAG_LOW_PRIORITY:
+ if (flags & TNY_HEADER_FLAG_ATTACHMENTS) {
+ if (G_UNLIKELY(!low_attachments_pixbuf))
+ low_attachments_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_ATTACH_LOW_PRIORITY);
+ return low_attachments_pixbuf;
+ } else {
+ if (G_UNLIKELY(!low_pixbuf))
+ low_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_LOW_PRIORITY);
+ return low_pixbuf;
+ }
+ break;
+ default:
+ if (flags & TNY_HEADER_FLAG_ATTACHMENTS) {
+ if (G_UNLIKELY(!normal_attachments_pixbuf))
+ normal_attachments_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_ATTACH_NORM_PRIORITY);
+ return normal_attachments_pixbuf;
+ }
+ }
+
+ return NULL;
+}
+
static void
set_common_flags (GtkCellRenderer *renderer, TnyHeaderFlags flags)
{
g_object_set (G_OBJECT(renderer),
- "weight", (flags & TNY_HEADER_FLAG_SEEN) ? 400: 800,
+ "weight", (flags & TNY_HEADER_FLAG_SEEN) ? PANGO_WEIGHT_NORMAL: PANGO_WEIGHT_ULTRABOLD,
"strikethrough", (flags & TNY_HEADER_FLAG_DELETED) ? TRUE:FALSE,
NULL);
}
}
void
+_modest_header_view_compact_flag_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
+ GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer user_data)
+{
+ TnyHeaderFlags flags;
+ GdkPixbuf* pixbuf = NULL;
+
+ gtk_tree_model_get (tree_model, iter, TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN,
+ &flags, -1);
+
+ pixbuf = get_pixbuf_for_compact_flag (flags);
+ g_object_set (G_OBJECT (renderer), "pixbuf", pixbuf, NULL);
+}
+
+void
_modest_header_view_header_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer user_data)
{
{
TnyHeaderFlags flags;
guint date, date_col;
- gchar *display_date;
+ gchar *display_date = NULL;
gboolean received = GPOINTER_TO_INT(user_data);
if (received)
-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", display_date, NULL);
set_common_flags (renderer, flags);
g_free (display_date);
}
+void
+_modest_header_view_compact_date_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
+ GtkTreeModel *tree_model, GtkTreeIter *iter,
+ gpointer user_data)
+{
+ TnyHeaderFlags flags;
+ guint date, date_col;
+ gchar *display_date = NULL, *tmp_date = NULL;
+ gboolean received = GPOINTER_TO_INT(user_data);
+
+ if (received)
+ date_col = TNY_GTK_HEADER_LIST_MODEL_DATE_RECEIVED_TIME_T_COLUMN;
+ else
+ date_col = TNY_GTK_HEADER_LIST_MODEL_DATE_SENT_TIME_T_COLUMN;
+
+ gtk_tree_model_get (tree_model, iter,
+ TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN, &flags,
+ date_col, &date,
+ -1);
+
+ tmp_date = modest_text_utils_get_display_date (date);
+ display_date = g_strdup_printf ("\n<small>%s</small>", tmp_date);
+ g_object_set (G_OBJECT(renderer),
+ "markup", display_date,
+ NULL);
+
+ set_common_flags (renderer, flags);
+ g_free (tmp_date);
+ g_free (display_date);
+}
void
_modest_header_view_sender_receiver_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
{
GObject *rendobj;
TnyHeaderFlags flags;
- gchar *address, *subject, *header, *display_date;
+ gchar *address, *subject, *header;
time_t date;
gboolean is_incoming;
TNY_GTK_HEADER_LIST_MODEL_SUBJECT_COLUMN, &subject,
TNY_GTK_HEADER_LIST_MODEL_DATE_SENT_TIME_T_COLUMN, &date,
-1);
-
+
rendobj = G_OBJECT(renderer);
- display_date = modest_text_utils_get_display_date (date);
- header = g_strdup_printf ("%s %s\n%s",
- modest_text_utils_get_display_address (address),
- display_date, subject);
+ header = g_markup_printf_escaped ("%s\n<small>%s</small>",
+ subject ? subject : _("mail_va_no_subject"),
+ address);
g_free (address);
g_free (subject);
- g_free (display_date);
-
- g_object_set (G_OBJECT(renderer), "text", header, NULL);
+
+ g_object_set (rendobj, "markup", header, NULL);
set_common_flags (renderer, flags);
g_free (header);
g_free (size_str);
}
+
+void
+_modest_header_view_status_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
+ GtkTreeModel *tree_model, GtkTreeIter *iter,
+ gpointer user_data)
+{
+ TnyHeaderFlags flags;
+ //guint status;
+ gchar *status_str;
+
+ gtk_tree_model_get (tree_model, iter,
+ TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN, &flags,
+ // TNY_GTK_HEADER_LIST_MODEL_MESSAGE_SIZE_COLUMN, &status,
+ -1);
+
+ status_str = g_strdup(_("mcen_li_outbox_waiting"));
+
+ g_object_set (G_OBJECT(renderer), "text", status_str, NULL);
+ set_common_flags (renderer, flags);
+
+ g_free (status_str);
+ }
+