forked from enlightenment/enlightenment
formatting. I'm going to catch whoever this is and beat them.
SVN revision: 55729
This commit is contained in:
parent
2e4b8b9901
commit
5020fd62b0
|
@ -9,32 +9,43 @@
|
|||
/* local config structure */
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
Eina_List *bindings;
|
||||
Evas_Object *o_bindings, *o_actions, *o_params;
|
||||
Evas_Object *o_add, *o_del;
|
||||
const char *bindex;
|
||||
Eina_List *bindings;
|
||||
Evas_Object *o_bindings, *o_actions, *o_params;
|
||||
Evas_Object *o_add, *o_del;
|
||||
const char *bindex;
|
||||
|
||||
E_Config_Dialog *cfd;
|
||||
};
|
||||
|
||||
/* local function prototypes */
|
||||
static void *_create_data(E_Config_Dialog *cfd);
|
||||
static void _fill_data(E_Config_Dialog_Data *cfdata);
|
||||
static void _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static void _fill_bindings(E_Config_Dialog_Data *cfdata);
|
||||
static void _fill_actions(E_Config_Dialog_Data *cfdata);
|
||||
static void *_create_data(E_Config_Dialog *cfd);
|
||||
static void _fill_data(E_Config_Dialog_Data *cfdata);
|
||||
static void _free_data(E_Config_Dialog *cfd __UNUSED__,
|
||||
E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply(E_Config_Dialog *cfd __UNUSED__,
|
||||
E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create(E_Config_Dialog *cfd,
|
||||
Evas *evas,
|
||||
E_Config_Dialog_Data *cfdata);
|
||||
static void _fill_bindings(E_Config_Dialog_Data *cfdata);
|
||||
static void _fill_actions(E_Config_Dialog_Data *cfdata);
|
||||
static E_Config_Binding_Acpi *_selected_binding_get(E_Config_Dialog_Data *cfdata);
|
||||
static E_Action_Description *_selected_action_get(E_Config_Dialog_Data *cfdata);
|
||||
static const char *_binding_label_get(E_Config_Binding_Acpi *bind);
|
||||
static void _cb_bindings_changed(void *data);
|
||||
static void _cb_actions_changed(void *data);
|
||||
static void _cb_entry_changed(void *data, void *data2 __UNUSED__);
|
||||
static void _cb_add_binding(void *data, void *data2 __UNUSED__);
|
||||
static void _cb_del_binding(void *data, void *data2 __UNUSED__);
|
||||
static Eina_Bool _cb_grab_key_down(void *data, int type __UNUSED__, void *event);
|
||||
static Eina_Bool _cb_acpi_event(void *data, int type, void *event);
|
||||
static E_Action_Description *_selected_action_get(E_Config_Dialog_Data *cfdata);
|
||||
static const char *_binding_label_get(E_Config_Binding_Acpi *bind);
|
||||
static void _cb_bindings_changed(void *data);
|
||||
static void _cb_actions_changed(void *data);
|
||||
static void _cb_entry_changed(void *data,
|
||||
void *data2 __UNUSED__);
|
||||
static void _cb_add_binding(void *data,
|
||||
void *data2 __UNUSED__);
|
||||
static void _cb_del_binding(void *data,
|
||||
void *data2 __UNUSED__);
|
||||
static Eina_Bool _cb_grab_key_down(void *data,
|
||||
int type __UNUSED__,
|
||||
void *event);
|
||||
static Eina_Bool _cb_acpi_event(void *data,
|
||||
int type,
|
||||
void *event);
|
||||
|
||||
/* local variables */
|
||||
static E_Dialog *grab_dlg = NULL;
|
||||
|
@ -42,7 +53,8 @@ static Ecore_X_Window grab_win = 0;
|
|||
static Eina_List *grab_hdls = NULL;
|
||||
|
||||
E_Config_Dialog *
|
||||
e_int_config_acpibindings(E_Container *con, const char *params __UNUSED__)
|
||||
e_int_config_acpibindings(E_Container *con,
|
||||
const char *params __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
|
@ -57,9 +69,9 @@ e_int_config_acpibindings(E_Container *con, const char *params __UNUSED__)
|
|||
v->basic.create_widgets = _basic_create;
|
||||
|
||||
cfd = e_config_dialog_new(con, _("ACPI Bindings"), "E",
|
||||
"advanced/acpi_bindings",
|
||||
"preferences-system-power-management",
|
||||
0, v, NULL);
|
||||
"advanced/acpi_bindings",
|
||||
"preferences-system-power-management",
|
||||
0, v, NULL);
|
||||
|
||||
return cfd;
|
||||
}
|
||||
|
@ -84,29 +96,30 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
|||
|
||||
EINA_LIST_FOREACH(e_config->acpi_bindings, l, bind)
|
||||
{
|
||||
E_Config_Binding_Acpi *b2;
|
||||
E_Config_Binding_Acpi *b2;
|
||||
|
||||
b2 = E_NEW(E_Config_Binding_Acpi, 1);
|
||||
b2->context = bind->context;
|
||||
b2->type = bind->type;
|
||||
b2->status = bind->status;
|
||||
b2->action = eina_stringshare_ref(bind->action);
|
||||
b2->params = eina_stringshare_ref(bind->params);
|
||||
cfdata->bindings = eina_list_append(cfdata->bindings, b2);
|
||||
b2 = E_NEW(E_Config_Binding_Acpi, 1);
|
||||
b2->context = bind->context;
|
||||
b2->type = bind->type;
|
||||
b2->status = bind->status;
|
||||
b2->action = eina_stringshare_ref(bind->action);
|
||||
b2->params = eina_stringshare_ref(bind->params);
|
||||
cfdata->bindings = eina_list_append(cfdata->bindings, b2);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
_free_data(E_Config_Dialog *cfd __UNUSED__,
|
||||
E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
E_Config_Binding_Acpi *bind;
|
||||
Ecore_Event_Handler *hdl;
|
||||
|
||||
EINA_LIST_FREE(cfdata->bindings, bind)
|
||||
{
|
||||
if (bind->action) eina_stringshare_del(bind->action);
|
||||
if (bind->params) eina_stringshare_del(bind->params);
|
||||
E_FREE(bind);
|
||||
if (bind->action) eina_stringshare_del(bind->action);
|
||||
if (bind->params) eina_stringshare_del(bind->params);
|
||||
E_FREE(bind);
|
||||
}
|
||||
|
||||
/* free the handlers */
|
||||
|
@ -115,15 +128,15 @@ _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
|||
|
||||
if (grab_win)
|
||||
{
|
||||
e_grabinput_release(grab_win, grab_win);
|
||||
ecore_x_window_free(grab_win);
|
||||
e_grabinput_release(grab_win, grab_win);
|
||||
ecore_x_window_free(grab_win);
|
||||
}
|
||||
grab_win = 0;
|
||||
|
||||
if (grab_dlg)
|
||||
{
|
||||
e_object_del(E_OBJECT(grab_dlg));
|
||||
e_acpi_events_thaw();
|
||||
e_object_del(E_OBJECT(grab_dlg));
|
||||
e_acpi_events_thaw();
|
||||
}
|
||||
grab_dlg = NULL;
|
||||
|
||||
|
@ -131,33 +144,34 @@ _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
|||
}
|
||||
|
||||
static int
|
||||
_basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
_basic_apply(E_Config_Dialog *cfd __UNUSED__,
|
||||
E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
E_Config_Binding_Acpi *bind, *b2;
|
||||
Eina_List *l;
|
||||
|
||||
EINA_LIST_FREE(e_config->acpi_bindings, bind)
|
||||
{
|
||||
e_bindings_acpi_del(bind->context, bind->type, bind->status,
|
||||
bind->action, bind->params);
|
||||
if (bind->action) eina_stringshare_del(bind->action);
|
||||
if (bind->params) eina_stringshare_del(bind->params);
|
||||
E_FREE(bind);
|
||||
e_bindings_acpi_del(bind->context, bind->type, bind->status,
|
||||
bind->action, bind->params);
|
||||
if (bind->action) eina_stringshare_del(bind->action);
|
||||
if (bind->params) eina_stringshare_del(bind->params);
|
||||
E_FREE(bind);
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(cfdata->bindings, l, bind)
|
||||
{
|
||||
b2 = E_NEW(E_Config_Binding_Acpi, 1);
|
||||
b2->context = bind->context;
|
||||
b2->type = bind->type;
|
||||
b2->status = bind->status;
|
||||
b2->action = eina_stringshare_ref(bind->action);
|
||||
b2->params = eina_stringshare_ref(bind->params);
|
||||
e_config->acpi_bindings =
|
||||
eina_list_append(e_config->acpi_bindings, b2);
|
||||
b2 = E_NEW(E_Config_Binding_Acpi, 1);
|
||||
b2->context = bind->context;
|
||||
b2->type = bind->type;
|
||||
b2->status = bind->status;
|
||||
b2->action = eina_stringshare_ref(bind->action);
|
||||
b2->params = eina_stringshare_ref(bind->params);
|
||||
e_config->acpi_bindings =
|
||||
eina_list_append(e_config->acpi_bindings, b2);
|
||||
|
||||
e_bindings_acpi_add(b2->context, b2->type, b2->status,
|
||||
b2->action, b2->params);
|
||||
e_bindings_acpi_add(b2->context, b2->type, b2->status,
|
||||
b2->action, b2->params);
|
||||
}
|
||||
e_config_save_queue();
|
||||
|
||||
|
@ -165,7 +179,9 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
|||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
_basic_create(E_Config_Dialog *cfd,
|
||||
Evas *evas,
|
||||
E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *ol, *of, *ow, *ot;
|
||||
|
||||
|
@ -173,17 +189,17 @@ _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
|||
|
||||
of = e_widget_frametable_add(evas, _("ACPI Bindings"), 0);
|
||||
ow = e_widget_ilist_add(evas, (24 * e_scale), (24 * e_scale),
|
||||
&(cfdata->bindex));
|
||||
&(cfdata->bindex));
|
||||
cfdata->o_bindings = ow;
|
||||
_fill_bindings(cfdata);
|
||||
e_widget_frametable_object_append(of, ow, 0, 0, 2, 1, 1, 1, 1, 1);
|
||||
|
||||
ow = e_widget_button_add(evas, _("Add Binding"), "list-add",
|
||||
_cb_add_binding, cfdata, NULL);
|
||||
_cb_add_binding, cfdata, NULL);
|
||||
cfdata->o_add = ow;
|
||||
e_widget_frametable_object_append(of, ow, 0, 1, 1, 1, 1, 0, 1, 0);
|
||||
ow = e_widget_button_add(evas, _("Delete Binding"), "list-remove",
|
||||
_cb_del_binding, cfdata, NULL);
|
||||
_cb_del_binding, cfdata, NULL);
|
||||
cfdata->o_del = ow;
|
||||
e_widget_disabled_set(ow, EINA_TRUE);
|
||||
e_widget_frametable_object_append(of, ow, 1, 1, 1, 1, 1, 0, 1, 0);
|
||||
|
@ -225,14 +241,14 @@ _fill_bindings(E_Config_Dialog_Data *cfdata)
|
|||
|
||||
EINA_LIST_FOREACH(cfdata->bindings, l, bind)
|
||||
{
|
||||
const char *lbl;
|
||||
char buff[32];
|
||||
const char *lbl;
|
||||
char buff[32];
|
||||
|
||||
i++;
|
||||
if (!(lbl = _binding_label_get(bind))) continue;
|
||||
snprintf(buff, sizeof(buff), "%d", i);
|
||||
e_widget_ilist_append(cfdata->o_bindings, NULL, lbl,
|
||||
_cb_bindings_changed, cfdata, buff);
|
||||
i++;
|
||||
if (!(lbl = _binding_label_get(bind))) continue;
|
||||
snprintf(buff, sizeof(buff), "%d", i);
|
||||
e_widget_ilist_append(cfdata->o_bindings, NULL, lbl,
|
||||
_cb_bindings_changed, cfdata, buff);
|
||||
}
|
||||
|
||||
e_widget_ilist_go(cfdata->o_bindings);
|
||||
|
@ -261,14 +277,14 @@ _fill_actions(E_Config_Dialog_Data *cfdata)
|
|||
|
||||
EINA_LIST_FOREACH(e_action_groups_get(), l, grp)
|
||||
{
|
||||
if (!grp->acts) continue;
|
||||
if ((strcmp(grp->act_grp, "Acpi")) &&
|
||||
(strcmp(grp->act_grp, "System")) &&
|
||||
(strcmp(grp->act_grp, "Launch"))) continue;
|
||||
e_widget_ilist_header_append(cfdata->o_actions, NULL, grp->act_grp);
|
||||
EINA_LIST_FOREACH(grp->acts, ll, dsc)
|
||||
e_widget_ilist_append(cfdata->o_actions, NULL, dsc->act_name,
|
||||
_cb_actions_changed, cfdata, dsc->act_cmd);
|
||||
if (!grp->acts) continue;
|
||||
if ((strcmp(grp->act_grp, "Acpi")) &&
|
||||
(strcmp(grp->act_grp, "System")) &&
|
||||
(strcmp(grp->act_grp, "Launch"))) continue;
|
||||
e_widget_ilist_header_append(cfdata->o_actions, NULL, grp->act_grp);
|
||||
EINA_LIST_FOREACH(grp->acts, ll, dsc)
|
||||
e_widget_ilist_append(cfdata->o_actions, NULL, dsc->act_name,
|
||||
_cb_actions_changed, cfdata, dsc->act_cmd);
|
||||
}
|
||||
|
||||
e_widget_ilist_go(cfdata->o_actions);
|
||||
|
@ -308,15 +324,15 @@ _selected_action_get(E_Config_Dialog_Data *cfdata)
|
|||
|
||||
EINA_LIST_FOREACH(e_action_groups_get(), l, grp)
|
||||
{
|
||||
if (!grp->acts) continue;
|
||||
if ((strcmp(grp->act_grp, "Acpi")) &&
|
||||
(strcmp(grp->act_grp, "System")) &&
|
||||
(strcmp(grp->act_grp, "Launch"))) continue;
|
||||
EINA_LIST_FOREACH(grp->acts, ll, dsc)
|
||||
{
|
||||
if ((dsc->act_name) && (!strcmp(dsc->act_name, lbl)))
|
||||
return dsc;
|
||||
}
|
||||
if (!grp->acts) continue;
|
||||
if ((strcmp(grp->act_grp, "Acpi")) &&
|
||||
(strcmp(grp->act_grp, "System")) &&
|
||||
(strcmp(grp->act_grp, "Launch"))) continue;
|
||||
EINA_LIST_FOREACH(grp->acts, ll, dsc)
|
||||
{
|
||||
if ((dsc->act_name) && (!strcmp(dsc->act_name, lbl)))
|
||||
return dsc;
|
||||
}
|
||||
}
|
||||
|
||||
return dsc;
|
||||
|
@ -330,25 +346,36 @@ _binding_label_get(E_Config_Binding_Acpi *bind)
|
|||
if (bind->type == E_ACPI_TYPE_UNKNOWN) return NULL;
|
||||
else if (bind->type == E_ACPI_TYPE_AC_ADAPTER)
|
||||
{
|
||||
ret = _("Ac Adapter");
|
||||
if (bind->status == 0) ret = _("AC Adapter Unplugged");
|
||||
else if (bind->status == 1) ret = _("AC Adapter Plugged");
|
||||
ret = _("Ac Adapter");
|
||||
if (bind->status == 0) ret = _("AC Adapter Unplugged");
|
||||
else if (bind->status == 1)
|
||||
ret = _("AC Adapter Plugged");
|
||||
}
|
||||
else if (bind->type == E_ACPI_TYPE_BATTERY) ret = _("Battery");
|
||||
else if (bind->type == E_ACPI_TYPE_BUTTON) ret = _("Button");
|
||||
else if (bind->type == E_ACPI_TYPE_FAN) ret = _("Fan");
|
||||
else if (bind->type == E_ACPI_TYPE_BATTERY)
|
||||
ret = _("Battery");
|
||||
else if (bind->type == E_ACPI_TYPE_BUTTON)
|
||||
ret = _("Button");
|
||||
else if (bind->type == E_ACPI_TYPE_FAN)
|
||||
ret = _("Fan");
|
||||
else if (bind->type == E_ACPI_TYPE_LID)
|
||||
{
|
||||
ret = _("Lid");
|
||||
if (bind->status == 0) ret = _("Lid Closed");
|
||||
else if (bind->status == 1) ret = _("Lid Opened");
|
||||
ret = _("Lid");
|
||||
if (bind->status == 0) ret = _("Lid Closed");
|
||||
else if (bind->status == 1)
|
||||
ret = _("Lid Opened");
|
||||
}
|
||||
else if (bind->type == E_ACPI_TYPE_POWER) ret = _("Power Button");
|
||||
else if (bind->type == E_ACPI_TYPE_PROCESSOR) ret = _("Processor");
|
||||
else if (bind->type == E_ACPI_TYPE_SLEEP) ret = _("Sleep Button");
|
||||
else if (bind->type == E_ACPI_TYPE_THERMAL) ret = _("Thermal");
|
||||
else if (bind->type == E_ACPI_TYPE_VIDEO) ret = _("Video");
|
||||
else if (bind->type == E_ACPI_TYPE_WIFI) ret = _("Wifi");
|
||||
else if (bind->type == E_ACPI_TYPE_POWER)
|
||||
ret = _("Power Button");
|
||||
else if (bind->type == E_ACPI_TYPE_PROCESSOR)
|
||||
ret = _("Processor");
|
||||
else if (bind->type == E_ACPI_TYPE_SLEEP)
|
||||
ret = _("Sleep Button");
|
||||
else if (bind->type == E_ACPI_TYPE_THERMAL)
|
||||
ret = _("Thermal");
|
||||
else if (bind->type == E_ACPI_TYPE_VIDEO)
|
||||
ret = _("Video");
|
||||
else if (bind->type == E_ACPI_TYPE_WIFI)
|
||||
ret = _("Wifi");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -365,10 +392,10 @@ _cb_bindings_changed(void *data)
|
|||
if (!(cfdata = data)) return;
|
||||
if (!(bind = _selected_binding_get(cfdata)))
|
||||
{
|
||||
e_widget_entry_clear(cfdata->o_params);
|
||||
e_widget_disabled_set(cfdata->o_params, EINA_TRUE);
|
||||
e_widget_disabled_set(cfdata->o_del, EINA_TRUE);
|
||||
return;
|
||||
e_widget_entry_clear(cfdata->o_params);
|
||||
e_widget_disabled_set(cfdata->o_params, EINA_TRUE);
|
||||
e_widget_disabled_set(cfdata->o_del, EINA_TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
e_widget_disabled_set(cfdata->o_del, EINA_FALSE);
|
||||
|
@ -376,13 +403,13 @@ _cb_bindings_changed(void *data)
|
|||
|
||||
EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->o_actions), items, item)
|
||||
{
|
||||
const char *val;
|
||||
const char *val;
|
||||
|
||||
i++;
|
||||
if (!(val = e_widget_ilist_item_value_get(item))) continue;
|
||||
if (strcmp(val, bind->action)) continue;
|
||||
e_widget_ilist_selected_set(cfdata->o_actions, i);
|
||||
break;
|
||||
i++;
|
||||
if (!(val = e_widget_ilist_item_value_get(item))) continue;
|
||||
if (strcmp(val, bind->action)) continue;
|
||||
e_widget_ilist_selected_set(cfdata->o_actions, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,16 +423,16 @@ _cb_actions_changed(void *data)
|
|||
if (!(cfdata = data)) return;
|
||||
if (!(bind = _selected_binding_get(cfdata)))
|
||||
{
|
||||
e_widget_entry_clear(cfdata->o_params);
|
||||
e_widget_disabled_set(cfdata->o_params, EINA_TRUE);
|
||||
e_widget_disabled_set(cfdata->o_del, EINA_TRUE);
|
||||
return;
|
||||
e_widget_entry_clear(cfdata->o_params);
|
||||
e_widget_disabled_set(cfdata->o_params, EINA_TRUE);
|
||||
e_widget_disabled_set(cfdata->o_del, EINA_TRUE);
|
||||
return;
|
||||
}
|
||||
if (!(dsc = _selected_action_get(cfdata)))
|
||||
{
|
||||
e_widget_entry_clear(cfdata->o_params);
|
||||
e_widget_disabled_set(cfdata->o_params, EINA_TRUE);
|
||||
return;
|
||||
e_widget_entry_clear(cfdata->o_params);
|
||||
e_widget_disabled_set(cfdata->o_params, EINA_TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
eina_stringshare_replace(&bind->action, dsc->act_cmd);
|
||||
|
@ -417,15 +444,16 @@ _cb_actions_changed(void *data)
|
|||
e_widget_entry_text_set(cfdata->o_params, bind->params);
|
||||
else
|
||||
{
|
||||
if ((!dsc->param_example) || (!dsc->param_example[0]))
|
||||
e_widget_entry_text_set(cfdata->o_params, _("<None>"));
|
||||
else
|
||||
e_widget_entry_text_set(cfdata->o_params, dsc->param_example);
|
||||
if ((!dsc->param_example) || (!dsc->param_example[0]))
|
||||
e_widget_entry_text_set(cfdata->o_params, _("<None>"));
|
||||
else
|
||||
e_widget_entry_text_set(cfdata->o_params, dsc->param_example);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_entry_changed(void *data, void *data2 __UNUSED__)
|
||||
_cb_entry_changed(void *data,
|
||||
void *data2 __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
E_Config_Binding_Acpi *bind;
|
||||
|
@ -436,11 +464,12 @@ _cb_entry_changed(void *data, void *data2 __UNUSED__)
|
|||
if (!dsc->editable) return;
|
||||
if (!(bind = _selected_binding_get(cfdata))) return;
|
||||
eina_stringshare_replace(&bind->params,
|
||||
e_widget_entry_text_get(cfdata->o_params));
|
||||
e_widget_entry_text_get(cfdata->o_params));
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_add_binding(void *data, void *data2 __UNUSED__)
|
||||
_cb_add_binding(void *data,
|
||||
void *data2 __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
E_Manager *man;
|
||||
|
@ -449,13 +478,13 @@ _cb_add_binding(void *data, void *data2 __UNUSED__)
|
|||
if (!(cfdata = data)) return;
|
||||
man = e_manager_current_get();
|
||||
grab_dlg = e_dialog_new(e_container_current_get(man), "E",
|
||||
"_acpibind_getbind_dialog");
|
||||
"_acpibind_getbind_dialog");
|
||||
if (!grab_dlg) return;
|
||||
e_dialog_title_set(grab_dlg, _("ACPI Binding"));
|
||||
e_dialog_icon_set(grab_dlg, "preferences-system-power-management", 48);
|
||||
e_dialog_text_set(grab_dlg,
|
||||
_("Please trigger the ACPI event you wish to bind to, "
|
||||
"<br><br>or <hilight>Escape</hilight> to abort."));
|
||||
_("Please trigger the ACPI event you wish to bind to, "
|
||||
"<br><br>or <hilight>Escape</hilight> to abort."));
|
||||
e_win_centered_set(grab_dlg->win, EINA_TRUE);
|
||||
e_win_borderless_set(grab_dlg->win, EINA_TRUE);
|
||||
|
||||
|
@ -465,51 +494,52 @@ _cb_add_binding(void *data, void *data2 __UNUSED__)
|
|||
|
||||
grab_hdls =
|
||||
eina_list_append(grab_hdls,
|
||||
ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
|
||||
_cb_grab_key_down, cfdata));
|
||||
ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
|
||||
_cb_grab_key_down, cfdata));
|
||||
grab_hdls =
|
||||
eina_list_append(grab_hdls,
|
||||
ecore_event_handler_add(E_EVENT_ACPI_AC_ADAPTER,
|
||||
_cb_acpi_event, cfdata));
|
||||
ecore_event_handler_add(E_EVENT_ACPI_AC_ADAPTER,
|
||||
_cb_acpi_event, cfdata));
|
||||
grab_hdls =
|
||||
eina_list_append(grab_hdls,
|
||||
ecore_event_handler_add(E_EVENT_ACPI_BATTERY,
|
||||
_cb_acpi_event, cfdata));
|
||||
ecore_event_handler_add(E_EVENT_ACPI_BATTERY,
|
||||
_cb_acpi_event, cfdata));
|
||||
grab_hdls =
|
||||
eina_list_append(grab_hdls,
|
||||
ecore_event_handler_add(E_EVENT_ACPI_FAN,
|
||||
_cb_acpi_event, cfdata));
|
||||
ecore_event_handler_add(E_EVENT_ACPI_FAN,
|
||||
_cb_acpi_event, cfdata));
|
||||
grab_hdls =
|
||||
eina_list_append(grab_hdls,
|
||||
ecore_event_handler_add(E_EVENT_ACPI_LID,
|
||||
_cb_acpi_event, cfdata));
|
||||
ecore_event_handler_add(E_EVENT_ACPI_LID,
|
||||
_cb_acpi_event, cfdata));
|
||||
grab_hdls =
|
||||
eina_list_append(grab_hdls,
|
||||
ecore_event_handler_add(E_EVENT_ACPI_POWER,
|
||||
_cb_acpi_event, cfdata));
|
||||
ecore_event_handler_add(E_EVENT_ACPI_POWER,
|
||||
_cb_acpi_event, cfdata));
|
||||
grab_hdls =
|
||||
eina_list_append(grab_hdls,
|
||||
ecore_event_handler_add(E_EVENT_ACPI_SLEEP,
|
||||
_cb_acpi_event, cfdata));
|
||||
ecore_event_handler_add(E_EVENT_ACPI_SLEEP,
|
||||
_cb_acpi_event, cfdata));
|
||||
grab_hdls =
|
||||
eina_list_append(grab_hdls,
|
||||
ecore_event_handler_add(E_EVENT_ACPI_VIDEO,
|
||||
_cb_acpi_event, cfdata));
|
||||
ecore_event_handler_add(E_EVENT_ACPI_VIDEO,
|
||||
_cb_acpi_event, cfdata));
|
||||
grab_hdls =
|
||||
eina_list_append(grab_hdls,
|
||||
ecore_event_handler_add(E_EVENT_ACPI_WIFI,
|
||||
_cb_acpi_event, cfdata));
|
||||
ecore_event_handler_add(E_EVENT_ACPI_WIFI,
|
||||
_cb_acpi_event, cfdata));
|
||||
|
||||
/* freeze all incoming acpi events */
|
||||
e_acpi_events_freeze();
|
||||
|
||||
e_dialog_show(grab_dlg);
|
||||
ecore_x_icccm_transient_for_set(grab_dlg->win->evas_win,
|
||||
cfdata->cfd->dia->win->evas_win);
|
||||
cfdata->cfd->dia->win->evas_win);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_del_binding(void *data, void *data2 __UNUSED__)
|
||||
_cb_del_binding(void *data,
|
||||
void *data2 __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
E_Config_Binding_Acpi *bind, *bind2;
|
||||
|
@ -521,45 +551,45 @@ _cb_del_binding(void *data, void *data2 __UNUSED__)
|
|||
/* delete from e_config */
|
||||
EINA_LIST_FOREACH(e_config->acpi_bindings, l, bind2)
|
||||
{
|
||||
if ((bind->context == bind2->context) && (bind->type == bind2->type) &&
|
||||
(((bind->action) && (bind2->action) &&
|
||||
(!strcmp(bind->action, bind2->action))) ||
|
||||
((!bind->action) && (!bind2->action))) &&
|
||||
(((bind->params) && (bind2->params) &&
|
||||
(!strcmp(bind->params, bind2->params))) ||
|
||||
((!bind->params) && (!bind2->params))))
|
||||
{
|
||||
if (bind2->action) eina_stringshare_del(bind2->action);
|
||||
if (bind2->params) eina_stringshare_del(bind2->params);
|
||||
E_FREE(bind2);
|
||||
e_config->acpi_bindings =
|
||||
eina_list_remove_list(e_config->acpi_bindings, l);
|
||||
e_config_save_queue();
|
||||
break;
|
||||
}
|
||||
if ((bind->context == bind2->context) && (bind->type == bind2->type) &&
|
||||
(((bind->action) && (bind2->action) &&
|
||||
(!strcmp(bind->action, bind2->action))) ||
|
||||
((!bind->action) && (!bind2->action))) &&
|
||||
(((bind->params) && (bind2->params) &&
|
||||
(!strcmp(bind->params, bind2->params))) ||
|
||||
((!bind->params) && (!bind2->params))))
|
||||
{
|
||||
if (bind2->action) eina_stringshare_del(bind2->action);
|
||||
if (bind2->params) eina_stringshare_del(bind2->params);
|
||||
E_FREE(bind2);
|
||||
e_config->acpi_bindings =
|
||||
eina_list_remove_list(e_config->acpi_bindings, l);
|
||||
e_config_save_queue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* delete from e_bindings */
|
||||
e_bindings_acpi_del(bind->context, bind->type, bind->status,
|
||||
bind->action, bind->params);
|
||||
bind->action, bind->params);
|
||||
|
||||
/* delete from dialog list */
|
||||
EINA_LIST_FOREACH(cfdata->bindings, l, bind2)
|
||||
{
|
||||
if ((bind->context == bind2->context) && (bind->type == bind2->type) &&
|
||||
(((bind->action) && (bind2->action) &&
|
||||
(!strcmp(bind->action, bind2->action))) ||
|
||||
((!bind->action) && (!bind2->action))) &&
|
||||
(((bind->params) && (bind2->params) &&
|
||||
(!strcmp(bind->params, bind2->params))) ||
|
||||
((!bind->params) && (!bind2->params))))
|
||||
{
|
||||
if (bind2->action) eina_stringshare_del(bind2->action);
|
||||
if (bind2->params) eina_stringshare_del(bind2->params);
|
||||
E_FREE(bind2);
|
||||
cfdata->bindings = eina_list_remove_list(cfdata->bindings, l);
|
||||
break;
|
||||
}
|
||||
if ((bind->context == bind2->context) && (bind->type == bind2->type) &&
|
||||
(((bind->action) && (bind2->action) &&
|
||||
(!strcmp(bind->action, bind2->action))) ||
|
||||
((!bind->action) && (!bind2->action))) &&
|
||||
(((bind->params) && (bind2->params) &&
|
||||
(!strcmp(bind->params, bind2->params))) ||
|
||||
((!bind->params) && (!bind2->params))))
|
||||
{
|
||||
if (bind2->action) eina_stringshare_del(bind2->action);
|
||||
if (bind2->params) eina_stringshare_del(bind2->params);
|
||||
E_FREE(bind2);
|
||||
cfdata->bindings = eina_list_remove_list(cfdata->bindings, l);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* reset gui */
|
||||
|
@ -571,7 +601,9 @@ _cb_del_binding(void *data, void *data2 __UNUSED__)
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_cb_grab_key_down(void *data, int type __UNUSED__, void *event)
|
||||
_cb_grab_key_down(void *data,
|
||||
int type __UNUSED__,
|
||||
void *event)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Ecore_Event_Key *ev;
|
||||
|
@ -581,27 +613,29 @@ _cb_grab_key_down(void *data, int type __UNUSED__, void *event)
|
|||
if (!(cfdata = data)) return ECORE_CALLBACK_PASS_ON;
|
||||
if (!strcmp(ev->keyname, "Escape"))
|
||||
{
|
||||
Ecore_Event_Handler *hdl;
|
||||
Ecore_Event_Handler *hdl;
|
||||
|
||||
/* free the handlers */
|
||||
EINA_LIST_FREE(grab_hdls, hdl)
|
||||
ecore_event_handler_del(hdl);
|
||||
/* free the handlers */
|
||||
EINA_LIST_FREE(grab_hdls, hdl)
|
||||
ecore_event_handler_del(hdl);
|
||||
|
||||
/* kill the dialog window */
|
||||
e_grabinput_release(grab_win, grab_win);
|
||||
ecore_x_window_free(grab_win);
|
||||
grab_win = 0;
|
||||
e_object_del(E_OBJECT(grab_dlg));
|
||||
grab_dlg = NULL;
|
||||
/* kill the dialog window */
|
||||
e_grabinput_release(grab_win, grab_win);
|
||||
ecore_x_window_free(grab_win);
|
||||
grab_win = 0;
|
||||
e_object_del(E_OBJECT(grab_dlg));
|
||||
grab_dlg = NULL;
|
||||
|
||||
/* unfreeze acpi events */
|
||||
e_acpi_events_thaw();
|
||||
/* unfreeze acpi events */
|
||||
e_acpi_events_thaw();
|
||||
}
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_cb_acpi_event(void *data, __UNUSED__ int type, void *event)
|
||||
_cb_acpi_event(void *data,
|
||||
__UNUSED__ int type,
|
||||
void *event)
|
||||
{
|
||||
E_Event_Acpi *ev;
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
@ -639,3 +673,4 @@ _cb_acpi_event(void *data, __UNUSED__ int type, void *event)
|
|||
_fill_bindings(cfdata);
|
||||
return ECORE_CALLBACK_DONE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue