00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00026
00027
00028
00029
00030
00031 #include <stdio.h>
00032
00033 #include <libermanifest/ermanifest.h>
00034
00035 #include "contentListerLog.h"
00036 #include "erMdsContent.h"
00037 #include "icons.h"
00038
00039
00040 static GdkPixbuf *g_icons[ICON_COUNT];
00041
00042
00043 void icons_init()
00044 {
00045 GError *error = NULL;
00046
00047 g_icons[clFolderIcon] = gdk_pixbuf_new_from_file(DATA_DIR "/Icon_folder.png", &error);
00048 if (NULL == g_icons[clFolderIcon])
00049 {
00050 CL_ERRORPRINTF("clFolderIcon - error %s", error->message);
00051 }
00052
00053 g_icons[clUnknownIcon] = gdk_pixbuf_new_from_file(DATA_DIR "/Icon_unknown.png", &error);
00054 if (NULL == g_icons[clUnknownIcon])
00055 {
00056 CL_ERRORPRINTF("clUnknownIcon - error %s", error->message);
00057 }
00058
00059 g_icons[clBookIcon] = gdk_pixbuf_new_from_file(DATA_DIR "/Icon_books.png", &error);
00060 if (NULL == g_icons[clBookIcon])
00061 {
00062 CL_ERRORPRINTF("clBookIcon - error %s", error->message);
00063 }
00064
00065 g_icons[clDocumentIcon] = gdk_pixbuf_new_from_file(DATA_DIR "/Icon_documents.png", &error);
00066 if (NULL == g_icons[clDocumentIcon])
00067 {
00068 CL_ERRORPRINTF("clDocumentIcon - error %s", error->message);
00069 }
00070
00071 g_icons[clMagazineIcon] = gdk_pixbuf_new_from_file(DATA_DIR "/Icon_magazines.png", &error);
00072 if (NULL == g_icons[clMagazineIcon])
00073 {
00074 CL_ERRORPRINTF("clMagazineIcon - error %s", error->message);
00075 }
00076
00077 g_icons[clMiscIcon] = gdk_pixbuf_new_from_file(DATA_DIR "/Icon_misc.png", &error);
00078 if (NULL == g_icons[clMiscIcon])
00079 {
00080 CL_ERRORPRINTF("clMiscIcon - error %s", error->message);
00081 }
00082
00083 g_icons[clMp3Icon] = gdk_pixbuf_new_from_file(DATA_DIR "/Icon_mp3.png", &error);
00084 if (NULL == g_icons[clMp3Icon])
00085 {
00086 CL_ERRORPRINTF("clMp3Icon - error %s", error->message);
00087 }
00088
00089 g_icons[clNewspaperIcon] = gdk_pixbuf_new_from_file(DATA_DIR "/Icon_newspapers.png", &error);
00090 if (NULL == g_icons[clNewspaperIcon])
00091 {
00092 CL_ERRORPRINTF("clNewspaperIcon - error %s", error->message);
00093 }
00094
00095 g_icons[clNoteIcon] = gdk_pixbuf_new_from_file(DATA_DIR "/Icon_notes.png", &error);
00096 if (NULL == g_icons[clNoteIcon])
00097 {
00098 CL_ERRORPRINTF("clNoteIcon - error %s", error->message);
00099 }
00100
00101 g_icons[clPhotoIcon] = gdk_pixbuf_new_from_file(DATA_DIR "/Icon_photos.png", &error);
00102 if (NULL == g_icons[clPhotoIcon])
00103 {
00104 CL_ERRORPRINTF("clPhotoIcon - error %s", error->message);
00105 }
00106
00107 g_icons[clReviewIcon] = gdk_pixbuf_new_from_file(DATA_DIR "/Icon_reviews.png", &error);
00108 if (NULL == g_icons[clReviewIcon])
00109 {
00110 CL_ERRORPRINTF("clReviewIcon - error %s", error->message);
00111 }
00112
00113 g_icons[clOutboxIcon] = gdk_pixbuf_new_from_file(DATA_DIR "/Icon_outbox.png", &error);
00114 if (NULL == g_icons[clReviewIcon])
00115 {
00116 CL_ERRORPRINTF("clReviewIcon - error %s", error->message);
00117 }
00118 }
00119
00120
00121 void icons_destroy()
00122 {
00123 int index;
00124
00125 CL_LOGPRINTF("entry");
00126
00127 for (index = 0; index < ICON_COUNT; index++)
00128 {
00129 if (g_icons[index])
00130 {
00131 g_object_unref(g_icons[index]);
00132 g_icons[index] = NULL;
00133 }
00134 }
00135
00136 CL_LOGPRINTF("exit");
00137 }
00138
00139
00140 GdkPixbuf *icons_get(unsigned int Icon_ID)
00141 {
00142 if ((Icon_ID < ICON_COUNT))
00143 {
00144 return g_icons[Icon_ID];
00145 }
00146 else
00147 {
00148 return NULL;
00149 }
00150 }
00151
00152 GdkPixbuf *icons_load(const char *location)
00153 {
00154 GdkPixbuf *image = NULL;
00155 GError *error = NULL;
00156
00157 if (location)
00158 {
00159 image = gdk_pixbuf_new_from_file_at_size(location, LOADED_ICON_MAX_WIDTH, LOADED_ICON_MAX_HEIGHT, &error);
00160
00161 if (NULL == image)
00162 {
00163 CL_WARNPRINTF("location %s - error %s", location, error->message);
00164 }
00165 }
00166 return image;
00167 }
00168
00169 void icons_unload(GdkPixbuf *image)
00170 {
00171 if (image)
00172 {
00173 g_object_unref(G_OBJECT(image));
00174 }
00175 }