make extra actions work. use them from illume.

SVN revision: 37811
devs/princeamd/enlightenment-0.17-elive
Carsten Haitzler 14 years ago
parent 3c66ab8d7a
commit 6cf459572f
  1. 30
      data/themes/illume.edc
  2. 27
      src/bin/e_actions.c
  3. 1
      src/bin/e_actions.h
  4. 40
      src/bin/e_sys.c
  5. 18
      src/bin/e_sys.h
  6. 52
      src/modules/illume/e_mod_win.c
  7. 47
      src/modules/syscon/e_syscon.c

@ -372,6 +372,36 @@ collections {
}
}
}
group { name: "e/icons/enlightenment/home";
images.image: "illume-home.png" COMP;
max: 96 96;
parts {
part { name: "icon";
repeat_events: 1;
description { state: "default" 0.0;
aspect: 1.0 1.0;
aspect_preference: BOTH;
image.normal: "illume-home.png";
}
}
}
}
group { name: "e/icons/enlightenment/close";
images.image: "illume-close.png" COMP;
max: 96 96;
parts {
part { name: "icon";
repeat_events: 1;
description { state: "default" 0.0;
aspect: 1.0 1.0;
aspect_preference: BOTH;
image.normal: "illume-close.png";
}
}
}
}
group { name: "e/modules/slipshelf/controls/default";
images {

@ -2705,6 +2705,33 @@ e_action_find(const char *name)
return act;
}
EAPI const char *
e_action_predef_label_get(const char *action, const char *params)
{
E_Action_Group *actg = NULL;
E_Action_Description *actd = NULL;
Eina_List *l, *l2;
for (l = action_groups; l; l = l->next)
{
actg = l->data;
for (l2 = actg->acts; l2; l2 = l2->next)
{
actd = l2->data;
if (!strcmp(actd->act_cmd, action))
{
if ((params) && (actd->act_params) &&
(!strcmp(params, actd->act_params)))
{
return actd->act_name;
}
}
}
}
if (params) return e_action_predef_label_get(action, NULL);
return NULL;
}
EAPI void
e_action_predef_name_set(const char *act_grp, const char *act_name, const char *act_cmd, const char *act_params, const char *param_example, int editable)
{

@ -54,6 +54,7 @@ EAPI E_Action *e_action_add(const char *name);
EAPI void e_action_del(const char *name);
EAPI E_Action *e_action_find(const char *name);
EAPI const char *e_action_predef_label_get(const char *action, const char *params);
EAPI void e_action_predef_name_set(const char *act_grp, const char *act_name, const char *act_cmd, const char *act_params, const char *param_example, int editable);
EAPI void e_action_predef_name_del(const char *act_grp, const char *act_name);
EAPI void e_action_predef_name_all_del(void);

@ -118,6 +118,46 @@ e_sys_action_do(E_Sys_Action a, char *param)
return ret;
}
static Eina_List *extra_actions = NULL;
EAPI E_Sys_Con_Action *
e_sys_con_extra_action_register(const char *label,
const char *icon_group,
const char *button_name,
void (*func) (void *data),
const void *data)
{
E_Sys_Con_Action *sca;
sca = E_NEW(E_Sys_Con_Action, 1);
if (label)
sca->label = eina_stringshare_add(label);
if (icon_group)
sca->icon_group = eina_stringshare_add(icon_group);
if (button_name)
sca->button_name = eina_stringshare_add(button_name);
sca->func = func;
sca->data = data;
extra_actions = eina_list_append(extra_actions, sca);
return sca;
}
EAPI void
e_sys_con_extra_action_unregister(E_Sys_Con_Action *sca)
{
extra_actions = eina_list_remove(extra_actions, sca);
if (sca->label) eina_stringshare_del(sca->label);
if (sca->icon_group) eina_stringshare_del(sca->icon_group);
if (sca->button_name) eina_stringshare_del(sca->button_name);
free(sca);
}
EAPI const Eina_List *
e_sys_con_extra_action_list_get(void)
{
return extra_actions;
}
/* local subsystem functions */
static int
_e_sys_cb_timer(void *data)

@ -3,6 +3,7 @@
*/
#ifdef E_TYPEDEFS
typedef struct _E_Sys_Con_Action E_Sys_Con_Action;
typedef enum _E_Sys_Action E_Sys_Action;
enum _E_Sys_Action
@ -19,6 +20,15 @@ enum _E_Sys_Action
E_SYS_HIBERNATE
};
struct _E_Sys_Con_Action
{
const char *label;
const char *icon_group;
const char *button_name;
void (*func) (void *data);
const void *data;
};
#else
#ifndef E_SYS_H
#define E_SYS_H
@ -27,6 +37,14 @@ EAPI int e_sys_init(void);
EAPI int e_sys_shutdown(void);
EAPI int e_sys_action_possible_get(E_Sys_Action a);
EAPI int e_sys_action_do(E_Sys_Action a, char *param);
EAPI E_Sys_Con_Action *e_sys_con_extra_action_register(const char *label,
const char *icon_group,
const char *button_name,
void (*func) (void *data),
const void *data);
EAPI void e_sys_con_extra_action_unregister(E_Sys_Con_Action *sca);
EAPI const Eina_List *e_sys_con_extra_action_list_get(void);
#endif
#endif

