Enlightenment CVS committal

Author  : titan
Project : e17
Module  : proto

Dir     : e17/proto/ephoto/src/bin


Modified Files:
        ephoto.h ephoto_gui.c ephoto_utils.c 


Log Message:
Add a little more work to the test ephoto.

===================================================================
RCS file: /cvs/e/e17/proto/ephoto/src/bin/ephoto.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ephoto.h    3 Dec 2006 21:51:32 -0000       1.3
+++ ephoto.h    5 Dec 2006 03:04:15 -0000       1.4
@@ -17,7 +17,8 @@
 void init_gui(void);
 
 /* Ephoto Utilities */
-Ecore_List *get_files(char *directory);
+Ecore_List *get_directories(char *directory);
+Ecore_List *get_images(char *directory);
 
 /* NLS */
 #ifdef ENABLE_NLS
===================================================================
RCS file: /cvs/e/e17/proto/ephoto/src/bin/ephoto_gui.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ephoto_gui.c        3 Dec 2006 21:52:12 -0000       1.5
+++ ephoto_gui.c        5 Dec 2006 03:04:15 -0000       1.6
@@ -3,11 +3,12 @@
 static void destroy(Ewl_Widget *w, void *event, void *data);
 static void add_menu_item(Ewl_Widget *c, char *txt, char *img, void *cb);
 static void add_button(Ewl_Widget *c, char *txt, char *img, void *cb);
+static void populate_files(Ewl_Widget *c, void *event, void *data);
 static void create_main_gui(void);
 static int destroy_boot(void *data);
 static Ewl_Widget *add_menu(Ewl_Widget *c, char *txt);
 static Ewl_Widget *add_tree(Ewl_Widget *c);
-static Ewl_Widget *progress;
+static Ewl_Widget *ftree, *atree, *fbox, *progress;
 static Ecore_Timer *timer;
 
 /*Boot Splash*/
@@ -168,15 +169,89 @@
        return tree;
 }
 
+static void populate_files(Ewl_Widget *w, void *event, void *data)
+{
+       char *cdir, *dir, *imagef;
+       Ecore_List *directories, *images;
+       Ewl_Widget *hbox, *image, *text, *children[2], *row;
+
+       cdir = data;
+       directories = get_directories(cdir);
+       images = get_images(cdir);
+
+       ewl_container_reset(EWL_CONTAINER(ftree));
+       while (!ecore_list_is_empty(directories))
+       {
+               dir = ecore_list_remove_first(directories);
+               
+               hbox = ewl_hbox_new();
+               ewl_object_alignment_set(EWL_OBJECT(hbox), 
EWL_FLAG_ALIGN_CENTER);
+               ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_ALL);
+               ewl_box_spacing_set(EWL_BOX(hbox), 5);
+               ewl_widget_show(hbox);
+
+               image = ewl_image_new();
+               ewl_image_file_set(EWL_IMAGE(image), 
+                                  PACKAGE_DATA_DIR "/images/folder.png", NULL);
+               ewl_container_child_append(EWL_CONTAINER(hbox), image);
+               ewl_widget_show(image);
+
+               text = ewl_text_new();
+               ewl_text_text_set(EWL_TEXT(text), basename(dir));
+               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(hbox), text);
+               ewl_widget_show(text);
+
+               children[0] = hbox;
+               children[1] = NULL;
+               
+               row = ewl_tree_row_add(EWL_TREE(ftree), NULL, children);
+               if (!strcmp(cdir, ".."))
+               {
+                       if (strchr(cdir, '/'))
+                       {
+                               ewl_callback_append(row, EWL_CALLBACK_CLICKED, 
+                                                   populate_files, 
strchr(cdir, '/'));
+                       }
+                       else
+                       {
+                               ewl_callback_append(row, EWL_CALLBACK_CLICKED,
+                                                   populate_files, "/");
+                       }
+               }
+               else
+               {
+                        ewl_callback_append(row, EWL_CALLBACK_CLICKED,
+                                            populate_files, dir);
+               }
+       }
+       ewl_widget_configure(ftree);
+
+       ewl_container_reset(EWL_CONTAINER(fbox));
+       while (!ecore_list_is_empty(images))
+       {
+               imagef = ecore_list_remove_first(images);
+
+               image = ewl_image_thumbnail_new();
+               ewl_image_thumbnail_request(EWL_IMAGE_THUMBNAIL(image), imagef);
+               ewl_image_proportional_set(EWL_IMAGE(image), TRUE);
+               ewl_object_alignment_set(EWL_OBJECT(image), 
EWL_FLAG_ALIGN_CENTER);
+               ewl_container_child_append(EWL_CONTAINER(fbox), image);
+               ewl_widget_show(image);
+       }
+       ewl_widget_configure(ftree);
+}
+
 static void create_main_gui(void)
 {
-       Ewl_Widget *win, *atree, *btree, *vbox, *menu_bar, *menu, *nb, *paned;
-       Ewl_Widget *ivbox, *ihbox, *sp, *image, *button;
+       Ewl_Widget *win, *vbox, *menu_bar, *menu, *nb, *paned;
+       Ewl_Widget *border, *ivbox, *ihbox, *sp, *image, *button;
 
        win = ewl_window_new();
         ewl_window_title_set(EWL_WINDOW(win), "Ephoto!");
         ewl_window_name_set(EWL_WINDOW(win), "Ephoto!");
-        ewl_object_size_request(EWL_OBJECT(win), 600, 400);
+        ewl_object_size_request(EWL_OBJECT(win), 800, 600);
         ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, destroy, NULL);
        ewl_widget_show(win);
 
@@ -208,21 +283,34 @@
        ewl_container_child_append(EWL_CONTAINER(paned), nb);
        ewl_widget_show(nb);
 
+       ftree = add_tree(nb);
+       ewl_callback_append(ftree, EWL_CALLBACK_SHOW, populate_files, 
getenv("HOME"));
+       ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(nb), ftree, "Files");
        atree = add_tree(nb);
        ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(nb), atree, "Albums");
-       btree = add_tree(nb);
-       ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(nb), btree, "Browser");
 
        ivbox = ewl_vbox_new();
        ewl_object_fill_policy_set(EWL_OBJECT(ivbox), EWL_FLAG_FILL_ALL);
        ewl_container_child_append(EWL_CONTAINER(paned), ivbox);
        ewl_widget_show(ivbox);
 
+       border = ewl_border_new();
+       ewl_border_text_set(EWL_BORDER(border), "Catalog");
+       ewl_border_label_alignment_set(EWL_BORDER(border), 
EWL_FLAG_ALIGN_CENTER);
+       ewl_object_fill_policy_set(EWL_OBJECT(border), EWL_FLAG_FILL_ALL);
+       ewl_container_child_append(EWL_CONTAINER(ivbox), border);
+       ewl_widget_show(border);
+
        sp = ewl_scrollpane_new();
        ewl_object_fill_policy_set(EWL_OBJECT(sp), EWL_FLAG_FILL_ALL);
-       ewl_container_child_append(EWL_CONTAINER(ivbox), sp);
+       ewl_container_child_append(EWL_CONTAINER(border), sp);
        ewl_widget_show(sp);
 
+       fbox = ewl_hfreebox_new();
+       ewl_object_fill_policy_set(EWL_OBJECT(fbox), EWL_FLAG_FILL_ALL);
+       ewl_container_child_append(EWL_CONTAINER(sp), fbox);
+       ewl_widget_show(fbox);
+
        image = ewl_image_new();
        ewl_image_proportional_set(EWL_IMAGE(image), TRUE);
        ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_CENTER);
@@ -236,10 +324,11 @@
        ewl_object_fill_policy_set(EWL_OBJECT(ihbox), EWL_FLAG_FILL_SHRINK);
        ewl_widget_show(ihbox);
 
-       add_button(ihbox, "In", PACKAGE_DATA_DIR "/images/search.png", NULL);
-       add_button(ihbox, "Out", PACKAGE_DATA_DIR "/images/search.png", NULL);
-       add_button(ihbox, "Left", PACKAGE_DATA_DIR "/images/undo.png", NULL);
-       add_button(ihbox, "Right", PACKAGE_DATA_DIR "/images/redo.png", NULL);
+       add_button(ihbox, "Refresh", NULL, NULL);
+       add_button(ihbox, "Left", NULL, NULL);
+       add_button(ihbox, "Right", NULL, NULL);
+       add_button(ihbox, "Edit", NULL, NULL);
+       add_button(ihbox, "Slideshow", NULL, NULL);
 
        return;
 }
===================================================================
RCS file: /cvs/e/e17/proto/ephoto/src/bin/ephoto_utils.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- ephoto_utils.c      3 Dec 2006 21:51:32 -0000       1.1
+++ ephoto_utils.c      5 Dec 2006 03:04:15 -0000       1.2
@@ -1,6 +1,6 @@
 #include "ephoto.h"
 
-Ecore_List *get_files(char *directory)
+Ecore_List *get_directories(char *directory)
 {
        Ecore_List *ls, *files;
        char *file;
@@ -31,6 +31,72 @@
                                }
                        }
                        if (ecore_file_is_dir(path))
+                       {
+                               ecore_list_append(files, strdup(path));
+                       }
+               }
+       }
+       else
+       {
+               files = NULL;
+       }
+       return files;
+}
+
+Ecore_List *get_images(char *directory)
+{
+        Ecore_List *ls, *files;
+        char *file;
+        char path[PATH_MAX];
+
+        if (ecore_file_is_dir(directory))
+        {
+                ls = ecore_list_new();
+                files = ecore_list_new();
+
+                ls = ecore_file_ls(directory);
+                while (!ecore_list_is_empty(ls))
+                {
+                        file = ecore_list_remove_first(ls);
+                        if (strncmp(file, ".", 1))
+                        {
+                                if (strcmp(directory, "/"))
+                                {
+                                        snprintf(path, PATH_MAX, "%s/%s",
+                                                 directory, file);
+                                }
+                                else
+                                {
+                                        snprintf(path, PATH_MAX, "%s%s",
+                                                 directory, file);
+                                }
+                        }
+
+                       if (fnmatch("*.[Jj][Pp][Ee][Gg]", path, 0) == 0)
+                       {
+                               ecore_list_append(files, strdup(path));
+                       }
+                       else if (fnmatch("*.[Jj][Pp][Gg]", path, 0) == 0)
+                       {
+                               ecore_list_append(files, strdup(path));
+                       }
+                       else if (fnmatch("*.[Pp][Nn][Gg]", path, 0) == 0)
+                       {
+                               ecore_list_append(files, strdup(path));
+                       }
+                       else if (fnmatch("*.[Gg][Ii][Ff]", path, 0) == 0)
+                       {
+                               ecore_list_append(files, strdup(path));
+                       }
+                       else if (fnmatch("*.[Tt][Ii][Ff]Ff]", path, 0) == 0)
+                       {
+                               ecore_list_append(files, strdup(path));
+                       }
+                       else if (fnmatch("*.[Tt][Ii][Ff]", path, 0) == 0)
+                       {
+                               ecore_list_append(files, strdup(path));
+                       }
+                       else if (fnmatch("*.[Ss][Vv][Gg]", path, 0) == 0)
                        {
                                ecore_list_append(files, strdup(path));
                        }



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to