Several cleanups, changes. The browser is now in its own window.
SVN revision: 31714
This commit is contained in:
parent
2f9dec93e6
commit
369fd1a164
|
@ -7,6 +7,7 @@ bin_PROGRAMS = ephoto
|
|||
|
||||
ephoto_SOURCES = ephoto.c \
|
||||
ephoto_browsing.c \
|
||||
ephoto_browser.c \
|
||||
ephoto_database.c \
|
||||
ephoto_dialogs.c \
|
||||
ephoto_edit_view.c \
|
||||
|
@ -21,9 +22,9 @@ ephoto_SOURCES = ephoto.c \
|
|||
ephoto_slideshow.c \
|
||||
ephoto_utils.c
|
||||
|
||||
ephoto_CFLAGS = @EWL_CFLAGS@ @SQLITE_CFLAGS@ @EXIF_CFLAGS@ -Wall
|
||||
ephoto_CFLAGS = @EWL_CFLAGS@ @SQLITE_CFLAGS@ @EXIF_CFLAGS@ @EFREET_MIME_CFLAGS@ -Wall
|
||||
|
||||
ephoto_LDADD = @EWL_LIBS@ @SQLITE_LIBS@ @EXIF_LIBS@
|
||||
ephoto_LDADD = @EWL_LIBS@ @SQLITE_LIBS@ @EXIF_LIBS@ @EFREET_MIME_LIBS@
|
||||
|
||||
EXTRA_DIST = \
|
||||
ephoto.h
|
||||
|
|
278
src/bin/ephoto.c
278
src/bin/ephoto.c
|
@ -2,11 +2,6 @@
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *album, *name, *description, *path, input;
|
||||
int i;
|
||||
Ecore_List *albums, *images;
|
||||
sqlite3 *db;
|
||||
|
||||
/*Check to make sure EWL is accessible*/
|
||||
if (!ewl_init(&argc, argv))
|
||||
{
|
||||
|
@ -14,276 +9,6 @@ int main(int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
for(i = 0; i < argc; i++)
|
||||
{
|
||||
if(!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
|
||||
{
|
||||
printf("Ephoto Version %s Help Page\n", VERSION);
|
||||
printf("Long Commands: \n"
|
||||
" --help - This Screen\n"
|
||||
" --add-album %%s %%s - Adds Album\n"
|
||||
" arg1 = name of album\n"
|
||||
" arg2 = description of album\n"
|
||||
" --add-image %%s %%s %%s - Adds Image\n"
|
||||
" arg1 = name of album to add image to\n"
|
||||
" arg2 = descriptive name for image\n"
|
||||
" arg3 = path to the image\n"
|
||||
" --add-image-dir %%s %%s - Adds All Images From Directory\n"
|
||||
" arg1 = name of album to add images to\n"
|
||||
" arg2 = directory to get images from\n"
|
||||
" --list-albums - List Albums\n"
|
||||
" --list-images %%s - List Images in Album\n"
|
||||
" arg1 = name of album to list images from\n"
|
||||
" --remove-album %%s - Removes Album\n"
|
||||
" arg1 = name of album\n"
|
||||
" --remove-image %%s %%s - Removes Image\n"
|
||||
" arg1 = name of album to remove image from\n"
|
||||
" arg2 = path of the image to be removed\n");
|
||||
printf("Short Commands: \n"
|
||||
" -h - This Screen\n"
|
||||
" -a %%s %%s - Adds Album\n"
|
||||
" -i %%s %%s %%s - Adds Image\n"
|
||||
" -id %%s %%s - Adds all Images From Directory\n"
|
||||
" -la - List Albums\n"
|
||||
" -li %%s - List Images in Album\n"
|
||||
" -ra %%s - Removes Album\n"
|
||||
" -ri %%s %%s - Removes Image\n");
|
||||
return 0;
|
||||
}
|
||||
if(!strcmp(argv[i], "--add-album") || !strcmp(argv[i], "-a"))
|
||||
{
|
||||
i++;
|
||||
if(argv[i]) name = argv[i];
|
||||
else
|
||||
{
|
||||
printf("Please specify a name for the album\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
i++;
|
||||
if(argv[i]) description = argv[i];
|
||||
else
|
||||
{
|
||||
printf("Please specify a description for the album\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Are you sure you want to create an album with "
|
||||
"the name %s and the description %s? ",
|
||||
name, description);
|
||||
int ret = scanf("%c", &input);
|
||||
if(!ret || ret == EOF)
|
||||
{
|
||||
printf("read error\n");
|
||||
return 1;
|
||||
}
|
||||
if(input == 'y' || input == 'Y')
|
||||
{
|
||||
db = ephoto_db_init();
|
||||
ephoto_db_add_album(db, name, description);
|
||||
ephoto_db_close(db);
|
||||
printf("Album was created\n");
|
||||
}
|
||||
else printf("Album was not created\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
if(!strcmp(argv[i], "--add-image") || !strcmp(argv[i], "-i"))
|
||||
{
|
||||
i++;
|
||||
if(argv[i]) album = argv[i];
|
||||
else
|
||||
{
|
||||
printf("Please specify the album you wish to add to\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
i++;
|
||||
if(argv[i]) name = argv[i];
|
||||
else
|
||||
{
|
||||
printf("Please specify a descriptive name for the image\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
i++;
|
||||
if(argv[i] && ecore_file_exists(argv[i])) path = argv[i];
|
||||
else
|
||||
{
|
||||
printf("Please specify a valid path to the image\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Are you sure you want to add an image "
|
||||
"to album %s with a name %s and path %s? ",
|
||||
album, name, path);
|
||||
int ret = scanf("%c", &input);
|
||||
if(!ret || ret == EOF)
|
||||
{
|
||||
printf("read error\n");
|
||||
return 1;
|
||||
}
|
||||
if(input == 'y' || input == 'Y')
|
||||
{
|
||||
db = ephoto_db_init();
|
||||
ephoto_db_add_image(db, album, name, path);
|
||||
ephoto_db_close(db);
|
||||
printf("Image was added\n");
|
||||
}
|
||||
else printf("Image was not added\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
if(!strcmp(argv[i], "--add-image-dir") || !strcmp(argv[i], "-id"))
|
||||
{
|
||||
i++;
|
||||
if(argv[i]) album = argv[i];
|
||||
else
|
||||
{
|
||||
printf("Please specify the album you wish to add to\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
i++;
|
||||
if(argv[i] && ecore_file_is_dir(argv[i])) path = argv[i];
|
||||
else
|
||||
{
|
||||
printf("Please specify a valid path to the image directory\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Are you sure you want to add images "
|
||||
"from the directory %s to the album %s? ",
|
||||
path, album);
|
||||
int ret = scanf("%c", &input);
|
||||
if(!ret || ret == EOF)
|
||||
{
|
||||
printf("read error\n");
|
||||
return 1;
|
||||
}
|
||||
if(input == 'y' || input == 'Y')
|
||||
{
|
||||
db = ephoto_db_init();
|
||||
images = ecore_list_new();
|
||||
images = get_images(path);
|
||||
while (!ecore_list_empty_is(images))
|
||||
{
|
||||
name = ecore_list_first_remove(images);
|
||||
ephoto_db_add_image(db, album, basename(name), name);
|
||||
}
|
||||
ephoto_db_close(db);
|
||||
ecore_list_destroy(images);
|
||||
printf("Images were added\n");
|
||||
}
|
||||
else printf("Images were not added\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
if(!strcmp(argv[i], "--list-albums") || !strcmp(argv[i], "-la"))
|
||||
{
|
||||
db = ephoto_db_init();
|
||||
albums = ecore_list_new();
|
||||
albums = ephoto_db_list_albums(db);
|
||||
ephoto_db_close(db);
|
||||
while(!ecore_list_empty_is(albums))
|
||||
{
|
||||
album = ecore_list_first_remove(albums);
|
||||
printf("%s\n", album);
|
||||
}
|
||||
ecore_list_destroy(albums);
|
||||
|
||||
return 0;
|
||||
}
|
||||
if(!strcmp(argv[i], "--list-images") || !strcmp(argv[i], "-li"))
|
||||
{
|
||||
i++;
|
||||
if(argv[i]) album = argv[i];
|
||||
else
|
||||
{
|
||||
printf("Please specify the album to list images from\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
db = ephoto_db_init();
|
||||
images = ephoto_db_list_images(db, album);
|
||||
ephoto_db_close(db);
|
||||
while(!ecore_list_empty_is(images))
|
||||
{
|
||||
path = ecore_list_first_remove(images);
|
||||
printf("%s\n", path);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if(!strcmp(argv[i], "--remove-album") || !strcmp(argv[i], "-ra"))
|
||||
{
|
||||
i++;
|
||||
if(argv[i]) name = argv[i];
|
||||
else
|
||||
{
|
||||
printf("Please specify the name of the album\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Are you sure you want to remove the album %s? ",
|
||||
name);
|
||||
int ret = scanf("%c", &input);
|
||||
if(!ret || ret == EOF)
|
||||
{
|
||||
printf("read error\n");
|
||||
return 1;
|
||||
}
|
||||
if(input == 'y' || input == 'Y')
|
||||
{
|
||||
db = ephoto_db_init();
|
||||
ephoto_db_delete_album(db, name);
|
||||
ephoto_db_close(db);
|
||||
printf("Album was removed\n");
|
||||
}
|
||||
else printf("Album was not removed\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
if(!strcmp(argv[i], "--remove-image") || !strcmp(argv[i], "-ri"))
|
||||
{
|
||||
i++;
|
||||
if(argv[i]) album = argv[i];
|
||||
else
|
||||
{
|
||||
printf("Please specify the name of the album "
|
||||
"the image belongs to.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
i++;
|
||||
if(argv[i]) path = argv[i];
|
||||
else
|
||||
{
|
||||
printf("Please specify the path of the image\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Are you sure you want to remove the image %s "
|
||||
"from the album %s? ",
|
||||
path, album);
|
||||
int ret = scanf("%c", &input);
|
||||
if(!ret || ret == EOF)
|
||||
{
|
||||
printf("read error\n");
|
||||
return 1;
|
||||
}
|
||||
if(input == 'y' || input == 'Y')
|
||||
{
|
||||
db = ephoto_db_init();
|
||||
ephoto_db_delete_image(db, album, path);
|
||||
ephoto_db_close(db);
|
||||
printf("Image was removed\n");
|
||||
}
|
||||
else printf("Image was not removed\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* NLS */
|
||||
#ifdef ENABLE_NLS
|
||||
setlocale(LC_MESSAGES, "");
|
||||
|
@ -291,8 +16,9 @@ int main(int argc, char **argv)
|
|||
bind_textdomain_codeset(PACKAGE, "UTF-8");
|
||||
textdomain(PACKAGE);
|
||||
#endif
|
||||
|
||||
/*Start the GUI*/
|
||||
create_main_gui();
|
||||
create_main();
|
||||
|
||||
/*Star the ewl loop*/
|
||||
ewl_main();
|
||||
|
|
|
@ -5,15 +5,9 @@
|
|||
#include <Ecore.h>
|
||||
#include <Ecore_Data.h>
|
||||
#include <Ecore_File.h>
|
||||
#include <Efreet_Mime.h>
|
||||
#include <Evas.h>
|
||||
#include <Ewl.h>
|
||||
#include <fnmatch.h>
|
||||
|
||||
#ifdef BUILD_EXIF_SUPPORT
|
||||
#include <libexif/exif-data.h>
|
||||
#include <libexif/exif-loader.h>
|
||||
#endif
|
||||
|
||||
#include <libgen.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
@ -25,6 +19,11 @@
|
|||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef BUILD_EXIF_SUPPORT
|
||||
#include <libexif/exif-data.h>
|
||||
#include <libexif/exif-loader.h>
|
||||
#endif
|
||||
|
||||
/* NLS */
|
||||
#ifdef ENABLE_NLS
|
||||
#include <libintl.h>
|
||||
|
@ -43,19 +42,17 @@
|
|||
char *sgettext(const char *msgid);
|
||||
#define S_(str) sgettext(str)
|
||||
|
||||
/* Ephoto Main gui callbacks */
|
||||
void create_main_gui(void);
|
||||
/*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 Browsing */
|
||||
Ecore_List *get_directories(const char *directory);
|
||||
Ecore_List *get_images(const char *directory);
|
||||
|
||||
/* Ephoto Exif */
|
||||
#ifdef BUILD_EXIF_SUPPORT
|
||||
Ecore_Hash *get_exif_data(const char *file);
|
||||
void display_exif_dialog(Ewl_Widget *w, void *event, void *data);
|
||||
#endif
|
||||
|
||||
/* Ephoto Databasing */
|
||||
sqlite3 *ephoto_db_init(void);
|
||||
void ephoto_db_add_album(sqlite3 *db, const char *name, const char *description);
|
||||
|
@ -66,7 +63,17 @@ 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 Gui */
|
||||
/* Ephoto Dialogs */
|
||||
void about_dialog(Ewl_Widget *w, void *event, void *data);
|
||||
void add_album(Ewl_Widget *w, void *event, void *data);
|
||||
|
||||
/* Ephoto Exif */
|
||||
#ifdef BUILD_EXIF_SUPPORT
|
||||
Ecore_Hash *get_exif_data(const char *file);
|
||||
void display_exif_dialog(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);
|
||||
|
@ -80,10 +87,6 @@ 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);
|
||||
|
||||
/* Ephoto Dialogs */
|
||||
void about_dialog(Ewl_Widget *w, void *event, void *data);
|
||||
void add_album(Ewl_Widget *w, void *event, void *data);
|
||||
|
||||
/* Ephoto Imaging */
|
||||
unsigned int *flip_horizontal(Ewl_Widget *image);
|
||||
unsigned int *flip_vertical(Ewl_Widget *image);
|
||||
|
@ -96,37 +99,34 @@ 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);
|
||||
|
||||
/* Ephoto Edit View */
|
||||
Ewl_Widget *add_edit_view(Ewl_Widget *c);
|
||||
|
||||
/* Ephoto List View */
|
||||
Ewl_Widget *add_list_view(Ewl_Widget *c);
|
||||
Ewl_Widget *add_ltree(Ewl_Widget *c);
|
||||
|
||||
/* Ephoto Normal View */
|
||||
Ewl_Widget *add_normal_view(Ewl_Widget *c);
|
||||
void freebox_image_clicked(Ewl_Widget *w, void *event, void *data);
|
||||
|
||||
/* Ephoto Single View */
|
||||
Ewl_Widget *add_single_view(Ewl_Widget *c);
|
||||
|
||||
/* Ephoto Slideshow */
|
||||
void start_slideshow(Ewl_Widget *w, void *event, void *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);
|
||||
|
||||
/* Ephoto Main View */
|
||||
void show_main_view(Ewl_Widget *w, void *event, void *data);
|
||||
void show_edit_view(Ewl_Widget *w, void *event, void *data);
|
||||
void populate_albums(Ewl_Widget *w, void *event, void *data);
|
||||
void populate_directories(Ewl_Widget *w, void *event, void *data);
|
||||
/*********************VIEWS******************/
|
||||
|
||||
/* Ephoto Viewer Views */
|
||||
void show_normal_view(Ewl_Widget *w, void *event, void *data);
|
||||
/*Ephoto Edit*/
|
||||
Ewl_Widget *add_edit_view(Ewl_Widget *c);
|
||||
|
||||
/*Ephoto List*/
|
||||
Ewl_Widget *add_list_view(Ewl_Widget *c);
|
||||
Ewl_Widget *add_ltree(Ewl_Widget *c);
|
||||
|
||||
/*Ephoto Normal*/
|
||||
Ewl_Widget *add_normal_view(Ewl_Widget *c);
|
||||
void freebox_image_clicked(Ewl_Widget *w, void *event, void *data);
|
||||
|
||||
/* Ephoto Single*/
|
||||
Ewl_Widget *add_single_view(Ewl_Widget *c);
|
||||
|
||||
/* Ephoto Slideshow*/
|
||||
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 Global Variables */
|
||||
|
@ -134,13 +134,11 @@ typedef struct _Ephoto_Main Ephoto_Main;
|
|||
|
||||
struct _Ephoto_Main
|
||||
{
|
||||
char *current_album;
|
||||
char *current_directory;
|
||||
Ecore_List *albums;
|
||||
Ecore_Hash *types;
|
||||
Ecore_List *directories;
|
||||
Ecore_List *images;
|
||||
Ewl_Widget *atree;
|
||||
Ewl_Widget *browser;
|
||||
Ewl_Widget *bwin;
|
||||
Ewl_Widget *dtree;
|
||||
Ewl_Widget *edit_vbox;
|
||||
Ewl_Widget *eimage;
|
||||
|
@ -150,8 +148,6 @@ struct _Ephoto_Main
|
|||
Ewl_Widget *list_vbox;
|
||||
Ewl_Widget *ltree;
|
||||
Ewl_Widget *lthumb_size;
|
||||
Ewl_Widget *main_nb;
|
||||
Ewl_Widget *main_vbox;
|
||||
Ewl_Widget *simage;
|
||||
Ewl_Widget *single_sp;
|
||||
Ewl_Widget *single_vbox;
|
||||
|
@ -160,7 +156,6 @@ struct _Ephoto_Main
|
|||
Ewl_Widget *view;
|
||||
Ewl_Widget *view_box;
|
||||
Ewl_Widget *win;
|
||||
sqlite3 *db;
|
||||
};
|
||||
|
||||
extern Ephoto_Main *em;
|
||||
|
|
|
@ -0,0 +1,190 @@
|
|||
#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);
|
||||
}
|
||||
|
||||
void show_browser(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
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_tree2_new();
|
||||
ewl_tree2_headers_visible_set(EWL_TREE2(tree), 0);
|
||||
ewl_tree2_fixed_rows_set(EWL_TREE2(tree), 1);
|
||||
ewl_tree2_column_count_set(EWL_TREE2(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;
|
||||
}
|
|
@ -51,8 +51,7 @@ Ecore_List *get_directories(const char *directory)
|
|||
Ecore_List *get_images(const char *directory)
|
||||
{
|
||||
Ecore_List *ls, *files;
|
||||
char *file;
|
||||
char path[PATH_MAX];
|
||||
char path[PATH_MAX], *file;
|
||||
|
||||
if (ecore_file_is_dir(directory))
|
||||
{
|
||||
|
@ -66,6 +65,8 @@ Ecore_List *get_images(const char *directory)
|
|||
file = ecore_list_first_remove(ls);
|
||||
if (strncmp(file, ".", 1))
|
||||
{
|
||||
const char *type;
|
||||
|
||||
if (strcmp(directory, "/"))
|
||||
{
|
||||
snprintf(path, PATH_MAX, "%s/%s",
|
||||
|
@ -76,15 +77,8 @@ Ecore_List *get_images(const char *directory)
|
|||
snprintf(path, PATH_MAX, "%s%s",
|
||||
directory, file);
|
||||
}
|
||||
if (fnmatch("*.[Jj][Pp][Ee][Gg]", path, 0) == 0)
|
||||
{
|
||||
ecore_dlist_append(files, strdup(path));
|
||||
}
|
||||
else if (fnmatch("*.[Jj][Pp][Gg]", path, 0) == 0)
|
||||
{
|
||||
ecore_dlist_append(files, strdup(path));
|
||||
}
|
||||
else if (fnmatch("*.[Pp][Nn][Gg]", path, 0) == 0)
|
||||
type = efreet_mime_type_get(strdup(path));
|
||||
if ((ecore_hash_get(em->types, type)) == "image")
|
||||
{
|
||||
ecore_dlist_append(files, strdup(path));
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#include "ephoto.h"
|
||||
|
||||
static void close_dialog(Ewl_Widget *w, void *event, void *data);
|
||||
static void save_image(Ewl_Widget *w, void *event, void *data);
|
||||
|
||||
static Ewl_Widget *album_entry, *description_entry, *save_entry, *save_quality;
|
||||
static Ewl_Widget *save_quality, *save_entry;
|
||||
|
||||
/*Close or Cancel the Dialog*/
|
||||
static void close_dialog(Ewl_Widget *w, void *event, void *data)
|
||||
|
@ -15,61 +14,6 @@ static void close_dialog(Ewl_Widget *w, void *event, void *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(album_entry));
|
||||
description = ewl_text_text_get(EWL_TEXT(description_entry));
|
||||
|
||||
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*/
|
||||
void add_album(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
Ewl_Widget *window, *label, *button, *vbox, *hbox;
|
||||
|
||||
window = add_window("Add Album", 200, 100, 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);
|
||||
|
||||
label = add_label(vbox, "Enter a name for the new album:");
|
||||
album_entry = add_entry(vbox, NULL, NULL, NULL);
|
||||
|
||||
label = add_label(vbox, "Enter a description for the album:");
|
||||
description_entry = 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);
|
||||
ewl_button_image_size_set(EWL_BUTTON(button), 25, 25);
|
||||
|
||||
button = add_button(hbox, "Cancel",
|
||||
PACKAGE_DATA_DIR "/images/dialog-close.png",
|
||||
close_dialog, window);
|
||||
ewl_button_image_size_set(EWL_BUTTON(button), 25, 25);
|
||||
}
|
||||
|
||||
/*Add an About Dialog*/
|
||||
void about_dialog(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,10 @@ Ewl_Widget *add_edit_view(Ewl_Widget *c)
|
|||
Ewl_Widget *button, *vbox, *ibox, *hbox, *bhbox, *nb;
|
||||
Ewl_Widget *standard, *advanced;
|
||||
|
||||
hbox = add_box(c, EWL_ORIENTATION_HORIZONTAL, 2);
|
||||
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();
|
||||
|
@ -78,7 +81,7 @@ Ewl_Widget *add_edit_view(Ewl_Widget *c)
|
|||
/*Show the edit view*/
|
||||
void show_edit_view(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->main_nb), em->edit_vbox);
|
||||
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));
|
||||
ewl_widget_enable(em->smi);
|
||||
return;
|
||||
|
|
|
@ -22,7 +22,6 @@ Ewl_Widget *add_list_view(Ewl_Widget *c)
|
|||
/*Show the list view*/
|
||||
void show_list_view(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
show_main_view(NULL, NULL, NULL);
|
||||
ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->view_box), em->list_vbox);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,36 +2,19 @@
|
|||
|
||||
/*Ewl Callbacks*/
|
||||
static void destroy(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);
|
||||
|
||||
/*Ephoto Create Callbacks*/
|
||||
static Ewl_Widget *add_atree(Ewl_Widget *c);
|
||||
static Ewl_Widget *add_dtree(Ewl_Widget *c);
|
||||
|
||||
/*Ephoto MVC Callbacks*/
|
||||
static Ewl_Widget *album_view_new(void *data, unsigned int row, unsigned int column);
|
||||
static Ewl_Widget *directory_view_new(void *data, unsigned int row, unsigned int column);
|
||||
static Ewl_Widget *album_header_fetch(void *data, unsigned int column);
|
||||
static Ewl_Widget *directory_header_fetch(void *data, unsigned int column);
|
||||
static void *album_data_fetch(void *data, unsigned int row, unsigned int column);
|
||||
static void *directory_data_fetch(void *data, unsigned int row, unsigned int column);
|
||||
static unsigned int album_data_count(void *data);
|
||||
static unsigned int directory_data_count(void *data);
|
||||
|
||||
/*Ephoto Global Variables*/
|
||||
Ephoto_Main *em;
|
||||
|
||||
/*Destroy the Main Window*/
|
||||
static void destroy(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
ephoto_db_close(em->db);
|
||||
ewl_widget_destroy(em->win);
|
||||
ecore_list_destroy(em->albums);
|
||||
ecore_hash_destroy(em->types);
|
||||
ecore_list_destroy(em->directories);
|
||||
ecore_dlist_destroy(em->images);
|
||||
free(em->current_directory);
|
||||
free(em->current_album);
|
||||
free(em);
|
||||
ewl_main_quit();
|
||||
return;
|
||||
|
@ -53,47 +36,33 @@ static void window_fullscreen(Ewl_Widget *w, void *event, void *data)
|
|||
return;
|
||||
}
|
||||
|
||||
/*Show the main view*/
|
||||
void show_main_view(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->main_nb), em->main_vbox);
|
||||
ewl_widget_disable(em->smi);
|
||||
}
|
||||
|
||||
/*Update the images based on the current tab*/
|
||||
static void update_view(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
const char *text;
|
||||
Ewl_Widget *page;
|
||||
|
||||
page = ewl_notebook_visible_page_get(EWL_NOTEBOOK(w));
|
||||
text = ewl_widget_name_get(page);
|
||||
if (!strcmp(text, "Albums"))
|
||||
{
|
||||
populate_albums(NULL, NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
populate_directories(NULL, NULL, NULL);
|
||||
}
|
||||
ecore_dlist_first_goto(em->images);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*Create the Main Ephoto Window*/
|
||||
void create_main_gui(void)
|
||||
void create_main(void)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
Ewl_Widget *vbox, *hbox, *vsep, *button;
|
||||
Ewl_Widget *mb, *menu, *mi;
|
||||
|
||||
/*Initialize our main Structure*/
|
||||
em = NULL;
|
||||
em = calloc(1, sizeof(Ephoto_Main));
|
||||
em->albums = ecore_list_new();
|
||||
|
||||
/*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->win = add_window("Ephoto!", 800, 600, destroy, NULL);
|
||||
|
||||
vbox = add_box(em->win, EWL_ORIENTATION_VERTICAL, 5);
|
||||
|
@ -109,53 +78,15 @@ void create_main_gui(void)
|
|||
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);
|
||||
|
||||
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, 2);
|
||||
ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_ALL);
|
||||
|
||||
em->main_nb = ewl_notebook_new();
|
||||
ewl_notebook_tabbar_visible_set(EWL_NOTEBOOK(em->main_nb), 0);
|
||||
ewl_object_fill_policy_set(EWL_OBJECT(em->main_nb), EWL_FLAG_FILL_ALL);
|
||||
ewl_container_child_append(EWL_CONTAINER(hbox), em->main_nb);
|
||||
ewl_widget_show(em->main_nb);
|
||||
|
||||
em->main_vbox = add_box(em->main_nb, EWL_ORIENTATION_VERTICAL, 2);
|
||||
ewl_object_fill_policy_set(EWL_OBJECT(em->main_vbox), EWL_FLAG_FILL_ALL);
|
||||
|
||||
em->edit_vbox = add_box(em->main_nb, EWL_ORIENTATION_VERTICAL, 2);
|
||||
ewl_object_fill_policy_set(EWL_OBJECT(em->edit_vbox), EWL_FLAG_FILL_ALL);
|
||||
|
||||
add_edit_view(em->edit_vbox);
|
||||
|
||||
em->view = add_box(em->main_vbox, EWL_ORIENTATION_HORIZONTAL, 1);
|
||||
em->view = add_box(vbox, EWL_ORIENTATION_HORIZONTAL, 1);
|
||||
ewl_object_fill_policy_set(EWL_OBJECT(em->view), EWL_FLAG_FILL_ALL);
|
||||
|
||||
em->browser = ewl_notebook_new();
|
||||
ewl_object_fill_policy_set(EWL_OBJECT(em->browser), EWL_FLAG_FILL_VFILL);
|
||||
ewl_object_preferred_inner_w_set(EWL_OBJECT(em->browser), 200);
|
||||
ewl_container_child_append(EWL_CONTAINER(em->view), em->browser);
|
||||
ewl_widget_show(em->browser);
|
||||
|
||||
em->atree = add_atree(em->browser);
|
||||
ewl_object_maximum_w_set(EWL_OBJECT(em->atree), 200);
|
||||
ewl_widget_name_set(em->atree, "Albums");
|
||||
ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(em->browser), em->atree,
|
||||
_("Albums"));
|
||||
|
||||
em->dtree = add_dtree(em->browser);
|
||||
ewl_object_maximum_w_set(EWL_OBJECT(em->dtree), 200);
|
||||
ewl_widget_name_set(em->dtree, "File System");
|
||||
ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(em->browser), em->dtree,
|
||||
_("File System"));
|
||||
|
||||
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);
|
||||
|
@ -166,7 +97,9 @@ void create_main_gui(void)
|
|||
|
||||
add_single_view(em->view_box);
|
||||
|
||||
add_list_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);
|
||||
|
@ -196,6 +129,14 @@ 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);
|
||||
|
||||
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);
|
||||
|
@ -229,341 +170,9 @@ 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);
|
||||
|
||||
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/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);
|
||||
|
||||
em->db = ephoto_db_init();
|
||||
|
||||
em->current_album = strdup(_("Complete Library"));
|
||||
|
||||
getcwd(buf, PATH_MAX);
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
em->current_directory = strdup(buf);
|
||||
|
||||
populate_albums(NULL, NULL, NULL);
|
||||
ewl_callback_append(em->browser, EWL_CALLBACK_VALUE_CHANGED,
|
||||
update_view, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/*Update the Image List*/
|
||||
void populate_albums(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
const char *album;
|
||||
char *imagef;
|
||||
Ewl_Widget *thumb;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
em->albums = ecore_list_new();
|
||||
em->albums = ephoto_db_list_albums(em->db);
|
||||
ewl_mvc_data_set(EWL_MVC(em->atree), em->albums);
|
||||
|
||||
if (!ecore_dlist_empty_is(em->images))
|
||||
{
|
||||
ecore_dlist_destroy(em->images);
|
||||
}
|
||||
|
||||
em->images = ecore_dlist_new();
|
||||
em->images = ephoto_db_list_images(em->db, em->current_album);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
show_browser(NULL, NULL, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*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;
|
||||
}
|
||||
|
||||
/*Create and Add a Tree to the Container c*/
|
||||
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_tree2_new();
|
||||
ewl_tree2_headers_visible_set(EWL_TREE2(tree), 0);
|
||||
ewl_tree2_fixed_rows_set(EWL_TREE2(tree), 1);
|
||||
ewl_tree2_column_count_set(EWL_TREE2(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;
|
||||
}
|
||||
|
||||
/*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_tree2_new();
|
||||
ewl_tree2_headers_visible_set(EWL_TREE2(tree), 0);
|
||||
ewl_tree2_fixed_rows_set(EWL_TREE2(tree), 1);
|
||||
ewl_tree2_column_count_set(EWL_TREE2(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 albums */
|
||||
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,
|
||||
populate_albums, 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);
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
/* 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 *album_header_fetch(void *data, unsigned int column)
|
||||
{
|
||||
Ewl_Widget *label;
|
||||
|
||||
label = add_label(NULL, "Albums");
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
/* 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 albums that will be displayed*/
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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 albums the view is displaying */
|
||||
static unsigned int album_data_count(void *data)
|
||||
{
|
||||
int val;
|
||||
|
||||
val = ecore_list_count(em->albums);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ Ewl_Widget *add_normal_view(Ewl_Widget *c)
|
|||
/*Show the normal view*/
|
||||
void show_normal_view(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
show_main_view(NULL, NULL, NULL);
|
||||
ewl_notebook_visible_page_set(EWL_NOTEBOOK(em->view_box), em->fbox_vbox);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ Ewl_Widget *add_single_view(Ewl_Widget *c)
|
|||
/*Show the single view*/
|
||||
void show_single_view(Ewl_Widget *w, void *event, void *data)
|
||||
{
|
||||
show_main_view(NULL, NULL, NULL);
|
||||
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));
|
||||
|
|
Loading…
Reference in New Issue