Cleanups.. try to use const char * more.
SVN revision: 28431
This commit is contained in:
parent
d6430b211d
commit
191c7a52f7
|
@ -18,31 +18,51 @@
|
|||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* NLS */
|
||||
#ifdef ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# include <locale.h>
|
||||
# define _(str) gettext(str)
|
||||
# define gettext_noop(str) str
|
||||
# define N_(str) gettext_noop(str)
|
||||
#else
|
||||
# define _(str) (str)
|
||||
# define gettext_noop(str) str
|
||||
# define N_(str) gettext_noop(str)
|
||||
# define gettext(str) ((char*) (str))
|
||||
#endif
|
||||
|
||||
/* NLS callbacks */
|
||||
char *sgettext(const char *msgid);
|
||||
#define S_(str) sgettext(str)
|
||||
|
||||
#endif
|
||||
|
||||
/* Ephoto Main gui callbacks */
|
||||
void create_main_gui(void);
|
||||
|
||||
/* Ephoto Browsing */
|
||||
Ecore_List *get_directories(char *directory);
|
||||
Ecore_List *get_images(char *directory);
|
||||
Ecore_List *get_directories(const char *directory);
|
||||
Ecore_List *get_images(const char *directory);
|
||||
|
||||
/* Ephoto Exif */
|
||||
Ecore_Hash *get_exif_data(char *file);
|
||||
Ecore_Hash *get_exif_data(const char *file);
|
||||
void display_exif_dialog(Ewl_Widget *w, void *event, void *data);
|
||||
|
||||
/* Ephoto Databasing */
|
||||
sqlite3 *ephoto_db_init(void);
|
||||
void ephoto_db_add_album(sqlite3 *db, char *name, char *description);
|
||||
void ephoto_db_delete_album(sqlite3 *db, char *name);
|
||||
void ephoto_db_add_album(sqlite3 *db, const char *name, const char *description);
|
||||
void ephoto_db_delete_album(sqlite3 *db, const char *name);
|
||||
Ecore_List *ephoto_db_list_albums(sqlite3 *db);
|
||||
void ephoto_db_add_image(sqlite3 *db, char *album, char *name, char *path);
|
||||
void ephoto_db_delete_image(sqlite3 *db, char *album, char *path);
|
||||
Ecore_List *ephoto_db_list_images(sqlite3 *db, char *album);
|
||||
void ephoto_db_add_image(sqlite3 *db, const char *album, const char *name, const char *path);
|
||||
void ephoto_db_delete_image(sqlite3 *db, const char *album, const char *path);
|
||||
Ecore_List *ephoto_db_list_images(sqlite3 *db, const char *album);
|
||||
void ephoto_db_close(sqlite3 *db);
|
||||
|
||||
/* Ephoto Gui */
|
||||
Ewl_Widget *add_button(Ewl_Widget *c, char *txt, char *img, void *cb, void *data);
|
||||
Ewl_Widget *add_image(Ewl_Widget *c, char *img, int thumbnail, void *cb, void *data);
|
||||
Ewl_Widget *add_label(Ewl_Widget *c, char *lbl, int blue);
|
||||
Ewl_Widget *add_button(Ewl_Widget *c, const char *txt, const char *img, void *cb, void *data);
|
||||
Ewl_Widget *add_image(Ewl_Widget *c, const char *img, int thumbnail, void *cb, void *data);
|
||||
Ewl_Widget *add_label(Ewl_Widget *c, const char *lbl, int blue);
|
||||
Ewl_Widget *add_shadow(Ewl_Widget *c);
|
||||
|
||||
/* Ephoto Imaging */
|
||||
|
@ -68,9 +88,9 @@ void set_info(Ewl_Widget *w, void *event, void *data);
|
|||
void generate_thumbnail(Ewl_Widget *image, char *path);
|
||||
|
||||
/* Ephoto Utilities*/
|
||||
char *image_pixels_string_get(const char *file);
|
||||
const char *file_size_get(int size);
|
||||
const char *image_pixels_string_get(const char *file);
|
||||
void image_pixels_int_get(const char *file, int *width, int *height);
|
||||
char *file_size_get(int size);
|
||||
|
||||
/* Ephoto Views */
|
||||
void show_normal_view(Ewl_Widget *w, void *event, void *data);
|
||||
|
@ -107,22 +127,3 @@ struct _Ephoto_Main
|
|||
|
||||
extern Ephoto_Main *em;
|
||||
|
||||
/* NLS */
|
||||
#ifdef ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# include <locale.h>
|
||||
# define _(str) gettext(str)
|
||||
# define gettext_noop(str) str
|
||||
# define N_(str) gettext_noop(str)
|
||||
#else
|
||||
# define _(str) (str)
|
||||
# define gettext_noop(str) str
|
||||
# define N_(str) gettext_noop(str)
|
||||
# define gettext(str) ((char*) (str))
|
||||
#endif
|
||||
|
||||
/* NLS callbacks */
|
||||
char *sgettext(const char *msgid);
|
||||
#define S_(str) sgettext(str)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "ephoto.h"
|
||||
|
||||
/*Populate a List of Sub Directories Inside of Directory.*/
|
||||
Ecore_List *get_directories(char *directory)
|
||||
Ecore_List *get_directories(const char *directory)
|
||||
{
|
||||
Ecore_List *ls, *files;
|
||||
char *file;
|
||||
const char *file;
|
||||
char path[PATH_MAX];
|
||||
|
||||
if (ecore_file_is_dir(directory))
|
||||
|
@ -48,10 +48,10 @@ Ecore_List *get_directories(char *directory)
|
|||
}
|
||||
|
||||
/*Populate a List of Images Inside of Directory*/
|
||||
Ecore_List *get_images(char *directory)
|
||||
Ecore_List *get_images(const char *directory)
|
||||
{
|
||||
Ecore_List *ls, *files;
|
||||
char *file;
|
||||
const char *file;
|
||||
char path[PATH_MAX];
|
||||
|
||||
if (ecore_file_is_dir(directory))
|
||||
|
|
|
@ -77,7 +77,7 @@ static int get_album_id(void *notused, int argc, char **argv, char **col)
|
|||
}
|
||||
|
||||
/*Add a new album to the album table*/
|
||||
void ephoto_db_add_album(sqlite3 *db, char *name, char *description)
|
||||
void ephoto_db_add_album(sqlite3 *db, const char *name, const char *description)
|
||||
{
|
||||
char command[PATH_MAX];
|
||||
|
||||
|
@ -89,7 +89,7 @@ void ephoto_db_add_album(sqlite3 *db, char *name, char *description)
|
|||
}
|
||||
|
||||
/*Deleate an album from the album table*/
|
||||
void ephoto_db_delete_album(sqlite3 *db, char *name)
|
||||
void ephoto_db_delete_album(sqlite3 *db, const char *name)
|
||||
{
|
||||
char command[PATH_MAX];
|
||||
|
||||
|
@ -104,7 +104,7 @@ void ephoto_db_delete_album(sqlite3 *db, char *name)
|
|||
}
|
||||
|
||||
/*Add a new image to a particular album*/
|
||||
void ephoto_db_add_image(sqlite3 *db, char *album, char *name, char *path)
|
||||
void ephoto_db_add_image(sqlite3 *db, const char *album, const char *name, const char *path)
|
||||
{
|
||||
char command[PATH_MAX];
|
||||
|
||||
|
@ -130,7 +130,7 @@ void ephoto_db_add_image(sqlite3 *db, char *album, char *name, char *path)
|
|||
}
|
||||
|
||||
/*Delete an image from a particular album*/
|
||||
void ephoto_db_delete_image(sqlite3 *db, char *album, char *path)
|
||||
void ephoto_db_delete_image(sqlite3 *db, const char *album, const char *path)
|
||||
{
|
||||
char command[PATH_MAX];
|
||||
|
||||
|
@ -204,10 +204,10 @@ static int list_image_ids(void *notused, int argc, char **argv, char **col)
|
|||
}
|
||||
|
||||
/*Return a list of images belonging to a certain album*/
|
||||
Ecore_List *ephoto_db_list_images(sqlite3 *db, char *album)
|
||||
Ecore_List *ephoto_db_list_images(sqlite3 *db, const char *album)
|
||||
{
|
||||
char command[PATH_MAX];
|
||||
char *id;
|
||||
const char *id;
|
||||
|
||||
if(images_list)
|
||||
{
|
||||
|
|
|
@ -76,7 +76,7 @@ void add_edit_tools(Ewl_Widget *c)
|
|||
/*Go to the previous image*/
|
||||
static void previous_image(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
char *image;
|
||||
const char *image;
|
||||
|
||||
ecore_dlist_previous(em->images);
|
||||
image = ecore_dlist_current(em->images);
|
||||
|
@ -95,7 +95,7 @@ static void previous_image(Ewl_Widget *w, void *event, void *data)
|
|||
/*Go to the next image*/
|
||||
static void next_image(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
char *image;
|
||||
const char *image;
|
||||
|
||||
ecore_dlist_next(em->images);
|
||||
image = ecore_dlist_current(em->images);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include "ephoto.h"
|
||||
|
||||
static char *get_image(void);
|
||||
static const char *get_image(void);
|
||||
static void close_dialog(Ewl_Widget *w, void *event, void *data);
|
||||
static void add_exif_to_container(Ewl_Widget *w, void *event, void *data);
|
||||
|
||||
/*Get the Exif Data for an image and return it in a hash*/
|
||||
Ecore_Hash *get_exif_data(char *file)
|
||||
Ecore_Hash *get_exif_data(const char *file)
|
||||
{
|
||||
const char **args, *ifd_name, *title;
|
||||
char value[1024];
|
||||
|
@ -54,7 +54,7 @@ Ecore_Hash *get_exif_data(char *file)
|
|||
}
|
||||
|
||||
/*Get the current image*/
|
||||
static char *get_image(void)
|
||||
static const char *get_image(void)
|
||||
{
|
||||
const char *img;
|
||||
|
||||
|
@ -94,7 +94,8 @@ static void close_dialog(Ewl_Widget *w, void *event, void *data)
|
|||
/*Add all the exif information to the container w*/
|
||||
static void add_exif_to_container(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
char *img, *key, *value, text[PATH_MAX];
|
||||
const char *img, *key, *value;
|
||||
char text[PATH_MAX];
|
||||
Ecore_Hash *exif_info;
|
||||
Ecore_List *keys, *values;
|
||||
Ewl_Widget *win;
|
||||
|
@ -134,7 +135,7 @@ static void add_exif_to_container(Ewl_Widget *w, void *event, void *data)
|
|||
/*Display a dialog which will display exif data*/
|
||||
void display_exif_dialog(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
char *img;
|
||||
const char *img;
|
||||
Ecore_Hash *exif_info;
|
||||
Ewl_Widget *win, *vbox, *image, *sp, *list, *label;
|
||||
Ewl_Model *model;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "ephoto.h"
|
||||
|
||||
/*Create and Add a Button to the Container c*/
|
||||
Ewl_Widget *add_button(Ewl_Widget *c, char *txt, char *img, void *cb, void *data)
|
||||
Ewl_Widget *add_button(Ewl_Widget *c, const char *txt, const char *img, void *cb, void *data)
|
||||
{
|
||||
Ewl_Widget *button;
|
||||
|
||||
|
@ -27,10 +27,10 @@ Ewl_Widget *add_button(Ewl_Widget *c, char *txt, char *img, void *cb, void *data
|
|||
}
|
||||
|
||||
/*Create and Add an Image to the Container c*/
|
||||
Ewl_Widget *add_image(Ewl_Widget *c, char *img, int thumbnail, void *cb, void *data)
|
||||
Ewl_Widget *add_image(Ewl_Widget *c, const char *img, int thumbnail, void *cb, void *data)
|
||||
{
|
||||
Ewl_Widget *image;
|
||||
char *thumb;
|
||||
const char *thumb;
|
||||
int w, h, pid;
|
||||
|
||||
if(!thumbnail)
|
||||
|
@ -77,7 +77,7 @@ Ewl_Widget *add_image(Ewl_Widget *c, char *img, int thumbnail, void *cb, void *d
|
|||
}
|
||||
|
||||
/*Add a label to the container c, with the text lbl, and whether you want it blue*/
|
||||
Ewl_Widget *add_label(Ewl_Widget *c, char *lbl, int blue)
|
||||
Ewl_Widget *add_label(Ewl_Widget *c, const char *lbl, int blue)
|
||||
{
|
||||
Ewl_Widget *label;
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ static Ewl_Widget *list_view_new(void)
|
|||
/*The row that is added to the tree*/
|
||||
static void list_view_assign(Ewl_Widget *w, void *data)
|
||||
{
|
||||
char *image;
|
||||
const char *image;
|
||||
char info[PATH_MAX];
|
||||
int size;
|
||||
int width, height;
|
||||
|
@ -106,7 +106,7 @@ static void list_view_assign(Ewl_Widget *w, void *data)
|
|||
size = ecore_file_size(image);
|
||||
|
||||
snprintf(info, PATH_MAX, "Name: %s\nPixels: %s\nSize: %s\n",
|
||||
basename(image),
|
||||
basename((char *)image),
|
||||
image_pixels_string_get(image),
|
||||
file_size_get(size));
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void show_normal_view(Ewl_Widget *w, void *event, void *data)
|
|||
/*Set the info that is in the info label on normal view*/
|
||||
void set_info(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
char *path, *pixels, *size;
|
||||
const char *path, *pixels, *size;
|
||||
char info[PATH_MAX];
|
||||
time_t modtime;
|
||||
|
||||
|
@ -50,11 +50,11 @@ void set_info(Ewl_Widget *w, void *event, void *data)
|
|||
ewl_widget_state_set(em->currentf, "selected", EWL_STATE_PERSISTENT);
|
||||
}
|
||||
|
||||
path = (char *)ewl_widget_name_get(w);
|
||||
path = ewl_widget_name_get(w);
|
||||
pixels = image_pixels_string_get(path);
|
||||
size = file_size_get(ecore_file_size(path));
|
||||
modtime = ecore_file_mod_time(path);
|
||||
snprintf(info, PATH_MAX, "%s - %s - %s", basename(path), pixels, size);
|
||||
snprintf(info, PATH_MAX, "%s - %s - %s", basename((char *)path), pixels, size);
|
||||
|
||||
ewl_label_text_set(EWL_LABEL(em->ilabel), info);
|
||||
ewl_widget_reparent(em->ilabel);
|
||||
|
|
|
@ -1,7 +1,33 @@
|
|||
#include "ephoto.h"
|
||||
|
||||
const char *file_size_get(int size)
|
||||
{
|
||||
double dsize;
|
||||
char fsize[256];
|
||||
|
||||
dsize = (double)size;
|
||||
if (dsize < 1024.0) snprintf(fsize, sizeof(fsize), _("%'.0f Bytes"), dsize);
|
||||
else
|
||||
{
|
||||
dsize /= 1024.0;
|
||||
if (dsize < 1024) snprintf(fsize, sizeof(fsize), _("%'.0f KB"), dsize);
|
||||
else
|
||||
{
|
||||
dsize /= 1024.0;
|
||||
if (dsize < 1024) snprintf(fsize, sizeof(fsize), _("%'.0f MB"), dsize);
|
||||
else
|
||||
{
|
||||
dsize /= 1024.0;
|
||||
snprintf(fsize, sizeof(fsize), _("%'.1f GB"), dsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
return strdup(fsize);
|
||||
}
|
||||
|
||||
|
||||
/*Get the pixels and return them in a string*/
|
||||
char *image_pixels_string_get(const char *file)
|
||||
const char *image_pixels_string_get(const char *file)
|
||||
{
|
||||
char pixels[PATH_MAX];
|
||||
int w, h;
|
||||
|
@ -33,28 +59,3 @@ void image_pixels_int_get(const char *file, int *width, int *height)
|
|||
return;
|
||||
}
|
||||
|
||||
/*Get the size of a file*/
|
||||
char *file_size_get(int size)
|
||||
{
|
||||
double dsize;
|
||||
char fsize[256];
|
||||
|
||||
dsize = (double)size;
|
||||
if (dsize < 1024.0) snprintf(fsize, sizeof(fsize), _("%'.0f Bytes"), dsize);
|
||||
else
|
||||
{
|
||||
dsize /= 1024.0;
|
||||
if (dsize < 1024) snprintf(fsize, sizeof(fsize), _("%'.0f KB"), dsize);
|
||||
else
|
||||
{
|
||||
dsize /= 1024.0;
|
||||
if (dsize < 1024) snprintf(fsize, sizeof(fsize), _("%'.0f MB"), dsize);
|
||||
else
|
||||
{
|
||||
dsize /= 1024.0;
|
||||
snprintf(fsize, sizeof(fsize), _("%'.1f GB"), dsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
return strdup(fsize);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue