New illume2 code for dual-head/xinerma.
SVN revision: 45068
|
@ -0,0 +1,33 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MODULE = illume-home
|
||||
|
||||
# data files for the module
|
||||
filesdir = $(libdir)/enlightenment/modules/$(MODULE)
|
||||
files_DATA = \
|
||||
e-module-$(MODULE).edj module.desktop
|
||||
|
||||
EXTRA_DIST = $(files_DATA)
|
||||
|
||||
# the module .so file
|
||||
INCLUDES = -I. \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/modules/$(MODULE) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/modules \
|
||||
@e_cflags@
|
||||
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
|
||||
pkg_LTLIBRARIES = module.la
|
||||
module_la_SOURCES = e_mod_main.c \
|
||||
e_mod_main.h \
|
||||
e_busycover.c \
|
||||
e_busycover.h \
|
||||
e_mod_config.c \
|
||||
e_mod_config.h
|
||||
|
||||
module_la_LIBADD = @e_libs@ @dlopen_libs@
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
module_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
||||
uninstall:
|
||||
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)
|
|
@ -0,0 +1,172 @@
|
|||
#include "e.h"
|
||||
#include "e_busycover.h"
|
||||
|
||||
/* local function prototypes */
|
||||
static void _e_busycover_cb_free(E_Busycover *esw);
|
||||
static void _e_busycover_win_cb_resize(E_Win *win);
|
||||
static int _e_busycover_zone_cb_move_resize(void *data, int type, void *event);
|
||||
static Evas_Object *_theme_obj_new(Evas *evas, const char *custom_dir, const char *group);
|
||||
|
||||
/* local variables */
|
||||
static Eina_List *busycovers = NULL;
|
||||
|
||||
/* public functions */
|
||||
EAPI int
|
||||
e_busycover_init(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_busycover_shutdown(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI E_Busycover *
|
||||
e_busycover_new(E_Zone *zone, const char *themedir)
|
||||
{
|
||||
E_Busycover *esw;
|
||||
Ecore_X_Window_State states[2];
|
||||
|
||||
esw = E_OBJECT_ALLOC(E_Busycover, E_BUSYCOVER_TYPE, _e_busycover_cb_free);
|
||||
if (!esw) return NULL;
|
||||
|
||||
esw->zone = zone;
|
||||
if (themedir) esw->themedir = eina_stringshare_add(themedir);
|
||||
|
||||
esw->win = e_win_new(zone->container);
|
||||
esw->win->data = esw;
|
||||
states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
|
||||
states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
|
||||
e_win_title_set(esw->win, _("Illume Busycover"));
|
||||
e_win_name_class_set(esw->win, "Illume-Busycover", "Illume-Busycover");
|
||||
e_win_resize_callback_set(esw->win, _e_busycover_win_cb_resize);
|
||||
ecore_x_icccm_hints_set(esw->win->evas_win, 0, 0, 0, 0, 0, 0, 0);
|
||||
ecore_x_netwm_window_state_set(esw->win->evas_win, states, 2);
|
||||
ecore_x_netwm_window_type_set(esw->win->evas_win, ECORE_X_WINDOW_TYPE_SPLASH);
|
||||
|
||||
esw->o_base = _theme_obj_new(e_win_evas_get(esw->win), esw->themedir,
|
||||
"modules/illume-home/busycover/default");
|
||||
evas_object_move(esw->o_base, 0, 0);
|
||||
evas_object_show(esw->o_base);
|
||||
edje_object_part_text_set(esw->o_base, "e.text.title", "LOADING");
|
||||
|
||||
ecore_evas_alpha_set(esw->win->ecore_evas, 1);
|
||||
|
||||
busycovers = eina_list_append(busycovers, esw);
|
||||
|
||||
esw->handlers =
|
||||
eina_list_append(esw->handlers,
|
||||
ecore_event_handler_add(E_EVENT_ZONE_MOVE_RESIZE,
|
||||
_e_busycover_zone_cb_move_resize,
|
||||
esw));
|
||||
return esw;
|
||||
}
|
||||
|
||||
EAPI E_Busycover_Handle *
|
||||
e_busycover_push(E_Busycover *esw, const char *msg, const char *icon)
|
||||
{
|
||||
E_Busycover_Handle *h;
|
||||
|
||||
E_OBJECT_CHECK(esw);
|
||||
E_OBJECT_TYPE_CHECK_RETURN(esw, E_BUSYCOVER_TYPE, NULL);
|
||||
h = E_NEW(E_Busycover_Handle, 1);
|
||||
h->busycover = esw;
|
||||
if (msg) h->msg = eina_stringshare_add(msg);
|
||||
if (icon) h->icon = eina_stringshare_add(icon);
|
||||
esw->handles = eina_list_prepend(esw->handles, h);
|
||||
edje_object_part_text_set(esw->o_base, "e.text.label", h->msg);
|
||||
/* FIXME: handle icon */
|
||||
|
||||
e_win_layer_set(esw->win, 9999);
|
||||
e_win_show(esw->win);
|
||||
e_border_zone_set(esw->win->border, esw->zone);
|
||||
|
||||
// evas_object_show(esw->o_base);
|
||||
// evas_object_raise(esw->o_base);
|
||||
return h;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_busycover_pop(E_Busycover *esw, E_Busycover_Handle *handle)
|
||||
{
|
||||
E_OBJECT_CHECK(esw);
|
||||
E_OBJECT_TYPE_CHECK(esw, E_BUSYCOVER_TYPE);
|
||||
if (!eina_list_data_find(esw->handles, handle)) return;
|
||||
esw->handles = eina_list_remove(esw->handles, handle);
|
||||
if (handle->msg) eina_stringshare_del(handle->msg);
|
||||
if (handle->icon) eina_stringshare_del(handle->icon);
|
||||
E_FREE(handle);
|
||||
if (esw->handles)
|
||||
{
|
||||
handle = esw->handles->data;
|
||||
edje_object_part_text_set(esw->o_base, "e.text.label", handle->msg);
|
||||
}
|
||||
else
|
||||
e_object_del(E_OBJECT(esw));
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static void
|
||||
_e_busycover_cb_free(E_Busycover *esw)
|
||||
{
|
||||
Ecore_Event_Handler *handle;
|
||||
|
||||
if (esw->o_base) evas_object_del(esw->o_base);
|
||||
e_object_del(E_OBJECT(esw->win));
|
||||
esw->win = NULL;
|
||||
busycovers = eina_list_remove(busycovers, esw);
|
||||
EINA_LIST_FREE(esw->handlers, handle)
|
||||
ecore_event_handler_del(handle);
|
||||
if (esw->themedir) eina_stringshare_del(esw->themedir);
|
||||
E_FREE(esw);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_busycover_win_cb_resize(E_Win *win)
|
||||
{
|
||||
E_Busycover *esw;
|
||||
|
||||
if (!(esw = win->data)) return;
|
||||
evas_object_resize(esw->o_base, win->w, win->h);
|
||||
}
|
||||
|
||||
static int
|
||||
_e_busycover_zone_cb_move_resize(void *data, int type, void *event)
|
||||
{
|
||||
E_Event_Zone_Move_Resize *ev;
|
||||
E_Busycover *esw;
|
||||
|
||||
ev = event;
|
||||
esw = data;
|
||||
if (esw->zone == ev->zone)
|
||||
{
|
||||
int x, y, w, h;
|
||||
|
||||
e_zone_useful_geometry_get(esw->zone, &x, &y, &w, &h);
|
||||
e_win_move_resize(esw->win, x, y, w, h);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_theme_obj_new(Evas *evas, const char *custom_dir, const char *group)
|
||||
{
|
||||
Evas_Object *o;
|
||||
|
||||
o = edje_object_add(evas);
|
||||
if (!e_theme_edje_object_set(o, "base/theme/modules/illume-home", group))
|
||||
{
|
||||
if (custom_dir)
|
||||
{
|
||||
char buff[PATH_MAX];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-home.edj",
|
||||
custom_dir);
|
||||
edje_object_file_set(o, buff, group);
|
||||
}
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef E_BUSYCOVER_H
|
||||
#define E_BUSYCOVER_H
|
||||
|
||||
#define E_BUSYCOVER_TYPE 0xE1b0782
|
||||
|
||||
typedef struct _E_Busycover E_Busycover;
|
||||
typedef struct _E_Busycover_Handle E_Busycover_Handle;
|
||||
|
||||
struct _E_Busycover
|
||||
{
|
||||
E_Object e_obj_inherit;
|
||||
E_Zone *zone;
|
||||
E_Win *win;
|
||||
Evas_Object *o_base;
|
||||
Eina_List *handlers, *handles;
|
||||
const char *themedir;
|
||||
};
|
||||
|
||||
struct _E_Busycover_Handle
|
||||
{
|
||||
E_Busycover *busycover;
|
||||
const char *msg, *icon;
|
||||
};
|
||||
|
||||
EAPI int e_busycover_init(void);
|
||||
EAPI int e_busycover_shutdown(void);
|
||||
EAPI E_Busycover *e_busycover_new(E_Zone *zone, const char *themedir);
|
||||
EAPI E_Busycover_Handle *e_busycover_push(E_Busycover *esw, const char *msg, const char *icon);
|
||||
EAPI void e_busycover_pop(E_Busycover *esw, E_Busycover_Handle *handle);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,200 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_mod_config.h"
|
||||
|
||||
/* local function prototypes */
|
||||
static void *_il_home_config_create(E_Config_Dialog *cfd);
|
||||
static void _il_home_config_free(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_il_home_config_ui(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static void _il_home_config_changed(void *data, Evas_Object *obj, void *event);
|
||||
static void _il_home_config_click_changed(void *data, Evas_Object *obj, void *event);
|
||||
static int _il_home_config_change_timeout(void *data);
|
||||
|
||||
/* local variables */
|
||||
EAPI Il_Home_Config *il_home_cfg = NULL;
|
||||
static E_Config_DD *conf_edd = NULL;
|
||||
Ecore_Timer *_il_home_config_change_timer = NULL;
|
||||
Evas_Object *delay_label, *delay_slider;
|
||||
|
||||
/* public functions */
|
||||
int
|
||||
il_home_config_init(E_Module *m)
|
||||
{
|
||||
conf_edd = E_CONFIG_DD_NEW("Illume-Home_Cfg", Il_Home_Config);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Il_Home_Config
|
||||
#define D conf_edd
|
||||
E_CONFIG_VAL(D, T, version, INT);
|
||||
E_CONFIG_VAL(D, T, icon_size, INT);
|
||||
E_CONFIG_VAL(D, T, single_click, INT);
|
||||
E_CONFIG_VAL(D, T, single_click_delay, INT);
|
||||
|
||||
il_home_cfg = e_config_domain_load("module.illume-home", conf_edd);
|
||||
if ((il_home_cfg) &&
|
||||
((il_home_cfg->version >> 16) < IL_CONFIG_MAJ))
|
||||
{
|
||||
E_FREE(il_home_cfg);
|
||||
il_home_cfg = NULL;
|
||||
}
|
||||
if (!il_home_cfg)
|
||||
{
|
||||
il_home_cfg = E_NEW(Il_Home_Config, 1);
|
||||
il_home_cfg->version = 0;
|
||||
il_home_cfg->icon_size = 120;
|
||||
il_home_cfg->single_click = 1;
|
||||
il_home_cfg->single_click_delay = 50;
|
||||
}
|
||||
if (il_home_cfg)
|
||||
{
|
||||
/* Add new config variables here */
|
||||
/* if ((il_home_cfg->version & 0xffff) < 1) */
|
||||
il_home_cfg->version = (IL_CONFIG_MAJ << 16) | IL_CONFIG_MIN;
|
||||
}
|
||||
|
||||
il_home_cfg->mod_dir = eina_stringshare_add(m->dir);
|
||||
|
||||
e_configure_registry_category_add("illume", 0, _("Illume"), NULL,
|
||||
"enlightenment/display");
|
||||
e_configure_registry_generic_item_add("illume/home", 0, _("Home"),
|
||||
NULL, "enlightenment/launcher",
|
||||
il_home_config_show);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
il_home_config_shutdown(void)
|
||||
{
|
||||
il_home_cfg->cfd = NULL;
|
||||
|
||||
e_configure_registry_item_del("illume/home");
|
||||
e_configure_registry_category_del("illume");
|
||||
|
||||
if (il_home_cfg->mod_dir) eina_stringshare_del(il_home_cfg->mod_dir);
|
||||
|
||||
E_FREE(il_home_cfg);
|
||||
il_home_cfg = NULL;
|
||||
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
il_home_config_save(void)
|
||||
{
|
||||
e_config_domain_save("module.illume-home", conf_edd, il_home_cfg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
il_home_config_show(E_Container *con, const char *params)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v = NULL;
|
||||
|
||||
if (e_config_dialog_find("E", "_config_illume_home_settings")) return;
|
||||
|
||||
v = E_NEW(E_Config_Dialog_View, 1);
|
||||
v->create_cfdata = _il_home_config_create;
|
||||
v->free_cfdata = _il_home_config_free;
|
||||
v->basic.create_widgets = _il_home_config_ui;
|
||||
v->basic_only = 1;
|
||||
v->normal_win = 1;
|
||||
v->scroll = 1;
|
||||
|
||||
cfd = e_config_dialog_new(con, _("Home Settings"), "E",
|
||||
"_config_illume_home_settings",
|
||||
"enlightenment/launcher_settings", 0, v, NULL);
|
||||
e_dialog_resizable_set(cfd->dia, 1);
|
||||
il_home_cfg->cfd = cfd;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static void *
|
||||
_il_home_config_create(E_Config_Dialog *cfd)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_config_free(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
il_home_cfg->cfd = NULL;
|
||||
il_home_win_cfg_update();
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_il_home_config_ui(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *list, *of, *o;
|
||||
E_Radio_Group *rg;
|
||||
|
||||
list = e_widget_list_add(evas, 0, 0);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Icon Size"), 0);
|
||||
rg = e_widget_radio_group_new(&(il_home_cfg->icon_size));
|
||||
o = e_widget_radio_add(evas, _("Small"), 60, rg);
|
||||
e_widget_framelist_object_append(of, o);
|
||||
evas_object_smart_callback_add(o, "changed", _il_home_config_changed, NULL);
|
||||
o = e_widget_radio_add(evas, _("Medium"), 80, rg);
|
||||
e_widget_framelist_object_append(of, o);
|
||||
evas_object_smart_callback_add(o, "changed", _il_home_config_changed, NULL);
|
||||
o = e_widget_radio_add(evas, _("Large"), 120, rg);
|
||||
e_widget_framelist_object_append(of, o);
|
||||
evas_object_smart_callback_add(o, "changed", _il_home_config_changed, NULL);
|
||||
o = e_widget_radio_add(evas, _("Very Large"), 160, rg);
|
||||
e_widget_framelist_object_append(of, o);
|
||||
evas_object_smart_callback_add(o, "changed", _il_home_config_changed, NULL);
|
||||
o = e_widget_radio_add(evas, _("Massive"), 240, rg);
|
||||
e_widget_framelist_object_append(of, o);
|
||||
evas_object_smart_callback_add(o, "changed", _il_home_config_changed, NULL);
|
||||
e_widget_list_object_append(list, of, 1, 0, 0.0);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Launch Action"), 0);
|
||||
o = e_widget_check_add(evas, _("Single press"),
|
||||
&(il_home_cfg->single_click));
|
||||
e_widget_framelist_object_append(of, o);
|
||||
evas_object_smart_callback_add(o, "changed",
|
||||
_il_home_config_click_changed, NULL);
|
||||
o = e_widget_label_add(evas, _("Press Delay"));
|
||||
delay_label = o;
|
||||
e_widget_disabled_set(o, !(il_home_cfg->single_click));
|
||||
e_widget_framelist_object_append(of, o);
|
||||
o = e_widget_slider_add(evas, 1, 0, "%1.0f ms", 0, 350, 1, 0, NULL,
|
||||
&(il_home_cfg->single_click_delay), 150);
|
||||
delay_slider = o;
|
||||
/* Slider does not emit a changed signal */
|
||||
// evas_object_smart_callback_add(o, "changed",
|
||||
// _il_home_config_changed, NULL);
|
||||
e_widget_disabled_set(o, !(il_home_cfg->single_click));
|
||||
e_widget_framelist_object_append(of, o);
|
||||
e_widget_list_object_append(list, of, 1, 0, 0.0);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_config_changed(void *data, Evas_Object *obj, void *event)
|
||||
{
|
||||
if (_il_home_config_change_timer)
|
||||
ecore_timer_del(_il_home_config_change_timer);
|
||||
_il_home_config_change_timer =
|
||||
ecore_timer_add(0.5, _il_home_config_change_timeout, data);
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_config_click_changed(void *data, Evas_Object *obj, void *event)
|
||||
{
|
||||
e_widget_disabled_set(delay_label, !il_home_cfg->single_click);
|
||||
e_widget_disabled_set(delay_slider, !il_home_cfg->single_click);
|
||||
_il_home_config_changed(data, obj, event);
|
||||
}
|
||||
|
||||
static int
|
||||
_il_home_config_change_timeout(void *data)
|
||||
{
|
||||
il_home_win_cfg_update();
|
||||
e_config_save_queue();
|
||||
_il_home_config_change_timer = NULL;
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef E_MOD_CONFIG_H
|
||||
#define E_MOD_CONFIG_H
|
||||
|
||||
#define IL_CONFIG_MIN 0
|
||||
#define IL_CONFIG_MAJ 0
|
||||
|
||||
typedef struct _Il_Home_Config Il_Home_Config;
|
||||
|
||||
struct _Il_Home_Config
|
||||
{
|
||||
int version;
|
||||
int mode, icon_size;
|
||||
int single_click, single_click_delay;
|
||||
|
||||
// Not User Configurable. Placeholders
|
||||
const char *mod_dir;
|
||||
E_Config_Dialog *cfd;
|
||||
};
|
||||
|
||||
int il_home_config_init(E_Module *m);
|
||||
int il_home_config_shutdown(void);
|
||||
int il_home_config_save(void);
|
||||
void il_home_config_show(E_Container *con, const char *params);
|
||||
|
||||
extern EAPI Il_Home_Config *il_home_cfg;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,836 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_mod_config.h"
|
||||
#include "e_busycover.h"
|
||||
|
||||
#define IL_HOME_WIN_TYPE 0xE0b0102f
|
||||
|
||||
/* local structures */
|
||||
typedef struct _Instance Instance;
|
||||
typedef struct _Il_Home_Win Il_Home_Win;
|
||||
typedef struct _Il_Home_Exec Il_Home_Exec;
|
||||
|
||||
struct _Instance
|
||||
{
|
||||
E_Gadcon_Client *gcc;
|
||||
Evas_Object *o_btn;
|
||||
Eina_List *wins;
|
||||
Ecore_Event_Handler *hdl;
|
||||
};
|
||||
struct _Il_Home_Win
|
||||
{
|
||||
E_Object e_obj_inherit;
|
||||
|
||||
E_Win *win;
|
||||
Evas_Object *o_bg, *o_sf, *o_fm;
|
||||
E_Busycover *cover;
|
||||
};
|
||||
struct _Il_Home_Exec
|
||||
{
|
||||
Efreet_Desktop *desktop;
|
||||
Ecore_Exe *exec;
|
||||
E_Border *border;
|
||||
Ecore_Timer *timeout;
|
||||
E_Busycover *cover;
|
||||
int startup_id;
|
||||
pid_t pid;
|
||||
void *handle;
|
||||
};
|
||||
|
||||
/* local function prototypes */
|
||||
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
||||
static void _gc_shutdown(E_Gadcon_Client *gcc);
|
||||
static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
|
||||
static char *_gc_label(E_Gadcon_Client_Class *cc);
|
||||
static Evas_Object *_gc_icon(E_Gadcon_Client_Class *cc, Evas *evas);
|
||||
static const char *_gc_id_new(E_Gadcon_Client_Class *cc);
|
||||
static void _il_home_btn_cb_click(void *data, void *data2);
|
||||
static void _il_home_win_new(Instance *inst);
|
||||
static void _il_home_win_cb_free(Il_Home_Win *hwin);
|
||||
static void _il_home_win_cb_resize(E_Win *win);
|
||||
static void _il_home_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
||||
static void _il_home_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
|
||||
static void _il_home_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
|
||||
static void _il_home_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h);
|
||||
static void _il_home_cb_selected(void *data, Evas_Object *obj, void *event);
|
||||
static void _il_home_desktop_run(Il_Home_Win *hwin, Efreet_Desktop *desktop);
|
||||
static void _il_home_apps_populate(void);
|
||||
static void _il_home_apps_unpopulate(void);
|
||||
static void _il_home_fmc_set(Evas_Object *obj);
|
||||
static void _il_home_desks_populate(void);
|
||||
static int _il_home_desktop_list_change(void *data, int type, void *event);
|
||||
static int _il_home_desktop_change(void *data, int type, void *event);
|
||||
static int _il_home_update_deferred(void *data);
|
||||
static int _il_home_win_cb_exe_del(void *data, int type, void *event);
|
||||
static E_Border *_il_home_desktop_find_border(E_Zone *zone, Efreet_Desktop *desktop);
|
||||
static int _il_home_win_cb_timeout(void *data);
|
||||
static int _il_home_border_add(void *data, int type, void *event);
|
||||
static int _il_home_border_remove(void *data, int type, void *event);
|
||||
static int _il_home_cb_client_message(void *data, int type, void *event);
|
||||
|
||||
/* local variables */
|
||||
static Eina_List *instances = NULL;
|
||||
static Eina_List *desks = NULL;
|
||||
static Eina_List *sels = NULL;
|
||||
static Eina_List *handlers = NULL;
|
||||
static Eina_List *exes = NULL;
|
||||
static Ecore_Timer *defer = NULL;
|
||||
|
||||
static const E_Gadcon_Client_Class _gc_class =
|
||||
{
|
||||
GADCON_CLIENT_CLASS_VERSION, "illume-home",
|
||||
{ _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL,
|
||||
e_gadcon_site_is_not_toolbar
|
||||
}, E_GADCON_CLIENT_STYLE_PLAIN
|
||||
};
|
||||
|
||||
/* public functions */
|
||||
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume Home" };
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
if (!il_home_config_init(m)) return NULL;
|
||||
|
||||
_il_home_apps_unpopulate();
|
||||
_il_home_apps_populate();
|
||||
|
||||
e_busycover_init();
|
||||
|
||||
handlers =
|
||||
eina_list_append(handlers,
|
||||
ecore_event_handler_add(EFREET_EVENT_DESKTOP_LIST_CHANGE,
|
||||
_il_home_desktop_list_change,
|
||||
NULL));
|
||||
handlers =
|
||||
eina_list_append(handlers,
|
||||
ecore_event_handler_add(EFREET_EVENT_DESKTOP_CHANGE,
|
||||
_il_home_desktop_change, NULL));
|
||||
|
||||
handlers =
|
||||
eina_list_append(handlers,
|
||||
ecore_event_handler_add(E_EVENT_BORDER_ADD,
|
||||
_il_home_border_add, NULL));
|
||||
handlers =
|
||||
eina_list_append(handlers,
|
||||
ecore_event_handler_add(E_EVENT_BORDER_REMOVE,
|
||||
_il_home_border_remove, NULL));
|
||||
|
||||
handlers =
|
||||
eina_list_append(handlers,
|
||||
ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
|
||||
_il_home_win_cb_exe_del, NULL));
|
||||
|
||||
e_gadcon_provider_register(&_gc_class);
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
{
|
||||
Ecore_Event_Handler *handle;
|
||||
Il_Home_Exec *exe;
|
||||
|
||||
EINA_LIST_FREE(exes, exe)
|
||||
{
|
||||
if (exe->exec)
|
||||
{
|
||||
ecore_exe_terminate(exe->exec);
|
||||
ecore_exe_free(exe->exec);
|
||||
exe->exec = NULL;
|
||||
}
|
||||
if (exe->handle)
|
||||
{
|
||||
e_busycover_pop(exe->cover, exe->handle);
|
||||
exe->handle = NULL;
|
||||
}
|
||||
if (exe->timeout) ecore_timer_del(exe->timeout);
|
||||
exe->cover = NULL;
|
||||
E_FREE(exe);
|
||||
}
|
||||
|
||||
_il_home_apps_unpopulate();
|
||||
|
||||
e_busycover_shutdown();
|
||||
|
||||
EINA_LIST_FREE(handlers, handle)
|
||||
ecore_event_handler_del(handle);
|
||||
|
||||
e_gadcon_provider_unregister(&_gc_class);
|
||||
|
||||
il_home_config_shutdown();
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
return il_home_config_save();
|
||||
}
|
||||
|
||||
void
|
||||
il_home_win_cfg_update(void)
|
||||
{
|
||||
_il_home_apps_unpopulate();
|
||||
_il_home_apps_populate();
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static E_Gadcon_Client *
|
||||
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||
{
|
||||
Instance *inst;
|
||||
Evas_Object *icon;
|
||||
Ecore_X_Window xwin;
|
||||
Ecore_X_Illume_Mode mode;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-home.edj",
|
||||
il_home_cfg->mod_dir);
|
||||
|
||||
inst = E_NEW(Instance, 1);
|
||||
inst->o_btn = e_widget_button_add(gc->evas, NULL, NULL,
|
||||
_il_home_btn_cb_click, inst, NULL);
|
||||
icon = e_icon_add(evas_object_evas_get(inst->o_btn));
|
||||
e_icon_file_edje_set(icon, buff, "btn_icon");
|
||||
e_widget_button_icon_set(inst->o_btn, icon);
|
||||
|
||||
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->o_btn);
|
||||
inst->gcc->data = inst;
|
||||
|
||||
// _il_home_win_new(inst);
|
||||
|
||||
xwin = inst->gcc->gadcon->zone->black_win;
|
||||
mode = ecore_x_e_illume_mode_get(xwin);
|
||||
// if (mode > ECORE_X_ILLUME_MODE_SINGLE)
|
||||
// _il_home_win_new(inst);
|
||||
|
||||
inst->hdl = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
|
||||
_il_home_cb_client_message, inst);
|
||||
|
||||
instances = eina_list_append(instances, inst);
|
||||
return inst->gcc;
|
||||
}
|
||||
|
||||
static void
|
||||
_gc_shutdown(E_Gadcon_Client *gcc)
|
||||
{
|
||||
Instance *inst;
|
||||
Il_Home_Win *hwin;
|
||||
|
||||
if (!(inst = gcc->data)) return;
|
||||
|
||||
instances = eina_list_remove(instances, inst);
|
||||
|
||||
if (inst->o_btn) evas_object_del(inst->o_btn);
|
||||
if (inst->hdl) ecore_event_handler_del(inst->hdl);
|
||||
|
||||
EINA_LIST_FREE(inst->wins, hwin)
|
||||
e_object_del(E_OBJECT(hwin));
|
||||
|
||||
E_FREE(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
|
||||
{
|
||||
e_gadcon_client_aspect_set(gcc, 16, 16);
|
||||
e_gadcon_client_min_size_set(gcc, 16, 16);
|
||||
}
|
||||
|
||||
static char *
|
||||
_gc_label(E_Gadcon_Client_Class *cc)
|
||||
{
|
||||
return _("Illume-Home");
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_gc_icon(E_Gadcon_Client_Class *cc, Evas *evas)
|
||||
{
|
||||
Evas_Object *o;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-home.edj",
|
||||
il_home_cfg->mod_dir);
|
||||
o = edje_object_add(evas);
|
||||
edje_object_file_set(o, buff, "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_gc_id_new(E_Gadcon_Client_Class *cc)
|
||||
{
|
||||
char buff[PATH_MAX];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s.%d", _gc_class.name,
|
||||
eina_list_count(instances));
|
||||
return strdup(buff);
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_btn_cb_click(void *data, void *data2)
|
||||
{
|
||||
Instance *inst;
|
||||
|
||||
if (!(inst = data)) return;
|
||||
_il_home_win_new(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_win_new(Instance *inst)
|
||||
{
|
||||
Il_Home_Win *hwin;
|
||||
E_Container *con;
|
||||
E_Zone *zone;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
if (!inst) return;
|
||||
|
||||
hwin = E_OBJECT_ALLOC(Il_Home_Win, IL_HOME_WIN_TYPE,
|
||||
_il_home_win_cb_free);
|
||||
if (!hwin) return;
|
||||
inst->wins = eina_list_append(inst->wins, hwin);
|
||||
|
||||
con = inst->gcc->gadcon->zone->container;
|
||||
zone = inst->gcc->gadcon->zone;
|
||||
|
||||
hwin->win = e_win_new(con);
|
||||
if (!hwin->win)
|
||||
{
|
||||
e_object_del(E_OBJECT(hwin));
|
||||
return;
|
||||
}
|
||||
hwin->win->data = inst;
|
||||
e_win_title_set(hwin->win, _("Illume Home"));
|
||||
e_win_name_class_set(hwin->win, "Illume-Home", "Illume-Home");
|
||||
e_win_resize_callback_set(hwin->win, _il_home_win_cb_resize);
|
||||
|
||||
if (!hwin->cover)
|
||||
{
|
||||
hwin->cover =
|
||||
e_busycover_new(inst->gcc->gadcon->zone, il_home_cfg->mod_dir);
|
||||
}
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-home.edj",
|
||||
il_home_cfg->mod_dir);
|
||||
|
||||
hwin->o_bg = edje_object_add(e_win_evas_get(hwin->win));
|
||||
if (!e_theme_edje_object_set(hwin->o_bg,
|
||||
"base/theme/modules/illume-home",
|
||||
"modules/illume-home/window"))
|
||||
edje_object_file_set(hwin->o_bg, buff, "modules/illume-home/window");
|
||||
evas_object_move(hwin->o_bg, 0, 0);
|
||||
evas_object_show(hwin->o_bg);
|
||||
|
||||
hwin->o_sf = e_scrollframe_add(e_win_evas_get(hwin->win));
|
||||
e_scrollframe_single_dir_set(hwin->o_sf, 1);
|
||||
evas_object_move(hwin->o_sf, 0, 0);
|
||||
evas_object_show(hwin->o_sf);
|
||||
|
||||
e_scrollframe_custom_edje_file_set(hwin->o_sf, buff,
|
||||
"modules/illume-home/launcher/scrollview");
|
||||
|
||||
hwin->o_fm = e_fm2_add(e_win_evas_get(hwin->win));
|
||||
_il_home_fmc_set(hwin->o_fm);
|
||||
evas_object_show(hwin->o_fm);
|
||||
e_user_dir_concat_static(buff, "appshadow");
|
||||
e_fm2_path_set(hwin->o_fm, NULL, buff);
|
||||
|
||||
e_fm2_window_object_set(hwin->o_fm, E_OBJECT(hwin->win));
|
||||
|
||||
e_scrollframe_extern_pan_set(hwin->o_sf, hwin->o_fm,
|
||||
_il_home_pan_set,
|
||||
_il_home_pan_get,
|
||||
_il_home_pan_max_get,
|
||||
_il_home_pan_child_size_get);
|
||||
evas_object_propagate_events_set(hwin->o_fm, 0);
|
||||
evas_object_smart_callback_add(hwin->o_fm, "selected",
|
||||
_il_home_cb_selected, hwin);
|
||||
|
||||
e_win_move_resize(hwin->win, zone->x, zone->y, zone->w, 100);
|
||||
e_win_show(hwin->win);
|
||||
e_border_zone_set(hwin->win->border, zone);
|
||||
e_win_placed_set(hwin->win, 1);
|
||||
hwin->win->border->lock_user_location = 1;
|
||||
|
||||
if (hwin->win->evas_win)
|
||||
e_drop_xdnd_register_set(hwin->win->evas_win, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_win_cb_free(Il_Home_Win *hwin)
|
||||
{
|
||||
if (hwin->win->evas_win)
|
||||
e_drop_xdnd_register_set(hwin->win->evas_win, 0);
|
||||
if (hwin->o_bg) evas_object_del(hwin->o_bg);
|
||||
hwin->o_bg = NULL;
|
||||
if (hwin->o_sf) evas_object_del(hwin->o_sf);
|
||||
hwin->o_sf = NULL;
|
||||
if (hwin->o_fm) evas_object_del(hwin->o_fm);
|
||||
hwin->o_fm = NULL;
|
||||
if (hwin->win) e_object_del(E_OBJECT(hwin->win));
|
||||
hwin->win = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_win_cb_resize(E_Win *win)
|
||||
{
|
||||
Instance *inst;
|
||||
Il_Home_Win *hwin;
|
||||
Eina_List *l;
|
||||
|
||||
if (!(inst = win->data)) return;
|
||||
EINA_LIST_FOREACH(inst->wins, l, hwin)
|
||||
{
|
||||
if (hwin->win != win)
|
||||
{
|
||||
hwin = NULL;
|
||||
continue;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
if (!hwin) return;
|
||||
|
||||
if (hwin->o_bg)
|
||||
{
|
||||
if (hwin->win)
|
||||
evas_object_resize(hwin->o_bg, hwin->win->w, hwin->win->h);
|
||||
}
|
||||
if (hwin->o_sf)
|
||||
{
|
||||
if (hwin->win)
|
||||
evas_object_resize(hwin->o_sf, hwin->win->w, hwin->win->h);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
||||
{
|
||||
e_fm2_pan_set(obj, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
|
||||
{
|
||||
e_fm2_pan_get(obj, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
|
||||
{
|
||||
e_fm2_pan_max_get(obj, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
|
||||
{
|
||||
e_fm2_pan_child_size_get(obj, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_cb_selected(void *data, Evas_Object *obj, void *event)
|
||||
{
|
||||
Il_Home_Win *hwin;
|
||||
Eina_List *selected;
|
||||
E_Fm2_Icon_Info *ici;
|
||||
|
||||
if (!(hwin = data)) return;
|
||||
selected = e_fm2_selected_list_get(hwin->o_fm);
|
||||
if (!selected) return;
|
||||
EINA_LIST_FREE(selected, ici)
|
||||
{
|
||||
Efreet_Desktop *desktop;
|
||||
|
||||
if (ici)
|
||||
{
|
||||
if (ici->real_link)
|
||||
{
|
||||
desktop = efreet_desktop_get(ici->real_link);
|
||||
if (desktop)
|
||||
_il_home_desktop_run(hwin, desktop);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_desktop_run(Il_Home_Win *hwin, Efreet_Desktop *desktop)
|
||||
{
|
||||
E_Exec_Instance *eins;
|
||||
Il_Home_Exec *exe;
|
||||
Eina_List *l;
|
||||
E_Border *b;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
if ((!desktop) || (!desktop->exec)) return;
|
||||
|
||||
EINA_LIST_FOREACH(exes, l, exe)
|
||||
{
|
||||
if (exe->desktop == desktop)
|
||||
{
|
||||
if ((exe->border) &&
|
||||
(exe->border->zone == hwin->win->border->zone))
|
||||
{
|
||||
e_border_uniconify(exe->border);
|
||||
e_border_show(exe->border);
|
||||
e_border_raise(exe->border);
|
||||
e_border_focus_set(exe->border, 1, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b = _il_home_desktop_find_border(hwin->win->border->zone, desktop);
|
||||
if (b)
|
||||
{
|
||||
e_border_uniconify(b);
|
||||
e_border_show(b);
|
||||
e_border_raise(b);
|
||||
e_border_focus_set(b, 1, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
exe = E_NEW(Il_Home_Exec, 1);
|
||||
if (!exe) return;
|
||||
|
||||
eins = e_exec(hwin->win->border->zone, desktop, NULL, NULL, "illume-home");
|
||||
exe->desktop = desktop;
|
||||
if (eins)
|
||||
{
|
||||
exe->exec = eins->exe;
|
||||
exe->startup_id = eins->startup_id;
|
||||
if (eins->exe)
|
||||
exe->pid = ecore_exe_pid_get(eins->exe);
|
||||
}
|
||||
|
||||
exe->timeout = ecore_timer_add(20.0, _il_home_win_cb_timeout, exe);
|
||||
exe->cover = hwin->cover;
|
||||
snprintf(buff, sizeof(buff), "Starting %s", desktop->name);
|
||||
exe->handle = e_busycover_push(exe->cover, buff, NULL);
|
||||
|
||||
exes = eina_list_append(exes, exe);
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_apps_populate(void)
|
||||
{
|
||||
Eina_List *l, *ll;
|
||||
Instance *inst;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
e_user_dir_concat_static(buff, "appshadow");
|
||||
ecore_file_mkpath(buff);
|
||||
|
||||
_il_home_desks_populate();
|
||||
|
||||
EINA_LIST_FOREACH(instances, l, inst)
|
||||
{
|
||||
Il_Home_Win *hwin;
|
||||
|
||||
EINA_LIST_FOREACH(inst->wins, ll, hwin)
|
||||
{
|
||||
if (!hwin) continue;
|
||||
_il_home_fmc_set(hwin->o_fm);
|
||||
e_fm2_path_set(hwin->o_fm, NULL, buff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_apps_unpopulate(void)
|
||||
{
|
||||
Efreet_Desktop *desktop;
|
||||
Eina_List *files;
|
||||
char buff[PATH_MAX], *file;
|
||||
size_t len;
|
||||
|
||||
EINA_LIST_FREE(desks, desktop)
|
||||
efreet_desktop_free(desktop);
|
||||
|
||||
len = e_user_dir_concat_static(buff, "appshadow");
|
||||
if ((len + 2) >= sizeof(buff)) return;
|
||||
|
||||
files = ecore_file_ls(buff);
|
||||
buff[len] = '/';
|
||||
len++;
|
||||
|
||||
EINA_LIST_FREE(files, file)
|
||||
{
|
||||
if (ecore_strlcpy(buff + len, file, sizeof(buff) - len) >= sizeof(buff) - len)
|
||||
continue;
|
||||
ecore_file_unlink(buff);
|
||||
free(file);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_fmc_set(Evas_Object *obj)
|
||||
{
|
||||
E_Fm2_Config fmc;
|
||||
|
||||
if (!obj) return;
|
||||
memset(&fmc, 0, sizeof(E_Fm2_Config));
|
||||
fmc.view.mode = E_FM2_VIEW_MODE_GRID_ICONS;
|
||||
fmc.view.open_dirs_in_place = 1;
|
||||
fmc.view.selector = 0;
|
||||
fmc.view.single_click = il_home_cfg->single_click;
|
||||
fmc.view.single_click_delay = il_home_cfg->single_click_delay;
|
||||
fmc.view.no_subdir_jump = 1;
|
||||
fmc.icon.extension.show = 0;
|
||||
fmc.icon.icon.w = il_home_cfg->icon_size * e_scale / 2.0;
|
||||
fmc.icon.icon.h = il_home_cfg->icon_size * e_scale / 2.0;
|
||||
fmc.icon.fixed.w = il_home_cfg->icon_size * e_scale / 2.0;
|
||||
fmc.icon.fixed.h = il_home_cfg->icon_size * e_scale / 2.0;
|
||||
fmc.list.sort.no_case = 0;
|
||||
fmc.list.sort.dirs.first = 1;
|
||||
fmc.list.sort.dirs.last = 0;
|
||||
fmc.selection.single = 1;
|
||||
fmc.selection.windows_modifiers = 0;
|
||||
e_fm2_config_set(obj, &fmc);
|
||||
}
|
||||
|
||||
static void
|
||||
_il_home_desks_populate(void)
|
||||
{
|
||||
Efreet_Menu *menu;
|
||||
|
||||
menu = efreet_menu_get();
|
||||
if (menu)
|
||||
{
|
||||
Eina_List *l, *ll;
|
||||
Efreet_Desktop *desktop;
|
||||
char buff[PATH_MAX];
|
||||
Efreet_Menu *entry, *subentry;
|
||||
Eina_List *settings, *sys, *kbd;
|
||||
int num = 0;
|
||||
|
||||
settings = efreet_util_desktop_category_list("Settings");
|
||||
sys = efreet_util_desktop_category_list("System");
|
||||
kbd = efreet_util_desktop_category_list("Keyboard");
|
||||
EINA_LIST_FOREACH(menu->entries, l, entry)
|
||||
{
|
||||
if (entry->type != EFREET_MENU_ENTRY_MENU) continue;
|
||||
desktop = entry->desktop;
|
||||
EINA_LIST_FOREACH(entry->entries, ll, subentry)
|
||||
{
|
||||
if (subentry->type != EFREET_MENU_ENTRY_DESKTOP) continue;
|
||||
if (!(desktop = subentry->desktop)) continue;
|
||||
if ((settings) && (sys) &&
|
||||
(eina_list_data_find(settings, desktop)) &&
|
||||
(eina_list_data_find(sys, desktop))) continue;
|
||||
if ((kbd) && (eina_list_data_find(kbd, desktop)))
|
||||
continue;
|
||||
if (!desktop) continue;
|
||||
desks = eina_list_append(desks, desktop);
|
||||
efreet_desktop_ref(desktop);
|
||||
if (desktop)
|
||||
{
|
||||
e_user_dir_snprintf(buff, sizeof(buff),
|
||||
"appshadow/%04x.desktop", num);
|
||||
ecore_file_symlink(desktop->orig_path, buff);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_il_home_desktop_list_change(void *data, int type, void *event)
|
||||
{
|
||||
if (defer) ecore_timer_del(defer);
|
||||
defer = ecore_timer_add(1.0, _il_home_update_deferred, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_il_home_desktop_change(void *data, int type, void *event)
|
||||
{
|
||||
if (defer) ecore_timer_del(defer);
|
||||
defer = ecore_timer_add(1.0, _il_home_update_deferred, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_il_home_update_deferred(void *data)
|
||||
{
|
||||
_il_home_apps_unpopulate();
|
||||
_il_home_apps_populate();
|
||||
defer = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_il_home_win_cb_exe_del(void *data, int type, void *event)
|
||||
{
|
||||
Il_Home_Exec *exe;
|
||||
Ecore_Exe_Event_Del *ev;
|
||||
Eina_List *l;
|
||||
|
||||
ev = event;
|
||||
EINA_LIST_FOREACH(exes, l, exe)
|
||||
{
|
||||
if (exe->pid == ev->pid)
|
||||
{
|
||||
if (exe->handle)
|
||||
{
|
||||
e_busycover_pop(exe->cover, exe->handle);
|
||||
exe->handle = NULL;
|
||||
}
|
||||
exes = eina_list_remove_list(exes, l);
|
||||
if (exe->timeout) ecore_timer_del(exe->timeout);
|
||||
exe->cover = NULL;
|
||||
E_FREE(exe);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static E_Border *
|
||||
_il_home_desktop_find_border(E_Zone *zone, Efreet_Desktop *desktop)
|
||||
{
|
||||
Eina_List *l;
|
||||
E_Border *bd;
|
||||
char *exe = NULL, *p;
|
||||
|
||||
if (!desktop) return NULL;
|
||||
if (!desktop->exec) return NULL;
|
||||
p = strchr(desktop->exec, ' ');
|
||||
if (!p)
|
||||
exe = strdup(desktop->exec);
|
||||
else
|
||||
{
|
||||
exe = malloc(p - desktop->exec + 1);
|
||||
if (exe) ecore_strlcpy(exe, desktop->exec, p - desktop->exec + 1);
|
||||
}
|
||||
if (exe)
|
||||
{
|
||||
p = strrchr(exe, '/');
|
||||
if (p) strcpy(exe, p + 1);
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(e_border_client_list(), l, bd)
|
||||
{
|
||||
if (bd->zone != zone) continue;
|
||||
if (e_exec_startup_id_pid_find(bd->client.netwm.pid,
|
||||
bd->client.netwm.startup_id) == desktop)
|
||||
{
|
||||
if (exe) free(exe);
|
||||
return bd;
|
||||
}
|
||||
if (exe)
|
||||
{
|
||||
if (bd->client.icccm.command.argv)
|
||||
{
|
||||
char *pp;
|
||||
|
||||
pp = strrchr(bd->client.icccm.command.argv[0], '/');
|
||||
if (!pp) pp = bd->client.icccm.command.argv[0];
|
||||
if (!strcmp(exe, pp))
|
||||
{
|
||||
if (exe) free(exe);
|
||||
return bd;
|
||||
}
|
||||
}
|
||||
if ((bd->client.icccm.name) &&
|
||||
(!strcasecmp(bd->client.icccm.name, exe)))
|
||||
{
|
||||
if (exe) free(exe);
|
||||
return bd;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (exe) free(exe);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
_il_home_win_cb_timeout(void *data)
|
||||
{
|
||||
Il_Home_Exec *exe;
|
||||
|
||||
if (!(exe = data)) return 1;
|
||||
if (exe->handle) e_busycover_pop(exe->cover, exe->handle);
|
||||
exe->handle = NULL;
|
||||
if (!exe->border)
|
||||
{
|
||||
exes = eina_list_remove(exes, exe);
|
||||
E_FREE(exe);
|
||||
return 0;
|
||||
}
|
||||
exe->timeout = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_il_home_border_add(void *data, int type, void *event)
|
||||
{
|
||||
E_Event_Border_Add *ev;
|
||||
Il_Home_Exec *exe;
|
||||
Eina_List *l;
|
||||
|
||||
ev = event;
|
||||
EINA_LIST_FOREACH(exes, l, exe)
|
||||
{
|
||||
if (!exe->border)
|
||||
{
|
||||
if ((exe->startup_id == ev->border->client.netwm.startup_id) ||
|
||||
(exe->pid == ev->border->client.netwm.pid))
|
||||
{
|
||||
exe->border = ev->border;
|
||||
if (exe->handle)
|
||||
{
|
||||
e_busycover_pop(exe->cover, exe->handle);
|
||||
exe->handle = NULL;
|
||||
}
|
||||
if (exe->timeout) ecore_timer_del(exe->timeout);
|
||||
exe->timeout = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_il_home_border_remove(void *data, int type, void *event)
|
||||
{
|
||||
E_Event_Border_Remove *ev;
|
||||
Il_Home_Exec *exe;
|
||||
Eina_List *l;
|
||||
|
||||
ev = event;
|
||||
EINA_LIST_FOREACH(exes, l, exe)
|
||||
{
|
||||
if (exe->border == ev->border)
|
||||
{
|
||||
if (exe->exec)
|
||||
{
|
||||
ecore_exe_free(exe->exec);
|
||||
exe->exec = NULL;
|
||||
}
|
||||
if (exe->handle)
|
||||
{
|
||||
e_busycover_pop(exe->cover, exe->handle);
|
||||
exe->handle = NULL;
|
||||
}
|
||||
exe->border = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_il_home_cb_client_message(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_X_Event_Client_Message *ev;
|
||||
Instance *inst;
|
||||
|
||||
ev = event;
|
||||
if (ev->message_type != ECORE_X_ATOM_E_ILLUME_HOME) return 1;
|
||||
if (!(inst = data)) return 1;
|
||||
_il_home_win_new(inst);
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef E_MOD_MAIN_H
|
||||
#define E_MOD_MAIN_H
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
||||
EAPI void *e_modapi_init(E_Module *m);
|
||||
EAPI int e_modapi_shutdown(E_Module *m);
|
||||
EAPI int e_modapi_save(E_Module *m);
|
||||
|
||||
void il_home_win_cfg_update(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,8 @@
|
|||
[Desktop Entry]
|
||||
Type=Link
|
||||
Name=Illume-Home
|
||||
Icon=e-module-illume-home
|
||||
X-Enlightenment-ModuleType=system
|
||||
Comment=<title>Illume Home for Embedded</title>
|
||||
Comment[fr]=<title>Illume pour l'embarqué – Home</title>
|
||||
Comment[it]=<title>Illume per sistemi embedded – modulo Home</title>
|
|
@ -0,0 +1,31 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MODULE = illume-indicator
|
||||
|
||||
# data files for the module
|
||||
filesdir = $(libdir)/enlightenment/modules/$(MODULE)
|
||||
files_DATA = \
|
||||
e-module-$(MODULE).edj module.desktop
|
||||
|
||||
EXTRA_DIST = $(files_DATA)
|
||||
|
||||
# the module .so file
|
||||
INCLUDES = -I. \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/modules/$(MODULE) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/modules \
|
||||
@e_cflags@
|
||||
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
|
||||
pkg_LTLIBRARIES = module.la
|
||||
module_la_SOURCES = e_mod_main.c \
|
||||
e_mod_main.h \
|
||||
e_mod_win.c \
|
||||
e_mod_win.h
|
||||
|
||||
module_la_LIBADD = @e_libs@ @dlopen_libs@
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
module_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
||||
uninstall:
|
||||
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)
|
|
@ -0,0 +1,60 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_mod_config.h"
|
||||
|
||||
/* local variables */
|
||||
EAPI Il_Ind_Config *il_ind_cfg = NULL;
|
||||
static E_Config_DD *conf_edd = NULL;
|
||||
|
||||
int
|
||||
il_ind_config_init(E_Module *m)
|
||||
{
|
||||
conf_edd = E_CONFIG_DD_NEW("Illume-Ind_Cfg", Il_Ind_Config);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Il_Ind_Config
|
||||
#define D conf_edd
|
||||
E_CONFIG_VAL(D, T, version, INT);
|
||||
|
||||
il_ind_cfg = e_config_domain_load("module.illume-indicator", conf_edd);
|
||||
if ((il_ind_cfg) &&
|
||||
((il_ind_cfg->version >> 16) < IL_CONFIG_MAJ))
|
||||
{
|
||||
E_FREE(il_ind_cfg);
|
||||
il_ind_cfg = NULL;
|
||||
}
|
||||
if (!il_ind_cfg)
|
||||
{
|
||||
il_ind_cfg = E_NEW(Il_Ind_Config, 1);
|
||||
il_ind_cfg->version = 0;
|
||||
}
|
||||
if (il_ind_cfg)
|
||||
{
|
||||
/* Add new config variables here */
|
||||
/* if ((il_ind_cfg->version & 0xffff) < 1) */
|
||||
il_ind_cfg->version = (IL_CONFIG_MAJ << 16) | IL_CONFIG_MIN;
|
||||
}
|
||||
|
||||
il_ind_cfg->mod_dir = eina_stringshare_add(m->dir);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
il_ind_config_shutdown(void)
|
||||
{
|
||||
if (il_ind_cfg->mod_dir) eina_stringshare_del(il_ind_cfg->mod_dir);
|
||||
il_ind_cfg->mod_dir = NULL;
|
||||
|
||||
E_FREE(il_ind_cfg);
|
||||
il_ind_cfg = NULL;
|
||||
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
il_ind_config_save(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef E_MOD_CONFIG_H
|
||||
#define E_MOD_CONFIG_H
|
||||
|
||||
#define IL_CONFIG_MIN 0
|
||||
#define IL_CONFIG_MAJ 0
|
||||
|
||||
typedef struct _Il_Ind_Config Il_Ind_Config;
|
||||
|
||||
struct _Il_Ind_Config
|
||||
{
|
||||
int version;
|
||||
|
||||
// Placeholders
|
||||
const char *mod_dir;
|
||||
};
|
||||
|
||||
int il_ind_config_init(E_Module *m);
|
||||
int il_ind_config_shutdown(void);
|
||||
int il_ind_config_save(void);
|
||||
|
||||
extern EAPI Il_Ind_Config *il_ind_cfg;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,66 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_mod_win.h"
|
||||
|
||||
/* local function prototypes */
|
||||
static int _cb_screens_sort(const void *data, const void *data2);
|
||||
|
||||
/* local variables */
|
||||
static Eina_List *iwins = NULL;
|
||||
const char *mod_dir = NULL;
|
||||
|
||||
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume-Indicator" };
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
E_Screen *screen;
|
||||
Eina_List *l, *screens;
|
||||
|
||||
mod_dir = eina_stringshare_add(m->dir);
|
||||
screens = (Eina_List *)e_xinerama_screens_get();
|
||||
// screens = eina_list_sort(screens, 0, _cb_screens_sort);
|
||||
EINA_LIST_FOREACH(screens, l, screen)
|
||||
{
|
||||
Il_Ind_Win *iwin = NULL;
|
||||
|
||||
if (!(iwin = e_mod_win_new(screen))) continue;
|
||||
iwins = eina_list_append(iwins, iwin);
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
{
|
||||
Il_Ind_Win *iwin;
|
||||
|
||||
EINA_LIST_FREE(iwins, iwin)
|
||||
{
|
||||
e_object_del(E_OBJECT(iwin));
|
||||
iwin = NULL;
|
||||
}
|
||||
|
||||
if (mod_dir) eina_stringshare_del(mod_dir);
|
||||
mod_dir = NULL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* local function prototypes */
|
||||
static int
|
||||
_cb_screens_sort(const void *data, const void *data2)
|
||||
{
|
||||
E_Screen *s1, *s2;
|
||||
|
||||
if (!(s1 = (E_Screen *)data)) return -1;
|
||||
if (!(s2 = (E_Screen *)data2)) return 1;
|
||||
return s2->escreen - s1->escreen;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef E_MOD_MAIN_H
|
||||
# define E_MOD_MAIN_H
|
||||
|
||||
# define IL_IND_WIN_TYPE 0xE1b0886
|
||||
|
||||
typedef struct _Il_Ind_Win Il_Ind_Win;
|
||||
|
||||
struct _Il_Ind_Win
|
||||
{
|
||||
E_Object e_obj_inherit;
|
||||
E_Win *win;
|
||||
E_Menu *menu;
|
||||
E_Gadcon *gadcon;
|
||||
Evas_Object *o_base, *o_event;
|
||||
};
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
||||
EAPI void *e_modapi_init(E_Module *m);
|
||||
EAPI int e_modapi_shutdown(E_Module *m);
|
||||
EAPI int e_modapi_save(E_Module *m);
|
||||
|
||||
extern const char *mod_dir;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,340 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_mod_win.h"
|
||||
|
||||
/* local function prototypes */
|
||||
static void _e_mod_win_cb_free(Il_Ind_Win *iwin);
|
||||
static void _e_mod_win_cb_resize(E_Win *win);
|
||||
static void _e_mod_win_cb_min_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h);
|
||||
static void _e_mod_win_cb_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h);
|
||||
static Evas_Object *_e_mod_win_cb_frame_request(void *data, E_Gadcon_Client *gcc, const char *style);
|
||||
static void _e_mod_win_cb_menu_items_append(void *data, E_Gadcon_Client *gcc, E_Menu *mn);
|
||||
static void _e_mod_win_cb_menu_append(Il_Ind_Win *iwin, E_Menu *mn);
|
||||
static void _e_mod_win_cb_menu_pre(void *data, E_Menu *mn);
|
||||
static void _e_mod_win_cb_menu_contents(void *data, E_Menu *mn, E_Menu_Item *mi);
|
||||
static void _e_mod_win_cb_menu_post(void *data, E_Menu *mn);
|
||||
static void _e_mod_win_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event);
|
||||
static void _e_mod_win_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event);
|
||||
static void _e_mod_win_cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event);
|
||||
static void _e_mod_win_cb_mouse_wheel(void *data, Evas *evas, Evas_Object *obj, void *event);
|
||||
|
||||
/* local variables */
|
||||
static int my = 0;
|
||||
|
||||
Il_Ind_Win *
|
||||
e_mod_win_new(E_Screen *screen)
|
||||
{
|
||||
Il_Ind_Win *iwin;
|
||||
E_Container *con;
|
||||
E_Zone *zone;
|
||||
Evas *evas;
|
||||
Ecore_X_Window_State states[2];
|
||||
|
||||
iwin = E_OBJECT_ALLOC(Il_Ind_Win, IL_IND_WIN_TYPE, _e_mod_win_cb_free);
|
||||
if (!iwin) return NULL;
|
||||
|
||||
con = e_container_current_get(e_manager_current_get());
|
||||
zone = e_util_container_zone_id_get(con->num, screen->escreen);
|
||||
|
||||
iwin->win = e_win_new(con);
|
||||
iwin->win->data = iwin;
|
||||
states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
|
||||
states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
|
||||
e_win_title_set(iwin->win, _("Illume Indicator"));
|
||||
e_win_name_class_set(iwin->win, "Illume-Indicator", "Illume-Indicator");
|
||||
e_win_resize_callback_set(iwin->win, _e_mod_win_cb_resize);
|
||||
ecore_x_icccm_hints_set(iwin->win->evas_win, 0, 0, 0, 0, 0, 0, 0);
|
||||
ecore_x_netwm_window_state_set(iwin->win->evas_win, states, 2);
|
||||
ecore_x_netwm_window_type_set(iwin->win->evas_win, ECORE_X_WINDOW_TYPE_DOCK);
|
||||
|
||||
evas = e_win_evas_get(iwin->win);
|
||||
|
||||
iwin->o_event = evas_object_rectangle_add(evas);
|
||||
evas_object_color_set(iwin->o_event, 0, 0, 0, 0);
|
||||
evas_object_move(iwin->o_event, 0, 0);
|
||||
evas_object_event_callback_add(iwin->o_event, EVAS_CALLBACK_MOUSE_DOWN,
|
||||
_e_mod_win_cb_mouse_down, iwin);
|
||||
evas_object_event_callback_add(iwin->o_event, EVAS_CALLBACK_MOUSE_UP,
|
||||
_e_mod_win_cb_mouse_up, iwin);
|
||||
evas_object_event_callback_add(iwin->o_event, EVAS_CALLBACK_MOUSE_MOVE,
|
||||
_e_mod_win_cb_mouse_move, iwin);
|
||||
evas_object_event_callback_add(iwin->o_event, EVAS_CALLBACK_MOUSE_WHEEL,
|
||||
_e_mod_win_cb_mouse_wheel, iwin);
|
||||
evas_object_show(iwin->o_event);
|
||||
|
||||
iwin->o_base = edje_object_add(evas);
|
||||
if (!e_theme_edje_object_set(iwin->o_base,
|
||||
"base/theme/modules/illume-indicator",
|
||||
"modules/illume-indicator/shelf"))
|
||||
{
|
||||
char buff[PATH_MAX];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-indicator.edj",
|
||||
mod_dir);
|
||||
edje_object_file_set(iwin->o_base, buff,
|
||||
"modules/illume-indicator/shelf");
|
||||
}
|
||||
evas_object_move(iwin->o_base, 0, 0);
|
||||
evas_object_show(iwin->o_base);
|
||||
|
||||
iwin->gadcon = e_gadcon_swallowed_new("illume-indicator", zone->id,
|
||||
iwin->o_base, "e.swallow.content");
|
||||
|
||||
edje_extern_object_min_size_set(iwin->gadcon->o_container, zone->w, 32);
|
||||
edje_object_part_swallow(iwin->o_base, "e.swallow.container",
|
||||
iwin->gadcon->o_container);
|
||||
e_gadcon_min_size_request_callback_set(iwin->gadcon,
|
||||
_e_mod_win_cb_min_size_request, iwin);
|
||||
e_gadcon_size_request_callback_set(iwin->gadcon,
|
||||
_e_mod_win_cb_size_request, iwin);
|
||||
e_gadcon_frame_request_callback_set(iwin->gadcon,
|
||||
_e_mod_win_cb_frame_request, iwin);
|
||||
e_gadcon_orient(iwin->gadcon, E_GADCON_ORIENT_FLOAT);
|
||||
e_gadcon_zone_set(iwin->gadcon, zone);
|
||||
e_gadcon_ecore_evas_set(iwin->gadcon, iwin->win->ecore_evas);
|
||||
e_gadcon_util_menu_attach_func_set(iwin->gadcon,
|
||||
_e_mod_win_cb_menu_items_append, iwin);
|
||||
e_gadcon_populate(iwin->gadcon);
|
||||
|
||||
e_win_size_min_set(iwin->win, zone->w, 32);
|
||||
e_win_move_resize(iwin->win, zone->x, zone->y, zone->w, 32);
|
||||
e_win_show(iwin->win);
|
||||
e_border_zone_set(iwin->win->border, zone);
|
||||
// e_win_placed_set(iwin->win, 1);
|
||||
// iwin->win->border->lock_user_location = 1;
|
||||
|
||||
ecore_x_e_illume_top_shelf_geometry_set(ecore_x_window_root_first_get(),
|
||||
zone->x, zone->y, zone->w, 32);
|
||||
|
||||
return iwin;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static void
|
||||
_e_mod_win_cb_free(Il_Ind_Win *iwin)
|
||||
{
|
||||
if (iwin->menu)
|
||||
{
|
||||
e_menu_post_deactivate_callback_set(iwin->menu, NULL, NULL);
|
||||
e_object_del(E_OBJECT(iwin->menu));
|
||||
iwin->menu = NULL;
|
||||
}
|
||||
|
||||
if (iwin->o_base) evas_object_del(iwin->o_base);
|
||||
if (iwin->o_event) evas_object_del(iwin->o_event);
|
||||
|
||||
e_object_del(E_OBJECT(iwin->gadcon));
|
||||
iwin->gadcon = NULL;
|
||||
|
||||
e_object_del(E_OBJECT(iwin->win));
|
||||
iwin->win = NULL;
|
||||
|
||||
E_FREE(iwin);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_win_cb_resize(E_Win *win)
|
||||
{
|
||||
Il_Ind_Win *iwin;
|
||||
|
||||
if (!(iwin = win->data)) return;
|
||||
evas_object_resize(iwin->o_event, win->w, win->h);
|
||||
evas_object_resize(iwin->o_base, win->w, win->h);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_win_cb_min_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h)
|
||||
{
|
||||
Il_Ind_Win *iwin;
|
||||
|
||||
if (!(iwin = data)) return;
|
||||
if (gc != iwin->gadcon) return;
|
||||
if (h < 32) h = 32;
|
||||
edje_extern_object_min_size_set(iwin->gadcon->o_container, w, h);
|
||||
edje_object_part_swallow(iwin->o_base, "e.swallow.content",
|
||||
iwin->gadcon->o_container);
|
||||
evas_object_resize(iwin->o_base, iwin->win->w, iwin->win->h);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_win_cb_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_e_mod_win_cb_frame_request(void *data, E_Gadcon_Client *gcc, const char *style)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_win_cb_menu_items_append(void *data, E_Gadcon_Client *gcc, E_Menu *mn)
|
||||
{
|
||||
Il_Ind_Win *iwin;
|
||||
|
||||
if (!(iwin = data)) return;
|
||||
_e_mod_win_cb_menu_append(iwin, mn);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_win_cb_menu_append(Il_Ind_Win *iwin, E_Menu *mn)
|
||||
{
|
||||
E_Menu *sm;
|
||||
E_Menu_Item *mi;
|
||||
|
||||
sm = e_menu_new();
|
||||
mi = e_menu_item_new(mn);
|
||||
e_menu_item_label_set(mi, _("Illume Indicator"));
|
||||
e_util_menu_item_theme_icon_set(mi, "preferences-desktop-shelf");
|
||||
e_menu_pre_activate_callback_set(sm, _e_mod_win_cb_menu_pre, iwin);
|
||||
e_object_data_set(E_OBJECT(mi), iwin);
|
||||
e_menu_item_submenu_set(mi, sm);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_win_cb_menu_pre(void *data, E_Menu *mn)
|
||||
{
|
||||
Il_Ind_Win *iwin;
|
||||
E_Menu_Item *mi;
|
||||
|
||||
if (!(iwin = data)) return;
|
||||
e_menu_pre_activate_callback_set(mn, NULL, NULL);
|
||||
|
||||
mi = e_menu_item_new(mn);
|
||||
e_menu_item_label_set(mi, _("Set Contents"));
|
||||
e_util_menu_item_theme_icon_set(mi, "preferences-desktop-shelf");
|
||||
e_menu_item_callback_set(mi, _e_mod_win_cb_menu_contents, iwin);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_win_cb_menu_contents(void *data, E_Menu *mn, E_Menu_Item *mi)
|
||||
{
|
||||
Il_Ind_Win *iwin;
|
||||
|
||||
if (!(iwin = data)) return;
|
||||
if (!iwin->gadcon->config_dialog)
|
||||
e_int_gadcon_config_shelf(iwin->gadcon);
|
||||
}
|
||||
|
||||
static void _e_mod_win_cb_menu_post(void *data, E_Menu *mn)
|
||||
{
|
||||
Il_Ind_Win *iwin;
|
||||
|
||||
if (!(iwin = data)) return;
|
||||
if (!iwin->menu) return;
|
||||
e_object_del(E_OBJECT(iwin->menu));
|
||||
iwin->menu = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_win_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event)
|
||||
{
|
||||
Il_Ind_Win *iwin;
|
||||
Evas_Event_Mouse_Down *ev;
|
||||
|
||||
if (!(iwin = data)) return;
|
||||
ev = event;
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||
if (ev->button == 1)
|
||||
{
|
||||
if (iwin->win->border->client.illume.drag.locked) return;
|
||||
ecore_x_e_illume_drag_start_send(iwin->win->border->client.win);
|
||||
ecore_x_pointer_last_xy_get(NULL, &my);
|
||||
}
|
||||
else if (ev->button == 3)
|
||||
{
|
||||
E_Menu *mn;
|
||||
E_Zone *zone;
|
||||
int x, y;
|
||||
|
||||
mn = e_menu_new();
|
||||
e_menu_post_deactivate_callback_set(mn, _e_mod_win_cb_menu_post, iwin);
|
||||
iwin->menu = mn;
|
||||
|
||||
_e_mod_win_cb_menu_append(iwin, mn);
|
||||
zone = e_util_zone_current_get(e_manager_current_get());
|
||||
e_gadcon_canvas_zone_geometry_get(iwin->gadcon, &x, &y, NULL, NULL);
|
||||
e_menu_activate_mouse(mn, zone, x + ev->output.x, y + ev->output.y,
|
||||
1, 1, E_MENU_POP_DIRECTION_AUTO, ev->timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_win_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event)
|
||||
{
|
||||
Il_Ind_Win *iwin;
|
||||
Evas_Event_Mouse_Up *ev;
|
||||
E_Border *bd;
|
||||
|
||||
if (!(iwin = data)) return;
|
||||
ev = event;
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||
if (ev->button != 1) return;
|
||||
bd = iwin->win->border;
|
||||
if (bd->client.illume.drag.locked) return;
|
||||
if (!ecore_x_e_illume_drag_get(bd->zone->black_win)) return;
|
||||
// if (!bd->client.illume.drag.drag) return;
|
||||
ecore_x_e_illume_drag_end_send(bd->client.win);
|
||||
my = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_win_cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event)
|
||||
{
|
||||
Il_Ind_Win *iwin;
|
||||
Evas_Event_Mouse_Move *ev;
|
||||
E_Border *bd;
|
||||
int dy, ny, py;
|
||||
|
||||
if (!(iwin = data)) return;
|
||||
ev = event;
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||
bd = iwin->win->border;
|
||||
if (bd->client.illume.drag.locked) return;
|
||||
if (!ecore_x_e_illume_drag_get(bd->zone->black_win)) return;
|
||||
// if (!bd->client.illume.drag.drag) return;
|
||||
if ((bd->y + bd->h + ev->cur.output.y) >= (bd->zone->h)) return;
|
||||
|
||||
ecore_x_pointer_last_xy_get(NULL, &py);
|
||||
dy = ((bd->zone->h - bd->h) / 8);
|
||||
|
||||
if ((ev->cur.output.y > ev->prev.output.y))
|
||||
{
|
||||
if ((py - my) < dy) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((my - py) < dy) return;
|
||||
}
|
||||
|
||||
if (py > my)
|
||||
ny = bd->y + dy;
|
||||
else if (py <= my)
|
||||
ny = bd->y - dy;
|
||||
else return;
|
||||
|
||||
if (bd->y != ny)
|
||||
{
|
||||
e_border_move(bd, bd->zone->x, ny);
|
||||
my = py;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_win_cb_mouse_wheel(void *data, Evas *evas, Evas_Object *obj, void *event)
|
||||
{
|
||||
Il_Ind_Win *iwin;
|
||||
Evas_Event_Mouse_Wheel *ev;
|
||||
Ecore_X_Illume_Quickpanel_State state;
|
||||
|
||||
if (!(iwin = data)) return;
|
||||
ev = event;
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
||||
if (ev->direction != 0) return;
|
||||
if (ev->z > 0)
|
||||
state = ECORE_X_ILLUME_QUICKPANEL_STATE_ON;
|
||||
else if (ev->z < 0)
|
||||
state = ECORE_X_ILLUME_QUICKPANEL_STATE_OFF;
|
||||
ecore_x_e_illume_quickpanel_state_send(ecore_x_window_root_first_get(), state);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef E_MOD_WIN_H
|
||||
# define E_MOD_WIN_H
|
||||
|
||||
Il_Ind_Win *e_mod_win_new(E_Screen *screen);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,8 @@
|
|||
[Desktop Entry]
|
||||
Type=Link
|
||||
Name=Illume-Indicator
|
||||
Icon=e-module-illume-indicator
|
||||
X-Enlightenment-ModuleType=system
|
||||
Comment=<title>Illume Indicator for Embedded</title>
|
||||
Comment[fr]=<title>Illume pour l'embarqué – Indicator</title>
|
||||
Comment[it]=<title>Illume per sistemi embedded – modulo Indicator</title>
|
|
@ -0,0 +1,29 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MODULE = illume-kbd-toggle
|
||||
|
||||
# data files for the module
|
||||
filesdir = $(libdir)/enlightenment/modules/$(MODULE)
|
||||
files_DATA = \
|
||||
e-module-$(MODULE).edj module.desktop
|
||||
|
||||
EXTRA_DIST = $(files_DATA)
|
||||
|
||||
# the module .so file
|
||||
INCLUDES = -I. \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/modules/$(MODULE) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/modules \
|
||||
@e_cflags@
|
||||
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
|
||||
pkg_LTLIBRARIES = module.la
|
||||
module_la_SOURCES = e_mod_main.c \
|
||||
e_mod_main.h
|
||||
|
||||
module_la_LIBADD = @e_libs@ @dlopen_libs@
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
module_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
||||
uninstall:
|
||||
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)
|
|
@ -0,0 +1,218 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
/* local structures */
|
||||
typedef struct _Instance Instance;
|
||||
struct _Instance
|
||||
{
|
||||
E_Gadcon_Client *gcc;
|
||||
Evas_Object *o_btn;
|
||||
Eina_List *handlers;
|
||||
};
|
||||
|
||||
/* local function prototypes */
|
||||
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
||||
static void _gc_shutdown(E_Gadcon_Client *gcc);
|
||||
static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
|
||||
static char *_gc_label(E_Gadcon_Client_Class *cc);
|
||||
static Evas_Object *_gc_icon(E_Gadcon_Client_Class *cc, Evas *evas);
|
||||
static const char *_gc_id_new(E_Gadcon_Client_Class *cc);
|
||||
static void _cb_btn_click(void *data, void *data2);
|
||||
static int _cb_border_focus_in(void *data, int type, void *event);
|
||||
static int _cb_border_remove(void *data, int type, void *event);
|
||||
|
||||
/* local variables */
|
||||
static Eina_List *instances = NULL;
|
||||
static const char *mod_dir = NULL;
|
||||
|
||||
static const E_Gadcon_Client_Class _gc_class =
|
||||
{
|
||||
GADCON_CLIENT_CLASS_VERSION, "illume-kbd-toggle",
|
||||
{ _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL,
|
||||
e_gadcon_site_is_not_toolbar
|
||||
}, E_GADCON_CLIENT_STYLE_PLAIN
|
||||
};
|
||||
|
||||
/* public functions */
|
||||
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume Keyboard Toggle" };
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
mod_dir = eina_stringshare_add(m->dir);
|
||||
e_gadcon_provider_register(&_gc_class);
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
{
|
||||
e_gadcon_provider_unregister(&_gc_class);
|
||||
if (mod_dir) eina_stringshare_del(mod_dir);
|
||||
mod_dir = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* local function prototypes */
|
||||
static E_Gadcon_Client *
|
||||
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||
{
|
||||
Instance *inst;
|
||||
Evas_Object *icon;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-kbd-toggle.edj", mod_dir);
|
||||
|
||||
inst = E_NEW(Instance, 1);
|
||||
inst->o_btn = e_widget_button_add(gc->evas, NULL, NULL,
|
||||
_cb_btn_click, inst, NULL);
|
||||
icon = e_icon_add(evas_object_evas_get(inst->o_btn));
|
||||
e_icon_file_edje_set(icon, buff, "icon");
|
||||
e_widget_button_icon_set(inst->o_btn, icon);
|
||||
|
||||
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->o_btn);
|
||||
inst->gcc->data = inst;
|
||||
|
||||
inst->handlers =
|
||||
eina_list_append(inst->handlers,
|
||||
ecore_event_handler_add(E_EVENT_BORDER_FOCUS_IN,
|
||||
_cb_border_focus_in, inst));
|
||||
inst->handlers =
|
||||
eina_list_append(inst->handlers,
|
||||
ecore_event_handler_add(E_EVENT_BORDER_REMOVE,
|
||||
_cb_border_remove, inst));
|
||||
|
||||
instances = eina_list_append(instances, inst);
|
||||
return inst->gcc;
|
||||
}
|
||||
|
||||
static void
|
||||
_gc_shutdown(E_Gadcon_Client *gcc)
|
||||
{
|
||||
Instance *inst;
|
||||
Ecore_Event_Handler *handler;
|
||||
|
||||
if (!(inst = gcc->data)) return;
|
||||
instances = eina_list_remove(instances, inst);
|
||||
if (inst->o_btn) evas_object_del(inst->o_btn);
|
||||
EINA_LIST_FREE(inst->handlers, handler)
|
||||
ecore_event_handler_del(handler);
|
||||
E_FREE(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
|
||||
{
|
||||
e_gadcon_client_aspect_set(gcc, 16, 16);
|
||||
e_gadcon_client_min_size_set(gcc, 16, 16);
|
||||
}
|
||||
|
||||
static char *
|
||||
_gc_label(E_Gadcon_Client_Class *cc)
|
||||
{
|
||||
return _("Illume-Keyboard-Toggle");
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_gc_icon(E_Gadcon_Client_Class *cc, Evas *evas)
|
||||
{
|
||||
Evas_Object *o;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-kbd-toggle.edj", mod_dir);
|
||||
o = edje_object_add(evas);
|
||||
edje_object_file_set(o, buff, "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_gc_id_new(E_Gadcon_Client_Class *cc)
|
||||
{
|
||||
char buff[PATH_MAX];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s.%d", _gc_class.name,
|
||||
eina_list_count(instances));
|
||||
return strdup(buff);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_btn_click(void *data, void *data2)
|
||||
{
|
||||
Ecore_X_Virtual_Keyboard_State state;
|
||||
Instance *inst;
|
||||
E_Border *bd;
|
||||
Evas_Object *icon;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
if (!(inst = data)) return;
|
||||
if (!(bd = e_border_focused_get())) return;
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-kbd-toggle.edj", mod_dir);
|
||||
|
||||
icon = e_icon_add(evas_object_evas_get(inst->o_btn));
|
||||
state = bd->client.vkbd.state;
|
||||
if ((state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF) ||
|
||||
(state == ECORE_X_VIRTUAL_KEYBOARD_STATE_UNKNOWN))
|
||||
{
|
||||
ecore_x_e_virtual_keyboard_state_set(bd->client.win,
|
||||
ECORE_X_VIRTUAL_KEYBOARD_STATE_ON);
|
||||
e_icon_file_edje_set(icon, buff, "btn_icon");
|
||||
}
|
||||
else
|
||||
{
|
||||
ecore_x_e_virtual_keyboard_state_set(bd->client.win,
|
||||
ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF);
|
||||
e_icon_file_edje_set(icon, buff, "icon");
|
||||
}
|
||||
e_widget_button_icon_set(inst->o_btn, icon);
|
||||
}
|
||||
|
||||
static int
|
||||
_cb_border_focus_in(void *data, int type, void *event)
|
||||
{
|
||||
Instance *inst;
|
||||
E_Event_Border_Focus_In *ev;
|
||||
E_Border *bd;
|
||||
Evas_Object *icon;
|
||||
Ecore_X_Virtual_Keyboard_State state;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
if (!(inst = data)) return 1;
|
||||
ev = event;
|
||||
if (ev->border->stolen) return 1;
|
||||
if (!(bd = ev->border)) return 1;
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-kbd-toggle.edj", mod_dir);
|
||||
|
||||
icon = e_icon_add(evas_object_evas_get(inst->o_btn));
|
||||
state = bd->client.vkbd.state;
|
||||
if ((state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF) ||
|
||||
(state == ECORE_X_VIRTUAL_KEYBOARD_STATE_UNKNOWN))
|
||||
e_icon_file_edje_set(icon, buff, "icon");
|
||||
else
|
||||
e_icon_file_edje_set(icon, buff, "btn_icon");
|
||||
e_widget_button_icon_set(inst->o_btn, icon);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_cb_border_remove(void *data, int type, void *event)
|
||||
{
|
||||
Instance *inst;
|
||||
Evas_Object *icon;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
if (!(inst = data)) return 1;
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-kbd-toggle.edj", mod_dir);
|
||||
icon = e_icon_add(evas_object_evas_get(inst->o_btn));
|
||||
e_icon_file_edje_set(icon, buff, "icon");
|
||||
e_widget_button_icon_set(inst->o_btn, icon);
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef E_MOD_MAIN_H
|
||||
#define E_MOD_MAIN_H
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
||||
EAPI void *e_modapi_init(E_Module *m);
|
||||
EAPI int e_modapi_shutdown(E_Module *m);
|
||||
EAPI int e_modapi_save(E_Module *m);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,8 @@
|
|||
[Desktop Entry]
|
||||
Type=Link
|
||||
Name=Illume-Keyboard-Toggle
|
||||
Icon=e-module-illume-kbd-toggle
|
||||
X-Enlightenment-ModuleType=system
|
||||
Comment=<title>Illume Keyboard Toggle for Embedded</title>
|
||||
Comment[fr]=<title>Illume pour l'embarqué – Keyboard Toggle</title>
|
||||
Comment[it]=<title>Illume per sistemi embedded – modulo Keyboard-toggle</title>
|
|
@ -0,0 +1,40 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
SUBDIRS = keyboards dicts
|
||||
MODULE = illume-keyboard
|
||||
|
||||
# data files for the module
|
||||
filesdir = $(libdir)/enlightenment/modules/$(MODULE)
|
||||
files_DATA = \
|
||||
e-module-$(MODULE).edj module.desktop
|
||||
|
||||
EXTRA_DIST = $(files_DATA)
|
||||
|
||||
# the module .so file
|
||||
INCLUDES = -I. \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/modules/$(MODULE) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/modules \
|
||||
@e_cflags@
|
||||
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
|
||||
pkg_LTLIBRARIES = module.la
|
||||
module_la_SOURCES = e_mod_main.c \
|
||||
e_mod_main.h \
|
||||
e_kbd_int.c \
|
||||
e_kbd_int.h \
|
||||
e_kbd_dict.c \
|
||||
e_kbd_dict.h \
|
||||
e_kbd_buf.c \
|
||||
e_kbd_buf.h \
|
||||
e_kbd_send.c \
|
||||
e_kbd_send.h \
|
||||
e_mod_config.c \
|
||||
e_mod_config.h
|
||||
|
||||
module_la_LIBADD = @e_libs@ @dlopen_libs@
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
module_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
||||
uninstall:
|
||||
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)
|
|
@ -0,0 +1,9 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MODULE = illume-keyboard
|
||||
|
||||
filesdir = $(libdir)/enlightenment/modules/$(MODULE)/dicts
|
||||
files_DATA = \
|
||||
English_(US).dic \
|
||||
English_(US)_Small.dic
|
||||
|
||||
EXTRA_DIST = $(files_DATA)
|
|
@ -0,0 +1,573 @@
|
|||
#include "e.h"
|
||||
#include "e_kbd_buf.h"
|
||||
#include "e_kbd_dict.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
static E_Kbd_Buf_Layout *
|
||||
_e_kbd_buf_new(void)
|
||||
{
|
||||
E_Kbd_Buf_Layout *kbl;
|
||||
|
||||
kbl = E_NEW(E_Kbd_Buf_Layout, 1);
|
||||
kbl->ref =1;
|
||||
return kbl;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_buf_layout_ref(E_Kbd_Buf_Layout *kbl)
|
||||
{
|
||||
kbl->ref++;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_buf_layout_unref(E_Kbd_Buf_Layout *kbl)
|
||||
{
|
||||
kbl->ref--;
|
||||
if (kbl->ref > 0) return;
|
||||
while (kbl->keys)
|
||||
{
|
||||
E_Kbd_Buf_Key *ky;
|
||||
|
||||
ky = kbl->keys->data;
|
||||
if (ky->key) eina_stringshare_del(ky->key);
|
||||
if (ky->key_shift) eina_stringshare_del(ky->key_shift);
|
||||
if (ky->key_capslock) eina_stringshare_del(ky->key_capslock);
|
||||
free(ky);
|
||||
kbl->keys = eina_list_remove_list(kbl->keys, kbl->keys);
|
||||
}
|
||||
free(kbl);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_buf_string_matches_clear(E_Kbd_Buf *kb)
|
||||
{
|
||||
while (kb->string_matches)
|
||||
{
|
||||
if (kb->string_matches->data)
|
||||
eina_stringshare_del(kb->string_matches->data);
|
||||
kb->string_matches = eina_list_remove_list(kb->string_matches, kb->string_matches);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_buf_actual_string_clear(E_Kbd_Buf *kb)
|
||||
{
|
||||
if (kb->actual_string) eina_stringshare_del(kb->actual_string);
|
||||
kb->actual_string = NULL;
|
||||
}
|
||||
|
||||
static E_Kbd_Buf_Key *
|
||||
_e_kbd_buf_at_coord_get(E_Kbd_Buf *kb, E_Kbd_Buf_Layout *kbl, int x, int y)
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
for (l = kbl->keys; l; l = l->next)
|
||||
{
|
||||
E_Kbd_Buf_Key *ky;
|
||||
|
||||
ky = l->data;
|
||||
if (ky->key)
|
||||
{
|
||||
if ((x >= ky->x) && (y >= ky->y) &&
|
||||
(x < (ky->x + ky->w)) && (y < (ky->y + ky->h)))
|
||||
return ky;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static E_Kbd_Buf_Key *
|
||||
_e_kbd_buf_closest_get(E_Kbd_Buf *kb, E_Kbd_Buf_Layout *kbl, int x, int y)
|
||||
{
|
||||
Eina_List *l;
|
||||
E_Kbd_Buf_Key *ky_closest = NULL;
|
||||
int dist_closest = 0x7fffffff;
|
||||
|
||||
for (l = kbl->keys; l; l = l->next)
|
||||
{
|
||||
E_Kbd_Buf_Key *ky;
|
||||
int dist, dx, dy;
|
||||
|
||||
ky = l->data;
|
||||
if (ky->key)
|
||||
{
|
||||
dx = x - (ky->x + (ky->w / 2));
|
||||
dy = y - (ky->y + (ky->h / 2));
|
||||
dist = (dx * dx) + (dy * dy);
|
||||
if (dist < dist_closest)
|
||||
{
|
||||
ky_closest = ky;
|
||||
dist_closest = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ky_closest;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_e_kbd_buf_keystroke_key_string_get(E_Kbd_Buf *kb, E_Kbd_Buf_Keystroke *ks, E_Kbd_Buf_Key *ky)
|
||||
{
|
||||
const char *str = NULL;
|
||||
|
||||
if ((ky) && (ky->key))
|
||||
{
|
||||
if (ks->shift)
|
||||
{
|
||||
if (ky->key_shift) str = ky->key_shift;
|
||||
else str = ky->key;
|
||||
}
|
||||
else if (ks->capslock)
|
||||
{
|
||||
if (ky->key_capslock) str = ky->key_capslock;
|
||||
else str = ky->key;
|
||||
}
|
||||
else str = ky->key;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_e_kbd_buf_keystroke_string_get(E_Kbd_Buf *kb, E_Kbd_Buf_Keystroke *ks)
|
||||
{
|
||||
const char *str = NULL;
|
||||
|
||||
if (ks->key) str = ks->key;
|
||||
else
|
||||
{
|
||||
E_Kbd_Buf_Key *ky;
|
||||
|
||||
ky = _e_kbd_buf_at_coord_get(kb, ks->layout, ks->x, ks->y);
|
||||
if (!ky) ky = _e_kbd_buf_closest_get(kb, ks->layout, ks->x, ks->y);
|
||||
str = _e_kbd_buf_keystroke_key_string_get(kb, ks, ky);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_buf_actual_string_update(E_Kbd_Buf *kb)
|
||||
{
|
||||
Eina_List *l;
|
||||
char *actual = NULL;
|
||||
int actual_len = 0;
|
||||
int actual_size = 0;
|
||||
|
||||
_e_kbd_buf_actual_string_clear(kb);
|
||||
for (l = kb->keystrokes; l; l = l->next)
|
||||
{
|
||||
E_Kbd_Buf_Keystroke *ks;
|
||||
const char *str;
|
||||
|
||||
ks = l->data;
|
||||
str = _e_kbd_buf_keystroke_string_get(kb, ks);
|
||||
if (str)
|
||||
{
|
||||
if ((actual_len + strlen(str) + 1) > actual_size)
|
||||
{
|
||||
actual_size += 64;
|
||||
actual = realloc(actual, actual_size);
|
||||
}
|
||||
strcpy(actual + actual_len, str);
|
||||
actual_len += strlen(str);
|
||||
}
|
||||
}
|
||||
if (actual)
|
||||
{
|
||||
kb->actual_string = eina_stringshare_add(actual);
|
||||
if (actual) free(actual);
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
_e_kbd_buf_matches_find(Eina_List *matches, const char *s)
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
for (l = matches; l; l = l->next)
|
||||
{
|
||||
if (!strcmp(l->data, s)) return s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_buf_matches_update(E_Kbd_Buf *kb)
|
||||
{
|
||||
Eina_List *matches = NULL;
|
||||
const char *word;
|
||||
int pri, i;
|
||||
E_Kbd_Dict *dicts[3];
|
||||
|
||||
_e_kbd_buf_string_matches_clear(kb);
|
||||
dicts[0] = kb->dict.personal;
|
||||
dicts[1] = kb->dict.sys;
|
||||
dicts[2] = kb->dict.data;
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
if (!dicts[i]) continue;
|
||||
e_kbd_dict_matches_lookup(dicts[i]);
|
||||
e_kbd_dict_matches_first(dicts[i]);
|
||||
for (;;)
|
||||
{
|
||||
word = e_kbd_dict_matches_match_get(dicts[i], &pri);
|
||||
if (!word) break;
|
||||
if (!_e_kbd_buf_matches_find(kb->string_matches, word))
|
||||
kb->string_matches = eina_list_append(kb->string_matches,
|
||||
eina_stringshare_add(word));
|
||||
e_kbd_dict_matches_next(dicts[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_e_kbd_buf_cb_data_dict_reload(void *data)
|
||||
{
|
||||
E_Kbd_Buf *kb;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
kb = data;
|
||||
kb->dict.data_reload_delay = NULL;
|
||||
e_kbd_buf_clear(kb);
|
||||
if (kb->dict.data) e_kbd_dict_free(kb->dict.data);
|
||||
e_user_dir_concat_static(buf, "dicts-dynamic/data.dic");
|
||||
kb->dict.data = e_kbd_dict_new(buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_buf_cb_data_dict_change(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path)
|
||||
{
|
||||
E_Kbd_Buf *kb;
|
||||
|
||||
kb = data;
|
||||
if (kb->dict.data_reload_delay) ecore_timer_del(kb->dict.data_reload_delay);
|
||||
kb->dict.data_reload_delay = ecore_timer_add(2.0, _e_kbd_buf_cb_data_dict_reload, kb);
|
||||
}
|
||||
|
||||
EAPI E_Kbd_Buf *
|
||||
e_kbd_buf_new(const char *sysdicts, const char *dict)
|
||||
{
|
||||
E_Kbd_Buf *kb;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
kb = E_NEW(E_Kbd_Buf, 1);
|
||||
if (!kb) return NULL;
|
||||
kb->sysdicts = eina_stringshare_add(sysdicts);
|
||||
|
||||
e_user_dir_concat_static(buf, "dicts");
|
||||
if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
|
||||
|
||||
e_user_dir_snprintf(buf, sizeof(buf), "dicts/%s", dict);
|
||||
kb->dict.sys = e_kbd_dict_new(buf);
|
||||
if (!kb->dict.sys)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s/dicts/%s", kb->sysdicts, dict);
|
||||
kb->dict.sys = e_kbd_dict_new(buf);
|
||||
}
|
||||
|
||||
e_user_dir_concat_static(buf, "dicts-dynamic");
|
||||
if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
|
||||
|
||||
e_user_dir_concat_static(buf, "dicts-dynamic/personal.dic");
|
||||
kb->dict.personal = e_kbd_dict_new(buf);
|
||||
if (!kb->dict.personal)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = fopen(buf, "w");
|
||||
if (f)
|
||||
{
|
||||
fprintf(f, "\n");
|
||||
fclose(f);
|
||||
}
|
||||
kb->dict.personal = e_kbd_dict_new(buf);
|
||||
}
|
||||
e_user_dir_concat_static(buf, "dicts-dynamic/data.dic");
|
||||
kb->dict.data = e_kbd_dict_new(buf);
|
||||
kb->dict.data_monitor =
|
||||
ecore_file_monitor_add(buf, _e_kbd_buf_cb_data_dict_change, kb);
|
||||
return kb;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_free(E_Kbd_Buf *kb)
|
||||
{
|
||||
e_kbd_buf_clear(kb);
|
||||
e_kbd_buf_layout_clear(kb);
|
||||
e_kbd_buf_lookup_cancel(kb);
|
||||
eina_stringshare_del(kb->sysdicts);
|
||||
if (kb->dict.sys) e_kbd_dict_free(kb->dict.sys);
|
||||
if (kb->dict.personal) e_kbd_dict_free(kb->dict.personal);
|
||||
if (kb->dict.data) e_kbd_dict_free(kb->dict.data);
|
||||
if (kb->dict.data_monitor) ecore_file_monitor_del(kb->dict.data_monitor);
|
||||
if (kb->dict.data_reload_delay) ecore_timer_del(kb->dict.data_reload_delay);
|
||||
free(kb);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_dict_set(E_Kbd_Buf *kb, const char *dict)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
|
||||
e_kbd_buf_clear(kb);
|
||||
|
||||
if (kb->dict.sys) e_kbd_dict_free(kb->dict.sys);
|
||||
|
||||
e_user_dir_concat_static(buf, "dicts");
|
||||
if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
|
||||
|
||||
e_user_dir_snprintf(buf, sizeof(buf), "dicts/%s", dict);
|
||||
kb->dict.sys = e_kbd_dict_new(buf);
|
||||
if (!kb->dict.sys)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s/dicts/%s", kb->sysdicts, dict);
|
||||
kb->dict.sys = e_kbd_dict_new(buf);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_clear(E_Kbd_Buf *kb)
|
||||
{
|
||||
e_kbd_buf_lookup_cancel(kb);
|
||||
while (kb->keystrokes)
|
||||
{
|
||||
E_Kbd_Buf_Keystroke *ks;
|
||||
|
||||
ks = kb->keystrokes->data;
|
||||
if (ks->key) eina_stringshare_del(ks->key);
|
||||
_e_kbd_buf_layout_unref(ks->layout);
|
||||
free(ks);
|
||||
kb->keystrokes = eina_list_remove_list(kb->keystrokes, kb->keystrokes);
|
||||
}
|
||||
_e_kbd_buf_string_matches_clear(kb);
|
||||
if (kb->dict.sys) e_kbd_dict_word_letter_clear(kb->dict.sys);
|
||||
if (kb->dict.personal) e_kbd_dict_word_letter_clear(kb->dict.personal);
|
||||
if (kb->dict.data) e_kbd_dict_word_letter_clear(kb->dict.data);
|
||||
_e_kbd_buf_actual_string_clear(kb);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_layout_clear(E_Kbd_Buf *kb)
|
||||
{
|
||||
if (kb->layout)
|
||||
{
|
||||
_e_kbd_buf_layout_unref(kb->layout);
|
||||
kb->layout = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_layout_size_set(E_Kbd_Buf *kb, int w, int h)
|
||||
{
|
||||
if (!kb->layout) kb->layout = _e_kbd_buf_new();
|
||||
if (!kb->layout) return;
|
||||
kb->layout->w = w;
|
||||
kb->layout->h = h;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_layout_fuzz_set(E_Kbd_Buf *kb, int fuzz)
|
||||
{
|
||||
if (!kb->layout) kb->layout = _e_kbd_buf_new();
|
||||
if (!kb->layout) return;
|
||||
kb->layout->fuzz = fuzz;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_layout_key_add(E_Kbd_Buf *kb, const char *key, const char *key_shift, const char *key_capslock, int x, int y, int w, int h)
|
||||
{
|
||||
E_Kbd_Buf_Key *ky;
|
||||
|
||||
if (!key) return;
|
||||
if (!kb->layout) kb->layout = _e_kbd_buf_new();
|
||||
if (!kb->layout) return;
|
||||
ky = E_NEW(E_Kbd_Buf_Key, 1);
|
||||
if (!ky) return;
|
||||
if (key) ky->key = eina_stringshare_add(key);
|
||||
if (key_shift) ky->key_shift = eina_stringshare_add(key_shift);
|
||||
if (key_capslock) ky->key_capslock = eina_stringshare_add(key_capslock);
|
||||
ky->x = x;
|
||||
ky->y = y;
|
||||
ky->w = w;
|
||||
ky->h = h;
|
||||
kb->layout->keys = eina_list_append(kb->layout->keys, ky);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_buf_keystroke_add(E_Kbd_Buf *kb, E_Kbd_Buf_Keystroke *ks)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
str = _e_kbd_buf_keystroke_string_get(kb, ks);
|
||||
if (str)
|
||||
{
|
||||
if (kb->dict.sys) e_kbd_dict_word_letter_add(kb->dict.sys, str, 0);
|
||||
if (kb->dict.personal) e_kbd_dict_word_letter_add(kb->dict.personal, str, 0);
|
||||
if (kb->dict.data) e_kbd_dict_word_letter_add(kb->dict.data, str, 0);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_pressed_key_add(E_Kbd_Buf *kb, const char *key, int shift, int capslock)
|
||||
{
|
||||
E_Kbd_Buf_Keystroke *ks;
|
||||
|
||||
e_kbd_buf_lookup_cancel(kb);
|
||||
if (!key) return;
|
||||
if (!kb->layout) kb->layout = _e_kbd_buf_new();
|
||||
if (!kb->layout) return;
|
||||
ks = E_NEW(E_Kbd_Buf_Keystroke, 1);
|
||||
if (!ks) return;
|
||||
ks->key = eina_stringshare_add(key);
|
||||
if (shift) ks->shift = 1;
|
||||
if (capslock) ks->capslock = 1;
|
||||
ks->layout = kb->layout;
|
||||
_e_kbd_buf_layout_ref(ks->layout);
|
||||
kb->keystrokes = eina_list_append(kb->keystrokes, ks);
|
||||
|
||||
if (kb->dict.sys) e_kbd_dict_word_letter_advance(kb->dict.sys);
|
||||
if (kb->dict.personal) e_kbd_dict_word_letter_advance(kb->dict.personal);
|
||||
if (kb->dict.data) e_kbd_dict_word_letter_advance(kb->dict.data);
|
||||
_e_kbd_buf_keystroke_add(kb, ks);
|
||||
|
||||
_e_kbd_buf_actual_string_update(kb);
|
||||
_e_kbd_buf_matches_update(kb);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_buf_keystroke_point_add(E_Kbd_Buf *kb, E_Kbd_Buf_Keystroke *ks)
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
for (l = ks->layout->keys; l; l = l->next)
|
||||
{
|
||||
E_Kbd_Buf_Key *ky;
|
||||
const char *str;
|
||||
int px, py, dx, dy, d, fuzz;
|
||||
|
||||
ky = l->data;
|
||||
px = ky->x + (ky->w / 2);
|
||||
py = ky->y + (ky->h / 2);
|
||||
dx = ks->x - px;
|
||||
dy = ks->y - py;
|
||||
d = sqrt((dx * dx) + (dy * dy));
|
||||
if (d <= ks->layout->fuzz)
|
||||
{
|
||||
str = _e_kbd_buf_keystroke_key_string_get(kb, ks, ky);
|
||||
if (str)
|
||||
{
|
||||
if (kb->dict.sys) e_kbd_dict_word_letter_add(kb->dict.sys, str, d);
|
||||
if (kb->dict.personal) e_kbd_dict_word_letter_add(kb->dict.personal, str, d);
|
||||
if (kb->dict.data) e_kbd_dict_word_letter_add(kb->dict.data, str, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_pressed_point_add(E_Kbd_Buf *kb, int x, int y, int shift, int capslock)
|
||||
{
|
||||
E_Kbd_Buf_Keystroke *ks;
|
||||
|
||||
e_kbd_buf_lookup_cancel(kb);
|
||||
if (!kb->layout) kb->layout = _e_kbd_buf_new();
|
||||
if (!kb->layout) return;
|
||||
ks = E_NEW(E_Kbd_Buf_Keystroke, 1);
|
||||
if (!ks) return;
|
||||
ks->x = x;
|
||||
ks->y = y;
|
||||
if (shift) ks->shift = 1;
|
||||
if (capslock) ks->capslock = 1;
|
||||
ks->layout = kb->layout;
|
||||
_e_kbd_buf_layout_ref(ks->layout);
|
||||
kb->keystrokes = eina_list_append(kb->keystrokes, ks);
|
||||
|
||||
if (kb->dict.sys) e_kbd_dict_word_letter_advance(kb->dict.sys);
|
||||
if (kb->dict.personal) e_kbd_dict_word_letter_advance(kb->dict.personal);
|
||||
if (kb->dict.data) e_kbd_dict_word_letter_advance(kb->dict.data);
|
||||
|
||||
_e_kbd_buf_keystroke_point_add(kb, ks);
|
||||
|
||||
_e_kbd_buf_actual_string_update(kb);
|
||||
_e_kbd_buf_matches_update(kb);
|
||||
}
|
||||
|
||||
EAPI const char *
|
||||
e_kbd_buf_actual_string_get(E_Kbd_Buf *kb)
|
||||
{
|
||||
return kb->actual_string;
|
||||
}
|
||||
|
||||
EAPI const Eina_List *
|
||||
e_kbd_buf_string_matches_get(E_Kbd_Buf *kb)
|
||||
{
|
||||
return kb->string_matches;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_backspace(E_Kbd_Buf *kb)
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
l = eina_list_last(kb->keystrokes);
|
||||
if (l)
|
||||
{
|
||||
E_Kbd_Buf_Keystroke *ks;
|
||||
|
||||
ks = l->data;
|
||||
if (ks->key) eina_stringshare_del(ks->key);
|
||||
_e_kbd_buf_layout_unref(ks->layout);
|
||||
free(ks);
|
||||
kb->keystrokes = eina_list_remove_list(kb->keystrokes, l);
|
||||
if (kb->dict.sys) e_kbd_dict_word_letter_delete(kb->dict.sys);
|
||||
if (kb->dict.personal) e_kbd_dict_word_letter_delete(kb->dict.personal);
|
||||
if (kb->dict.data) e_kbd_dict_word_letter_delete(kb->dict.data);
|
||||
_e_kbd_buf_actual_string_update(kb);
|
||||
_e_kbd_buf_matches_update(kb);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_word_use(E_Kbd_Buf *kb, const char *word)
|
||||
{
|
||||
if (kb->dict.personal)
|
||||
e_kbd_dict_word_usage_adjust(kb->dict.personal, word, 1);
|
||||
}
|
||||
|
||||
// FIXME: just faking delayed lookup with timer
|
||||
static int
|
||||
_e_kbd_buf_cb_faket(void *data)
|
||||
{
|
||||
E_Kbd_Buf *kb;
|
||||
|
||||
kb = data;
|
||||
kb->lookup.faket = NULL;
|
||||
kb->lookup.func((void *)kb->lookup.data);
|
||||
kb->lookup.func = NULL;
|
||||
kb->lookup.data = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_lookup(E_Kbd_Buf *kb, void (*func) (void *data), const void *data)
|
||||
{
|
||||
e_kbd_buf_lookup_cancel(kb);
|
||||
|
||||
kb->lookup.func = func;
|
||||
kb->lookup.data = data;
|
||||
|
||||
// FIXME: just faking delayed lookup with timer
|
||||
kb->lookup.faket = ecore_timer_add(0.1, _e_kbd_buf_cb_faket, kb);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_buf_lookup_cancel(E_Kbd_Buf *kb)
|
||||
{
|
||||
// FIXME: just faking delayed lookup with timer
|
||||
if (!kb->lookup.faket) return;
|
||||
ecore_timer_del(kb->lookup.faket);
|
||||
kb->lookup.faket = NULL;
|
||||
|
||||
kb->lookup.func = NULL;
|
||||
kb->lookup.data = NULL;
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
#ifndef E_KBD_BUF_H
|
||||
#define E_KBD_BUF_H
|
||||
|
||||
#include "e_kbd_dict.h"
|
||||
|
||||
typedef struct _E_Kbd_Buf E_Kbd_Buf;
|
||||
typedef struct _E_Kbd_Buf_Key E_Kbd_Buf_Key;
|
||||
typedef struct _E_Kbd_Buf_Keystroke E_Kbd_Buf_Keystroke;
|
||||
typedef struct _E_Kbd_Buf_Layout E_Kbd_Buf_Layout;
|
||||
|
||||
struct _E_Kbd_Buf
|
||||
{
|
||||
const char *sysdicts;
|
||||
Eina_List *keystrokes;
|
||||
Eina_List *string_matches;
|
||||
const char *actual_string;
|
||||
E_Kbd_Buf_Layout *layout;
|
||||
struct {
|
||||
void (*func) (void *data);
|
||||
const void *data;
|
||||
// FIXME: just faking delayed lookup with timer
|
||||
Ecore_Timer *faket;
|
||||
} lookup;
|
||||
struct {
|
||||
E_Kbd_Dict *sys;
|
||||
E_Kbd_Dict *personal;
|
||||
E_Kbd_Dict *data;
|
||||
Ecore_File_Monitor *data_monitor;
|
||||
Ecore_Timer *data_reload_delay;
|
||||
} dict;
|
||||
};
|
||||
|
||||
struct _E_Kbd_Buf_Key
|
||||
{
|
||||
int x, y, w, h;
|
||||
const char *key, *key_shift, *key_capslock;
|
||||
};
|
||||
|
||||
struct _E_Kbd_Buf_Keystroke
|
||||
{
|
||||
const char *key;
|
||||
int x, y;
|
||||
E_Kbd_Buf_Layout *layout;
|
||||
unsigned char shift : 1;
|
||||
unsigned char capslock : 1;
|
||||
};
|
||||
|
||||
struct _E_Kbd_Buf_Layout {
|
||||
int ref;
|
||||
int w, h;
|
||||
int fuzz;
|
||||
Eina_List *keys;
|
||||
};
|
||||
|
||||
EAPI E_Kbd_Buf *e_kbd_buf_new(const char *sysdicts, const char *dicts);
|
||||
EAPI void e_kbd_buf_free(E_Kbd_Buf *kb);
|
||||
EAPI void e_kbd_buf_dict_set(E_Kbd_Buf *kb, const char *dict);
|
||||
EAPI void e_kbd_buf_clear(E_Kbd_Buf *kb);
|
||||
EAPI void e_kbd_buf_layout_clear(E_Kbd_Buf *kb);
|
||||
EAPI void e_kbd_buf_layout_size_set(E_Kbd_Buf *kb, int w, int h);
|
||||
EAPI void e_kbd_buf_layout_fuzz_set(E_Kbd_Buf *kb, int fuzz);
|
||||
EAPI void e_kbd_buf_layout_key_add(E_Kbd_Buf *kb, const char *key, const char *key_shift, const char *key_capslock, int x, int y, int w, int h);
|
||||
EAPI void e_kbd_buf_pressed_key_add(E_Kbd_Buf *kb, const char *key, int shift, int capslock);
|
||||
EAPI void e_kbd_buf_pressed_point_add(E_Kbd_Buf *kb, int x, int y, int shift, int capslock);
|
||||
EAPI const char *e_kbd_buf_actual_string_get(E_Kbd_Buf *kb);
|
||||
EAPI const Eina_List *e_kbd_buf_string_matches_get(E_Kbd_Buf *kb);
|
||||
EAPI void e_kbd_buf_backspace(E_Kbd_Buf *kb);
|
||||
EAPI void e_kbd_buf_lookup(E_Kbd_Buf *kb, void (*func) (void *data), const void *data);
|
||||
EAPI void e_kbd_buf_lookup_cancel(E_Kbd_Buf *kb);
|
||||
EAPI void e_kbd_buf_word_use(E_Kbd_Buf *kb, const char *word);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,861 @@
|
|||
#include "e.h"
|
||||
#include "e_kbd_dict.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#define MAXLATIN 0x100
|
||||
|
||||
static unsigned char _e_kbd_normalise_base[MAXLATIN];
|
||||
static unsigned char _e_kbd_normalise_ready = 0;
|
||||
|
||||
static void
|
||||
_e_kbd_normalise_init(void)
|
||||
{
|
||||
int i;
|
||||
const char *table[][2] =
|
||||
{
|
||||
{"À", "a"},
|
||||
{"Á", "a"},
|
||||
{"Â", "a"},
|
||||
{"Ã", "a"},
|
||||
{"Ä", "a"},
|
||||
{"Å", "a"},
|
||||
{"Æ", "a"},
|
||||
{"Ç", "c"},
|
||||
{"È", "e"},
|
||||
{"É", "e"},
|
||||
{"Ê", "e"},
|
||||
{"Ë", "e"},
|
||||
{"Ì", "i"},
|
||||
{"Í", "i"},
|
||||
{"Î", "i"},
|
||||
{"Ï", "i"},
|
||||
{"Ð", "d"},
|
||||
{"Ñ", "n"},
|
||||
{"Ò", "o"},
|
||||
{"Ó", "o"},
|
||||
{"Ô", "o"},
|
||||
{"Õ", "o"},
|
||||
{"Ö", "o"},
|
||||
{"×", "x"},
|
||||
{"Ø", "o"},
|
||||
{"Ù", "u"},
|
||||
{"Ú", "u"},
|
||||
{"Û", "u"},
|
||||
{"Ü", "u"},
|
||||
{"Ý", "y"},
|
||||
{"Þ", "p"},
|
||||
{"ß", "s"},
|
||||
{"à", "a"},
|
||||
{"á", "a"},
|
||||
{"â", "a"},
|
||||
{"ã", "a"},
|
||||
{"ä", "a"},
|
||||
{"å", "a"},
|
||||
{"æ", "a"},
|
||||
{"ç", "c"},
|
||||
{"è", "e"},
|
||||
{"é", "e"},
|
||||
{"ê", "e"},
|
||||
{"ë", "e"},
|
||||
{"ì", "i"},
|
||||
{"í", "i"},
|
||||
{"î", "i"},
|
||||
{"ï", "i"},
|
||||
{"ð", "o"},
|
||||
{"ñ", "n"},
|
||||
{"ò", "o"},
|
||||
{"ó", "o"},
|
||||
{"ô", "o"},
|
||||
{"õ", "o"},
|
||||
{"ö", "o"},
|
||||
{"ø", "o"},
|
||||
{"ù", "u"},
|
||||
{"ú", "u"},
|
||||
{"û", "u"},
|
||||
{"ü", "u"},
|
||||
{"ý", "y"},
|
||||
{"þ", "p"},
|
||||
{"ÿ", "y"}
|
||||
}; // 63 items
|
||||
|
||||
if (_e_kbd_normalise_ready) return;
|
||||
_e_kbd_normalise_ready = 1;
|
||||
for (i = 0; i < 128; i++)
|
||||
_e_kbd_normalise_base[i] = tolower(i);
|
||||
for (;i < MAXLATIN; i++)
|
||||
{
|
||||
int glyph, j;
|
||||
|
||||
for (j = 0; j < 63; j++)
|
||||
{
|
||||
evas_string_char_next_get(table[j][0], 0, &glyph);
|
||||
if (glyph == i)
|
||||
{
|
||||
_e_kbd_normalise_base[i] = *table[j][1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_e_kbd_dict_letter_normalise(int glyph)
|
||||
{
|
||||
// FIXME: ö -> o, ä -> a, Ó -> o etc. - ie normalise to latin-1
|
||||
if (glyph < MAXLATIN) return _e_kbd_normalise_base[glyph];
|
||||
return tolower(glyph) & 0x7f;
|
||||
}
|
||||
|
||||
static int
|
||||
_e_kbd_dict_normalized_strncmp(const char *a, const char *b, int len)
|
||||
{
|
||||
// FIXME: normalise 2 strings and then compare
|
||||
if (len < 0) return strcasecmp(a, b);
|
||||
return strncasecmp(a, b, len);
|
||||
}
|
||||
|
||||
static int
|
||||
_e_kbd_dict_normalized_strcmp(const char *a, const char *b)
|
||||
{
|
||||
return _e_kbd_dict_normalized_strncmp(a, b, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_dict_normalized_strcpy(char *dst, const char *src)
|
||||
{
|
||||
const char *p;
|
||||
char *d;
|
||||
|
||||
for (p = src, d = dst; *p; p++, d++)
|
||||
*d = _e_kbd_dict_letter_normalise(*p);
|
||||
*d = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_e_kbd_dict_matches_lookup_cb_sort(const void *d1, const void *d2)
|
||||
{
|
||||
const E_Kbd_Dict_Word *kw1, *kw2;
|
||||
|
||||
kw1 = d1;
|
||||
kw2 = d2;
|
||||
if (kw1->usage < kw2->usage) return 1;
|
||||
else if (kw1->usage > kw2->usage) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_e_kbd_dict_writes_cb_sort(const void *d1, const void *d2)
|
||||
{
|
||||
const E_Kbd_Dict_Word *kw1, *kw2;
|
||||
|
||||
kw1 = d1;
|
||||
kw2 = d2;
|
||||
return _e_kbd_dict_normalized_strcmp(kw1->word, kw2->word);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_e_kbd_dict_line_next(E_Kbd_Dict *kd, const char *p)
|
||||
{
|
||||
const char *e, *pp;
|
||||
|
||||
e = kd->file.dict + kd->file.size;
|
||||
for (pp = p; pp < e; pp++)
|
||||
if (*pp == '\n') return pp + 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
_e_kbd_dict_line_parse(E_Kbd_Dict *kd, const char *p, int *usage)
|
||||
{
|
||||
const char *ps;
|
||||
char *wd = NULL;
|
||||
|
||||
for (ps = p; !isspace(*ps); ps++);
|
||||
wd = malloc(ps - p + 1);
|
||||
if (!wd) return NULL;
|
||||
strncpy(wd, p, ps - p);
|
||||
wd[ps - p] = 0;
|
||||
if (*ps == '\n') *usage = 0;
|
||||
else
|
||||
{
|
||||
ps++;
|
||||
*usage = atoi(ps);
|
||||
}
|
||||
return wd;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_dict_lookup_build_line(E_Kbd_Dict *kd, const char *p, const char *eol, int *glyphs)
|
||||
{
|
||||
char *s;
|
||||
int p2;
|
||||
|
||||
s = alloca(eol - p + 1);
|
||||
strncpy(s, p, eol - p);
|
||||
s[eol - p] = 0;
|
||||
p2 = evas_string_char_next_get(s, 0, &(glyphs[0]));
|
||||
if ((p2 > 0) && (glyphs[0] > 0))
|
||||
p2 = evas_string_char_next_get(s, p2, &(glyphs[1]));
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_dict_lookup_build(E_Kbd_Dict *kd)
|
||||
{
|
||||
const char *p, *e, *eol;
|
||||
int glyphs[2], pglyphs[2];
|
||||
|
||||
p = kd->file.dict;
|
||||
e = p + kd->file.size;
|
||||
pglyphs[0] = pglyphs[1] = 0;
|
||||
while (p < e)
|
||||
{
|
||||
eol = strchr(p, '\n');
|
||||
if (!eol) break;
|
||||
if (eol > p)
|
||||
{
|
||||
glyphs[0] = glyphs[1] = 0;
|
||||
_e_kbd_dict_lookup_build_line(kd, p, eol, glyphs);
|
||||
if ((glyphs[1] != pglyphs[1]) || (glyphs[0] != pglyphs[0]))
|
||||
{
|
||||
int v1, v2;
|
||||
|
||||
if (isspace(glyphs[0]))
|
||||
{
|
||||
glyphs[0] = 0;
|
||||
glyphs[1] = 0;
|
||||
}
|
||||
else if (isspace(glyphs[1]))
|
||||
glyphs[1] = 0;
|
||||
if (glyphs[0] == 0)
|
||||
{
|
||||
pglyphs[0] = pglyphs[1] = 0;
|
||||
p = eol + 1;
|
||||
continue;
|
||||
}
|
||||
v1 = _e_kbd_dict_letter_normalise(glyphs[0]);
|
||||
v2 = _e_kbd_dict_letter_normalise(glyphs[1]);
|
||||
if (!kd->lookup.tuples[v1][v2])
|
||||
kd->lookup.tuples[v1][v2] = p;
|
||||
pglyphs[0] = v1;
|
||||
pglyphs[1] = v2;
|
||||
}
|
||||
}
|
||||
p = eol + 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_e_kbd_dict_open(E_Kbd_Dict *kd)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
kd->file.fd = open(kd->file.file, O_RDONLY);
|
||||
if (kd->file.fd < 0) return 0;
|
||||
if (fstat(kd->file.fd, &st) < 0)
|
||||
{
|
||||
close(kd->file.fd);
|
||||
return 0;
|
||||
}
|
||||
kd->file.size = st.st_size;
|
||||
kd->file.dict = mmap(NULL, kd->file.size, PROT_READ, MAP_SHARED,
|
||||
kd->file.fd, 0);
|
||||
if ((kd->file.dict== MAP_FAILED) || (kd->file.dict == NULL))
|
||||
{
|
||||
close(kd->file.fd);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_dict_close(E_Kbd_Dict *kd)
|
||||
{
|
||||
if (kd->file.fd < 0) return;
|
||||
memset(kd->lookup.tuples, 0, sizeof(kd->lookup.tuples));
|
||||
munmap((void *)kd->file.dict, kd->file.size);
|
||||
close(kd->file.fd);
|
||||
kd->file.fd = -1;
|
||||
kd->file.dict = NULL;
|
||||
kd->file.size = 0;
|
||||
}
|
||||
|
||||
EAPI E_Kbd_Dict *
|
||||
e_kbd_dict_new(const char *file)
|
||||
{
|
||||
// alloc and load new dict - build quick-lookup table. words MUST be sorted
|
||||
E_Kbd_Dict *kd;
|
||||
|
||||
_e_kbd_normalise_init();
|
||||
kd = E_NEW(E_Kbd_Dict, 1);
|
||||
if (!kd) return NULL;
|
||||
kd->file.file = eina_stringshare_add(file);
|
||||
if (!kd->file.file)
|
||||
{
|
||||
free(kd);
|
||||
return NULL;
|
||||
}
|
||||
kd->file.fd = -1;
|
||||
if (!_e_kbd_dict_open(kd))
|
||||
{
|
||||
eina_stringshare_del(kd->file.file);
|
||||
free(kd);
|
||||
return NULL;
|
||||
}
|
||||
_e_kbd_dict_lookup_build(kd);
|
||||
return kd;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_dict_free(E_Kbd_Dict *kd)
|
||||
{
|
||||
// free dict and anything in it
|
||||
e_kbd_dict_word_letter_clear(kd);
|
||||
e_kbd_dict_save(kd);
|
||||
_e_kbd_dict_close(kd);
|
||||
free(kd);
|
||||
}
|
||||
|
||||
static E_Kbd_Dict_Word *
|
||||
_e_kbd_dict_changed_write_find(E_Kbd_Dict *kd, const char *word)
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
for (l = kd->changed.writes; l; l = l->next)
|
||||
{
|
||||
E_Kbd_Dict_Word *kw;
|
||||
|
||||
kw = l->data;
|
||||
if (!strcmp(kw->word, word)) return kw;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_dict_save(E_Kbd_Dict *kd)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
// save any changes (new words added, usage adjustments).
|
||||
// all words MUST be sorted
|
||||
if (!kd->changed.writes) return;
|
||||
if (kd->changed.flush_timer)
|
||||
{
|
||||
ecore_timer_del(kd->changed.flush_timer);
|
||||
kd->changed.flush_timer = NULL;
|
||||
}
|
||||
ecore_file_unlink(kd->file.file);
|
||||
f = fopen(kd->file.file, "w");
|
||||
kd->changed.writes = eina_list_sort(kd->changed.writes,
|
||||
eina_list_count(kd->changed.writes),
|
||||
_e_kbd_dict_writes_cb_sort);
|
||||
if (f)
|
||||
{
|
||||
const char *p, *pn;
|
||||
|
||||
p = kd->file.dict;
|
||||
while (p)
|
||||
{
|
||||
char *wd;
|
||||
int usage = 0;
|
||||
|
||||
pn = _e_kbd_dict_line_next(kd, p);
|
||||
if (!pn) return;
|
||||
wd = _e_kbd_dict_line_parse(kd, p, &usage);
|
||||
if ((wd) && (strlen(wd) > 0))
|
||||
{
|
||||
if (kd->changed.writes)
|
||||
{
|
||||
int writeline = 0;
|
||||
|
||||
while (kd->changed.writes)
|
||||
{
|
||||
E_Kbd_Dict_Word *kw;
|
||||
int cmp;
|
||||
|
||||
kw = kd->changed.writes->data;
|
||||
cmp = _e_kbd_dict_normalized_strcmp(kw->word, wd);
|
||||
if (cmp < 0)
|
||||
{
|
||||
fprintf(f, "%s %i\n", kw->word, kw->usage);
|
||||
writeline = 1;
|
||||
eina_stringshare_del(kw->word);
|
||||
free(kw);
|
||||
kd->changed.writes = eina_list_remove_list(kd->changed.writes, kd->changed.writes);
|
||||
}
|
||||
else if (cmp == 0)
|
||||
{
|
||||
fprintf(f, "%s %i\n", wd, kw->usage);
|
||||
if (!strcmp(kw->word, wd))
|
||||
writeline = 0;
|
||||
else
|
||||
writeline = 1;
|
||||
eina_stringshare_del(kw->word);
|
||||
free(kw);
|
||||
kd->changed.writes = eina_list_remove_list(kd->changed.writes, kd->changed.writes);
|
||||
break;
|
||||
}
|
||||
else if (cmp > 0)
|
||||
{
|
||||
writeline = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (writeline)
|
||||
fprintf(f, "%s %i\n", wd, usage);
|
||||
}
|
||||
else
|
||||
fprintf(f, "%s %i\n", wd, usage);
|
||||
}
|
||||
if (wd) free(wd);
|
||||
p = pn;
|
||||
if (p >= (kd->file.dict + kd->file.size)) break;
|
||||
}
|
||||
while (kd->changed.writes)
|
||||
{
|
||||
E_Kbd_Dict_Word *kw;
|
||||
|
||||
kw = kd->changed.writes->data;
|
||||
fprintf(f, "%s %i\n", kw->word, kw->usage);
|
||||
eina_stringshare_del(kw->word);
|
||||
free(kw);
|
||||
kd->changed.writes = eina_list_remove_list(kd->changed.writes, kd->changed.writes);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
_e_kbd_dict_close(kd);
|
||||
if (_e_kbd_dict_open(kd)) _e_kbd_dict_lookup_build(kd);
|
||||
}
|
||||
|
||||
static int
|
||||
_e_kbd_dict_cb_save_flush(void *data)
|
||||
{
|
||||
E_Kbd_Dict *kd;
|
||||
|
||||
kd = data;
|
||||
if ((kd->matches.list) || (kd->word.letters) || (kd->matches.deadends) ||
|
||||
(kd->matches.leads))
|
||||
return 1;
|
||||
kd->changed.flush_timer = NULL;
|
||||
e_kbd_dict_save(kd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_dict_changed_write_add(E_Kbd_Dict *kd, const char *word, int usage)
|
||||
{
|
||||
E_Kbd_Dict_Word *kw;
|
||||
|
||||
kw = E_NEW(E_Kbd_Dict_Word, 1);
|
||||
kw->word = eina_stringshare_add(word);
|
||||
kw->usage = usage;
|
||||
kd->changed.writes = eina_list_prepend(kd->changed.writes, kw);
|
||||
if (eina_list_count(kd->changed.writes) > 64)
|
||||
e_kbd_dict_save(kd);
|
||||
else
|
||||
{
|
||||
if (kd->changed.flush_timer)
|
||||
ecore_timer_del(kd->changed.flush_timer);
|
||||
kd->changed.flush_timer =
|
||||
ecore_timer_add(5.0, _e_kbd_dict_cb_save_flush, kd);
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
_e_kbd_dict_find_pointer(E_Kbd_Dict *kd, const char *p, int baselen, const char *word)
|
||||
{
|
||||
const char *pn;
|
||||
int len;
|
||||
|
||||
if (!p) return NULL;
|
||||
len = strlen(word);
|
||||
while (p)
|
||||
{
|
||||
pn = _e_kbd_dict_line_next(kd, p);
|
||||
if (!pn) return NULL;
|
||||
if ((pn - p) > len)
|
||||
{
|
||||
if (!_e_kbd_dict_normalized_strncmp(p, word, len))
|
||||
return p;
|
||||
}
|
||||
if (_e_kbd_dict_normalized_strncmp(p, word, baselen))
|
||||
return NULL;
|
||||
p = pn;
|
||||
if (p >= (kd->file.dict + kd->file.size)) break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_e_kbd_dict_find(E_Kbd_Dict *kd, const char *word)
|
||||
{
|
||||
const char *p;
|
||||
char *tword;
|
||||
int glyphs[2], p2, v1, v2, i;
|
||||
|
||||
/* work backwards in leads. i.e.:
|
||||
* going
|
||||
* goin
|
||||
* goi
|
||||
* go
|
||||
* g
|
||||
*/
|
||||
tword = alloca(strlen(word) + 1);
|
||||
_e_kbd_dict_normalized_strcpy(tword, word);
|
||||
p = eina_hash_find(kd->matches.leads, tword);
|
||||
if (p) return p;
|
||||
p2 = strlen(tword);
|
||||
while (tword[0])
|
||||
{
|
||||
p2 = evas_string_char_prev_get(tword, p2, &i);
|
||||
if (p2 < 0) break;
|
||||
tword[p2] = 0;
|
||||
p = eina_hash_find(kd->matches.leads, tword);
|
||||
if (p)
|
||||
return _e_kbd_dict_find_pointer(kd, p, p2, word);
|
||||
}
|
||||
/* looking at leads going back letters didn't work */
|
||||
p = kd->file.dict;
|
||||
if ((p[0] == '\n') && (kd->file.size <= 1)) return NULL;
|
||||
glyphs[0] = glyphs[1] = 0;
|
||||
p2 = evas_string_char_next_get(word, 0, &(glyphs[0]));
|
||||
if ((p2 > 0) && (glyphs[0] > 0))
|
||||
p2 = evas_string_char_next_get(word, p2, &(glyphs[1]));
|
||||
v1 = _e_kbd_dict_letter_normalise(glyphs[0]);
|
||||
if (glyphs[1] != 0)
|
||||
{
|
||||
v2 = _e_kbd_dict_letter_normalise(glyphs[1]);
|
||||
p = kd->lookup.tuples[v1][v2];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
p = kd->lookup.tuples[v1][i];
|
||||
if (p) break;
|
||||
}
|
||||
}
|
||||
return _e_kbd_dict_find_pointer(kd, p, p2, word);
|
||||
}
|
||||
|
||||
static const char *
|
||||
_e_kbd_dict_find_full(E_Kbd_Dict *kd, const char *word)
|
||||
{
|
||||
const char *p;
|
||||
int len;
|
||||
|
||||
p = _e_kbd_dict_find(kd, word);
|
||||
if (!p) return NULL;
|
||||
len = strlen(word);
|
||||
if (isspace(p[len])) return p;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_dict_word_usage_adjust(E_Kbd_Dict *kd, const char *word, int adjust)
|
||||
{
|
||||
// add "adjust" to word usage count
|
||||
E_Kbd_Dict_Word *kw;
|
||||
|
||||
kw = _e_kbd_dict_changed_write_find(kd, word);
|
||||
if (kw)
|
||||
{
|
||||
kw->usage += adjust;
|
||||
if (kd->changed.flush_timer)
|
||||
ecore_timer_del(kd->changed.flush_timer);
|
||||
kd->changed.flush_timer = ecore_timer_add(5.0, _e_kbd_dict_cb_save_flush, kd);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *line;
|
||||
int usage = 0;
|
||||
|
||||
line = _e_kbd_dict_find_full(kd, word);
|
||||
if (line)
|
||||
{
|
||||
char *wd;
|
||||
|
||||
// FIXME: we need to find an EXACT line match - case and all
|
||||
wd = _e_kbd_dict_line_parse(kd, line, &usage);
|
||||
if (wd) free(wd);
|
||||
}
|
||||
usage += adjust;
|
||||
_e_kbd_dict_changed_write_add(kd, word, usage);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_dict_word_delete(E_Kbd_Dict *kd, const char *word)
|
||||
{
|
||||
// delete a word from the dictionary
|
||||
E_Kbd_Dict_Word *kw;
|
||||
|
||||
kw = _e_kbd_dict_changed_write_find(kd, word);
|
||||
if (kw)
|
||||
kw->usage = -1;
|
||||
else
|
||||
{
|
||||
if (_e_kbd_dict_find_full(kd, word))
|
||||
_e_kbd_dict_changed_write_add(kd, word, -1);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_dict_word_letter_clear(E_Kbd_Dict *kd)
|
||||
{
|
||||
// clear the current word buffer
|
||||
while (kd->word.letters)
|
||||
e_kbd_dict_word_letter_delete(kd);
|
||||
if (kd->matches.deadends)
|
||||
{
|
||||
eina_hash_free(kd->matches.deadends);
|
||||
kd->matches.deadends = NULL;
|
||||
}
|
||||
if (kd->matches.leads)
|
||||
{
|
||||
eina_hash_free(kd->matches.leads);
|
||||
kd->matches.leads = NULL;
|
||||
}
|
||||
while (kd->matches.list)
|
||||
{
|
||||
E_Kbd_Dict_Word *kw;
|
||||
|
||||
kw = kd->matches.list->data;
|
||||
eina_stringshare_del(kw->word);
|
||||
free(kw);
|
||||
kd->matches.list = eina_list_remove_list(kd->matches.list, kd->matches.list);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_dict_word_letter_add(E_Kbd_Dict *kd, const char *letter, int dist)
|
||||
{
|
||||
// add a letter with a distance (0 == closest) as an option for the current
|
||||
// letter position - advance starts a new letter position
|
||||
Eina_List *l, *list;
|
||||
E_Kbd_Dict_Letter *kl;
|
||||
|
||||
l = eina_list_last(kd->word.letters);
|
||||
if (!l) return;
|
||||
list = l->data;
|
||||
kl = E_NEW(E_Kbd_Dict_Letter, 1);
|
||||
if (!kl) return;
|
||||
kl->letter = eina_stringshare_add(letter);
|
||||
kl->dist = dist;
|
||||
list = eina_list_append(list, kl);
|
||||
l->data = list;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_dict_word_letter_advance(E_Kbd_Dict *kd)
|
||||
{
|
||||
// start a new letter in the word
|
||||
kd->word.letters = eina_list_append(kd->word.letters, NULL);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_dict_word_letter_delete(E_Kbd_Dict *kd)
|
||||
{
|
||||
// delete the current letter completely
|
||||
Eina_List *l, *list;
|
||||
|
||||
l = eina_list_last(kd->word.letters);
|
||||
if (!l) return;
|
||||
list = l->data;
|
||||
while (list)
|
||||
{
|
||||
E_Kbd_Dict_Letter *kl;
|
||||
|
||||
kl = list->data;
|
||||
eina_stringshare_del(kl->letter);
|
||||
free(kl);
|
||||
list = eina_list_remove_list(list, list);
|
||||
}
|
||||
kd->word.letters = eina_list_remove_list(kd->word.letters, l);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_kbd_dict_matches_lookup_iter(E_Kbd_Dict *kd, Eina_List *word,
|
||||
Eina_List *more)
|
||||
{
|
||||
Eina_List *l, *l2, *list;
|
||||
const char *p, *pn;
|
||||
char *base, *buf, *wd, *bufapp;
|
||||
E_Kbd_Dict_Letter *kl;
|
||||
int len = 0, dist = 0, d, baselen, maxdist = 0, md;
|
||||
static int level = 0, lv;
|
||||
|
||||
level++;
|
||||
for (l = word; l; l = l->next)
|
||||
{
|
||||
kl = l->data;
|
||||
len += strlen(kl->letter);
|
||||
dist += kl->dist;
|
||||
if (kl->dist > maxdist) maxdist = kl->dist;
|
||||
}
|
||||
if (maxdist < 1) maxdist = 1;
|
||||
buf = alloca(len + 20); // 20 - just padding enough for 1 more utf8 char
|
||||
base = alloca(len + 20);
|
||||
base[0] = 0;
|
||||
for (l = word; l; l = l->next)
|
||||
{
|
||||
kl = l->data;
|
||||
strcat(base, kl->letter);
|
||||
}
|
||||
baselen = strlen(base);
|
||||
strcpy(buf, base);
|
||||
bufapp = buf + baselen;
|
||||
list = more->data;
|
||||
for (l = list; l; l = l->next)
|
||||
{
|
||||
kl = l->data;
|
||||
if (kl->dist > maxdist) maxdist = kl->dist;
|
||||
}
|
||||
for (l = list; l; l = l->next)
|
||||
{
|
||||
kl = l->data;
|
||||
strcpy(bufapp, kl->letter);
|
||||
if ((kd->matches.deadends) && eina_hash_find(kd->matches.deadends, buf))
|
||||
continue;
|
||||
p = eina_hash_find(kd->matches.leads, buf);
|
||||
if (p) p = _e_kbd_dict_find_pointer(kd, p, baselen, buf);
|
||||
else p = _e_kbd_dict_find(kd, buf);
|
||||
if (!p)
|
||||
{
|
||||
if (!kd->matches.deadends)
|
||||
kd->matches.deadends = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(kd->matches.deadends, buf, kd);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!kd->matches.leads)
|
||||
kd->matches.leads = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(kd->matches.leads, buf, p);
|
||||
}
|
||||
if ((!more->next) || (!more->next->data))
|
||||
{
|
||||
d = dist + kl->dist;
|
||||
md = maxdist;
|
||||
for (;;)
|
||||
{
|
||||
E_Kbd_Dict_Word *kw;
|
||||
int usage = 0;
|
||||
|
||||
wd = _e_kbd_dict_line_parse(kd, p, &usage);
|
||||
if (!wd) break;
|
||||
if (_e_kbd_dict_normalized_strcmp(wd, buf))
|
||||
{
|
||||
free(wd);
|
||||
break;
|
||||
}
|
||||
kw = E_NEW(E_Kbd_Dict_Word, 1);
|
||||
if (kw)
|
||||
{
|
||||
int accuracy;
|
||||
int w, b, w2, b2, wc, bc, upper;
|
||||
|
||||
// match any capitalisation
|
||||
for (w = 0, b = 0; wd[w] && buf[b];)
|
||||
{
|
||||
b2 = evas_string_char_next_get(buf, b, &bc);
|
||||
w2 = evas_string_char_next_get(wd, w, &wc);
|
||||
if (isupper(bc)) wd[w] = toupper(wc);
|
||||
w = w2;
|
||||
b = b2;
|
||||
}
|
||||
kw->word = eina_stringshare_add(wd);
|
||||
// FIXME: magic combination of distance metric and
|
||||
// frequency of useage. this is simple now, but could
|
||||
// be tweaked
|
||||
wc = eina_list_count(word);
|
||||
if (md < 1) md = 1;
|
||||
|
||||
// basically a metric to see how far away teh keys that
|
||||
// were actually pressed are away from the letters of
|
||||
// this word in a physical on-screen sense
|
||||
accuracy = md - (d / (wc + 1));
|
||||
// usage is the frequency of usage in the dictionary.
|
||||
// it its < 1 time, it's assumed to be 1.
|
||||
if (usage < 1) usage = 1;
|
||||
// multiply usage by a factor of 100 for better detailed
|
||||
// sorting. 10 == 1/10th factor
|
||||
usage = 100 + ((usage - 1) * 10);
|
||||
// and well just multiply and lets see. maybe this can
|
||||
// do with multiplication factors etc. but simple for
|
||||
// now.
|
||||
kw->usage = (usage * accuracy) / md;
|
||||
kd->matches.list = eina_list_append(kd->matches.list, kw);
|
||||
}
|
||||
free(wd);
|
||||
p = _e_kbd_dict_line_next(kd, p);
|
||||
if (p >= (kd->file.dict + kd->file.size)) break;
|
||||
if (!p) break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
word = eina_list_append(word, kl);
|
||||
_e_kbd_dict_matches_lookup_iter(kd, word, more->next);
|
||||
word = eina_list_remove_list(word, eina_list_last(word));
|
||||
}
|
||||
}
|
||||
level--;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_dict_matches_lookup(E_Kbd_Dict *kd)
|
||||
{
|
||||
// find all matches and sort them
|
||||
while (kd->matches.list)
|
||||
{
|
||||
E_Kbd_Dict_Word *kw;
|
||||
|
||||
kw = kd->matches.list->data;
|
||||
eina_stringshare_del(kw->word);
|
||||
free(kw);
|
||||
kd->matches.list = eina_list_remove_list(kd->matches.list, kd->matches.list);
|
||||
}
|
||||
if (kd->word.letters)
|
||||
_e_kbd_dict_matches_lookup_iter(kd, NULL, kd->word.letters);
|
||||
kd->matches.list = eina_list_sort(kd->matches.list,
|
||||
eina_list_count(kd->matches.list),
|
||||
_e_kbd_dict_matches_lookup_cb_sort);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_dict_matches_first(E_Kbd_Dict *kd)
|
||||
{
|
||||
// jump to first match
|
||||
kd->matches.list_ptr = kd->matches.list;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_dict_matches_next(E_Kbd_Dict *kd)
|
||||
{
|
||||
// jump to next match
|
||||
kd->matches.list_ptr = kd->matches.list_ptr->next;
|
||||
}
|
||||
|
||||
EAPI const char *
|
||||
e_kbd_dict_matches_match_get(E_Kbd_Dict *kd, int *pri_ret)
|
||||
{
|
||||
// return the word (string utf-8) for the current match
|
||||
if (kd->matches.list_ptr)
|
||||
{
|
||||
E_Kbd_Dict_Word *kw;
|
||||
|
||||
kw = kd->matches.list_ptr->data;
|
||||
if (kw)
|
||||
{
|
||||
*pri_ret = kw->usage;
|
||||
return kw->word;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
#ifndef E_KBD_DICT_H
|
||||
#define E_KBD_DICT_H
|
||||
|
||||
typedef struct _E_Kbd_Dict E_Kbd_Dict;
|
||||
typedef struct _E_Kbd_Dict_Word E_Kbd_Dict_Word;
|
||||
typedef struct _E_Kbd_Dict_Letter E_Kbd_Dict_Letter;
|
||||
|
||||
struct _E_Kbd_Dict_Word
|
||||
{
|
||||
const char *word;
|
||||
int usage;
|
||||
};
|
||||
|
||||
struct _E_Kbd_Dict_Letter
|
||||
{
|
||||
const char *letter;
|
||||
int dist;
|
||||
};
|
||||
|
||||
struct _E_Kbd_Dict
|
||||
{
|
||||
struct {
|
||||
const char *file;
|
||||
int fd;
|
||||
const char *dict;
|
||||
int size;
|
||||
} file;
|
||||
struct {
|
||||
const char *tuples[128][128];
|
||||
} lookup;
|
||||
struct {
|
||||
Ecore_Timer *flush_timer;
|
||||
Eina_List *writes;
|
||||
} changed;
|
||||
struct {
|
||||
Eina_List *letters;
|
||||
} word;
|
||||
struct {
|
||||
Eina_Hash *deadends;
|
||||
Eina_Hash *leads;
|
||||
Eina_List *list;
|
||||
Eina_List *list_ptr;
|
||||
} matches;
|
||||
};
|
||||
|
||||
|
||||
EAPI E_Kbd_Dict *e_kbd_dict_new(const char *file);
|
||||
EAPI void e_kbd_dict_free(E_Kbd_Dict *kd);
|
||||
EAPI void e_kbd_dict_save(E_Kbd_Dict *kd);
|
||||
EAPI void e_kbd_dict_word_usage_adjust(E_Kbd_Dict *kd, const char *word, int adjust);
|
||||
EAPI void e_kbd_dict_word_delete(E_Kbd_Dict *kd, const char *word);
|
||||
EAPI void e_kbd_dict_word_letter_clear(E_Kbd_Dict *kd);
|
||||
EAPI void e_kbd_dict_word_letter_add(E_Kbd_Dict *kd, const char *letter, int dist);
|
||||
EAPI void e_kbd_dict_word_letter_advance(E_Kbd_Dict *kd);
|
||||
EAPI void e_kbd_dict_word_letter_delete(E_Kbd_Dict *kd);
|
||||
EAPI void e_kbd_dict_matches_lookup(E_Kbd_Dict *kd);
|
||||
EAPI void e_kbd_dict_matches_first(E_Kbd_Dict *kd);
|
||||
EAPI void e_kbd_dict_matches_next(E_Kbd_Dict *kd);
|
||||
EAPI const char *e_kbd_dict_matches_match_get(E_Kbd_Dict *kd, int *pri_ret);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,115 @@
|
|||
#ifndef E_KBD_INT_H
|
||||
#define E_KBD_INT_H
|
||||
|
||||
#include "e_kbd_buf.h"
|
||||
|
||||
typedef enum _E_Kbd_Int_Type
|
||||
{
|
||||
E_KBD_INT_TYPE_UNKNOWN = 0,
|
||||
E_KBD_INT_TYPE_ALPHA = (1 << 0),
|
||||
E_KBD_INT_TYPE_NUMERIC = (1 << 1),
|
||||
E_KBD_INT_TYPE_PIN = (1 << 2),
|
||||
E_KBD_INT_TYPE_PHONE_NUMBER = (1 << 3),
|
||||
E_KBD_INT_TYPE_HEX = (1 << 4),
|
||||
E_KBD_INT_TYPE_TERMINAL = (1 << 5),
|
||||
E_KBD_INT_TYPE_PASSWORD = (1 << 6)
|
||||
} E_Kbd_Int_Type;
|
||||
|
||||
typedef struct _E_Kbd_Int E_Kbd_Int;
|
||||
typedef struct _E_Kbd_Int_Key E_Kbd_Int_Key;
|
||||
typedef struct _E_Kbd_Int_Key_State E_Kbd_Int_Key_State;
|
||||
typedef struct _E_Kbd_Int_Layout E_Kbd_Int_Layout;
|
||||
typedef struct _E_Kbd_Int_Match E_Kbd_Int_Match;
|
||||
|
||||
struct _E_Kbd_Int
|
||||
{
|
||||
E_Win *win;
|
||||
const char *themedir, *syskbds, *sysdicts;
|
||||
Evas_Object *base_obj, *layout_obj, *event_obj, *icon_obj, *box_obj;
|
||||
Eina_List *layouts;
|
||||
Eina_List *matches;
|
||||
Ecore_Event_Handler *client_message_handler;
|
||||
struct {
|
||||
char *directory;
|
||||
const char *file;
|
||||
int w, h;
|
||||
int fuzz;
|
||||
E_Kbd_Int_Type type;
|
||||
Eina_List *keys;
|
||||
E_Kbd_Int_Key *pressed;
|
||||
int state;
|
||||
} layout;
|
||||
struct {
|
||||
Evas_Coord x, y, cx, cy;
|
||||
int lx, ly, clx, cly;
|
||||
Ecore_Timer *hold_timer;
|
||||
unsigned char down : 1;
|
||||
unsigned char stroke : 1;
|
||||
unsigned char zoom : 1;
|
||||
} down;
|
||||
struct {
|
||||
E_Popup *popup;
|
||||
Evas_Object *base_obj, *ilist_obj;
|
||||
} layoutlist;
|
||||
struct {
|
||||
E_Popup *popup;
|
||||
Evas_Object *base_obj, *ilist_obj;
|
||||
Eina_List *matches;
|
||||
} matchlist;
|
||||
struct {
|
||||
E_Popup *popup;
|
||||
Evas_Object *base_obj, *ilist_obj;
|
||||
Eina_List *matches;
|
||||
} dictlist;
|
||||
struct {
|
||||
E_Popup *popup;
|
||||
Evas_Object *base_obj, *layout_obj, *sublayout_obj;
|
||||
E_Kbd_Int_Key *pressed;
|
||||
} zoomkey;
|
||||
|
||||
E_Kbd_Buf *kbuf;
|
||||
};
|
||||
|
||||
struct _E_Kbd_Int_Key
|
||||
{
|
||||
int x, y, w, h;
|
||||
|
||||
Eina_List *states;
|
||||
Evas_Object *obj, *zoom_obj, *icon_obj, *zoom_icon_obj;
|
||||
|
||||
unsigned char pressed : 1;
|
||||
unsigned char selected : 1;
|
||||
|
||||
unsigned char is_shift : 1;
|
||||
unsigned char is_ctrl : 1;
|
||||
unsigned char is_alt : 1;
|
||||
unsigned char is_capslock : 1;
|
||||
};
|
||||
|
||||
struct _E_Kbd_Int_Key_State
|
||||
{
|
||||
int state;
|
||||
const char *label, *icon;
|
||||
const char *out;
|
||||
};
|
||||
|
||||
struct _E_Kbd_Int_Layout
|
||||
{
|
||||
const char *path;
|
||||
const char *dir;
|
||||
const char *icon;
|
||||
const char *name;
|
||||
int type;
|
||||
};
|
||||
|
||||
struct _E_Kbd_Int_Match
|
||||
{
|
||||
E_Kbd_Int *ki;
|
||||
const char *str;
|
||||
Evas_Object *obj;
|
||||
};
|
||||
|
||||
EAPI E_Kbd_Int *e_kbd_int_new(const char *themedir, const char *syskbds, const char *sysdicts);
|
||||
EAPI void e_kbd_int_free(E_Kbd_Int *ki);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,38 @@
|
|||
#include "e.h"
|
||||
#include "e_kbd_send.h"
|
||||
|
||||
static const char *
|
||||
_string_to_keysym(const char *str)
|
||||
{
|
||||
int glyph, ok;
|
||||
|
||||
/* utf8 -> glyph id (unicode - ucs4) */
|
||||
glyph = 0;
|
||||
ok = evas_string_char_next_get(str, 0, &glyph);
|
||||
if (glyph <= 0) return NULL;
|
||||
/* glyph id -> keysym */
|
||||
if (glyph > 0xff) glyph |= 0x1000000;
|
||||
return ecore_x_keysym_string_get(glyph);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_send_string_press(const char *str, Kbd_Mod mod)
|
||||
{
|
||||
const char *key = NULL;
|
||||
|
||||
key = _string_to_keysym(str);
|
||||
if (!key) return;
|
||||
e_kbd_send_keysym_press(key, mod);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_kbd_send_keysym_press(const char *key, Kbd_Mod mod)
|
||||
{
|
||||
if (mod & KBD_MOD_CTRL) ecore_x_test_fake_key_down("Control_L");
|
||||
if (mod & KBD_MOD_ALT) ecore_x_test_fake_key_down("Alt_L");
|
||||
if (mod & KBD_MOD_WIN) ecore_x_test_fake_key_down("Super_L");
|
||||
ecore_x_test_fake_key_press(key);
|
||||
if (mod & KBD_MOD_WIN) ecore_x_test_fake_key_up("Super_L");
|
||||
if (mod & KBD_MOD_ALT) ecore_x_test_fake_key_up("Alt_L");
|
||||
if (mod & KBD_MOD_CTRL) ecore_x_test_fake_key_up("Control_L");
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef E_KBD_SEND_H
|
||||
#define E_KBD_SEND_H
|
||||
|
||||
typedef enum _Kbd_Mod
|
||||
{
|
||||
KBD_MOD_SHIFT = (1 << 0),
|
||||
KBD_MOD_CTRL = (1 << 1),
|
||||
KBD_MOD_ALT = (1 << 2),
|
||||
KBD_MOD_WIN = (1 << 3)
|
||||
} Kbd_Mod;
|
||||
|
||||
EAPI void e_kbd_send_string_press(const char *str, Kbd_Mod mod);
|
||||
EAPI void e_kbd_send_keysym_press(const char *key, Kbd_Mod mod);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,249 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_mod_config.h"
|
||||
|
||||
/* local function prototypes */
|
||||
static void *_il_kbd_config_create(E_Config_Dialog *cfd);
|
||||
static void _il_kbd_config_free(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_il_kbd_config_ui(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static void _il_kbd_config_changed(void *data, Evas_Object *obj, void *event);
|
||||
static int _il_kbd_config_change_timeout(void *data);
|
||||
|
||||
EAPI Il_Kbd_Config *il_kbd_cfg = NULL;
|
||||
static E_Config_DD *conf_edd = NULL;
|
||||
Ecore_Timer *_il_kbd_config_change_timer = NULL;
|
||||
int kbd_external = 0;
|
||||
|
||||
/* public functions */
|
||||
EAPI int
|
||||
il_kbd_config_init(E_Module *m)
|
||||
{
|
||||
conf_edd = E_CONFIG_DD_NEW("Illume_Kbd_Cfg", Il_Kbd_Config);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Il_Kbd_Config
|
||||
#define D conf_edd
|
||||
E_CONFIG_VAL(D, T, version, INT);
|
||||
E_CONFIG_VAL(D, T, use_internal, INT);
|
||||
E_CONFIG_VAL(D, T, run_keyboard, STR);
|
||||
E_CONFIG_VAL(D, T, dict, STR);
|
||||
|
||||
il_kbd_cfg = e_config_domain_load("module.illume-keyboard", conf_edd);
|
||||
if ((il_kbd_cfg) &&
|
||||
((il_kbd_cfg->version >> 16) < IL_CONFIG_MAJ))
|
||||
{
|
||||
E_FREE(il_kbd_cfg);
|
||||
il_kbd_cfg = NULL;
|
||||
}
|
||||
if (!il_kbd_cfg)
|
||||
{
|
||||
il_kbd_cfg = E_NEW(Il_Kbd_Config, 1);
|
||||
il_kbd_cfg->version = 0;
|
||||
il_kbd_cfg->use_internal = 1;
|
||||
il_kbd_cfg->run_keyboard = NULL;
|
||||
il_kbd_cfg->dict = eina_stringshare_add("English_(US).dic");
|
||||
}
|
||||
if (il_kbd_cfg)
|
||||
{
|
||||
/* Add new config variables here */
|
||||
/* if ((il_kbd_cfg->version & 0xffff) < 1) */
|
||||
il_kbd_cfg->version = (IL_CONFIG_MAJ << 16) | IL_CONFIG_MIN;
|
||||
}
|
||||
|
||||
il_kbd_cfg->mod_dir = eina_stringshare_add(m->dir);
|
||||
|
||||
e_configure_registry_category_add("illume", 0, _("Illume"), NULL,
|
||||
"enlightenment/display");
|
||||
e_configure_registry_generic_item_add("illume/keyboard", 0, _("Keyboard"),
|
||||
NULL, "enlightenment/keyboard",
|
||||
il_kbd_config_show);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
il_kbd_config_shutdown(void)
|
||||
{
|
||||
il_kbd_cfg->cfd = NULL;
|
||||
|
||||
e_configure_registry_item_del("illume/keyboard");
|
||||
e_configure_registry_category_del("illume");
|
||||
|
||||
if (il_kbd_cfg->mod_dir) eina_stringshare_del(il_kbd_cfg->mod_dir);
|
||||
if (il_kbd_cfg->run_keyboard) eina_stringshare_del(il_kbd_cfg->run_keyboard);
|
||||
if (il_kbd_cfg->dict) eina_stringshare_del(il_kbd_cfg->dict);
|
||||
|
||||
E_FREE(il_kbd_cfg);
|
||||
il_kbd_cfg = NULL;
|
||||
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
il_kbd_config_save(void)
|
||||
{
|
||||
e_config_domain_save("module.illume-keyboard", conf_edd, il_kbd_cfg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
il_kbd_config_show(E_Container *con, const char *params)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
|
||||
if (e_config_dialog_find("E", "_config_illume_keyboard_settings")) return;
|
||||
|
||||
v = E_NEW(E_Config_Dialog_View, 1);
|
||||
v->create_cfdata = _il_kbd_config_create;
|
||||
v->free_cfdata = _il_kbd_config_free;
|
||||
v->basic.create_widgets = _il_kbd_config_ui;
|
||||
v->basic_only = 1;
|
||||
v->normal_win = 1;
|
||||
v->scroll = 1;
|
||||
|
||||
cfd = e_config_dialog_new(con, _("Keyboard Settings"), "E",
|
||||
"_config_illume_keyboard_settings",
|
||||
"enlightenment/keyboard_settings", 0, v, NULL);
|
||||
e_dialog_resizable_set(cfd->dia, 1);
|
||||
il_kbd_cfg->cfd = cfd;
|
||||
}
|
||||
|
||||
/* local function prototypes */
|
||||
static void *
|
||||
_il_kbd_config_create(E_Config_Dialog *cfd)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_il_kbd_config_free(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
il_kbd_cfg->cfd = NULL;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_il_kbd_config_ui(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *list, *of, *ow;
|
||||
E_Radio_Group *rg;
|
||||
Eina_List *l;
|
||||
|
||||
list = e_widget_list_add(evas, 0, 0);
|
||||
if (!il_kbd_cfg->run_keyboard)
|
||||
{
|
||||
if (il_kbd_cfg->use_internal) kbd_external = 1;
|
||||
else kbd_external = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Eina_List *kbds;
|
||||
Efreet_Desktop *desktop;
|
||||
int nn = 0;
|
||||
|
||||
kbd_external = 0;
|
||||
kbds = efreet_util_desktop_category_list("Keyboard");
|
||||
if (kbds)
|
||||
{
|
||||
nn = 2;
|
||||
EINA_LIST_FOREACH(kbds, l, desktop)
|
||||
{
|
||||
const char *dname;
|
||||
|
||||
dname = ecore_file_file_get(desktop->orig_path);
|
||||
if (dname)
|
||||
{
|
||||
if (!strcmp(il_kbd_cfg->run_keyboard, dname))
|
||||
{
|
||||
kbd_external = nn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nn++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Keyboards"), 0);
|
||||
rg = e_widget_radio_group_new(&(kbd_external));
|
||||
ow = e_widget_radio_add(evas, _("None"), 0, rg);
|
||||
e_widget_framelist_object_append(of, ow);
|
||||
evas_object_smart_callback_add(ow, "changed", _il_kbd_config_changed, NULL);
|
||||
ow = e_widget_radio_add(evas, _("Default"), 1, rg);
|
||||
e_widget_framelist_object_append(of, ow);
|
||||
evas_object_smart_callback_add(ow, "changed", _il_kbd_config_changed, NULL);
|
||||
{
|
||||
Eina_List *kbds;
|
||||
Efreet_Desktop *desktop;
|
||||
int nn = 2;
|
||||
|
||||
kbds = efreet_util_desktop_category_list("Keyboard");
|
||||
EINA_LIST_FOREACH(kbds, l, desktop)
|
||||
{
|
||||
const char *dname;
|
||||
|
||||
dname = ecore_file_file_get(desktop->orig_path);
|
||||
ow = e_widget_radio_add(evas, desktop->name, nn, rg);
|
||||
e_widget_framelist_object_append(of, ow);
|
||||
evas_object_smart_callback_add(ow, "changed",
|
||||
_il_kbd_config_changed, NULL);
|
||||
nn++;
|
||||
}
|
||||
}
|
||||
e_widget_list_object_append(list, of, 1, 0, 0.0);
|
||||
return list;
|
||||
}
|
||||
|
||||
static void
|
||||
_il_kbd_config_changed(void *data, Evas_Object *obj, void *event)
|
||||
{
|
||||
if (_il_kbd_config_change_timer)
|
||||
ecore_timer_del(_il_kbd_config_change_timer);
|
||||
_il_kbd_config_change_timer =
|
||||
ecore_timer_add(0.5, _il_kbd_config_change_timeout, data);
|
||||
}
|
||||
|
||||
static int
|
||||
_il_kbd_config_change_timeout(void *data)
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
il_kbd_cfg->use_internal = 0;
|
||||
if (il_kbd_cfg->run_keyboard)
|
||||
eina_stringshare_del(il_kbd_cfg->run_keyboard);
|
||||
il_kbd_cfg->run_keyboard = NULL;
|
||||
if (kbd_external == 0)
|
||||
il_kbd_cfg->use_internal = 0;
|
||||
else if (kbd_external == 1)
|
||||
il_kbd_cfg->use_internal = 1;
|
||||
else
|
||||
{
|
||||
Eina_List *kbds;
|
||||
Efreet_Desktop *desktop;
|
||||
int nn;
|
||||
|
||||
kbds = efreet_util_desktop_category_list("Keyboard");
|
||||
if (kbds)
|
||||
{
|
||||
nn = 2;
|
||||
EINA_LIST_FOREACH(kbds, l, desktop)
|
||||
{
|
||||
const char *dname;
|
||||
|
||||
dname = ecore_file_file_get(desktop->orig_path);
|
||||
if (nn == kbd_external)
|
||||
{
|
||||
if (dname)
|
||||
il_kbd_cfg->run_keyboard = eina_stringshare_add(dname);
|
||||
break;
|
||||
}
|
||||
nn++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
il_kbd_cfg_update();
|
||||
e_config_save_queue();
|
||||
_il_kbd_config_change_timer = NULL;
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef E_MOD_CONFIG_H
|
||||
#define E_MOD_CONFIG_H
|
||||
|
||||
#define IL_CONFIG_MIN 0
|
||||
#define IL_CONFIG_MAJ 0
|
||||
|
||||
typedef struct _Il_Kbd_Config Il_Kbd_Config;
|
||||
|
||||
struct _Il_Kbd_Config
|
||||
{
|
||||
int version;
|
||||
|
||||
int use_internal;
|
||||
const char *dict, *run_keyboard;
|
||||
|
||||
// Not User Configurable. Placeholders
|
||||
const char *mod_dir;
|
||||
E_Config_Dialog *cfd;
|
||||
};
|
||||
|
||||
EAPI int il_kbd_config_init(E_Module *m);
|
||||
EAPI int il_kbd_config_shutdown(void);
|
||||
EAPI int il_kbd_config_save(void);
|
||||
|
||||
EAPI void il_kbd_config_show(E_Container *con, const char *params);
|
||||
|
||||
extern EAPI Il_Kbd_Config *il_kbd_cfg;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,117 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_mod_config.h"
|
||||
#include "e_kbd_int.h"
|
||||
|
||||
/* local function prototypes */
|
||||
static void _il_kbd_stop(void);
|
||||
static void _il_kbd_start(void);
|
||||
static int _il_kbd_cb_exit(void *data, int type, void *event);
|
||||
|
||||
/* local variables */
|
||||
static E_Kbd_Int *ki = NULL;
|
||||
static Ecore_Exe *_kbd_exe = NULL;
|
||||
static Ecore_Event_Handler *_kbd_exe_exit_handler = NULL;
|
||||
|
||||
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume Keyboard" };
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
if (!il_kbd_config_init(m)) return NULL;
|
||||
_il_kbd_start();
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
{
|
||||
_il_kbd_stop();
|
||||
il_kbd_config_shutdown();
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
return il_kbd_config_save();
|
||||
}
|
||||
|
||||
EAPI void
|
||||
il_kbd_cfg_update(void)
|
||||
{
|
||||
_il_kbd_stop();
|
||||
_il_kbd_start();
|
||||
}
|
||||
|
||||
static void
|
||||
_il_kbd_stop(void)
|
||||
{
|
||||
if (ki) e_kbd_int_free(ki);
|
||||
ki = NULL;
|
||||
if (_kbd_exe) ecore_exe_interrupt(_kbd_exe);
|
||||
_kbd_exe = NULL;
|
||||
if (_kbd_exe_exit_handler) ecore_event_handler_del(_kbd_exe_exit_handler);
|
||||
_kbd_exe_exit_handler = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_il_kbd_start(void)
|
||||
{
|
||||
if (il_kbd_cfg->use_internal)
|
||||
{
|
||||
ki = e_kbd_int_new(il_kbd_cfg->mod_dir,
|
||||
il_kbd_cfg->mod_dir, il_kbd_cfg->mod_dir);
|
||||
}
|
||||
else if (il_kbd_cfg->run_keyboard)
|
||||
{
|
||||
E_Exec_Instance *inst;
|
||||
Efreet_Desktop *desktop;
|
||||
|
||||
desktop = efreet_util_desktop_file_id_find(il_kbd_cfg->run_keyboard);
|
||||
if (!desktop)
|
||||
{
|
||||
Eina_List *kbds, *l;
|
||||
|
||||
kbds = efreet_util_desktop_category_list("Keyboard");
|
||||
if (kbds)
|
||||
{
|
||||
EINA_LIST_FOREACH(kbds, l, desktop)
|
||||
{
|
||||
const char *dname;
|
||||
|
||||
dname = ecore_file_file_get(desktop->orig_path);
|
||||
if (dname)
|
||||
{
|
||||
if (!strcmp(dname, il_kbd_cfg->run_keyboard))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (desktop)
|
||||
{
|
||||
E_Zone *zone;
|
||||
|
||||
zone = e_util_zone_current_get(e_manager_current_get());
|
||||
inst = e_exec(zone, desktop, NULL, NULL, "illume-keyboard");
|
||||
if (inst)
|
||||
{
|
||||
_kbd_exe = inst->exe;
|
||||
_kbd_exe_exit_handler =
|
||||
ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
|
||||
_il_kbd_cb_exit, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_il_kbd_cb_exit(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_Exe_Event_Del *ev;
|
||||
|
||||
ev = event;
|
||||
if (ev->exe == _kbd_exe) _kbd_exe = NULL;
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef E_MOD_MAIN_H
|
||||
#define E_MOD_MAIN_H
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
||||
EAPI void *e_modapi_init(E_Module *m);
|
||||
EAPI int e_modapi_shutdown(E_Module *m);
|
||||
EAPI int e_modapi_save(E_Module *m);
|
||||
|
||||
EAPI void il_kbd_cfg_update(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,106 @@
|
|||
##KBDCONF-1.0
|
||||
kbd 130 45
|
||||
fuzz 20
|
||||
|
||||
# keyboard type
|
||||
type ALPHA
|
||||
# an icon for the keyboard so you know which one you have
|
||||
icon alpha.png
|
||||
|
||||
# if the key out is in quotes - "q" for example, then this key is used for
|
||||
# typing words and can be part of a dictionary match, any other key when
|
||||
# pressed will end the dictionary match (u can disable dictionary matching in
|
||||
# a layout by not having any outputs in quotes)
|
||||
key 5 5 10 10
|
||||
normal q "q"
|
||||
shift Q "Q"
|
||||
key 15 5 10 10
|
||||
normal w "w"
|
||||
shift W "W"
|
||||
key 25 5 10 10
|
||||
normal e "e"
|
||||
shift E "E"
|
||||
key 35 5 10 10
|
||||
normal r "r"
|
||||
shift R "R"
|
||||
key 45 5 10 10
|
||||
normal t "t"
|
||||
shift T "T"
|
||||
key 55 5 10 10
|
||||
normal y "y"
|
||||
shift Y "Y"
|
||||
key 65 5 10 10
|
||||
normal u "u"
|
||||
shift U "U"
|
||||
key 75 5 10 10
|
||||
normal i "i"
|
||||
shift I "I"
|
||||
key 85 5 10 10
|
||||
normal o "o"
|
||||
shift O "O"
|
||||
key 95 5 10 10
|
||||
normal p "p"
|
||||
shift P "P"
|
||||
|
||||
key 10 15 10 10
|
||||
normal a "a"
|
||||
shift A "A"
|
||||
key 20 15 10 10
|
||||
normal s "s"
|
||||
shift S "S"
|
||||
key 30 15 10 10
|
||||
normal d "d"
|
||||
shift D "D"
|
||||
key 40 15 10 10
|
||||
normal f "f"
|
||||
shift F "F"
|
||||
key 50 15 10 10
|
||||
normal g "g"
|
||||
shift G "G"
|
||||
key 60 15 10 10
|
||||
normal h "h"
|
||||
shift H "H"
|
||||
key 70 15 10 10
|
||||
normal j "j"
|
||||
shift J "J"
|
||||
key 80 15 10 10
|
||||
normal k "k"
|
||||
shift K "K"
|
||||
key 90 15 10 10
|
||||
normal l "l"
|
||||
shift L "L"
|
||||
|
||||
key 15 25 10 10
|
||||
normal z "z"
|
||||
shift Z "Z"
|
||||
key 25 25 10 10
|
||||
normal x "x"
|
||||
shift X "X"
|
||||
key 35 25 10 10
|
||||
normal c "c"
|
||||
shift C "C"
|
||||
key 45 25 10 10
|
||||
normal v "v"
|
||||
shift V "V"
|
||||
key 55 25 10 10
|
||||
normal b "b"
|
||||
shift B "B"
|
||||
key 65 25 10 10
|
||||
normal n "n"
|
||||
shift N "N"
|
||||
key 75 25 10 10
|
||||
normal m "m"
|
||||
shift M "M"
|
||||
key 105 25 10 10
|
||||
normal shift.png
|
||||
is_shift
|
||||
|
||||
key 115 5 10 10
|
||||
normal . period
|
||||
shift , comma
|
||||
key 115 15 10 10
|
||||
normal ? question
|
||||
shift ! exclam
|
||||
key 115 25 10 10
|
||||
normal ' "'"
|
||||
shift / slash
|
|
@ -0,0 +1,22 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MODULE = illume-keyboard
|
||||
|
||||
filesdir = $(libdir)/enlightenment/modules/$(MODULE)/keyboards
|
||||
files_DATA = \
|
||||
ignore_built_in_keyboards \
|
||||
Default.kbd \
|
||||
alpha.png \
|
||||
Numbers.kbd \
|
||||
numeric.png \
|
||||
Terminal.kbd \
|
||||
qwerty.png \
|
||||
up.png \
|
||||
down.png \
|
||||
left.png \
|
||||
right.png \
|
||||
shift.png \
|
||||
tab.png \
|
||||
enter.png \
|
||||
backspace.png
|
||||
|
||||
EXTRA_DIST = $(files_DATA)
|
|
@ -0,0 +1,120 @@
|
|||
##KBDCONF-1.0
|
||||
kbd 130 45
|
||||
fuzz 20
|
||||
|
||||
# keyboard type
|
||||
type NUMERIC
|
||||
# an icon for the keyboard so you know which one you have
|
||||
icon numeric.png
|
||||
|
||||
key 5 5 10 10
|
||||
normal 1 1
|
||||
shift ! exclam
|
||||
key 15 5 10 10
|
||||
normal 2 2
|
||||
shift @ at
|
||||
key 25 5 10 10
|
||||
normal 3 3
|
||||
shift # numbersign
|
||||
key 35 5 10 10
|
||||
normal 4 4
|
||||
shift $ dollar
|
||||
key 45 5 10 10
|
||||
normal 5 5
|
||||
shift % percent
|
||||
key 55 5 10 10
|
||||
normal 6 6
|
||||
shift ^ asciicircum
|
||||
key 65 5 10 10
|
||||
normal 7 7
|
||||
shift & ampersand
|
||||
key 75 5 10 10
|
||||
normal 8 8
|
||||
shift * asterisk
|
||||
key 85 5 10 10
|
||||
normal 9 9
|
||||
shift ( parenleft
|
||||
key 95 5 10 10
|
||||
normal 0 0
|
||||
shift ) parenright
|
||||
key 105 5 10 10
|
||||
normal [ bracketleft
|
||||
shift { braceleft
|
||||
key 115 5 10 10
|
||||
normal ] bracketright
|
||||
shift } braceright
|
||||
|
||||
|
||||
key 5 15 10 10
|
||||
normal tab.png Tab
|
||||
shift tab.png ISO_Left_Tab
|
||||
key 15 15 10 10
|
||||
normal ` grave
|
||||
shift ~ asciitilde
|
||||
key 25 15 10 10
|
||||
normal - "-"
|
||||
shift _ underscore
|
||||
key 35 15 10 10
|
||||
normal = equal
|
||||
shift + plus
|
||||
key 45 15 10 10
|
||||
normal \ backslash
|
||||
shift | bar
|
||||
key 55 15 10 10
|
||||
normal ; semicolon
|
||||
shift : colon
|
||||
key 65 15 10 10
|
||||
normal ' apostrophe
|
||||
shift " quotedbl
|
||||
key 75 15 10 10
|
||||
normal / slash
|
||||
shift ? question
|
||||
key 85 15 10 10
|
||||
normal , comma
|
||||
shift < less
|
||||
key 95 15 10 10
|
||||
normal ß "ß"
|
||||
shift ¢ "¢"
|
||||
key 105 15 10 10
|
||||
normal € "€"
|
||||
shift £ "£"
|
||||
key 115 15 10 10
|
||||
normal ø "ø"
|
||||
shift Ø "Ø"
|
||||
|
||||
key 5 25 10 10
|
||||
normal ä "ä"
|
||||
shift Ä "Ä"
|
||||
key 15 25 10 10
|
||||
normal ö "ö"
|
||||
shift Ö "Ö"
|
||||
key 25 25 10 10
|
||||
normal ü "ü"
|
||||
shift Ü "Ü"
|
||||
key 35 25 10 10
|
||||
normal é "é"
|
||||
shift É "É"
|
||||
key 45 25 10 10
|
||||
normal è "è"
|
||||
shift È "È"
|
||||
key 55 25 10 10
|
||||
normal ô "ô"
|
||||
shift Ô "Ô"
|
||||
key 65 25 10 10
|
||||
normal ç "ç"
|
||||
shift Ç "Ç"
|
||||
key 75 25 10 10
|
||||
normal à "à"
|
||||
shift À "À"
|
||||
key 85 25 10 10
|
||||
normal ò "ò"
|
||||
shift Ò "Ò"
|
||||
key 95 25 10 10
|
||||
normal ó "ó"
|
||||
shift Ó "Ó"
|
||||
key 105 25 10 10
|
||||
normal ñ "ñ"
|
||||
shift Ñ "Ñ"
|
||||
key 115 25 10 10
|
||||
normal shift.png
|
||||
is_shift
|
|
@ -0,0 +1,244 @@
|
|||
##KBDCONF-1.0
|
||||
kbd 450 150
|
||||
|
||||
# keyboard type
|
||||
type TERMINAL
|
||||
# an icon for the keyboard so you know which one you have
|
||||
icon qwerty.png
|
||||
|
||||
key 0 0 30 30
|
||||
normal ` grave
|
||||
shift ~ asciitilde
|
||||
capslock ` grave
|
||||
key 30 0 30 30
|
||||
normal 1 1
|
||||
shift ! exclam
|
||||
capslock 1 1
|
||||
key 60 0 30 30
|
||||
normal 2 2
|
||||
shift @ at
|
||||
capslock 2 2
|
||||
key 90 0 30 30
|
||||
normal 3 3
|
||||
shift # numbersign
|
||||
capslock 3 3
|
||||
key 120 0 30 30
|
||||
normal 4 4
|
||||
shift $ dollar
|
||||
capslock 4 4
|
||||
key 150 0 30 30
|
||||
normal 5 5
|
||||
shift % percent
|
||||
capslock 5 5
|
||||
key 180 0 30 30
|
||||
normal 6 6
|
||||
shift ^ asciicircum
|
||||
capslock 6 6
|
||||
key 210 0 30 30
|
||||
normal 7 7
|
||||
shift & ampersand
|
||||
capslock 7 7
|
||||
key 240 0 30 30
|
||||
normal 8 8
|
||||
shift * asterisk
|
||||
capslock 8 8
|
||||
key 270 0 30 30
|
||||
normal 9 9
|
||||
shift ( parenleft
|
||||
capslock 9 9
|
||||
key 300 0 30 30
|
||||
normal 0 0
|
||||
shift ) parenright
|
||||
capslock 0 0
|
||||
key 330 0 30 30
|
||||
normal - minus
|
||||
shift _ underscore
|
||||
capslock - minus
|
||||
key 360 0 30 30
|
||||
normal = equal
|
||||
shift + plus
|
||||
capslock = equal
|
||||
key 390 0 60 30
|
||||
normal backspace.png BackSpace
|
||||
|
||||
key 0 30 45 30
|
||||
normal tab.png Tab
|
||||
shift tab.png ISO_Left_Tab
|
||||
key 45 30 30 30
|
||||
normal q q
|
||||
shift Q Q
|
||||
capslock Q Q
|
||||
key 75 30 30 30
|
||||
normal w w
|
||||
shift W W
|
||||
capslock W W
|
||||
key 105 30 30 30
|
||||
normal e e
|
||||
shift E E
|
||||
capslock E E
|
||||
key 135 30 30 30
|
||||
normal r r
|
||||
shift R R
|
||||
capslock R R
|
||||
key 165 30 30 30
|
||||
normal t t
|
||||
shift T T
|
||||
capslock T T
|
||||
key 195 30 30 30
|
||||
normal y y
|
||||
shift Y Y
|
||||
capslock Y Y
|
||||
key 225 30 30 30
|
||||
normal u u
|
||||
shift U U
|
||||
capslock U U
|
||||
key 255 30 30 30
|
||||
normal i i
|
||||
shift I I
|
||||
capslock I I
|
||||
key 285 30 30 30
|
||||
normal o o
|
||||
shift O O
|
||||
capslock O O
|
||||
key 315 30 30 30
|
||||
normal p p
|
||||
shift P P
|
||||
capslock P P
|
||||
key 345 30 30 30
|
||||
normal [ bracketleft
|
||||
shift { braceleft
|
||||
capslock [ bracketleft
|
||||
key 375 30 30 30
|
||||
normal ] bracketright
|
||||
shift } braceright
|
||||
capslock ] bracketright
|
||||
key 405 30 45 30
|
||||
normal \ backslash
|
||||
shift | bar
|
||||
capslock \ backslash
|
||||
|
||||
key 0 60 60 30
|
||||
normal caps
|
||||
capslock CAPS
|
||||
is_capslock
|
||||
key 60 60 30 30
|
||||
normal a a
|
||||
shift A A
|
||||
capslock A A
|
||||
key 90 60 30 30
|
||||
normal s s
|
||||
shift S S
|
||||
capslock S S
|
||||
key 120 60 30 30
|
||||
normal d d
|
||||
shift D D
|
||||
capslock D D
|
||||
key 150 60 30 30
|
||||
normal f f
|
||||
shift F F
|
||||
capslock F F
|
||||
key 180 60 30 30
|
||||
normal g g
|
||||
shift G G
|
||||
capslock G G
|
||||
key 210 60 30 30
|
||||
normal h h
|
||||
shift H H
|
||||
capslock H H
|
||||
key 240 60 30 30
|
||||
normal j j
|
||||
shift J J
|
||||
capslock J J
|
||||
key 270 60 30 30
|
||||
normal k k
|
||||
shift K K
|
||||
capslock K K
|
||||
key 300 60 30 30
|
||||
normal l l
|
||||
shift L L
|
||||
capslock L L
|
||||
key 330 60 30 30
|
||||
normal ; semicolon
|
||||
shift : colon
|
||||
capslock ; semicolon
|
||||
key 360 60 30 30
|
||||
normal ' apostrophe
|
||||
shift " quotedbl
|
||||
capslock ' apostrophe
|
||||
key 390 60 60 30
|
||||
normal enter.png Return
|
||||
|
||||
key 0 90 75 30
|
||||
normal shift.png
|
||||
is_shift
|
||||
key 75 90 30 30
|
||||
normal z z
|
||||
shift Z Z
|
||||
capslock Z Z
|
||||
key 105 90 30 30
|
||||
normal x x
|
||||
shift X X
|
||||
capslock X X
|
||||
key 135 90 30 30
|
||||
normal c c
|
||||
shift C C
|
||||
capslock C C
|
||||
key 165 90 30 30
|
||||
normal v v
|
||||
shift V V
|
||||
capslock V V
|
||||
key 195 90 30 30
|
||||
normal b b
|
||||
shift B B
|
||||
capslock B B
|
||||
key 225 90 30 30
|
||||
normal n n
|
||||
shift N N
|
||||
capslock N N
|
||||
key 255 90 30 30
|
||||
normal m m
|
||||
shift M M
|
||||
capslock M M
|
||||
key 285 90 30 30
|
||||
normal , comma
|
||||
shift < less
|
||||
capslock , comma
|
||||
key 315 90 30 30
|
||||
normal . period
|
||||
shift > greater
|
||||
capslock . period
|
||||
key 345 90 30 30
|
||||
normal / slash
|
||||
shift ? question
|
||||
capslock / slash
|
||||
key 375 90 30 30
|
||||
normal ins Insert
|
||||
key 405 90 35 30
|
||||
normal del Delete
|
||||
|
||||
key 0 120 30 30
|
||||
normal ctrl
|
||||
is_ctrl
|
||||
key 30 120 30 30
|
||||
normal alt
|
||||
is_alt
|
||||
key 60 120 120 30
|
||||
normal space space
|
||||
key 180 120 30 30
|
||||
normal left.png Left
|
||||
key 210 120 30 30
|
||||
normal right.png Right
|
||||
key 240 120 30 30
|
||||
normal up.png Up
|
||||
key 270 120 30 30
|
||||
normal down.png Down
|
||||
key 300 120 30 30
|
||||
normal pu Prior
|
||||
key 330 120 30 30
|
||||
normal pd Next
|
||||
key 360 120 30 30
|
||||
normal hm Home
|
||||
key 390 120 30 30
|
||||
normal en End
|
||||
key 420 120 30 30
|
||||
normal es Escape
|
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 289 B |
After Width: | Height: | Size: 276 B |
After Width: | Height: | Size: 286 B |
|
@ -0,0 +1 @@
|
|||
/org/freedesktop/Hal/devices/platform_*
|
After Width: | Height: | Size: 271 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 274 B |
After Width: | Height: | Size: 266 B |
After Width: | Height: | Size: 306 B |
After Width: | Height: | Size: 262 B |
|
@ -0,0 +1,8 @@
|
|||
[Desktop Entry]
|
||||
Type=Link
|
||||
Name=Illume-Keyboard
|
||||
Icon=e-module-illume-keyboard
|
||||
X-Enlightenment-ModuleType=system
|
||||
Comment=<title>Illume Keyboard for Embedded</title>
|
||||
Comment[fr]=<title>Illume pour l'embarqué – Keyboard</title>
|
||||
Comment[it]=<title>Illume per sistemi embedded – modulo Keyboard</title>
|
|
@ -0,0 +1,29 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MODULE = illume-mode-toggle
|
||||
|
||||
# data files for the module
|
||||
filesdir = $(libdir)/enlightenment/modules/$(MODULE)
|
||||
files_DATA = \
|
||||
e-module-$(MODULE).edj module.desktop
|
||||
|
||||
EXTRA_DIST = $(files_DATA)
|
||||
|
||||
# the module .so file
|
||||
INCLUDES = -I. \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/modules/$(MODULE) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/modules \
|
||||
@e_cflags@
|
||||
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
|
||||
pkg_LTLIBRARIES = module.la
|
||||
module_la_SOURCES = e_mod_main.c \
|
||||
e_mod_main.h
|
||||
|
||||
module_la_LIBADD = @e_libs@ @dlopen_libs@
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
module_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
||||
uninstall:
|
||||
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)
|
|
@ -0,0 +1,184 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
/* local structures */
|
||||
typedef struct _Instance Instance;
|
||||
struct _Instance
|
||||
{
|
||||
E_Gadcon_Client *gcc;
|
||||
Evas_Object *o_btn;
|
||||
Ecore_Event_Handler *hdl;
|
||||
};
|
||||
|
||||
/* local function prototypes */
|
||||
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
||||
static void _gc_shutdown(E_Gadcon_Client *gcc);
|
||||
static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
|
||||
static char *_gc_label(E_Gadcon_Client_Class *cc);
|
||||
static Evas_Object *_gc_icon(E_Gadcon_Client_Class *cc, Evas *evas);
|
||||
static const char *_gc_id_new(E_Gadcon_Client_Class *cc);
|
||||
static void _cb_btn_click(void *data, void *data2);
|
||||
static int _cb_event_client_message(void *data, int type, void *event);
|
||||
static void _set_icon(Instance *inst);
|
||||
|
||||
/* local variables */
|
||||
static Eina_List *instances = NULL;
|
||||
static const char *mod_dir = NULL;
|
||||
|
||||
static const E_Gadcon_Client_Class _gc_class =
|
||||
{
|
||||
GADCON_CLIENT_CLASS_VERSION, "illume-mode-toggle",
|
||||
{ _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL,
|
||||
e_gadcon_site_is_not_toolbar
|
||||
}, E_GADCON_CLIENT_STYLE_PLAIN
|
||||
};
|
||||
|
||||
/* public functions */
|
||||
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume Mode Toggle" };
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
mod_dir = eina_stringshare_add(m->dir);
|
||||
e_gadcon_provider_register(&_gc_class);
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
{
|
||||
e_gadcon_provider_unregister(&_gc_class);
|
||||
if (mod_dir) eina_stringshare_del(mod_dir);
|
||||
mod_dir = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static E_Gadcon_Client *
|
||||
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||
{
|
||||
Instance *inst;
|
||||
|
||||
inst = E_NEW(Instance, 1);
|
||||
|
||||
inst->o_btn = e_widget_button_add(gc->evas, NULL, NULL,
|
||||
_cb_btn_click, inst, NULL);
|
||||
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->o_btn);
|
||||
inst->gcc->data = inst;
|
||||
|
||||
_set_icon(inst);
|
||||
|
||||
inst->hdl = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
|
||||
_cb_event_client_message, inst);
|
||||
|
||||
instances = eina_list_append(instances, inst);
|
||||
return inst->gcc;
|
||||
}
|
||||
|
||||
static void
|
||||
_gc_shutdown(E_Gadcon_Client *gcc)
|
||||
{
|
||||
Instance *inst;
|
||||
|
||||
if (!(inst = gcc->data)) return;
|
||||
instances = eina_list_remove(instances, inst);
|
||||
if (inst->o_btn) evas_object_del(inst->o_btn);
|
||||
if (inst->hdl) ecore_event_handler_del(inst->hdl);
|
||||
inst->hdl = NULL;
|
||||
E_FREE(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
|
||||
{
|
||||
e_gadcon_client_aspect_set(gcc, 16, 16);
|
||||
e_gadcon_client_min_size_set(gcc, 16, 16);
|
||||
}
|
||||
|
||||
static char *
|
||||
_gc_label(E_Gadcon_Client_Class *cc)
|
||||
{
|
||||
return _("Illume-Mode-Toggle");
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_gc_icon(E_Gadcon_Client_Class *cc, Evas *evas)
|
||||
{
|
||||
Evas_Object *o;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-mode-toggle.edj", mod_dir);
|
||||
o = edje_object_add(evas);
|
||||
edje_object_file_set(o, buff, "icon");
|
||||
return o;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_gc_id_new(E_Gadcon_Client_Class *cc)
|
||||
{
|
||||
char buff[PATH_MAX];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s.%d", _gc_class.name,
|
||||
eina_list_count(instances));
|
||||
return strdup(buff);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_btn_click(void *data, void *data2)
|
||||
{
|
||||
Instance *inst;
|
||||
Ecore_X_Window xwin;
|
||||
Ecore_X_Illume_Mode mode;
|
||||
|
||||
if (!(inst = data)) return;
|
||||
|
||||
xwin = inst->gcc->gadcon->zone->black_win;
|
||||
mode = ecore_x_e_illume_mode_get(xwin);
|
||||
mode += 1;
|
||||
if (mode > ECORE_X_ILLUME_MODE_DUAL_LEFT)
|
||||
mode = ECORE_X_ILLUME_MODE_SINGLE;
|
||||
ecore_x_e_illume_mode_set(xwin, mode);
|
||||
ecore_x_e_illume_mode_send(xwin, mode);
|
||||
}
|
||||
|
||||
static int
|
||||
_cb_event_client_message(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_X_Event_Client_Message *ev;
|
||||
Instance *inst;
|
||||
|
||||
ev = event;
|
||||
if (ev->message_type != ECORE_X_ATOM_E_ILLUME_MODE) return 1;
|
||||
if (!(inst = data)) return 1;
|
||||
_set_icon(inst);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_set_icon(Instance *inst)
|
||||
{
|
||||
Evas_Object *icon;
|
||||
Ecore_X_Window xwin;
|
||||
Ecore_X_Illume_Mode mode;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-mode-toggle.edj", mod_dir);
|
||||
icon = e_icon_add(evas_object_evas_get(inst->o_btn));
|
||||
|
||||
xwin = inst->gcc->gadcon->zone->black_win;
|
||||
mode = ecore_x_e_illume_mode_get(xwin);
|
||||
if (mode <= ECORE_X_ILLUME_MODE_SINGLE)
|
||||
e_icon_file_edje_set(icon, buff, "single");
|
||||
else if (mode == ECORE_X_ILLUME_MODE_DUAL_TOP)
|
||||
e_icon_file_edje_set(icon, buff, "dual_top");
|
||||
else if (mode == ECORE_X_ILLUME_MODE_DUAL_LEFT)
|
||||
e_icon_file_edje_set(icon, buff, "dual_left");
|
||||
|
||||
e_widget_button_icon_set(inst->o_btn, icon);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef E_MOD_MAIN_H
|
||||
#define E_MOD_MAIN_H
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
||||
EAPI void *e_modapi_init(E_Module *m);
|
||||
EAPI int e_modapi_shutdown(E_Module *m);
|
||||
EAPI int e_modapi_save(E_Module *m);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,8 @@
|
|||
[Desktop Entry]
|
||||
Type=Link
|
||||
Name=Illume-Mode-Toggle
|
||||
Icon=e-module-illume-mode-toggle
|
||||
X-Enlightenment-ModuleType=system
|
||||
Comment=<title>Illume Mode Toggle for Embedded</title>
|
||||
Comment[fr]=<title>Illume pour l'embarqué – Mode Toggle</title>
|
||||
Comment[it]=<title>Illume per sistemi embedded – modulo Mode-toggle</title>
|
|
@ -0,0 +1,31 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MODULE = illume-softkey
|
||||
|
||||
# data files for the module
|
||||
filesdir = $(libdir)/enlightenment/modules/$(MODULE)
|
||||
files_DATA = \
|
||||
e-module-$(MODULE).edj module.desktop
|
||||
|
||||
EXTRA_DIST = $(files_DATA)
|
||||
|
||||
# the module .so file
|
||||
INCLUDES = -I. \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/modules/$(MODULE) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/modules \
|
||||
@e_cflags@
|
||||
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
|
||||
pkg_LTLIBRARIES = module.la
|
||||
module_la_SOURCES = e_mod_main.c \
|
||||
e_mod_main.h \
|
||||
e_mod_win.c \
|
||||
e_mod_win.h
|
||||
|
||||
module_la_LIBADD = @e_libs@ @dlopen_libs@
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
module_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
||||
uninstall:
|
||||
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)
|
|
@ -0,0 +1,65 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_mod_config.h"
|
||||
|
||||
EAPI Il_Sk_Config *il_sk_cfg = NULL;
|
||||
static E_Config_DD *conf_edd = NULL;
|
||||
|
||||
/* public functions */
|
||||
int
|
||||
il_sk_config_init(E_Module *m)
|
||||
{
|
||||
conf_edd = E_CONFIG_DD_NEW("Illume-Softkey_Cfg", Il_Sk_Config);
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Il_Sk_Config
|
||||
#define D conf_edd
|
||||
E_CONFIG_VAL(D, T, version, INT);
|
||||
|
||||
il_sk_cfg = e_config_domain_load("module.illume-softkey", conf_edd);
|
||||
if ((il_sk_cfg) &&
|
||||
((il_sk_cfg->version >> 16) < IL_CONFIG_MAJ))
|
||||
{
|
||||
E_FREE(il_sk_cfg);
|
||||
il_sk_cfg = NULL;
|
||||
}
|
||||
if (!il_sk_cfg)
|
||||
{
|
||||
il_sk_cfg = E_NEW(Il_Sk_Config, 1);
|
||||
il_sk_cfg->version = 0;
|
||||
}
|
||||
if (il_sk_cfg)
|
||||
{
|
||||
/* Add new config variables here */
|
||||
/* if ((il_sk_cfg->version & 0xffff) < 1) */
|
||||
il_sk_cfg->version = (IL_CONFIG_MAJ << 16) | IL_CONFIG_MIN;
|
||||
}
|
||||
il_sk_cfg->mod_dir = eina_stringshare_add(m->dir);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
il_sk_config_shutdown(void)
|
||||
{
|
||||
if (il_sk_cfg->mod_dir) eina_stringshare_del(il_sk_cfg->mod_dir);
|
||||
il_sk_cfg->mod_dir = NULL;
|
||||
|
||||
E_FREE(il_sk_cfg);
|
||||
il_sk_cfg = NULL;
|
||||
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
il_sk_config_save(void)
|
||||
{
|
||||
e_config_domain_save("module.illume-softkey", conf_edd, il_sk_cfg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
il_sk_config_show(E_Container *con, const char *params)
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef E_MOD_CONFIG_H
|
||||
#define E_MOD_CONFIG_H
|
||||
|
||||
#define IL_CONFIG_MIN 0
|
||||
#define IL_CONFIG_MAJ 0
|
||||
|
||||
typedef struct _Il_Sk_Config Il_Sk_Config;
|
||||
struct _Il_Sk_Config
|
||||
{
|
||||
int version;
|
||||
|
||||
const char *mod_dir;
|
||||
};
|
||||
|
||||
int il_sk_config_init(E_Module *m);
|
||||
int il_sk_config_shutdown(void);
|
||||
int il_sk_config_save(void);
|
||||
void il_sk_config_show(E_Container *con, const char *params);
|
||||
|
||||
extern EAPI Il_Sk_Config *il_sk_cfg;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,67 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_mod_win.h"
|
||||
|
||||
/* local function prototypes */
|
||||
static int _cb_screens_sort(const void *data, const void *data2);
|
||||
|
||||
/* local variables */
|
||||
static Eina_List *swins = NULL;
|
||||
const char *mod_dir = NULL;
|
||||
|
||||
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume-Softkey" };
|
||||
|
||||
/* public functions */
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
E_Screen *screen;
|
||||
Eina_List *l, *screens;
|
||||
|
||||
mod_dir = eina_stringshare_add(m->dir);
|
||||
screens = (Eina_List *)e_xinerama_screens_get();
|
||||
// screens = eina_list_sort(screens, 0, _cb_screens_sort);
|
||||
EINA_LIST_FOREACH(screens, l, screen)
|
||||
{
|
||||
Il_Sk_Win *swin = NULL;
|
||||
|
||||
if (!(swin = e_mod_softkey_win_new(screen))) continue;
|
||||
swins = eina_list_append(swins, swin);
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
{
|
||||
Il_Sk_Win *swin;
|
||||
|
||||
EINA_LIST_FREE(swins, swin)
|
||||
{
|
||||
e_object_del(E_OBJECT(swin));
|
||||
swin = NULL;
|
||||
}
|
||||
|
||||
if (mod_dir) eina_stringshare_del(mod_dir);
|
||||
mod_dir = NULL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* local function prototypes */
|
||||
static int
|
||||
_cb_screens_sort(const void *data, const void *data2)
|
||||
{
|
||||
E_Screen *s1, *s2;
|
||||
|
||||
if (!(s1 = (E_Screen *)data)) return -1;
|
||||
if (!(s2 = (E_Screen *)data2)) return 1;
|
||||
return s2->escreen - s1->escreen;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef E_MOD_MAIN_H
|
||||
#define E_MOD_MAIN_H
|
||||
|
||||
#define IL_SK_WIN_TYPE 0xE1b0784
|
||||
|
||||
typedef struct _Il_Sk_Win Il_Sk_Win;
|
||||
|
||||
struct _Il_Sk_Win
|
||||
{
|
||||
E_Object e_obj_inherit;
|
||||
|
||||
E_Win *win;
|
||||
Evas_Object *o_base, *o_box;
|
||||
Evas_Object *b_close, *b_back;
|
||||
};
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
||||
EAPI void *e_modapi_init(E_Module *m);
|
||||
EAPI int e_modapi_shutdown(E_Module *m);
|
||||
EAPI int e_modapi_save(E_Module *m);
|
||||
|
||||
extern const char *mod_dir;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,133 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include "e_mod_win.h"
|
||||
|
||||
/* local function prototypes */
|
||||
static void _il_sk_win_cb_free(Il_Sk_Win *win);
|
||||
static void _il_sk_win_cb_resize(E_Win *win);
|
||||
static void _il_sk_win_cb_back_click(void *data, void *data2);
|
||||
static void _il_sk_win_cb_close_click(void *data, void *data2);
|
||||
|
||||
Il_Sk_Win *
|
||||
e_mod_softkey_win_new(E_Screen *screen)
|
||||
{
|
||||
Il_Sk_Win *swin;
|
||||
E_Container *con;
|
||||
E_Zone *zone;
|
||||
Evas *evas;
|
||||
Ecore_X_Window_State states[2];
|
||||
char buff[PATH_MAX];
|
||||
|
||||
swin = E_OBJECT_ALLOC(Il_Sk_Win, IL_SK_WIN_TYPE, _il_sk_win_cb_free);
|
||||
if (!swin) return NULL;
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-softkey.edj", mod_dir);
|
||||
|
||||
con = e_container_current_get(e_manager_current_get());
|
||||
zone = e_util_container_zone_id_get(con->num, screen->escreen);
|
||||
|
||||
swin->win = e_win_new(con);
|
||||
swin->win->data = swin;
|
||||
states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
|
||||
states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
|
||||
e_win_title_set(swin->win, _("Illume Softkey"));
|
||||
e_win_name_class_set(swin->win, "Illume-Softkey", "Illume-Softkey");
|
||||
e_win_resize_callback_set(swin->win, _il_sk_win_cb_resize);
|
||||
ecore_x_icccm_hints_set(swin->win->evas_win, 0, 0, 0, 0, 0, 0, 0);
|
||||
ecore_x_netwm_window_state_set(swin->win->evas_win, states, 2);
|
||||
ecore_x_netwm_window_type_set(swin->win->evas_win, ECORE_X_WINDOW_TYPE_DOCK);
|
||||
|
||||
evas = e_win_evas_get(swin->win);
|
||||
|
||||
swin->o_base = edje_object_add(evas);
|
||||
if (!e_theme_edje_object_set(swin->o_base, "base/theme/modules/illume-softkey",
|
||||
"modules/illume-softkey/window"))
|
||||
edje_object_file_set(swin->o_base, buff, "modules/illume-softkey/window");
|
||||
evas_object_move(swin->o_base, 0, 0);
|
||||
evas_object_resize(swin->o_base, zone->w, 32);
|
||||
evas_object_show(swin->o_base);
|
||||
|
||||
swin->o_box = e_widget_list_add(evas, 1, 1);
|
||||
edje_object_part_swallow(swin->o_base, "e.swallow.buttons", swin->o_box);
|
||||
|
||||
swin->b_back = e_widget_button_add(evas, NULL, "go-previous",
|
||||
_il_sk_win_cb_back_click, swin, NULL);
|
||||
e_widget_list_object_append(swin->o_box, swin->b_back, 1, 0, 0.5);
|
||||
|
||||
swin->b_close = e_widget_button_add(evas, NULL, "window-close",
|
||||
_il_sk_win_cb_close_click, swin, NULL);
|
||||
e_widget_list_object_append(swin->o_box, swin->b_close, 1, 0, 0.5);
|
||||
|
||||
e_win_size_min_set(swin->win, zone->w, 32);
|
||||
e_win_move_resize(swin->win, zone->x, (zone->h - 32), zone->w, 32);
|
||||
e_win_show(swin->win);
|
||||
e_border_zone_set(swin->win->border, zone);
|
||||
e_win_placed_set(swin->win, 1);
|
||||
swin->win->border->lock_user_location = 1;
|
||||
|
||||
return swin;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
static void
|
||||
_il_sk_win_cb_free(Il_Sk_Win *win)
|
||||
{
|
||||
if (win->b_close) evas_object_del(win->b_close);
|
||||
if (win->b_back) evas_object_del(win->b_back);
|
||||
if (win->o_box) evas_object_del(win->o_box);
|
||||
if (win->o_base) evas_object_del(win->o_base);
|
||||
e_object_del(E_OBJECT(win->win));
|
||||
E_FREE(win);
|
||||
}
|
||||
|
||||
static void
|
||||
_il_sk_win_cb_resize(E_Win *win)
|
||||
{
|
||||
Il_Sk_Win *swin;
|
||||
|
||||
if (!(swin = win->data)) return;
|
||||
evas_object_resize(swin->o_base, swin->win->w, swin->win->h);
|
||||
}
|
||||
|
||||
static void
|
||||
_il_sk_win_cb_back_click(void *data, void *data2)
|
||||
{
|
||||
Il_Sk_Win *swin;
|
||||
E_Border *bd, *fbd;
|
||||
Eina_List *focused, *l;
|
||||
|
||||
if (!(swin = data)) return;
|
||||
if (!(bd = e_border_focused_get())) return;
|
||||
focused = e_border_focus_stack_get();
|
||||
EINA_LIST_REVERSE_FOREACH(focused, l, fbd)
|
||||
{
|
||||
E_Border *fb;
|
||||
|
||||
if (e_object_is_del(E_OBJECT(fbd))) continue;
|
||||
if ((!fbd->client.icccm.accepts_focus) &&
|
||||
(!fbd->client.icccm.take_focus)) continue;
|
||||
if (fbd->client.netwm.state.skip_taskbar) continue;
|
||||
if (fbd == bd)
|
||||
{
|
||||
if (!(fb = focused->next->data)) continue;
|
||||
if (e_object_is_del(E_OBJECT(fb))) continue;
|
||||
if ((!fb->client.icccm.accepts_focus) &&
|
||||
(!fb->client.icccm.take_focus)) continue;
|
||||
if (fb->client.netwm.state.skip_taskbar) continue;
|
||||
e_border_raise(fb);
|
||||
e_border_focus_set(fb, 1, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_il_sk_win_cb_close_click(void *data, void *data2)
|
||||
{
|
||||
Il_Sk_Win *swin;
|
||||
E_Border *bd;
|
||||
|
||||
if (!(swin = data)) return;
|
||||
if (!(bd = e_border_focused_get())) return;
|
||||
e_border_act_close_begin(bd);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef E_MOD_WIN_H
|
||||
# define E_MOD_WIN_H
|
||||
|
||||
Il_Sk_Win *e_mod_softkey_win_new(E_Screen *screen);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,8 @@
|
|||
[Desktop Entry]
|
||||
Type=Link
|
||||
Name=Illume-Softkey
|
||||
Icon=e-module-illume-softkey
|
||||
X-Enlightenment-ModuleType=system
|
||||
Comment=<title>Illume Softkey for Embedded</title>
|
||||
Comment[fr]=<title>Illume pour l'embarqué – Softkey</title>
|
||||
Comment[it]=<title>Illume per sistemi embedded – modulo Softkey</title>
|