return icon_name;
}
+
+
+GdkPixbuf*
+modest_platform_get_icon (const gchar *name)
+{
+ GError *err = NULL;
+ GdkPixbuf* pixbuf;
+
+ g_return_val_if_fail (name, NULL);
+
+ pixbuf = gdk_pixbuf_new_from_file (name, &err);
+
+ if (!pixbuf) {
+ g_printerr ("modest: error while loading icon '%s': %s\n",
+ name, err->message);
+ g_error_free (err);
+ }
+
+ return pixbuf;
+}
+
return icon_name;
}
+
+
+GdkPixbuf*
+modest_platform_get_icon (const gchar *name)
+{
+ GError *err = NULL;
+ GdkPixbuf* pixbuf;
+ GtkIconTheme *current_theme;
+
+ g_return_val_if_fail (name, NULL);
+
+ current_theme = gtk_icon_theme_get_default ();
+ pixbuf = gtk_icon_theme_load_icon (current_theme, name, 26,
+ GTK_ICON_LOOKUP_NO_SVG,
+ &err);
+ if (!pixbuf) {
+ g_printerr ("modest: error while loading icon '%s': %s\n",
+ name, err->message);
+ g_error_free (err);
+ }
+
+ return pixbuf;
+}
+
#define __MODEST_PLATFORM_H__
#include <glib.h>
+#include <gtk/gtk.h>
#include <tny-device.h>
/**
/**
- * modest_platform_get_file_icon:
+ * modest_platform_get_file_icon_name:
* @name: the name of the file, or NULL
* @mime_type: the mime-type, or NULL
* @effective_mime_type: out-param which receives the 'effective mime-type', ie., the mime type
gchar* modest_platform_get_file_icon_name (const gchar* name, const gchar* mime_type,
gchar **effective_mime_type);
+/**
+ * modest_platform_get_icon:
+ * @name: the name of the icon
+ *
+ * this function returns an icon, or NULL in case of error
+ */
+GdkPixbuf* modest_platform_get_icon (const gchar *name);
+
+
+
#endif /* __MODEST_PLATFORM_UTILS_H__ */
#include <modest-runtime.h>
#include "modest-folder-view.h"
#include <modest-dnd.h>
+#include <modest-platform.h>
/* 'private'/'protected' functions */
static void modest_folder_view_class_init (ModestFolderViewClass *klass);
}
-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;
-}
-
static void
icon_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
switch (type) {
case TNY_FOLDER_TYPE_ROOT:
- pixbuf = get_cached_icon (MODEST_FOLDER_ICON_ACCOUNT);
+ pixbuf = modest_platform_get_icon (MODEST_FOLDER_ICON_ACCOUNT);
break;
case TNY_FOLDER_TYPE_INBOX:
- pixbuf = get_cached_icon (MODEST_FOLDER_ICON_INBOX);
+ pixbuf = modest_platform_get_icon (MODEST_FOLDER_ICON_INBOX);
break;
case TNY_FOLDER_TYPE_OUTBOX:
- pixbuf = get_cached_icon (MODEST_FOLDER_ICON_OUTBOX);
+ pixbuf = modest_platform_get_icon (MODEST_FOLDER_ICON_OUTBOX);
break;
case TNY_FOLDER_TYPE_JUNK:
- pixbuf = get_cached_icon (MODEST_FOLDER_ICON_JUNK);
+ pixbuf = modest_platform_get_icon (MODEST_FOLDER_ICON_JUNK);
break;
case TNY_FOLDER_TYPE_SENT:
- pixbuf = get_cached_icon (MODEST_FOLDER_ICON_SENT);
+ pixbuf = modest_platform_get_icon (MODEST_FOLDER_ICON_SENT);
break;
case TNY_FOLDER_TYPE_TRASH:
- pixbuf = get_cached_icon (MODEST_FOLDER_ICON_TRASH);
+ pixbuf = modest_platform_get_icon (MODEST_FOLDER_ICON_TRASH);
break;
case TNY_FOLDER_TYPE_DRAFTS:
- pixbuf = get_cached_icon (MODEST_FOLDER_ICON_DRAFTS);
+ pixbuf = modest_platform_get_icon (MODEST_FOLDER_ICON_DRAFTS);
break;
case TNY_FOLDER_TYPE_NORMAL:
default:
- pixbuf = get_cached_icon (MODEST_FOLDER_ICON_NORMAL);
+ pixbuf = modest_platform_get_icon (MODEST_FOLDER_ICON_NORMAL);
break;
}
g_object_set (rendobj, "pixbuf", pixbuf, NULL);
#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 */
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;
}
}