summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <m.blumenkran@samsung.com>2013-06-18 11:18:06 +0100
committerMike Blumenkrantz <m.blumenkran@samsung.com>2013-06-18 15:44:56 +0100
commitf8448c071ae183da994b773824778da98f57357d (patch)
tree8369fac4b3a1e250058f880d9eb422995a83db7d /src
parent30c908cdc085895427cc55569387f01c7f658307 (diff)
use new e_exec events to track/add/del new exes which are not launched from ibar
Diffstat (limited to 'src')
-rw-r--r--src/modules/ibar/e_mod_main.c77
1 files changed, 62 insertions, 15 deletions
diff --git a/src/modules/ibar/e_mod_main.c b/src/modules/ibar/e_mod_main.c
index 86a488c21..cec72f4c3 100644
--- a/src/modules/ibar/e_mod_main.c
+++ b/src/modules/ibar/e_mod_main.c
@@ -51,8 +51,8 @@ struct _IBar
51 Evas_Object *o_drop_over, *o_empty; 51 Evas_Object *o_drop_over, *o_empty;
52 IBar_Icon *ic_drop_before; 52 IBar_Icon *ic_drop_before;
53 int drop_before; 53 int drop_before;
54 Eina_Hash *icon_hash;
54 Eina_Inlist *icons; 55 Eina_Inlist *icons;
55 unsigned int icons_count;
56 IBar_Order *io; 56 IBar_Order *io;
57 Evas_Coord dnd_x, dnd_y; 57 Evas_Coord dnd_x, dnd_y;
58 Eina_Bool focused : 1; 58 Eina_Bool focused : 1;
@@ -79,6 +79,7 @@ struct _IBar_Icon
79 int x, y; 79 int x, y;
80 } drag; 80 } drag;
81 Eina_Bool focused : 1; 81 Eina_Bool focused : 1;
82 Eina_Bool not_in_order : 1;
82}; 83};
83 84
84static IBar *_ibar_new(Evas *evas, Instance *inst); 85static IBar *_ibar_new(Evas *evas, Instance *inst);
@@ -262,7 +263,7 @@ _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
262 case E_GADCON_ORIENT_CORNER_BL: 263 case E_GADCON_ORIENT_CORNER_BL:
263 case E_GADCON_ORIENT_CORNER_BR: 264 case E_GADCON_ORIENT_CORNER_BR:
264 _ibar_orient_set(inst->ibar, 1); 265 _ibar_orient_set(inst->ibar, 1);
265 e_gadcon_client_aspect_set(gcc, inst->ibar->icons_count * 16, 16); 266 e_gadcon_client_aspect_set(gcc, eina_hash_population(inst->ibar->icon_hash) * 16, 16);
266 break; 267 break;
267 268
268 case E_GADCON_ORIENT_VERT: 269 case E_GADCON_ORIENT_VERT:
@@ -273,7 +274,7 @@ _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
273 case E_GADCON_ORIENT_CORNER_LB: 274 case E_GADCON_ORIENT_CORNER_LB:
274 case E_GADCON_ORIENT_CORNER_RB: 275 case E_GADCON_ORIENT_CORNER_RB:
275 _ibar_orient_set(inst->ibar, 0); 276 _ibar_orient_set(inst->ibar, 0);
276 e_gadcon_client_aspect_set(gcc, 16, inst->ibar->icons_count * 16); 277 e_gadcon_client_aspect_set(gcc, 16, eina_hash_population(inst->ibar->icon_hash) * 16);
277 break; 278 break;
278 279
279 default: 280 default:
@@ -337,6 +338,7 @@ _ibar_new(Evas *evas, Instance *inst)
337 b = E_NEW(IBar, 1); 338 b = E_NEW(IBar, 1);
338 inst->ibar = b; 339 inst->ibar = b;
339 b->inst = inst; 340 b->inst = inst;
341 b->icon_hash = eina_hash_string_superfast_new(NULL);
340 b->o_box = e_box_add(evas); 342 b->o_box = e_box_add(evas);
341 e_box_homogenous_set(b->o_box, 1); 343 e_box_homogenous_set(b->o_box, 1);
342 e_box_orientation_set(b->o_box, 1); 344 e_box_orientation_set(b->o_box, 1);
@@ -360,6 +362,7 @@ _ibar_free(IBar *b)
360 if (b->o_drop) evas_object_del(b->o_drop); 362 if (b->o_drop) evas_object_del(b->o_drop);
361 if (b->o_drop_over) evas_object_del(b->o_drop_over); 363 if (b->o_drop_over) evas_object_del(b->o_drop_over);
362 if (b->o_empty) evas_object_del(b->o_empty); 364 if (b->o_empty) evas_object_del(b->o_empty);
365 eina_hash_free(b->icon_hash);
363 _ibar_order_del(b); 366 _ibar_order_del(b);
364 ibars = eina_list_remove(ibars, b); 367 ibars = eina_list_remove(ibars, b);
365 free(b); 368 free(b);
@@ -475,7 +478,7 @@ _ibar_fill(IBar *b)
475 _ibar_icon_signal_emit(ic, "e,state,on", "e"); 478 _ibar_icon_signal_emit(ic, "e,state,on", "e");
476 } 479 }
477 b->icons = eina_inlist_append(b->icons, EINA_INLIST_GET(ic)); 480 b->icons = eina_inlist_append(b->icons, EINA_INLIST_GET(ic));
478 b->icons_count++; 481 eina_hash_add(b->icon_hash, ic->app->orig_path, ic);
479 e_box_pack_end(b->o_box, ic->o_holder); 482 e_box_pack_end(b->o_box, ic->o_holder);
480 } 483 }
481 } 484 }
@@ -657,7 +660,7 @@ _ibar_icon_free(IBar_Icon *ic)
657 E_Exec_Instance *inst; 660 E_Exec_Instance *inst;
658 661
659 ic->ibar->icons = eina_inlist_remove(ic->ibar->icons, EINA_INLIST_GET(ic)); 662 ic->ibar->icons = eina_inlist_remove(ic->ibar->icons, EINA_INLIST_GET(ic));
660 ic->ibar->icons_count--; 663 eina_hash_del_by_key(ic->ibar->icon_hash, ic->app->orig_path);
661 E_FREE_FUNC(ic->reset_timer, ecore_timer_del); 664 E_FREE_FUNC(ic->reset_timer, ecore_timer_del);
662 ic->exe_current = NULL; 665 ic->exe_current = NULL;
663 if (ic->ibar->ic_drop_before == ic) 666 if (ic->ibar->ic_drop_before == ic)
@@ -674,7 +677,7 @@ _ibar_icon_free(IBar_Icon *ic)
674 e_exec_instance_watcher_del(ic->exe_inst, _ibar_instance_watch, ic); 677 e_exec_instance_watcher_del(ic->exe_inst, _ibar_instance_watch, ic);
675 ic->exe_inst = NULL; 678 ic->exe_inst = NULL;
676 } 679 }
677 E_FREE(ic); 680 free(ic);
678} 681}
679 682
680static void 683static void
@@ -1152,19 +1155,12 @@ _ibar_instance_watch(void *data, E_Exec_Instance *inst, E_Exec_Watch_Type type)
1152 1155
1153 switch (type) 1156 switch (type)
1154 { 1157 {
1155 case E_EXEC_WATCH_STOPPED:
1156 case E_EXEC_WATCH_TIMEOUT:
1157 _ibar_icon_signal_emit(ic, "e,state,started", "e");
1158 e_exec_instance_watcher_del(inst, _ibar_instance_watch, ic);
1159 ic->exes = eina_list_remove(ic->exes, inst);
1160 if (!ic->exes) _ibar_icon_signal_emit(ic, "e,state,off", "e");
1161 if (ic->exe_inst == inst) ic->exe_inst = NULL;
1162 break;
1163 case E_EXEC_WATCH_STARTED: 1158 case E_EXEC_WATCH_STARTED:
1164 _ibar_icon_signal_emit(ic, "e,state,started", "e"); 1159 _ibar_icon_signal_emit(ic, "e,state,started", "e");
1165 if (!ic->exes) _ibar_icon_signal_emit(ic, "e,state,on", "e"); 1160 if (!ic->exes) _ibar_icon_signal_emit(ic, "e,state,on", "e");
1166 if (ic->exe_inst == inst) ic->exe_inst = NULL; 1161 if (ic->exe_inst == inst) ic->exe_inst = NULL;
1167 ic->exes = eina_list_append(ic->exes, inst); 1162 if (!eina_list_data_find(ic->exes, inst))
1163 ic->exes = eina_list_append(ic->exes, inst);
1168 break; 1164 break;
1169 default: 1165 default:
1170 break; 1166 break;
@@ -1959,6 +1955,53 @@ _ibar_cb_action_focus(E_Object *obj __UNUSED__, const char *params __UNUSED__, E
1959 _ibar_go_focus(); 1955 _ibar_go_focus();
1960} 1956}
1961 1957
1958static Eina_Bool
1959_ibar_cb_exec_del(void *d EINA_UNUSED, int t EINA_UNUSED, E_Exec_Instance *exe)
1960{
1961 IBar *b;
1962 Eina_List *l;
1963
1964 if (!exe->desktop) return ECORE_CALLBACK_RENEW; //can't do anything here :(
1965 EINA_LIST_FOREACH(ibars, l, b)
1966 {
1967 IBar_Icon *ic;
1968
1969 ic = eina_hash_find(b->icon_hash, exe->desktop->orig_path);
1970 if (ic)
1971 {
1972 _ibar_icon_signal_emit(ic, "e,state,started", "e");
1973 ic->exes = eina_list_remove(ic->exes, exe);
1974 if (!ic->exes) _ibar_icon_signal_emit(ic, "e,state,off", "e");
1975 if (ic->exe_inst == exe) ic->exe_inst = NULL;
1976 e_exec_instance_watcher_del(exe, _ibar_instance_watch, ic);
1977 }
1978 }
1979 return ECORE_CALLBACK_RENEW;
1980}
1981
1982static Eina_Bool
1983_ibar_cb_exec_new(void *d EINA_UNUSED, int t EINA_UNUSED, E_Exec_Instance *exe)
1984{
1985 IBar *b;
1986 Eina_List *l;
1987
1988 if (!exe->desktop) return ECORE_CALLBACK_RENEW; //can't do anything here :(
1989 EINA_LIST_FOREACH(ibars, l, b)
1990 {
1991 IBar_Icon *ic;
1992
1993 ic = eina_hash_find(b->icon_hash, exe->desktop->orig_path);
1994 if (ic)
1995 {
1996 _ibar_icon_signal_emit(ic, "e,state,started", "e");
1997 if (!ic->exes) _ibar_icon_signal_emit(ic, "e,state,on", "e");
1998 if (!eina_list_data_find(ic->exes, exe))
1999 ic->exes = eina_list_append(ic->exes, exe);
2000 }
2001 }
2002 return ECORE_CALLBACK_RENEW;
2003}
2004
1962/* module setup */ 2005/* module setup */
1963EAPI E_Module_Api e_modapi = 2006EAPI E_Module_Api e_modapi =
1964{ 2007{
@@ -2011,6 +2054,10 @@ e_modapi_init(E_Module *m)
2011 _ibar_cb_config_icons, NULL); 2054 _ibar_cb_config_icons, NULL);
2012 E_LIST_HANDLER_APPEND(ibar_config->handlers, EFREET_EVENT_ICON_CACHE_UPDATE, 2055 E_LIST_HANDLER_APPEND(ibar_config->handlers, EFREET_EVENT_ICON_CACHE_UPDATE,
2013 _ibar_cb_config_icons, NULL); 2056 _ibar_cb_config_icons, NULL);
2057 E_LIST_HANDLER_APPEND(ibar_config->handlers, E_EVENT_EXEC_NEW,
2058 _ibar_cb_exec_new, NULL);
2059 E_LIST_HANDLER_APPEND(ibar_config->handlers, E_EVENT_EXEC_DEL,
2060 _ibar_cb_exec_del, NULL);
2014 2061
2015 e_gadcon_provider_register(&_gadcon_class); 2062 e_gadcon_provider_register(&_gadcon_class);
2016 ibar_orders = eina_hash_string_superfast_new(NULL); 2063 ibar_orders = eina_hash_string_superfast_new(NULL);