2016-10-28 11:26:28 -07:00
|
|
|
#include "luncher.h"
|
|
|
|
static Eina_List *handlers;
|
|
|
|
static Evas_Object *current_preview;
|
|
|
|
static Eina_Bool current_preview_menu;
|
|
|
|
static Eina_Bool _bar_icon_preview_show(void *data);
|
2016-12-13 07:49:56 -08:00
|
|
|
static Eina_Bool _bar_icon_preview_hide(void *data);
|
2017-01-10 13:45:13 -08:00
|
|
|
static void _bar_icon_del(Instance *inst, Icon *ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
|
2016-11-01 10:01:33 -07:00
|
|
|
static void
|
|
|
|
_bar_aspect(Instance *inst)
|
|
|
|
{
|
|
|
|
switch (e_gadget_site_orient_get(e_gadget_site_get(inst->o_main)))
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, 1, eina_list_count(inst->icons));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, eina_list_count(inst->icons), 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-11 11:20:01 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_bar_check_for_iconic(Icon *ic)
|
|
|
|
{
|
|
|
|
Eina_List *l, *ll, *clients = NULL;
|
|
|
|
E_Client *ec;
|
|
|
|
E_Exec_Instance *ex;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ic->execs, l, ex)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(ex->clients, ll, ec)
|
|
|
|
clients = eina_list_append(clients, ec);
|
|
|
|
}
|
|
|
|
EINA_LIST_FOREACH(ic->clients, l, ec)
|
|
|
|
clients = eina_list_append(clients, ec);
|
|
|
|
|
|
|
|
EINA_LIST_FREE(clients, ec)
|
|
|
|
{
|
|
|
|
if (ec->iconic)
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2017-01-10 14:46:39 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_bar_check_for_duplicates(Icon *ic, E_Client *dupe)
|
|
|
|
{
|
|
|
|
Eina_List *l, *ll, *clients = NULL;
|
|
|
|
E_Client *ec;
|
|
|
|
E_Exec_Instance *ex;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ic->execs, l, ex)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(ex->clients, ll, ec)
|
|
|
|
clients = eina_list_append(clients, ec);
|
|
|
|
}
|
|
|
|
EINA_LIST_FOREACH(ic->clients, l, ec)
|
|
|
|
clients = eina_list_append(clients, ec);
|
|
|
|
|
|
|
|
EINA_LIST_FREE(clients, ec)
|
|
|
|
{
|
|
|
|
if (ec == dupe)
|
2017-02-10 14:23:43 -08:00
|
|
|
{
|
|
|
|
eina_list_free(clients);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2017-01-10 14:46:39 -08:00
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-11-01 08:03:35 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_bar_check_modifiers(Evas_Modifier *modifiers)
|
|
|
|
{
|
|
|
|
if ((evas_key_modifier_is_set(modifiers, "Alt")) ||
|
|
|
|
(evas_key_modifier_is_set(modifiers, "Control")) ||
|
|
|
|
(evas_key_modifier_is_set(modifiers, "Shift")))
|
|
|
|
return EINA_TRUE;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
static Evas_Object *
|
|
|
|
_bar_gadget_configure(Evas_Object *g)
|
|
|
|
{
|
|
|
|
if (!luncher_config) return NULL;
|
|
|
|
if (luncher_config->config_dialog) return NULL;
|
|
|
|
Instance *inst = evas_object_data_get(g, "instance");
|
2016-11-01 13:16:06 -07:00
|
|
|
return config_luncher(e_zone_current_get(), inst, EINA_TRUE);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
2017-01-11 19:21:34 -08:00
|
|
|
static void
|
|
|
|
_bar_popup_dismissed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2016-11-18 12:13:08 -08:00
|
|
|
{
|
|
|
|
E_FREE_FUNC(obj, evas_object_del);
|
|
|
|
}
|
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
static const char *
|
|
|
|
_bar_location_get(Instance *inst)
|
|
|
|
{
|
|
|
|
const char *s = "float";
|
|
|
|
|
|
|
|
E_Gadget_Site_Orient orient = e_gadget_site_orient_get(e_gadget_site_get(inst->o_main));
|
|
|
|
E_Gadget_Site_Anchor anchor = e_gadget_site_anchor_get(e_gadget_site_get(inst->o_main));
|
|
|
|
|
|
|
|
if (anchor & E_GADGET_SITE_ANCHOR_LEFT)
|
|
|
|
{
|
|
|
|
if (anchor & E_GADGET_SITE_ANCHOR_TOP)
|
|
|
|
{
|
|
|
|
switch (orient)
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_HORIZONTAL:
|
|
|
|
s = "top";
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
s = "left";
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_NONE:
|
|
|
|
s = "left";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (anchor & E_GADGET_SITE_ANCHOR_BOTTOM)
|
|
|
|
{
|
|
|
|
switch (orient)
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_HORIZONTAL:
|
|
|
|
s = "bottom";
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
s = "left";
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_NONE:
|
|
|
|
s = "left";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
s = "left";
|
|
|
|
}
|
|
|
|
else if (anchor & E_GADGET_SITE_ANCHOR_RIGHT)
|
|
|
|
{
|
|
|
|
if (anchor & E_GADGET_SITE_ANCHOR_TOP)
|
|
|
|
{
|
|
|
|
switch (orient)
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_HORIZONTAL:
|
|
|
|
s = "top";
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
s = "right";
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_NONE:
|
|
|
|
s = "right";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (anchor & E_GADGET_SITE_ANCHOR_BOTTOM)
|
|
|
|
{
|
|
|
|
switch (orient)
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_HORIZONTAL:
|
|
|
|
s = "bottom";
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
s = "right";
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_NONE:
|
|
|
|
s = "right";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
s = "right";
|
|
|
|
}
|
|
|
|
else if (anchor & E_GADGET_SITE_ANCHOR_TOP)
|
|
|
|
s = "top";
|
|
|
|
else if (anchor & E_GADGET_SITE_ANCHOR_BOTTOM)
|
|
|
|
s = "bottom";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (orient)
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_HORIZONTAL:
|
|
|
|
s = "bottom";
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
s = "left";
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Icon *
|
|
|
|
_bar_icon_match(Instance *inst, E_Client *ec)
|
|
|
|
{
|
2017-01-10 13:45:13 -08:00
|
|
|
Icon *ic = NULL, *ic2 = NULL;
|
2016-10-28 11:26:28 -07:00
|
|
|
Eina_Bool has_desktop = EINA_FALSE;
|
2017-01-10 14:08:24 -08:00
|
|
|
char ori[32];
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
if (ec->exe_inst)
|
|
|
|
{
|
|
|
|
if (ec->exe_inst->desktop)
|
|
|
|
has_desktop = EINA_TRUE;
|
|
|
|
}
|
2017-01-12 14:50:37 -08:00
|
|
|
if (has_desktop)
|
2017-01-10 13:45:13 -08:00
|
|
|
{
|
|
|
|
ic = eina_hash_find(inst->icons_desktop_hash, ec->exe_inst->desktop->orig_path);
|
2017-02-18 04:18:09 -08:00
|
|
|
if ((ic) && (ic2 = eina_hash_find(inst->icons_clients_hash, &ec)))
|
2017-01-10 14:08:24 -08:00
|
|
|
{
|
|
|
|
ic2->execs = eina_list_remove(ic2->execs, ec->exe_inst);
|
|
|
|
ic2->clients = eina_list_remove(ic2->clients, ec);
|
|
|
|
if (!eina_list_count(ic2->execs) && !eina_list_count(ic2->clients))
|
|
|
|
{
|
|
|
|
eina_hash_del(inst->icons_clients_hash, ec, ic2);
|
|
|
|
snprintf(ori, sizeof(ori), "e,state,off,%s", _bar_location_get(inst));
|
|
|
|
elm_layout_signal_emit(ic2->o_layout, ori, "e");
|
|
|
|
if (!ic2->in_order)
|
|
|
|
_bar_icon_del(inst, ic2);
|
|
|
|
}
|
|
|
|
}
|
2017-01-10 13:45:13 -08:00
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
if (has_desktop && !ic)
|
2017-01-12 14:50:37 -08:00
|
|
|
ic = eina_hash_find(inst->icons_clients_hash, &ec);
|
2016-10-28 11:26:28 -07:00
|
|
|
if (!ic)
|
2017-01-12 14:50:37 -08:00
|
|
|
ic = eina_hash_find(inst->icons_clients_hash, &ec);
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
return ic;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_instance_watch(void *data, E_Exec_Instance *ex, E_Exec_Watch_Type type)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
2016-11-05 08:53:56 -07:00
|
|
|
char ori[32];
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case E_EXEC_WATCH_STARTED:
|
|
|
|
if (ic->starting) elm_layout_signal_emit(ic->o_layout, "e,state,started", "e");
|
|
|
|
ic->starting = EINA_FALSE;
|
2017-02-27 18:57:18 -08:00
|
|
|
if (!ic->execs && ic->inst->cfg->type != E_LUNCHER_MODULE_LAUNCH_ONLY)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
2016-11-05 08:53:56 -07:00
|
|
|
snprintf(ori, sizeof(ori), "e,state,on,%s", _bar_location_get(ic->inst));
|
|
|
|
elm_layout_signal_emit(ic->o_layout, ori, "e");
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
2017-02-27 18:57:18 -08:00
|
|
|
if (!eina_list_data_find(ic->execs, ex) && ic->inst->cfg->type != E_LUNCHER_MODULE_LAUNCH_ONLY)
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->execs = eina_list_append(ic->execs, ex);
|
|
|
|
break;
|
2017-02-18 08:29:09 -08:00
|
|
|
case E_EXEC_WATCH_TIMEOUT:
|
|
|
|
case E_EXEC_WATCH_STOPPED:
|
|
|
|
ic->exec = NULL;
|
|
|
|
break;
|
2016-10-28 11:26:28 -07:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_del(Instance *inst, Icon *ic)
|
|
|
|
{
|
|
|
|
inst->icons = eina_list_remove(inst->icons, ic);
|
2016-12-13 07:49:56 -08:00
|
|
|
if (ic->preview)
|
|
|
|
_bar_icon_preview_hide(ic);
|
2017-03-13 15:40:43 -07:00
|
|
|
if (!inst->main_del)
|
|
|
|
_bar_aspect(inst);
|
2017-03-08 16:21:15 -08:00
|
|
|
evas_object_del(ic->o_spacera);
|
|
|
|
evas_object_del(ic->o_spacerb);
|
2016-10-28 11:26:28 -07:00
|
|
|
evas_object_del(ic->o_icon);
|
2016-11-18 12:13:08 -08:00
|
|
|
evas_object_del(ic->o_overlay);
|
|
|
|
evas_object_del(ic->o_layout);
|
2016-10-28 11:26:28 -07:00
|
|
|
eina_hash_del_by_data(inst->icons_desktop_hash, ic);
|
|
|
|
eina_hash_del_by_data(inst->icons_clients_hash, ic);
|
|
|
|
if (ic->desktop)
|
|
|
|
efreet_desktop_unref(ic->desktop);
|
|
|
|
eina_list_free(ic->execs);
|
|
|
|
eina_list_free(ic->clients);
|
|
|
|
eina_stringshare_del(ic->icon);
|
|
|
|
eina_stringshare_del(ic->key);
|
|
|
|
if (ic->exec)
|
|
|
|
e_exec_instance_watcher_del(ic->exec, _bar_instance_watch, ic);
|
|
|
|
ic->exec = NULL;
|
2017-01-10 11:43:50 -08:00
|
|
|
E_FREE_FUNC(ic->mouse_in_timer, ecore_timer_del);
|
|
|
|
E_FREE_FUNC(ic->mouse_out_timer, ecore_timer_del);
|
2016-10-28 11:26:28 -07:00
|
|
|
E_FREE(ic);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_menu_settings_clicked(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
Evas_Object *popup = evas_object_data_get(obj, "popup");
|
2016-11-18 12:13:08 -08:00
|
|
|
Evas_Object *box = evas_object_data_get(obj, "content");
|
2016-10-28 11:26:28 -07:00
|
|
|
|
2016-11-18 12:13:08 -08:00
|
|
|
evas_object_del(box);
|
2016-10-28 11:26:28 -07:00
|
|
|
elm_ctxpopup_dismiss(popup);
|
|
|
|
e_gadget_configure(ic->inst->o_main);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_menu_add_clicked(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
Evas_Object *popup = evas_object_data_get(obj, "popup");
|
2016-11-18 12:13:08 -08:00
|
|
|
Evas_Object *box = evas_object_data_get(obj, "content");
|
2016-10-28 11:26:28 -07:00
|
|
|
|
2016-11-18 12:13:08 -08:00
|
|
|
evas_object_del(box);
|
2016-10-28 11:26:28 -07:00
|
|
|
elm_ctxpopup_dismiss(popup);
|
2017-01-11 08:13:05 -08:00
|
|
|
if (ic->desktop)
|
|
|
|
e_order_append(ic->inst->order, ic->desktop);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_menu_remove_clicked(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
Evas_Object *popup = evas_object_data_get(obj, "popup");
|
2016-11-18 12:13:08 -08:00
|
|
|
Evas_Object *box = evas_object_data_get(obj, "content");
|
2016-10-28 11:26:28 -07:00
|
|
|
|
2016-11-18 12:13:08 -08:00
|
|
|
evas_object_del(box);
|
2016-10-28 11:26:28 -07:00
|
|
|
elm_ctxpopup_dismiss(popup);
|
2017-01-11 08:13:05 -08:00
|
|
|
if (ic->desktop)
|
|
|
|
e_order_remove(ic->inst->order, ic->desktop);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_menu_properties_clicked(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
Evas_Object *popup = evas_object_data_get(obj, "popup");
|
2016-11-18 12:13:08 -08:00
|
|
|
Evas_Object *box = evas_object_data_get(obj, "content");
|
2016-10-28 11:26:28 -07:00
|
|
|
|
2016-11-18 12:13:08 -08:00
|
|
|
evas_object_del(box);
|
2016-10-28 11:26:28 -07:00
|
|
|
elm_ctxpopup_dismiss(popup);
|
2017-01-11 08:13:05 -08:00
|
|
|
if (ic->desktop)
|
|
|
|
e_desktop_edit(ic->desktop);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_menu_action_clicked(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Efreet_Desktop_Action *action = (Efreet_Desktop_Action*)data;
|
|
|
|
Evas_Object *popup = evas_object_data_get(obj, "popup");
|
2016-11-18 12:13:08 -08:00
|
|
|
Evas_Object *box = evas_object_data_get(obj, "content");
|
2016-10-28 11:26:28 -07:00
|
|
|
|
2016-11-18 12:13:08 -08:00
|
|
|
evas_object_del(box);
|
2016-10-28 11:26:28 -07:00
|
|
|
elm_ctxpopup_dismiss(popup);
|
|
|
|
e_exec(e_zone_current_get(), NULL, action->exec, NULL, "luncher");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-11-01 08:03:35 -07:00
|
|
|
_bar_icon_menu_icon_mouse_out(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data EINA_UNUSED)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
elm_layout_signal_emit(obj, "e,state,unfocused", "e");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-31 13:12:49 -07:00
|
|
|
_bar_icon_menu_icon_mouse_in(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
2016-10-31 13:12:49 -07:00
|
|
|
Evas_Event_Mouse_In *ev = event_data;
|
|
|
|
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2016-11-01 08:03:35 -07:00
|
|
|
if (_bar_check_modifiers(ev->modifiers)) return;
|
2016-10-31 13:12:49 -07:00
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
elm_layout_signal_emit(obj, "e,state,focused", "e");
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_bar_icon_menu_item_new(Icon *ic, Evas_Object *popup, Evas_Object *parent, const char *name, const char *icon)
|
|
|
|
{
|
|
|
|
const char *path = NULL, *k = NULL;
|
2016-11-02 07:34:10 -07:00
|
|
|
char buf[4096];
|
2016-10-28 11:26:28 -07:00
|
|
|
int len = 0;
|
|
|
|
Evas_Object *layout, *label, *img;
|
|
|
|
|
|
|
|
layout = elm_layout_add(parent);
|
|
|
|
e_theme_edje_object_set(layout, "e/gadget/luncher/preview",
|
|
|
|
"e/gadget/luncher/preview");
|
|
|
|
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_IN, _bar_icon_menu_icon_mouse_in, NULL);
|
|
|
|
evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_OUT, _bar_icon_menu_icon_mouse_out, NULL);
|
|
|
|
elm_layout_signal_emit(layout, "e,state,icon,menu", "e");
|
|
|
|
elm_box_pack_end(parent, layout);
|
|
|
|
evas_object_data_set(layout, "popup", popup);
|
2016-11-18 12:13:08 -08:00
|
|
|
evas_object_data_set(layout, "content", parent);
|
2016-10-28 11:26:28 -07:00
|
|
|
evas_object_show(layout);
|
|
|
|
|
|
|
|
label = elm_label_add(layout);
|
|
|
|
elm_object_style_set(label, "luncher_preview");
|
|
|
|
elm_label_ellipsis_set(label, EINA_TRUE);
|
|
|
|
elm_object_text_set(label, name);
|
|
|
|
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
|
|
|
elm_layout_content_set(layout, "e.swallow.title", label);
|
|
|
|
evas_object_show(label);
|
|
|
|
|
|
|
|
img = elm_icon_add(layout);
|
|
|
|
evas_object_size_hint_aspect_set(img, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
|
|
|
if (!icon)
|
|
|
|
path = NULL;
|
|
|
|
else if (strncmp(icon, "/", 1) && !ecore_file_exists(icon))
|
|
|
|
{
|
|
|
|
path = efreet_icon_path_find(e_config->icon_theme, icon, ic->inst->size);
|
|
|
|
if (!path)
|
|
|
|
{
|
|
|
|
if (e_util_strcmp(e_config->icon_theme, "hicolor"))
|
|
|
|
path = efreet_icon_path_find("hicolor", icon, ic->inst->size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ecore_file_exists(icon))
|
|
|
|
{
|
|
|
|
path = icon;
|
|
|
|
}
|
2017-02-10 14:22:10 -08:00
|
|
|
if (!path && icon)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "e/icons/%s", icon);
|
|
|
|
if (eina_list_count(e_theme_collection_items_find("base/theme/icons", buf)))
|
|
|
|
{
|
|
|
|
path = e_theme_edje_file_get("base/theme/icons", buf);
|
|
|
|
k = buf;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
|
|
|
|
k = "e/icons/unknown";
|
|
|
|
}
|
|
|
|
}
|
2017-02-10 14:22:10 -08:00
|
|
|
else if (!path && !icon)
|
|
|
|
{
|
|
|
|
path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
|
|
|
|
k = "e/icons/unknown";
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
if (path && icon)
|
|
|
|
{
|
|
|
|
len = strlen(icon);
|
|
|
|
if ((len > 4) && (!strcasecmp(icon + len - 4, ".edj")))
|
|
|
|
k = "icon";
|
|
|
|
}
|
|
|
|
elm_image_file_set(img, path, k);
|
|
|
|
elm_layout_content_set(layout, "e.swallow.icon", img);
|
|
|
|
evas_object_show(img);
|
|
|
|
|
|
|
|
elm_layout_sizing_eval(layout);
|
|
|
|
|
|
|
|
return layout;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_drag_done(E_Drag *drag, int dropped)
|
|
|
|
{
|
|
|
|
Instance *inst = e_object_data_get(E_OBJECT(drag));
|
|
|
|
|
|
|
|
efreet_desktop_unref(drag->data);
|
|
|
|
if (!inst) return;
|
2016-11-08 09:20:07 -08:00
|
|
|
evas_object_smart_callback_call(e_gadget_site_get(inst->o_main), "gadget_site_unlocked", NULL);
|
2016-10-28 11:26:28 -07:00
|
|
|
if (!dropped)
|
|
|
|
bar_recalculate(inst);
|
|
|
|
}
|
|
|
|
|
2016-11-21 11:02:19 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_bar_icon_preview_hide(void *data)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
|
2017-01-12 09:12:54 -08:00
|
|
|
if (!ic) return EINA_FALSE;
|
|
|
|
|
2016-11-21 11:02:19 -08:00
|
|
|
ic->mouse_out_timer = NULL;
|
|
|
|
|
2017-01-12 09:12:54 -08:00
|
|
|
if (!ic->preview || ic->preview_dismissed)
|
2016-11-21 11:02:19 -08:00
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
E_FREE_FUNC(ic->preview_box, evas_object_del);
|
2017-01-09 09:49:54 -08:00
|
|
|
E_FREE_FUNC(ic->preview_scroller, evas_object_del);
|
2016-11-21 11:02:19 -08:00
|
|
|
elm_ctxpopup_dismiss(ic->preview);
|
2016-12-13 12:04:45 -08:00
|
|
|
ic->preview_dismissed = EINA_TRUE;
|
2016-11-21 11:02:19 -08:00
|
|
|
current_preview = NULL;
|
|
|
|
current_preview_menu = EINA_FALSE;
|
|
|
|
ic->active = EINA_FALSE;
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
static void
|
|
|
|
_bar_icon_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
Evas_Event_Mouse_Move *ev = event_data;
|
|
|
|
int dx, dy;
|
|
|
|
|
2016-10-31 13:12:49 -07:00
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2016-11-01 08:03:35 -07:00
|
|
|
if (_bar_check_modifiers(ev->modifiers)) return;
|
2016-10-31 13:12:49 -07:00
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
if (!ic->drag.start) return;
|
|
|
|
|
|
|
|
dx = ev->cur.output.x - ic->drag.x;
|
|
|
|
dy = ev->cur.output.y - ic->drag.y;
|
|
|
|
if (((dx * dx) + (dy * dy)) >
|
|
|
|
(e_config->drag_resist * e_config->drag_resist))
|
|
|
|
{
|
|
|
|
E_Drag *d;
|
|
|
|
Evas_Object *o;
|
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
unsigned int size;
|
|
|
|
const char *drag_types[] = { "enlightenment/desktop" };
|
|
|
|
|
2016-11-21 11:02:19 -08:00
|
|
|
_bar_icon_preview_hide(ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->drag.dnd = 1;
|
|
|
|
ic->drag.start = 0;
|
|
|
|
|
|
|
|
evas_object_geometry_get(ic->o_icon, &x, &y, &w, &h);
|
|
|
|
d = e_drag_new(x, y, drag_types, 1,
|
|
|
|
ic->desktop, -1, NULL, _bar_icon_drag_done);
|
|
|
|
d->button_mask = evas_pointer_button_down_mask_get(e_comp->evas);
|
|
|
|
efreet_desktop_ref(ic->desktop);
|
|
|
|
size = MAX(w, h);
|
|
|
|
o = e_util_desktop_icon_add(ic->desktop, size, e_drag_evas_get(d));
|
|
|
|
e_drag_object_set(d, o);
|
|
|
|
|
|
|
|
e_drag_resize(d, w, h);
|
|
|
|
e_drag_start(d, ic->drag.x, ic->drag.y);
|
|
|
|
e_object_data_set(E_OBJECT(d), ic->inst);
|
|
|
|
if (ic->in_order)
|
|
|
|
e_order_remove(ic->inst->order, ic->desktop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_bar_drag_timer(void *data)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
|
|
|
|
ic->drag_timer = NULL;
|
|
|
|
ic->drag.start = 1;
|
2016-11-08 09:20:07 -08:00
|
|
|
evas_object_smart_callback_call(e_gadget_site_get(ic->inst->o_main), "gadget_site_locked", NULL);
|
2016-10-28 11:26:28 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
Evas_Event_Mouse_Up *ev = event_data;
|
|
|
|
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2016-11-01 08:03:35 -07:00
|
|
|
if (_bar_check_modifiers(ev->modifiers)) return;
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
if (ev->button == 1)
|
|
|
|
{
|
2016-11-04 08:22:34 -07:00
|
|
|
E_FREE_FUNC(ic->mouse_in_timer, ecore_timer_del);
|
|
|
|
E_FREE_FUNC(ic->mouse_out_timer, ecore_timer_del);
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->drag.x = ev->output.x;
|
|
|
|
ic->drag.y = ev->output.y;
|
2016-11-04 08:22:34 -07:00
|
|
|
E_FREE_FUNC(ic->drag_timer, ecore_timer_del);
|
2017-02-03 13:52:28 -08:00
|
|
|
ic->drag_timer = ecore_timer_loop_add(.35, _bar_drag_timer, ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
if (ev->button == 3)
|
|
|
|
{
|
|
|
|
Evas_Object *popup, *box, *item, *sep;
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
Efreet_Desktop_Action *action;
|
|
|
|
E_Gadget_Site_Orient orient = e_gadget_site_orient_get(e_gadget_site_get(ic->inst->o_main));
|
|
|
|
|
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
|
|
|
|
popup = elm_ctxpopup_add(e_comp->elm);
|
|
|
|
elm_object_style_set(popup, "noblock");
|
2017-01-05 13:43:48 -08:00
|
|
|
evas_object_smart_callback_add(popup, "dismissed", _bar_popup_dismissed, NULL);
|
2016-10-28 11:26:28 -07:00
|
|
|
evas_object_size_hint_min_set(popup, ic->inst->size, ic->inst->size);
|
|
|
|
|
|
|
|
box = elm_box_add(popup);
|
|
|
|
evas_object_size_hint_align_set(box, 0, 0);
|
|
|
|
switch (orient)
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_HORIZONTAL:
|
|
|
|
elm_box_horizontal_set(box, EINA_TRUE);
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
elm_box_horizontal_set(box, EINA_FALSE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
elm_box_horizontal_set(box, EINA_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ic->desktop)
|
|
|
|
{
|
|
|
|
if (ic->desktop->actions)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(ic->desktop->actions, l, action)
|
|
|
|
{
|
|
|
|
item = _bar_icon_menu_item_new(ic, popup, box, action->name, action->icon);
|
|
|
|
evas_object_event_callback_add(item, EVAS_CALLBACK_MOUSE_UP, _bar_icon_menu_action_clicked, action);
|
|
|
|
}
|
|
|
|
sep = elm_separator_add(box);
|
|
|
|
switch (orient)
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_HORIZONTAL:
|
|
|
|
elm_separator_horizontal_set(item, EINA_TRUE);
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
elm_separator_horizontal_set(item, EINA_FALSE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
elm_separator_horizontal_set(item, EINA_FALSE);
|
|
|
|
}
|
|
|
|
elm_box_pack_end(box, sep);
|
|
|
|
evas_object_show(sep);
|
|
|
|
}
|
|
|
|
}
|
2017-01-11 08:13:05 -08:00
|
|
|
if (ic->desktop)
|
|
|
|
{
|
|
|
|
item = _bar_icon_menu_item_new(ic, popup, box, _("Icon Properties"), "preferences-applications");
|
|
|
|
evas_object_event_callback_add(item, EVAS_CALLBACK_MOUSE_UP, _bar_icon_menu_properties_clicked, ic);
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
if (ic->in_order)
|
|
|
|
{
|
|
|
|
item = _bar_icon_menu_item_new(ic, popup, box, _("Remove From Bar"), "list-remove");
|
|
|
|
evas_object_event_callback_add(item, EVAS_CALLBACK_MOUSE_UP, _bar_icon_menu_remove_clicked, ic);
|
|
|
|
}
|
2017-01-11 08:13:05 -08:00
|
|
|
else if (!ic->in_order && ic->desktop)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
item = _bar_icon_menu_item_new(ic, popup, box, _("Add To Bar"), "list-add");
|
|
|
|
evas_object_event_callback_add(item, EVAS_CALLBACK_MOUSE_UP, _bar_icon_menu_add_clicked, ic);
|
|
|
|
}
|
|
|
|
item = _bar_icon_menu_item_new(ic, popup, box, _("Luncher Settings"), "configure");
|
|
|
|
evas_object_event_callback_add(item, EVAS_CALLBACK_MOUSE_UP, _bar_icon_menu_settings_clicked, ic);
|
|
|
|
|
|
|
|
elm_object_content_set(popup, box);
|
|
|
|
evas_object_show(box);
|
|
|
|
|
|
|
|
e_gadget_util_ctxpopup_place(ic->inst->o_main, popup, ic->o_layout);
|
|
|
|
e_comp_object_util_autoclose(popup, NULL, NULL, NULL);
|
|
|
|
evas_object_layer_set(popup, E_LAYER_POPUP);
|
|
|
|
evas_object_show(popup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
Evas_Event_Mouse_Up *ev = event_data;
|
|
|
|
|
2016-10-31 13:12:49 -07:00
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2016-11-01 08:03:35 -07:00
|
|
|
if (_bar_check_modifiers(ev->modifiers)) return;
|
2016-10-31 13:12:49 -07:00
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
if (ev->button == 1)
|
|
|
|
{
|
2016-11-04 08:22:34 -07:00
|
|
|
E_FREE_FUNC(ic->drag_timer, ecore_timer_del);
|
2016-10-28 11:26:28 -07:00
|
|
|
if (ic->drag.dnd)
|
|
|
|
{
|
|
|
|
ic->drag.start = 0;
|
|
|
|
ic->drag.dnd = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ev->button == 1 && ic->desktop)
|
|
|
|
{
|
|
|
|
if (ic->desktop->type == EFREET_DESKTOP_TYPE_APPLICATION)
|
|
|
|
{
|
|
|
|
E_Exec_Instance *ex;
|
|
|
|
|
|
|
|
ex = e_exec(e_zone_current_get(), ic->desktop, NULL, NULL, "luncher");
|
|
|
|
ic->exec = ex;
|
|
|
|
e_exec_instance_watcher_add(ex, _bar_instance_watch, ic);
|
|
|
|
if (!ic->starting) elm_layout_signal_emit(ic->o_layout, "e,state,starting", "e");
|
|
|
|
ic->starting = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (ic->desktop->type == EFREET_DESKTOP_TYPE_LINK)
|
|
|
|
{
|
|
|
|
if (!strncasecmp(ic->desktop->url, "file:", 5))
|
|
|
|
{
|
|
|
|
E_Action *act;
|
|
|
|
|
|
|
|
act = e_action_find("fileman");
|
|
|
|
if (act)
|
|
|
|
act->func.go(NULL, ic->desktop->url + 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ev->button == 1 && !ic->in_order)
|
|
|
|
{
|
|
|
|
_bar_icon_preview_show(ic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-11-01 08:03:35 -07:00
|
|
|
_bar_icon_preview_item_mouse_out(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data EINA_UNUSED)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
elm_layout_signal_emit(obj, "e,state,unfocused", "e");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-31 13:12:49 -07:00
|
|
|
_bar_icon_preview_item_mouse_in(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
2016-10-31 13:12:49 -07:00
|
|
|
Evas_Event_Mouse_In *ev = event_data;
|
|
|
|
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2016-11-01 08:03:35 -07:00
|
|
|
if (_bar_check_modifiers(ev->modifiers)) return;
|
2016-10-31 13:12:49 -07:00
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
elm_layout_signal_emit(obj, "e,state,focused", "e");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-11-01 08:03:35 -07:00
|
|
|
_bar_icon_preview_mouse_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
|
|
|
|
if (current_preview_menu)
|
|
|
|
return;
|
2016-11-04 08:22:34 -07:00
|
|
|
E_FREE_FUNC(ic->mouse_out_timer, ecore_timer_del);
|
2017-02-03 13:52:28 -08:00
|
|
|
ic->mouse_out_timer = ecore_timer_loop_add(0.25, _bar_icon_preview_hide, ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-31 13:12:49 -07:00
|
|
|
_bar_icon_preview_mouse_in(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
Icon *ic = data;
|
2016-10-31 13:12:49 -07:00
|
|
|
Evas_Event_Mouse_In *ev = event_data;
|
|
|
|
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2016-11-01 08:03:35 -07:00
|
|
|
if (_bar_check_modifiers(ev->modifiers)) return;
|
2016-10-28 11:26:28 -07:00
|
|
|
|
2016-11-04 08:22:34 -07:00
|
|
|
E_FREE_FUNC(ic->mouse_out_timer, ecore_timer_del);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_preview_menu_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
|
|
|
|
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_HIDE, _bar_icon_preview_menu_hide, ic);
|
|
|
|
if (ic)
|
|
|
|
{
|
|
|
|
if (ic->preview)
|
|
|
|
{
|
|
|
|
current_preview_menu = EINA_FALSE;
|
|
|
|
_bar_icon_preview_mouse_out(ic, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_preview_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data)
|
|
|
|
{
|
|
|
|
E_Client *ec = data;
|
|
|
|
Evas_Event_Mouse_Up *ev = event_data;
|
|
|
|
Icon *ic = evas_object_data_get(current_preview, "icon");
|
|
|
|
|
2016-10-31 13:12:49 -07:00
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2016-11-01 08:03:35 -07:00
|
|
|
if (_bar_check_modifiers(ev->modifiers)) return;
|
2016-10-31 13:12:49 -07:00
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
if (ev->button == 3)
|
|
|
|
{
|
|
|
|
e_int_client_menu_show(ec, ev->canvas.x, ev->canvas.y, 0, ev->timestamp);
|
|
|
|
evas_object_event_callback_add(ec->border_menu->comp_object, EVAS_CALLBACK_HIDE,
|
|
|
|
_bar_icon_preview_menu_hide, ic);
|
|
|
|
current_preview_menu = EINA_TRUE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
e_client_activate(ec, 1);
|
2016-11-21 11:02:19 -08:00
|
|
|
_bar_icon_preview_hide(ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_preview_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Evas_Object *img = data;
|
|
|
|
|
|
|
|
evas_object_del(img);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_preview_client_add(Icon *ic, E_Client *ec)
|
|
|
|
{
|
|
|
|
Evas_Object *layout, *label, *img;
|
|
|
|
|
|
|
|
layout = elm_layout_add(ic->preview_box);
|
|
|
|
e_theme_edje_object_set(layout, "e/gadget/luncher/preview",
|
|
|
|
"e/gadget/luncher/preview");
|
|
|
|
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_IN,
|
|
|
|
_bar_icon_preview_item_mouse_in, ic);
|
|
|
|
evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_OUT,
|
|
|
|
_bar_icon_preview_item_mouse_out, ic);
|
|
|
|
elm_box_pack_end(ic->preview_box, layout);
|
|
|
|
evas_object_show(layout);
|
|
|
|
|
|
|
|
label = elm_label_add(layout);
|
|
|
|
elm_object_style_set(label, "luncher_preview");
|
|
|
|
elm_label_ellipsis_set(label, EINA_TRUE);
|
|
|
|
elm_object_text_set(label, e_client_util_name_get(ec));
|
|
|
|
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
|
|
|
elm_layout_content_set(layout, "e.swallow.title", label);
|
|
|
|
evas_object_show(label);
|
|
|
|
|
|
|
|
img = e_comp_object_util_mirror_add(ec->frame);
|
|
|
|
edje_extern_object_aspect_set(img, EDJE_ASPECT_CONTROL_BOTH, ec->client.w, ec->client.h);
|
|
|
|
elm_layout_content_set(layout, "e.swallow.icon", img);
|
|
|
|
evas_object_show(img);
|
|
|
|
|
|
|
|
if (!(ec->desk->visible) || (ec->iconic))
|
|
|
|
elm_layout_signal_emit(layout, "e,state,invisible", "e");
|
|
|
|
|
|
|
|
evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_bar_icon_preview_mouse_up, ec);
|
|
|
|
evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL,
|
|
|
|
_bar_icon_preview_del, img);
|
|
|
|
elm_layout_sizing_eval(layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_bar_icon_preview_show(void *data)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
E_Client *ec;
|
|
|
|
E_Exec_Instance *ex;
|
|
|
|
Eina_List *clients = NULL;
|
|
|
|
E_Gadget_Site_Orient orient;
|
2017-01-09 09:49:54 -08:00
|
|
|
E_Zone *zone = e_zone_current_get();
|
2016-10-28 11:26:28 -07:00
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
if (!ic)
|
|
|
|
return EINA_FALSE;
|
|
|
|
ic->mouse_in_timer = NULL;
|
|
|
|
if (ic->drag.dnd)
|
|
|
|
return EINA_FALSE;
|
2016-11-02 07:34:10 -07:00
|
|
|
if (!ic->inst)
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!ic->inst->o_icon_con)
|
2016-10-28 11:26:28 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
orient = e_gadget_site_orient_get(e_gadget_site_get(ic->inst->o_main));
|
|
|
|
|
2016-12-13 12:04:45 -08:00
|
|
|
if (current_preview && (current_preview != ic->preview))
|
2016-11-22 08:45:38 -08:00
|
|
|
_bar_icon_preview_hide(evas_object_data_get(current_preview, "icon"));
|
2016-12-13 12:04:45 -08:00
|
|
|
if (ic->preview && !ic->preview_dismissed)
|
|
|
|
_bar_icon_preview_hide(ic);
|
|
|
|
ic->preview_dismissed = EINA_FALSE;
|
2016-10-28 11:26:28 -07:00
|
|
|
if (!eina_list_count(ic->execs) && !eina_list_count(ic->clients))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ic->preview = elm_ctxpopup_add(e_comp->elm);
|
|
|
|
elm_object_style_set(ic->preview, "noblock");
|
|
|
|
evas_object_size_hint_min_set(ic->preview, ic->inst->size, ic->inst->size);
|
2016-11-18 12:13:08 -08:00
|
|
|
evas_object_smart_callback_add(ic->preview, "dismissed", _bar_popup_dismissed, NULL);
|
2016-10-28 11:26:28 -07:00
|
|
|
evas_object_event_callback_add(ic->preview, EVAS_CALLBACK_MOUSE_IN,
|
|
|
|
_bar_icon_preview_mouse_in, ic);
|
|
|
|
evas_object_event_callback_add(ic->preview, EVAS_CALLBACK_MOUSE_OUT,
|
|
|
|
_bar_icon_preview_mouse_out, ic);
|
|
|
|
|
2017-01-09 09:49:54 -08:00
|
|
|
ic->preview_scroller = elm_scroller_add(ic->preview);
|
|
|
|
elm_scroller_content_min_limit(ic->preview_scroller, EINA_TRUE, EINA_TRUE);
|
|
|
|
evas_object_size_hint_max_set(ic->preview_scroller, zone->w - 15, zone->h - 15);
|
|
|
|
elm_object_style_set(ic->preview_scroller, "no_inset_shadow");
|
|
|
|
E_EXPAND(ic->preview_scroller);
|
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->preview_box = elm_box_add(ic->preview);
|
|
|
|
evas_object_size_hint_align_set(ic->preview_box, 0, 0);
|
|
|
|
switch (orient)
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_HORIZONTAL:
|
|
|
|
elm_box_horizontal_set(ic->preview_box, EINA_TRUE);
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
elm_box_horizontal_set(ic->preview_box, EINA_FALSE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
elm_box_horizontal_set(ic->preview_box, EINA_FALSE);
|
|
|
|
}
|
|
|
|
EINA_LIST_FOREACH(ic->execs, l, ex)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(ex->clients, ll, ec)
|
2017-01-10 11:33:27 -08:00
|
|
|
clients = eina_list_append(clients, ec);
|
|
|
|
}
|
2017-01-10 12:33:03 -08:00
|
|
|
EINA_LIST_FOREACH(ic->clients, l, ec)
|
|
|
|
clients = eina_list_append(clients, ec);
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
EINA_LIST_FREE(clients, ec)
|
|
|
|
{
|
|
|
|
if (!ec->netwm.state.skip_taskbar && !e_client_util_ignored_get(ec))
|
|
|
|
{
|
|
|
|
if (!e_client_util_is_popup(ec))
|
|
|
|
{
|
|
|
|
_bar_icon_preview_client_add(ic, ec);
|
|
|
|
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!count)
|
|
|
|
{
|
2016-11-21 11:02:19 -08:00
|
|
|
_bar_icon_preview_hide(ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2017-01-09 09:49:54 -08:00
|
|
|
elm_object_content_set(ic->preview_scroller, ic->preview_box);
|
|
|
|
elm_object_content_set(ic->preview, ic->preview_scroller);
|
2016-10-28 11:26:28 -07:00
|
|
|
evas_object_show(ic->preview_box);
|
|
|
|
|
2017-03-13 18:57:16 -07:00
|
|
|
e_gadget_util_ctxpopup_place(ic->inst->o_main, ic->preview, ic->o_icon);
|
2016-10-28 11:26:28 -07:00
|
|
|
evas_object_layer_set(ic->preview, E_LAYER_POPUP);
|
|
|
|
|
|
|
|
evas_object_data_del(ic->preview, "icon");
|
|
|
|
evas_object_data_set(ic->preview, "icon", ic);
|
2016-11-22 08:45:38 -08:00
|
|
|
evas_object_show(ic->preview);
|
2016-10-28 11:26:28 -07:00
|
|
|
current_preview = ic->preview;
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-31 13:12:49 -07:00
|
|
|
_bar_icon_mouse_in(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
Eina_Bool clients = EINA_FALSE;
|
2016-10-31 13:12:49 -07:00
|
|
|
Evas_Event_Mouse_In *ev = event_data;
|
|
|
|
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2016-11-01 08:03:35 -07:00
|
|
|
if (_bar_check_modifiers(ev->modifiers)) return;
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
elm_object_tooltip_show(obj);
|
|
|
|
ic->active = EINA_TRUE;
|
|
|
|
|
2016-11-04 08:22:34 -07:00
|
|
|
E_FREE_FUNC(ic->mouse_out_timer, ecore_timer_del);
|
|
|
|
E_FREE_FUNC(ic->mouse_in_timer, ecore_timer_del);
|
2016-10-28 11:26:28 -07:00
|
|
|
if (eina_list_count(ic->execs) || eina_list_count(ic->clients))
|
|
|
|
clients = EINA_TRUE;
|
2016-11-22 08:45:38 -08:00
|
|
|
if (clients && current_preview && !current_preview_menu)
|
|
|
|
_bar_icon_preview_show(ic);
|
2017-01-11 11:20:01 -08:00
|
|
|
else if (_bar_check_for_iconic(ic))
|
|
|
|
_bar_icon_preview_show(ic);
|
2016-11-22 08:45:38 -08:00
|
|
|
else if (clients && !current_preview)
|
2017-02-03 13:52:28 -08:00
|
|
|
ic->mouse_in_timer = ecore_timer_loop_add(0.3, _bar_icon_preview_show, ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-11-01 08:03:35 -07:00
|
|
|
_bar_icon_mouse_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data EINA_UNUSED)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
|
|
|
|
elm_object_tooltip_hide(obj);
|
2016-11-04 08:22:34 -07:00
|
|
|
E_FREE_FUNC(ic->mouse_in_timer, ecore_timer_del);
|
|
|
|
E_FREE_FUNC(ic->mouse_out_timer, ecore_timer_del);
|
2017-02-03 13:52:28 -08:00
|
|
|
ic->mouse_out_timer = ecore_timer_loop_add(0.25, _bar_icon_preview_hide, ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_exec_new_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Icon *ic = data;
|
|
|
|
E_Client *ec = e_comp_object_client_get(obj);
|
|
|
|
|
|
|
|
if (ic->preview)
|
|
|
|
_bar_icon_preview_client_add(ic, ec);
|
|
|
|
evas_object_event_callback_del_full(ec->frame, EVAS_CALLBACK_SHOW, _bar_exec_new_show, ic);
|
|
|
|
}
|
|
|
|
|
2017-02-22 09:05:27 -08:00
|
|
|
static void
|
|
|
|
_bar_icon_file_set(Icon *ic, Efreet_Desktop *desktop, E_Client *non_desktop_client)
|
|
|
|
{
|
|
|
|
const char *path = NULL, *k = NULL;
|
|
|
|
char buf[4096];
|
|
|
|
int len = 0;
|
|
|
|
if (desktop)
|
|
|
|
{
|
|
|
|
if (!desktop->icon)
|
|
|
|
path = NULL;
|
|
|
|
else if (strncmp(desktop->icon, "/", 1) && !ecore_file_exists(desktop->icon))
|
|
|
|
{
|
|
|
|
path = efreet_icon_path_find(e_config->icon_theme, desktop->icon, ic->inst->size);
|
|
|
|
if (!path)
|
|
|
|
{
|
|
|
|
if (e_util_strcmp(e_config->icon_theme, "hicolor"))
|
|
|
|
path = efreet_icon_path_find("hicolor", desktop->icon, ic->inst->size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ecore_file_exists(desktop->icon))
|
|
|
|
{
|
|
|
|
path = desktop->icon;
|
|
|
|
}
|
|
|
|
if (!path && desktop->icon)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "e/icons/%s", desktop->icon);
|
|
|
|
if (eina_list_count(e_theme_collection_items_find("base/theme/icons", buf)))
|
|
|
|
{
|
|
|
|
path = e_theme_edje_file_get("base/theme/icons", buf);
|
|
|
|
k = buf;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
|
|
|
|
k = "e/icons/unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!path && !desktop->icon)
|
|
|
|
{
|
|
|
|
path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
|
|
|
|
k = "e/icons/unknown";
|
|
|
|
}
|
|
|
|
if (path && desktop->icon && !k)
|
|
|
|
{
|
|
|
|
len = strlen(desktop->icon);
|
|
|
|
if ((len > 4) && (!strcasecmp(desktop->icon + len - 4, ".edj")))
|
|
|
|
k = "icon";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (non_desktop_client)
|
|
|
|
{
|
|
|
|
Evas_Object *tmp;
|
|
|
|
const char *file, *group;
|
|
|
|
Eina_Bool ret = EINA_FALSE;
|
|
|
|
|
|
|
|
tmp = e_client_icon_add(non_desktop_client, evas_object_evas_get(ic->o_layout));
|
|
|
|
if (isedje(tmp))
|
|
|
|
{
|
|
|
|
edje_object_file_get(tmp, &file, &group);
|
|
|
|
if (file && group)
|
|
|
|
ret = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = e_icon_file_get(tmp, &file, &group);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
eina_stringshare_replace(&ic->icon, file);
|
|
|
|
eina_stringshare_replace(&ic->key, group);
|
|
|
|
path = ic->icon;
|
|
|
|
k = ic->key;
|
|
|
|
}
|
|
|
|
evas_object_del(tmp);
|
|
|
|
}
|
|
|
|
else if (ic->icon)
|
|
|
|
{
|
|
|
|
if (strncmp(ic->icon, "/", 1) && !ecore_file_exists(ic->icon))
|
|
|
|
{
|
|
|
|
path = efreet_icon_path_find(e_config->icon_theme, ic->icon, ic->inst->size);
|
|
|
|
if (!path)
|
|
|
|
{
|
|
|
|
if (e_util_strcmp(e_config->icon_theme, "hicolor"))
|
|
|
|
path = efreet_icon_path_find("hicolor", ic->icon, ic->inst->size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ecore_file_exists(ic->icon))
|
|
|
|
{
|
|
|
|
path = ic->icon;
|
|
|
|
k = ic->key;
|
|
|
|
}
|
|
|
|
if (!path)
|
|
|
|
{
|
|
|
|
path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
|
|
|
|
k = "e/icons/unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
|
|
|
|
k = "e/icons/unknown";
|
|
|
|
}
|
|
|
|
elm_image_file_set(ic->o_icon, path, k);
|
|
|
|
elm_image_file_set(ic->o_overlay, path, k);
|
|
|
|
}
|
|
|
|
|
2017-03-08 16:21:15 -08:00
|
|
|
static void
|
2017-03-11 15:12:57 -08:00
|
|
|
_bar_resized_cb(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
2017-03-08 16:21:15 -08:00
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
Icon *ic = NULL;
|
|
|
|
Eina_List *l = NULL;
|
2017-03-11 15:12:57 -08:00
|
|
|
Evas_Coord tot = 0;
|
2017-03-08 16:21:15 -08:00
|
|
|
|
|
|
|
if (!inst->effect) return;
|
|
|
|
switch (e_gadget_site_orient_get(e_gadget_site_get(inst->o_main)))
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
EINA_LIST_FOREACH(inst->icons, l, ic)
|
2017-03-11 15:12:57 -08:00
|
|
|
tot += ic->scale * 1000;
|
|
|
|
evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, 1000, tot);
|
2017-03-08 16:21:15 -08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
EINA_LIST_FOREACH(inst->icons, l, ic)
|
2017-03-11 15:12:57 -08:00
|
|
|
tot += ic->scale * 1000;
|
|
|
|
evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, tot, 1000);
|
2017-03-08 16:21:15 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_icon_scale_message(void *data, Evas_Object *obj EINA_UNUSED, Edje_Message_Type type EINA_UNUSED, int id EINA_UNUSED, void *msg)
|
|
|
|
{
|
|
|
|
Edje_Message_String_Float_Set *mmsg = msg;
|
|
|
|
Evas_Coord add = 0;
|
|
|
|
Icon *ic = data;
|
|
|
|
float total;
|
|
|
|
|
|
|
|
|
|
|
|
ic->scale = mmsg->val[0];
|
|
|
|
|
|
|
|
if (ic->scale > 1.0)
|
|
|
|
{
|
2017-03-11 15:12:57 -08:00
|
|
|
total = ic->inst->size * (ic->scale - 1.0);
|
|
|
|
add = (Evas_Coord) total/2.0;
|
2017-03-08 16:21:15 -08:00
|
|
|
switch (e_gadget_site_orient_get(e_gadget_site_get(ic->inst->o_main)))
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
evas_object_resize(ic->o_spacerb, ic->inst->size, add);
|
|
|
|
evas_object_size_hint_min_set(ic->o_spacerb, ic->inst->size, add);
|
|
|
|
evas_object_resize(ic->o_spacera, ic->inst->size, add);
|
|
|
|
evas_object_size_hint_min_set(ic->o_spacera, ic->inst->size, add);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
evas_object_resize(ic->o_spacerb, add, ic->inst->size);
|
|
|
|
evas_object_size_hint_min_set(ic->o_spacerb, add, ic->inst->size);
|
|
|
|
evas_object_resize(ic->o_spacera, add, ic->inst->size);
|
|
|
|
evas_object_size_hint_min_set(ic->o_spacera, add, ic->inst->size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_object_resize(ic->o_spacerb, 0, 0);
|
|
|
|
evas_object_resize(ic->o_spacera, 0, 0);
|
|
|
|
evas_object_size_hint_min_set(ic->o_spacerb, 0, 0);
|
|
|
|
evas_object_size_hint_min_set(ic->o_spacera, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
static Icon *
|
|
|
|
_bar_icon_add(Instance *inst, Efreet_Desktop *desktop, E_Client *non_desktop_client)
|
|
|
|
{
|
2017-02-22 09:05:27 -08:00
|
|
|
char ori[32];
|
2016-10-28 11:26:28 -07:00
|
|
|
Icon *ic;
|
|
|
|
const Eina_List *l;
|
2016-11-18 12:13:08 -08:00
|
|
|
Edje_Message_String *msg;
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
ic = E_NEW(Icon, 1);
|
|
|
|
if (desktop)
|
|
|
|
efreet_desktop_ref(desktop);
|
|
|
|
ic->desktop = desktop;
|
|
|
|
ic->inst = inst;
|
|
|
|
ic->preview = NULL;
|
|
|
|
ic->preview_box = NULL;
|
2017-01-09 09:49:54 -08:00
|
|
|
ic->preview_scroller = NULL;
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->mouse_in_timer = NULL;
|
|
|
|
ic->mouse_out_timer = NULL;
|
|
|
|
ic->active = EINA_FALSE;
|
|
|
|
ic->starting = EINA_FALSE;
|
2016-12-13 12:04:45 -08:00
|
|
|
ic->preview_dismissed = EINA_FALSE;
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->exec = NULL;
|
2017-03-13 11:16:36 -07:00
|
|
|
ic->scale = 1.0;
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
ic->o_layout = elm_layout_add(inst->o_icon_con);
|
|
|
|
e_theme_edje_object_set(ic->o_layout, "e/gadget/luncher/icon",
|
|
|
|
"e/gadget/luncher/icon");
|
2016-11-01 09:56:51 -07:00
|
|
|
E_EXPAND(ic->o_layout);
|
|
|
|
E_FILL(ic->o_layout);
|
2017-03-08 16:21:15 -08:00
|
|
|
edje_object_message_handler_set(elm_layout_edje_get(ic->o_layout), _bar_icon_scale_message, ic);
|
2017-03-11 15:12:57 -08:00
|
|
|
edje_object_signal_callback_add(elm_layout_edje_get(ic->o_layout), "e,state,resized", "e", _bar_resized_cb, inst);
|
2016-10-28 11:26:28 -07:00
|
|
|
elm_box_pack_end(inst->o_icon_con, ic->o_layout);
|
|
|
|
evas_object_show(ic->o_layout);
|
|
|
|
|
2017-03-08 16:21:15 -08:00
|
|
|
ic->o_spacerb = evas_object_rectangle_add(evas_object_evas_get(ic->inst->o_icon_con));
|
|
|
|
ic->o_spacera = evas_object_rectangle_add(evas_object_evas_get(ic->inst->o_icon_con));
|
|
|
|
evas_object_color_set(ic->o_spacerb, 0, 0, 0, 0);
|
|
|
|
evas_object_color_set(ic->o_spacera, 0, 0, 0, 0);
|
|
|
|
evas_object_resize(ic->o_spacerb, 0, 0);
|
|
|
|
evas_object_resize(ic->o_spacera, 0, 0);
|
|
|
|
evas_object_size_hint_min_set(ic->o_spacerb, 0, 0);
|
|
|
|
evas_object_size_hint_min_set(ic->o_spacera, 0, 0);
|
2017-03-11 15:12:57 -08:00
|
|
|
elm_box_pack_before(inst->o_icon_con, ic->o_spacerb, ic->o_layout);
|
|
|
|
elm_box_pack_after(inst->o_icon_con, ic->o_spacera, ic->o_layout);
|
2017-03-08 16:21:15 -08:00
|
|
|
evas_object_show(ic->o_spacerb);
|
|
|
|
evas_object_show(ic->o_spacera);
|
|
|
|
|
2016-11-05 08:27:41 -07:00
|
|
|
snprintf(ori, sizeof(ori), "e,state,off,%s", _bar_location_get(inst));
|
|
|
|
elm_layout_signal_emit(ic->o_layout, ori, "e");
|
2017-01-05 13:35:20 -08:00
|
|
|
msg = alloca(sizeof(Edje_Message_String));
|
2016-11-22 19:17:22 -08:00
|
|
|
if (inst->cfg->style)
|
|
|
|
msg->str = strdup(inst->cfg->style);
|
2016-11-18 12:13:08 -08:00
|
|
|
edje_object_message_send(elm_layout_edje_get(ic->o_layout), EDJE_MESSAGE_STRING, 1, msg);
|
2016-12-13 11:39:39 -08:00
|
|
|
free(msg->str);
|
2016-11-05 08:27:41 -07:00
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->o_icon = elm_icon_add(ic->o_layout);
|
|
|
|
E_EXPAND(ic->o_icon);
|
|
|
|
|
|
|
|
ic->o_overlay = elm_icon_add(ic->o_layout);
|
|
|
|
E_EXPAND(ic->o_overlay);
|
|
|
|
|
2017-02-22 09:05:27 -08:00
|
|
|
_bar_icon_file_set(ic, desktop, non_desktop_client);
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
if (desktop)
|
|
|
|
elm_object_tooltip_text_set(ic->o_icon, desktop->name);
|
|
|
|
else if (non_desktop_client && non_desktop_client->icccm.class)
|
|
|
|
elm_object_tooltip_text_set(ic->o_icon, non_desktop_client->icccm.class);
|
|
|
|
else if (non_desktop_client && non_desktop_client->icccm.name)
|
|
|
|
elm_object_tooltip_text_set(ic->o_icon, non_desktop_client->icccm.name);
|
|
|
|
else if (non_desktop_client && non_desktop_client->icccm.title)
|
|
|
|
elm_object_tooltip_text_set(ic->o_icon, non_desktop_client->icccm.title);
|
|
|
|
else if (non_desktop_client && non_desktop_client->netwm.name)
|
|
|
|
elm_object_tooltip_text_set(ic->o_icon, non_desktop_client->netwm.name);
|
|
|
|
else
|
|
|
|
elm_object_tooltip_text_set(ic->o_icon, _("Unknown"));
|
|
|
|
|
|
|
|
elm_object_tooltip_orient_set(ic->o_icon, ELM_TOOLTIP_ORIENT_CENTER);
|
|
|
|
elm_object_tooltip_style_set(ic->o_icon, "luncher");
|
|
|
|
evas_object_size_hint_aspect_set(ic->o_icon, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
|
|
|
elm_layout_content_set(ic->o_layout, "e.swallow.icon", ic->o_icon);
|
|
|
|
evas_object_event_callback_add(ic->o_icon, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_bar_icon_mouse_up, ic);
|
|
|
|
evas_object_event_callback_priority_add(ic->o_icon, EVAS_CALLBACK_MOUSE_DOWN, 0,
|
|
|
|
_bar_icon_mouse_down, ic);
|
|
|
|
evas_object_event_callback_add(ic->o_icon, EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_bar_icon_mouse_move, ic);
|
|
|
|
evas_object_event_callback_add(ic->o_icon, EVAS_CALLBACK_MOUSE_IN,
|
|
|
|
_bar_icon_mouse_in, ic);
|
|
|
|
evas_object_event_callback_add(ic->o_icon, EVAS_CALLBACK_MOUSE_OUT,
|
|
|
|
_bar_icon_mouse_out, ic);
|
|
|
|
evas_object_show(ic->o_icon);
|
|
|
|
|
|
|
|
evas_object_size_hint_aspect_set(ic->o_overlay, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
|
|
|
elm_layout_content_set(ic->o_layout, "e.swallow.overlay", ic->o_overlay);
|
|
|
|
evas_object_show(ic->o_overlay);
|
|
|
|
|
|
|
|
if (desktop)
|
|
|
|
eina_hash_add(inst->icons_desktop_hash, eina_stringshare_add(desktop->orig_path), ic);
|
|
|
|
else
|
2017-01-12 14:50:37 -08:00
|
|
|
eina_hash_add(inst->icons_clients_hash, &non_desktop_client, ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
if (desktop)
|
|
|
|
{
|
2017-02-27 18:57:18 -08:00
|
|
|
if (inst->cfg->type != E_LUNCHER_MODULE_LAUNCH_ONLY)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
2017-02-27 18:57:18 -08:00
|
|
|
l = e_exec_desktop_instances_find(desktop);
|
|
|
|
if (l)
|
|
|
|
{
|
|
|
|
snprintf(ori, sizeof(ori), "e,state,on,%s", _bar_location_get(inst));
|
|
|
|
elm_layout_signal_emit(ic->o_layout, ori, "e");
|
|
|
|
ic->execs = eina_list_clone(l);
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2017-01-10 14:46:39 -08:00
|
|
|
{
|
|
|
|
if (!_bar_check_for_duplicates(ic, non_desktop_client))
|
|
|
|
ic->clients = eina_list_append(ic->clients, non_desktop_client);
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
elm_layout_sizing_eval(ic->o_layout);
|
2016-11-01 12:21:23 -07:00
|
|
|
_bar_aspect(inst);
|
2016-10-28 11:26:28 -07:00
|
|
|
return ic;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_bar_cb_client_remove(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client_Property *ev)
|
|
|
|
{
|
|
|
|
Instance *inst = NULL;
|
|
|
|
Eina_List *l = NULL;
|
2016-11-05 08:53:56 -07:00
|
|
|
char ori[32];
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(luncher_instances, l, inst)
|
|
|
|
{
|
|
|
|
Icon *ic = NULL;
|
|
|
|
|
2016-11-22 19:17:22 -08:00
|
|
|
if (!inst->bar) continue;
|
|
|
|
if (ev->ec) ic = _bar_icon_match(inst, ev->ec);
|
2016-10-28 11:26:28 -07:00
|
|
|
if (ic)
|
|
|
|
{
|
|
|
|
if (ic->starting) elm_layout_signal_emit(ic->o_layout, "e,state,started", "e");
|
|
|
|
ic->starting = EINA_FALSE;
|
|
|
|
if (ev->ec)
|
|
|
|
ic->clients = eina_list_remove(ic->clients, ev->ec);
|
2016-11-02 07:34:10 -07:00
|
|
|
if (ev->ec->exe_inst)
|
|
|
|
ic->execs = eina_list_remove(ic->execs, ev->ec->exe_inst);
|
2016-10-28 11:26:28 -07:00
|
|
|
if (!eina_list_count(ic->execs) && !eina_list_count(ic->clients))
|
|
|
|
{
|
2016-11-05 08:27:41 -07:00
|
|
|
snprintf(ori, sizeof(ori), "e,state,off,%s", _bar_location_get(inst));
|
|
|
|
elm_layout_signal_emit(ic->o_layout, ori, "e");
|
2017-02-06 09:12:43 -08:00
|
|
|
if (ic->preview)
|
|
|
|
_bar_icon_preview_hide(ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
if (!ic->in_order)
|
|
|
|
_bar_icon_del(inst, ic);
|
|
|
|
}
|
2017-02-07 09:47:35 -08:00
|
|
|
else if (ic->preview && (current_preview == ic->preview))
|
|
|
|
{
|
2017-02-06 09:12:43 -08:00
|
|
|
_bar_icon_preview_show(ic);
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_bar_cb_exec_del(void *data EINA_UNUSED, int type EINA_UNUSED, E_Exec_Instance *ex)
|
|
|
|
{
|
|
|
|
Instance *inst = NULL;
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
E_Client *ec = NULL;
|
2016-11-05 08:53:56 -07:00
|
|
|
char ori[32];
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ex->clients, l, ec)
|
|
|
|
{
|
2017-02-28 08:08:44 -08:00
|
|
|
if (!ec->netwm.state.skip_taskbar && !e_client_util_is_popup(ec))
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-11-01 11:28:21 -07:00
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
EINA_LIST_FOREACH(luncher_instances, l, inst)
|
|
|
|
{
|
|
|
|
Icon *ic = NULL;
|
2016-11-01 11:28:21 -07:00
|
|
|
|
2016-11-22 19:17:22 -08:00
|
|
|
if (!inst->bar) continue;
|
2016-11-01 11:28:21 -07:00
|
|
|
if (ex->desktop)
|
|
|
|
{
|
|
|
|
ic = eina_hash_find(inst->icons_desktop_hash, ex->desktop->orig_path);
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
if (ic)
|
|
|
|
{
|
|
|
|
if (ic->starting) elm_layout_signal_emit(ic->o_layout, "e,state,started", "e");
|
|
|
|
ic->starting = EINA_FALSE;
|
|
|
|
ic->execs = eina_list_remove(ic->execs, ex);
|
|
|
|
ic->clients = eina_list_remove(ic->clients, ec);
|
|
|
|
if (!eina_list_count(ic->execs) && !eina_list_count(ic->clients))
|
|
|
|
{
|
2016-11-05 08:27:41 -07:00
|
|
|
snprintf(ori, sizeof(ori), "e,state,off,%s", _bar_location_get(inst));
|
|
|
|
elm_layout_signal_emit(ic->o_layout, ori, "e");
|
2017-02-06 09:12:43 -08:00
|
|
|
if (ic->preview)
|
|
|
|
_bar_icon_preview_hide(ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
if (!ic->in_order)
|
|
|
|
_bar_icon_del(inst, ic);
|
|
|
|
}
|
2017-02-07 09:47:35 -08:00
|
|
|
else if (ic->preview && (current_preview == ic->preview))
|
2017-02-06 09:12:43 -08:00
|
|
|
{
|
|
|
|
_bar_icon_preview_show(ic);
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_bar_cb_exec_client_prop(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client_Property *ev)
|
|
|
|
{
|
|
|
|
Instance *inst = NULL;
|
|
|
|
E_Client *ec = NULL;
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
Eina_Bool skip;
|
|
|
|
Eina_Bool has_desktop = EINA_TRUE;
|
|
|
|
|
|
|
|
if (e_client_util_ignored_get(ev->ec))
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
if ((!(ev->property & E_CLIENT_PROPERTY_NETWM_STATE)) && (!(ev->property & E_CLIENT_PROPERTY_ICON))
|
|
|
|
&& (!(ev->property & E_CLIENT_PROPERTY_URGENCY)))
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
|
|
|
|
if (!ev->ec->exe_inst)
|
|
|
|
has_desktop = EINA_FALSE;
|
|
|
|
if (ev->ec->exe_inst)
|
|
|
|
{
|
|
|
|
if (!ev->ec->exe_inst->desktop)
|
|
|
|
has_desktop = EINA_FALSE;
|
|
|
|
}
|
|
|
|
if (has_desktop)
|
|
|
|
{
|
|
|
|
skip = EINA_TRUE;
|
|
|
|
EINA_LIST_FOREACH(ev->ec->exe_inst->clients, l, ec)
|
|
|
|
{
|
2017-02-28 08:08:44 -08:00
|
|
|
if (!ec->netwm.state.skip_taskbar && !e_client_util_is_popup(ec))
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
skip = EINA_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2017-02-28 08:08:44 -08:00
|
|
|
{
|
2017-02-28 08:58:11 -08:00
|
|
|
if (ev->ec->netwm.state.skip_taskbar || e_client_util_is_popup(ev->ec))
|
2017-02-28 08:08:44 -08:00
|
|
|
skip = EINA_TRUE;
|
|
|
|
else
|
|
|
|
skip = EINA_FALSE;
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
EINA_LIST_FOREACH(luncher_instances, l, inst)
|
|
|
|
{
|
|
|
|
Icon *ic = NULL;
|
2016-11-05 08:53:56 -07:00
|
|
|
char ori[32];
|
2016-10-28 11:26:28 -07:00
|
|
|
|
2016-11-22 19:17:22 -08:00
|
|
|
if (!inst->bar) continue;
|
2016-11-02 07:34:10 -07:00
|
|
|
ic = _bar_icon_match(inst, ev->ec);
|
2016-10-28 11:26:28 -07:00
|
|
|
if (skip && !ic) continue;
|
|
|
|
if (!skip)
|
|
|
|
{
|
|
|
|
if (ic)
|
|
|
|
{
|
|
|
|
if ((ev->property & E_CLIENT_PROPERTY_URGENCY))
|
|
|
|
{
|
|
|
|
if (ev->ec->urgent)
|
|
|
|
elm_layout_signal_emit(ic->o_layout, "e,state,urgent", "e");
|
|
|
|
else
|
|
|
|
elm_layout_signal_emit(ic->o_layout, "e,state,normal", "e");
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
if (ic->starting) elm_layout_signal_emit(ic->o_layout, "e,state,started", "e");
|
|
|
|
ic->starting = EINA_FALSE;
|
2016-11-05 08:53:56 -07:00
|
|
|
snprintf(ori, sizeof(ori), "e,state,on,%s", _bar_location_get(inst));
|
|
|
|
elm_layout_signal_emit(ic->o_layout, ori, "e");
|
2016-10-28 11:26:28 -07:00
|
|
|
if (has_desktop)
|
|
|
|
{
|
2017-01-10 14:46:39 -08:00
|
|
|
if (!(_bar_check_for_duplicates(ic, ev->ec)))
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->execs = eina_list_append(ic->execs, ev->ec->exe_inst);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-10 14:46:39 -08:00
|
|
|
if (!(_bar_check_for_duplicates(ic, ev->ec)))
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->clients = eina_list_append(ic->clients, ev->ec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-11 10:01:30 -08:00
|
|
|
if (has_desktop && !ev->ec->internal_elm_win)
|
2016-10-28 11:26:28 -07:00
|
|
|
ic = _bar_icon_add(inst, ev->ec->exe_inst->desktop, NULL);
|
|
|
|
else
|
|
|
|
ic = _bar_icon_add(inst, NULL, ev->ec);
|
2016-11-05 08:53:56 -07:00
|
|
|
snprintf(ori, sizeof(ori), "e,state,on,%s", _bar_location_get(inst));
|
|
|
|
elm_layout_signal_emit(ic->o_layout, ori, "e");
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->in_order = EINA_FALSE;
|
|
|
|
inst->icons = eina_list_append(inst->icons, ic);
|
2016-11-01 10:01:33 -07:00
|
|
|
_bar_aspect(inst);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (has_desktop)
|
|
|
|
ic->execs = eina_list_remove(ic->execs, ev->ec->exe_inst);
|
2016-11-07 07:35:34 -08:00
|
|
|
else
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->clients = eina_list_remove(ic->clients, ev->ec);
|
|
|
|
if (!eina_list_count(ic->execs) && !eina_list_count(ic->clients))
|
|
|
|
{
|
2017-02-06 09:12:43 -08:00
|
|
|
if (ic->preview)
|
|
|
|
_bar_icon_preview_hide(ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
if (!ic->in_order)
|
|
|
|
_bar_icon_del(inst, ic);
|
|
|
|
else
|
2016-11-05 08:27:41 -07:00
|
|
|
{
|
|
|
|
snprintf(ori, sizeof(ori), "e,state,off,%s", _bar_location_get(inst));
|
|
|
|
elm_layout_signal_emit(ic->o_layout, ori, "e");
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
2017-02-07 09:47:35 -08:00
|
|
|
else if (ic->preview && (current_preview == ic->preview))
|
2017-02-06 09:12:43 -08:00
|
|
|
{
|
|
|
|
_bar_icon_preview_show(ic);
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_bar_cb_exec_new(void *data EINA_UNUSED, int type, E_Exec_Instance *ex)
|
|
|
|
{
|
|
|
|
Instance *inst = NULL;
|
|
|
|
E_Client *ec = NULL;
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
Eina_Bool skip;
|
|
|
|
|
|
|
|
if (type == E_EVENT_EXEC_NEW_CLIENT)
|
|
|
|
{
|
|
|
|
ec = eina_list_data_get(ex->clients);
|
2017-02-28 08:08:44 -08:00
|
|
|
if (ec->netwm.state.skip_taskbar || e_client_util_is_popup(ec))
|
|
|
|
skip = EINA_TRUE;
|
|
|
|
else
|
|
|
|
skip = EINA_FALSE;
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skip = EINA_TRUE;
|
|
|
|
EINA_LIST_FOREACH(ex->clients, l, ec)
|
|
|
|
{
|
2017-02-28 08:08:44 -08:00
|
|
|
if (!ec->netwm.state.skip_taskbar && !e_client_util_is_popup(ec))
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
skip = EINA_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EINA_LIST_FOREACH(luncher_instances, l, inst)
|
|
|
|
{
|
|
|
|
Icon *ic = NULL;
|
2016-11-05 08:53:56 -07:00
|
|
|
char ori[32];
|
2016-10-28 11:26:28 -07:00
|
|
|
|
2016-11-22 19:17:22 -08:00
|
|
|
if (!inst->bar) continue;
|
|
|
|
if (ec) ic = _bar_icon_match(inst, ec);
|
2016-10-28 11:26:28 -07:00
|
|
|
if (ic)
|
|
|
|
{
|
|
|
|
if (skip) continue;
|
|
|
|
if (ic->starting) elm_layout_signal_emit(ic->o_layout, "e,state,started", "e");
|
|
|
|
ic->starting = EINA_FALSE;
|
2016-11-05 08:53:56 -07:00
|
|
|
snprintf(ori, sizeof(ori), "e,state,on,%s", _bar_location_get(inst));
|
|
|
|
elm_layout_signal_emit(ic->o_layout, ori, "e");
|
2016-10-28 11:26:28 -07:00
|
|
|
if (ex->desktop)
|
|
|
|
{
|
2017-01-10 14:46:39 -08:00
|
|
|
if (!(_bar_check_for_duplicates(ic, ec)))
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->execs = eina_list_append(ic->execs, ex);
|
2016-12-14 08:23:25 -08:00
|
|
|
if (evas_object_visible_get(ec->frame))
|
2016-12-14 08:27:48 -08:00
|
|
|
_bar_exec_new_show(ic, NULL, ec->frame, NULL);
|
2016-12-14 08:23:25 -08:00
|
|
|
else
|
|
|
|
evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW,
|
|
|
|
_bar_exec_new_show, ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-10 14:46:39 -08:00
|
|
|
if (!(_bar_check_for_duplicates(ic, ec)))
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->clients = eina_list_append(ic->clients, ec);
|
2016-12-14 08:23:25 -08:00
|
|
|
if (evas_object_visible_get(ec->frame))
|
2016-12-14 08:27:48 -08:00
|
|
|
_bar_exec_new_show(ic, NULL, ec->frame, NULL);
|
2016-12-14 08:23:25 -08:00
|
|
|
else
|
|
|
|
evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW,
|
|
|
|
_bar_exec_new_show, ic);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (skip) continue;
|
2017-01-11 10:01:30 -08:00
|
|
|
if (ex->desktop && !ec->internal_elm_win)
|
2016-10-28 11:26:28 -07:00
|
|
|
ic = _bar_icon_add(inst, ex->desktop, NULL);
|
|
|
|
else
|
|
|
|
ic = _bar_icon_add(inst, NULL, ec);
|
2016-11-05 08:53:56 -07:00
|
|
|
snprintf(ori, sizeof(ori), "e,state,on,%s", _bar_location_get(inst));
|
|
|
|
elm_layout_signal_emit(ic->o_layout, ori, "e");
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->in_order = EINA_FALSE;
|
|
|
|
inst->icons = eina_list_append(inst->icons, ic);
|
2016-11-01 10:01:33 -07:00
|
|
|
_bar_aspect(inst);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_empty(Instance *inst)
|
|
|
|
{
|
|
|
|
if (inst->icons)
|
|
|
|
{
|
|
|
|
elm_box_clear(inst->o_icon_con);
|
2017-01-20 08:52:52 -08:00
|
|
|
while (inst->icons)
|
|
|
|
_bar_icon_del(inst, eina_list_data_get(inst->icons));
|
2016-10-28 11:26:28 -07:00
|
|
|
inst->icons = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_fill(Instance *inst)
|
|
|
|
{
|
|
|
|
const Eina_Hash *execs = e_exec_instances_get();
|
|
|
|
Eina_Iterator *it;
|
|
|
|
Eina_List *l, *ll, *lll;
|
|
|
|
E_Exec_Instance *ex;
|
2016-10-31 12:58:42 -07:00
|
|
|
E_Client *ec;
|
2016-10-28 11:26:28 -07:00
|
|
|
Icon *ic;
|
2016-11-05 08:53:56 -07:00
|
|
|
char ori[32];
|
2016-10-28 11:26:28 -07:00
|
|
|
|
2017-02-27 18:57:18 -08:00
|
|
|
if (inst->order && inst->cfg->type != E_LUNCHER_MODULE_TASKS_ONLY)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
Efreet_Desktop *desktop;
|
2016-10-31 03:30:57 -07:00
|
|
|
Eina_List *list;
|
2016-10-28 11:26:28 -07:00
|
|
|
|
2016-10-31 03:30:57 -07:00
|
|
|
EINA_LIST_FOREACH(inst->order->desktops, list, desktop)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
ic = _bar_icon_add(inst, desktop, NULL);
|
|
|
|
ic->in_order = EINA_TRUE;
|
|
|
|
inst->icons = eina_list_append(inst->icons, ic);
|
|
|
|
}
|
|
|
|
}
|
2017-02-27 18:57:18 -08:00
|
|
|
if (inst->cfg->type == E_LUNCHER_MODULE_LAUNCH_ONLY)
|
|
|
|
{
|
|
|
|
_bar_aspect(inst);
|
|
|
|
return;
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
it = eina_hash_iterator_data_new(execs);
|
|
|
|
EINA_ITERATOR_FOREACH(it, l)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(l, ll, ex)
|
|
|
|
{
|
|
|
|
Eina_Bool skip = EINA_TRUE;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ex->clients, lll, ec)
|
|
|
|
{
|
2017-02-28 08:08:44 -08:00
|
|
|
if (!ec->netwm.state.skip_taskbar && !e_client_util_is_popup(ec))
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
skip = EINA_FALSE;
|
|
|
|
}
|
|
|
|
if (skip) continue;
|
|
|
|
ic = _bar_icon_match(inst, ec);
|
|
|
|
if (ic)
|
|
|
|
{
|
2017-01-10 14:46:39 -08:00
|
|
|
if (!(_bar_check_for_duplicates(ic, ec)))
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->execs = eina_list_append(ic->execs, ex);
|
|
|
|
continue;
|
|
|
|
}
|
2017-01-12 14:50:37 -08:00
|
|
|
if (!ec->internal_elm_win)
|
|
|
|
ic = _bar_icon_add(inst, ex->desktop, NULL);
|
|
|
|
else
|
|
|
|
ic = _bar_icon_add(inst, NULL, ec);
|
2016-11-05 08:53:56 -07:00
|
|
|
snprintf(ori, sizeof(ori), "e,state,on,%s", _bar_location_get(inst));
|
|
|
|
elm_layout_signal_emit(ic->o_layout, ori, "e");
|
2016-10-28 11:26:28 -07:00
|
|
|
ic->in_order = EINA_FALSE;
|
|
|
|
inst->icons = eina_list_append(inst->icons, ic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-12-13 11:39:39 -08:00
|
|
|
eina_iterator_free(it);
|
2016-10-31 12:58:42 -07:00
|
|
|
E_CLIENT_FOREACH(ec)
|
|
|
|
{
|
2016-11-01 11:28:21 -07:00
|
|
|
if (e_client_util_ignored_get(ec)) continue;
|
2016-11-01 12:21:23 -07:00
|
|
|
if (ec->netwm.state.skip_taskbar) continue;
|
2017-02-28 08:08:44 -08:00
|
|
|
if (e_client_util_is_popup(ec)) continue;
|
2016-11-01 11:28:21 -07:00
|
|
|
ic = _bar_icon_match(inst, ec);
|
2016-10-31 12:58:42 -07:00
|
|
|
if (!ic)
|
|
|
|
{
|
2017-01-11 10:01:30 -08:00
|
|
|
if (ec->exe_inst && ec->exe_inst->desktop && !ec->internal_elm_win)
|
2016-11-01 17:33:37 -07:00
|
|
|
ic = _bar_icon_add(inst, ec->exe_inst->desktop, NULL);
|
|
|
|
else
|
|
|
|
ic = _bar_icon_add(inst, NULL, ec);
|
2016-11-05 08:53:56 -07:00
|
|
|
snprintf(ori, sizeof(ori), "e,state,on,%s", _bar_location_get(inst));
|
|
|
|
elm_layout_signal_emit(ic->o_layout, ori, "e");
|
2016-10-31 12:58:42 -07:00
|
|
|
ic->in_order = EINA_FALSE;
|
|
|
|
inst->icons = eina_list_append(inst->icons, ic);
|
|
|
|
}
|
|
|
|
}
|
2016-11-01 10:01:33 -07:00
|
|
|
_bar_aspect(inst);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_resize_job(void *data)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
Eina_List *l;
|
|
|
|
Icon *ic;
|
2016-11-02 07:34:10 -07:00
|
|
|
E_Gadget_Site_Orient orient;
|
2016-10-28 11:26:28 -07:00
|
|
|
Evas_Coord x, y, w, h, size;
|
|
|
|
|
|
|
|
if (inst)
|
|
|
|
{
|
2016-11-18 12:13:08 -08:00
|
|
|
if (inst->effect) return;
|
2016-11-05 08:27:41 -07:00
|
|
|
orient = e_gadget_site_orient_get(e_gadget_site_get(inst->o_main));
|
2016-11-01 09:56:51 -07:00
|
|
|
elm_layout_sizing_eval(inst->o_main);
|
2016-10-28 11:26:28 -07:00
|
|
|
evas_object_geometry_get(inst->o_main, &x, &y, &w, &h);
|
|
|
|
switch (orient)
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_HORIZONTAL:
|
|
|
|
size = h;
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
size = w;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
size = h;
|
|
|
|
}
|
|
|
|
inst->size = size;
|
|
|
|
EINA_LIST_FOREACH(inst->icons, l, ic)
|
2017-02-22 09:05:27 -08:00
|
|
|
_bar_icon_file_set(ic, ic->desktop, NULL);
|
2016-10-28 11:26:28 -07:00
|
|
|
inst->resize_job = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_bar_cb_update_icons(EINA_UNUSED void *data, EINA_UNUSED int ev_type, EINA_UNUSED void *ev)
|
|
|
|
{
|
|
|
|
Instance *inst = NULL;
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(luncher_instances, l, inst)
|
|
|
|
{
|
2016-11-22 19:17:22 -08:00
|
|
|
if (!inst->bar) continue;
|
2016-10-28 11:26:28 -07:00
|
|
|
if (inst->resize_job) return ECORE_CALLBACK_RENEW;
|
|
|
|
inst->resize_job = ecore_job_add(_bar_resize_job, inst);
|
|
|
|
}
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
|
|
|
|
if (inst->resize_job) return;
|
|
|
|
inst->resize_job = ecore_job_add(_bar_resize_job, inst);
|
|
|
|
}
|
|
|
|
|
2016-11-18 12:13:08 -08:00
|
|
|
static void
|
|
|
|
_bar_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
Evas_Coord px, py;
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
Icon *ic = NULL;
|
|
|
|
const char *position = _bar_location_get(inst);
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
inst->effect = EINA_TRUE;
|
|
|
|
|
|
|
|
if (eina_streq(position, "left"))
|
|
|
|
pos = 0;
|
|
|
|
else if (eina_streq(position, "top"))
|
|
|
|
pos = 1;
|
|
|
|
else if (eina_streq(position, "right"))
|
|
|
|
pos = 2;
|
|
|
|
else
|
|
|
|
pos = 3;
|
|
|
|
|
|
|
|
evas_pointer_canvas_xy_get(evas_object_evas_get(inst->o_main), &px, &py);
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(inst->icons, l, ic)
|
|
|
|
{
|
|
|
|
Edje_Message_Int_Set *msg;
|
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
|
2017-03-13 11:16:36 -07:00
|
|
|
ic->scale = 1.0;
|
2016-11-28 11:04:38 -08:00
|
|
|
evas_object_geometry_get(ic->o_icon, &x, &y, &w, &h);
|
2017-03-08 16:21:15 -08:00
|
|
|
evas_object_resize(ic->o_spacerb, 0, 0);
|
|
|
|
evas_object_resize(ic->o_spacera, 0, 0);
|
|
|
|
evas_object_size_hint_min_set(ic->o_spacerb, 0, 0);
|
|
|
|
evas_object_size_hint_min_set(ic->o_spacera, 0, 0);
|
|
|
|
if (!E_INSIDE(px, py, x, y, w, h))
|
|
|
|
_bar_icon_mouse_out(ic, NULL, ic->o_icon, NULL);
|
2017-03-13 18:57:16 -07:00
|
|
|
else
|
|
|
|
evas_object_raise(ic->o_layout);
|
2016-11-18 12:13:08 -08:00
|
|
|
msg = alloca(sizeof(Edje_Message_Int_Set) + (7 * sizeof(int)));
|
|
|
|
msg->count = 7;
|
|
|
|
msg->val[0] = px;
|
|
|
|
msg->val[1] = py;
|
|
|
|
msg->val[2] = x;
|
|
|
|
msg->val[3] = y;
|
|
|
|
msg->val[4] = w;
|
|
|
|
msg->val[5] = h;
|
|
|
|
msg->val[6] = pos;
|
|
|
|
edje_object_message_send(elm_layout_edje_get(ic->o_layout), EDJE_MESSAGE_INT_SET, 2, msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_mouse_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
Evas_Coord px, py, x, y, w, h;
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
Icon *ic = NULL;
|
|
|
|
|
|
|
|
evas_pointer_canvas_xy_get(evas_object_evas_get(inst->o_main), &px, &py);
|
|
|
|
evas_object_geometry_get(inst->o_main, &x, &y, &w, &h);
|
|
|
|
|
|
|
|
if (E_INSIDE(px, py, x, y, w, h)) return;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(inst->icons, l, ic)
|
|
|
|
{
|
|
|
|
elm_layout_signal_emit(ic->o_layout, "e,state,default", "e");
|
|
|
|
elm_layout_signal_emit(ic->o_layout, "e,state,unfocused", "e");
|
2017-03-13 11:16:36 -07:00
|
|
|
ic->scale = 1.0;
|
2017-03-08 16:21:15 -08:00
|
|
|
evas_object_resize(ic->o_spacerb, 0, 0);
|
|
|
|
evas_object_resize(ic->o_spacera, 0, 0);
|
|
|
|
evas_object_size_hint_min_set(ic->o_spacerb, 0, 0);
|
|
|
|
evas_object_size_hint_min_set(ic->o_spacera, 0, 0);
|
|
|
|
_bar_icon_mouse_out(ic, NULL, ic->o_icon, NULL);
|
2016-11-18 12:13:08 -08:00
|
|
|
}
|
|
|
|
inst->effect = EINA_FALSE;
|
|
|
|
_bar_aspect(inst);
|
|
|
|
}
|
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
static void
|
|
|
|
_bar_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
|
2017-03-13 15:40:43 -07:00
|
|
|
inst->main_del = EINA_TRUE;
|
2017-03-10 12:57:16 -08:00
|
|
|
_bar_empty(inst);
|
2016-11-04 08:22:34 -07:00
|
|
|
e_object_del(E_OBJECT(inst->order));
|
|
|
|
E_FREE_FUNC(inst->drop_handler, evas_object_del);
|
2017-02-06 08:45:58 -08:00
|
|
|
eina_hash_free(inst->icons_desktop_hash);
|
|
|
|
eina_hash_free(inst->icons_clients_hash);
|
2016-10-28 11:26:28 -07:00
|
|
|
luncher_instances = eina_list_remove(luncher_instances, inst);
|
|
|
|
free(inst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_drop_drop(void *data, const char *type, void *event_data)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
E_Event_Dnd_Drop *ev = event_data;
|
|
|
|
Efreet_Desktop *desktop = NULL;
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
Icon *ic = NULL;
|
|
|
|
|
|
|
|
evas_object_del(inst->place_holder);
|
|
|
|
inst->place_holder = NULL;
|
|
|
|
if (!strcmp(type, "enlightenment/desktop"))
|
|
|
|
desktop = ev->data;
|
|
|
|
else if (!strcmp(type, "enlightenment/border"))
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
ec = ev->data;
|
|
|
|
desktop = ec->desktop;
|
|
|
|
if (!desktop)
|
|
|
|
{
|
|
|
|
desktop = e_desktop_client_create(ec);
|
|
|
|
efreet_desktop_save(desktop);
|
|
|
|
e_desktop_edit(desktop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "text/uri-list"))
|
|
|
|
l = ev->data;
|
|
|
|
|
|
|
|
ic = inst->drop_before;
|
|
|
|
if (ic)
|
|
|
|
{
|
|
|
|
if (desktop)
|
|
|
|
e_order_prepend_relative(inst->order, desktop, ic->desktop);
|
|
|
|
else
|
|
|
|
e_order_files_prepend_relative(inst->order, l, ic->desktop);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (desktop)
|
|
|
|
e_order_append(inst->order, desktop);
|
|
|
|
else
|
|
|
|
e_order_files_append(inst->order, l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_drop_leave(void *data, const char *type EINA_UNUSED, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
|
2016-10-31 12:58:42 -07:00
|
|
|
inst->inside = EINA_FALSE;
|
2016-10-28 11:26:28 -07:00
|
|
|
evas_object_del(inst->place_holder);
|
|
|
|
inst->place_holder = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_drop_move(void *data, const char *type EINA_UNUSED, void *event_data)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
E_Event_Dnd_Move *ev = event_data;
|
|
|
|
Evas_Coord x = ev->x, y = ev->y;
|
|
|
|
Eina_List *l;
|
|
|
|
Icon *ic;
|
|
|
|
|
2016-10-31 12:58:42 -07:00
|
|
|
if (!inst->inside)
|
|
|
|
return;
|
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
EINA_LIST_FOREACH(inst->icons, l, ic)
|
|
|
|
{
|
|
|
|
Evas_Coord dx, dy, dw, dh;
|
|
|
|
|
|
|
|
if (!ic->in_order) continue;
|
|
|
|
evas_object_geometry_get(ic->o_layout, &dx, &dy, &dw, &dh);
|
|
|
|
if (E_INSIDE(x, y, dx, dy, dw, dh))
|
|
|
|
inst->drop_before = ic;
|
|
|
|
}
|
|
|
|
elm_box_unpack(inst->o_icon_con, inst->place_holder);
|
2016-11-08 08:55:57 -08:00
|
|
|
if (inst->drop_before)
|
|
|
|
elm_box_pack_before(inst->o_icon_con, inst->place_holder, inst->drop_before->o_layout);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_drop_enter(void *data, const char *type EINA_UNUSED, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
2016-10-31 12:58:42 -07:00
|
|
|
|
|
|
|
inst->inside = EINA_TRUE;
|
2016-10-28 11:26:28 -07:00
|
|
|
inst->place_holder = evas_object_rectangle_add(evas_object_evas_get(inst->o_icon_con));
|
|
|
|
evas_object_color_set(inst->place_holder, 0, 0, 0, 0);
|
|
|
|
evas_object_size_hint_min_set(inst->place_holder, inst->size, inst->size);
|
|
|
|
evas_object_size_hint_max_set(inst->place_holder, inst->size, inst->size);
|
|
|
|
evas_object_show(inst->place_holder);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_removed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
2016-11-05 08:53:56 -07:00
|
|
|
char buf[4096];
|
2017-02-27 18:57:18 -08:00
|
|
|
Ecore_Event_Handler *handler;
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
if (inst->o_main != event_data) return;
|
|
|
|
if (e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s", inst->cfg->dir) >= sizeof(buf))
|
|
|
|
return;
|
|
|
|
|
2017-02-27 18:57:18 -08:00
|
|
|
EINA_LIST_FREE(handlers, handler)
|
|
|
|
E_FREE_FUNC(handler, ecore_event_handler_del);
|
|
|
|
|
|
|
|
E_FREE_FUNC(inst->iconify_provider, e_comp_object_effect_mover_del);
|
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
luncher_config->items = eina_list_remove(luncher_config->items, inst->cfg);
|
2016-11-18 12:13:08 -08:00
|
|
|
eina_stringshare_del(inst->cfg->style);
|
2016-10-28 11:26:28 -07:00
|
|
|
eina_stringshare_del(inst->cfg->dir);
|
|
|
|
E_FREE(inst->cfg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_iconify_end(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
|
|
|
|
{
|
|
|
|
E_Client *ec = data;
|
|
|
|
|
|
|
|
evas_object_layer_set(ec->frame, ec->layer);
|
|
|
|
ec->layer_block = 0;
|
|
|
|
if (ec->iconic)
|
|
|
|
evas_object_hide(ec->frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_bar_iconify_start(void *data, Evas_Object *obj, const char *signal EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
Icon *ic = NULL;
|
|
|
|
E_Client *ec;
|
|
|
|
int ox, oy, ow, oh;
|
|
|
|
|
|
|
|
ec = e_comp_object_client_get(obj);
|
|
|
|
|
|
|
|
if (ec)
|
|
|
|
ic = _bar_icon_match(inst, ec);
|
|
|
|
|
|
|
|
if (!ic) return EINA_FALSE;
|
2017-01-11 11:20:01 -08:00
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
ec->layer_block = 1;
|
|
|
|
evas_object_layer_set(ec->frame, E_LAYER_CLIENT_PRIO);
|
|
|
|
evas_object_geometry_get(ic->o_layout, &ox, &oy, &ow, &oh);
|
|
|
|
e_comp_object_effect_set(ec->frame, "iconify/luncher");
|
|
|
|
e_comp_object_effect_params_set(ec->frame, 1, (int[]){ec->x, ec->y, ec->w, ec->h, ox, oy, ow, oh}, 8);
|
|
|
|
e_comp_object_effect_params_set(ec->frame, 0, (int[]){!!strcmp(signal, "e,action,iconify")}, 1);
|
|
|
|
e_comp_object_effect_start(ec->frame, _bar_iconify_end, ec);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-31 03:31:58 -07:00
|
|
|
_bar_anchor_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
|
|
|
|
if (inst && inst->o_icon_con)
|
|
|
|
{
|
2016-10-31 12:58:42 -07:00
|
|
|
bar_recalculate(inst);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_order_update(void *data, E_Order *eo EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
|
|
|
|
2016-11-22 08:45:38 -08:00
|
|
|
if (inst && inst->o_icon_con)
|
|
|
|
{
|
|
|
|
bar_recalculate(inst);
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_bar_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Instance *inst = data;
|
2016-11-05 08:53:56 -07:00
|
|
|
char buf[4096];
|
2016-10-28 11:26:28 -07:00
|
|
|
const char *drop[] = { "enlightenment/desktop", "enlightenment/border", "text/uri-list" };
|
|
|
|
E_Gadget_Site_Orient orient = e_gadget_site_orient_get(e_gadget_site_get(inst->o_main));
|
|
|
|
|
|
|
|
inst->o_icon_con = elm_box_add(inst->o_main);
|
|
|
|
E_EXPAND(inst->o_icon_con);
|
|
|
|
switch (orient)
|
|
|
|
{
|
|
|
|
case E_GADGET_SITE_ORIENT_HORIZONTAL:
|
|
|
|
elm_box_horizontal_set(inst->o_icon_con, EINA_TRUE);
|
|
|
|
break;
|
|
|
|
case E_GADGET_SITE_ORIENT_VERTICAL:
|
|
|
|
elm_box_horizontal_set(inst->o_icon_con, EINA_FALSE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
elm_box_horizontal_set(inst->o_icon_con, EINA_TRUE);
|
|
|
|
}
|
|
|
|
elm_layout_content_set(inst->o_main, "e.swallow.bar", inst->o_icon_con);
|
|
|
|
evas_object_show(inst->o_icon_con);
|
|
|
|
|
|
|
|
evas_object_data_set(inst->o_main, "instance", inst);
|
|
|
|
evas_object_data_set(inst->o_icon_con, "instance", inst);
|
|
|
|
|
|
|
|
e_gadget_configure_cb_set(inst->o_main, _bar_gadget_configure);
|
|
|
|
evas_object_smart_callback_del_full(obj, "gadget_created", _bar_created_cb, data);
|
|
|
|
|
|
|
|
if (!inst->cfg->dir)
|
|
|
|
inst->cfg->dir = eina_stringshare_add("default");
|
|
|
|
if (inst->cfg->dir[0] != '/')
|
|
|
|
e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s/.order",
|
|
|
|
inst->cfg->dir);
|
|
|
|
else
|
|
|
|
eina_strlcpy(buf, inst->cfg->dir, sizeof(buf));
|
|
|
|
|
2016-11-18 12:13:08 -08:00
|
|
|
if (!inst->cfg->style)
|
|
|
|
inst->cfg->style = eina_stringshare_add("default");
|
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
inst->order = e_order_new(buf);
|
|
|
|
e_order_update_callback_set(inst->order, _bar_order_update, inst);
|
|
|
|
|
2017-02-27 18:57:18 -08:00
|
|
|
if (inst->cfg->type != E_LUNCHER_MODULE_LAUNCH_ONLY)
|
|
|
|
{
|
|
|
|
inst->iconify_provider = e_comp_object_effect_mover_add(80, "e,action,*iconify",
|
|
|
|
_bar_iconify_start, inst);
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
_bar_fill(inst);
|
|
|
|
|
2017-02-27 18:57:18 -08:00
|
|
|
if (inst->cfg->type != E_LUNCHER_MODULE_TASKS_ONLY)
|
|
|
|
{
|
|
|
|
inst->drop_handler =
|
|
|
|
e_gadget_drop_handler_add(inst->o_main, inst,
|
|
|
|
_bar_drop_enter, _bar_drop_move,
|
|
|
|
_bar_drop_leave, _bar_drop_drop,
|
|
|
|
drop, 3);
|
|
|
|
elm_layout_content_set(inst->o_main, "e.swallow.drop", inst->drop_handler);
|
|
|
|
evas_object_show(inst->drop_handler);
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_RESIZE, _bar_resize, inst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Config_Item *
|
|
|
|
_conf_item_get(int *id)
|
|
|
|
{
|
|
|
|
Config_Item *ci;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
if (*id > 0)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(luncher_config->items, l, ci)
|
|
|
|
if (*id == ci->id) return ci;
|
|
|
|
}
|
|
|
|
|
|
|
|
ci = E_NEW(Config_Item, 1);
|
2016-11-01 10:01:51 -07:00
|
|
|
|
|
|
|
if (*id != -1)
|
|
|
|
ci->id = eina_list_count(luncher_config->items)+1;
|
|
|
|
else
|
|
|
|
ci->id = -1;
|
2016-10-28 11:26:28 -07:00
|
|
|
ci->dir = eina_stringshare_add("default");
|
2016-11-22 08:45:38 -08:00
|
|
|
ci->style = eina_stringshare_add("default");
|
2017-02-27 18:57:18 -08:00
|
|
|
ci->type = E_LUNCHER_MODULE_FULL;
|
2016-10-28 11:26:28 -07:00
|
|
|
luncher_config->items = eina_list_append(luncher_config->items, ci);
|
|
|
|
|
|
|
|
return ci;
|
|
|
|
}
|
|
|
|
|
2016-10-31 12:58:42 -07:00
|
|
|
static void
|
|
|
|
_bar_recalculate_job(void *data)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
2016-10-31 12:58:42 -07:00
|
|
|
Instance *inst = data;
|
|
|
|
|
2016-11-07 07:35:34 -08:00
|
|
|
if (inst)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
2016-11-07 07:35:34 -08:00
|
|
|
if (inst->o_icon_con)
|
|
|
|
{
|
|
|
|
_bar_empty(inst);
|
|
|
|
_bar_fill(inst);
|
|
|
|
}
|
|
|
|
inst->recalc_job = NULL;
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
2016-10-31 12:58:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EINTERN void
|
|
|
|
bar_recalculate(Instance *inst)
|
|
|
|
{
|
2016-11-04 08:22:34 -07:00
|
|
|
E_FREE_FUNC(inst->recalc_job, ecore_job_del);
|
2016-10-31 12:58:42 -07:00
|
|
|
inst->recalc_job = ecore_job_add(_bar_recalculate_job, inst);
|
2016-10-28 11:26:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EINTERN void
|
|
|
|
bar_reorder(Instance *inst)
|
|
|
|
{
|
2016-11-05 08:53:56 -07:00
|
|
|
char buf[4096];
|
2016-10-28 11:26:28 -07:00
|
|
|
|
|
|
|
if (inst)
|
|
|
|
{
|
2016-11-04 08:22:34 -07:00
|
|
|
E_FREE_FUNC(inst->recalc_job, ecore_job_del);
|
2016-10-28 11:26:28 -07:00
|
|
|
_bar_empty(inst);
|
|
|
|
if (!inst->cfg->dir)
|
|
|
|
inst->cfg->dir = eina_stringshare_add("default");
|
|
|
|
if (inst->cfg->dir[0] != '/')
|
|
|
|
e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s/.order",
|
|
|
|
inst->cfg->dir);
|
|
|
|
else
|
|
|
|
eina_strlcpy(buf, inst->cfg->dir, sizeof(buf));
|
|
|
|
e_object_del(E_OBJECT(inst->order));
|
|
|
|
inst->order = e_order_new(buf);
|
|
|
|
e_order_update_callback_set(inst->order, _bar_order_update, inst);
|
|
|
|
_bar_fill(inst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-27 18:57:18 -08:00
|
|
|
EINTERN void
|
|
|
|
bar_config_updated(Instance *inst)
|
|
|
|
{
|
|
|
|
Ecore_Event_Handler *handler;
|
|
|
|
const char *drop[] = { "enlightenment/desktop", "enlightenment/border", "text/uri-list" };
|
|
|
|
|
|
|
|
EINA_LIST_FREE(handlers, handler)
|
|
|
|
E_FREE_FUNC(handler, ecore_event_handler_del);
|
|
|
|
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_CONFIG_ICON_THEME,
|
|
|
|
_bar_cb_update_icons, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, EFREET_EVENT_ICON_CACHE_UPDATE,
|
|
|
|
_bar_cb_update_icons, NULL);
|
|
|
|
if (inst->cfg->type != E_LUNCHER_MODULE_LAUNCH_ONLY)
|
|
|
|
{
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_EXEC_NEW,
|
|
|
|
_bar_cb_exec_new, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_EXEC_NEW_CLIENT,
|
|
|
|
_bar_cb_exec_new, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_PROPERTY,
|
|
|
|
_bar_cb_exec_client_prop, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_EXEC_DEL,
|
|
|
|
_bar_cb_exec_del, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_REMOVE,
|
|
|
|
_bar_cb_client_remove, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!inst->iconify_provider && inst->cfg->type != E_LUNCHER_MODULE_LAUNCH_ONLY)
|
|
|
|
{
|
|
|
|
inst->iconify_provider = e_comp_object_effect_mover_add(80, "e,action,*iconify",
|
|
|
|
_bar_iconify_start, inst);
|
|
|
|
}
|
|
|
|
else if (inst->iconify_provider && inst->cfg->type == E_LUNCHER_MODULE_LAUNCH_ONLY)
|
|
|
|
{
|
|
|
|
E_FREE_FUNC(inst->iconify_provider, e_comp_object_effect_mover_del);
|
|
|
|
}
|
|
|
|
|
|
|
|
bar_reorder(inst);
|
|
|
|
|
|
|
|
if (!inst->drop_handler && inst->cfg->type != E_LUNCHER_MODULE_TASKS_ONLY)
|
|
|
|
{
|
|
|
|
inst->drop_handler =
|
|
|
|
e_gadget_drop_handler_add(inst->o_main, inst,
|
|
|
|
_bar_drop_enter, _bar_drop_move,
|
|
|
|
_bar_drop_leave, _bar_drop_drop,
|
|
|
|
drop, 3);
|
|
|
|
elm_layout_content_set(inst->o_main, "e.swallow.drop", inst->drop_handler);
|
|
|
|
evas_object_show(inst->drop_handler);
|
|
|
|
}
|
|
|
|
else if (inst->drop_handler && inst->cfg->type == E_LUNCHER_MODULE_TASKS_ONLY)
|
|
|
|
{
|
|
|
|
E_FREE_FUNC(inst->drop_handler, evas_object_del);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-28 11:26:28 -07:00
|
|
|
EINTERN Evas_Object *
|
2016-10-31 03:31:58 -07:00
|
|
|
bar_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient EINA_UNUSED)
|
2016-10-28 11:26:28 -07:00
|
|
|
{
|
|
|
|
Instance *inst;
|
|
|
|
|
|
|
|
inst = E_NEW(Instance, 1);
|
|
|
|
inst->size = 0;
|
|
|
|
inst->resize_job = NULL;
|
|
|
|
inst->cfg = _conf_item_get(id);
|
|
|
|
*id = inst->cfg->id;
|
2016-10-31 12:58:42 -07:00
|
|
|
inst->inside = EINA_FALSE;
|
2016-11-18 12:13:08 -08:00
|
|
|
inst->effect = EINA_FALSE;
|
2016-11-22 19:17:22 -08:00
|
|
|
inst->bar = EINA_TRUE;
|
2017-03-13 15:40:43 -07:00
|
|
|
inst->main_del = EINA_FALSE;
|
2016-10-28 11:26:28 -07:00
|
|
|
inst->icons_desktop_hash = eina_hash_string_superfast_new(NULL);
|
|
|
|
inst->icons_clients_hash = eina_hash_pointer_new(NULL);
|
|
|
|
inst->o_main = elm_layout_add(parent);
|
|
|
|
e_theme_edje_object_set(inst->o_main, "e/gadget/luncher/bar",
|
|
|
|
"e/gadget/luncher/bar");
|
2017-03-13 18:57:16 -07:00
|
|
|
edje_object_update_hints_set(elm_layout_edje_get(inst->o_main), EINA_TRUE);
|
2016-11-18 12:13:08 -08:00
|
|
|
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_MOUSE_MOVE, _bar_mouse_move, inst);
|
|
|
|
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_MOUSE_OUT, _bar_mouse_out, inst);
|
2016-10-28 11:26:28 -07:00
|
|
|
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_DEL, _bar_del, inst);
|
|
|
|
evas_object_smart_callback_add(parent, "gadget_created", _bar_created_cb, inst);
|
|
|
|
evas_object_smart_callback_add(parent, "gadget_site_anchor", _bar_anchor_changed_cb, inst);
|
|
|
|
evas_object_smart_callback_add(parent, "gadget_removed", _bar_removed_cb, inst);
|
|
|
|
evas_object_show(inst->o_main);
|
|
|
|
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_CONFIG_ICON_THEME,
|
|
|
|
_bar_cb_update_icons, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, EFREET_EVENT_ICON_CACHE_UPDATE,
|
|
|
|
_bar_cb_update_icons, NULL);
|
2017-02-27 18:57:18 -08:00
|
|
|
if (inst->cfg->type != E_LUNCHER_MODULE_LAUNCH_ONLY)
|
|
|
|
{
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_EXEC_NEW,
|
|
|
|
_bar_cb_exec_new, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_EXEC_NEW_CLIENT,
|
|
|
|
_bar_cb_exec_new, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_PROPERTY,
|
|
|
|
_bar_cb_exec_client_prop, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_EXEC_DEL,
|
|
|
|
_bar_cb_exec_del, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_REMOVE,
|
|
|
|
_bar_cb_client_remove, NULL);
|
|
|
|
}
|
2016-10-28 11:26:28 -07:00
|
|
|
if (inst->cfg->id < 0) return inst->o_main;
|
|
|
|
luncher_instances = eina_list_append(luncher_instances, inst);
|
|
|
|
|
|
|
|
current_preview = NULL;
|
|
|
|
current_preview_menu = EINA_FALSE;
|
|
|
|
|
|
|
|
return inst->o_main;
|
|
|
|
}
|
|
|
|
|