contentLister/inc/icons.h File Reference

contentLister - icon handling More...

#include <gtk/gtk.h>
#include <gdk/gdk.h>

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define LOADED_ICON_MAX_WIDTH   64
#define LOADED_ICON_MAX_HEIGHT   90

Functions

void icons_init ()
void icons_destroy ()
GdkPixbuf * icons_get (unsigned int Icon_ID)
GdkPixbuf * icons_load (const char *location)
void icons_unload (GdkPixbuf *image)


Detailed Description

contentLister - icon handling

<File description>="">

Definition in file icons.h.


Define Documentation

#define LOADED_ICON_MAX_HEIGHT   90

Definition at line 38 of file icons.h.

#define LOADED_ICON_MAX_WIDTH   64

Definition at line 37 of file icons.h.


Function Documentation

void icons_destroy (  ) 

Destroy loaded icons

Returns:
void

Definition at line 121 of file icons.c.

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 }

GdkPixbuf* icons_get ( unsigned int  Icon_ID  ) 

request from contentlister

Parameters:
Icon_ID - the icon identification
Returns:
READ ONLY reference to icon pixbuf

Definition at line 140 of file icons.c.

00141 {
00142     if ((Icon_ID < ICON_COUNT))
00143     {
00144         return g_icons[Icon_ID];
00145     }
00146     else
00147     {
00148         return NULL;
00149     }
00150 }

void icons_init (  ) 

Load the frequently use items

Returns:
void

Definition at line 43 of file icons.c.

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 }

GdkPixbuf* icons_load ( const char *  location  ) 

Load the icon image

Parameters:
location - icon file location
Returns:
NULL in case of error

Definition at line 152 of file icons.c.

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 }

void icons_unload ( GdkPixbuf *  image  ) 

Unload the icon image

Parameters:
image - pointer
Returns:

Definition at line 169 of file icons.c.

00170 {
00171     if (image)
00172     {
00173         g_object_unref(G_OBJECT(image));
00174     }
00175 }


Generated on Sun Dec 14 17:12:55 2008 by  doxygen 1.5.6