diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 08005eb..36a35c2 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -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 diff --git a/src/bin/ephoto.c b/src/bin/ephoto.c index 6aca9ff..3b6dfa4 100644 --- a/src/bin/ephoto.c +++ b/src/bin/ephoto.c @@ -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; } + diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h index d576a95..03612e0 100644 --- a/src/bin/ephoto.h +++ b/src/bin/ephoto.h @@ -1,20 +1,28 @@ #ifndef _EPHOTO_H_ #define _EPHOTO_H_ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + #include "config.h" #include #include #include #include +#include #include #include #include #include #include +#include +#include #include #include #include #include +#include #include #include #include @@ -24,7 +32,6 @@ #include #endif -/* NLS */ #ifdef ENABLE_NLS #include #include @@ -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 diff --git a/src/bin/ephoto_albums.c b/src/bin/ephoto_albums.c new file mode 100755 index 0000000..81f1e7f --- /dev/null +++ b/src/bin/ephoto_albums.c @@ -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); +} + diff --git a/src/bin/ephoto_browser.c b/src/bin/ephoto_browser.c deleted file mode 100644 index 4aa0167..0000000 --- a/src/bin/ephoto_browser.c +++ /dev/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; -} diff --git a/src/bin/ephoto_browsing.c b/src/bin/ephoto_browsing.c deleted file mode 100644 index f3f0390..0000000 --- a/src/bin/ephoto_browsing.c +++ /dev/null @@ -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; -} diff --git a/src/bin/ephoto_database.c b/src/bin/ephoto_database.c index d114500..34071f9 100644 --- a/src/bin/ephoto_database.c +++ b/src/bin/ephoto_database.c @@ -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; diff --git a/src/bin/ephoto_dialogs.c b/src/bin/ephoto_dialogs.c index 7bd1f23..fe69c13 100644 --- a/src/bin/ephoto_dialogs.c +++ b/src/bin/ephoto_dialogs.c @@ -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); } - diff --git a/src/bin/ephoto_edit_view.c b/src/bin/ephoto_edit_view.c deleted file mode 100644 index 699e690..0000000 --- a/src/bin/ephoto_edit_view.c +++ /dev/null @@ -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); - ewl_widget_show(ibox); - - em->eimage = add_image(ibox, NULL, 0, NULL, NULL); - ewl_object_alignment_set(EWL_OBJECT(em->eimage), EWL_FLAG_ALIGN_CENTER); - ewl_object_fill_policy_set(EWL_OBJECT(em->eimage), EWL_FLAG_FILL_SHRINK); - - bhbox = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 2); - ewl_object_alignment_set(EWL_OBJECT(bhbox), EWL_FLAG_ALIGN_CENTER); - ewl_object_fill_policy_set(EWL_OBJECT(bhbox), EWL_FLAG_FILL_SHRINK); - - button = add_button(bhbox, NULL, PACKAGE_DATA_DIR "/images/media-seek-backward.png", previous_image, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 25, 25); - ewl_attach_tooltip_text_set(button, _("Previous Image")); - - button = add_button(bhbox, NULL, PACKAGE_DATA_DIR "/images/media-seek-forward.png", next_image, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 25, 25); - ewl_attach_tooltip_text_set(button, _("Next Image")); - - return hbox; -} - -/*Show the edit view*/ -void show_edit_view(Ewl_Widget *w, void *event, void *data) -{ - ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->view_box), em->edit_vbox); - ewl_image_file_path_set(EWL_IMAGE(em->eimage), ecore_dlist_current(em->images)); - - return; -} - -/*Add edit tools to container c*/ -static void add_standard_edit_tools(Ewl_Widget *c) -{ - Ewl_Widget *button; - - button = add_button(c, "Zoom In", PACKAGE_DATA_DIR "/images/search.png", zoom_in, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 20, 20); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); - - button = add_button(c, "Zoom Out", PACKAGE_DATA_DIR "/images/search.png", zoom_out, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 20, 20); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); - - button = add_button(c, "Rotate Left", PACKAGE_DATA_DIR "/images/undo.png", rotate_image_left, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 20, 20); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); - - button = add_button(c, "Rotate Right", PACKAGE_DATA_DIR "/images/redo.png", rotate_image_right, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 20, 20); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); - - button = add_button(c, "Flip Horizontally", PACKAGE_DATA_DIR "/images/go-next.png", flip_image_horizontal, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 20, 20); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); - - button = add_button(c, "Flip Vertically", PACKAGE_DATA_DIR "/images/go-down.png", flip_image_vertical, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 20, 20); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); - - return; -} - -/* Add advanced edit tools */ -static void add_advanced_edit_tools(Ewl_Widget *c) -{ - Ewl_Widget *button; - - button = add_button(c, "Blur Image", NULL, image_blur, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 20, 20); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); - - button = add_button(c, "Sharpen Image", NULL, image_sharpen, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 20, 20); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); - - button = add_button(c, "Black and White", NULL, image_grayscale, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 20, 20); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); - - button = add_button(c, "Sepia", NULL, image_sepia, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 20, 20); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); - - button = add_button(c, "Channel Editor", NULL, channel_mixer, NULL); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); - - return; -} - -/*Go to the previous image*/ -static void previous_image(Ewl_Widget *w, void *event, void *data) -{ - char *image; - - ecore_dlist_previous(em->images); - image = ecore_dlist_current(em->images); - if(!image) - { - ecore_dlist_last_goto(em->images); - image = ecore_dlist_current(em->images); - } - ewl_image_file_path_set(EWL_IMAGE(em->eimage), image); - ewl_widget_configure(em->eimage->parent); - - return; -} - -/*Go to the next image*/ -static void next_image(Ewl_Widget *w, void *event, void *data) -{ - char *image; - - ecore_dlist_next(em->images); - image = ecore_dlist_current(em->images); - if(!image) - { - ecore_dlist_first_goto(em->images); - image = ecore_dlist_current(em->images); - } - ewl_image_file_path_set(EWL_IMAGE(em->eimage), image); - ewl_widget_configure(em->eimage->parent); - - return; -} - -/*Zoom in on the image*/ -static void zoom_in(Ewl_Widget *w, void *event, void *data) -{ - int ow, oh; - - ewl_object_current_size_get(EWL_OBJECT(em->eimage), &ow, &oh); - - ewl_image_size_set(EWL_IMAGE(em->eimage), ow*1.5, oh*1.5); - ewl_widget_configure(em->eimage->parent); - - return; -} - -/*Zoom out the image*/ -static void zoom_out(Ewl_Widget *w, void *event, void *data) -{ - int ow, oh; - - ewl_object_current_size_get(EWL_OBJECT(em->eimage), &ow, &oh); - - ewl_image_size_set(EWL_IMAGE(em->eimage), ow/1.5, oh/1.5); - ewl_widget_configure(em->eimage->parent); - - return; -} - - -/*Flip the image 180 degrees horizontally*/ -static void flip_image_horizontal(Ewl_Widget *w, void *event, void *data) -{ - - unsigned int *image_data; - int nw, nh; - Ewl_Image *image; - - evas_object_image_size_get(EWL_IMAGE(em->eimage)->image, &nw, &nh); - image_data = flip_horizontal(em->eimage); - update_image(em->eimage, nw, nh, image_data); - ewl_image_size_set(EWL_IMAGE(em->eimage), nh, nw); - image = (Ewl_Image *)em->eimage; - image->ow = nw; - image->oh = nh; - ewl_object_preferred_inner_size_set(EWL_OBJECT(em->eimage), nw, nh); - ewl_widget_configure(em->eimage->parent); - - return; -} - -/*Flip the image 180 degrees vertically*/ -static void flip_image_vertical(Ewl_Widget *w, void *event, void *data) -{ - unsigned int *image_data; - int nw, nh; - Ewl_Image *image; - - evas_object_image_size_get(EWL_IMAGE(em->eimage)->image, &nw, &nh); - image_data = flip_vertical(em->eimage); - update_image(em->eimage, nw, nh, image_data); - ewl_image_size_set(EWL_IMAGE(em->eimage), nh, nw); - image = (Ewl_Image *)em->eimage; - image->ow = nw; - image->oh = nh; - ewl_object_preferred_inner_size_set(EWL_OBJECT(em->eimage), nh, nw); - ewl_widget_configure(em->eimage->parent); - - return; -} - -/*Rotate the image 90 degrees to the left*/ -static void rotate_image_left(Ewl_Widget *w, void *event, void *data) -{ - unsigned int *image_data; - int nw, nh; - Ewl_Image *image; - - evas_object_image_size_get(EWL_IMAGE(em->eimage)->image, &nh, &nw); - image_data = rotate_left(em->eimage); - update_image(em->eimage, nw, nh, image_data); - ewl_image_size_set(EWL_IMAGE(em->eimage), nh, nw); - image = (Ewl_Image *)em->eimage; - image->ow = nw; - image->oh = nh; - ewl_object_preferred_inner_size_set(EWL_OBJECT(em->eimage), nw, nh); - ewl_widget_configure(em->eimage->parent); - - return; -} - -/*Rotate the image 90 degrees to the right*/ -static void rotate_image_right(Ewl_Widget *w, void *event, void *data) -{ - unsigned int *image_data; - int nw, nh; - Ewl_Image *image; - - evas_object_image_size_get(EWL_IMAGE(em->eimage)->image, &nh, &nw); - image_data = rotate_right(em->eimage); - update_image(em->eimage, nw, nh, image_data); - image = (Ewl_Image *)em->eimage; - image->ow = nw; - image->oh = nh; - ewl_object_preferred_inner_size_set(EWL_OBJECT(em->eimage), nw, nh); - ewl_widget_configure(em->eimage->parent); - - return; -} - -/* Blur the image*/ -static void image_blur(Ewl_Widget *w, void *event, void *data) -{ - unsigned int *image_data; - int nw, nh; - - evas_object_image_size_get(EWL_IMAGE(em->eimage)->image, &nw, &nh); - image_data = blur_image(em->eimage); - update_image(em->eimage, nw, nh, image_data); - ewl_widget_configure(em->eimage->parent); - - return; -} - -/* Sharpen the image*/ -static void image_sharpen(Ewl_Widget *w, void *event, void *data) -{ - unsigned int *image_data; - int nw, nh; - - evas_object_image_size_get(EWL_IMAGE(em->eimage)->image, &nw, &nh); - image_data = sharpen_image(em->eimage); - update_image(em->eimage, nw, nh, image_data); - ewl_widget_configure(em->eimage->parent); - - return; -} - -/*Convert image to Black and White*/ -static void image_grayscale(Ewl_Widget *w, void *event, void *data) -{ - unsigned int *image_data; - int nw, nh; - - evas_object_image_size_get(EWL_IMAGE(em->eimage)->image, &nw, &nh); - image_data = grayscale_image(em->eimage); - update_image(em->eimage, nw, nh, image_data); - ewl_widget_configure(em->eimage->parent); - - return; -} - -/*Convert image to Sepia*/ -static void image_sepia(Ewl_Widget *w, void *event, void *data) -{ - unsigned int *image_data; - int nw, nh; - - evas_object_image_size_get(EWL_IMAGE(em->eimage)->image, &nw, &nh); - image_data = sepia_image(em->eimage); - update_image(em->eimage, nw, nh, image_data); - ewl_widget_configure(em->eimage->parent); - - return; -} - -/*Close the Channel Mixer*/ -static void close_channel(Ewl_Widget *w, void *event, void *data) -{ -/* Ewl_Widget *win; - - win = data; - - ewl_widget_destroy(win);*/ -} - -/*Add a Channel Mixer*/ -static void channel_mixer(Ewl_Widget *w, void *event, void *data) -{ - close_channel(NULL, NULL, NULL); -/* Ewl_Widget *window, *vbox, *seek; - - window = add_window("Channel Editor", 400, 400, NULL, NULL); - ewl_callback_append(window, EWL_CALLBACK_DELETE_WINDOW, close_channel, window); - - vbox = add_box(window, EWL_ORIENTATION_VERTICAL, 1); - - add_label(vbox, "Hue"); - - seek = ewl_hseeker_new(); - ewl_range_minimum_value_set(EWL_RANGE(seek), -100); - ewl_range_maximum_value_set(EWL_RANGE(seek), 100); - ewl_range_step_set(EWL_RANGE(seek), 10); - ewl_range_value_set(EWL_RANGE(seek), 0); - ewl_container_child_append(EWL_CONTAINER(vbox), seek); - ewl_widget_show(seek); - - add_label(vbox, "Saturation"); - - seek = ewl_hseeker_new(); - ewl_range_minimum_value_set(EWL_RANGE(seek), -100); - ewl_range_maximum_value_set(EWL_RANGE(seek), 100); - ewl_range_step_set(EWL_RANGE(seek), 10); - ewl_range_value_set(EWL_RANGE(seek), 0); - ewl_container_child_append(EWL_CONTAINER(vbox), seek); - ewl_widget_show(seek); - - add_label(vbox, "Value"); - - seek = ewl_hseeker_new(); - ewl_range_minimum_value_set(EWL_RANGE(seek), -100); - ewl_range_maximum_value_set(EWL_RANGE(seek), 100); - ewl_range_step_set(EWL_RANGE(seek), 10); - ewl_range_value_set(EWL_RANGE(seek), 0); - ewl_container_child_append(EWL_CONTAINER(vbox), seek); - ewl_widget_show(seek); - - add_label(vbox, "Light"); - - seek = ewl_hseeker_new(); - ewl_range_minimum_value_set(EWL_RANGE(seek), -100); - ewl_range_maximum_value_set(EWL_RANGE(seek), 100); - ewl_range_step_set(EWL_RANGE(seek), 10); - ewl_range_value_set(EWL_RANGE(seek), 0); - ewl_container_child_append(EWL_CONTAINER(vbox), seek); - ewl_widget_show(seek); - - add_label(vbox, "Brightness"); - - seek = ewl_hseeker_new(); - ewl_range_minimum_value_set(EWL_RANGE(seek), -100); - ewl_range_maximum_value_set(EWL_RANGE(seek), 100); - ewl_range_step_set(EWL_RANGE(seek), 10); - ewl_range_value_set(EWL_RANGE(seek), 0); - ewl_container_child_append(EWL_CONTAINER(vbox), seek); - ewl_widget_show(seek); - - add_label(vbox, "Contrast"); - - seek = ewl_hseeker_new(); - ewl_range_minimum_value_set(EWL_RANGE(seek), -100); - ewl_range_maximum_value_set(EWL_RANGE(seek), 100); - ewl_range_step_set(EWL_RANGE(seek), 10); - ewl_range_value_set(EWL_RANGE(seek), 0); - ewl_container_child_append(EWL_CONTAINER(vbox), seek); - ewl_widget_show(seek);*/ -} - diff --git a/src/bin/ephoto_exif.c b/src/bin/ephoto_exif.c index af27f46..c81f3ed 100644 --- a/src/bin/ephoto_exif.c +++ b/src/bin/ephoto_exif.c @@ -2,11 +2,10 @@ #ifdef BUILD_EXIF_SUPPORT 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); +static void list_is_destroyed(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(const char *file) +Ecore_Hash * +get_exif_data(const char *file) { const char **args, *title; char value[1024]; @@ -43,7 +42,8 @@ Ecore_Hash *get_exif_data(const char *file) if (entry) { exif_entry_ref(entry); - exif_entry_get_value(entry, value, sizeof(value)); + exif_entry_get_value(entry, value, + sizeof(value)); ecore_hash_set(exif_info, strdup(title), strdup(value)); exif_entry_unref(entry); @@ -55,8 +55,8 @@ Ecore_Hash *get_exif_data(const char *file) return exif_info; } -/*Get the current image*/ -static const char *get_image(void) +static const char * +get_image(void) { const char *img = NULL; @@ -65,31 +65,23 @@ static const char *get_image(void) return strdup(img); } -/*Close a dialog*/ -static void close_dialog(Ewl_Widget *w, void *event, void *data) +static void +list_is_destroyed(Ewl_Widget *w, void *event, void *data) { Ecore_List *destroy; - Ewl_Widget *win; - win = data; - destroy = ewl_widget_data_get(win, "list"); + destroy = ewl_widget_data_get(w, "list"); ecore_list_destroy(destroy); - ewl_widget_destroy(win); - - return; } -/*Add all the exif information to the container w*/ -static void add_exif_to_container(Ewl_Widget *w, void *event, void *data) +void +display_exif(Ewl_Widget *w, void *event, void *data) { const char *img; char *key, *value; char text[PATH_MAX]; Ecore_Hash *exif_info; Ecore_List *keys, *values; - Ewl_Widget *win; - - win = data; values = ecore_list_new(); ecore_list_free_cb_set(values, free); @@ -115,17 +107,18 @@ static void add_exif_to_container(Ewl_Widget *w, void *event, void *data) } } ewl_mvc_data_set(EWL_MVC(w), values); - ewl_widget_data_set(win, "list", values); + ewl_callback_append(w, EWL_CALLBACK_DESTROY, list_is_destroyed, NULL); + ewl_widget_data_set(w, "list", values); ecore_hash_destroy(exif_info); return; } -/*Display a dialog which will display exif data*/ -void display_exif_dialog(Ewl_Widget *w, void *event, void *data) +void +add_exif_to_container(Ewl_Widget *c) { const char *img; - Ewl_Widget *win, *vbox, *image, *sp, *list, *text; + Ewl_Widget *sp, *list; Ewl_Model *model; Ewl_View *view; @@ -135,25 +128,9 @@ void display_exif_dialog(Ewl_Widget *w, void *event, void *data) return; } - win = add_window("Ephoto Exif Info", 310, 460, NULL, NULL); - ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, close_dialog, win); - ewl_window_dialog_set(EWL_WINDOW(win), 1); - - vbox = add_box(win, EWL_ORIENTATION_VERTICAL, 5); - ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL); - - text = add_text(vbox, "Preview"); - - image = add_image(vbox, img, 1, NULL, NULL); - ewl_image_constrain_set(EWL_IMAGE(image), 120); - ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_CENTER); - ewl_object_fill_policy_set(EWL_OBJECT(image), EWL_FLAG_FILL_SHRINK); - - text = add_text(vbox, "Image Information"); - 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_container_child_append(EWL_CONTAINER(c), sp); ewl_widget_show(sp); model = ewl_model_ecore_list_get(); @@ -164,10 +141,8 @@ void display_exif_dialog(Ewl_Widget *w, void *event, void *data) ewl_mvc_view_set(EWL_MVC(list), view); ewl_object_fill_policy_set(EWL_OBJECT(list), EWL_FLAG_FILL_ALL); ewl_container_child_append(EWL_CONTAINER(sp), list); - ewl_callback_append(list, EWL_CALLBACK_SHOW, add_exif_to_container, win); + ewl_callback_append(list, EWL_CALLBACK_SHOW, display_exif, NULL); ewl_widget_show(list); - - add_button(vbox, "Close", PACKAGE_DATA_DIR "/images/dialog-close.png", close_dialog, win); return; } diff --git a/src/bin/ephoto_gui.c b/src/bin/ephoto_gui.c index 610c04a..d0e1724 100644 --- a/src/bin/ephoto_gui.c +++ b/src/bin/ephoto_gui.c @@ -1,12 +1,12 @@ #include "ephoto.h" -/*Create and Add a box to container c, with orientation and spacing*/ -Ewl_Widget *add_box(Ewl_Widget *c, Ewl_Orientation orientation, int spacing) +Ewl_Widget * +add_box(Ewl_Widget *c, Ewl_Orientation o, int spacing) { Ewl_Widget *box; box = ewl_box_new(); - if(orientation) ewl_box_orientation_set(EWL_BOX(box), orientation); + if(o) ewl_box_orientation_set(EWL_BOX(box), o); if(spacing) ewl_box_spacing_set(EWL_BOX(box), spacing); if(c) ewl_container_child_append(EWL_CONTAINER(c), box); ewl_widget_show(box); @@ -14,8 +14,8 @@ Ewl_Widget *add_box(Ewl_Widget *c, Ewl_Orientation orientation, int spacing) return box; } -/*Create and Add a Button to the Container c*/ -Ewl_Widget *add_button(Ewl_Widget *c, char *lbl, const char *img, void *cb, void *data) +Ewl_Widget * +add_button(Ewl_Widget *c, char *lbl, const char *img, void *cb, void *data) { Ewl_Widget *button; @@ -31,8 +31,8 @@ Ewl_Widget *add_button(Ewl_Widget *c, char *lbl, const char *img, void *cb, void return button; } -/*Create and Add an Entry to Container c With Text txt and the Callback cb*/ -Ewl_Widget *add_entry(Ewl_Widget *c, char *txt, void *cb, void *data) +Ewl_Widget * +add_entry(Ewl_Widget *c, char *txt, void *cb, void *data) { Ewl_Widget *entry; @@ -45,13 +45,13 @@ Ewl_Widget *add_entry(Ewl_Widget *c, char *txt, void *cb, void *data) return entry; } -/*Create and add an icon to the container c*/ -Ewl_Widget *add_icon(Ewl_Widget *c, char *lbl, const char *img, int thumbnail, void *cb, void *data) +Ewl_Widget * +add_icon(Ewl_Widget *c, char *lbl, const char *img, int thumb, void *cb, void *data) { Ewl_Widget *icon; icon = ewl_icon_new(); - if(!thumbnail) ewl_icon_thumbnailing_set(EWL_ICON(icon), FALSE); + if(!thumb) ewl_icon_thumbnailing_set(EWL_ICON(icon), FALSE); if (lbl) ewl_icon_label_set(EWL_ICON(icon), _(lbl)); if (img) ewl_icon_image_set(EWL_ICON(icon), img, NULL); if (c) ewl_container_child_append(EWL_CONTAINER(c), icon); @@ -61,13 +61,13 @@ Ewl_Widget *add_icon(Ewl_Widget *c, char *lbl, const char *img, int thumbnail, v return icon; } -/*Create and Add an Image to the Container c*/ -Ewl_Widget *add_image(Ewl_Widget *c, const char *img, int thumbnail, void *cb, void *data) +Ewl_Widget * +add_image(Ewl_Widget *c, const char *img, int thumb, void *cb, void *data) { Ewl_Widget *image; int w, h; - if(!thumbnail) + if(!thumb) { image = ewl_image_new(); if(img) ewl_image_file_path_set(EWL_IMAGE(image), img); @@ -90,102 +90,101 @@ Ewl_Widget *add_image(Ewl_Widget *c, const char *img, int thumbnail, void *cb, v ewl_image_constrain_set(EWL_IMAGE(image), 48); } ewl_image_proportional_set(EWL_IMAGE(image), TRUE); - ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_LEFT); + ewl_object_alignment_set(EWL_OBJECT(image), + EWL_FLAG_ALIGN_LEFT); if(c) ewl_container_child_append(EWL_CONTAINER(c), image); - if(cb) ewl_callback_append(image, EWL_CALLBACK_CLICKED, cb, data); + if(cb) ewl_callback_append(image, EWL_CALLBACK_CLICKED, cb, + data); ewl_widget_show(image); return image; } -/*Create and Add a Label to the Container c, With the Text lbl*/ -Ewl_Widget *add_label(Ewl_Widget *c, char *lbl) +Ewl_Widget * +add_label(Ewl_Widget *c, char *lbl) { Ewl_Widget *label; label = ewl_label_new(); if(lbl) ewl_label_text_set(EWL_LABEL(label), _(lbl)); - ewl_object_alignment_set(EWL_OBJECT(label), EWL_FLAG_ALIGN_CENTER); - ewl_object_fill_policy_set(EWL_OBJECT(label), EWL_FLAG_FILL_SHRINK); + ewl_object_alignment_set(EWL_OBJECT(label), + EWL_FLAG_ALIGN_CENTER); + ewl_object_fill_policy_set(EWL_OBJECT(label), + EWL_FLAG_FILL_SHRINK); if(c) ewl_container_child_append(EWL_CONTAINER(c), label); ewl_widget_show(label); return label; } -/*Create and Add a Menubar to the Container c*/ -Ewl_Widget *add_menubar(Ewl_Widget *c) +Ewl_Widget * +add_menubar(Ewl_Widget *c) { Ewl_Widget *mb; mb = ewl_hmenubar_new(); - ewl_object_fill_policy_set(EWL_OBJECT(mb), EWL_FLAG_FILL_HFILL); + ewl_object_fill_policy_set(EWL_OBJECT(mb), + EWL_FLAG_FILL_HFILL); if(c) ewl_container_child_append(EWL_CONTAINER(c), mb); ewl_widget_show(mb); return mb; } -/*Create and Add a Menu to the Container c*/ -Ewl_Widget *add_menu(Ewl_Widget *c, char *lbl) +Ewl_Widget * +add_menu(Ewl_Widget *c, char *lbl) { Ewl_Widget *menu; menu = ewl_menu_new(); if(lbl) ewl_button_label_set(EWL_BUTTON(menu), _(lbl)); - ewl_object_fill_policy_set(EWL_OBJECT(menu), EWL_FLAG_FILL_NONE); + ewl_object_fill_policy_set(EWL_OBJECT(menu), + EWL_FLAG_FILL_NONE); if(c) ewl_container_child_append(EWL_CONTAINER(c), menu); ewl_widget_show(menu); return menu; } -/*Create and Add a Menu Item to the Container c*/ -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 *mi; mi = ewl_menu_item_new(); if(img) ewl_button_image_set(EWL_BUTTON(mi), img, NULL); if(lbl) ewl_button_label_set(EWL_BUTTON(mi), _(lbl)); - ewl_object_alignment_set(EWL_OBJECT(mi), EWL_FLAG_ALIGN_CENTER); - ewl_object_fill_policy_set(EWL_OBJECT(mi), EWL_FLAG_FILL_ALL); + ewl_object_alignment_set(EWL_OBJECT(mi), + EWL_FLAG_ALIGN_CENTER); + ewl_object_fill_policy_set(EWL_OBJECT(mi), + EWL_FLAG_FILL_ALL); if(c) ewl_container_child_append(EWL_CONTAINER(c), mi); - if(cb) ewl_callback_append(mi, EWL_CALLBACK_CLICKED, cb, data); + if(cb) ewl_callback_append(mi, EWL_CALLBACK_CLICKED, cb, + data); ewl_widget_show(mi); return mi; } -/*Create and Add a Shadow to the Container c*/ -Ewl_Widget *add_shadow(Ewl_Widget *c) -{ - Ewl_Widget *shadow; - - shadow = ewl_shadow_new(); - if(c) ewl_container_child_append(EWL_CONTAINER(c), shadow); - ewl_widget_show(shadow); - - return shadow; -} - -/*Create and Add a Text Widget to the Container c*/ -Ewl_Widget *add_text(Ewl_Widget *c, char *txt) +Ewl_Widget * +add_text(Ewl_Widget *c, char *txt) { Ewl_Widget *text; text = ewl_text_new(); if(txt) ewl_text_text_set(EWL_TEXT(text), _(txt)); - ewl_object_alignment_set(EWL_OBJECT(text), EWL_FLAG_ALIGN_CENTER); - ewl_object_fill_policy_set(EWL_OBJECT(text), EWL_FLAG_FILL_SHRINK); + ewl_object_alignment_set(EWL_OBJECT(text), + EWL_FLAG_ALIGN_CENTER); + ewl_object_fill_policy_set(EWL_OBJECT(text), + EWL_FLAG_FILL_SHRINK); if(c) ewl_container_child_append(EWL_CONTAINER(c), text); ewl_widget_show(text); return text; } -/*Create and Add a Window*/ -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) { Ewl_Widget *win; @@ -195,9 +194,9 @@ Ewl_Widget *add_window(char *name, int width, int height, void *cb, void *data) ewl_window_title_set(EWL_WINDOW(win), _(name)); ewl_window_name_set(EWL_WINDOW(win), _(name)); } - if(width && height) ewl_object_size_request(EWL_OBJECT(win), width, - height); - if(cb) ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, cb, data); + if(w && h) ewl_object_size_request(EWL_OBJECT(win), w, h); + if(cb) ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, + cb, data); ewl_widget_show(win); return win; diff --git a/src/bin/ephoto_imaging.c b/src/bin/ephoto_imaging.c index 17da357..163b624 100644 --- a/src/bin/ephoto_imaging.c +++ b/src/bin/ephoto_imaging.c @@ -1,6 +1,7 @@ #include "ephoto.h" -unsigned int *flip_horizontal(Ewl_Widget *image) +unsigned int * +flip_horizontal(Ewl_Widget *image) { unsigned int *im_data, *im_data_new; int index, ind, i, j, ni, nj, ew, eh; @@ -29,7 +30,8 @@ unsigned int *flip_horizontal(Ewl_Widget *image) return im_data_new; } -unsigned int *flip_vertical(Ewl_Widget *image) +unsigned int * +flip_vertical(Ewl_Widget *image) { unsigned int *im_data, *im_data_new; int index, ind, i, j, ni, nj, ew, eh; @@ -58,7 +60,8 @@ unsigned int *flip_vertical(Ewl_Widget *image) return im_data_new; } -unsigned int *rotate_left(Ewl_Widget *image) +unsigned int * +rotate_left(Ewl_Widget *image) { unsigned int *im_data, *im_data_new; int index, ind, i, j, ni, nj, ew, eh, nw, nh; @@ -90,7 +93,8 @@ unsigned int *rotate_left(Ewl_Widget *image) return im_data_new; } -unsigned int *rotate_right(Ewl_Widget *image) +unsigned int * +rotate_right(Ewl_Widget *image) { unsigned int *im_data, *im_data_new; int index, ind, i, j, ni, nj, ew, eh, nw, nh; @@ -122,7 +126,8 @@ unsigned int *rotate_right(Ewl_Widget *image) return im_data_new; } -unsigned int *blur_image(Ewl_Widget *image) +unsigned int * +blur_image(Ewl_Widget *image) { unsigned int *im_data, *im_data_new, *p1, *p2; int rad = 2; @@ -214,7 +219,8 @@ unsigned int *blur_image(Ewl_Widget *image) return im_data_new; } -unsigned int *sharpen_image(Ewl_Widget *image) +unsigned int * +sharpen_image(Ewl_Widget *image) { unsigned int *im_data, *im_data_new, *p1, *p2; int a, r, g, b, x, y, w, h; @@ -273,7 +279,8 @@ unsigned int *sharpen_image(Ewl_Widget *image) return im_data_new; } -unsigned int *grayscale_image(Ewl_Widget *image) +unsigned int * +grayscale_image(Ewl_Widget *image) { unsigned int *im_data, *im_data_new; int gray, i, r, g, b, a, ew, eh; @@ -306,7 +313,8 @@ unsigned int *grayscale_image(Ewl_Widget *image) return im_data_new; } -unsigned int *sepia_image(Ewl_Widget *image) +unsigned int * +sepia_image(Ewl_Widget *image) { unsigned int *im_data, *im_data_new; int i, r, rr, g, gg, b, bb, a, ew, eh; @@ -352,19 +360,22 @@ unsigned int *sepia_image(Ewl_Widget *image) return im_data_new; } -void update_image(Ewl_Widget *image, int w, int h, unsigned int *data) +void +update_image(Ewl_Widget *image, int w, int h, unsigned int *data) { - if (w && h && !data) - { - ewl_image_size_set(EWL_IMAGE(image), w, h); - ewl_widget_configure(image); - } - if (w && h && data) + if (!w || !h) + return; + if (data) { evas_object_image_size_set(EWL_IMAGE(image)->image, w, h); evas_object_image_data_set(EWL_IMAGE(image)->image, data); evas_object_image_data_update_add(EWL_IMAGE(image)->image, 0, 0, - w, h); + w, h); } + else + { + ewl_image_size_set(EWL_IMAGE(image), w, h); + ewl_widget_configure(image); + } } diff --git a/src/bin/ephoto_import.c b/src/bin/ephoto_import.c new file mode 100755 index 0000000..fbc6802 --- /dev/null +++ b/src/bin/ephoto_import.c @@ -0,0 +1,98 @@ +#include "ephoto.h" + +static void close_dialog(Ewl_Widget *w, void *event, void *data); +static void import(Ewl_Widget *w, void *event, void *data); +Ewl_Widget *name_entry, *desc_entry; + +static void +close_dialog(Ewl_Widget *w, void *event, void *data) +{ + Ewl_Widget *win; + + win = data; + + ewl_widget_destroy(win); +} + +static void +import(Ewl_Widget *w, void *event, void *data) +{ + char *name, *desc, *image; + Ecore_List *selected_images; + Ewl_Event_Action_Response *e; + Ewl_Widget *win; + + win = data; + + e = event; + + if (e->response == EWL_STOCK_CANCEL) + { + ewl_widget_destroy(win); + return; + } + + selected_images = ewl_filepicker_selected_files_get(EWL_FILEPICKER(w)); + if (ecore_list_empty_is(selected_images)) + return; + + name = ewl_text_text_get(EWL_TEXT(name_entry)); + desc = ewl_text_text_get(EWL_TEXT(desc_entry)); + + if (!name) + return; + else + ephoto_db_add_album(em->db, name, desc); + + while (!ecore_list_empty_is(selected_images)) + { + image = ecore_list_first_remove(selected_images); + ephoto_db_add_image(em->db, name, basename(image), image); + } + + ewl_widget_destroy(win); + populate_albums(NULL, NULL, NULL); + + return; +} + +void +ephoto_import_dialog(Ewl_Widget *w, void *event, void *data) +{ + Ecore_List *filters; + Ewl_Widget *fpick, *vbox, *window; + + filters = ecore_list_new(); + + ecore_list_append(filters, "image/gif"); + ecore_list_append(filters, "image/jpeg"); + ecore_list_append(filters, "image/png"); + ecore_list_append(filters, "image/svg+xml"); + ecore_list_append(filters, "image/tiff"); + + window = add_window("Import Photos", 400, 400, NULL, NULL); + ewl_callback_append(window, EWL_CALLBACK_DELETE_WINDOW, close_dialog, + window); + + vbox = add_box(window, EWL_ORIENTATION_VERTICAL, 10); + ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL); + + add_text(vbox, "Please provide a name for the new album:"); + + name_entry = add_entry(vbox, "New Album", NULL, NULL); + + add_text(vbox, "Please provide a short description for this album:"); + + desc_entry = add_entry(vbox, "Album Description", NULL, NULL); + + fpick = ewl_filepicker_new(); + ewl_filepicker_directory_set(EWL_FILEPICKER(fpick), em->current_directory); + ewl_filepicker_multiselect_set(EWL_FILEPICKER(fpick), TRUE); + ewl_filepicker_filter_add(EWL_FILEPICKER(fpick), "Images", ".gif, .jpg, .png", filters); + ewl_container_child_append(EWL_CONTAINER(vbox), fpick); + ewl_callback_append(fpick, EWL_CALLBACK_VALUE_CHANGED, import, window); + ewl_widget_show(fpick); + + return; +} + diff --git a/src/bin/ephoto_list_view.c b/src/bin/ephoto_list_view.c deleted file mode 100644 index 46cd447..0000000 --- a/src/bin/ephoto_list_view.c +++ /dev/null @@ -1,152 +0,0 @@ -#include "ephoto.h" - -static Ewl_Widget *list_view_new(void *data, unsigned int row, unsigned int column); -static Ewl_Widget *list_header_fetch(void *data, unsigned int column); -static void iterate(char *point2); -static void *list_data_fetch(void *data, unsigned int row, unsigned int column); -static void list_item_clicked(Ewl_Widget *w, void *event, void *data); -static unsigned int list_data_count(void *data); - -/*Add the list view*/ -Ewl_Widget *add_list_view(Ewl_Widget *c) -{ - em->list_vbox = add_box(c, EWL_ORIENTATION_VERTICAL, 5); - ewl_object_fill_policy_set(EWL_OBJECT(em->list_vbox), EWL_FLAG_FILL_ALL); - ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(c), em->list_vbox, "List"); - - em->ltree = add_ltree(em->list_vbox); - - return em->list_vbox; -} - -/*Show the list view*/ -void show_list_view(Ewl_Widget *w, void *event, void *data) -{ - ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->view_box), em->list_vbox); -} - -/*Iterate the list to our spot*/ -static void iterate(char *point2) -{ - char *point1; - - ecore_dlist_first_goto(em->images); - while(ecore_dlist_current(em->images)) - { - point1 = ecore_dlist_current(em->images); - if (!strcmp(point1, point2)) return; - ecore_dlist_next(em->images); - } -} - -/*Go to single view*/ -static void list_item_clicked(Ewl_Widget *w, void *event, void *data) -{ - char *image; - - image = data; - iterate(image); - show_single_view(NULL, NULL, NULL); - - free(image); -} - -/*Create and Add a Tree to the Container c*/ -Ewl_Widget *add_ltree(Ewl_Widget *c) -{ - Ewl_Widget *tree; - Ewl_Model *model; - Ewl_View *view; - - model = ewl_model_new(); - ewl_model_data_fetch_set(model, list_data_fetch); - ewl_model_data_count_set(model, list_data_count); - - view = ewl_view_new(); - ewl_view_widget_fetch_set(view, list_view_new); - ewl_view_header_fetch_set(view, list_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 images */ -static Ewl_Widget *list_view_new(void *data, unsigned int row, unsigned int column) -{ - const char *image; - char info[PATH_MAX]; - int size, width, height; - Ewl_Widget *hbox, *img, *text; - - image = data; - image_pixels_int_get(image, &width, &height); - size = ecore_file_size(image); - snprintf(info, PATH_MAX, "%s: %s\n%s: %s\n%s: %s\n", - _("Name"), - basename((char *)image), - _("Pixels"), - image_pixels_string_get(image), - _("Size"), - file_size_get(size)); - - hbox = add_box(NULL, EWL_ORIENTATION_HORIZONTAL, 10); - ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_HFILL); - ewl_callback_append(hbox, EWL_CALLBACK_CLICKED, list_item_clicked, strdup(image)); - ewl_widget_name_set(hbox, image); - - img = add_image(hbox, image, 1, NULL, NULL); - ewl_image_constrain_set(EWL_IMAGE(img), 64); - - text = add_text(hbox, info); - ewl_object_fill_policy_set(EWL_OBJECT(text), EWL_FLAG_FILL_SHRINK); - ewl_object_alignment_set(EWL_OBJECT(text), EWL_FLAG_ALIGN_LEFT); - - return hbox; -} - -/* The header for the tree */ -static Ewl_Widget *list_header_fetch(void *data, unsigned int column) -{ - Ewl_Widget *label; - - label = add_label(NULL, "Images"); - - return label; -} - -/* The images that will be displayed*/ -static void *list_data_fetch(void *data, unsigned int row, unsigned int column) -{ - const char *image; - void *val = NULL; - - image = ecore_dlist_index_goto(em->images, row); - if (image) - { - val = (void *)image; - } - - return val; -} - -/* The number of images the view is displaying */ -static unsigned int list_data_count(void *data) -{ - int val; - - val = ecore_list_count(em->images); - - return val; -} - diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c index 18e4d47..bfd1c79 100644 --- a/src/bin/ephoto_main.c +++ b/src/bin/ephoto_main.c @@ -1,91 +1,65 @@ #include "ephoto.h" -/*Ewl Callbacks*/ static void destroy(Ewl_Widget *w, void *event, void *data); -static void window_fullscreen(Ewl_Widget *w, void *event, void *data); -/*Ephoto Global Variables*/ -Ephoto_Main *em; - -/*Destroy the Main Window*/ -static void destroy(Ewl_Widget *w, void *event, void *data) +static void +destroy(Ewl_Widget *w, void *event, void *data) { ewl_widget_destroy(em->win); ecore_hash_destroy(em->types); - ecore_list_destroy(em->directories); + ecore_list_destroy(em->albums); + ecore_list_destroy(em->fsystem); ecore_dlist_destroy(em->images); + ephoto_db_close(em->db); + free(em->current_album); free(em->current_directory); free(em); + if (ec->requested_album) + free(ec->requested_album); + if (ec->requested_directory) + free(ec->requested_directory); + if (ec->requested_image) + free(ec->requested_image); + free(ec); ewl_main_quit(); return; } -static void window_fullscreen(Ewl_Widget *w, void *event, void *data) +void +create_main(void) { - int fullscreen; + const char *type; + char buf[PATH_MAX]; + Ewl_Widget *hbox, *vbox; - fullscreen = ewl_window_fullscreen_get(EWL_WINDOW(em->win)); - if(!fullscreen) + if (ec->requested_image) { - ewl_window_fullscreen_set(EWL_WINDOW(em->win), 1); + type = efreet_mime_type_get(ec->requested_image); + if ((ecore_hash_get(em->types, type)) != "image") + ec->requested_image = NULL; } + + if (ec->requested_album) + em->current_album = strdup(ec->requested_album); + else + em->current_album = strdup("Complete Library"); + em->db = ephoto_db_init(); + + if (ec->requested_directory) + em->current_directory = strdup(ec->requested_directory); else { - ewl_window_fullscreen_set(EWL_WINDOW(em->win), 0); + getcwd(buf, PATH_MAX); + em->current_directory = strdup(buf); } - return; -} - -/*Create the Main Ephoto Window*/ -void create_main(void) -{ - char buf[PATH_MAX]; - Ewl_Widget *vbox, *vsep, *button; - Ewl_Widget *mb, *menu, *mi; - - /*Initialize our main Structure*/ - em = NULL; - em = calloc(1, sizeof(Ephoto_Main)); - - /*Set up our Lists*/ - em->directories = ecore_list_new(); - em->images = ecore_dlist_new(); - - /*Set up the image types hash*/ - 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"); - - getcwd(buf, PATH_MAX); - buf[sizeof(buf)-1] = '\0'; - em->current_directory = strdup(buf); - em->bwin = NULL; - - em->win = add_window("Ephoto!", 600, 475, destroy, NULL); + em->win = add_window("Ephoto!", 715, 500, destroy, NULL); vbox = add_box(em->win, EWL_ORIENTATION_VERTICAL, 5); ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL); - mb = add_menubar(vbox); - - menu = add_menu(mb, "File"); - mi = add_menu_item(menu, "Exit", - PACKAGE_DATA_DIR "/images/exit.png", - destroy, NULL); - menu = add_menu(mb, "Albums"); - - menu = add_menu(mb, "View"); - mi = add_menu_item(menu, "Browser", - NULL, show_browser, NULL); - - menu = add_menu(mb, "Help"); - mi = add_menu_item(menu, "About", - PACKAGE_DATA_DIR "/images/stock_help.png", - about_dialog, NULL); + hbox = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 5); + ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_HFILL); em->view = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 1); ewl_object_fill_policy_set(EWL_OBJECT(em->view), EWL_FLAG_FILL_ALL); @@ -96,86 +70,17 @@ void create_main(void) ewl_container_child_append(EWL_CONTAINER(em->view), em->view_box); ewl_widget_show(em->view_box); - add_normal_view(em->view_box); - - add_single_view(em->view_box); - - add_list_view(em->view_box); - - add_edit_view(em->view_box); - - em->toolbar = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 5); - ewl_object_alignment_set(EWL_OBJECT(em->toolbar), EWL_FLAG_ALIGN_CENTER); - ewl_object_fill_policy_set(EWL_OBJECT(em->toolbar), EWL_FLAG_FILL_SHRINK); - - button = add_button(em->toolbar, NULL, - PACKAGE_DATA_DIR "/images/normal_view.png", - show_normal_view, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 30, 30); - ewl_attach_tooltip_text_set(button, _("Normal View")); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_CENTER); - - button = add_button(em->toolbar, NULL, - PACKAGE_DATA_DIR "/images/list_view.png", - show_list_view, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 30, 30); - ewl_attach_tooltip_text_set(button, _("List View")); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_CENTER); - - button = add_button(em->toolbar, NULL, - PACKAGE_DATA_DIR "/images/image.png", - show_single_view, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 30, 30); - ewl_attach_tooltip_text_set(button, _("Single View")); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_CENTER); - - button = add_button(em->toolbar, NULL, - PACKAGE_DATA_DIR "/images/edit_view.png", - show_edit_view, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 30, 30); - ewl_attach_tooltip_text_set(button, _("Move to edit view")); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_CENTER); - - vsep = ewl_vseparator_new(); - ewl_container_child_append(EWL_CONTAINER(em->toolbar), vsep); - ewl_widget_show(vsep); - - button = add_button(em->toolbar, NULL, - PACKAGE_DATA_DIR "/images/get_exif.png", - NULL, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 30, 30); - ewl_attach_tooltip_text_set(button, _("You do not have libexif 0.6.13")); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_CENTER); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); -#ifdef BUILD_EXIF_SUPPORT - ewl_callback_append(button, EWL_CALLBACK_CLICKED, display_exif_dialog, - NULL); - ewl_attach_tooltip_text_set(button, _("View Exif Data")); -#endif - - button = add_button(em->toolbar, NULL, - PACKAGE_DATA_DIR "/images/stock_fullscreen.png", - window_fullscreen, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 30, 30); - ewl_attach_tooltip_text_set(button, _("Toggle Fullscreen")); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_CENTER); - - button = add_button(em->toolbar, NULL, - PACKAGE_DATA_DIR "/images/x-office-presentation.png", - start_slideshow, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 30, 30); - ewl_attach_tooltip_text_set(button, _("Start a Slideshow")); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_CENTER); - - show_browser(NULL, NULL, NULL); + if (ec->requested_image) + { + add_single_view(em->view_box); + add_normal_view(em->view_box); + } + else + { + add_normal_view(em->view_box); + add_single_view(em->view_box); + } return; } - diff --git a/src/bin/ephoto_nls.c b/src/bin/ephoto_nls.c index df47ad7..1e4d424 100644 --- a/src/bin/ephoto_nls.c +++ b/src/bin/ephoto_nls.c @@ -1,8 +1,8 @@ #include "ephoto.h" #include -/*NLS Translator*/ -char *sgettext(const char *msgid) +char * +sgettext(const char *msgid) { char *msgval; diff --git a/src/bin/ephoto_normal_view.c b/src/bin/ephoto_normal_view.c index 14976ce..82bb2b0 100644 --- a/src/bin/ephoto_normal_view.c +++ b/src/bin/ephoto_normal_view.c @@ -1,10 +1,9 @@ #include "ephoto.h" static void change_size(Ewl_Widget *w, void *event, void *data); -static void iterate(char *point2); -/*Change the thumb size*/ -static void change_size(Ewl_Widget *w, void *event, void *data) +static void +change_size(Ewl_Widget *w, void *event, void *data) { Ewl_Widget *child; @@ -13,7 +12,7 @@ static void change_size(Ewl_Widget *w, void *event, void *data) while ((child = ewl_container_child_next(EWL_CONTAINER(em->fbox)))) { ewl_image_constrain_set(EWL_IMAGE(child), - ewl_range_value_get(EWL_RANGE(em->fthumb_size))); + ewl_range_value_get(EWL_RANGE(em->fthumb_size))); ewl_widget_reparent(child); } ewl_widget_configure(em->fbox_vbox); @@ -21,69 +20,68 @@ static void change_size(Ewl_Widget *w, void *event, void *data) return; } -/*Add the normal view*/ -Ewl_Widget *add_normal_view(Ewl_Widget *c) +Ewl_Widget * +add_normal_view(Ewl_Widget *c) { - Ewl_Widget *sp; + Ewl_Widget *box, *button, *hbox, *sp, *vbox; em->fbox_vbox = add_box(c, EWL_ORIENTATION_VERTICAL, 5); - ewl_object_fill_policy_set(EWL_OBJECT(em->fbox_vbox), EWL_FLAG_FILL_ALL); - ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(c), em->fbox_vbox, "Normal"); + ewl_object_fill_policy_set(EWL_OBJECT(em->fbox_vbox), + EWL_FLAG_FILL_ALL); + ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(c), em->fbox_vbox, + "Normal"); + + hbox = ewl_hbox_new(); + ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_ALL); + ewl_container_child_append(EWL_CONTAINER(em->fbox_vbox), hbox); + ewl_widget_show(hbox); + + vbox = add_box(hbox, EWL_ORIENTATION_VERTICAL, 2); + ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_VFILL); + + show_albums(vbox); + + box = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 2); + ewl_object_fill_policy_set(EWL_OBJECT(box), EWL_FLAG_FILL_SHRINK); + + button = add_button(box, "Import", PACKAGE_DATA_DIR "/images/add.png", + ephoto_import_dialog, NULL); + ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); + + button = add_button(box, "Export", PACKAGE_DATA_DIR "/images/emblem-photos.png", NULL, NULL); + ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); + + vbox = add_box(hbox, EWL_ORIENTATION_VERTICAL, 2); sp = ewl_scrollpane_new(); ewl_object_fill_policy_set(EWL_OBJECT(sp), EWL_FLAG_FILL_ALL); - ewl_container_child_append(EWL_CONTAINER(em->fbox_vbox), sp); - ewl_widget_show(sp); + ewl_container_child_append(EWL_CONTAINER(vbox), sp); + ewl_widget_show(sp); em->fbox = ewl_hfreebox_new(); - ewl_object_fill_policy_set(EWL_OBJECT(em->fbox), EWL_FLAG_FILL_ALL); + ewl_freebox_layout_type_set(EWL_FREEBOX(em->fbox), + EWL_FREEBOX_LAYOUT_AUTO); + ewl_object_fill_policy_set(EWL_OBJECT(em->fbox), EWL_FLAG_FILL_ALL); ewl_container_child_append(EWL_CONTAINER(sp), em->fbox); ewl_widget_show(em->fbox); em->fthumb_size = ewl_hseeker_new(); - ewl_range_minimum_value_set(EWL_RANGE(em->fthumb_size), 8); - ewl_range_maximum_value_set(EWL_RANGE(em->fthumb_size), 128); + ewl_range_minimum_value_set(EWL_RANGE(em->fthumb_size), 16); + ewl_range_maximum_value_set(EWL_RANGE(em->fthumb_size), 144); ewl_range_step_set(EWL_RANGE(em->fthumb_size), 16); - ewl_range_value_set(EWL_RANGE(em->fthumb_size), 64); - ewl_container_child_append(EWL_CONTAINER(em->fbox_vbox), em->fthumb_size); - ewl_callback_append(em->fthumb_size, EWL_CALLBACK_VALUE_CHANGED, change_size, NULL); - ewl_object_alignment_set(EWL_OBJECT(em->fthumb_size), EWL_FLAG_ALIGN_RIGHT); - ewl_object_maximum_size_set(EWL_OBJECT(em->fthumb_size), 160, 20); + ewl_range_value_set(EWL_RANGE(em->fthumb_size), 80); + ewl_container_child_append(EWL_CONTAINER(vbox), em->fthumb_size); + ewl_callback_append(em->fthumb_size, EWL_CALLBACK_VALUE_CHANGED, + change_size, NULL); + ewl_object_maximum_size_set(EWL_OBJECT(em->fthumb_size), 160, 40); ewl_widget_show(em->fthumb_size); return em->fbox_vbox; } -/*Show the normal view*/ -void show_normal_view(Ewl_Widget *w, void *event, void *data) +void +show_normal_view(Ewl_Widget *w, void *event, void *data) { - ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->view_box), em->fbox_vbox); + ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->view_box), + em->fbox_vbox); } - -/*Find our spot in the list*/ -static void iterate(char *point2) -{ - char *point1; - - ecore_dlist_first_goto(em->images); - while(ecore_dlist_current(em->images)) - { - point1 = ecore_dlist_current(em->images); - if (!strcmp(point1, point2)) return; - ecore_dlist_next(em->images); - } -} - -/*Action when an image is clicked*/ -void freebox_image_clicked(Ewl_Widget *w, void *event, void *data) -{ - const char *path; - - - path = ewl_widget_name_get(w); - iterate(strdup(path)); - show_single_view(NULL, NULL, NULL); - - return; -} - diff --git a/src/bin/ephoto_single_view.c b/src/bin/ephoto_single_view.c index 47c196a..d20a632 100644 --- a/src/bin/ephoto_single_view.c +++ b/src/bin/ephoto_single_view.c @@ -1,58 +1,214 @@ #include "ephoto.h" -/*Ephoto Image Changing*/ +static void add_standard_edit_tools(Ewl_Widget *c); +static void show_advanced(void); 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); +static void set_requested_image_file(Ewl_Widget *w, void *event, void *data); -/*Add the single view*/ -Ewl_Widget *add_single_view(Ewl_Widget *c) +static void +set_requested_image_file(Ewl_Widget *w, void *event, void *data) { - Ewl_Widget *hbox, *ibox, *button; + ewl_image_file_path_set(EWL_IMAGE(w), ec->requested_image); +} + +Ewl_Widget * +add_single_view(Ewl_Widget *c) +{ + Ewl_Widget *vbox, *ibox, *hbox, *image, *bhbox; + Ewl_Widget *standard, *advanced; + + em->ewin = NULL; + + em->single_vbox = add_box(c, EWL_ORIENTATION_VERTICAL, 2); + ewl_object_fill_policy_set(EWL_OBJECT(em->single_vbox), + EWL_FLAG_FILL_ALL); + + hbox = add_box(em->single_vbox, EWL_ORIENTATION_HORIZONTAL, 2); + ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_ALL); + + standard = add_box(hbox, EWL_ORIENTATION_VERTICAL, 2); + ewl_object_maximum_w_set(EWL_OBJECT(standard), 30); + ewl_object_minimum_w_set(EWL_OBJECT(standard), 30); + ewl_object_fill_policy_set(EWL_OBJECT(standard), EWL_FLAG_FILL_VFILL); + + add_standard_edit_tools(standard); - em->single_vbox = add_box(c, EWL_ORIENTATION_VERTICAL, 5); - ewl_object_fill_policy_set(EWL_OBJECT(em->single_vbox), EWL_FLAG_FILL_ALL); - ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(c), em->single_vbox, "Single"); + advanced = add_image(standard, + PACKAGE_DATA_DIR "/images/camera-photo.png", + 0, show_advanced, NULL); + ewl_image_size_set(EWL_IMAGE(advanced), 25, 25); + ewl_object_alignment_set(EWL_OBJECT(advanced), EWL_FLAG_ALIGN_LEFT); + ewl_object_fill_policy_set(EWL_OBJECT(advanced), EWL_FLAG_FILL_SHRINK); + 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(em->single_vbox), ibox); + ewl_container_child_append(EWL_CONTAINER(vbox), ibox); ewl_widget_show(ibox); em->simage = add_image(ibox, NULL, 0, NULL, NULL); - ewl_object_alignment_set(EWL_OBJECT(em->simage), EWL_FLAG_ALIGN_CENTER); - ewl_object_fill_policy_set(EWL_OBJECT(em->simage), EWL_FLAG_FILL_SHRINK); + ewl_object_alignment_set(EWL_OBJECT(em->simage), + EWL_FLAG_ALIGN_CENTER); + ewl_object_fill_policy_set(EWL_OBJECT(em->simage), + EWL_FLAG_FILL_SHRINK); + if (ec->requested_image) + ewl_callback_append(em->simage, EWL_CALLBACK_SHOW, + set_requested_image_file, NULL); + + bhbox = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 5); + ewl_object_alignment_set(EWL_OBJECT(bhbox), EWL_FLAG_ALIGN_CENTER); + ewl_object_fill_policy_set(EWL_OBJECT(bhbox), EWL_FLAG_FILL_SHRINK); - hbox = add_box(em->single_vbox, EWL_ORIENTATION_HORIZONTAL, 2); - ewl_object_alignment_set(EWL_OBJECT(hbox), EWL_FLAG_ALIGN_CENTER); - ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_SHRINK); + image = add_image(bhbox, + PACKAGE_DATA_DIR "/images/media-seek-backward.png", 0, + previous_image, NULL); + ewl_image_size_set(EWL_IMAGE(image), 32, 32); + ewl_attach_tooltip_text_set(image, _("Previous Image")); + + image = add_image(bhbox, + PACKAGE_DATA_DIR "/images/media-seek-forward.png", 0, + next_image, NULL); + ewl_image_size_set(EWL_IMAGE(image), 32, 32); + ewl_attach_tooltip_text_set(image, _("Next Image")); - button = add_button(hbox, NULL, - PACKAGE_DATA_DIR "/images/media-seek-backward.png", - previous_image, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 25, 25); - ewl_attach_tooltip_text_set(button, _("Previous Image")); + hbox = add_box(em->single_vbox, EWL_ORIENTATION_HORIZONTAL, 5); + ewl_object_alignment_set(EWL_OBJECT(hbox), EWL_FLAG_ALIGN_LEFT); + ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_SHRINK); - button = add_button(hbox, NULL, - PACKAGE_DATA_DIR "/images/media-seek-forward.png", - next_image, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 25, 25); - ewl_attach_tooltip_text_set(button, _("Next Image")); + image = add_image(hbox, PACKAGE_DATA_DIR "/images/normal_view.png", 0, + show_normal_view, NULL); + ewl_image_size_set(EWL_IMAGE(image), 25, 25); + ewl_attach_tooltip_text_set(image, _("Image Thumbnail View")); + ewl_object_fill_policy_set(EWL_OBJECT(image), EWL_FLAG_FILL_SHRINK); return em->single_vbox; } -/*Show the single view*/ -void show_single_view(Ewl_Widget *w, void *event, void *data) +void +show_single_view(Ewl_Widget *w, void *event, void *data) { - ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->view_box), em->single_vbox); - ewl_image_file_path_set(EWL_IMAGE(em->simage), + ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->view_box), + em->single_vbox); + if (ecore_dlist_current(em->images)) + { + ewl_image_file_path_set(EWL_IMAGE(em->simage), ecore_dlist_current(em->images)); + } + return; +} + +static void +add_standard_edit_tools(Ewl_Widget *c) +{ + Ewl_Widget *image; + + image = add_image(c, PACKAGE_DATA_DIR "/images/search.png", 0, zoom_in, + NULL); + ewl_image_size_set(EWL_IMAGE(image), 25, 25); + ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_LEFT); + + image = add_image(c, PACKAGE_DATA_DIR "/images/search.png", 0, zoom_out, + NULL); + ewl_image_size_set(EWL_IMAGE(image), 25, 25); + ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_LEFT); + + image = add_image(c, PACKAGE_DATA_DIR "/images/undo.png", 0, + rotate_image_left, NULL); + ewl_image_size_set(EWL_IMAGE(image), 25, 25); + ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_LEFT); + + image = add_image(c, PACKAGE_DATA_DIR "/images/redo.png", 0, + rotate_image_right, NULL); + ewl_image_size_set(EWL_IMAGE(image), 25, 25); + ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_LEFT); + + image = add_image(c, PACKAGE_DATA_DIR "/images/go-next.png", 0, + flip_image_horizontal, NULL); + ewl_image_size_set(EWL_IMAGE(image), 25, 25); + ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_LEFT); + + image = add_image(c, PACKAGE_DATA_DIR "/images/go-down.png", 0, + flip_image_vertical, NULL); + ewl_image_size_set(EWL_IMAGE(image), 25, 25); + ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_LEFT); return; } -/*Go to the previous image*/ -static void previous_image(Ewl_Widget *w, void *event, void *data) +static void +destroy(Ewl_Widget *w, void *event, void *data) +{ + ewl_widget_destroy(w); + em->ewin = NULL; +} + +static void +show_advanced(void) +{ + const char *file; + Epsilon *ep; + Ewl_Widget *grid, *image; + + ep = epsilon_new(ecore_dlist_current(em->images)); + if (!epsilon_exists(ep)) + epsilon_generate(ep); + file = epsilon_thumb_file_get(ep); + epsilon_free(ep); + + em->ewin = add_window("Ephoto Effects!", 375, 100, destroy, NULL); + + grid = ewl_grid_new(); + ewl_grid_dimensions_set(EWL_GRID(grid), 1, 4); + ewl_object_alignment_set(EWL_OBJECT(grid), EWL_FLAG_ALIGN_CENTER); + ewl_object_fill_policy_set(EWL_OBJECT(grid), EWL_FLAG_FILL_ALL); + ewl_container_child_append(EWL_CONTAINER(em->ewin), grid); + ewl_widget_show(grid); + + image = add_icon(grid, "Grayscale", file, 0, image_grayscale, + em->simage); + ewl_icon_constrain_set(EWL_ICON(image), 81); + ewl_callback_append(EWL_ICON(image)->image, EWL_CALLBACK_CONFIGURE, + image_grayscale, EWL_ICON(image)->image); + ewl_grid_child_position_set(EWL_GRID(grid), image, 0, 0, 0, 0); + + image = add_icon(grid, "Sepia", file, 0, image_sepia, em->simage); + ewl_icon_constrain_set(EWL_ICON(image), 81); + ewl_callback_append(EWL_ICON(image)->image, EWL_CALLBACK_CONFIGURE, + image_sepia, EWL_ICON(image)->image); + ewl_grid_child_position_set(EWL_GRID(grid), image, 1, 1, 0, 0); + + image = add_icon(grid, "Blur", file, 0, image_blur, em->simage); + ewl_icon_constrain_set(EWL_ICON(image), 81); + ewl_callback_append(EWL_ICON(image)->image, EWL_CALLBACK_CONFIGURE, + image_blur, EWL_ICON(image)->image); + ewl_grid_child_position_set(EWL_GRID(grid), image, 2, 2, 0, 0); + + image = add_icon(grid, "Sharpen", file, 0, image_sharpen, em->simage); + ewl_icon_constrain_set(EWL_ICON(image), 81); + ewl_callback_append(EWL_ICON(image)->image, EWL_CALLBACK_CONFIGURE, + image_sharpen, EWL_ICON(image)->image); + ewl_grid_child_position_set(EWL_GRID(grid), image, 3, 3, 0, 0); + + return; +} + +static void +previous_image(Ewl_Widget *w, void *event, void *data) { char *image; @@ -63,15 +219,14 @@ static void previous_image(Ewl_Widget *w, void *event, void *data) ecore_dlist_last_goto(em->images); image = ecore_dlist_current(em->images); } - ewl_image_file_path_set(EWL_IMAGE(em->simage), image); - ewl_widget_configure(em->simage->parent); - + ewl_image_file_path_set(EWL_IMAGE(em->simage), image); + ewl_widget_configure(em->simage->parent); + return; } - -/*Go to the next image*/ -static void next_image(Ewl_Widget *w, void *event, void *data) +static void +next_image(Ewl_Widget *w, void *event, void *data) { char *image; @@ -84,7 +239,260 @@ static void next_image(Ewl_Widget *w, void *event, void *data) } ewl_image_file_path_set(EWL_IMAGE(em->simage), image); ewl_widget_configure(em->simage->parent); + + return; +} + +static void +zoom_in(Ewl_Widget *w, void *event, void *data) +{ + int ow, oh; + + ewl_object_current_size_get(EWL_OBJECT(em->simage), &ow, &oh); + + ewl_image_size_set(EWL_IMAGE(em->simage), ow*2, oh*2); + ewl_widget_configure(em->simage->parent); return; } +static void +zoom_out(Ewl_Widget *w, void *event, void *data) +{ + int ow, oh; + + ewl_object_current_size_get(EWL_OBJECT(em->simage), &ow, &oh); + + ewl_image_size_set(EWL_IMAGE(em->simage), ow/2, oh/2); + ewl_widget_configure(em->simage->parent); + + return; +} + +static void +flip_image_horizontal(Ewl_Widget *w, void *event, void *data) +{ + + unsigned int *image_data; + int nw, nh; + + image_data = flip_horizontal(em->simage); + evas_object_image_size_get(EWL_IMAGE(em->simage)->image, &nw, &nh); + update_image(em->simage, nw, nh, image_data); + ewl_widget_configure(em->simage->parent); + + return; +} + +static void +flip_image_vertical(Ewl_Widget *w, void *event, void *data) +{ + unsigned int *image_data; + int nw, nh; + + image_data = flip_vertical(em->simage); + evas_object_image_size_get(EWL_IMAGE(em->simage)->image, &nw, &nh); + update_image(em->simage, nw, nh, image_data); + ewl_widget_configure(em->simage->parent); + + return; +} + +static void +rotate_image_left(Ewl_Widget *w, void *event, void *data) +{ + unsigned int *image_data; + int nw, nh; + Ewl_Image *image; + + evas_object_image_size_get(EWL_IMAGE(em->simage)->image, &nh, &nw); + image_data = rotate_left(em->simage); + image = EWL_IMAGE(em->simage); + ewl_image_size_set(EWL_IMAGE(image), nw, nh); + image->ow = nw; + image->oh = nh; + update_image(em->simage, nw, nh, image_data); + ewl_object_preferred_inner_size_set(EWL_OBJECT(em->simage), nw, nh); + ewl_widget_configure(em->simage->parent); + + return; +} + +static void +rotate_image_right(Ewl_Widget *w, void *event, void *data) +{ + unsigned int *image_data; + int nw, nh; + Ewl_Image *image; + + evas_object_image_size_get(EWL_IMAGE(em->simage)->image, &nh, &nw); + image_data = rotate_right(em->simage); + update_image(em->simage, nw, nh, image_data); + image = EWL_IMAGE(em->simage); + ewl_image_size_set(EWL_IMAGE(image), nw, nh); + image->ow = nw; + image->oh = nh; + ewl_object_preferred_inner_size_set(EWL_OBJECT(em->simage), nw, nh); + ewl_widget_configure(em->simage->parent); + + return; +} + +static void +image_blur(Ewl_Widget *w, void *event, void *data) +{ + unsigned int *image_data; + int nw, nh; + Ewl_Widget *image; + + image = data; + + evas_object_image_size_get(EWL_IMAGE(image)->image, &nw, &nh); + image_data = blur_image(image); + update_image(image, nw, nh, image_data); + ewl_widget_configure(image->parent); + + ewl_callback_del(image, EWL_CALLBACK_CONFIGURE, image_blur); + + return; +} + +static void +image_sharpen(Ewl_Widget *w, void *event, void *data) +{ + unsigned int *image_data; + int nw, nh; + Ewl_Widget *image; + + image = data; + + evas_object_image_size_get(EWL_IMAGE(image)->image, &nw, &nh); + image_data = sharpen_image(image); + update_image(image, nw, nh, image_data); + ewl_widget_configure(image->parent); + + ewl_callback_del(image, EWL_CALLBACK_CONFIGURE, image_sharpen); + + return; +} + +static void +image_grayscale(Ewl_Widget *w, void *event, void *data) +{ + unsigned int *image_data; + int nw, nh; + Ewl_Widget *image; + + image = data; + + evas_object_image_size_get(EWL_IMAGE(image)->image, &nw, &nh); + image_data = grayscale_image(image); + update_image(image, nw, nh, image_data); + ewl_widget_configure(image->parent); + + ewl_callback_del(image, EWL_CALLBACK_CONFIGURE, image_grayscale); + + return; +} + +static void +image_sepia(Ewl_Widget *w, void *event, void *data) +{ + unsigned int *image_data; + int nw, nh; + Ewl_Widget *image; + + image = data; + + evas_object_image_size_get(EWL_IMAGE(image)->image, &nw, &nh); + image_data = sepia_image(image); + update_image(image, nw, nh, image_data); + ewl_widget_configure(image->parent); + + ewl_callback_del(image, EWL_CALLBACK_CONFIGURE, image_sepia); + + return; +} + +static void +close_channel(Ewl_Widget *w, void *event, void *data) +{ +/* Ewl_Widget *win; + + win = data; + + ewl_widget_destroy(win);*/ +} + +static void +channel_mixer(Ewl_Widget *w, void *event, void *data) +{ + close_channel(NULL, NULL, NULL); +/* Ewl_Widget *window, *vbox, *seek; + + window = add_window("Channel Editor", 400, 400, NULL, NULL); + ewl_callback_append(window, EWL_CALLBACK_DELETE_WINDOW, close_channel, window); + + vbox = add_box(window, EWL_ORIENTATION_VERTICAL, 1); + + add_label(vbox, "Hue"); + + seek = ewl_hseeker_new(); + ewl_range_minimum_value_set(EWL_RANGE(seek), -100); + ewl_range_maximum_value_set(EWL_RANGE(seek), 100); + ewl_range_step_set(EWL_RANGE(seek), 10); + ewl_range_value_set(EWL_RANGE(seek), 0); + ewl_container_child_append(EWL_CONTAINER(vbox), seek); + ewl_widget_show(seek); + + add_label(vbox, "Saturation"); + + seek = ewl_hseeker_new(); + ewl_range_minimum_value_set(EWL_RANGE(seek), -100); + ewl_range_maximum_value_set(EWL_RANGE(seek), 100); + ewl_range_step_set(EWL_RANGE(seek), 10); + ewl_range_value_set(EWL_RANGE(seek), 0); + ewl_container_child_append(EWL_CONTAINER(vbox), seek); + ewl_widget_show(seek); + + add_label(vbox, "Value"); + + seek = ewl_hseeker_new(); + ewl_range_minimum_value_set(EWL_RANGE(seek), -100); + ewl_range_maximum_value_set(EWL_RANGE(seek), 100); + ewl_range_step_set(EWL_RANGE(seek), 10); + ewl_range_value_set(EWL_RANGE(seek), 0); + ewl_container_child_append(EWL_CONTAINER(vbox), seek); + ewl_widget_show(seek); + + add_label(vbox, "Light"); + + seek = ewl_hseeker_new(); + ewl_range_minimum_value_set(EWL_RANGE(seek), -100); + ewl_range_maximum_value_set(EWL_RANGE(seek), 100); + ewl_range_step_set(EWL_RANGE(seek), 10); + ewl_range_value_set(EWL_RANGE(seek), 0); + ewl_container_child_append(EWL_CONTAINER(vbox), seek); + ewl_widget_show(seek); + + add_label(vbox, "Brightness"); + + seek = ewl_hseeker_new(); + ewl_range_minimum_value_set(EWL_RANGE(seek), -100); + ewl_range_maximum_value_set(EWL_RANGE(seek), 100); + ewl_range_step_set(EWL_RANGE(seek), 10); + ewl_range_value_set(EWL_RANGE(seek), 0); + ewl_container_child_append(EWL_CONTAINER(vbox), seek); + ewl_widget_show(seek); + + add_label(vbox, "Contrast"); + + seek = ewl_hseeker_new(); + ewl_range_minimum_value_set(EWL_RANGE(seek), -100); + ewl_range_maximum_value_set(EWL_RANGE(seek), 100); + ewl_range_step_set(EWL_RANGE(seek), 10); + ewl_range_value_set(EWL_RANGE(seek), 0); + ewl_container_child_append(EWL_CONTAINER(vbox), seek); + ewl_widget_show(seek);*/ +} + diff --git a/src/bin/ephoto_slideshow.c b/src/bin/ephoto_slideshow.c index 07f4923..9f2fc7f 100644 --- a/src/bin/ephoto_slideshow.c +++ b/src/bin/ephoto_slideshow.c @@ -6,7 +6,8 @@ static void show_first_image(Ewl_Widget *w, void *event, void *data); static Ecore_Timer *change; static Ewl_Widget *win; -static int change_picture(void *data) +static int +change_picture(void *data) { char *image_path; Ewl_Widget *image; @@ -28,13 +29,15 @@ static int change_picture(void *data) return 1; } -static void destroy(Ewl_Widget *w, void *event, void *data) +static void +destroy(Ewl_Widget *w, void *event, void *data) { ewl_widget_destroy(win); ecore_timer_del(change); } -static void show_first_image(Ewl_Widget *w, void *event, void *data) +static void +show_first_image(Ewl_Widget *w, void *event, void *data) { char *image_path; @@ -48,7 +51,8 @@ static void show_first_image(Ewl_Widget *w, void *event, void *data) return; } -void start_slideshow(Ewl_Widget *w, void *event, void *data) +void +start_slideshow(Ewl_Widget *w, void *event, void *data) { Ewl_Widget *cell, *image; @@ -56,13 +60,12 @@ void start_slideshow(Ewl_Widget *w, void *event, void *data) ewl_window_fullscreen_set(EWL_WINDOW(win), 1); ewl_callback_append(win, EWL_CALLBACK_CLICKED, destroy, NULL); - image = add_image(win, PACKAGE_DATA_DIR "/images/black.png", 0, NULL, NULL); - ewl_image_proportional_set(EWL_IMAGE(image), FALSE); - ewl_object_fill_policy_set(EWL_OBJECT(image), EWL_FLAG_FILL_ALL); - cell = ewl_cell_new(); ewl_object_fill_policy_set(EWL_OBJECT(cell), EWL_FLAG_FILL_ALL); ewl_container_child_append(EWL_CONTAINER(win), cell); + ewl_theme_data_str_set(cell, "/cell/file", + PACKAGE_DATA_DIR "/images/single_vbox.edj"); + ewl_theme_data_str_set(cell, "/cell/group", "bg"); ewl_widget_show(cell); image = add_image(cell, NULL, 0, NULL, NULL); diff --git a/src/bin/ephoto_utils.c b/src/bin/ephoto_utils.c index c04b132..f4e82fc 100644 --- a/src/bin/ephoto_utils.c +++ b/src/bin/ephoto_utils.c @@ -1,6 +1,7 @@ #include "ephoto.h" -const char *file_size_get(int size) +const char * +file_size_get(int size) { double dsize; char fsize[256]; @@ -29,9 +30,8 @@ const char *file_size_get(int size) return strdup(fsize); } - -/*Get the pixels and return them in a string*/ -const char *image_pixels_string_get(const char *file) +const char * +image_pixels_string_get(const char *file) { char pixels[PATH_MAX]; int w, h; @@ -46,8 +46,8 @@ const char *image_pixels_string_get(const char *file) return strdup(pixels); } -/*Get the pixels and return them in integers*/ -void image_pixels_int_get(const char *file, int *width, int *height) +void +image_pixels_int_get(const char *file, int *width, int *height) { int w, h; Evas_Imaging_Image *image; @@ -62,3 +62,84 @@ void image_pixels_int_get(const char *file, int *width, int *height) return; } +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; +} + +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; +} +