From 17eec468f4ada5257b515b61644d8bb13749245e Mon Sep 17 00:00:00 2001 From: titan Date: Sat, 28 Apr 2007 04:12:24 +0000 Subject: [PATCH] Cleanups, move exif button out of edit view and into toolbar, start album work. SVN revision: 29745 --- src/bin/ephoto.h | 2 + src/bin/ephoto_edit_view.c | 10 ----- src/bin/ephoto_exif.c | 2 +- src/bin/ephoto_imaging.c | 16 +++++++ src/bin/ephoto_main.c | 86 ++++++++++++++++++++++++++++++++++-- src/bin/ephoto_single_view.c | 1 + 6 files changed, 102 insertions(+), 15 deletions(-) diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h index b5d8f4a..af5afb1 100644 --- a/src/bin/ephoto.h +++ b/src/bin/ephoto.h @@ -84,6 +84,7 @@ unsigned int *flip_vertical(Ewl_Widget *image); unsigned int *rotate_left(Ewl_Widget *image); unsigned int *rotate_right(Ewl_Widget *image); void update_image(Ewl_Widget *image, int w, int h, unsigned int *data); +void save_image(Ewl_Widget *image, const char *file); /* Ephoto Edit View */ Ewl_Widget *add_edit_view(Ewl_Widget *c); @@ -138,6 +139,7 @@ struct _Ephoto_Main Ewl_Widget *main_nb; Ewl_Widget *main_vbox; Ewl_Widget *simage; + Ewl_Widget *single_sp; Ewl_Widget *single_vbox; Ewl_Widget *toolbar; Ewl_Widget *view; diff --git a/src/bin/ephoto_edit_view.c b/src/bin/ephoto_edit_view.c index 69d711d..51c820d 100644 --- a/src/bin/ephoto_edit_view.c +++ b/src/bin/ephoto_edit_view.c @@ -77,16 +77,6 @@ static void add_standard_edit_tools(Ewl_Widget *c) { Ewl_Widget *button; - button = add_button(c, "Get Exif", PACKAGE_DATA_DIR "/images/get_exif.png", NULL, NULL); - ewl_button_image_size_set(EWL_BUTTON(button), 30, 30); - ewl_button_label_set(EWL_BUTTON(button), "You do not have libexif 0.6.13"); - ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); -#ifdef BUILD_EXIF_SUPPORT - ewl_callback_append(button, EWL_CALLBACK_CLICKED, display_exif_dialog, NULL); - ewl_button_label_set(EWL_BUTTON(button), "View Exif Data"); -#endif - button = add_button(c, "Rotate Left", PACKAGE_DATA_DIR "/images/undo.png", rotate_image_left, NULL); ewl_button_image_size_set(EWL_BUTTON(button), 30, 30); ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT); diff --git a/src/bin/ephoto_exif.c b/src/bin/ephoto_exif.c index 11e8fec..daa53d7 100644 --- a/src/bin/ephoto_exif.c +++ b/src/bin/ephoto_exif.c @@ -59,7 +59,7 @@ static const char *get_image(void) { const char *img = NULL; - if (VISIBLE(em->edit_vbox)) img = ewl_image_file_path_get(EWL_IMAGE(em->eimage)); + img = ecore_dlist_current(em->images); if(!img) return NULL; return strdup(img); } diff --git a/src/bin/ephoto_imaging.c b/src/bin/ephoto_imaging.c index 997af83..4275a1d 100644 --- a/src/bin/ephoto_imaging.c +++ b/src/bin/ephoto_imaging.c @@ -136,3 +136,19 @@ void update_image(Ewl_Widget *image, int w, int h, unsigned int *data) evas_object_image_data_update_add(EWL_IMAGE(image)->image, 0, 0, w, h); } } + +void save_image(Ewl_Widget *image, const char *file) +{ + pid_t pid; + + if(image && file) + { + pid = fork(); + if(pid == 0) + { + evas_object_image_save(EWL_IMAGE(image)->image, file, NULL, NULL); + exit(0); + } + } + return; +} diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c index 16c38d1..35dc06d 100644 --- a/src/bin/ephoto_main.c +++ b/src/bin/ephoto_main.c @@ -1,9 +1,12 @@ #include "ephoto.h" /*Ewl Callbacks*/ +static void add_album(Ewl_Widget *w, void *event, void *data); +static void cancel(Ewl_Widget *w, void *event, void *data); static void destroy(Ewl_Widget *w, void *event, void *data); static void populate_albums(Ewl_Widget *w, void *event, void *data); static void populate_directories(Ewl_Widget *w, void *event, void *data); +static void save(Ewl_Widget *w, void *event, void *data); static void update_view(Ewl_Widget *w, void *event, void *data); static void window_fullscreen(Ewl_Widget *w, void *event, void *data); @@ -23,6 +26,7 @@ static unsigned int directory_data_count(void *data); /*Ephoto Global Variables*/ Ephoto_Main *em; +Ewl_Widget *ae, *de; /*Destroy the Main Window*/ static void destroy(Ewl_Widget *w, void *event, void *data) @@ -82,6 +86,63 @@ static void update_view(Ewl_Widget *w, void *event, void *data) return; } +/*Cancel the Album Dialog*/ +static void cancel(Ewl_Widget *w, void *event, void *data) +{ + Ewl_Widget *win; + + win = data; + + ewl_widget_destroy(win); +} + +/*Save the Album*/ +static void save(Ewl_Widget *w, void *event, void *data) +{ + char *album, *description; + Ewl_Widget *win; + sqlite3 *db; + + win = data; + + album = ewl_text_text_get(EWL_TEXT(ae)); + description = ewl_text_text_get(EWL_TEXT(de)); + + if (album) + { + db = ephoto_db_init(); + ephoto_db_add_album(db, album, description); + ephoto_db_close(db); + ewl_widget_destroy(win); + ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->browser), em->atree); + populate_albums(NULL, NULL, NULL); + } +} + +/*Add an Album to Ephoto*/ +static void add_album(Ewl_Widget *w, void *event, void *data) +{ + Ewl_Widget *window, *label, *button, *vbox, *hbox; + + window = NULL; + window = add_window("Add Album", 200, 100, cancel, window); + + vbox = add_box(window, EWL_ORIENTATION_VERTICAL, 3); + ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL); + + label = add_label(vbox, "Enter a name for the new album:"); + ae = add_entry(vbox, NULL, NULL, NULL); + + label = add_label(vbox, "Enter a description for the album:"); + de = add_entry(vbox, NULL, NULL, NULL); + + hbox = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 2); + ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_SHRINK); + + button = add_button(hbox, "Save", PACKAGE_DATA_DIR "/images/stock_save.png", save, window); + button = add_button(hbox, "Cancel", PACKAGE_DATA_DIR "/images/dialog-close.png", cancel, window); +} + /*Create the Main Ephoto Window*/ void create_main_gui(void) { @@ -102,6 +163,8 @@ void create_main_gui(void) 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"); + mi = add_menu_item(menu, "Add Album", PACKAGE_DATA_DIR "/images/add.png", add_album, NULL); hbox = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 2); ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_ALL); @@ -180,6 +243,16 @@ void create_main_gui(void) 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_LEFT); + ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL); +#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"); @@ -202,12 +275,8 @@ void create_main_gui(void) ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_CENTER); - em->albums = ecore_list_new(); em->db = ephoto_db_init(); - em->albums = ephoto_db_list_albums(em->db); - ewl_mvc_data_set(EWL_MVC(em->atree), em->albums); - em->current_album = strdup("Complete Library"); em->current_directory = strdup(getenv("HOME")); @@ -231,11 +300,20 @@ static void populate_albums(Ewl_Widget *w, void *event, void *data) album = ewl_widget_name_get(w); em->current_album = strdup(album); } + if (!ecore_list_is_empty(em->albums)) + { + ecore_list_destroy(em->albums); + } if (!ecore_list_is_empty(em->images)) { ecore_dlist_destroy(em->images); } + em->albums = ecore_list_new(); + em->albums = ephoto_db_list_albums(em->db); + ewl_mvc_data_set(EWL_MVC(em->atree), em->albums); + ewl_mvc_dirty_set(EWL_MVC(em->atree), 1); + em->images = ecore_dlist_new(); em->images = ephoto_db_list_images(em->db, em->current_album); diff --git a/src/bin/ephoto_single_view.c b/src/bin/ephoto_single_view.c index c421605..e598390 100644 --- a/src/bin/ephoto_single_view.c +++ b/src/bin/ephoto_single_view.c @@ -43,6 +43,7 @@ void show_single_view(Ewl_Widget *w, void *event, void *data) ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->main_nb), em->main_vbox); ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->view_box), em->single_vbox); ewl_image_file_path_set(EWL_IMAGE(em->simage), ecore_dlist_current(em->images)); + return; }