Enlightenment CVS committal Author : raster Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_actions.c e_actions.h e_alert.c e_alert.h e_apps.c e_apps_cache.c Log Message: alert made more robust just in case... but mor eimportantle e_apps and e_apps_cache now use stringshare. bit by bit my friends... bit by bit... =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_actions.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -3 -r1.41 -r1.42 --- e_actions.c 1 Dec 2005 07:10:32 -0000 1.41 +++ e_actions.c 2 Dec 2005 09:08:58 -0000 1.42 @@ -1412,7 +1412,7 @@ } E_Action * -e_action_add(char *name) +e_action_add(const char *name) { E_Action *act; @@ -1421,15 +1421,15 @@ { act = E_OBJECT_ALLOC(E_Action, E_ACTION_TYPE, _e_action_free); if (!act) return NULL; - act->name = strdup(name); - actions = evas_hash_add(actions, name, act); + act->name = name; + actions = evas_hash_direct_add(actions, act->name, act); action_names = evas_list_append(action_names, name); } return act; } E_Action * -e_action_find(char *name) +e_action_find(const char *name) { E_Action *act; @@ -1444,7 +1444,6 @@ { actions = evas_hash_del(actions, act->name, act); action_names = evas_list_remove(action_names, act->name); - E_FREE(act->name); free(act); } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_actions.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- e_actions.h 28 Sep 2005 22:47:07 -0000 1.7 +++ e_actions.h 2 Dec 2005 09:08:58 -0000 1.8 @@ -32,8 +32,8 @@ EAPI int e_actions_shutdown(void); EAPI Evas_List *e_action_name_list(void); -EAPI E_Action *e_action_add(char *name); -EAPI E_Action *e_action_find(char *name); +EAPI E_Action *e_action_add(const char *name); +EAPI E_Action *e_action_find(const char *name); #endif #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_alert.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- e_alert.c 22 Nov 2005 13:28:10 -0000 1.5 +++ e_alert.c 2 Dec 2005 09:08:58 -0000 1.6 @@ -19,12 +19,18 @@ static char *title = NULL, *str1 = NULL, *str2 = NULL, *str3 = NULL; static Font font = 0; static XFontStruct *fs = NULL; - +static GC gc = 0; +static Window win = 0, b1 = 0, b2 = 0, b3 = 0; +static int ww = 600, hh = 440; /* externally accessible functions */ int -e_alert_init(char *disp) +e_alert_init(const char *disp) { + XGCValues gcv; + int wid, hih, mask; + XSetWindowAttributes att; + dd = XOpenDisplay(disp); if (!dd) return 0; font = XLoadFont(dd, "fixed"); @@ -36,12 +42,41 @@ str1 = "(F1) Ignore"; str2 = "(F2) Restart"; str3 = "(F3) Exit"; + + wid = DisplayWidth(dd, DefaultScreen(dd)); + hih = DisplayHeight(dd, DefaultScreen(dd)); + att.background_pixel = WhitePixel(dd, DefaultScreen(dd)); + att.border_pixel = BlackPixel(dd, DefaultScreen(dd)); + att.override_redirect = True; + mask = CWBackPixel | CWBorderPixel | CWOverrideRedirect; + + win = XCreateWindow(dd, DefaultRootWindow(dd), + (wid - ww) / 2, (hih - hh) / 2, ww, hh, 0, + CopyFromParent, InputOutput, + CopyFromParent, mask, &att); + + b1 = XCreateWindow(dd, win, -100, -100, 1, 1, 0, CopyFromParent, + InputOutput, CopyFromParent, mask, &att); + b2 = XCreateWindow(dd, win, -100, -100, 1, 1, 0, CopyFromParent, + InputOutput, CopyFromParent, mask, &att); + b3 = XCreateWindow(dd, win, -100, -100, 1, 1, 0, CopyFromParent, + InputOutput, CopyFromParent, mask, &att); + XMapWindow(dd, b1); + XMapWindow(dd, b2); + XMapWindow(dd, b3); + + gc = XCreateGC(dd, win, 0, &gcv); + XSetForeground(dd, gc, att.border_pixel); + XSelectInput(dd, win, KeyPressMask | KeyReleaseMask | ExposureMask); + return 1; } int e_alert_shutdown(void) { + XDestroyWindow(dd, win); + XFreeGC(dd, gc); XFreeFont(dd, fs); XCloseDisplay(dd); title = NULL; @@ -51,22 +86,19 @@ dd = NULL; font = 0; fs = NULL; + gc = 0; return 1; } void -e_alert_show(char *text) +e_alert_show(const char *text) { - int wid, hih, w, i, j, k, mask; - XGCValues gcv; - GC gc; + int w, i, j, k; char line[1024]; XEvent ev; - XSetWindowAttributes att; - int fw, fh, ww, hh, mh; + int fw, fh, mh; KeyCode key; int button; - Window win = 0, b1 = 0, b2 = 0, b3 = 0; if (!text) return; @@ -77,53 +109,20 @@ exit(-1); } - ww = 600; - hh = 440; - - wid = DisplayWidth(dd, DefaultScreen(dd)); - hih = DisplayHeight(dd, DefaultScreen(dd)); - att.background_pixel = WhitePixel(dd, DefaultScreen(dd)); - att.border_pixel = BlackPixel(dd, DefaultScreen(dd)); - att.override_redirect = True; - mask = CWBackPixel | CWBorderPixel | CWOverrideRedirect; - - win = XCreateWindow(dd, DefaultRootWindow(dd), - (wid - ww) / 2, (hih - hh) / 2, ww, hh, 0, - CopyFromParent, InputOutput, - CopyFromParent, mask, &att); - - b1 = XCreateWindow(dd, win, -100, -100, 1, 1, 0, CopyFromParent, - InputOutput, CopyFromParent, mask, &att); - b2 = XCreateWindow(dd, win, -100, -100, 1, 1, 0, CopyFromParent, - InputOutput, CopyFromParent, mask, &att); - b3 = XCreateWindow(dd, win, -100, -100, 1, 1, 0, CopyFromParent, - InputOutput, CopyFromParent, mask, &att); - XMapWindow(dd, b1); - XMapWindow(dd, b2); - XMapWindow(dd, b3); - - gc = XCreateGC(dd, win, 0, &gcv); - XSetForeground(dd, gc, att.border_pixel); - XSelectInput(dd, win, KeyPressMask | KeyReleaseMask | ExposureMask); - fh = fs->ascent + fs->descent; mh = ((ww - 20) / 3) - 20; /* fixed size... */ w = 5 + (((ww - 20 - mh) * 0) / 4); XMoveResizeWindow(dd, b1, w, hh - 15 - fh, mh + 10, fh + 10); - XSelectInput(dd, b1, - ButtonPressMask | ButtonReleaseMask | ExposureMask); + XSelectInput(dd, b1, ButtonPressMask | ButtonReleaseMask | ExposureMask); w = 5 + (((ww - 20 - mh) * 1) / 2); XMoveResizeWindow(dd, b2, w, hh - 15 - fh, mh + 10, fh + 10); - XSelectInput(dd, b2, - ButtonPressMask | ButtonReleaseMask | ExposureMask); + XSelectInput(dd, b2, ButtonPressMask | ButtonReleaseMask | ExposureMask); w = 5 + (((ww - 20 - mh) * 2) / 2); XMoveResizeWindow(dd, b3, w, hh - 15 - fh, mh + 10, fh + 10); - XSelectInput(dd, b3, - ButtonPressMask | ButtonReleaseMask | ExposureMask); + XSelectInput(dd, b3, ButtonPressMask | ButtonReleaseMask | ExposureMask); - XSync(dd, False); XMapWindow(dd, win); XGrabPointer(dd, win, True, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime); @@ -212,7 +211,6 @@ } } XDestroyWindow(dd, win); - XFreeGC(dd, gc); XSync(dd, False); switch (button) =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_alert.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_alert.h 15 Jun 2005 05:06:45 -0000 1.1 +++ e_alert.h 2 Dec 2005 09:08:58 -0000 1.2 @@ -7,10 +7,10 @@ #ifndef E_ALERT_H #define E_ALERT_H -int e_alert_init(char *disp); +int e_alert_init(const char *disp); int e_alert_shutdown(void); -void e_alert_show(char *text); +void e_alert_show(const char *text); #endif #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_apps.c,v retrieving revision 1.104 retrieving revision 1.105 diff -u -3 -r1.104 -r1.105 --- e_apps.c 24 Nov 2005 01:37:01 -0000 1.104 +++ e_apps.c 2 Dec 2005 09:08:58 -0000 1.105 @@ -123,11 +123,11 @@ e_app_cache_init(); home = e_user_homedir_get(); snprintf(buf, sizeof(buf), "%s/.e/e/applications/trash", home); - _e_apps_path_trash = strdup(buf); + _e_apps_path_trash = evas_stringshare_add(buf); snprintf(buf, sizeof(buf), "%s/.e/e/applications/all", home); - _e_apps_path_all = strdup(buf); + _e_apps_path_all = evas_stringshare_add(buf); free(home); - _e_apps_repositories = evas_list_append(_e_apps_repositories, strdup(buf)); + _e_apps_repositories = evas_list_append(_e_apps_repositories, evas_stringshare_add(buf)); _e_apps_exit_handler = ecore_event_handler_add(ECORE_EVENT_EXE_EXIT, _e_apps_cb_exit, NULL); _e_apps_border_add_handler = ecore_event_handler_add(E_EVENT_BORDER_ADD, _e_app_cb_event_border_add, NULL); _e_apps_all = e_app_new(buf, 1); @@ -145,7 +145,7 @@ } while (_e_apps_repositories) { - free(_e_apps_repositories->data); + evas_stringshare_del(_e_apps_repositories->data); _e_apps_repositories = evas_list_remove_list(_e_apps_repositories, _e_apps_repositories); } if (_e_apps_exit_handler) @@ -158,8 +158,8 @@ ecore_event_handler_del(_e_apps_border_add_handler); _e_apps_border_add_handler = NULL; } - free(_e_apps_path_trash); - free(_e_apps_path_all); + evas_stringshare_del(_e_apps_path_trash); + evas_stringshare_del(_e_apps_path_all); { Evas_List *l; for (l = _e_apps_list; l; l = l->next) @@ -235,7 +235,7 @@ /* no image for now */ a->image = NULL; /* record the path */ - a->path = strdup(path); + a->path = evas_stringshare_add(path); if (ecore_file_is_dir(a->path)) { @@ -243,7 +243,7 @@ if (ecore_file_exists(buf)) e_app_fields_fill(a, buf); else - a->name = strdup(ecore_file_get_file(a->path)); + a->name = evas_stringshare_add(ecore_file_get_file(a->path)); if (scan_subdirs) e_app_subdir_scan(a, scan_subdirs); a->monitor = ecore_file_monitor_add(a->path, _e_app_cb_monitor, a); @@ -272,7 +272,7 @@ error: if (a->monitor) ecore_file_monitor_del(a->monitor); - if (a->path) free(a->path); + if (a->path) evas_stringshare_del(a->path); e_app_fields_empty(a); free(a); return NULL; @@ -285,8 +285,7 @@ a = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free); a->image = NULL; - if (path) - a->path = strdup(path); + if (path) a->path = evas_stringshare_add(path); return a; } @@ -469,8 +468,8 @@ if (ecore_file_exists(buf)) snprintf(buf, sizeof(buf), "%s/%s", before->parent->path, ecore_file_get_file(add->path)); ecore_file_mv(add->path, buf); - free(add->path); - add->path = strdup(buf); + evas_stringshare_del(add->path); + add->path = evas_stringshare_add(buf); } _e_app_save_order(before->parent); @@ -495,8 +494,8 @@ if (ecore_file_exists(buf)) snprintf(buf, sizeof(buf), "%s/%s", parent->path, ecore_file_get_file(add->path)); ecore_file_mv(add->path, buf); - free(add->path); - add->path = strdup(buf); + evas_stringshare_del(add->path); + add->path = evas_stringshare_add(buf); } _e_app_save_order(parent); @@ -628,8 +627,8 @@ /* Move to trash */ snprintf(buf, sizeof(buf), "%s/%s", _e_apps_path_trash, ecore_file_get_file(a->path)); ecore_file_mv(a->path, buf); - free(a->path); - a->path = strdup(buf); + evas_stringshare_del(a->path); + a->path = evas_stringshare_add(buf); } _e_app_save_order(a->parent); _e_app_change(a, E_APP_DEL); @@ -867,6 +866,15 @@ ef = eet_open(path, EET_FILE_MODE_READ); if (!ef) return; +#define STORE(member) \ + if (v) \ + { \ + str = alloca(size + 1); \ + memcpy(str, v, size); \ + str[size] = 0; \ + a->member = evas_stringshare_add(str); \ + free(v); \ + } if (lang) { snprintf(buf, sizeof(buf), "app/info/name[%s]", lang); @@ -875,14 +883,7 @@ } else v = eet_read(ef, "app/info/name", &size); - if (v) - { - str = malloc(size + 1); - memcpy(str, v, size); - str[size] = 0; - a->name = str; - free(v); - } + STORE(name); if (lang) { @@ -892,15 +893,7 @@ } else v = eet_read(ef, "app/info/generic", &size); - - if (v) - { - str = malloc(size + 1); - memcpy(str, v, size); - str[size] = 0; - a->generic = str; - free(v); - } + STORE(generic); if (lang) { @@ -910,70 +903,20 @@ } else v = eet_read(ef, "app/info/comment", &size); - - if (v) - { - str = malloc(size + 1); - memcpy(str, v, size); - str[size] = 0; - a->comment = str; - free(v); - } + STORE(comment); v = eet_read(ef, "app/info/exe", &size); - if (v) - { - str = malloc(size + 1); - memcpy(str, v, size); - str[size] = 0; - a->exe = str; - free(v); - } + STORE(exe); v = eet_read(ef, "app/icon/class", &size); - if (v) - { - str = malloc(size + 1); - memcpy(str, v, size); - str[size] = 0; - a->icon_class = str; - free(v); - } + STORE(icon_class); v = eet_read(ef, "app/window/name", &size); - if (v) - { - str = malloc(size + 1); - memcpy(str, v, size); - str[size] = 0; - a->win_name = str; - free(v); - } + STORE(win_name); v = eet_read(ef, "app/window/class", &size); - if (v) - { - str = malloc(size + 1); - memcpy(str, v, size); - str[size] = 0; - a->win_class = str; - free(v); - } + STORE(win_class); v = eet_read(ef, "app/window/title", &size); - if (v) - { - str = malloc(size + 1); - memcpy(str, v, size); - str[size] = 0; - a->win_title = str; - free(v); - } + STORE(win_title); v = eet_read(ef, "app/window/role", &size); - if (v) - { - str = malloc(size + 1); - memcpy(str, v, size); - str[size] = 0; - a->win_role = str; - free(v); - } + STORE(win_role); v = eet_read(ef, "app/info/startup_notify", &size); if (v) { @@ -1105,15 +1048,24 @@ void e_app_fields_empty(E_App *a) { - E_FREE(a->name); - E_FREE(a->generic); - E_FREE(a->comment); - E_FREE(a->exe); - E_FREE(a->icon_class); - E_FREE(a->win_name); - E_FREE(a->win_class); - E_FREE(a->win_title); - E_FREE(a->win_role); + if (a->name) evas_stringshare_del(a->name); + if (a->generic) evas_stringshare_del(a->generic); + if (a->comment) evas_stringshare_del(a->comment); + if (a->exe) evas_stringshare_del(a->exe); + if (a->icon_class) evas_stringshare_del(a->icon_class); + if (a->win_name) evas_stringshare_del(a->win_name); + if (a->win_class) evas_stringshare_del(a->win_class); + if (a->win_title) evas_stringshare_del(a->win_title); + if (a->win_role) evas_stringshare_del(a->win_role); + a->name = NULL; + a->generic = NULL; + a->comment = NULL; + a->exe = NULL; + a->icon_class = NULL; + a->win_name = NULL; + a->win_class = NULL; + a->win_title = NULL; + a->win_role = NULL; } Ecore_List * @@ -1358,7 +1310,7 @@ _e_apps = evas_hash_del(_e_apps, a->path, a); _e_apps_list = evas_list_remove(_e_apps_list, a); e_app_fields_empty(a); - E_FREE(a->path); + if (a->path) evas_stringshare_del(a->path); free(a); } } @@ -1460,7 +1412,7 @@ else if (event == ECORE_FILE_EVENT_DELETED_FILE) { e_app_fields_empty(app); - app->name = strdup(ecore_file_get_file(app->path)); + app->name = evas_stringshare_add(ecore_file_get_file(app->path)); } else { @@ -1856,7 +1808,7 @@ static void _e_app_cache_copy(E_App_Cache *ac, E_App *a) { -#define IF_DUP(x) if ((ac->x) && (ac->x[0] != 0)) a->x = strdup(ac->x) +#define IF_DUP(x) if ((ac->x) && (ac->x[0] != 0)) a->x = evas_stringshare_add(ac->x) IF_DUP(name); IF_DUP(generic); IF_DUP(comment); @@ -1891,7 +1843,7 @@ ecore_list_destroy(sc->files); e_app_cache_free(sc->cache); ecore_timer_del(sc->timer); - free(sc->path); + evas_stringshare_del(sc->path); free(sc); printf("Cache scan finish.\n"); return 0; @@ -1942,7 +1894,7 @@ a = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free); _e_app_cache_copy(ac, a); - a->path = strdup(path); + a->path = evas_stringshare_add(path); a->scanned = 1; for (l = ac->subapps; l; l = l->next) { @@ -1965,10 +1917,10 @@ _e_app_cache_copy(ac2, a2); if (ac2->is_dir) { - E_FREE(a2->exe); + if (a2->exe) evas_stringshare_del(a2->exe); } a2->parent = a; - a2->path = strdup(buf); + a2->path = evas_stringshare_add(buf); a->subapps = evas_list_append(a->subapps, a2); _e_apps = evas_hash_add(_e_apps, a2->path, a2); _e_apps_list = evas_list_prepend(_e_apps_list, a2); @@ -2009,7 +1961,7 @@ sc = calloc(1, sizeof(E_App_Scan_Cache)); if (sc) { - sc->path = strdup(path); + sc->path = evas_stringshare_add(path); sc->cache = ac; sc->app = a; sc->files = e_app_dir_file_list_get(a); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_apps_cache.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- e_apps_cache.c 25 Sep 2005 04:58:18 -0000 1.3 +++ e_apps_cache.c 2 Dec 2005 09:08:58 -0000 1.4 @@ -4,14 +4,7 @@ #include "e.h" #define NEWD(str, typ) \ - eet_data_descriptor_new(str, sizeof(typ), \ - (void *(*) (void *))evas_list_next, \ - (void *(*) (void *, void *))evas_list_append, \ - (void *(*) (void *))evas_list_data, \ - (void *(*) (void *))evas_list_free, \ - (void (*) (void *, int (*) (void *, const char *, void *, void *), void *))evas_hash_foreach, \ - (void *(*) (void *, const char *, void *))evas_hash_add, \ - (void (*) (void *))evas_hash_free) + { eddc.name = str; eddc.size = sizeof(typ); } #define FREED(eed) \ if (eed) \ @@ -31,7 +24,24 @@ int e_app_cache_init(void) { - _e_app_cache_edd = NEWD("E_App_Cache", E_App_Cache); + Eet_Data_Descriptor_Class eddc; + + eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION; + eddc.func.mem_alloc = NULL; + eddc.func.mem_free = NULL; + eddc.func.str_alloc = evas_stringshare_add; + eddc.func.str_free = evas_stringshare_del; + eddc.func.list_next = evas_list_next; + eddc.func.list_append = evas_list_append; + eddc.func.list_data = evas_list_data; + eddc.func.list_free = evas_list_free; + eddc.func.hash_foreach = evas_hash_foreach; + eddc.func.hash_add = evas_hash_add; + eddc.func.hash_free = evas_hash_free; + + NEWD("E_App_Cache", E_App_Cache); + _e_app_cache_edd = eet_data_descriptor2_new(&eddc); + NEWI("nm", name, EET_T_STRING); NEWI("gn", generic, EET_T_STRING); NEWI("cm", comment, EET_T_STRING); @@ -113,7 +123,7 @@ if ((!ac2->is_link) && (!ac2->is_dir)) ac2->file_mod_time = ecore_file_mod_time(buf); ac->subapps = evas_list_append(ac->subapps, ac2); - ac->subapps_hash = evas_hash_add(ac->subapps_hash, ac2->file, ac2); + ac->subapps_hash = evas_hash_direct_add(ac->subapps_hash, ac2->file, ac2); } } return ac; @@ -123,16 +133,16 @@ e_app_cache_free(E_App_Cache *ac) { if (!ac) return; - E_FREE(ac->name); - E_FREE(ac->generic); - E_FREE(ac->comment); - E_FREE(ac->exe); - E_FREE(ac->file); - E_FREE(ac->win_name); - E_FREE(ac->win_class); - E_FREE(ac->win_title); - E_FREE(ac->win_role); - E_FREE(ac->icon_class); + if (ac->name) evas_stringshare_del(ac->name); + if (ac->generic) evas_stringshare_del(ac->generic); + if (ac->comment) evas_stringshare_del(ac->comment); + if (ac->exe) evas_stringshare_del(ac->exe); + if (ac->file) evas_stringshare_del(ac->file); + if (ac->win_name) evas_stringshare_del(ac->win_name); + if (ac->win_class) evas_stringshare_del(ac->win_class); + if (ac->win_title) evas_stringshare_del(ac->win_title); + if (ac->win_role) evas_stringshare_del(ac->win_role); + if (ac->icon_class) evas_stringshare_del(ac->icon_class); while (ac->subapps) { E_App_Cache *ac2; @@ -161,17 +171,15 @@ return ret; } - - static void _e_eapp_cache_fill(E_App_Cache *ac, E_App *a) { -#define IF_DUP(x) if (a->x) ac->x = strdup(a->x) +#define IF_DUP(x) if (a->x) ac->x = evas_stringshare_add(a->x) IF_DUP(name); IF_DUP(generic); IF_DUP(comment); IF_DUP(exe); - ac->file = strdup(ecore_file_get_file(a->path)); + ac->file = evas_stringshare_add(ecore_file_get_file(a->path)); IF_DUP(win_name); IF_DUP(win_class); IF_DUP(win_title); ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs