Change from Freebox to Freebox_mvc.. update to work with fill policy changes

SVN revision: 34826
This commit is contained in:
titan 2008-06-14 21:35:01 +00:00 committed by titan
parent 380a984e28
commit 20edb14dbe
9 changed files with 221 additions and 372 deletions

View File

@ -1,63 +1,16 @@
#include "ephoto.h"
Ephoto_Config *ec;
Ephoto_Main *em;
int
main(int argc, char **argv)
{
int i;
if (!ewl_init(&argc, argv))
{
printf("Ewl is not usable, please check your installation!\n");
printf("Ewl is not usable, check your installation!\n");
return 1;
}
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);

View File

@ -69,7 +69,6 @@ void ephoto_db_close(sqlite3 *db);
/*ephoto_dialogs.c*/
void about_dialog(Ewl_Widget *w, void *event, void *data);
void add_album_dialog(Ewl_Widget *w, void *event, void *data);
/*ephoto_exif.c*/
#ifdef BUILD_EXIF_SUPPORT
@ -108,7 +107,7 @@ Ewl_Widget *add_menu_item(Ewl_Widget *c, char *lbl,
void *cb,
void *data);
Ewl_Widget *add_text(Ewl_Widget *c, char *text);
Ewl_Widget *add_window(char *name, int w, int h, void *cb,
Ewl_Widget *add_window(char *title, int w, int h, void *cb,
void *data);
/*ephoto_imaging.c*/
@ -170,6 +169,7 @@ struct _Ephoto_Main
Ewl_Widget *fbox;
Ewl_Widget *ftree;
Ewl_Widget *fthumb_size;
Ewl_Widget *scroll;
Ewl_Widget *simage;
Ewl_Widget *single_vbox;
Ewl_Widget *view;
@ -178,16 +178,6 @@ struct _Ephoto_Main
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

View File

@ -10,7 +10,6 @@ static void *album_data_fetch(void *data, unsigned int row,
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);
static void populate_images(Ewl_Widget *w, void *event, void *data);
void
@ -45,13 +44,14 @@ add_atree(Ewl_Widget *c)
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_headers_visible_set(EWL_TREE(tree), TRUE);
ewl_tree_fixed_rows_set(EWL_TREE(tree), TRUE);
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_object_fill_policy_set(EWL_OBJECT(tree), EWL_FLAG_FILL_FILL);
ewl_object_minimum_w_set(EWL_OBJECT(tree), 180);
ewl_container_child_prepend(EWL_CONTAINER(c), tree);
ewl_widget_show(tree);
@ -142,25 +142,6 @@ add_rc_menu(Ewl_Widget *w, void *event, void *data)
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)
{
@ -197,7 +178,7 @@ populate_albums(Ewl_Widget *w, void *event, void *data)
static void
populate_images(Ewl_Widget *w, void *event, void *data)
{
pthread_t thumb_worker, image_worker;
pthread_t image_worker;
int ret1;
if (!ecore_list_empty_is(em->images))
@ -213,45 +194,11 @@ populate_images(Ewl_Widget *w, void *event, void *data)
}
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_join(thumb_worker, NULL);
ewl_mvc_data_set(EWL_MVC(em->fbox), em->images);
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()
{

View File

@ -21,7 +21,8 @@ ephoto_db_init(void)
images_list = ecore_dlist_new();
image_ids = ecore_list_new();
snprintf(path, PATH_MAX, "%s/.ephoto/.ephoto_database", getenv("HOME"));
snprintf(path, PATH_MAX, "%s/.ephoto/.ephoto_database",
getenv("HOME"));
snprintf(path2, PATH_MAX, "%s/.ephoto", getenv("HOME"));
if (!ecore_file_exists(path))

View File

@ -1,8 +1,6 @@
#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 void
close_dialog(Ewl_Widget *w, void *event, void *data)
@ -17,13 +15,15 @@ close_dialog(Ewl_Widget *w, void *event, void *data)
void
about_dialog(Ewl_Widget *w, void *event, void *data)
{
char *txt, title[PATH_MAX];
Ewl_Widget *window, *button, *image, *vbox, *sp, *text;
window = add_window("About Ephoto", 200, 300, NULL, NULL);
window = add_window("About Ephoto", 300, 375, NULL, NULL);
ewl_window_dialog_set(EWL_WINDOW(window), TRUE);
ewl_callback_append(window, EWL_CALLBACK_DELETE_WINDOW, close_dialog,
window);
vbox = add_box(window, EWL_ORIENTATION_VERTICAL, 3);
vbox = add_box(window, EWL_ORIENTATION_VERTICAL, 0);
ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL);
image = add_image(vbox, PACKAGE_DATA_DIR "/images/photo_lens.png", 0,
@ -33,20 +33,33 @@ about_dialog(Ewl_Widget *w, void *event, void *data)
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(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"
"images in a fullscreen mode, and view images in a\n"
"slideshow. The edit view offers simple and advanced\n"
"editing options.");
snprintf(title, PATH_MAX, "Ephoto - Version %s", VERSION);
txt = "Ephoto is a photo management application that "
"organizes images and allows viewing and editing of "
"them. It includes a standard thumbnail browser "
"and a single picture browser that allows for "
"editing. Features include viewing exif data, "
"viewing slideshows, and exporting your images.";
text = ewl_text_new();
ewl_text_wrap_set(EWL_TEXT(text), EWL_TEXT_WRAP_WORD);
ewl_object_alignment_set(EWL_OBJECT(text), EWL_FLAG_ALIGN_CENTER);
ewl_text_font_source_set(EWL_TEXT(text), ewl_theme_path_get(),
"ewl/default/bold");
ewl_text_font_size_set(EWL_TEXT(text), 20);
ewl_text_align_set(EWL_TEXT(text), EWL_FLAG_ALIGN_CENTER);
ewl_text_styles_set(EWL_TEXT(text), EWL_TEXT_STYLE_SOFT_SHADOW);
ewl_text_text_append(EWL_TEXT(text), title);
ewl_text_align_set(EWL_TEXT(text), EWL_FLAG_ALIGN_LEFT);
ewl_text_styles_set(EWL_TEXT(text), EWL_TEXT_STYLE_NONE);
ewl_text_font_set(EWL_TEXT(text), NULL);
ewl_text_font_size_set(EWL_TEXT(text), 14);
ewl_text_text_append(EWL_TEXT(text), "\n\n");
ewl_text_text_append(EWL_TEXT(text), txt);
ewl_container_child_append(EWL_CONTAINER(sp), text);
ewl_widget_show(text);
button = add_button(vbox, "Close",
PACKAGE_DATA_DIR "/images/dialog-close.png",
@ -57,48 +70,3 @@ about_dialog(Ewl_Widget *w, void *event, void *data)
return;
}
static void
add_ok(Ewl_Widget *w, void *event, void *data)
{
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)
{
ephoto_db_add_album(em->db, name, desc);
populate_albums(NULL, NULL, NULL);
}
ewl_widget_destroy(win);
}
void
add_album_dialog(Ewl_Widget *w, void *event, void *data)
{
Ewl_Widget *window, *vbox, *hbox;
window = add_window("Add Album", 340, 160, NULL, NULL);
ewl_callback_append(window, EWL_CALLBACK_DELETE_WINDOW, close_dialog,
window);
vbox = add_box(window, EWL_ORIENTATION_VERTICAL, 5);
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);
hbox = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 5);
ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_SHRINK);
add_button(hbox, "Save", NULL, add_ok, window);
add_button(hbox, "Cancel", NULL, close_dialog, window);
}

View File

@ -170,7 +170,7 @@ add_text(Ewl_Widget *c, char *txt)
Ewl_Widget *text;
text = ewl_text_new();
if(txt) ewl_text_text_set(EWL_TEXT(text), _(txt));
if(txt) ewl_text_text_append(EWL_TEXT(text), _(txt));
ewl_object_alignment_set(EWL_OBJECT(text),
EWL_FLAG_ALIGN_CENTER);
if(c) ewl_container_child_append(EWL_CONTAINER(c), text);
@ -180,18 +180,17 @@ add_text(Ewl_Widget *c, char *txt)
}
Ewl_Widget *
add_window(char *name, int w, int h, void *cb, void *data)
add_window(char *title, int w, int h, void *cb, void *data)
{
Ewl_Widget *win;
win = ewl_window_new();
if(name)
{
ewl_window_title_set(EWL_WINDOW(win), _(name));
ewl_window_name_set(EWL_WINDOW(win), _(name));
}
if(w && h) ewl_object_size_request(EWL_OBJECT(win), w, h);
if(cb) ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW,
if(title)
ewl_window_title_set(EWL_WINDOW(win), _(title));
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);

View File

@ -1,5 +1,6 @@
#include "ephoto.h"
Ephoto_Main *em;
static void destroy(Ewl_Widget *w, void *event, void *data);
static void
@ -14,13 +15,6 @@ destroy(Ewl_Widget *w, void *event, void *data)
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;
}
@ -28,36 +22,43 @@ destroy(Ewl_Widget *w, void *event, void *data)
void
create_main(void)
{
const char *type;
char buf[PATH_MAX];
Ewl_Widget *hbox, *vbox;
Ewl_Widget *hbox, *mbar, *menu, *vbox;
if (ec->requested_image)
{
type = efreet_mime_type_get(ec->requested_image);
if ((ecore_hash_get(em->types, type)) != "image")
ec->requested_image = NULL;
}
em = NULL;
em = calloc(1, sizeof(Ephoto_Main));
if (ec->requested_album)
em->current_album = strdup(ec->requested_album);
else
em->current_album = strdup("Complete Library");
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");
em->current_album = strdup("Complete Library");
em->db = ephoto_db_init();
if (ec->requested_directory)
em->current_directory = strdup(ec->requested_directory);
else
{
getcwd(buf, PATH_MAX);
em->current_directory = strdup(buf);
}
getcwd(buf, PATH_MAX);
em->current_directory = strdup(buf);
em->win = add_window("Ephoto!", 715, 500, destroy, NULL);
em->win = add_window("Ephoto - Photo Management", 600, 400, destroy, NULL);
vbox = add_box(em->win, EWL_ORIENTATION_VERTICAL, 5);
ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL);
mbar = add_menubar(vbox);
menu = add_menu(mbar, "File");
add_menu_item(menu, "Exit",
PACKAGE_DATA_DIR "/images/exit.png", destroy, NULL);
menu = add_menu(mbar, "Help");
add_menu_item(menu, "About",
PACKAGE_DATA_DIR "/images/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);
@ -70,16 +71,8 @@ create_main(void)
ewl_container_child_append(EWL_CONTAINER(em->view), em->view_box);
ewl_widget_show(em->view_box);
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);
}
add_normal_view(em->view_box);
add_single_view(em->view_box);
return;
}

