More abstraction. This makes things easier and faster.

SVN revision: 29234
This commit is contained in:
titan 2007-03-30 00:45:12 +00:00 committed by titan
parent 28c75ad4b1
commit 9c788c1691
9 changed files with 127 additions and 128 deletions

View File

@ -62,7 +62,6 @@ data
item: "/tooltip/group" "/ephoto/window";
item: "/tooltip/hoffset" "5";
item: "/tooltip/voffset" "5";
item: "/tree2/vbox/scrollpane/overlay/vbox/node/row/cell/hbox/group" "/ephoto/select";
item: "/vscrollbar/decrement/group" "/ephoto/vscrollbar/decrement";
item: "/vscrollbar/increment/group" "/ephoto/vscrollbar/increment";
item: "/vseeker/group" "/ephoto/vrunner";

View File

@ -25,16 +25,16 @@
/* NLS */
#ifdef ENABLE_NLS
# include <libintl.h>
# include <locale.h>
# define _(str) gettext(str)
# define gettext_noop(str) str
# define N_(str) gettext_noop(str)
#include <libintl.h>
#include <locale.h>
#define _(str) gettext(str)
#define gettext_noop(str) str
#define N_(str) gettext_noop(str)
#else
# define _(str) (str)
# define gettext_noop(str) str
# define N_(str) gettext_noop(str)
# define gettext(str) ((char*) (str))
#define _(str) (str)
#define gettext_noop(str) str
#define N_(str) gettext_noop(str)
#define gettext(str) ((char*) (str))
#endif
/* NLS callbacks */
@ -65,11 +65,16 @@ Ecore_List *ephoto_db_list_images(sqlite3 *db, const char *album);
void ephoto_db_close(sqlite3 *db);
/* Ephoto Gui */
Ewl_Widget *add_box(Ewl_Widget *c, Ewl_Orientation orientation, int spacing);
Ewl_Widget *add_button(Ewl_Widget *c, const char *txt, const char *img, void *cb, void *data);
Ewl_Widget *add_entry(Ewl_Widget *c, const char *txt, void *cb, void *data);
Ewl_Widget *add_image(Ewl_Widget *c, const char *img, int thumbnail, void *cb, void *data);
Ewl_Widget *add_label(Ewl_Widget *c, const char *lbl);
Ewl_Widget *add_menubar(Ewl_Widget *c);
Ewl_Widget *add_menu(Ewl_Widget *c, const char *lbl);
Ewl_Widget *add_text(Ewl_Widget *c, const char *text);
Ewl_Widget *add_shadow(Ewl_Widget *c);
Ewl_Widget *add_window(const char *name, int width, int height, void *cb, void *data);
/* Ephoto Imaging */
unsigned int *flip_horizontal(Ewl_Widget *image);
@ -118,7 +123,6 @@ struct _Ephoto_Main
Ewl_Widget *fbox;
Ewl_Widget *list_vbox;
Ewl_Widget *ltree;
Ewl_Widget *tbar;
Ewl_Widget *toolbar;
Ewl_Widget *view_box;
Ewl_Widget *win;

View File

@ -11,10 +11,8 @@ static void rotate_image_right(Ewl_Widget *w, void *event, void *data);
/*Add the edit view*/
Ewl_Widget *add_edit_view(Ewl_Widget *c)
{
em->edit_vbox = ewl_vbox_new();
em->edit_vbox = add_box(c, EWL_ORIENTATION_VERTICAL, 5);
ewl_object_fill_policy_set(EWL_OBJECT(em->edit_vbox), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(c), em->edit_vbox);
ewl_widget_show(em->edit_vbox);
ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(c), em->edit_vbox, "Edit");
em->eimage = add_image(em->edit_vbox, NULL, 0, NULL, NULL);

View File

@ -124,7 +124,7 @@ static void add_exif_to_container(Ewl_Widget *w, void *event, void *data)
void display_exif_dialog(Ewl_Widget *w, void *event, void *data)
{
const char *img;
Ewl_Widget *win, *vbox, *image, *sp, *list, *text;
Ewl_Widget *win = NULL, *vbox, *image, *sp, *list, *text;
Ewl_Model *model;
Ewl_View *view;
@ -134,18 +134,11 @@ void display_exif_dialog(Ewl_Widget *w, void *event, void *data)
return;
}
win = ewl_window_new();
ewl_window_title_set(EWL_WINDOW(win), "Ephoto Exif Info");
ewl_window_name_set(EWL_WINDOW(win), "Ephoto Exif Info");
win = add_window("Ephoto Exif Info", 310, 460, close_dialog, win);
ewl_window_dialog_set(EWL_WINDOW(win), 1);
ewl_object_size_request(EWL_OBJECT(win), 310, 460);
ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, close_dialog, win);
ewl_widget_show(win);
vbox = ewl_vbox_new();
vbox = add_box(win, EWL_ORIENTATION_VERTICAL, 5);
ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(win), vbox);
ewl_widget_show(vbox);
text = add_text(vbox, "Preview");

View File

@ -1,31 +1,50 @@
#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 *box;
box = ewl_box_new();
if(orientation) ewl_box_orientation_set(EWL_BOX(box), orientation);
if(spacing) ewl_box_spacing_set(EWL_BOX(box), spacing);
if(c) ewl_container_child_append(EWL_CONTAINER(c), box);
ewl_widget_show(box);
return box;
}
/*Create and Add a Button to the Container c*/
Ewl_Widget *add_button(Ewl_Widget *c, const char *txt, const char *img, void *cb, void *data)
{
Ewl_Widget *button;
button = ewl_button_new();
if (img)
{
ewl_button_image_set(EWL_BUTTON(button), img, NULL);
}
if (txt)
{
ewl_button_label_set(EWL_BUTTON(button), _(txt));
}
if(img) ewl_button_image_set(EWL_BUTTON(button), img, NULL);
if(txt) ewl_button_label_set(EWL_BUTTON(button), _(txt));
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_CENTER);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK);
ewl_container_child_append(EWL_CONTAINER(c), button);
if (cb)
{
ewl_callback_append(button, EWL_CALLBACK_CLICKED, cb, data);
}
if(c) ewl_container_child_append(EWL_CONTAINER(c), button);
if(cb) ewl_callback_append(button, EWL_CALLBACK_CLICKED, cb, data);
ewl_widget_show(button);
return button;
}
/*Create and Add an Entry to Container c With Text txt and the Callback cb*/
Ewl_Widget *add_entry(Ewl_Widget *c, const char *txt, void *cb, void *data)
{
Ewl_Widget *entry;
entry = ewl_entry_new();
if(txt) ewl_text_text_set(EWL_TEXT(entry), txt);
if(c) ewl_container_child_append(EWL_CONTAINER(c), entry);
if(cb) ewl_callback_append(entry, EWL_CALLBACK_VALUE_CHANGED, cb, data);
ewl_widget_show(entry);
return entry;
}
/*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)
{
@ -35,11 +54,7 @@ Ewl_Widget *add_image(Ewl_Widget *c, const char *img, int thumbnail, void *cb, v
if(!thumbnail)
{
image = ewl_image_new();
if (img)
{
ewl_image_file_path_set(EWL_IMAGE(image), img);
}
if(img) ewl_image_file_path_set(EWL_IMAGE(image), img);
}
else
{
@ -48,72 +63,107 @@ Ewl_Widget *add_image(Ewl_Widget *c, const char *img, int thumbnail, void *cb, v
{
image = ewl_image_thumbnail_new();
ewl_image_file_path_set(EWL_IMAGE(image), PACKAGE_DATA_DIR "/images/image.png");
if (img)
{
ewl_image_thumbnail_request(EWL_IMAGE_THUMBNAIL(image), img);
}
if(img) ewl_image_thumbnail_request(EWL_IMAGE_THUMBNAIL(image), img);
}
else
{
image = ewl_image_new();
if (img)
{
ewl_image_file_path_set(EWL_IMAGE(image), img);
}
if(img) ewl_image_file_path_set(EWL_IMAGE(image), img);
}
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_container_child_append(EWL_CONTAINER(c), image);
if (cb)
{
ewl_callback_append(image, EWL_CALLBACK_CLICKED, cb, data);
}
if(c) ewl_container_child_append(EWL_CONTAINER(c), image);
if(cb) ewl_callback_append(image, EWL_CALLBACK_CLICKED, cb, data);
ewl_widget_show(image);
return image;
}
/*Add a label to the container c, with the text lbl, and whether you want it blue*/
/*Create and Add a Label to the Container c, With the Text lbl*/
Ewl_Widget *add_label(Ewl_Widget *c, const char *lbl)
{
Ewl_Widget *label;
label = ewl_label_new();
ewl_label_text_set(EWL_LABEL(label), lbl);
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_container_child_append(EWL_CONTAINER(c), label);
if(c) ewl_container_child_append(EWL_CONTAINER(c), label);
ewl_widget_show(label);
return label;
}
/*Add a text widget to the container c*/
/*Create and Add a Menubar to the Container 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);
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, const char *lbl)
{
Ewl_Widget *menu;
menu = ewl_menu_new();
if(lbl) ewl_label_text_set(EWL_LABEL(menu), lbl);
if(c) ewl_container_child_append(EWL_CONTAINER(c), menu);
ewl_widget_show(menu);
return menu;
}
/*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, const char *txt)
{
Ewl_Widget *text;
text = ewl_text_new();
ewl_text_text_set(EWL_TEXT(text), txt);
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_container_child_append(EWL_CONTAINER(c), text);
if(c) ewl_container_child_append(EWL_CONTAINER(c), text);
ewl_widget_show(text);
return text;
}
/*Add a shadow to the container c*/
Ewl_Widget *add_shadow(Ewl_Widget *c)
/*Create and Add a Window*/
Ewl_Widget *add_window(const char *name, int width, int height, void *cb, void *data)
{
Ewl_Widget *shadow;
Ewl_Widget *win;
shadow = ewl_shadow_new();
ewl_container_child_append(EWL_CONTAINER(c), shadow);
ewl_widget_show(shadow);
win = ewl_window_new();
if(name)
{
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);
ewl_widget_show(win);
return shadow;
return win;
}

View File

@ -8,10 +8,8 @@ static int list_data_count(void *data);
/*Add the list view*/
Ewl_Widget *add_list_view(Ewl_Widget *c)
{
em->list_vbox = ewl_vbox_new();
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_container_child_append(EWL_CONTAINER(c), em->list_vbox);
ewl_widget_show(em->list_vbox);
ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(c), em->list_vbox, "List");
em->ltree = add_ltree(em->list_vbox);
@ -71,12 +69,10 @@ static Ewl_Widget *list_view_new(void *data, int row, int column)
image_pixels_string_get(image),
file_size_get(size));
hbox = ewl_hbox_new();
ewl_box_spacing_set(EWL_BOX(hbox), 10);
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, show_edit_view, strdup(image));
ewl_widget_name_set(hbox, image);
ewl_widget_show(hbox);
img = add_image(hbox, image, 1, NULL, NULL);
ewl_image_constrain_set(EWL_IMAGE(img), 64);
@ -93,9 +89,7 @@ static Ewl_Widget *list_header_fetch(void *data, int column)
{
Ewl_Widget *label;
label = ewl_label_new();
ewl_label_text_set(EWL_LABEL(label), "Images");
ewl_widget_show(label);
label = add_label(NULL, "Images");
return label;
}

View File

@ -48,60 +48,32 @@ static void window_fullscreen(Ewl_Widget *w, void *event, void *data)
/*Create the Main Ephoto Window*/
void create_main_gui(void)
{
Ewl_Widget *vbox, *entry, *hbox;
Ewl_Widget *rvbox, *hsep, *vsep, *button;
Ewl_Widget *vbox, *hbox, *hsep, *vsep, *button;
Ewl_Widget *mb, *menu;
em = NULL;
em = calloc(1, sizeof(Ephoto_Main));
em->albums = ecore_list_new();
em->images = ecore_dlist_new();
em->win = ewl_window_new();
ewl_window_title_set(EWL_WINDOW(em->win), "Ephoto!");
ewl_window_name_set(EWL_WINDOW(em->win), "Ephoto!");
ewl_object_size_request(EWL_OBJECT(em->win), 777, 542);
ewl_callback_append(em->win, EWL_CALLBACK_DELETE_WINDOW, destroy, NULL);
ewl_widget_show(em->win);
em->win = add_window("Ephoto!", 775, 540, destroy, NULL);
vbox = ewl_vbox_new();
ewl_box_spacing_set(EWL_BOX(vbox), 5);
vbox = add_box(em->win, EWL_ORIENTATION_VERTICAL, 5);
ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(em->win), vbox);
ewl_widget_show(vbox);
em->tbar = ewl_hbox_new();
ewl_object_fill_policy_set(EWL_OBJECT(em->tbar), EWL_FLAG_FILL_SHRINK);
ewl_object_alignment_set(EWL_OBJECT(em->tbar), EWL_FLAG_ALIGN_RIGHT);
ewl_container_child_append(EWL_CONTAINER(vbox), em->tbar);
ewl_widget_show(em->tbar);
mb = add_menubar(vbox);
menu = add_menu(mb, "File");
entry = ewl_entry_new();
ewl_object_minimum_size_set(EWL_OBJECT(entry), 157, 22);
ewl_object_maximum_size_set(EWL_OBJECT(entry), 157, 22);
ewl_container_child_append(EWL_CONTAINER(em->tbar), entry);
ewl_widget_show(entry);
add_button(em->tbar, "Find", NULL, NULL, NULL);
hbox = ewl_hbox_new();
ewl_box_spacing_set(EWL_BOX(hbox), 2);
hbox = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 2);
ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(vbox), hbox);
ewl_widget_show(hbox);
em->atree = add_atree(hbox);
ewl_object_maximum_w_set(EWL_OBJECT(em->atree), 172);
rvbox = ewl_vbox_new();
ewl_box_spacing_set(EWL_BOX(rvbox), 1);
ewl_object_fill_policy_set(EWL_OBJECT(rvbox), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(hbox), rvbox);
ewl_widget_show(rvbox);
em->view_box = ewl_notebook_new();
ewl_notebook_tabbar_visible_set(EWL_NOTEBOOK(em->view_box), 0);
ewl_object_fill_policy_set(EWL_OBJECT(em->view_box), EWL_FLAG_FILL_ALL);
ewl_container_child_append(EWL_CONTAINER(rvbox), em->view_box);
ewl_container_child_append(EWL_CONTAINER(hbox), em->view_box);
ewl_widget_show(em->view_box);
add_normal_view(em->view_box);
@ -114,13 +86,10 @@ void create_main_gui(void)
ewl_container_child_append(EWL_CONTAINER(vbox), hsep);
ewl_widget_show(hsep);
em->toolbar = ewl_htoolbar_new();
ewl_box_spacing_set(EWL_BOX(em->toolbar), 5);
em->toolbar = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 1);
ewl_object_minimum_h_set(EWL_OBJECT(em->toolbar), 30);
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);
ewl_container_child_append(EWL_CONTAINER(vbox), em->toolbar);
ewl_widget_show(em->toolbar);
button = add_button(em->toolbar, NULL, PACKAGE_DATA_DIR "/images/normal_view.png", show_normal_view, NULL);
ewl_image_size_set(EWL_IMAGE(EWL_BUTTON(button)->image_object), 30, 30);
@ -260,9 +229,7 @@ static Ewl_Widget *album_header_fetch(void *data, int column)
{
Ewl_Widget *label;
label = ewl_label_new();
ewl_label_text_set(EWL_LABEL(label), "Browser");
ewl_widget_show(label);
label = add_label(NULL, "Browser");
return label;
}

View File

@ -5,10 +5,8 @@ Ewl_Widget *add_normal_view(Ewl_Widget *c)
{
Ewl_Widget *sp;
em->fbox_vbox = ewl_vbox_new();
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_container_child_append(EWL_CONTAINER(c), em->fbox_vbox);
ewl_widget_show(em->fbox_vbox);
ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(c), em->fbox_vbox, "Normal");
sp = ewl_scrollpane_new();

View File

@ -52,13 +52,9 @@ void start_slideshow(Ewl_Widget *w, void *event, void *data)
{
Ewl_Widget *cell, *image;
win = ewl_window_new();
ewl_window_title_set(EWL_WINDOW(win), "Ephoto Slideshow!");
ewl_window_name_set(EWL_WINDOW(win), "Ephoto Slideshow!");
win = add_window("Ephoto Slideshow!", 600, 400, destroy, NULL);
ewl_window_fullscreen_set(EWL_WINDOW(win), 1);
ewl_callback_append(win, EWL_CALLBACK_CLICKED, destroy, NULL);
ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, destroy, NULL);
ewl_widget_show(win);
cell = ewl_cell_new();
ewl_object_fill_policy_set(EWL_OBJECT(cell), EWL_FLAG_FILL_ALL);