Enlightenment CVS committal
Author : titan
Project : e17
Module : apps/ephoto
Dir : e17/apps/ephoto/src/bin
Modified Files:
ephoto.h ephoto_browsing.c ephoto_database.c
ephoto_edit_view.c ephoto_exif.c ephoto_gui.c
ephoto_list_view.c ephoto_normal_view.c ephoto_utils.c
Log Message:
Cleanups.. try to use const char * more.
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ephoto.h 21 Feb 2007 07:06:54 -0000 1.4
+++ ephoto.h 22 Feb 2007 04:06:30 -0000 1.5
@@ -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 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 @@
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
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto_browsing.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- ephoto_browsing.c 15 Feb 2007 10:20:21 -0000 1.1
+++ ephoto_browsing.c 22 Feb 2007 04:06:30 -0000 1.2
@@ -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 @@
}
/*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))
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto_database.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ephoto_database.c 18 Feb 2007 01:02:43 -0000 1.2
+++ ephoto_database.c 22 Feb 2007 04:06:30 -0000 1.3
@@ -77,7 +77,7 @@
}
/*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 @@
}
/*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 @@
}
/*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 @@
}
/*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 @@
}
/*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)
{
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto_edit_view.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ephoto_edit_view.c 21 Feb 2007 07:06:54 -0000 1.5
+++ ephoto_edit_view.c 22 Feb 2007 04:06:30 -0000 1.6
@@ -76,7 +76,7 @@
/*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 @@
/*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);
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto_exif.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ephoto_exif.c 21 Feb 2007 07:06:54 -0000 1.5
+++ ephoto_exif.c 22 Feb 2007 04:06:31 -0000 1.6
@@ -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 @@
}
/*Get the current image*/
-static char *get_image(void)
+static const char *get_image(void)
{
const char *img;
@@ -94,7 +94,8 @@
/*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 @@
/*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;
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto_gui.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ephoto_gui.c 20 Feb 2007 03:45:58 -0000 1.2
+++ ephoto_gui.c 22 Feb 2007 04:06:31 -0000 1.3
@@ -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 @@
}
/*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 @@
}
/*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;
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto_list_view.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ephoto_list_view.c 21 Feb 2007 07:06:54 -0000 1.5
+++ ephoto_list_view.c 22 Feb 2007 04:06:31 -0000 1.6
@@ -90,7 +90,7 @@
/*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 @@
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));
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto_normal_view.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ephoto_normal_view.c 21 Feb 2007 07:06:54 -0000 1.4
+++ ephoto_normal_view.c 22 Feb 2007 04:06:31 -0000 1.5
@@ -39,7 +39,7 @@
/*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 @@
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);
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto_utils.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- ephoto_utils.c 15 Feb 2007 10:20:21 -0000 1.1
+++ ephoto_utils.c 22 Feb 2007 04:06:31 -0000 1.2
@@ -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 @@
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);
-}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs