summaryrefslogtreecommitdiff
path: root/src/lib/efreet
diff options
context:
space:
mode:
authorSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-06-21 10:39:40 +0200
committerSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-06-21 10:39:40 +0200
commitaa8565b372c0a2a6a828b624d32a5b69e70bdd7c (patch)
tree3b1ff45cc5dc5a6331c670446d324983108946dc /src/lib/efreet
parent70d491fd687a1d91993b786b41d2f4d415cd2a78 (diff)
efreet: Add data to async request
Diffstat (limited to 'src/lib/efreet')
-rw-r--r--src/lib/efreet/efreet_menu.c22
-rw-r--r--src/lib/efreet/efreet_menu.h8
2 files changed, 17 insertions, 13 deletions
diff --git a/src/lib/efreet/efreet_menu.c b/src/lib/efreet/efreet_menu.c
index d4bbeb6a4d..713cfe981e 100644
--- a/src/lib/efreet/efreet_menu.c
+++ b/src/lib/efreet/efreet_menu.c
@@ -160,6 +160,7 @@ typedef struct Efreet_Menu_Async Efreet_Menu_Async;
160struct Efreet_Menu_Async 160struct Efreet_Menu_Async
161{ 161{
162 Efreet_Menu_Cb func; 162 Efreet_Menu_Cb func;
163 void *data;
163 Eina_Stringshare *path; 164 Eina_Stringshare *path;
164}; 165};
165 166
@@ -173,7 +174,7 @@ static Eina_Hash *efreet_menu_filter_cbs = NULL;
173static Eina_Hash *efreet_menu_move_cbs = NULL; 174static Eina_Hash *efreet_menu_move_cbs = NULL;
174static Eina_Hash *efreet_menu_layout_cbs = NULL; 175static Eina_Hash *efreet_menu_layout_cbs = NULL;
175 176
176static Efreet_Menu *efreet_menu_internal_get(Efreet_Menu_Cb func); 177static Efreet_Menu *efreet_menu_internal_get(Efreet_Menu_Cb func, void *data);
177 178
178static Efreet_Menu_Internal *efreet_menu_by_name_find(Efreet_Menu_Internal *internal, 179static Efreet_Menu_Internal *efreet_menu_by_name_find(Efreet_Menu_Internal *internal,
179 const char *name, 180 const char *name,
@@ -521,24 +522,25 @@ efreet_menu_file_set(const char *file)
521} 522}
522 523
523EAPI void 524EAPI void
524efreet_menu_async_get(Efreet_Menu_Cb func) 525efreet_menu_async_get(Efreet_Menu_Cb func, void *data)
525{ 526{
526 efreet_menu_internal_get(func); 527 efreet_menu_internal_get(func, data);
527} 528}
528 529
529EAPI Efreet_Menu * 530EAPI Efreet_Menu *
530efreet_menu_get(void) 531efreet_menu_get(void)
531{ 532{
532 return efreet_menu_internal_get(NULL); 533 return efreet_menu_internal_get(NULL, NULL);
533} 534}
534 535
535EAPI void 536EAPI void
536efreet_menu_async_parse(const char *path, Efreet_Menu_Cb func) 537efreet_menu_async_parse(const char *path, Efreet_Menu_Cb func, void *data)
537{ 538{
538 Efreet_Menu_Async *async; 539 Efreet_Menu_Async *async;
539 540
540 async = NEW(Efreet_Menu_Async, 1); 541 async = NEW(Efreet_Menu_Async, 1);
541 async->func = func; 542 async->func = func;
543 async->data = data;
542 async->path = eina_stringshare_add(path); 544 async->path = eina_stringshare_add(path);
543 ecore_thread_run(_efreet_menu_async_parse_cb, NULL, NULL, async); 545 ecore_thread_run(_efreet_menu_async_parse_cb, NULL, NULL, async);
544} 546}
@@ -722,7 +724,7 @@ efreet_menu_dump(Efreet_Menu *menu, const char *indent)
722} 724}
723 725
724static Efreet_Menu * 726static Efreet_Menu *
725efreet_menu_internal_get(Efreet_Menu_Cb func) 727efreet_menu_internal_get(Efreet_Menu_Cb func, void *data)
726{ 728{
727 char menu[PATH_MAX]; 729 char menu[PATH_MAX];
728 const char *dir; 730 const char *dir;
@@ -736,7 +738,7 @@ efreet_menu_internal_get(Efreet_Menu_Cb func)
736 { 738 {
737 if (func) 739 if (func)
738 { 740 {
739 efreet_menu_async_parse(efreet_menu_file, func); 741 efreet_menu_async_parse(efreet_menu_file, func, data);
740 return NULL; 742 return NULL;
741 } 743 }
742 else 744 else
@@ -752,7 +754,7 @@ efreet_menu_internal_get(Efreet_Menu_Cb func)
752 { 754 {
753 if (func) 755 if (func)
754 { 756 {
755 efreet_menu_async_parse(menu, func); 757 efreet_menu_async_parse(menu, func, data);
756 return NULL; 758 return NULL;
757 } 759 }
758 else 760 else
@@ -769,7 +771,7 @@ efreet_menu_internal_get(Efreet_Menu_Cb func)
769 { 771 {
770 if (func) 772 if (func)
771 { 773 {
772 efreet_menu_async_parse(menu, func); 774 efreet_menu_async_parse(menu, func, data);
773 return NULL; 775 return NULL;
774 } 776 }
775 else 777 else
@@ -3866,7 +3868,7 @@ _efreet_menu_async_parse_cb(void *data, Ecore_Thread *thread EINA_UNUSED)
3866 3868
3867 menu = efreet_menu_parse(async->path); 3869 menu = efreet_menu_parse(async->path);
3868 ecore_thread_main_loop_begin(); 3870 ecore_thread_main_loop_begin();
3869 async->func(menu); 3871 async->func(async->data, menu);
3870 ecore_thread_main_loop_end(); 3872 ecore_thread_main_loop_end();
3871 eina_stringshare_del(async->path); 3873 eina_stringshare_del(async->path);
3872 free(async); 3874 free(async);
diff --git a/src/lib/efreet/efreet_menu.h b/src/lib/efreet/efreet_menu.h
index f4b999c074..fa58692cd2 100644
--- a/src/lib/efreet/efreet_menu.h
+++ b/src/lib/efreet/efreet_menu.h
@@ -49,7 +49,7 @@ struct Efreet_Menu
49 * 49 *
50 * @since 1.8 50 * @since 1.8
51 */ 51 */
52typedef void *(*Efreet_Menu_Cb) (Efreet_Menu *menu); 52typedef void *(*Efreet_Menu_Cb) (void *data, Efreet_Menu *menu);
53 53
54/** 54/**
55 * @return Returns no value 55 * @return Returns no value
@@ -79,10 +79,11 @@ EAPI void efreet_menu_file_set(const char *file);
79 * Creates the Efreet_Menu representation of the default menu or 79 * Creates the Efreet_Menu representation of the default menu or
80 * NULL if none found and returns it in the callback. 80 * NULL if none found and returns it in the callback.
81 * @param func function to call when menu is created 81 * @param func function to call when menu is created
82 * @param data user data to return in callback
82 * 83 *
83 * @since 1.8 84 * @since 1.8
84 */ 85 */
85EAPI void efreet_menu_async_get(Efreet_Menu_Cb func); 86EAPI void efreet_menu_async_get(Efreet_Menu_Cb func, void *data);
86 87
87/** 88/**
88 * @return Returns the Efreet_Menu representation of the default menu or 89 * @return Returns the Efreet_Menu representation of the default menu or
@@ -96,10 +97,11 @@ EAPI Efreet_Menu *efreet_menu_get(void);
96 * returns it in the callback 97 * returns it in the callback
97 * @param path The path of the menu to load 98 * @param path The path of the menu to load
98 * @param func function to call when menu is created 99 * @param func function to call when menu is created
100 * @param data user data to return in callback
99 * 101 *
100 * @since 1.8 102 * @since 1.8
101 */ 103 */
102EAPI void efreet_menu_async_parse(const char *path, Efreet_Menu_Cb func); 104EAPI void efreet_menu_async_parse(const char *path, Efreet_Menu_Cb func, void *data);
103 105
104/** 106/**
105 * @param path The path of the menu to load 107 * @param path The path of the menu to load