Enlightenment CVS committal
Author : leviathan
Project : e17
Module : apps/exhibit
Dir : e17/apps/exhibit/src/bin
Modified Files:
exhibit.h exhibit_file.c exhibit_file.h exhibit_image.c
exhibit_main.c exhibit_menus.c exhibit_tab.c exhibit_thumb.c
Log Message:
Change the way exhibit handles files:
- Populate the images list in Etk_Tab and actually use it
- Remove all usage of cur_path and stop changing directories
===================================================================
RCS file: /cvs/e/e17/apps/exhibit/src/bin/exhibit.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -3 -r1.47 -r1.48
--- exhibit.h 12 Jul 2007 13:33:08 -0000 1.47
+++ exhibit.h 2 Sep 2007 18:37:37 -0000 1.48
@@ -151,7 +151,6 @@
struct _Ex_Tab
{
char *dir;
- char cur_path[PATH_MAX];
/* Path and filename of the dir to the
currently "set" image */
===================================================================
RCS file: /cvs/e/e17/apps/exhibit/src/bin/exhibit_file.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -3 -r1.22 -r1.23
--- exhibit_file.c 25 Aug 2007 13:49:46 -0000 1.22
+++ exhibit_file.c 2 Sep 2007 18:37:37 -0000 1.23
@@ -230,3 +230,19 @@
}
else return ecore_file_file_get(path);
}
+
+char *
+_ex_path_normalize(const char *path)
+{
+ int size;
+ size = strlen(path);
+ if (size >= 2 && path[size - 1] == '/')
+ return strdup(path);
+ else
+ {
+ char * newpath;
+ newpath = calloc(size + 2, sizeof(char));
+ snprintf(newpath, size + 2, "%s/", path);
+ return newpath;
+ }
+}
===================================================================
RCS file: /cvs/e/e17/apps/exhibit/src/bin/exhibit_file.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- exhibit_file.h 8 Sep 2006 16:54:30 -0000 1.11
+++ exhibit_file.h 2 Sep 2007 18:37:37 -0000 1.12
@@ -13,5 +13,6 @@
char *_ex_file_strip_extention(char *path);
const char *_ex_file_get(char *path);
+char *_ex_path_normalize(const char *path);
#endif
===================================================================
RCS file: /cvs/e/e17/apps/exhibit/src/bin/exhibit_image.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -3 -r1.52 -r1.53
--- exhibit_image.c 25 Jul 2007 17:00:54 -0000 1.52
+++ exhibit_image.c 2 Sep 2007 18:37:37 -0000 1.53
@@ -651,7 +651,7 @@
int ret;
r1 = ecore_file_realpath(dir);
- r2 = ecore_file_realpath(e->cur_tab->cur_path);
+ r2 = ecore_file_realpath(e->cur_tab->dir);
ret = strcmp(r1, r2);
free(r1);
===================================================================
RCS file: /cvs/e/e17/apps/exhibit/src/bin/exhibit_main.c,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -3 -r1.119 -r1.120
--- exhibit_main.c 25 Jul 2007 17:00:54 -0000 1.119
+++ exhibit_main.c 2 Sep 2007 18:37:37 -0000 1.120
@@ -157,7 +157,7 @@
e->cur_tab->cur_file = malloc(PATH_MAX);
memset(e->cur_tab->cur_file, 0, PATH_MAX);
- snprintf(e->cur_tab->set_img_path, PATH_MAX, "%s", e->cur_tab->cur_path);
+ snprintf(e->cur_tab->set_img_path, PATH_MAX, "%s", e->cur_tab->dir);
snprintf(e->cur_tab->cur_file, PATH_MAX, "%s", image);
e->cur_tab->image_loaded = ETK_TRUE;
@@ -232,7 +232,7 @@
etk_tree_freeze(ETK_TREE(e->cur_tab->itree));
etk_tree_freeze(ETK_TREE(e->cur_tab->dtree));
-
+
while (cur < data->num)
{
char image[PATH_MAX];
@@ -252,7 +252,7 @@
if ((!e->options->list_hidden) && (file[0] == '.'))
continue;
- snprintf(image, PATH_MAX, "%s", file);
+ snprintf(image, PATH_MAX, "%s%s", e->cur_tab->dir, file);
if (data->update == EX_TREE_UPDATE_ALL || data->update ==
EX_TREE_UPDATE_DIRS)
{
@@ -278,7 +278,8 @@
if(!realpath(image, imagereal))
snprintf(imagereal, PATH_MAX, "%s", image);
-
+
+ e->cur_tab->images = evas_list_append(e->cur_tab->images,
strdup(imagereal));
_ex_main_itree_add(imagereal, data->selected_file);
if (i == MAX_INSERTS_PER_ITERATION)
@@ -300,8 +301,8 @@
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,
+ D(("Adding monitoring to path %s\n", e->cur_tab->dir));
+ e->cur_tab->monitor = ecore_file_monitor_add(e->cur_tab->dir,
_ex_main_monitor_dir, NULL);
}
@@ -327,9 +328,10 @@
int j = 1;
int i = 0;
int (*cmp)(const void *, const void *) = _ex_sort_cmp_name;
+ Evas_List *l;
_ex_main_image_unset();
- chdir(e->cur_tab->dir);
+ //chdir(e->cur_tab->dir);
if (update == EX_TREE_UPDATE_ALL || update == EX_TREE_UPDATE_DIRS)
{
@@ -345,14 +347,7 @@
e->cur_tab->monitor = NULL;
}
- getcwd(e->cur_tab->cur_path, PATH_MAX);
- if (strlen(e->cur_tab->cur_path) < PATH_MAX - 2)
- {
- int len = strlen(e->cur_tab->cur_path);
- e->cur_tab->cur_path[len] = '/';
- e->cur_tab->cur_path[len + 1] = '\0';
- }
-
etk_entry_text_set(ETK_ENTRY(etk_combobox_entry_entry_get(ETK_COMBOBOX_ENTRY(e->combobox_entry))),
e->cur_tab->cur_path);
+
etk_entry_text_set(ETK_ENTRY(etk_combobox_entry_entry_get(ETK_COMBOBOX_ENTRY(e->combobox_entry))),
e->cur_tab->dir);
data = calloc(1, sizeof(Ex_Populate_Data));
if (selected_file)
@@ -361,7 +356,7 @@
data->selected_file = NULL;
data->update = update;
- dir = opendir(".");
+ dir = opendir(e->cur_tab->dir);
if (!dir)
{
@@ -407,12 +402,13 @@
data->num = FILELIST_SIZE * j + i;
closedir(dir);
+ // free the old images list
+ for (l = e->cur_tab->images; l; l = l->next)
+ if (l->data) free(l->data);
+ e->cur_tab->images = evas_list_free(e->cur_tab->images);
+
ecore_timer_add(0.001, _ex_main_populate_files_timer_cb, data);
- /* Set the dir to the current dir at the end so we avoid stepdown
- * like ".." if we just call the refresh on the listing like after a delete
- */
- e->cur_tab->dir = strdup(".");
}
void
@@ -683,7 +679,7 @@
{
Ex_Tab *tab;
- tab = _ex_tab_new(e, e->cur_tab->cur_path);
+ tab = _ex_tab_new(e, e->cur_tab->dir);
_ex_main_window_tab_append(tab);
_ex_main_populate_files(NULL, EX_TREE_UPDATE_ALL);
@@ -814,7 +810,7 @@
D(("Selecting tab %d\n", e->cur_tab->num));
_ex_tab_select(tab);
-
etk_entry_text_set(ETK_ENTRY(etk_combobox_entry_entry_get(ETK_COMBOBOX_ENTRY(e->combobox_entry))),
e->cur_tab->cur_path);
+
etk_entry_text_set(ETK_ENTRY(etk_combobox_entry_entry_get(ETK_COMBOBOX_ENTRY(e->combobox_entry))),
e->cur_tab->dir);
}
void
@@ -871,7 +867,7 @@
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));
+ _ex_file_get(e->cur_tab->dir));
break;
}
}
===================================================================
RCS file: /cvs/e/e17/apps/exhibit/src/bin/exhibit_menus.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -3 -r1.50 -r1.51
--- exhibit_menus.c 12 Jul 2007 13:33:08 -0000 1.50
+++ exhibit_menus.c 2 Sep 2007 18:37:37 -0000 1.51
@@ -104,7 +104,7 @@
EX_MENU_ITEM_GET_RETURN(obj);
- tab = _ex_tab_new(e, e->cur_tab->cur_path);
+ tab = _ex_tab_new(e, e->cur_tab->dir);
_ex_main_window_tab_append(tab);
_ex_main_populate_files(NULL, EX_TREE_UPDATE_ALL);
}
===================================================================
RCS file: /cvs/e/e17/apps/exhibit/src/bin/exhibit_tab.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- exhibit_tab.c 4 Jul 2007 15:27:44 -0000 1.40
+++ exhibit_tab.c 2 Sep 2007 18:37:37 -0000 1.41
@@ -70,11 +70,7 @@
etk_scrolled_view_policy_set(etk_tree_scrolled_view_get(ETK_TREE(tab->itree)),
ETK_POLICY_AUTO, ETK_POLICY_SHOW);
etk_tree_build(ETK_TREE(tab->itree));
- if (dir)
- tab->dir = strdup(dir);
- else
- tab->dir = strdup(".");
-
+ tab->dir = _ex_path_normalize(dir);
tab->alignment = etk_alignment_new(0.5, 0.5, 0.0, 0.0);
tab->image = etk_image_new();
@@ -133,9 +129,9 @@
void
_ex_tab_select(Ex_Tab *tab)
{
- chdir(tab->cur_path);
+ //chdir(tab->dir);
- D(("_ex_tab_select: changed dir to %s\n", tab->cur_path));
+ D(("_ex_tab_select: changed dir to %s\n", tab->dir));
D(("_ex_tab_select: selecting tab num %d\n", e->cur_tab->num));
if (tab->comment.visible)
@@ -332,7 +328,7 @@
row = ll->data;
etk_tree_row_fields_get(row, etk_tree_nth_col_get(tree, 0),
&icol1_string, &icol2_string, etk_tree_nth_col_get(tree, 1),NULL);
- snprintf(tmp, PATH_MAX * sizeof(char), "file://%s%s\r\n",
tab->cur_path, icol2_string);
+ snprintf(tmp, PATH_MAX * sizeof(char), "file://%s%s\r\n",
tab->dir, icol2_string);
strncat(drag_data, tmp, PATH_MAX * evas_list_count(rows));
if (i <= EX_DND_MAX_NUM * EX_DND_MAX_NUM)
{
@@ -359,7 +355,7 @@
row = etk_tree_selected_row_get(tree);
etk_tree_row_fields_get(row, etk_tree_nth_col_get(tree, 0),
&icol1_string, &icol2_string, etk_tree_nth_col_get(tree, 1),NULL);
drag_data = calloc(PATH_MAX, sizeof(char));
- snprintf(drag_data, PATH_MAX * sizeof(char), "file://%s%s\r\n",
tab->cur_path, icol2_string);
+ snprintf(drag_data, PATH_MAX * sizeof(char), "file://%s%s\r\n",
tab->dir, icol2_string);
image = etk_image_new_from_file(icol1_string, NULL);
etk_image_keep_aspect_set(ETK_IMAGE(image), ETK_TRUE);
etk_widget_size_request_set(image, 96, 96);
@@ -376,6 +372,7 @@
Etk_Tree *tree;
char *dcol_string;
Exhibit *e;
+ char *path, *real_path;
e = data;
_ex_slideshow_stop(e);
@@ -384,13 +381,21 @@
tree = ETK_TREE(object);
etk_tree_row_fields_get(row, etk_tree_nth_col_get(tree, 0), NULL, NULL,
&dcol_string, NULL);
+ path = calloc(PATH_MAX, sizeof(char));
+ snprintf(path, PATH_MAX, "%s/%s", e->cur_tab->dir, dcol_string);
+
+ real_path = ecore_file_realpath(path);
+ E_FREE(path);
+
E_FREE(e->cur_tab->dir);
- e->cur_tab->dir = strdup(dcol_string);
+ e->cur_tab->dir = _ex_path_normalize(real_path);
+ E_FREE(real_path);
+
etk_tree_clear(ETK_TREE(e->cur_tab->itree));
etk_tree_clear(ETK_TREE(e->cur_tab->dtree));
etk_combobox_entry_clear(ETK_COMBOBOX_ENTRY(e->combobox_entry));
_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));
+ 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->dir));
}
static void
@@ -399,6 +404,8 @@
Exhibit *e;
Etk_Tree *tree;
char *icol_string;
+ int row_num;
+ char *path;
e = data;
e->zoom = 0;
@@ -409,7 +416,10 @@
etk_tree_row_fields_get(row, etk_tree_nth_col_get(tree, 0), NULL, NULL,
&icol_string, NULL);
- _ex_main_image_set(e, icol_string);
+ row_num = etk_tree_row_num_get(tree, row);
+ path = (char *) evas_list_nth(e->cur_tab->images, row_num);
+
+ _ex_main_image_set(e, path);
}
static void
===================================================================
RCS file: /cvs/e/e17/apps/exhibit/src/bin/exhibit_thumb.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- exhibit_thumb.c 6 Jul 2007 10:17:54 -0000 1.16
+++ exhibit_thumb.c 2 Sep 2007 18:37:37 -0000 1.17
@@ -146,7 +146,7 @@
tab = _ex_tab_find_by_itree(tree);
snprintf(file, sizeof(file), "%s%s",
- tab->cur_path, icol_string);
+ tab->dir, icol_string);
ep = epsilon_new(file);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs