Add separate vkbd toggle gadget.

SVN revision: 44462
This commit is contained in:
Christopher Michael 2009-12-15 04:33:12 +00:00
parent cfe205e65c
commit 7ad967ee23
7 changed files with 246 additions and 4 deletions

View File

@ -239,7 +239,7 @@ SUBDIRS += connman
endif
if USE_MODULE_ILLUME
SUBDIRS += illume illume2 illume-home illume-softkey illume-keyboard illume-indicator
SUBDIRS += illume illume2 illume-home illume-softkey illume-keyboard illume-indicator illume-kbd-toggle
endif
if USE_MODULE_SYSCON
@ -321,6 +321,7 @@ illume-home \
illume-softkey \
illume-keyboard \
illume-indicator \
illume-kbd-toggle \
syscon \
everything \
systray

View File

@ -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)

View File

@ -0,0 +1,195 @@
#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 *handler;
};
/* 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);
/* 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, "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;
inst->handler =
ecore_event_handler_add(E_EVENT_BORDER_FOCUS_IN,
_cb_border_focus_in, 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->handler) ecore_event_handler_del(inst->handler);
inst->handler = 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-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 = ecore_x_e_virtual_keyboard_state_get(bd->client.win);
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 = ecore_x_e_virtual_keyboard_state_get(bd->client.win);
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;
}

View File

@ -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

View File

@ -0,0 +1,6 @@
[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>

View File

@ -97,14 +97,14 @@ _e_flaunch_apps_populate(E_Flaunch *fl)
int num = 0, max, count;
// FIXME: 3 should become config here
max = 3;
max = 10;
// for now just look for any apps in "category" 'Bar' and add the first 3
// FIXME: category should be configurable...
bar_desktops = efreet_util_desktop_category_list("Bar");
bar_desktops = efreet_util_desktop_category_list("System");
if (bar_desktops)
{
Efreet_Desktop *desktop;
printf("Have Desktops\n");
count = eina_list_count(bar_desktops);
if (count < max)
{
@ -118,6 +118,7 @@ _e_flaunch_apps_populate(E_Flaunch *fl)
}
EINA_LIST_FOREACH(bar_desktops, l, desktop)
{
printf("Desktop: %s\n", desktop->name);
if (desktop->orig_path)
{
const char *dname;