@ -39,6 +39,8 @@ static int _cb_efreet_desktop_change(void *data, int type, void *event);
static void _apps_unpopulate(void);
static void _apps_populate(void);
static int _cb_update_deferred(void *data);
static void _cb_sys_con_close(void *data);
static void _cb_sys_con_home(void *data);
static void _e_illume_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
static void _e_illume_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
@ -69,6 +71,9 @@ static E_Flaunch *flaunch = NULL;
static E_Appwin *appwin = NULL;
static E_Syswin *syswin = NULL;
static E_Sys_Con_Action *sys_con_act_close = NULL;
static E_Sys_Con_Action *sys_con_act_home = NULL;
/* called from the module core */
void
_e_mod_win_init(E_Module *m)
@ -144,11 +149,20 @@ _e_mod_win_init(E_Module *m)
_apps_unpopulate();
_apps_populate();
e_configure_registry_custom_desktop_exec_callback_set(_cb_cfg_exec, NULL);
sys_con_act_close = e_sys_con_extra_action_register
(_("Close"), "enlightenment/close", "button", _cb_sys_con_close, NULL);
sys_con_act_home = e_sys_con_extra_action_register
(_("Home"), "enlightenment/home", "button", _cb_sys_con_home, NULL);
}
void
_e_mod_win_shutdown(void)
{
e_sys_con_extra_action_unregister(sys_con_act_close);
sys_con_act_close = NULL;
e_sys_con_extra_action_unregister(sys_con_act_home);
sys_con_act_home = NULL;
e_object_del(E_OBJECT(flaunch));
flaunch = NULL;
if (busywin)
@ -1107,6 +1121,44 @@ _cb_update_deferred(void *data)
return 0;
}
static void
_cb_sys_con_close(void *data)
{
E_Border *bd;
bd = e_border_focused_get();
if (bd)
{
if (e_object_is_del(E_OBJECT(bd))) return;
if ((!bd->client.icccm.accepts_focus) &&
(!bd->client.icccm.take_focus)) return;
if (bd->client.netwm.state.skip_taskbar) return;
if (bd->user_skip_winlist) return;
_e_mod_layout_border_close(bd);
}
}
static void
_cb_sys_con_home(void *data)
{
Eina_List *l, *borders;
borders = e_border_client_list();
for (l = borders; l; l = l->next)
{
E_Border *bd;
bd = l->data;
if (e_object_is_del(E_OBJECT(bd))) continue;
if ((!bd->client.icccm.accepts_focus) &&
(!bd->client.icccm.take_focus)) continue;
if (bd->client.netwm.state.skip_taskbar) continue;
if (bd->user_skip_winlist) continue;
_e_mod_layout_border_hide(bd);
}
}
static void
_e_illume_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
{

@ -13,6 +13,7 @@ static int _cb_mouse_wheel(void *data, int type, void *event);
static void _cb_signal_close(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _cb_signal_syscon(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _cb_signal_action(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _cb_signal_action_extra(void *data, Evas_Object *obj, const char *emission, const char *source);
static int _cb_timeout_defaction(void *data);
/* local subsystem globals */
@ -163,7 +164,8 @@ e_syscon_show(E_Zone *zone, const char *defact)
else
e_theme_edje_object_set(o, "base/theme/widgets",
"e/widgets/syscon/item/button");
// edje_object_part_text_set(o, "e.text.label", sca->action);
edje_object_part_text_set(o, "e.text.label",
e_action_predef_label_get(sca->action, sca->params));
if (sca->icon)
{
o2 = edje_object_add(popup->evas);
@ -189,7 +191,37 @@ e_syscon_show(E_Zone *zone, const char *defact)
iw, ih, iw, ih);
evas_object_show(o);
}
// FIXME: "extra" list needs to be handled
for (l = (Eina_List *)e_sys_con_extra_action_list_get(); l; l = l->next)
{
E_Sys_Con_Action *sca;
char buf[1024];
sca = l->data;
o = edje_object_add(popup->evas);
edje_object_signal_callback_add(o, "e,action,click", "", _cb_signal_action_extra, sca);
if (sca->button_name)
{
snprintf(buf, sizeof(buf), "e/widgets/syscon/item/%s",
sca->button_name);
e_theme_edje_object_set(o, "base/theme/widgets", buf);
}
else
e_theme_edje_object_set(o, "base/theme/widgets",
"e/widgets/syscon/item/button");
edje_object_part_text_set(o, "e.text.label", sca->label);
if (sca->icon_group)
{
o2 = edje_object_add(popup->evas);
e_util_edje_icon_set(o2, sca->icon_group);
edje_object_part_swallow(o, "e.swallow.icon", o2);
evas_object_show(o2);
}
e_flowlayout_pack_end(o_flow_extra, o);
iw = ih = e_config->syscon.extra.icon_size * e_scale;
e_flowlayout_pack_options_set(o, 1, 1, 0, 0, 0.5, 0.5,
iw, ih, iw, ih);
evas_object_show(o);
}
e_flowlayout_fill_set(o_flow_main, 1);
edje_object_part_swallow(o_bg, "e.swallow.main", o_flow_main);
@ -391,6 +423,17 @@ _cb_signal_action(void *data, Evas_Object *obj, const char *emission, const char
if (a) a->func.go(NULL, sca->params);
}
static void
_cb_signal_action_extra(void *data, Evas_Object *obj, const char *emission, const char *source)
{
E_Sys_Con_Action *sca;
e_syscon_hide();
sca = data;
if (!sca) return;
if (sca->func) sca->func((void *)sca->data);
}
static int
_cb_timeout_defaction(void *data)
{

Loading…
Cancel
Save