View File

@ -1,29 +1,54 @@
#include "ephoto.h"
static void change_size(Ewl_Widget *w, void *event, void *data);
static void thumb_clicked(Ewl_Widget *w, void *event, void *data);
static void
change_size(Ewl_Widget *w, void *event, void *data)
{
Ewl_Widget *child;
ewl_container_child_iterate_begin(EWL_CONTAINER(em->fbox));
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_widget_reparent(child);
}
ewl_widget_configure(em->fbox_vbox);
ewl_mvc_dirty_set(EWL_MVC(em->fbox), TRUE);
ewl_widget_configure(em->scroll);
return;
}
static void
thumb_clicked(Ewl_Widget *w, void *event, void *data)
{
const char *file;
Ewl_Event_Mouse_Down *ev;
ev = event;
if (ev->clicks == 2)
{
file = ewl_widget_name_get(w);
show_single_view(NULL, NULL, NULL);
}
}
static Ewl_Widget *
fbox_widget_fetch(void *data, unsigned int row, unsigned int column)
{
char *imagef;
Ewl_Widget *image;
imagef = data;
image = add_image(NULL, imagef, 1, thumb_clicked, NULL);
ewl_image_constrain_set(EWL_IMAGE(image),
ewl_range_value_get(EWL_RANGE(em->fthumb_size)));
ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_CENTER);
ewl_widget_name_set(image, imagef);
return image;
}
Ewl_Widget *
add_normal_view(Ewl_Widget *c)
{
Ewl_Widget *avbox, *box, *button, *hbox, *image, *sp, *vbox;
Ewl_Widget *avbox, *box, *button, *hbox, *image, *vbox;
Ewl_View *view;
em->fbox_vbox = add_box(c, EWL_ORIENTATION_VERTICAL, 5);
ewl_object_fill_policy_set(EWL_OBJECT(em->fbox_vbox),
@ -31,38 +56,43 @@ add_normal_view(Ewl_Widget *c)
ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(c), em->fbox_vbox,
"Normal");
hbox = ewl_hbox_new();
hbox = add_box(em->fbox_vbox, EWL_ORIENTATION_HORIZONTAL, 5);
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);
avbox = add_box(hbox, EWL_ORIENTATION_VERTICAL, 2);
ewl_object_fill_policy_set(EWL_OBJECT(avbox), EWL_FLAG_FILL_VFILL);
ewl_object_minimum_w_set(EWL_OBJECT(avbox), 220);
box = add_box(avbox, 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);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_NONE);
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);
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_NONE);
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(vbox), sp);
ewl_widget_show(sp);
em->scroll = ewl_scrollpane_new();
ewl_container_child_append(EWL_CONTAINER(vbox), em->scroll);
ewl_widget_show(em->scroll);
em->fbox = ewl_hfreebox_new();
ewl_freebox_layout_type_set(EWL_FREEBOX(em->fbox),
EWL_FREEBOX_LAYOUT_AUTO);
view = ewl_view_new();
ewl_view_widget_fetch_set(view, fbox_widget_fetch);
em->fbox = ewl_hfreebox_mvc_new();
ewl_mvc_model_set(EWL_MVC(em->fbox), ewl_model_ecore_list_instance());
ewl_mvc_view_set(EWL_MVC(em->fbox), view);
ewl_mvc_selection_mode_set(EWL_MVC(em->fbox), EWL_SELECTION_MODE_SINGLE);
ewl_object_fill_policy_set(EWL_OBJECT(em->fbox), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(sp), em->fbox);
ewl_container_child_append(EWL_CONTAINER(em->scroll), em->fbox);
ewl_widget_show(em->fbox);
show_albums(avbox);
box = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 10);
ewl_object_fill_policy_set(EWL_OBJECT(box), EWL_FLAG_FILL_SHRINK);
@ -80,8 +110,6 @@ add_normal_view(Ewl_Widget *c)
ewl_object_maximum_size_set(EWL_OBJECT(em->fthumb_size), 160, 40);
ewl_widget_show(em->fthumb_size);
show_albums(avbox);
image = add_image(box, PACKAGE_DATA_DIR "/images/image.png", 0, NULL, NULL);
ewl_image_constrain_set(EWL_IMAGE(image), 32);

View File

@ -16,19 +16,16 @@ 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);
static void set_image_file(Ewl_Widget *w, void *event, void *data);
static void
set_requested_image_file(Ewl_Widget *w, void *event, void *data)
{
ewl_image_file_path_set(EWL_IMAGE(w), ec->requested_image);
}
static void
set_image_file(Ewl_Widget *w, void *event, void *data)
{
ewl_image_file_path_set(EWL_IMAGE(w), ecore_dlist_current(em->images));
Ewl_Selection_Idx *i;
i = ewl_mvc_selected_get(EWL_MVC(em->fbox));
ewl_image_file_path_set(EWL_IMAGE(w), ecore_dlist_index_goto(em->images, i->row));
ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_NONE);
ewl_callback_del(w, EWL_CALLBACK_CONFIGURE, set_image_file);
}
@ -36,8 +33,7 @@ set_image_file(Ewl_Widget *w, void *event, void *data)
Ewl_Widget *
add_single_view(Ewl_Widget *c)
{
Ewl_Widget *vbox, *ibox, *hbox, *image, *bhbox;
Ewl_Widget *standard, *advanced;
Ewl_Widget *ibox, *bhbox;
em->ewin = NULL;
@ -45,29 +41,9 @@ add_single_view(Ewl_Widget *c)
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);
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(vbox), ibox);
ewl_object_fill_policy_set(EWL_OBJECT(ibox), EWL_FLAG_FILL_SHRINK);
ewl_container_child_append(EWL_CONTAINER(em->single_vbox), ibox);
ewl_widget_show(ibox);
em->simage = add_image(ibox, NULL, 0, NULL, NULL);
@ -75,35 +51,12 @@ add_single_view(Ewl_Widget *c)
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);
bhbox = add_box(em->single_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);
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"));
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);
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);
add_standard_edit_tools(bhbox);
return em->single_vbox;
}
@ -124,37 +77,79 @@ show_single_view(Ewl_Widget *w, void *event, void *data)
static void
add_standard_edit_tools(Ewl_Widget *c)
{
Ewl_Widget *image;
Ewl_Widget *button;
image = add_image(c, PACKAGE_DATA_DIR "/images/in.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);
button = add_button(c, NULL,
PACKAGE_DATA_DIR "/images/in.png",
zoom_in, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 22, 22);
ewl_attach_tooltip_text_set(button, _("Zoom In"));
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_NONE);
image = add_image(c, PACKAGE_DATA_DIR "/images/out.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);
button = add_button(c, NULL,
PACKAGE_DATA_DIR "/images/out.png",
zoom_out, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 22, 22);
ewl_attach_tooltip_text_set(button, _("Zoom Out"));
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_NONE);
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);
button = add_button(c, NULL,
PACKAGE_DATA_DIR "/images/undo.png",
rotate_image_left, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 22, 22);
ewl_attach_tooltip_text_set(button, _("Rotate Left"));
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_NONE);
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);
button = add_button(c, NULL,
PACKAGE_DATA_DIR "/images/redo.png",
rotate_image_right, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 22, 22);
ewl_attach_tooltip_text_set(button, _("Rotate Right"));
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_NONE);
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);
button = add_button(c, NULL,
PACKAGE_DATA_DIR "/images/go-next.png",
flip_image_horizontal, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 22, 22);
ewl_attach_tooltip_text_set(button, _("Flip Horizontally"));
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_NONE);
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);
button = add_button(c, NULL,
PACKAGE_DATA_DIR "/images/go-down.png",
flip_image_vertical, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 22, 22);
ewl_attach_tooltip_text_set(button, _("Flip Vertically"));
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_NONE);
button = add_button(c, NULL,
PACKAGE_DATA_DIR "/images/camera-photo.png",
show_advanced, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 22, 22);
ewl_attach_tooltip_text_set(button, _("Advanced Tools"));
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_NONE);
button = add_button(c, NULL,
PACKAGE_DATA_DIR "/images/media-seek-backward.png",
previous_image, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 22, 22);
ewl_attach_tooltip_text_set(button, _("Previous Image"));
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_NONE);
button = add_button(c, NULL,
PACKAGE_DATA_DIR "/images/media-seek-forward.png",
next_image, NULL);
ewl_button_image_size_set(EWL_BUTTON(button), 22, 22);
ewl_attach_tooltip_text_set(button, _("Next Image"));
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_NONE);
return;
}
@ -169,49 +164,24 @@ destroy(Ewl_Widget *w, void *event, void *data)
static void
show_advanced(void)
{
const char *file;
Epsilon *ep;
Ewl_Widget *grid, *image;
Ewl_Widget *fbox, *button;
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 Advanced Image Tools!",
240, 185, destroy, NULL);
em->ewin = add_window("Ephoto Effects!", 375, 100, destroy, NULL);
fbox = ewl_hfreebox_new();
ewl_object_alignment_set(EWL_OBJECT(fbox), EWL_FLAG_ALIGN_CENTER);
ewl_object_fill_policy_set(EWL_OBJECT(fbox), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(em->ewin), fbox);
ewl_widget_show(fbox);
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);
button = add_button(fbox, "Grayscale", NULL, image_grayscale, em->simage);
button = add_button(fbox, "Sepia", NULL, image_sepia, em->simage);
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);
button = add_button(fbox, "Blur", NULL, image_blur, em->simage);
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);
button = add_button(fbox, "Sharpen", NULL, image_sharpen, em->simage);
return;
}