Enlightenment CVS committal Author : balony Project : e17 Module : proto
Dir : e17/proto/exhibit/src/bin Modified Files: exhibit.h exhibit_image.c exhibit_main.c exhibit_main.h exhibit_menus.c exhibit_options.c exhibit_tab.c Log Message: - Added monitoring for the dir/file -listing - Some minor cleanup =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit.h,v retrieving revision 1.31 retrieving revision 1.32 diff -u -3 -r1.31 -r1.32 --- exhibit.h 15 Aug 2006 22:21:47 -0000 1.31 +++ exhibit.h 1 Sep 2006 20:23:50 -0000 1.32 @@ -70,6 +70,13 @@ EX_SORT_BY_RESOLUTION = -4 } Ex_Sort; +typedef enum _Ex_Tree_Update +{ + EX_TREE_UPDATE_FILES = -1, + EX_TREE_UPDATE_DIRS = -2, + EX_TREE_UPDATE_ALL = -3, +} Ex_Tree_Update; + struct _Ex_Options { char *app1; @@ -139,7 +146,8 @@ int num; - Etk_Bool fit_window; + Etk_Bool fit_window; + Ecore_File_Monitor *monitor; Evas_List *images; Evas_List *dirs; =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_image.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -3 -r1.36 -r1.37 --- exhibit_image.c 25 Aug 2006 12:00:13 -0000 1.36 +++ exhibit_image.c 1 Sep 2006 20:23:50 -0000 1.37 @@ -582,16 +582,6 @@ /* Dont fork for the tree polulating to work */ evas_object_image_save(im->image_object, file, NULL, NULL); - /* Refresh list if the file is saved in our dir */ - D(("Image path: %s <-> Cur path: %s\n", fd->e->cur_tab->set_img_path, - fd->e->cur_tab->cur_path)); - if (!strcmp(fd->e->cur_tab->set_img_path, fd->e->cur_tab->cur_path)) - { - etk_tree_clear(ETK_TREE(fd->e->cur_tab->itree)); - etk_tree_clear(ETK_TREE(fd->e->cur_tab->dtree)); - _ex_main_populate_files(fd->e, NULL); - } - etk_widget_hide(fd->win); } @@ -679,23 +669,13 @@ } _ex_main_image_unset(); - - /* Refresh the tree as we deleted the file first */ - etk_tree_clear(ETK_TREE(tab->itree)); - etk_tree_clear(ETK_TREE(tab->dtree)); - _ex_main_populate_files(e, NULL); - - D(("Ex_Tab pointer in _ex_image_delete_cb %p\n", tab)); etk_object_destroy(ETK_OBJECT(tab->dialog)); - - D(("Deleted for %s\n", string)); + D(("Deleted %s\n", string)); } static void _ex_image_delete_dialog_response(Etk_Object *obj, int response_id, void *data) { - Exhibit *e = data; - switch(response_id) { case ETK_RESPONSE_OK: @@ -715,9 +695,8 @@ Ex_Tab *tab = e->cur_tab; char string[PATH_MAX]; - sprintf(string, "Are you sure you want to delete this image? <br>%s%s<br> ", tab->set_img_path, tab->cur_file); - - D(("Ex_Tab pointer in _ex_image_delete %p\n", e->cur_tab)); + sprintf(string, "Are you sure you want to delete this image? <br>%s%s<br> ", + tab->set_img_path, tab->cur_file); tab->dialog = etk_message_dialog_new(ETK_MESSAGE_DIALOG_QUESTION, ETK_MESSAGE_DIALOG_OK_CANCEL, @@ -731,11 +710,6 @@ _("Exhibit - Confirm delete")); etk_widget_show_all(tab->dialog); - - /* TODO - * Center the dialog on top of the app. - etk_window_center_on_window(ETK_WINDOW(tab->dialog), ETK_WINDOW(e->win)); - */ } @@ -761,13 +735,8 @@ ret = rename(oldpath, newpath); if (ret == -1) _ex_main_dialog_show("Error renaming file!", ETK_MESSAGE_DIALOG_ERROR); - else - { - _ex_main_image_unset(); - etk_tree_clear(ETK_TREE(tab->itree)); - etk_tree_clear(ETK_TREE(tab->dtree)); - _ex_main_populate_files(e, NULL); - } + else + _ex_main_image_unset(); E_FREE(newpath); E_FREE(oldpath); @@ -1064,8 +1033,6 @@ char filename_s[PATH_MAX]; Ecore_X_Window *roots = NULL; - D(("Entered the foo\n")); - if (!ecore_x_init(NULL)) exit(0); @@ -1166,9 +1133,8 @@ { char e_bg_set[PATH_MAX*2]; - snprintf(e_bg_set, PATH_MAX, "enlightenment_remote -default-bg-set %s", edj_file); - - D(("FOO: %s\n", e_bg_set)); + snprintf(e_bg_set, PATH_MAX, "enlightenment_remote -default-bg-set %s", + edj_file); system(e_bg_set); } =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_main.c,v retrieving revision 1.69 retrieving revision 1.70 diff -u -3 -r1.69 -r1.70 --- exhibit_main.c 25 Aug 2006 12:00:13 -0000 1.69 +++ exhibit_main.c 1 Sep 2006 20:23:50 -0000 1.70 @@ -10,6 +10,7 @@ Exhibit *e; Evas_List *event_handlers; +static void _ex_main_monitor_dir(void *data, Ecore_File_Monitor *ecore_file_monitor, Ecore_File_Event event, const char *path); static int _ex_main_dtree_compare_cb(Etk_Tree *tree, Etk_Tree_Row *row1, Etk_Tree_Row *row2, Etk_Tree_Col *col, void *data); static void _ex_main_goto_dir_clicked_cb(Etk_Object *object, void *data); static void _ex_main_entry_dir_key_down_cb(Etk_Object *object, void *event, void *data); @@ -103,17 +104,11 @@ else { etk_image_set_from_file(ETK_IMAGE(e->cur_tab->image), image); - + if (e->cur_tab->fit_window) - { - _ex_tab_current_fit_to_window(e); - D(("Setting EX_IMAGE_FIT_TO_WINDOW loaded and used\n")); - } + _ex_tab_current_fit_to_window(e); else - { - _ex_tab_current_zoom_one_to_one(e); - D(("Setting EX_IMAGE_ONE_TO_ONE loaded and used\n")); - } + _ex_tab_current_zoom_one_to_one(e); } bytes = ecore_file_size(image); @@ -133,7 +128,6 @@ etk_range_value_set(vs, (double)h/2); /* Reset undo data every time we change image */ - D(("Resetting undo data on image %p\n", e->cur_tab->image)); data2 = etk_object_data_get(ETK_OBJECT(e->cur_tab->image), "undo"); if (data2) E_FREE(data2); @@ -158,24 +152,31 @@ } void -_ex_main_populate_files(Exhibit *e, const char *selected_file) +_ex_main_populate_files(const char *selected_file, Ex_Tree_Update update) { char back[PATH_MAX]; DIR *dir; struct dirent *dir_entry; - Etk_Tree_Row *row, *selected_row; - - selected_row = NULL; - snprintf(back, PATH_MAX, ".."); - etk_tree_append(ETK_TREE(e->cur_tab->dtree), e->cur_tab->dcol, - etk_theme_icon_theme_get(), "actions/go-up_16", back, NULL); + Etk_Tree_Row *row, *selected_row = NULL; chdir(e->cur_tab->dir); + + if (update == EX_TREE_UPDATE_ALL || update == EX_TREE_UPDATE_DIRS) + { + snprintf(back, PATH_MAX, ".."); + etk_tree_append(ETK_TREE(e->cur_tab->dtree), e->cur_tab->dcol, + etk_theme_icon_theme_get(), "actions/go-up_16", back, NULL); + } - D(("Changing to dir: %s\n", e->cur_tab->dir)); + if (e->cur_tab->monitor) + { + D(("Removing old monitoring\n")); + ecore_file_monitor_del(e->cur_tab->monitor); + e->cur_tab->monitor = NULL; + } if ((dir = opendir(".")) == NULL) - return ; + return; etk_tree_freeze(ETK_TREE(e->cur_tab->itree)); etk_tree_freeze(ETK_TREE(e->cur_tab->dtree)); @@ -201,17 +202,25 @@ continue; snprintf(image, PATH_MAX, "%s", dir_entry->d_name); - if(stat(image, &st) == -1) continue; - if(S_ISDIR(st.st_mode)) + + if (update == EX_TREE_UPDATE_ALL || update == EX_TREE_UPDATE_DIRS) { - etk_tree_append(ETK_TREE(e->cur_tab->dtree), e->cur_tab->dcol, - etk_theme_icon_theme_get(), - "places/folder_16", - dir_entry->d_name, NULL); - e->cur_tab->dirs = evas_list_append(e->cur_tab->dirs, dir_entry->d_name); - continue; + if(stat(image, &st) == -1) continue; + if(S_ISDIR(st.st_mode)) + { + etk_tree_append(ETK_TREE(e->cur_tab->dtree), e->cur_tab->dcol, + etk_theme_icon_theme_get(), + "places/folder_16", + dir_entry->d_name, NULL); + e->cur_tab->dirs = evas_list_append(e->cur_tab->dirs, dir_entry->d_name); + continue; + } } + /* If we don't want to do the rtree updating */ + if (update == EX_TREE_UPDATE_DIRS) + continue; + if(!_ex_file_is_viewable(dir_entry->d_name)) continue; @@ -252,20 +261,25 @@ } etk_tree_thaw(ETK_TREE(e->cur_tab->itree)); + etk_tree_thaw(ETK_TREE(e->cur_tab->dtree)); - D(("e->options->default_sort: %d\n", e->options->default_sort)); - - if (e->options->default_sort == EX_SORT_BY_DATE) - _ex_sort_date_cb(NULL, NULL); - else if (e->options->default_sort == EX_SORT_BY_SIZE) - _ex_sort_size_cb(NULL, NULL); - else if (e->options->default_sort == EX_SORT_BY_NAME) - _ex_sort_name_cb(NULL, NULL); - else if (e->options->default_sort == EX_SORT_BY_RESOLUTION) - _ex_sort_resol_cb(NULL, NULL); + if (update == EX_TREE_UPDATE_FILES) + { + if (e->options->default_sort == EX_SORT_BY_DATE) + _ex_sort_date_cb(NULL, NULL); + else if (e->options->default_sort == EX_SORT_BY_SIZE) + _ex_sort_size_cb(NULL, NULL); + else if (e->options->default_sort == EX_SORT_BY_NAME) + _ex_sort_name_cb(NULL, NULL); + else if (e->options->default_sort == EX_SORT_BY_RESOLUTION) + _ex_sort_resol_cb(NULL, NULL); + } - etk_tree_thaw(ETK_TREE(e->cur_tab->dtree)); - etk_tree_sort(ETK_TREE(e->cur_tab->dtree), _ex_main_dtree_compare_cb, ETK_TRUE, e->cur_tab->dcol, NULL); + if (update == EX_TREE_UPDATE_ALL || update == EX_TREE_UPDATE_DIRS) + { + etk_tree_sort(ETK_TREE(e->cur_tab->dtree), _ex_main_dtree_compare_cb, + ETK_TRUE, e->cur_tab->dcol, NULL); + } if(selected_row) { @@ -277,18 +291,65 @@ stepdown like ".." if we just call the refresh on the listing like after a delete */ e->cur_tab->dir = strdup("."); + + if (!e->cur_tab->monitor) + { + D(("Adding monitoring to path %s\n", e->cur_tab->cur_path)); + e->cur_tab->monitor = ecore_file_monitor_add(e->cur_tab->cur_path, + _ex_main_monitor_dir, NULL); + } closedir(dir); } static void -_ex_main_entry_dir_key_down_cb(Etk_Object *object, void *event, void *data) +_ex_main_monitor_dir(void *data, Ecore_File_Monitor *ecore_file_monitor, Ecore_File_Event event, const char *path) { - Etk_Event_Key_Down *ev; - Exhibit *e; + /* Only do changes if tree's are visible */ + if (ecore_file_monitor != e->cur_tab->monitor) + return; - e = data; - ev = event; + /* TODO: update non-visible tabs too */ + + switch (event) + { + case ECORE_FILE_EVENT_CREATED_DIRECTORY: + etk_tree_clear(ETK_TREE(e->cur_tab->dtree)); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_DIRS); + break; + case ECORE_FILE_EVENT_DELETED_DIRECTORY: + etk_tree_clear(ETK_TREE(e->cur_tab->dtree)); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_DIRS); + break; + case ECORE_FILE_EVENT_DELETED_SELF: + etk_tree_clear(ETK_TREE(e->cur_tab->dtree)); + etk_tree_clear(ETK_TREE(e->cur_tab->itree)); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_ALL); + break; + case ECORE_FILE_EVENT_MODIFIED: + etk_tree_clear(ETK_TREE(e->cur_tab->itree)); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_FILES); + break; + case ECORE_FILE_EVENT_DELETED_FILE: + etk_tree_clear(ETK_TREE(e->cur_tab->itree)); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_FILES); + break; + case ECORE_FILE_EVENT_CREATED_FILE: + etk_tree_clear(ETK_TREE(e->cur_tab->itree)); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_FILES); + break; + default: + D(("Unknown ecore file event occured\n")); + break; + } + + D(("Monitor event %d happened in %s\n", event, path)); +} + +static void +_ex_main_entry_dir_key_down_cb(Etk_Object *object, void *event, void *data) +{ + Etk_Event_Key_Down *ev = event; if(!strcmp(ev->key, "Tab")) { @@ -362,29 +423,22 @@ e->cur_tab->dir = strdup((char*)etk_entry_text_get(ETK_ENTRY(e->entry[0]))); etk_tree_clear(ETK_TREE(e->cur_tab->itree)); etk_tree_clear(ETK_TREE(e->cur_tab->dtree)); - _ex_main_populate_files(e, NULL); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_ALL); } } static void _ex_main_goto_dir_clicked_cb(Etk_Object *object, void *data) { - Exhibit *e; - - e = data; - e->cur_tab->dir = strdup((char*)etk_entry_text_get(ETK_ENTRY(e->entry[0]))); etk_tree_clear(ETK_TREE(e->cur_tab->itree)); etk_tree_clear(ETK_TREE(e->cur_tab->dtree)); - _ex_main_populate_files(e, NULL); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_ALL); } static Etk_Bool _ex_main_window_deleted_cb(void *data) { - Exhibit *e; - - e = data; etk_main_quit(); return 1; } @@ -392,11 +446,7 @@ static void _ex_main_window_key_down_cb(Etk_Object *object, void *event, void *data) { - Etk_Event_Key_Down *ev; - Exhibit *e; - - e = data; - ev = event; + Etk_Event_Key_Down *ev = event; if(ev->modifiers == ETK_MODIFIER_CTRL) { @@ -407,7 +457,7 @@ tab = _ex_tab_new(e, e->cur_tab->cur_path); _ex_main_window_tab_append(e, tab); - _ex_main_populate_files(e, NULL); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_ALL); } else if(!strcmp(ev->key, "w")) { @@ -568,7 +618,7 @@ e->cur_tab->dir = strdup(dir); etk_tree_clear(ETK_TREE(e->cur_tab->itree)); etk_tree_clear(ETK_TREE(e->cur_tab->dtree)); - _ex_main_populate_files(e, ecore_file_get_file(file)); + _ex_main_populate_files(ecore_file_get_file(file), EX_TREE_UPDATE_ALL); if(ecore_file_exists(file) && !ecore_file_is_dir(file)) _ex_main_image_set(e, file); etk_notebook_page_tab_label_set(ETK_NOTEBOOK(e->notebook), e->cur_tab->num, _ex_file_get(e->cur_tab->cur_path)); @@ -833,7 +883,7 @@ _ex_tab_select(tab); etk_paned_child2_set(ETK_PANED(e->hpaned), tab->scrolled_view, ETK_TRUE); - _ex_main_populate_files(e, file); + _ex_main_populate_files(file, EX_TREE_UPDATE_ALL); e->hbox = etk_hbox_new(ETK_TRUE, 0); etk_box_append(ETK_BOX(e->vbox), e->hbox, ETK_BOX_END, ETK_BOX_NONE, 0); =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_main.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- exhibit_main.h 10 Aug 2006 04:01:10 -0000 1.12 +++ exhibit_main.h 1 Sep 2006 20:23:50 -0000 1.13 @@ -5,7 +5,7 @@ #define _EX_MAIN_H void _ex_main_statusbar_zoom_update(Exhibit *e); -void _ex_main_populate_files(Exhibit *e, const char *selected_file); +void _ex_main_populate_files(const char *selected_file, Ex_Tree_Update update); int _ex_main_window_slideshow_next(void *data); void _ex_main_window_slideshow_toggle(Exhibit *e); void _ex_main_window_tab_append(Exhibit *e, Ex_Tab *tab); =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_menus.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -3 -r1.31 -r1.32 --- exhibit_menus.c 18 Aug 2006 10:36:41 -0000 1.31 +++ exhibit_menus.c 1 Sep 2006 20:23:50 -0000 1.32 @@ -96,7 +96,7 @@ tab = _ex_tab_new(e, e->cur_tab->cur_path); _ex_main_window_tab_append(e, tab); - _ex_main_populate_files(e, NULL); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_ALL); } void @@ -383,10 +383,6 @@ { EX_MENU_ITEM_GET_RETURN(obj); - etk_tree_clear(ETK_TREE(e->cur_tab->itree)); - etk_tree_clear(ETK_TREE(e->cur_tab->dtree)); - _ex_main_populate_files(e, NULL); - if (!e->cur_tab->image_loaded) return; @@ -481,7 +477,7 @@ e->cur_tab->dir = strdup(e->options->fav_path); etk_tree_clear(ETK_TREE(e->cur_tab->itree)); etk_tree_clear(ETK_TREE(e->cur_tab->dtree)); - _ex_main_populate_files(e, NULL); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_ALL); } void =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_options.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- exhibit_options.c 15 Aug 2006 18:45:51 -0000 1.14 +++ exhibit_options.c 1 Sep 2006 20:23:50 -0000 1.15 @@ -473,7 +473,7 @@ e->options->default_sort = e->options->default_sort_tmp; etk_tree_clear(ETK_TREE(e->cur_tab->dtree)); etk_tree_clear(ETK_TREE(e->cur_tab->itree)); - _ex_main_populate_files(e, NULL); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_ALL); /* RUN IN */ APP_NEW(dialog->app1, e->options->app1); =================================================================== RCS file: /cvs/e/e17/proto/exhibit/src/bin/exhibit_tab.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -3 -r1.28 -r1.29 --- exhibit_tab.c 25 Aug 2006 12:00:13 -0000 1.28 +++ exhibit_tab.c 1 Sep 2006 20:23:50 -0000 1.29 @@ -134,12 +134,15 @@ D(("_ex_tab_select: changed dir to %s\n", tab->cur_path)); D(("_ex_tab_select: selecting tab num %d\n", e->cur_tab->num)); - if(tab->comment.visible) - etk_notebook_page_child_set(ETK_NOTEBOOK(e->notebook), tab->num, - tab->comment.vbox); - else if(tab->fit_window) - etk_notebook_page_child_set(ETK_NOTEBOOK(e->notebook), tab->num, - tab->alignment); + if (!e->notebook) + { + if(tab->comment.visible) + etk_notebook_page_child_set(ETK_NOTEBOOK(e->notebook), tab->num, + tab->comment.vbox); + else if(tab->fit_window) + etk_notebook_page_child_set(ETK_NOTEBOOK(e->notebook), tab->num, + tab->alignment); + } etk_table_attach(ETK_TABLE(e->table), tab->dtree, 0, 3, 3, 3, @@ -429,7 +432,7 @@ e->cur_tab->dir = strdup(dcol_string); etk_tree_clear(ETK_TREE(e->cur_tab->itree)); etk_tree_clear(ETK_TREE(e->cur_tab->dtree)); - _ex_main_populate_files(e, NULL); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_ALL); etk_notebook_page_tab_label_set(ETK_NOTEBOOK(e->notebook), etk_notebook_current_page_get(ETK_NOTEBOOK(e->notebook)), _ex_file_get(e->cur_tab->cur_path)); } @@ -466,6 +469,6 @@ e->cur_tab->dir = strdup((char*)etk_entry_text_get(ETK_ENTRY(e->entry[0]))); etk_tree_clear(ETK_TREE(e->cur_tab->itree)); etk_tree_clear(ETK_TREE(e->cur_tab->dtree)); - _ex_main_populate_files(e, NULL); + _ex_main_populate_files(NULL, EX_TREE_UPDATE_ALL); } } ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs