A lot of fixes and changes.. still needs a bit of work.. got some bugs to fixes. Wanted to get what I have in to cvs.

SVN revision: 34222
master
titan 16 years ago committed by titan
parent 8b98342250
commit c7e5687565
  1. 32
      src/bin/Makefile.am
  2. 57
      src/bin/ephoto.c
  3. 178
      src/bin/ephoto.h
  4. 249
      src/bin/ephoto_albums.c
  5. 194
      src/bin/ephoto_browser.c
  6. 94
      src/bin/ephoto_browsing.c
  7. 62
      src/bin/ephoto_database.c
  8. 127
      src/bin/ephoto_dialogs.c
  9. 440
      src/bin/ephoto_edit_view.c
  10. 63
      src/bin/ephoto_exif.c
  11. 101
      src/bin/ephoto_gui.c
  12. 43
      src/bin/ephoto_imaging.c
  13. 98
      src/bin/ephoto_import.c
  14. 152
      src/bin/ephoto_list_view.c
  15. 187
      src/bin/ephoto_main.c
  16. 4
      src/bin/ephoto_nls.c
  17. 98
      src/bin/ephoto_normal_view.c
  18. 478
      src/bin/ephoto_single_view.c
  19. 19
      src/bin/ephoto_slideshow.c
  20. 93
      src/bin/ephoto_utils.c

@ -6,25 +6,23 @@ MAINTAINERCLEANFILES = *.o ephoto config.h.in config.h Makefile.in Makefile \
bin_PROGRAMS = ephoto
ephoto_SOURCES = ephoto.c \
ephoto_browsing.c \
ephoto_browser.c \
ephoto_database.c \
ephoto_dialogs.c \
ephoto_edit_view.c \
ephoto_exif.c \
ephoto_gui.c \
ephoto_imaging.c \
ephoto_list_view.c \
ephoto_main.c \
ephoto_nls.c \
ephoto_normal_view.c \
ephoto_single_view.c \
ephoto_slideshow.c \
ephoto_utils.c
ephoto_albums.c \
ephoto_database.c \
ephoto_dialogs.c \
ephoto_exif.c \
ephoto_gui.c \
ephoto_imaging.c \
ephoto_import.c \
ephoto_main.c \
ephoto_nls.c \
ephoto_normal_view.c \
ephoto_single_view.c \
ephoto_slideshow.c \
ephoto_utils.c
ephoto_CFLAGS = @EWL_CFLAGS@ @SQLITE_CFLAGS@ @EXIF_CFLAGS@ @EFREET_MIME_CFLAGS@ -Wall
ephoto_CFLAGS = @EWL_CFLAGS@ @SQLITE_CFLAGS@ @EXIF_CFLAGS@ @EFREET_MIME_CFLAGS@ @EPSILON_CFLAGS@ -Wall
ephoto_LDADD = @EWL_LIBS@ @SQLITE_LIBS@ @EXIF_LIBS@ @EFREET_MIME_LIBS@
ephoto_LDADD = @EWL_LIBS@ @SQLITE_LIBS@ @EXIF_LIBS@ @EFREET_MIME_LIBS@ @EPSILON_LIBS@
EXTRA_DIST = \
ephoto.h

@ -1,15 +1,63 @@
#include "ephoto.h"
int main(int argc, char **argv)
Ephoto_Config *ec;
Ephoto_Main *em;
int
main(int argc, char **argv)
{
/*Check to make sure EWL is accessible*/
int i;
if (!ewl_init(&argc, argv))
{
printf("Ewl is not usable, please check your installation!\n");
return 1;
}
/* NLS */
em = NULL;
em = calloc(1, sizeof(Ephoto_Main));
em->albums = ecore_list_new();
em->fsystem = ecore_list_new();
em->images = ecore_dlist_new();
em->types = ecore_hash_new(ecore_str_hash, ecore_str_compare);
ecore_hash_set(em->types, "image/gif", "image");
ecore_hash_set(em->types, "image/jpeg", "image");
ecore_hash_set(em->types, "image/png", "image");
ecore_hash_set(em->types, "image/svg+xml", "image");
ecore_hash_set(em->types, "image/tiff", "image");
ec = NULL;
ec = calloc(1, sizeof(Ephoto_Config));
for(i = 1; i < argc; i++)
{
if (!strcmp(argv[i], "--help"))
{
printf( "Help Page\n"
"ephoto %%f - Opens an image for viewing\n");
return 0;
}
else
{
if(strncmp(argv[i], "/", 1))
{
char buf[PATH_MAX], file[PATH_MAX];
getcwd(buf, PATH_MAX);
buf[sizeof(buf)-1] = '\0';
snprintf(file, PATH_MAX, "%s/%s", buf, argv[i]);
if (ecore_file_exists(file))
ec->requested_image = file;
}
else
if (ecore_file_exists(argv[i]))
ec->requested_image = argv[i];
}
}
#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
@ -17,11 +65,10 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
#endif
/*Start the GUI*/
create_main();
/*Star the ewl loop*/
ewl_main();
return 0;
}

@ -1,20 +1,28 @@
#ifndef _EPHOTO_H_
#define _EPHOTO_H_
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "config.h"
#include <Ecore.h>
#include <Ecore_Data.h>
#include <Ecore_File.h>
#include <Efreet_Mime.h>
#include <Epsilon.h>
#include <Evas.h>
#include <Ewl.h>
#include <libgen.h>
#include <limits.h>
#include <math.h>
#include <pthread.h>
#include <sched.h>
#include <sqlite3.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
@ -24,7 +32,6 @@
#include <libexif/exif-loader.h>
#endif
/* NLS */
#ifdef ENABLE_NLS
#include <libintl.h>
#include <locale.h>
@ -38,56 +45,73 @@
#define gettext(str) ((char*) (str))
#endif
/* NLS callbacks */
char *sgettext(const char *msgid);
#define S_(str) sgettext(str)
/*Ephoto*/
void create_main(void);
/* Ephoto Browser */
void show_browser(Ewl_Widget *w, void *event, void *data);
void populate_directories(Ewl_Widget *w, void *event, void *data);
/*ephoto_albums.c*/
void show_albums(Ewl_Widget *c);
void populate_albums(Ewl_Widget *w, void *event, void *data);
void show_add_album_dialog(Ewl_Widget *w, void *event, void *data);
void *get_albums_pre();
void *get_aimages_pre();
void *create_athumb();
/* Ephoto Browsing */
Ecore_List *get_directories(const char *directory);
Ecore_List *get_images(const char *directory);
/* Ephoto Databasing */
/*ephoto_database.c*/
sqlite3 *ephoto_db_init(void);
void ephoto_db_add_album(sqlite3 *db, const char *name, const char *description);
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, const char *album, const char *name, const char *path);
void ephoto_db_delete_image(sqlite3 *db, const char *album, const char *path);
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 Dialogs */
/*ephoto_dialogs.c*/
void about_dialog(Ewl_Widget *w, void *event, void *data);
void add_album(Ewl_Widget *w, void *event, void *data);
void add_album_dialog(Ewl_Widget *w, void *event, void *data);
/* Ephoto Exif */
/*ephoto_exif.c*/
#ifdef BUILD_EXIF_SUPPORT
Ecore_Hash *get_exif_data(const char *file);
void display_exif_dialog(Ewl_Widget *w, void *event, void *data);
void add_exif_to_container(Ewl_Widget *c);
void display_exif(Ewl_Widget *w, void *event, void *data);
#endif
/* Ephoto GUI */
Ewl_Widget *add_box(Ewl_Widget *c, Ewl_Orientation orientation, int spacing);
Ewl_Widget *add_button(Ewl_Widget *c, char *lbl, const char *img, void *cb, void *data);
Ewl_Widget *add_entry(Ewl_Widget *c, char *txt, void *cb, void *data);
Ewl_Widget *add_icon(Ewl_Widget *c, char *lbl, const char *img, int thumbnail, void *cb, void *data);
Ewl_Widget *add_image(Ewl_Widget *c, const char *img, int thumbnail, void *cb, void *data);
/*ephoto_fsystem.c*/
void show_fsystem(Ewl_Widget *c);
void populate_fsystem(Ewl_Widget *w, void *event, void *data);
void *get_directories_pre();
void *get_fimages_pre();
void *create_fthumb();
/*ephoto_gui.c*/
Ewl_Widget *add_box(Ewl_Widget *c, Ewl_Orientation o, int spacing);
Ewl_Widget *add_button(Ewl_Widget *c, char *lbl, const char *img,
void *cb,
void *data);
Ewl_Widget *add_entry(Ewl_Widget *c, char *txt, void *cb,
void *data);
Ewl_Widget *add_icon(Ewl_Widget *c, char *lbl, const char *img,
int thumb,
void *cb,
void *data);
Ewl_Widget *add_image(Ewl_Widget *c,
const char *img, int thumb,
void *cb,
void *data);
Ewl_Widget *add_label(Ewl_Widget *c, char *lbl);
Ewl_Widget *add_menubar(Ewl_Widget *c);
Ewl_Widget *add_menu(Ewl_Widget *c, char *lbl);
Ewl_Widget *add_menu_item(Ewl_Widget *c, char *lbl, const char *img, void *cb, void *data);
Ewl_Widget *add_menu_item(Ewl_Widget *c, char *lbl,
const char *img,
void *cb,
void *data);
Ewl_Widget *add_text(Ewl_Widget *c, char *text);
Ewl_Widget *add_shadow(Ewl_Widget *c);
Ewl_Widget *add_window(char *name, int width, int height, void *cb, void *data);
Ewl_Widget *add_window(char *name, int w, int h, void *cb,
void *data);
/* Ephoto Imaging */
/*ephoto_imaging.c*/
unsigned int *flip_horizontal(Ewl_Widget *image);
unsigned int *flip_vertical(Ewl_Widget *image);
unsigned int *rotate_left(Ewl_Widget *image);
@ -96,68 +120,74 @@ unsigned int *blur_image(Ewl_Widget *image);
unsigned int *sharpen_image(Ewl_Widget *image);
unsigned int *grayscale_image(Ewl_Widget *image);
unsigned int *sepia_image(Ewl_Widget *image);
void update_image(Ewl_Widget *image, int w, int h, unsigned int *data);
void save_dialog(const char *file);
void update_image(Ewl_Widget *image, int w, int h,
unsigned int *data);
/* Ephoto Utilities*/
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);
/*********************VIEWS******************/
/*ephoto_import.c*/
void ephoto_import_dialog(Ewl_Widget *w, void *event, void *data);
/*Ephoto Edit*/
Ewl_Widget *add_edit_view(Ewl_Widget *c);
/*ephoto_main.c*/
void create_main(void);
/*Ephoto List*/
Ewl_Widget *add_list_view(Ewl_Widget *c);
Ewl_Widget *add_ltree(Ewl_Widget *c);
/*ephoto_nls.c*/
char *sgettext(const char *msgid);
#define S_(str) sgettext(str)
/*Ephoto Normal*/
/*ephoto_normal_view.c*/
Ewl_Widget *add_normal_view(Ewl_Widget *c);
void freebox_image_clicked(Ewl_Widget *w, void *event, void *data);
void show_normal_view(Ewl_Widget *w, void *event, void *data);
/* Ephoto Single*/
/*ephoto_single_view.c*/
Ewl_Widget *add_single_view(Ewl_Widget *c);
void show_single_view(Ewl_Widget *w, void *event, void *data);
/* Ephoto Slideshow*/
/*ephoto_slideshow.c*/
void start_slideshow(Ewl_Widget *w, void *event, void *data);
/* Ephoto Views*/
void show_edit_view(Ewl_Widget *w, void *event, void *data);
void show_list_view(Ewl_Widget *w, void *event, void *data);
void show_normal_view(Ewl_Widget *w, void *event, void *data);
void show_single_view(Ewl_Widget *w, void *event, void *data);
/*ephoto_utils.c*/
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);
Ecore_List *get_directories(const char *directory);
Ecore_List *get_images(const char *directory);
/* Ephoto Global Variables */
/*globals*/
typedef struct _Ephoto_Main Ephoto_Main;
struct _Ephoto_Main
{
char *current_directory;
Ecore_Hash *types;
Ecore_List *directories;
Ecore_List *images;
Ewl_Widget *bwin;
Ewl_Widget *dtree;
Ewl_Widget *edit_vbox;
Ewl_Widget *eimage;
Ewl_Widget *fbox_vbox;
Ewl_Widget *fbox;
char *current_album;
char *current_directory;
Ecore_Hash *types;
Ecore_List *albums;
Ecore_List *fsystem;
Ecore_List *images;
Ewl_Widget *atree;
Ewl_Widget *ewin;
Ewl_Widget *fbox_vbox;
Ewl_Widget *fbox;
Ewl_Widget *ftree;
Ewl_Widget *fthumb_size;
Ewl_Widget *list_vbox;
Ewl_Widget *ltree;
Ewl_Widget *lthumb_size;
Ewl_Widget *simage;
Ewl_Widget *single_sp;
Ewl_Widget *single_vbox;
Ewl_Widget *smi;
Ewl_Widget *toolbar;
Ewl_Widget *view;
Ewl_Widget *view_box;
Ewl_Widget *single_vbox;
Ewl_Widget *view;
Ewl_Widget *view_box;
Ewl_Widget *win;
sqlite3 *db;
};
typedef struct _Ephoto_Config Ephoto_Config;
struct _Ephoto_Config
{
char *requested_album;
char *requested_directory;
char *requested_image;
};
extern Ephoto_Main *em;
extern Ephoto_Config *ec;
#endif

@ -0,0 +1,249 @@
#include "ephoto.h"
static Ewl_Widget *add_atree(Ewl_Widget *c);
static Ewl_Widget *album_view_new(void *data, unsigned int row,
unsigned int column);
static Ewl_Widget *album_header_fetch(void *data,
unsigned int column);
static void *album_data_fetch(void *data, unsigned int row,
unsigned int column);
static unsigned int album_data_count(void *data);
static void add_rc_menu(Ewl_Widget *w, void *event, void *data);
static void album_clicked(Ewl_Widget *w, void *event, void *data);
static void thumb_clicked(Ewl_Widget *w, void *event, void *data);
void
show_albums(Ewl_Widget *c)
{
em->atree = add_atree(c);
ewl_object_maximum_w_set(EWL_OBJECT(em->atree), 180);
populate_albums(NULL, NULL, NULL);
}
static Ewl_Widget *
add_atree(Ewl_Widget *c)
{
Ewl_Widget *tree;
Ewl_Model *model;
Ewl_View *view;
model = ewl_model_new();
ewl_model_data_fetch_set(model, album_data_fetch);
ewl_model_data_count_set(model, album_data_count);
view = ewl_view_new();
ewl_view_widget_fetch_set(view, album_view_new);
ewl_view_header_fetch_set(view, album_header_fetch);
tree = ewl_tree_new();
ewl_tree_headers_visible_set(EWL_TREE(tree), 0);
ewl_tree_fixed_rows_set(EWL_TREE(tree), 1);
ewl_tree_column_count_set(EWL_TREE(tree), 1);
ewl_mvc_model_set(EWL_MVC(tree), model);
ewl_mvc_view_set(EWL_MVC(tree), view);
ewl_mvc_selection_mode_set(EWL_MVC(tree), EWL_SELECTION_MODE_SINGLE);
ewl_object_fill_policy_set(EWL_OBJECT(tree), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(c), tree);
ewl_widget_show(tree);
return tree;
}
static Ewl_Widget *
album_view_new(void *data, unsigned int row, unsigned int column)
{
char *album;
Ewl_Widget *icon;
album = data;
icon = add_icon(NULL, album, PACKAGE_DATA_DIR "/images/image.png", 0,
album_clicked, NULL);
ewl_icon_constrain_set(EWL_ICON(icon), 25);
ewl_box_orientation_set(EWL_BOX(icon), EWL_ORIENTATION_HORIZONTAL);
ewl_object_alignment_set(EWL_OBJECT(icon), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(icon), EWL_FLAG_FILL_ALL);
ewl_widget_name_set(icon, album);
ewl_callback_append(icon, EWL_CALLBACK_SHOW, add_rc_menu, NULL);
return icon;
}
static Ewl_Widget *
album_header_fetch(void *data, unsigned int column)
{
Ewl_Widget *label;
label = add_label(NULL, "Albums");
return label;
}
static void *
album_data_fetch(void *data, unsigned int row, unsigned int column)
{
const char *album;
void *val = NULL;
album = ecore_list_index_goto(em->albums, row);
if (album)
{
val = (void *)album;
}
return val;
}
static unsigned int
album_data_count(void *data)
{
int val;
val = ecore_list_count(em->albums);
return val;
}
static void album_clicked(Ewl_Widget *w, void *event, void *data)
{
em->current_album = strdup(ewl_icon_label_get(EWL_ICON(w)));
populate_albums(NULL, NULL, NULL);
}
static void
rc_remove(Ewl_Widget *w, void *event, void *data)
{
Ewl_Widget *icon;
icon = data;
ephoto_db_delete_album(em->db, ewl_icon_label_get(EWL_ICON(icon)));
populate_albums(NULL, NULL, NULL);
}
static void
add_rc_menu(Ewl_Widget *w, void *event, void *data)
{
Ewl_Widget *context;
context = ewl_context_menu_new();
ewl_context_menu_attach(EWL_CONTEXT_MENU(context), w);
add_menu_item(context, "Remove Album",
PACKAGE_DATA_DIR "/images/remove.png",
rc_remove, w);
}
static void
thumb_clicked(Ewl_Widget *w, void *event, void *data)
{
const char *file;
char *point1;
file = ewl_widget_name_get(w);
ecore_dlist_first_goto(em->images);
while(ecore_dlist_current(em->images))
{
point1 = ecore_dlist_current(em->images);
if (!strcmp(point1, file)) break;
ecore_dlist_next(em->images);
}
show_single_view(NULL, NULL, NULL);
}
void
populate_albums(Ewl_Widget *w, void *event, void *data)
{
const char *album;
pthread_t thumb_worker, album_worker, image_worker;
int ret1, ret2;
album = NULL;
if (w)
{
album = ewl_widget_name_get(w);
em->current_album = strdup(album);
}
if (!ecore_list_empty_is(em->albums))
{
ecore_list_destroy(em->albums);
}
if (!ecore_list_empty_is(em->images))
{
ecore_dlist_destroy(em->images);
}
em->albums = ecore_list_new();
em->images = ecore_dlist_new();
if(em->fbox) ewl_container_reset(EWL_CONTAINER(em->fbox));
ret1 = pthread_create(&album_worker, NULL, get_albums_pre, NULL);
ret2 = pthread_create(&image_worker, NULL, get_aimages_pre, NULL);
if (ret1 || ret2)
{
printf("ERROR: Couldn't create thread!\n");
return;
}
pthread_join(album_worker, NULL);
pthread_join(image_worker, NULL);
ret1 = pthread_create(&thumb_worker, NULL, create_athumb, NULL);
if (ret1)
{
printf("ERROR: Couldn't create thread!\n");
return;
}
pthread_detach(thumb_worker);
return;
}
void *
create_athumb()
{
Ewl_Widget *thumb;
char *imagef;
while (ecore_dlist_current(em->images))
{
imagef = ecore_dlist_current(em->images);
if (imagef)
{
thumb = add_image(em->fbox, imagef, 1,
thumb_clicked, NULL);
ewl_image_constrain_set(EWL_IMAGE(thumb),
ewl_range_value_get(EWL_RANGE
(em->fthumb_size)));
ewl_object_alignment_set(EWL_OBJECT(thumb),
EWL_FLAG_ALIGN_CENTER);
ewl_widget_name_set(thumb, imagef);
}
ecore_dlist_next(em->images);
}
ewl_widget_configure(em->fbox_vbox);
pthread_exit(NULL);
}
void *
get_albums_pre()
{
em->albums = ephoto_db_list_albums(em->db);
ecore_dlist_first_goto(em->albums);
ewl_mvc_data_set(EWL_MVC(em->atree), em->albums);
pthread_exit(NULL);
}
void *
get_aimages_pre()
{
em->images = ephoto_db_list_images(em->db, em->current_album);
ecore_dlist_first_goto(em->images);
pthread_exit(NULL);
}

@ -1,194 +0,0 @@
#include "ephoto.h"
static void destroy(Ewl_Widget *w, void *event, void *data);
/*Ephoto Directory Tree*/
static Ewl_Widget *add_dtree(Ewl_Widget *c);
/*Ephoto MVC Callbacks*/
static Ewl_Widget *directory_view_new(void *data, unsigned int row, unsigned int column);
static Ewl_Widget *directory_header_fetch(void *data, unsigned int column);
static void *directory_data_fetch(void *data, unsigned int row, unsigned int column);
static unsigned int directory_data_count(void *data);
static void destroy(Ewl_Widget *w, void *event, void *data)
{
ewl_widget_destroy(w);
em->bwin = NULL;
}
void show_browser(Ewl_Widget *w, void *event, void *data)
{
if (!em->bwin)
{
em->bwin = add_window("Browser!", 200, 400, destroy, NULL);
em->dtree = add_dtree(em->bwin);
ewl_object_maximum_w_set(EWL_OBJECT(em->dtree), 200);
populate_directories(NULL, NULL, NULL);
}
}
/*Create and Add a Tree to the Container c*/
static Ewl_Widget *add_dtree(Ewl_Widget *c)
{
Ewl_Widget *tree;
Ewl_Model *model;
Ewl_View *view;
model = ewl_model_new();
ewl_model_data_fetch_set(model, directory_data_fetch);
ewl_model_data_count_set(model, directory_data_count);
view = ewl_view_new();
ewl_view_widget_fetch_set(view, directory_view_new);
ewl_view_header_fetch_set(view, directory_header_fetch);
tree = ewl_tree_new();
ewl_tree_headers_visible_set(EWL_TREE(tree), 0);
ewl_tree_fixed_rows_set(EWL_TREE(tree), 1);
ewl_tree_column_count_set(EWL_TREE(tree), 1);
ewl_mvc_model_set(EWL_MVC(tree), model);
ewl_mvc_view_set(EWL_MVC(tree), view);
ewl_mvc_selection_mode_set(EWL_MVC(tree), EWL_SELECTION_MODE_NONE);
ewl_object_fill_policy_set(EWL_OBJECT(tree), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(c), tree);
ewl_widget_show(tree);
return tree;
}
/* The view of the users directories */
static Ewl_Widget *directory_view_new(void *data, unsigned int row, unsigned int column)
{
char *current_directory, *directory;
int len;
Ewl_Widget *icon;
len = strlen(em->current_directory);
current_directory = alloca(len + 1);
strcpy(current_directory, em->current_directory);
directory = data;
icon = add_icon(NULL, basename(directory),
PACKAGE_DATA_DIR "/images/folder.png", 0,
populate_directories, NULL);
ewl_icon_constrain_set(EWL_ICON(icon), 25);
ewl_box_orientation_set(EWL_BOX(icon), EWL_ORIENTATION_HORIZONTAL);
ewl_object_alignment_set(EWL_OBJECT(icon), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(icon), EWL_FLAG_FILL_ALL);
if (!strncmp(directory, "..", 2))
{
ewl_icon_image_set(EWL_ICON(icon), PACKAGE_DATA_DIR "/images/go-up.png", NULL);
ewl_icon_constrain_set(EWL_ICON(icon), 25);
ewl_widget_name_set(icon, dirname(current_directory));
}
else
{
ewl_widget_name_set(icon, directory);
}
return icon;
}
/* The header for the tree */
static Ewl_Widget *directory_header_fetch(void *data, unsigned int column)
{
Ewl_Widget *label;
label = add_label(NULL, "Directories");
return label;
}
/*The directories that will be displayed*/
static void *directory_data_fetch(void *data, unsigned int row, unsigned int column)
{
const char *directory;
void *val = NULL;
directory = ecore_list_index_goto(em->directories, row);
if (directory)
{
val = (void *)directory;
}
return val;
}
/* The number of directories the view is displaying */
static unsigned int directory_data_count(void *data)
{
int val;
val = ecore_list_count(em->directories);
return val;
}
/*Update the Image List*/
void populate_directories(Ewl_Widget *w, void *event, void *data)
{
const char *directory;
char *imagef;
Ewl_Widget *thumb;
directory = NULL;
if (w)
{
directory = ewl_widget_name_get(w);
em->current_directory = strdup(directory);
}
if (!ecore_list_empty_is(em->directories))
{
ecore_list_destroy(em->directories);
}
em->directories = ecore_list_new();
em->directories = get_directories(em->current_directory);
ecore_dlist_first_goto(em->directories);
ewl_mvc_data_set(EWL_MVC(em->dtree), em->directories);
if (!ecore_list_empty_is(em->images))
{
ecore_dlist_destroy(em->images);
}
em->images = ecore_dlist_new();
em->images = get_images(em->current_directory);
ecore_dlist_first_goto(em->images);
ewl_container_reset(EWL_CONTAINER(em->fbox));
while (ecore_dlist_current(em->images))
{
imagef = ecore_dlist_current(em->images);
if(imagef)
{
thumb = add_image(em->fbox, imagef, 1,
freebox_image_clicked, NULL);
ewl_image_constrain_set(EWL_IMAGE(thumb),
ewl_range_value_get(EWL_RANGE(em->fthumb_size)));
ewl_object_alignment_set(EWL_OBJECT(thumb),
EWL_FLAG_ALIGN_CENTER);
ewl_widget_name_set(thumb, imagef);
}
ecore_dlist_next(em->images);
}
ewl_widget_configure(em->fbox_vbox);
ewl_mvc_data_set(EWL_MVC(em->ltree), em->images);
ecore_dlist_first_goto(em->images);
if (ecore_dlist_current(em->images))
{
ewl_image_file_path_set(EWL_IMAGE(em->simage),
ecore_dlist_current(em->images));
}
return;
}

@ -1,94 +0,0 @@
#include "ephoto.h"
/*Populate a List of Sub Directories Inside of Directory.*/
Ecore_List *get_directories(const char *directory)
{
Ecore_List *ls, *files;
char *file;
char path[PATH_MAX];
if (ecore_file_is_dir(directory))
{
ls = ecore_list_new();
files = ecore_list_new();
ecore_list_free_cb_set(files, free);
if (strcmp(directory, "/"))
{
ecore_list_append(files, strdup(".."));
}
ls = ecore_file_ls(directory);
while (!ecore_list_empty_is(ls))
{
file = ecore_list_first_remove(ls);
if (strncmp(file, ".", 1))
{
if (strcmp(directory, "/"))
{
snprintf(path, PATH_MAX, "%s/%s",
directory, file);
}
else
{
snprintf(path, PATH_MAX, "%s%s",
directory, file);
}
}
if (ecore_file_is_dir(path))
{
ecore_list_append(files, strdup(path));
}
}
}
else
{
files = NULL;
}
ecore_list_first_goto(files);
return files;
}
/*Populate a List of Images Inside of Directory*/
Ecore_List *get_images(const char *directory)
{
Ecore_List *ls, *files;
char path[PATH_MAX], *file;
if (ecore_file_is_dir(directory))
{
ls = ecore_list_new();
files = ecore_dlist_new();
ecore_dlist_free_cb_set(files, free);
ls = ecore_file_ls(directory);
while (!ecore_list_empty_is(ls))
{
file = ecore_list_first_remove(ls);
if (strncmp(file, ".", 1))
{
const char *type;
if (strcmp(directory, "/"))
{
snprintf(path, PATH_MAX, "%s/%s",
directory, file);
}
else
{
snprintf(path, PATH_MAX, "%s%s",
directory, file);
}
type = efreet_mime_type_get(strdup(path));
if ((ecore_hash_get(em->types, type)) == "image")
{
ecore_dlist_append(files, strdup(path));
}
}
}
}
else
{
files = NULL;
}
ecore_dlist_first_goto(files);
return files;
}

@ -1,20 +1,17 @@
#include "ephoto.h"
/*Ephoto databasing callbacks*/
static int get_album_id(void *notused, int argc, char **argv, char **col);
static int get_image_id(void *notused, int argc, char **argv, char **col);
static int list_albums(void *notused, int argc, char **argv, char **col);
static int list_images(void *notused, int argc, char **argv, char **col);
static int list_image_ids(void *notused, int argc, char **argv, char **col);
/*Ephoto databasing global variables*/
static int image_id, album_id;
/*Ephoto databasing ecore global variables*/
static Ecore_List *albums, *images_list, *image_ids;
/*Open the sqlite3 database. Create the database if it does not already exits.*/
sqlite3 *ephoto_db_init(void)
sqlite3 *
ephoto_db_init(void)
{
char path[PATH_MAX];
char path2[PATH_MAX];
@ -55,8 +52,8 @@ sqlite3 *ephoto_db_init(void)
return db;
}
/*Get the id of an image in the images table*/
static int get_image_id(void *notused, int argc, char **argv, char **col)
static int
get_image_id(void *notused, int argc, char **argv, char **col)
{
int i;
@ -68,8 +65,8 @@ static int get_image_id(void *notused, int argc, char **argv, char **col)
return 0;
}
/*Get the id of an album in the albums table*/
static int get_album_id(void *notused, int argc, char **argv, char **col)
static int
get_album_id(void *notused, int argc, char **argv, char **col)
{
int i;
@ -81,8 +78,8 @@ static int get_album_id(void *notused, int argc, char **argv, char **col)
return 0;
}
/*Add a new album to the album table*/
void ephoto_db_add_album(sqlite3 *db, const char *name, const char *description)
void
ephoto_db_add_album(sqlite3 *db, const char *name, const char *description)
{
char command[PATH_MAX];
@ -94,8 +91,8 @@ void ephoto_db_add_album(sqlite3 *db, const char *name, const char *description)
return;
}
/*Deleate an album from the album table*/
void ephoto_db_delete_album(sqlite3 *db, const char *name)
void
ephoto_db_delete_album(sqlite3 *db, const char *name)
{
char command[PATH_MAX];
@ -113,8 +110,8 @@ void ephoto_db_delete_album(sqlite3 *db, const char *name)
return;
}
/*Add a new image to a particular album*/
void ephoto_db_add_image(sqlite3 *db, const char *album, const char *name, const char *path)
void
ephoto_db_add_image(sqlite3 *db, const char *album, const char *name, const char *path)
{
char command[PATH_MAX];
@ -132,7 +129,6 @@ void ephoto_db_add_image(sqlite3 *db, const char *album, const char *name, const
"VALUES('%d', '%d');", image_id, album_id);
sqlite3_exec(db, command, 0, 0, 0);
/*This is to make sure the complete library has all images*/
snprintf(command, PATH_MAX,
"SELECT id FROM albums WHERE name = 'Complete Library';");
sqlite3_exec(db, command, get_album_id, 0, 0);
@ -144,8 +140,8 @@ void ephoto_db_add_image(sqlite3 *db, const char *album, const char *name, const
return;
}
/*Delete an image from a particular album*/
void ephoto_db_delete_image(sqlite3 *db, const char *album, const char *path)
void
ephoto_db_delete_image(sqlite3 *db, const char *album, const char *path)
{
char command[PATH_MAX];
@ -162,8 +158,8 @@ void ephoto_db_delete_image(sqlite3 *db, const char *album, const char *path)
return;
}
/*Populate a list the albums in the albums table*/
static int list_albums(void *notused, int argc, char **argv, char **col)
static int
list_albums(void *notused, int argc, char **argv, char **col)
{
int i;
@ -177,8 +173,8 @@ static int list_albums(void *notused, int argc, char **argv, char **col)
return 0;
}
/*Return a list of albums in the albums table*/
Ecore_List *ephoto_db_list_albums(sqlite3 *db)
Ecore_List *
ephoto_db_list_albums(sqlite3 *db)
{
if(!ecore_list_empty_is(albums))
{
@ -190,8 +186,8 @@ Ecore_List *ephoto_db_list_albums(sqlite3 *db)
return albums;
}
/*Populate a list of images belonging to a certain album*/
static int list_images(void *notused, int argc, char **argv, char **col)
static int
list_images(void *notused, int argc, char **argv, char **col)
{
int i;
@ -199,14 +195,15 @@ static int list_images(void *notused, int argc, char **argv, char **col)
for(i = 0; i < argc; i++)
{
ecore_dlist_append(images_list, strdup(argv[i] ? argv[i] : "NULL"));
ecore_dlist_append(images_list,
strdup(argv[i] ? argv[i] : "NULL"));
}
return 0;
}
/*Populate a list of the id's of images belonging to a certain album*/
static int list_image_ids(void *notused, int argc, char **argv, char **col)
static int
list_image_ids(void *notused, int argc, char **argv, char **col)
{
int i;
@ -214,14 +211,15 @@ static int list_image_ids(void *notused, int argc, char **argv, char **col)
for(i = 0; i < argc; i++)
{
ecore_list_append(image_ids, strdup(argv[i] ? argv[i] : "NULL"));
ecore_list_append(image_ids,
strdup(argv[i] ? argv[i] : "NULL"));
}
return 0;
}
/*Return a list of images belonging to a certain album*/
Ecore_List *ephoto_db_list_images(sqlite3 *db, const char *album)
Ecore_List *
ephoto_db_list_images(sqlite3 *db, const char *album)
{
char command[PATH_MAX];
char *id;
@ -256,8 +254,8 @@ Ecore_List *ephoto_db_list_images(sqlite3 *db, const char *album)
return images_list;
}
/*Close the sqlite3 database*/
void ephoto_db_close(sqlite3 *db)
void
ephoto_db_close(sqlite3 *db)
{
sqlite3_close(db);
return;

@ -1,11 +1,11 @@
#include "ephoto.h"
static void close_dialog(Ewl_Widget *w, void *event, void *data);
static void add_ok(Ewl_Widget *w, void *event, void *data);
Ewl_Widget *name_entry, *desc_entry;
static Ewl_Widget *save_quality, *save_entry;
/*Close or Cancel the Dialog*/
static void close_dialog(Ewl_Widget *w, void *event, void *data)
static void
close_dialog(Ewl_Widget *w, void *event, void *data)
{
Ewl_Widget *win;
@ -14,21 +14,30 @@ static void close_dialog(Ewl_Widget *w, void *event, void *data)
ewl_widget_destroy(win);
}
/*Add an About Dialog*/
void about_dialog(Ewl_Widget *w, void *event, void *data)
void
about_dialog(Ewl_Widget *w, void *event, void *data)
{
Ewl_Widget *window, *button, *image, *vbox, *text;
Ewl_Widget *window, *button, *image, *vbox, *sp, *text;
window = add_window("About Ephoto", 300, 400, NULL, NULL);
ewl_callback_append(window, EWL_CALLBACK_DELETE_WINDOW, close_dialog, window);
window = add_window("About Ephoto", 200, 300, NULL, NULL);
ewl_callback_append(window, EWL_CALLBACK_DELETE_WINDOW, close_dialog,
window);
vbox = add_box(window, EWL_ORIENTATION_VERTICAL, 3);
ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL);
image = add_image(vbox, PACKAGE_DATA_DIR "/images/photo_lens.png", 0, NULL, NULL);
image = add_image(vbox, PACKAGE_DATA_DIR "/images/photo_lens.png", 0,
NULL, NULL);
ewl_image_constrain_set(EWL_IMAGE(image), 144);
ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_CENTER);
ewl_object_fill_policy_set(EWL_OBJECT(image), EWL_FLAG_FILL_SHRINK);
sp = ewl_scrollpane_new();
ewl_object_fill_policy_set(EWL_OBJECT(sp), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(vbox), sp);
ewl_widget_show(sp);
text = add_text(vbox, "Ephoto is an advanced image viewer that allows\n"
text = add_text(sp, "Ephoto is an advanced image viewer that allows\n"
"you to view images using several methods. They\n"
"include an icon view, a list view, and a single\n"
"image view. You can also view exif data, view\n"
@ -37,91 +46,59 @@ void about_dialog(Ewl_Widget *w, void *event, void *data)
"editing options.");
ewl_text_wrap_set(EWL_TEXT(text), EWL_TEXT_WRAP_WORD);
ewl_object_alignment_set(EWL_OBJECT(text), EWL_FLAG_ALIGN_CENTER);
ewl_object_alignment_set(EWL_OBJECT(text), EWL_FLAG_ALIGN_CENTER);
button = add_button(vbox, "Close",
PACKAGE_DATA_DIR "/images/dialog-close.png",
close_dialog, window);
PACKAGE_DATA_DIR "/images/dialog-close.png",
close_dialog, window);
ewl_button_image_size_set(EWL_BUTTON(button), 25, 25);
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_CENTER);
return;
}
static void save_image(Ewl_Widget *w, void *event, void *data)
static void
add_ok(Ewl_Widget *w, void *event, void *data)
{
const char *file;
char flags[PATH_MAX];
char *ext;
file = ewl_text_text_get(EWL_TEXT(save_entry));
ext = strrchr(file, '.')+1;
if (!strncmp(ext, "png", 3))
{
snprintf(flags, PATH_MAX, "compress=%i",
(int)ewl_range_value_get(EWL_RANGE(save_quality)));
}
else
{
double svalue;
float jvalue;
svalue = ewl_range_value_get(EWL_RANGE(save_quality));
jvalue = (svalue / 9) * 100;
snprintf(flags, PATH_MAX, "quality=%.0f", jvalue);
}
if(!file) return;
if(VISIBLE(em->eimage))
Ewl_Widget *win = data;
char *name, *desc;
name = ewl_text_text_get(EWL_TEXT(name_entry));
desc = ewl_text_text_get(EWL_TEXT(desc_entry));
if (name)
{
evas_object_image_save(EWL_IMAGE(em->eimage)->image,
file, NULL, flags);
ephoto_db_add_album(em->db, name, desc);
populate_albums(NULL, NULL, NULL);
}
ewl_widget_destroy(EWL_WIDGET(data));
ewl_widget_destroy(win);
}
void save_dialog(const char *file)
void
add_album_dialog(Ewl_Widget *w, void *event, void *data)
{
Ewl_Widget *save_win, *vbox, *hbox, *button;
save_win = add_window("Save Image", 300, 100, NULL, NULL);
ewl_callback_append(save_win, EWL_CALLBACK_DELETE_WINDOW, close_dialog, save_win);
Ewl_Widget *window, *vbox, *hbox;
vbox = add_box(save_win, EWL_ORIENTATION_VERTICAL, 5);
ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL);
window = add_window("Add Album", 340, 160, NULL, NULL);
ewl_callback_append(window, EWL_CALLBACK_DELETE_WINDOW, close_dialog,
window);
add_label(vbox, "Save As:");
vbox = add_box(window, EWL_ORIENTATION_VERTICAL, 5);
ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL);
save_entry = add_entry(vbox, "default.jpg", NULL, NULL);
add_text(vbox, "Please provide a name for the new album:");
add_label(vbox, "Quality/Compression:");
name_entry = add_entry(vbox, "New Album", NULL, NULL);
save_quality = ewl_hseeker_new();
ewl_range_minimum_value_set(EWL_RANGE(save_quality), 1);
ewl_range_maximum_value_set(EWL_RANGE(save_quality), 9);
ewl_range_step_set(EWL_RANGE(save_quality), 1);
ewl_range_value_set(EWL_RANGE(save_quality), 7);
ewl_container_child_append(EWL_CONTAINER(vbox), save_quality);
ewl_widget_show(save_quality);
add_text(vbox, "Please provide a short description for this album:");
hbox = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 5);
ewl_object_alignment_set(EWL_OBJECT(hbox), EWL_FLAG_ALIGN_CENTER);
ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_SHRINK);
desc_entry = add_entry(vbox, "Album Description", NULL, NULL);
button = add_button(hbox, "Save",
PACKAGE_DATA_DIR "/images/stock_save.png",
save_image, save_win);
ewl_button_image_size_set(EWL_BUTTON(button), 25, 25);
hbox = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 5);
ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_SHRINK);
button = add_button(hbox, "Close",
PACKAGE_DATA_DIR "/images/dialog-close.png",
close_dialog, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 25, 25);
add_button(hbox, "Save", NULL, add_ok, window);
return;
add_button(hbox, "Cancel", NULL, close_dialog, window);
}

@ -1,440 +0,0 @@
#include "ephoto.h"
/*Ephoto Image Manipulation*/
static void add_standard_edit_tools(Ewl_Widget *c);
static void add_advanced_edit_tools(Ewl_Widget *c);
static void previous_image(Ewl_Widget *w, void *event, void *data);
static void next_image(Ewl_Widget *w, void *event, void *data);
static void zoom_in(Ewl_Widget *w, void *event, void *data);
static void zoom_out(Ewl_Widget *w, void *event, void *data);
static void flip_image_horizontal(Ewl_Widget *w, void *event, void *data);
static void flip_image_vertical(Ewl_Widget *w, void *event, void *data);
static void rotate_image_left(Ewl_Widget *w, void *event, void *data);
static void rotate_image_right(Ewl_Widget *w, void *event, void *data);
static void image_blur(Ewl_Widget *w, void *event, void *data);
static void image_sharpen(Ewl_Widget *w, void *event, void *data);
static void image_grayscale(Ewl_Widget *w, void *event, void *data);
static void image_sepia(Ewl_Widget *w, void *event, void *data);
static void close_channel(Ewl_Widget *w, void *event, void *data);
static void channel_mixer(Ewl_Widget *w, void *event, void *data);
/*Add the edit view*/
Ewl_Widget *add_edit_view(Ewl_Widget *c)
{
Ewl_Widget *button, *vbox, *ibox, *hbox, *bhbox, *nb;
Ewl_Widget *standard, *advanced;
em->edit_vbox = add_box(c, EWL_ORIENTATION_VERTICAL, 2);
ewl_object_fill_policy_set(EWL_OBJECT(em->edit_vbox), EWL_FLAG_FILL_ALL);
hbox = add_box(em->edit_vbox, EWL_ORIENTATION_HORIZONTAL, 2);
ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_ALL);
nb = ewl_notebook_new();
ewl_object_fill_policy_set(EWL_OBJECT(nb), EWL_FLAG_FILL_VFILL | EWL_FLAG_FILL_HSHRINK);
ewl_container_child_append(EWL_CONTAINER(hbox), nb);
ewl_widget_show(nb);
standard = add_box(nb, EWL_ORIENTATION_VERTICAL, 2);
ewl_object_maximum_w_set(EWL_OBJECT(standard), 172);
ewl_object_minimum_w_set(EWL_OBJECT(standard), 172);
ewl_object_fill_policy_set(EWL_OBJECT(standard), EWL_FLAG_FILL_VFILL);
ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(nb), standard, _("Standard Tools"));
add_standard_edit_tools(standard);
advanced = add_box(nb, EWL_ORIENTATION_VERTICAL, 2);
ewl_object_maximum_w_set(EWL_OBJECT(advanced), 172);
ewl_object_minimum_w_set(EWL_OBJECT(advanced), 172);
ewl_object_fill_policy_set(EWL_OBJECT(advanced), EWL_FLAG_FILL_VFILL);
ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(nb), advanced, _("Advanced Tools"));
add_advanced_edit_tools(advanced);
vbox = add_box(hbox, EWL_ORIENTATION_VERTICAL, 0);
ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL);
ibox = ewl_cell_new();
ewl_object_fill_policy_set(EWL_OBJECT(ibox), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(vbox), ibox);