diff --git a/src/bin/e_fileman_smart.c b/src/bin/e_fileman_smart.c index 7e6aa0d9b..244a51012 100644 --- a/src/bin/e_fileman_smart.c +++ b/src/bin/e_fileman_smart.c @@ -697,8 +697,6 @@ _e_fm_smart_del(Evas_Object *object) if(sd->timer) { - if(sd->dir2) - closedir(sd->dir2); ecore_timer_del(sd->timer); sd->timer = NULL; } @@ -1435,13 +1433,13 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir) Ecore_Sheap *heap; char *f; int type; - DIR *dir2; - struct dirent *dp; + DIR *dir_handle; + struct dirent *dir_entry; if (!dir) return; if ((sd->dir) && (!strcmp(sd->dir, dir))) return; - if (!(dir2 = opendir(dir))) return; + if (!(dir_handle = opendir(dir))) return; /* save the old meta */ if(sd->meta) @@ -1451,17 +1449,19 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir) sd->meta = NULL; } + /* Get list of files for directory */ type = E_FM_FILE_TYPE_NORMAL; list = NULL; - while((dp = readdir(dir2))) + while((dir_entry = readdir(dir_handle))) { - if ((!strcmp(dp->d_name, ".") || (!strcmp (dp->d_name, "..")))) continue; - if ((dp->d_name[0] == '.') && (!(type & E_FM_FILE_TYPE_HIDDEN))) continue; - f = strdup(dp->d_name); + if ((!strcmp(dir_entry->d_name, ".") || (!strcmp (dir_entry->d_name, "..")))) continue; + if ((dir_entry->d_name[0] == '.') && (!(type & E_FM_FILE_TYPE_HIDDEN))) continue; + f = strdup(dir_entry->d_name); list = evas_list_append(list, f); } - closedir(dir2); + closedir(dir_handle); + /* Sort file list */ heap = ecore_sheap_new(ECORE_COMPARE_CB(strcasecmp), evas_list_count(list)); while (list) { @@ -1474,24 +1474,15 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir) sd->files_raw = evas_list_append(sd->files_raw, f); ecore_sheap_destroy(heap); + + /* Set new directory name */ if (sd->dir) free (sd->dir); sd->dir = strdup(dir); - + /* Load meta data for this directory and the Icons in the directory */ _e_fm_dir_meta_load(sd); - if(sd->meta) - { - /* FIXME whats the purpose of this */ - Evas_List *l; - - for(l = sd->meta->files; l; l = l->next) - { - E_Fm_Icon_Metadata *im; - im = l->data; - } - } - else + if (!sd->meta) e_icon_canvas_width_fix(sd->layout, sd->w); /* Reset position */ @@ -1539,7 +1530,6 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir) } } - sd->dir2 = dir2; if(sd->timer) ecore_timer_del(sd->timer); sd->timer = ecore_timer_add(sd->timer_int, _e_fm_dir_files_get, sd); @@ -1635,7 +1625,6 @@ _e_fm_dir_files_get(void *data) if(!sd->files_raw) { sd->timer = NULL; - return 0; } else @@ -3638,6 +3627,7 @@ _e_fm_selector_send_hilite_file(E_Fm_Icon *icon) icon->sd->selector_hilite_func(icon->sd->object, strdup(icon->file->path), icon->sd->selector_data); } +/* Hash function based on directory stat information, Creates unique directory ID. */ static char * _e_fm_dir_meta_dir_id(char *dir) { @@ -3679,6 +3669,12 @@ _e_fm_dir_meta_dir_id(char *dir) return strdup(s); } +/* Read metadata from meta data file /. Set meta data + * from file to sd->meta and create sd->meta->files_hash. + * + * @sd Smart Data for directory + * @return 1 if file found and loaded 0 if no data was loaded + */ static int _e_fm_dir_meta_load(E_Fm_Smart_Data *sd) { @@ -3691,10 +3687,13 @@ _e_fm_dir_meta_load(E_Fm_Smart_Data *sd) hash = _e_fm_dir_meta_dir_id(sd->dir); snprintf(buf, sizeof(buf), "%s/%s", meta_path, hash); + free(hash); ef = eet_open(buf, EET_FILE_MODE_READ); if (!ef) return 0; m = eet_data_read(ef, _e_fm_dir_meta_edd, "metadata"); eet_close(ef); + + /* Hash the metadata for quick access */ if (m) { Evas_List *l; @@ -3708,7 +3707,6 @@ _e_fm_dir_meta_load(E_Fm_Smart_Data *sd) m->files_hash = evas_hash_add(m->files_hash, im->name, im); } } - free(hash); sd->meta = m; return 1; } @@ -3782,11 +3780,11 @@ _e_fm_dir_meta_save(E_Fm_Smart_Data *sd) hash = _e_fm_dir_meta_dir_id(sd->dir); snprintf(buf, sizeof(buf), "%s/%s", meta_path, hash); + free(hash); ef = eet_open(buf, EET_FILE_MODE_WRITE); if (!ef) return 0; ret = eet_data_write(ef, _e_fm_dir_meta_edd, "metadata", sd->meta, 1); eet_close(ef); - free(hash); return ret; } diff --git a/src/bin/e_fileman_smart.h b/src/bin/e_fileman_smart.h index 4a5c4dafa..a57c98a81 100644 --- a/src/bin/e_fileman_smart.h +++ b/src/bin/e_fileman_smart.h @@ -145,7 +145,6 @@ struct _E_Fm_Smart_Data Evas_Hash *mime_menu_hash; /* FIXME delete this */ char *dir; /* FIXME this could be actually a E_Fm_Dir */ - DIR *dir2; double timer_int; Ecore_Timer *timer; diff --git a/src/bin/e_intl.c b/src/bin/e_intl.c index 919df3456..c1dae8f39 100644 --- a/src/bin/e_intl.c +++ b/src/bin/e_intl.c @@ -61,24 +61,6 @@ EAPI int e_intl_init(void) { char *s; - - /* supporeted languages - as we get translations - add them here - * - * if you add a language: - * - * NOTE: add a language NAME for this in e_intl_language_name_get() if - * there isn't one yet (use the english name - then we will add - * translations of the language names to the .po file) - * NOTE: add a translation logic list to take all possible ways to address - * a language locale and convert it to a simplified one that is in - * the list here below. languages can often have multiple ways of - * being addressed (same language spoken in multiple countries or - * many variants of the language). this translation allows all the - * variants to be used and mapped to a simple "single" name for that - * language. if the differences in variants are large (eg simplified - * vs. traditional chinese) we may refer to them as separate languages - * entirely. - */ _e_intl_input_method_config_edd = E_CONFIG_DD_NEW("input_method_config", E_Input_Method_Config); E_CONFIG_VAL(_e_intl_input_method_config_edd, E_Input_Method_Config, version, INT); @@ -125,6 +107,8 @@ e_intl_post_init(void) { if ((e_config->language) && (e_config->language[0] != 0)) e_intl_language_set(e_config->language); + else + e_intl_language_set(NULL); if ((e_config->input_method) && (e_config->input_method[0] != 0)) e_intl_input_method_set(e_config->input_method); @@ -143,14 +127,15 @@ e_intl_post_shutdown(void) } e_intl_input_method_set(NULL); + e_intl_language_set(NULL); + E_EXE_STOP(_e_intl_input_method_exec); return 1; } /* * TODO - * - Set the env variables only after the locale has been validated * - Add error dialogs explaining any errors while setting the locale * * Locale aliases need to be configured * * Locale is invalid @@ -185,36 +170,28 @@ e_intl_language_set(const char *lang) } if (lang) - { - _e_intl_language = strdup(lang); - /* Only set env vars is a non NULL locale was passed */ - if (set_envars) - { - /* FIXME: maybe we should set these anyway? */ - if (getenv("LANGUAGE")) - e_util_env_set("LANGUAGE", _e_intl_language); - if (getenv("LANG")) - e_util_env_set("LANG", _e_intl_language); - if (getenv("LC_ALL")) - e_util_env_set("LC_ALL", _e_intl_language); - if (getenv("LC_MESSAGES")) - e_util_env_set("LC_MESSAGES", _e_intl_language); - } - } + _e_intl_language = strdup(lang); else - { - _e_intl_language = NULL; - } + _e_intl_language = NULL; alias_locale = _e_intl_locale_alias_get(_e_intl_language); if (!_e_intl_locale_validate(alias_locale)) { - fprintf(stderr, "The locale %s cannot be found on your " + fprintf(stderr, "The locale '%s' cannot be found on your " "system. Please install this locale or try " "something else.\n", alias_locale); } else { + /* Only set env vars is a non NULL locale was passed */ + if (set_envars) + { + e_util_env_set("LANGUAGE", _e_intl_language); + e_util_env_set("LANG", _e_intl_language); + e_util_env_set("LC_ALL", _e_intl_language); + e_util_env_set("LC_MESSAGES", _e_intl_language); + } + setlocale(LC_ALL, _e_intl_language); if (_e_intl_language) { @@ -223,15 +200,32 @@ e_intl_language_set(const char *lang) locale_path = _e_intl_language_path_find(alias_locale); if (locale_path == NULL) { - fprintf(stderr, "Can't find the " - "translation path for the locale %s. " - "Please make sure your messages " - "path is in order. If this locale " - "is an alias make sure you have your " - "locale.aliases file in the right place. Note: " - "If your locale is C, POSIX, en_US, en_GB, " - "en_US.utf8 etc. this is normal.\n", - alias_locale); + char * match_lang; + + match_lang = _e_intl_locale_canonic_get(alias_locale, E_LOC_LANG); + + /* If locale is C or some form of en don't report an error */ + if ( match_lang == NULL && strcmp (alias_locale, "C") ) + { + fprintf(stderr, "The locale you have chosen '%s' " + "appears to be an alias, however, it can not be " + "resloved. Please make sure you have a " + "'locale.aliases' file in your 'messages' path " + "which can resolve this alias.\n" + "\n" + "Enlightenment will not be translated.\n", + alias_locale); + } + else if ( match_lang != NULL && strcmp(match_lang, "en") ) + { + fprintf(stderr, "The translation files for the " + "locale you have chosen (%s) cannot be found in " + "your 'messages' path.\n" + "\n" + "Enlightenment will not be translated.\n", + alias_locale); + } + E_FREE(match_lang); } else { @@ -358,7 +352,7 @@ e_intl_input_method_set(const char *method) } } - /* Need to free up the directory listing */ + /* Free up the directory listing */ while (input_methods) { E_Input_Method_Config *imc; diff --git a/src/bin/e_ipc_codec.h b/src/bin/e_ipc_codec.h index e91224080..33010864f 100644 --- a/src/bin/e_ipc_codec.h +++ b/src/bin/e_ipc_codec.h @@ -144,8 +144,10 @@ EAPI int e_ipc_codec_3int_3str_dec(char *data, int bytes, E_Ipc_3Int_3Str * EAPI void *e_ipc_codec_3int_3str_enc(int val1, int val2, int val3, char *str1, char *str2, char *str3, int *size_ret); EAPI int e_ipc_codec_3int_3str_list_dec(char *data, int bytes, Evas_List **dest); EAPI void *e_ipc_codec_3int_3str_list_enc(Evas_List *list, int *size_ret); + EAPI int e_ipc_codec_str_4int_dec(char *data, int bytes, E_Ipc_Str_4Int **dest); EAPI void *e_ipc_codec_str_4int_enc(char *str1, int val1, int val2, int val3, int val4, int *size_ret); - +EAPI int e_ipc_codec_str_4int_list_dec(char *data, int bytes, Evas_List **dest); +EAPI void *e_ipc_codec_str_4int_list_enc(Evas_List *list, int *size_ret); #endif #endif diff --git a/src/bin/e_ipc_handlers.h b/src/bin/e_ipc_handlers.h index efef15409..d5d127f6a 100644 --- a/src/bin/e_ipc_handlers.h +++ b/src/bin/e_ipc_handlers.h @@ -1538,7 +1538,8 @@ break; LIST_DATA() Evas_List *dir_list = NULL; E_PATH_GET(path, s); - dir_list = e_path_dir_list_get(path); + if (path) + dir_list = e_path_dir_list_get(path); E_Path_Dir *p; if (s) { @@ -1632,7 +1633,7 @@ break; STRING2(s1, s2, e_2str, HDL); { E_PATH_GET(path, s1) - e_path_user_path_append(path, s2); + if (path) e_path_user_path_append(path, s2); } SAVE; END_STRING2(e_2str) @@ -1651,7 +1652,7 @@ break; STRING2(s1, s2, e_2str, HDL); { E_PATH_GET(path, s1) - e_path_user_path_prepend(path, s2); + if (path) e_path_user_path_prepend(path, s2); } SAVE; END_STRING2(e_2str) @@ -1670,7 +1671,7 @@ break; STRING2(s1, s2, e_2str, HDL); { E_PATH_GET(path, s1) - e_path_user_path_remove(path, s2); + if (path) e_path_user_path_remove(path, s2); } SAVE; END_STRING2(e_2str)