forked from enlightenment/enlightenment
Bryce/Gadgets: Add backlight, xkbswitch, and mixer gadgets. This should round out the core gadget ports.
All three of these gadgets are ports of the existing modules of the same name and are contained within those directories. Once the move from shelves -> bryce and gadcon->gadgets is complete, backlight and mixer will likely need to go into the sysinfo gadget.
This commit is contained in:
parent
8ea03a039f
commit
20f94cec74
|
@ -12,7 +12,10 @@ backlightpkg_LTLIBRARIES = src/modules/backlight/module.la
|
|||
src_modules_backlight_module_la_LIBADD = $(MOD_LIBS)
|
||||
src_modules_backlight_module_la_CPPFLAGS = $(MOD_CPPFLAGS)
|
||||
src_modules_backlight_module_la_LDFLAGS = $(MOD_LDFLAGS)
|
||||
src_modules_backlight_module_la_SOURCES = src/modules/backlight/e_mod_main.c
|
||||
src_modules_backlight_module_la_SOURCES = src/modules/backlight/e_mod_main.c \
|
||||
src/modules/backlight/gadget/backlight.h \
|
||||
src/modules/backlight/gadget/backlight.c \
|
||||
src/modules/backlight/gadget/mod.c
|
||||
|
||||
PHONIES += backlight install-backlight
|
||||
backlight: $(backlightpkg_LTLIBRARIES) $(backlight_DATA)
|
||||
|
|
|
@ -34,6 +34,9 @@ src_modules_mixer_module_la_SOURCES = src/modules/mixer/e_mod_main.c \
|
|||
src/modules/mixer/e_mod_main.h \
|
||||
src/modules/mixer/e_mod_config.c \
|
||||
src/modules/mixer/e_mod_config.h \
|
||||
src/modules/mixer/gadget/mixer.h \
|
||||
src/modules/mixer/gadget/mixer.c \
|
||||
src/modules/mixer/gadget/mod.c \
|
||||
$(emixerlib)
|
||||
src_modules_mixer_module_la_LIBADD = $(MOD_LIBS) @PULSE_LIBS@ @ALSA_LIBS@
|
||||
|
||||
|
|
|
@ -16,7 +16,10 @@ src_modules_xkbswitch_module_la_SOURCES = src/modules/xkbswitch/e_mod_main.c \
|
|||
src/modules/xkbswitch/e_mod_main.h \
|
||||
src/modules/xkbswitch/e_mod_config.c \
|
||||
src/modules/xkbswitch/e_mod_parse.c \
|
||||
src/modules/xkbswitch/e_mod_parse.h
|
||||
src/modules/xkbswitch/e_mod_parse.h \
|
||||
src/modules/xkbswitch/gadget/xkbswitch.h \
|
||||
src/modules/xkbswitch/gadget/xkbswitch.c \
|
||||
src/modules/xkbswitch/gadget/mod.c
|
||||
|
||||
PHONIES += xkbswitch install-xkbswitch
|
||||
xkbswitch: $(xkbswitchpkg_LTLIBRARIES) $(xkbswitch_DATA)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*/
|
||||
|
||||
#include "e.h"
|
||||
#include "gadget/backlight.h"
|
||||
|
||||
/* gadcon requirements */
|
||||
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
||||
|
@ -469,6 +470,8 @@ E_API E_Module_Api e_modapi =
|
|||
E_API void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
e_modapi_gadget_init(m);
|
||||
|
||||
backlight_module = m;
|
||||
e_gadcon_provider_register(&_gadcon_class);
|
||||
E_LIST_HANDLER_APPEND(handlers, E_EVENT_BACKLIGHT_CHANGE, _backlight_cb_changed, NULL);
|
||||
|
@ -484,8 +487,10 @@ e_modapi_init(E_Module *m)
|
|||
}
|
||||
|
||||
E_API int
|
||||
e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
{
|
||||
e_modapi_gadget_shutdown(m);
|
||||
|
||||
if (act)
|
||||
{
|
||||
e_action_predef_name_del("Screen", "Backlight Controls");
|
||||
|
@ -498,7 +503,9 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
|||
}
|
||||
|
||||
E_API int
|
||||
e_modapi_save(E_Module *m EINA_UNUSED)
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
e_modapi_gadget_save(m);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,300 @@
|
|||
#include "backlight.h"
|
||||
|
||||
typedef struct _Instance Instance;
|
||||
|
||||
struct _Instance
|
||||
{
|
||||
Evas_Object *o_main;
|
||||
Evas_Object *o_backlight, *o_table, *o_slider;
|
||||
Evas_Object *popup, *box;
|
||||
E_Gadget_Site_Orient orient;
|
||||
double val;
|
||||
};
|
||||
|
||||
static Eina_List *ginstances = NULL;
|
||||
static E_Action *act = NULL;
|
||||
static Eina_List *handlers;
|
||||
|
||||
static void
|
||||
_backlight_gadget_update(Instance *inst)
|
||||
{
|
||||
Edje_Message_Float msg;
|
||||
|
||||
msg.val = inst->val;
|
||||
if (msg.val < 0.0) msg.val = 0.0;
|
||||
else if (msg.val > 1.0) msg.val = 1.0;
|
||||
edje_object_message_send(elm_layout_edje_get(inst->o_backlight), EDJE_MESSAGE_FLOAT, 0, &msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_backlight_level_set(Instance *inst, double val, Eina_Bool set_slider)
|
||||
{
|
||||
if (val > 1.0) val = 1.0;
|
||||
if (val < 0.0) val = 0.0;
|
||||
if (set_slider)
|
||||
e_widget_slider_value_double_set(inst->o_slider, val);
|
||||
inst->val = val;
|
||||
e_backlight_mode_set(e_zone_current_get(), E_BACKLIGHT_MODE_NORMAL);
|
||||
e_backlight_level_set(e_zone_current_get(), val, 0.0);
|
||||
e_config->backlight.normal = val;
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
static void
|
||||
_backlight_settings_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
e_gadget_configure(inst->o_main);
|
||||
elm_ctxpopup_dismiss(inst->popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_slider_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
inst->val = elm_slider_value_get(inst->o_slider);
|
||||
_backlight_level_set(inst, inst->val, EINA_FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
_backlight_popup_dismissed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
E_FREE_FUNC(obj, evas_object_del);
|
||||
inst->popup = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_backlight_popup_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
inst->popup = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_backlight_popup_new(Instance *inst)
|
||||
{
|
||||
Evas_Object *ic, *o;
|
||||
|
||||
if (inst->popup) return;
|
||||
|
||||
e_backlight_mode_set(e_zone_current_get(), E_BACKLIGHT_MODE_NORMAL);
|
||||
inst->val = e_backlight_level_get(e_zone_current_get());
|
||||
_backlight_gadget_update(inst);
|
||||
|
||||
inst->popup = elm_ctxpopup_add(e_comp->elm);
|
||||
elm_object_style_set(inst->popup, "noblock");
|
||||
evas_object_smart_callback_add(inst->popup, "dismissed", _backlight_popup_dismissed, inst);
|
||||
evas_object_event_callback_add(inst->popup, EVAS_CALLBACK_DEL, _backlight_popup_deleted, inst);
|
||||
|
||||
inst->box = elm_box_add(e_comp->elm);
|
||||
elm_box_horizontal_set(inst->box, EINA_FALSE);
|
||||
evas_object_size_hint_weight_set(inst->box, 0.0, 1.0);
|
||||
evas_object_size_hint_align_set(inst->box, 0.0, 0.0);
|
||||
elm_object_content_set(inst->popup, inst->box);
|
||||
evas_object_show(inst->box);
|
||||
|
||||
o = elm_slider_add(inst->box);
|
||||
elm_slider_horizontal_set(o, EINA_FALSE);
|
||||
elm_slider_inverted_set(o, EINA_TRUE);
|
||||
elm_slider_unit_format_set(o, NULL);
|
||||
elm_slider_indicator_show_set(o, EINA_FALSE);
|
||||
elm_slider_min_max_set(o, 0.05, 1.0);
|
||||
elm_slider_step_set(o, 0.05);
|
||||
elm_slider_span_size_set(o, 100);
|
||||
elm_slider_value_set(o, inst->val);
|
||||
evas_object_smart_callback_add(o, "changed", _slider_cb, inst);
|
||||
elm_box_pack_end(inst->box, o);
|
||||
evas_object_show(o);
|
||||
inst->o_slider = o;
|
||||
|
||||
ic = elm_icon_add(inst->box);
|
||||
elm_icon_standard_set(ic, "preferences-system");
|
||||
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
||||
evas_object_show(ic);
|
||||
|
||||
o = elm_button_add(inst->box);
|
||||
elm_object_part_content_set(o, "icon", ic);
|
||||
evas_object_smart_callback_add(o, "clicked", _backlight_settings_cb, inst);
|
||||
elm_box_pack_end(inst->box, o);
|
||||
evas_object_show(o);
|
||||
|
||||
e_gadget_util_ctxpopup_place(inst->o_main, inst->popup, inst->o_backlight);
|
||||
evas_object_show(inst->popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_backlight_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
|
||||
{
|
||||
Instance *inst = data;
|
||||
Evas_Event_Mouse_Down *ev = event;
|
||||
|
||||
if (ev->button == 1)
|
||||
{
|
||||
if (inst->popup) elm_ctxpopup_dismiss(inst->popup);
|
||||
else _backlight_popup_new(inst);
|
||||
}
|
||||
else if (ev->button == 3)
|
||||
{
|
||||
e_gadget_configure(inst->o_main);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_backlight_cb_mouse_wheel(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
|
||||
{
|
||||
Evas_Event_Mouse_Wheel *ev = event;
|
||||
Instance *inst = data;
|
||||
|
||||
inst->val = e_backlight_level_get(e_zone_current_get());
|
||||
if (ev->z > 0)
|
||||
_backlight_level_set(inst, inst->val - 0.1, EINA_FALSE);
|
||||
else if (ev->z < 0)
|
||||
_backlight_level_set(inst, inst->val + 0.1, EINA_FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_action_cb(E_Object *obj EINA_UNUSED,
|
||||
const char *params)
|
||||
{
|
||||
Eina_List *l;
|
||||
Instance *inst;
|
||||
|
||||
EINA_LIST_FOREACH(ginstances, l, inst)
|
||||
{
|
||||
if (!params)
|
||||
{
|
||||
if (inst->popup) elm_ctxpopup_dismiss(inst->popup);
|
||||
else _backlight_popup_new(inst);
|
||||
}
|
||||
else
|
||||
{
|
||||
_backlight_level_set(inst, inst->val + atof(params), EINA_FALSE);
|
||||
if (inst->popup) elm_ctxpopup_dismiss(inst->popup);
|
||||
_backlight_popup_new(inst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_backlight_cb_mod_init_end(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
|
||||
{
|
||||
Eina_List *l;
|
||||
Instance *inst;
|
||||
|
||||
EINA_LIST_FOREACH(ginstances, l, inst)
|
||||
{
|
||||
inst->val = e_backlight_level_get(e_zone_current_get());
|
||||
_backlight_gadget_update(inst);
|
||||
}
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_backlight_cb_changed(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
|
||||
{
|
||||
Eina_List *l;
|
||||
Instance *inst;
|
||||
|
||||
EINA_LIST_FOREACH(ginstances, l, inst)
|
||||
{
|
||||
inst->val = e_backlight_level_get(e_zone_current_get());
|
||||
_backlight_gadget_update(inst);
|
||||
}
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_backlight_gadget_configure(Evas_Object *g EINA_UNUSED)
|
||||
{
|
||||
if (e_configure_registry_exists("screen/power_management"))
|
||||
{
|
||||
e_configure_registry_call("screen/power_management", NULL, NULL);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_backlight_gadget_created_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
|
||||
if (inst->o_main)
|
||||
{
|
||||
e_gadget_configure_cb_set(inst->o_main, _backlight_gadget_configure);
|
||||
// _backlight_orient(inst, e_gadget_site_orient_get(obj));
|
||||
|
||||
inst->o_backlight = elm_layout_add(inst->o_main);
|
||||
E_EXPAND(inst->o_backlight);
|
||||
E_FILL(inst->o_backlight);
|
||||
e_theme_edje_object_set(inst->o_backlight,
|
||||
"base/theme/modules/backlight",
|
||||
"e/modules/backlight/main");
|
||||
evas_object_event_callback_add(inst->o_backlight,
|
||||
EVAS_CALLBACK_MOUSE_DOWN,
|
||||
_backlight_cb_mouse_down,
|
||||
inst);
|
||||
evas_object_event_callback_add(inst->o_backlight,
|
||||
EVAS_CALLBACK_MOUSE_WHEEL,
|
||||
_backlight_cb_mouse_wheel,
|
||||
inst);
|
||||
elm_box_pack_end(inst->o_main, inst->o_backlight);
|
||||
evas_object_show(inst->o_backlight);
|
||||
}
|
||||
evas_object_smart_callback_del_full(obj, "gadget_created", _backlight_gadget_created_cb, data);
|
||||
}
|
||||
|
||||
static void
|
||||
backlight_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
|
||||
if (inst->popup)
|
||||
elm_ctxpopup_dismiss(inst->popup);
|
||||
ginstances = eina_list_remove(ginstances, inst);
|
||||
free(inst);
|
||||
}
|
||||
|
||||
EINTERN Evas_Object *
|
||||
backlight_gadget_create(Evas_Object *parent, int *id EINA_UNUSED, E_Gadget_Site_Orient orient)
|
||||
{
|
||||
Instance *inst;
|
||||
|
||||
inst = E_NEW(Instance, 1);
|
||||
inst->o_main = elm_box_add(parent);
|
||||
inst->orient = orient;
|
||||
E_EXPAND(inst->o_main);
|
||||
E_FILL(inst->o_main);
|
||||
evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
||||
evas_object_smart_callback_add(parent, "gadget_created", _backlight_gadget_created_cb, inst);
|
||||
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_DEL, backlight_del, inst);
|
||||
|
||||
ginstances = eina_list_append(ginstances, inst);
|
||||
return inst->o_main;
|
||||
}
|
||||
|
||||
EINTERN void
|
||||
backlight_init(void)
|
||||
{
|
||||
E_LIST_HANDLER_APPEND(handlers, E_EVENT_BACKLIGHT_CHANGE, _backlight_cb_changed, NULL);
|
||||
E_LIST_HANDLER_APPEND(handlers, E_EVENT_MODULE_INIT_END, _backlight_cb_mod_init_end, NULL);
|
||||
act = e_action_add("backlight");
|
||||
if (act)
|
||||
{
|
||||
act->func.go = _e_mod_action_cb;
|
||||
e_action_predef_name_set(N_("Screen"), N_("Backlight Controls"), "backlight",
|
||||
NULL, "syntax: brightness change(-1.0 - 1.0), example: -0.1", 1);
|
||||
}
|
||||
}
|
||||
|
||||
EINTERN void
|
||||
backlight_shutdown(void)
|
||||
{
|
||||
if (act)
|
||||
{
|
||||
e_action_predef_name_del("Screen", "Backlight Controls");
|
||||
e_action_del("backlight");
|
||||
act = NULL;
|
||||
}
|
||||
E_FREE_LIST(handlers, ecore_event_handler_del);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef BACKLIGHT_H
|
||||
#define BACKLIGHT_H
|
||||
|
||||
#include "e.h"
|
||||
|
||||
EINTERN void *e_modapi_gadget_init(E_Module *m EINA_UNUSED);
|
||||
EINTERN int e_modapi_gadget_shutdown(E_Module *m EINA_UNUSED);
|
||||
EINTERN int e_modapi_gadget_save(E_Module *m EINA_UNUSED);
|
||||
|
||||
EINTERN Evas_Object *backlight_gadget_create(Evas_Object *parent, int *id EINA_UNUSED, E_Gadget_Site_Orient orient);
|
||||
EINTERN void backlight_init(void);
|
||||
EINTERN void backlight_shutdown(void);
|
||||
|
||||
extern E_Module *gm;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,27 @@
|
|||
#include "backlight.h"
|
||||
|
||||
E_Module *gm;
|
||||
|
||||
EINTERN void *
|
||||
e_modapi_gadget_init(E_Module *m)
|
||||
{
|
||||
gm = m;
|
||||
backlight_init();
|
||||
e_gadget_type_add("Backlight Gadget", backlight_gadget_create, NULL);
|
||||
return m;
|
||||
}
|
||||
|
||||
EINTERN int
|
||||
e_modapi_gadget_shutdown(E_Module *m EINA_UNUSED)
|
||||
{
|
||||
backlight_shutdown();
|
||||
e_gadget_type_del("Backlight Gadget");
|
||||
return 1;
|
||||
}
|
||||
|
||||
EINTERN int
|
||||
e_modapi_gadget_save(E_Module *m EINA_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
#include "emix.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_mod_config.h"
|
||||
#include "gadget/mixer.h"
|
||||
|
||||
#define VOLUME_STEP 5
|
||||
|
||||
|
@ -1499,6 +1500,8 @@ e_modapi_init(E_Module *m)
|
|||
emix_config_init(_backend_changed, NULL);
|
||||
emix_event_callback_add(_events_cb, NULL);
|
||||
|
||||
e_modapi_gadget_init(m);
|
||||
|
||||
backend = emix_config_backend_get();
|
||||
if (backend && emix_backend_set(backend))
|
||||
backend_loaded = EINA_TRUE;
|
||||
|
@ -1558,7 +1561,7 @@ err:
|
|||
}
|
||||
|
||||
E_API int
|
||||
e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
{
|
||||
E_Client_Volume_Sink *sink;
|
||||
Client_Mixer *cm;
|
||||
|
@ -1585,6 +1588,8 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
|||
EINA_LIST_FREE(_client_sinks, sink)
|
||||
e_client_volume_sink_del(sink);
|
||||
|
||||
e_modapi_gadget_shutdown(m);
|
||||
|
||||
emix_event_callback_del(_events_cb);
|
||||
emix_shutdown();
|
||||
emix_config_shutdown();
|
||||
|
@ -1592,8 +1597,9 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
|||
}
|
||||
|
||||
E_API int
|
||||
e_modapi_save(E_Module *m EINA_UNUSED)
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
e_modapi_gadget_save(m);
|
||||
emix_config_save();
|
||||
return 1;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,31 @@
|
|||
#ifndef MIXER_H
|
||||
#define MIXER_H
|
||||
|
||||
#include "e.h"
|
||||
#include <Eina.h>
|
||||
#include "emix.h"
|
||||
#include "../e_mod_config.h"
|
||||
|
||||
EINTERN void *e_modapi_gadget_init(E_Module *m);
|
||||
EINTERN int e_modapi_gadget_shutdown(E_Module *m);
|
||||
EINTERN int e_modapi_gadget_save(E_Module *m);
|
||||
|
||||
extern int _e_gemix_log_domain;
|
||||
extern E_Module *gm;
|
||||
|
||||
#undef GDBG
|
||||
#undef GINF
|
||||
#undef GWRN
|
||||
#undef GERR
|
||||
#undef GCRIT
|
||||
#define GDBG(...) EINA_LOG_DOM_DBG(_e_gemix_log_domain, __VA_ARGS__)
|
||||
#define GINF(...) EINA_LOG_DOM_INF(_e_gemix_log_domain, __VA_ARGS__)
|
||||
#define GWRN(...) EINA_LOG_DOM_WARN(_e_gemix_log_domain, __VA_ARGS__)
|
||||
#define GERR(...) EINA_LOG_DOM_ERR(_e_gemix_log_domain, __VA_ARGS__)
|
||||
#define GCRIT(...) EINA_LOG_DOM_CRIT(_e_gemix_log_domain, __VA_ARGS__)
|
||||
|
||||
EINTERN Eina_Bool mixer_init(void);
|
||||
EINTERN void mixer_shutdown(void);
|
||||
EINTERN Evas_Object *mixer_gadget_create(Evas_Object *parent, int *id EINA_UNUSED, E_Gadget_Site_Orient orient EINA_UNUSED);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,49 @@
|
|||
#include "mixer.h"
|
||||
|
||||
int _e_gemix_log_domain;
|
||||
E_Module *gm;
|
||||
|
||||
EINTERN void *
|
||||
e_modapi_gadget_init(E_Module *m)
|
||||
{
|
||||
Eina_Bool loaded = EINA_FALSE;
|
||||
|
||||
_e_gemix_log_domain = eina_log_domain_register("mixer_gadget", EINA_COLOR_RED);
|
||||
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(emix_init(), NULL);
|
||||
|
||||
gm = m;
|
||||
|
||||
loaded = mixer_init();
|
||||
if (!loaded)
|
||||
goto err;
|
||||
|
||||
e_gadget_type_add("Mixer Gadget", mixer_gadget_create, NULL);
|
||||
|
||||
return m;
|
||||
err:
|
||||
// emix_config_shutdown();
|
||||
emix_shutdown();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EINTERN int
|
||||
e_modapi_gadget_shutdown(E_Module *m EINA_UNUSED)
|
||||
{
|
||||
mixer_shutdown();
|
||||
|
||||
e_gadget_type_del("Mixer Gadget");
|
||||
|
||||
|
||||
emix_shutdown();
|
||||
// emix_config_shutdown();
|
||||
return 1;
|
||||
}
|
||||
|
||||
EINTERN int
|
||||
e_modapi_gadget_save(E_Module *m EINA_UNUSED)
|
||||
{
|
||||
emix_config_save();
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ E_Module *gmodule;
|
|||
Evas_Object *cfg_dialog;
|
||||
Eina_List *ginstances, *ghandlers;
|
||||
|
||||
E_API void *
|
||||
EINTERN void *
|
||||
e_modapi_gadget_init(E_Module *m)
|
||||
{
|
||||
conf_edd = E_CONFIG_DD_NEW("Pager_Config", Config);
|
||||
|
@ -69,7 +69,7 @@ e_modapi_gadget_init(E_Module *m)
|
|||
return m;
|
||||
}
|
||||
|
||||
E_API int
|
||||
EINTERN int
|
||||
e_modapi_gadget_shutdown(E_Module *m EINA_UNUSED)
|
||||
{
|
||||
if (cfg_dialog)
|
||||
|
@ -96,7 +96,7 @@ e_modapi_gadget_shutdown(E_Module *m EINA_UNUSED)
|
|||
return 1;
|
||||
}
|
||||
|
||||
E_API int
|
||||
EINTERN int
|
||||
e_modapi_gadget_save(E_Module *m EINA_UNUSED)
|
||||
{
|
||||
e_config_domain_save("module.pager", conf_edd, pager_config);
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
#include "e.h"
|
||||
|
||||
E_API void *e_modapi_gadget_init(E_Module *m);
|
||||
E_API int e_modapi_gadget_shutdown(E_Module *m);
|
||||
E_API int e_modapi_gadget_save(E_Module *m);
|
||||
EINTERN void *e_modapi_gadget_init(E_Module *m);
|
||||
EINTERN int e_modapi_gadget_shutdown(E_Module *m);
|
||||
EINTERN int e_modapi_gadget_save(E_Module *m);
|
||||
|
||||
typedef struct _Config Config;
|
||||
struct _Config
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_mod_parse.h"
|
||||
#include "gadget/xkbswitch.h"
|
||||
|
||||
/* GADCON */
|
||||
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
||||
|
@ -76,6 +77,7 @@ e_modapi_init(E_Module *m)
|
|||
_("Keyboard"), NULL,
|
||||
"preferences-desktop-keyboard",
|
||||
_xkb_cfg_dialog);
|
||||
e_modapi_gadget_init(m);
|
||||
|
||||
_xkb.module = m;
|
||||
xkb_change_handle = ecore_event_handler_add(E_EVENT_XKB_CHANGED, _xkb_changed_state, NULL);
|
||||
|
@ -89,11 +91,13 @@ e_modapi_init(E_Module *m)
|
|||
* and frees up the config.
|
||||
*/
|
||||
E_API int
|
||||
e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
{
|
||||
e_configure_registry_item_del("keyboard_and_mouse/xkbswitch");
|
||||
e_configure_registry_category_del("keyboard_and_mouse");
|
||||
|
||||
e_modapi_gadget_shutdown(m);
|
||||
|
||||
if (_xkb.evh) ecore_event_handler_del(_xkb.evh);
|
||||
if (_xkb.cfd) e_object_del(E_OBJECT(_xkb.cfd));
|
||||
_xkb.cfd = NULL;
|
||||
|
@ -108,8 +112,10 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
|||
* Used to save the configuration file.
|
||||
*/
|
||||
E_API int
|
||||
e_modapi_save(E_Module *m EINA_UNUSED)
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
e_modapi_gadget_save(m);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
#include "xkbswitch.h"
|
||||
|
||||
Xkbg _xkbg = { NULL, NULL, NULL };
|
||||
|
||||
EINTERN void *
|
||||
e_modapi_gadget_init(E_Module *m)
|
||||
{
|
||||
_xkbg.module = m;
|
||||
xkbg_init();
|
||||
e_gadget_type_add("Xkbswitch Gadget", xkbg_gadget_create, NULL);
|
||||
return m;
|
||||
}
|
||||
|
||||
EINTERN int
|
||||
e_modapi_gadget_shutdown(E_Module *m EINA_UNUSED)
|
||||
{
|
||||
xkbg_shutdown();
|
||||
_xkbg.module = NULL;
|
||||
e_gadget_type_del("Xkbswitch Gadget");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EINTERN int
|
||||
e_modapi_gadget_save(E_Module *m EINA_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,284 @@
|
|||
#include "xkbswitch.h"
|
||||
|
||||
typedef struct _Instance
|
||||
{
|
||||
Evas_Object *o_main;
|
||||
Evas_Object *o_xkbswitch;
|
||||
Evas_Object *o_xkbflag;
|
||||
Evas_Object *menu;
|
||||
Evas_Object *popup;
|
||||
E_Gadget_Site_Orient orient;
|
||||
E_Config_XKB_Layout *layout;
|
||||
} Instance;
|
||||
|
||||
static Eina_List *ginstances = NULL;
|
||||
static Ecore_Event_Handler *xkbg_change_handle = NULL;
|
||||
|
||||
void
|
||||
_xkbg_update_icon(int cur_group)
|
||||
{
|
||||
Instance *inst;
|
||||
Eina_List *l;
|
||||
E_Config_XKB_Layout *cl;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(e_config->xkb.used_layouts);
|
||||
//INF("ui: %d", cur_group);
|
||||
cl = eina_list_nth(e_config->xkb.used_layouts, cur_group);
|
||||
EINA_SAFETY_ON_NULL_RETURN(cl);
|
||||
if (!e_config_xkb_layout_eq(cl, e_config->xkb.current_layout))
|
||||
{
|
||||
e_config_xkb_layout_free(e_config->xkb.current_layout);
|
||||
e_config->xkb.current_layout = e_config_xkb_layout_dup(cl);
|
||||
}
|
||||
|
||||
if (e_config->xkb.only_label)
|
||||
{
|
||||
EINA_LIST_FOREACH(ginstances, l, inst)
|
||||
{
|
||||
if (!e_config_xkb_layout_eq(e_config->xkb.current_layout, inst->layout))
|
||||
inst->layout = e_config->xkb.current_layout;
|
||||
E_FREE_FUNC(inst->o_xkbflag, evas_object_del);
|
||||
e_theme_edje_object_set(inst->o_xkbswitch,
|
||||
"base/theme/modules/xkbswitch",
|
||||
"e/modules/xkbswitch/noflag");
|
||||
elm_layout_text_set(inst->o_xkbswitch,
|
||||
"e.text.label", cl->name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EINA_LIST_FOREACH(ginstances, l, inst)
|
||||
{
|
||||
if (!e_config_xkb_layout_eq(e_config->xkb.current_layout, inst->layout))
|
||||
inst->layout = e_config->xkb.current_layout;
|
||||
if (!inst->o_xkbflag)
|
||||
inst->o_xkbflag = e_icon_add(evas_object_evas_get(inst->o_xkbswitch));
|
||||
e_theme_edje_object_set(inst->o_xkbswitch,
|
||||
"base/theme/modules/xkbswitch",
|
||||
"e/modules/xkbswitch/main");
|
||||
e_xkb_e_icon_flag_setup(inst->o_xkbflag, cl->name);
|
||||
elm_layout_content_set(inst->o_xkbswitch, "e.swallow.flag",
|
||||
inst->o_xkbflag);
|
||||
elm_layout_text_set(inst->o_xkbswitch, "e.text.label",
|
||||
e_xkb_layout_name_reduce(cl->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_xkbg_changed_state(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
_xkbg_update_icon(e_config->xkb.cur_group);
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_xkbg_gadget_configure(Evas_Object *g EINA_UNUSED)
|
||||
{
|
||||
if (e_configure_registry_exists("keyboard_and_mouse/xkbswitch"))
|
||||
{
|
||||
e_configure_registry_call("keyboard_and_mouse/xkbswitch", NULL, NULL);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_xkbg_cb_menu_set(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = evas_object_data_get(obj, "inst");
|
||||
Eina_List *l;
|
||||
int cur_group = -1, grp = -1;
|
||||
E_Config_XKB_Layout *cl2, *cl = data;
|
||||
|
||||
if (inst->popup)
|
||||
elm_ctxpopup_dismiss(inst->popup);
|
||||
|
||||
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl2)
|
||||
{
|
||||
grp++;
|
||||
if (cl2 == cl) cur_group = grp;
|
||||
}
|
||||
if (cur_group == -1) return;
|
||||
if (e_config_xkb_layout_eq(cl, e_xkb_layout_get())) return;
|
||||
e_xkb_layout_set(cl);
|
||||
e_config_xkb_layout_free(e_config->xkb.sel_layout);
|
||||
e_config->xkb.sel_layout = e_config_xkb_layout_dup(cl);
|
||||
}
|
||||
|
||||
static void
|
||||
_xkbg_popup_dismissed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
E_FREE_FUNC(obj, evas_object_del);
|
||||
inst->popup = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_xkbg_popup_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
inst->popup = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_xkbg_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
|
||||
{
|
||||
Evas_Event_Mouse_Down *ev = event;
|
||||
Instance *inst = data;
|
||||
|
||||
if (!inst) return;
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||
if (ev->button == 3)
|
||||
{
|
||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||
e_gadget_configure(inst->o_main);
|
||||
}
|
||||
else if ((ev->button == 1) && (inst->popup))
|
||||
{
|
||||
elm_ctxpopup_dismiss(inst->popup);
|
||||
return;
|
||||
}
|
||||
else if ((ev->button == 1) && (!inst->popup)) /* Left-click layout menu */
|
||||
{
|
||||
if (!e_config->xkb.dont_touch_my_damn_keyboard)
|
||||
{
|
||||
E_Config_XKB_Layout *cl, *cur;
|
||||
Eina_List *l;
|
||||
Elm_Object_Item *mi;
|
||||
char buf[4096], buf2[4096];
|
||||
|
||||
cur = e_xkb_layout_get();
|
||||
|
||||
inst->popup = elm_ctxpopup_add(e_comp->elm);
|
||||
elm_object_style_set(inst->popup, "noblock");
|
||||
evas_object_smart_callback_add(inst->popup, "dismissed", _xkbg_popup_dismissed, inst);
|
||||
evas_object_event_callback_add(inst->popup, EVAS_CALLBACK_DEL, _xkbg_popup_deleted, inst);
|
||||
|
||||
inst->menu = elm_list_add(inst->popup);
|
||||
elm_list_select_mode_set(inst->menu, ELM_OBJECT_SELECT_MODE_ALWAYS);
|
||||
evas_object_data_set(inst->menu, "inst", inst);
|
||||
elm_object_content_set(inst->popup, inst->menu);
|
||||
E_EXPAND(inst->menu);
|
||||
E_FILL(inst->menu);
|
||||
|
||||
/* Append all the layouts */
|
||||
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
|
||||
{
|
||||
const char *name = cl->name;
|
||||
Evas_Object *ic;
|
||||
|
||||
e_xkb_flag_file_get(buf, sizeof(buf), name);
|
||||
if (cl->variant)
|
||||
snprintf(buf2, sizeof(buf2), "%s (%s, %s)", cl->name, cl->model, cl->variant);
|
||||
else
|
||||
snprintf(buf2, sizeof(buf2), "%s (%s)", cl->name, cl->model);
|
||||
|
||||
ic = elm_icon_add(inst->menu);
|
||||
elm_image_file_set(ic, buf, NULL);
|
||||
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
||||
evas_object_show(ic);
|
||||
|
||||
mi = elm_list_item_append(inst->menu, buf2, ic, NULL, _xkbg_cb_menu_set, cl);
|
||||
|
||||
if (e_config_xkb_layout_eq(cur, cl))
|
||||
elm_list_item_selected_set(mi, EINA_TRUE);
|
||||
}
|
||||
|
||||
evas_object_show(inst->menu);
|
||||
evas_object_size_hint_min_set(inst->popup, 200 * e_scale, 100 * e_scale);
|
||||
e_gadget_util_ctxpopup_place(inst->o_main, inst->popup, inst->o_xkbswitch);
|
||||
evas_object_show(inst->popup);
|
||||
}
|
||||
}
|
||||
else if (ev->button == 2)
|
||||
e_xkb_layout_next();
|
||||
}
|
||||
|
||||
static void
|
||||
_xkbg_gadget_created_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
|
||||
if (inst->o_main)
|
||||
{
|
||||
e_gadget_configure_cb_set(inst->o_main, _xkbg_gadget_configure);
|
||||
// _xkbdswitch_orient(inst, e_gadget_site_orient_get(obj));
|
||||
|
||||
inst->o_xkbswitch = elm_layout_add(inst->o_main);
|
||||
E_EXPAND(inst->o_xkbswitch);
|
||||
E_FILL(inst->o_xkbswitch);
|
||||
|
||||
inst->layout = e_xkb_layout_get();
|
||||
if (e_config->xkb.only_label || (!inst->layout))
|
||||
e_theme_edje_object_set(inst->o_xkbswitch,
|
||||
"base/theme/modules/xkbswitch",
|
||||
"e/modules/xkbswitch/noflag");
|
||||
else
|
||||
e_theme_edje_object_set(inst->o_xkbswitch,
|
||||
"base/theme/modules/xkbswitch",
|
||||
"e/modules/xkbswitch/main");
|
||||
elm_layout_text_set(inst->o_xkbswitch, "e.text.label",
|
||||
inst->layout ? e_xkb_layout_name_reduce(inst->layout->name) : _("NONE"));
|
||||
if (inst->layout && (!e_config->xkb.only_label))
|
||||
{
|
||||
inst->o_xkbflag = e_icon_add(evas_object_evas_get(inst->o_xkbswitch));
|
||||
E_EXPAND(inst->o_xkbflag);
|
||||
E_FILL(inst->o_xkbflag);
|
||||
e_xkb_e_icon_flag_setup(inst->o_xkbflag, inst->layout->name);
|
||||
/* The icon is part of the gadget. */
|
||||
elm_layout_content_set(inst->o_xkbswitch, "e.swallow.flag",
|
||||
inst->o_xkbflag);
|
||||
}
|
||||
else inst->o_xkbflag = NULL;
|
||||
evas_object_event_callback_add(inst->o_xkbswitch, EVAS_CALLBACK_MOUSE_DOWN,
|
||||
_xkbg_cb_mouse_down, inst);
|
||||
elm_box_pack_end(inst->o_main, inst->o_xkbswitch);
|
||||
evas_object_show(inst->o_xkbswitch);
|
||||
}
|
||||
evas_object_smart_callback_del_full(obj, "gadget_created", _xkbg_gadget_created_cb, data);
|
||||
}
|
||||
|
||||
static void
|
||||
xkbg_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Instance *inst = data;
|
||||
|
||||
if (inst->popup)
|
||||
elm_ctxpopup_dismiss(inst->popup);
|
||||
ginstances = eina_list_remove(ginstances, inst);
|
||||
free(inst);
|
||||
}
|
||||
|
||||
EINTERN Evas_Object *
|
||||
xkbg_gadget_create(Evas_Object *parent, int *id EINA_UNUSED, E_Gadget_Site_Orient orient)
|
||||
{
|
||||
Instance *inst;
|
||||
|
||||
inst = E_NEW(Instance, 1);
|
||||
inst->o_main = elm_box_add(parent);
|
||||
inst->orient = orient;
|
||||
E_EXPAND(inst->o_main);
|
||||
E_FILL(inst->o_main);
|
||||
evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
|
||||
evas_object_smart_callback_add(parent, "gadget_created", _xkbg_gadget_created_cb, inst);
|
||||
evas_object_event_callback_add(inst->o_main, EVAS_CALLBACK_DEL, xkbg_del, inst);
|
||||
|
||||
ginstances = eina_list_append(ginstances, inst);
|
||||
return inst->o_main;
|
||||
}
|
||||
|
||||
EINTERN void
|
||||
xkbg_init(void)
|
||||
{
|
||||
xkbg_change_handle = ecore_event_handler_add(E_EVENT_XKB_CHANGED, _xkbg_changed_state, NULL);
|
||||
}
|
||||
|
||||
EINTERN void
|
||||
xkbg_shutdown(void)
|
||||
{
|
||||
if (_xkbg.evh) ecore_event_handler_del(_xkbg.evh);
|
||||
if (_xkbg.cfd) e_object_del(E_OBJECT(_xkbg.cfd));
|
||||
_xkbg.cfd = NULL;
|
||||
ecore_event_handler_del(xkbg_change_handle);
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef XKBSWITCH_H
|
||||
#define XKBSWITCH_H
|
||||
|
||||
#include "e.h"
|
||||
|
||||
typedef struct _Xkbg
|
||||
{
|
||||
E_Module *module;
|
||||
E_Config_Dialog *cfd;
|
||||
Ecore_Event_Handler *evh;
|
||||
} Xkbg;
|
||||
|
||||
void _xkbg_update_icon(int);
|
||||
E_Config_Dialog *_xkbg_cfg_dialog(Evas_Object *, const char *params);
|
||||
|
||||
extern Xkbg _xkbg;
|
||||
|
||||
EINTERN void *e_modapi_gadget_init(E_Module *m);
|
||||
EINTERN int e_modapi_gadget_shutdown(E_Module *m EINA_UNUSED);
|
||||
EINTERN int e_modapi_gadget_save(E_Module *m EINA_UNUSED);
|
||||
EINTERN Evas_Object *xkbg_gadget_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient);
|
||||
EINTERN void xkbg_init(void);
|
||||
EINTERN void xkbg_shutdown(void);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue