Main Page | Data Structures | Directories | File List | Data Fields | Globals

e_mod_data_picture.h File Reference

Go to the source code of this file.

Data Structures

struct  _Picture_List_Local
struct  _Picture_List_Net
struct  _Picture_Cache
 Cache of pictures in RAM. More...
struct  _Picture
struct  _Picture_Infos

Defines

#define DATA_PICTURE_BOTH   0
#define DATA_PICTURE_LOCAL   1
#define DATA_PICTURE_NET   2
#define DATA_PICTURE_INFOS_LEN   100
#define DATA_PICTURE_THUMB_SIZE_DEFAULT   300
#define DATA_PICTURE_CACHE_SIZE_DEFAULT   2

Functions

int devian_data_picture_list_local_init (void)
 Initialise the list of local pictures wich we can display.
void devian_data_picture_list_local_shutdown (void)
 Shutdown the list of local pictures.
void devian_data_picture_list_local_regen (void)
 This function regenerate the list of local pictures.
int devian_data_picture_list_net_init (void)
void devian_data_picture_list_net_shutdown (void)
int devian_data_picture_cache_init (void)
 Init picture cache.
void devian_data_picture_cache_shutdown (void)
 Shutdown picture cache.
Picture * devian_data_picture_cache_attach (Source_Picture *source, int edje_part)
 Attach a picture to a source.
void devian_data_picture_cache_detach (Source_Picture *source, int part)
 Detach a picture of source.
char * devian_data_picture_get_name_from_path (char *path, int len)
 Get the name of a picture.


Define Documentation

#define DATA_PICTURE_BOTH   0
 

Definition at line 14 of file e_mod_data_picture.h.

Referenced by _picture_list_get_picture().

#define DATA_PICTURE_CACHE_SIZE_DEFAULT   2
 

Definition at line 20 of file e_mod_data_picture.h.

Referenced by devian_config_main_new().

#define DATA_PICTURE_INFOS_LEN   100
 

Definition at line 18 of file e_mod_data_picture.h.

Referenced by _picture_list_local_add_dir().

#define DATA_PICTURE_LOCAL   1
 

Definition at line 15 of file e_mod_data_picture.h.

Referenced by _picture_cache_del_picture(), _picture_free(), _picture_list_get_picture(), _picture_list_local_add_dir(), devian_config_main_new(), and devian_data_picture_cache_detach().

#define DATA_PICTURE_NET   2
 

Definition at line 16 of file e_mod_data_picture.h.

Referenced by _picture_list_get_picture().

#define DATA_PICTURE_THUMB_SIZE_DEFAULT   300
 

Definition at line 19 of file e_mod_data_picture.h.

Referenced by devian_config_main_new().


Function Documentation

Picture* devian_data_picture_cache_attach Source_Picture *  source,
int  edje_part
 

Attach a picture to a source.

Parameters:
source Source where to attach a picture from cache
edje_part Part of the source where to attach the picture
Returns:
A pointer to the picture, or NULL if fails (no pictures avalaible ...)

Definition at line 201 of file e_mod_data_picture.c.

References _picture_cache_fill(), _picture_cache_get_picture_unused(), DDATAC, and dEvianM.

Referenced by devian_source_picture_add(), and devian_source_picture_change().

00203 {
00204   Picture_Cache *cache;
00205   Picture *picture;
00206 
00207   cache = dEvianM->picture_cache;
00208 
00209   /* If old pictures are still attached, abord */
00210   if (!edje_part && source->picture0)
00211     return NULL;
00212   if (edje_part && source->picture1)
00213     return NULL;
00214 
00215   /* Need to fill the cache ? */
00216   if ( cache->pos == -1 )
00217     _picture_cache_fill();
00218   else
00219     if ( cache->pos >
00220    ( evas_list_count(cache->pictures) -
00221      (int)(evas_list_count(cache->pictures) / 4) ) )
00222       _picture_cache_fill();
00223 
00224   /* Get the next picture and change next picture */
00225   if (cache->pos != -1)
00226     {
00227       picture = evas_list_nth(cache->pictures, cache->pos);
00228       cache->pos++;
00229       if ( cache->pos > (evas_list_count(cache->pictures)-1) )
00230   cache->pos = -1; // Overflow -> no more pictures avalaible !
00231     }
00232   else
00233     {
00234       picture = _picture_cache_get_picture_unused();
00235       if (!picture)
00236   return NULL;
00237     }
00238 
00239   /* Attach the picture to the source */
00240   picture->source = source;
00241   if (!edje_part)
00242     source->picture0 = picture;
00243   else
00244     source->picture1 = picture;
00245   cache->nb_attached++;
00246 
00247   DDATAC(("attach ok (%s, %p), pos: %d", picture->picture_description->name, picture, cache->pos));
00248 
00249   return picture;
00250 }

void devian_data_picture_cache_detach Source_Picture *  source,
int  part
 

Detach a picture of source.

Parameters:
source Source where to detach the picture
part Part of the source to use

Definition at line 258 of file e_mod_data_picture.c.

References _picture_free(), DATA_PICTURE_LOCAL, DDATAC, and dEvianM.

Referenced by _picture_cache_del_picture(), devian_source_detach(), and devian_source_picture_del().

00259 {
00260   Picture_Cache *cache;
00261   Picture *picture = NULL;
00262 
00263   cache = dEvianM->picture_cache;
00264 
00265   if (!source)
00266     return;
00267   if (!part && (source->picture0))
00268     {
00269       picture = source->picture0;
00270     }
00271   else
00272     {
00273       if (part && (source->picture1))
00274   picture = source->picture1;
00275       else
00276   printf("BAD BAD BAD in cache detach\n");
00277     }
00278   
00279   if (!picture)
00280     return;
00281 
00282   /* Detach source from picture */
00283   picture->source = NULL;
00284 
00285   /* Picture needs to be deleted ? */
00286   if (picture->delete)
00287     {
00288       if (picture->from == DATA_PICTURE_LOCAL)
00289   _picture_free(picture, 1, 1);
00290     }
00291 
00292   /* Detach picture from source */
00293   if (!part && (source->picture0))
00294     source->picture0 = NULL;
00295   else
00296     {
00297       if (part && (source->picture1))
00298   source->picture1 = NULL;
00299     }
00300 
00301   evas_object_hide(picture->picture);
00302 
00303   cache->nb_attached--;
00304 
00305   if (picture->picture_description)
00306     DDATAC(("detach ok (%s)", picture->picture_description->name));
00307   else
00308     DDATAC(("detach ok (-null-)"));
00309 }

int devian_data_picture_cache_init void   ) 
 

Init picture cache.

Definition at line 154 of file e_mod_data_picture.c.

References _picture_cache_fill(), and dEvianM.

Referenced by devian_devian_main_init().

00155 {
00156   Picture_Cache *cache;
00157 
00158   cache = E_NEW(Picture_Cache, 1);
00159   cache->pictures = NULL;
00160   cache->pos = -1;
00161   cache->nb_attached = 0;
00162   dEvianM->picture_cache = cache;
00163 
00164   _picture_cache_fill();
00165   
00166   return 1;
00167 }

void devian_data_picture_cache_shutdown void   ) 
 

Shutdown picture cache.

Definition at line 172 of file e_mod_data_picture.c.

References _picture_cache_del_picture(), and dEvianM.

Referenced by devian_devian_main_shutdown().

00173 {
00174   Picture_Cache *cache;
00175   Picture *picture;
00176   Evas_List *l;
00177 
00178   cache = dEvianM->picture_cache;
00179 
00180   if(!cache)
00181     return;
00182   
00183   for(l = cache->pictures; l; l = evas_list_next(l))
00184     {
00185       picture = evas_list_data(l);
00186       _picture_cache_del_picture(picture);
00187     }
00188 
00189   evas_list_free(l);
00190   E_FREE(cache);
00191   cache = NULL;
00192 }

char* devian_data_picture_get_name_from_path char *  path,
int  len
 

Get the name of a picture.

Parameters:
path Path of the picture
len Len of the string to return
Returns:
The name

Definition at line 318 of file e_mod_data_picture.c.

References DEVIAN_MAX_PATH.

Referenced by _picture_list_local_add_dir().

00319 {
00320   char name[DEVIAN_MAX_PATH];
00321   int name_l;
00322   char *fichier;
00323   char *ext;
00324   int ext_l;
00325 
00326   fichier = strrchr(path, '/') + 1;
00327   if(!fichier)
00328     return strdup(path);
00329 
00330   ext = strrchr(path, '.');
00331   if (!ext)
00332     return strdup(path);
00333   ext_l = strlen(ext);
00334 
00335   name_l = strlen(fichier) - ext_l;
00336 
00337   strncpy(name, fichier, name_l);
00338   name[name_l] = '\0';
00339   
00340   return (char *)evas_stringshare_add(name);
00341 }

int devian_data_picture_list_local_init void   ) 
 

Initialise the list of local pictures wich we can display.

This function creates a list of pictures and generate thumbs for all pictures in pictures directories.

Returns:
0 on success

Definition at line 28 of file e_mod_data_picture.c.

References _picture_list_local_add_dir(), _picture_list_local_popup_load_start(), _picture_list_local_popup_load_stop(), and dEvianM.

Referenced by devian_data_picture_list_local_regen(), and devian_devian_main_init().

00029 {
00030   E_Popup *popup;
00031   Picture_List_Local *list;
00032 
00033   if (!dEvianM->picture_list_local)
00034     {
00035       list = E_NEW(Picture_List_Local, 1);
00036       list->pictures = NULL;
00037       list->nb_pictures_waiting = 0;
00038       dEvianM->picture_list_local = list;
00039     }
00040   else
00041     list = dEvianM->picture_list_local;
00042 
00043   /* Load pictures */
00044   popup = _picture_list_local_popup_load_start();
00045   _picture_list_local_add_dir(e_module_dir_get(dEvianM->module), 0);
00046   _picture_list_local_add_dir(dEvianM->conf->sources_picture_data_import_dir,
00047             dEvianM->conf->sources_picture_data_import_recursive);
00048   _picture_list_local_popup_load_stop(popup);
00049 
00050   if (dEvianM->conf->sources_picture_data_import_thumbs_warn &&
00051       (list->nb_pictures_waiting > 2))
00052     {
00053       char buf[4096];
00054       dEvianM->conf->sources_picture_data_import_thumbs_warn = 0;
00055       snprintf(buf, sizeof(buf),
00056          _(
00057      "<hilight>Creating thumbs</hilight><br><br>"
00058      "%d pictures are being thumbed in a background task.<br>"
00059      "It can take a while, but after, loading will be faster :)<br><br>"
00060      "Each time wou will load pictures that haven't been loaded in devian before,<br>"
00061      "they will be thumbed"
00062      ),
00063          list->nb_pictures_waiting
00064          );
00065       e_module_dialog_show(_("dEvian Module Information"), buf);
00066       return 0;
00067     }
00068   
00069   return 0;
00070 }

void devian_data_picture_list_local_regen void   ) 
 

This function regenerate the list of local pictures.

Definition at line 102 of file e_mod_data_picture.c.

References _picture_free(), devian_data_picture_list_local_init(), and dEvianM.

Referenced by _main_advanced_create_widgets(), and _main_basic_create_widgets().

00103 {
00104   Picture_List_Local *list;
00105   Evas_List *l;
00106   Picture *picture;
00107 
00108   list = dEvianM->picture_list_local;
00109 
00110   if (!list)
00111     {
00112       devian_data_picture_list_local_init();
00113       return;
00114     }
00115 
00116   if (list->nb_pictures_waiting)
00117     {
00118       printf("WAIT ITS ALREADY RUNNING =)\n");
00119       return;
00120     }
00121 
00122   for (l=list->pictures; l; l=evas_list_next(l))
00123     {
00124       picture = evas_list_data(l);
00125       _picture_free(picture, 1, 0);
00126 
00127       /*
00128       {
00129   Evas_List *o;
00130   Picture *O;
00131   printf("\n");
00132   for(o=list->pictures; o; o=evas_list_next(o))
00133     {
00134       O = evas_list_data(o);
00135       printf("%s - ", O->picture_description->name);
00136     }
00137   printf("\n\n");
00138       }
00139       */
00140 
00141     }
00142   //dEvianM->picture_list_local->pictures=l;
00143 
00144   devian_data_picture_list_local_init();
00145 }

void devian_data_picture_list_local_shutdown void   ) 
 

Shutdown the list of local pictures.

It deletes all pictures and free the list

Definition at line 77 of file e_mod_data_picture.c.

References _picture_free(), and dEvianM.

Referenced by devian_devian_main_shutdown().

00078 {
00079   Picture_List_Local *list;
00080   Evas_List *l;
00081   Picture *picture;
00082 
00083   list = dEvianM->picture_list_local;
00084 
00085   if (!list)
00086     return;
00087 
00088   for (l=list->pictures; l; l=evas_list_next(l))
00089     {
00090       picture = evas_list_data(l);
00091       _picture_free(picture, 1, 1);
00092     }
00093 
00094   evas_list_free(l);
00095   E_FREE(list);
00096   dEvianM->picture_list_local=NULL;
00097 }

int devian_data_picture_list_net_init void   ) 
 

void devian_data_picture_list_net_shutdown void   ) 
 


Generated on Fri Jan 6 02:26:26 2006 for dEvian by  doxygen 1.4.4