diff --git a/src/modules/illume-indicator/Makefile.am b/src/modules/illume-indicator/Makefile.am new file mode 100644 index 000000000..8400ced84 --- /dev/null +++ b/src/modules/illume-indicator/Makefile.am @@ -0,0 +1,50 @@ +MAINTAINERCLEANFILES = Makefile.in +MODULE = illume-indicator + +EDJE_CC = @edje_cc@ +EDJE_FLAGS = -v \ + -id $(top_srcdir)/src/modules/$(MODULE)/images \ + @EDJE_DEF@ + +# data files for the module +filesdir = $(libdir)/enlightenment/modules/$(MODULE) +files_DATA = \ + e-module-$(MODULE).edj \ + module.desktop + +EXTRA_DIST = \ + e-module-$(MODULE).edc \ + module.desktop.in + +# 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_ind_win.c \ + e_mod_ind_win.h \ + 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 + +e-module-$(MODULE).edj: Makefile $(EXTRA_DIST) + $(EDJE_CC) $(EDJE_FLAGS) \ + $(top_srcdir)/src/modules/$(MODULE)/e-module-$(MODULE).edc \ + $(top_builddir)/src/modules/$(MODULE)/e-module-$(MODULE).edj + +clean-local: + rm -f *.edj + +uninstall: + rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE) diff --git a/src/modules/illume-indicator/e-module-illume-indicator.edc b/src/modules/illume-indicator/e-module-illume-indicator.edc new file mode 100644 index 000000000..5f5d8b9e6 --- /dev/null +++ b/src/modules/illume-indicator/e-module-illume-indicator.edc @@ -0,0 +1,57 @@ +collections +{ + group + { + images.image: "module_icon.png" COMP; + name: "icon"; + max: 128 128; + parts + { + part + { + name: "base"; + mouse_events: 0; + description + { + state: "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + image.normal: "module_icon.png"; + } + } + } + } + group + { + images.image: "base_bg.png" COMP; + name: "modules/illume-indicator/shelf"; + parts + { + part + { + name: "base"; + type: IMAGE; + mouse_events: 0; + description + { + state: "default" 0.0; + color_class: "shelf_base"; + image.normal: "base_bg.png"; + image.border: 2 2 2 2; + fill.smooth: 0; + } + } + part + { + name: "e.swallow.content"; + type: SWALLOW; + description + { + state: "default" 0.0; + rel1.offset: 3 3; + rel2.offset: -4 -4; + } + } + } + } +} diff --git a/src/modules/illume-indicator/e_mod_config.c b/src/modules/illume-indicator/e_mod_config.c new file mode 100644 index 000000000..af1a7ba25 --- /dev/null +++ b/src/modules/illume-indicator/e_mod_config.c @@ -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; +} + diff --git a/src/modules/illume-indicator/e_mod_config.h b/src/modules/illume-indicator/e_mod_config.h new file mode 100644 index 000000000..575bb0c89 --- /dev/null +++ b/src/modules/illume-indicator/e_mod_config.h @@ -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 diff --git a/src/modules/illume-indicator/e_mod_ind_win.c b/src/modules/illume-indicator/e_mod_ind_win.c new file mode 100644 index 000000000..2b8e93ceb --- /dev/null +++ b/src/modules/illume-indicator/e_mod_ind_win.c @@ -0,0 +1,426 @@ +#include "e.h" +#include "e_mod_main.h" +#include "e_mod_ind_win.h" + +/* local function prototypes */ +static void _e_mod_ind_win_cb_free(Il_Ind_Win *iwin); +static void _e_mod_ind_win_cb_hook_eval_end(void *data, void *data2); +static void _e_mod_ind_win_cb_resize(E_Win *win); +static void _e_mod_ind_win_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event); +static void _e_mod_ind_win_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event); +static void _e_mod_ind_win_cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event); +static void _e_mod_ind_win_cb_menu_items_append(void *data, E_Gadcon_Client *gcc, E_Menu *mn); +static void _e_mod_ind_win_cb_menu_append(Il_Ind_Win *iwin, E_Menu *mn); +static void _e_mod_ind_win_cb_menu_pre(void *data, E_Menu *mn); +static void _e_mod_ind_win_cb_menu_contents(void *data, E_Menu *mn, E_Menu_Item *mi); +static void _e_mod_ind_win_cb_menu_post(void *data, E_Menu *mn); +static void _e_mod_ind_win_cb_min_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h); +static void _e_mod_ind_win_cb_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h); +static Evas_Object *_e_mod_ind_win_cb_frame_request(void *data, E_Gadcon_Client *gcc, const char *style); + +Il_Ind_Win * +e_mod_ind_win_new(E_Zone *zone) +{ + Evas *evas; + Il_Ind_Win *iwin; + Ecore_X_Window_State states[2]; + Ecore_X_Illume_Mode mode; + + /* allocate our new indicator window object */ + iwin = E_OBJECT_ALLOC(Il_Ind_Win, IL_IND_WIN_TYPE, _e_mod_ind_win_cb_free); + if (!iwin) return NULL; + iwin->zone = zone; + + /* we hook into eval end so we can set this indicator on the right zone */ + iwin->hook = e_border_hook_add(E_BORDER_HOOK_EVAL_END, + _e_mod_ind_win_cb_hook_eval_end, iwin); + + /* create the new indicator window */ + iwin->win = e_win_new(zone->container); + iwin->win->data = iwin; + 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_ind_win_cb_resize); + + /* set this window to not show in taskbar and pager */ + states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR; + states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER; + ecore_x_netwm_window_state_set(iwin->win->evas_win, states, 2); + + /* set this window to be a 'dock' window */ + ecore_x_netwm_window_type_set(iwin->win->evas_win, ECORE_X_WINDOW_TYPE_DOCK); + + /* set this window to not accept or take focus */ + ecore_x_icccm_hints_set(iwin->win->evas_win, 0, 0, 0, 0, 0, 0, 0); + + evas = e_win_evas_get(iwin->win); + + /* create our event rectangle */ + 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_ind_win_cb_mouse_down, iwin); + evas_object_event_callback_add(iwin->o_event, EVAS_CALLBACK_MOUSE_UP, + _e_mod_ind_win_cb_mouse_up, iwin); + evas_object_event_callback_add(iwin->o_event, EVAS_CALLBACK_MOUSE_MOVE, + _e_mod_ind_win_cb_mouse_move, iwin); + evas_object_show(iwin->o_event); + + /* create our base object */ + 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]; + + memset(buff, 0, sizeof(buff)); + snprintf(buff, sizeof(buff), "%s/e-module-illume-indicator.edj", + _ind_mod_dir); + edje_object_file_set(iwin->o_base, buff, + "modules/illume-indicator/shelf"); + memset(buff, 0, sizeof(buff)); + } + evas_object_move(iwin->o_base, 0, 0); + evas_object_show(iwin->o_base); + + /* create our gadget container */ + 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_ind_win_cb_min_size_request, iwin); + e_gadcon_size_request_callback_set(iwin->gadcon, + _e_mod_ind_win_cb_size_request, iwin); + e_gadcon_frame_request_callback_set(iwin->gadcon, + _e_mod_ind_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_ind_win_cb_menu_items_append, iwin); + e_gadcon_populate(iwin->gadcon); + + /* set minimum size of window */ + e_win_size_min_set(iwin->win, zone->w, (32 * e_scale)); + + /* position and resize the window */ + e_win_move_resize(iwin->win, zone->x, zone->y, zone->w, (32 * e_scale)); + + /* show the window */ + e_win_show(iwin->win); + + /* get the current illume mode and lock dragging if we need to */ + mode = ecore_x_e_illume_mode_get(zone->black_win); + if (mode == ECORE_X_ILLUME_MODE_DUAL_TOP) + iwin->win->border->client.illume.drag.locked = 0; + else + iwin->win->border->client.illume.drag.locked = 1; + + /* tell illume conformant apps our position and size */ + ecore_x_e_illume_top_shelf_geometry_set(ecore_x_window_root_first_get(), + zone->x, zone->y, zone->w, + (32 * e_scale)); + return iwin; +} + +/* local functions */ +static void +_e_mod_ind_win_cb_free(Il_Ind_Win *iwin) +{ + /* delete the menu */ + if (iwin->menu) + { + e_menu_post_deactivate_callback_set(iwin->menu, NULL, NULL); + e_object_del(E_OBJECT(iwin->menu)); + } + iwin->menu = NULL; + + /* delete the border hook */ + if (iwin->hook) e_border_hook_del(iwin->hook); + iwin->hook = NULL; + + /* delete the objects */ + if (iwin->o_event) evas_object_del(iwin->o_event); + if (iwin->o_base) evas_object_del(iwin->o_base); + + /* delete the gadget container */ + e_object_del(E_OBJECT(iwin->gadcon)); + iwin->gadcon = NULL; + + /* delete the window */ + e_object_del(E_OBJECT(iwin->win)); + iwin->win = NULL; + + /* free the object */ + E_FREE(iwin); +} + +static void +_e_mod_ind_win_cb_hook_eval_end(void *data, void *data2) +{ + Il_Ind_Win *iwin; + E_Border *bd; + + if (!(iwin = data)) return; + if (!(bd = data2)) return; + if (bd != iwin->win->border) return; + if (bd->zone != iwin->zone) + { + bd->x = iwin->zone->x; + bd->y = iwin->zone->y; + bd->changes.pos = 1; + bd->changed = 1; + e_border_zone_set(bd, iwin->zone); + } + bd->lock_user_location = 1; +} + +static void +_e_mod_ind_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_ind_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->button == 1) + { + iwin->mouse_down = 1; + + /* make sure we are not drag locked */ + if (iwin->win->border->client.illume.drag.locked) return; + + iwin->drag.start = 1; + iwin->drag.dnd = 0; + + /* grab the mouse position */ + ecore_x_pointer_last_xy_get(NULL, &iwin->drag.y); + + /* change the pointer to indicate we are dragging */ + if (iwin->win->border->pointer) + e_pointer_type_push(iwin->win->border->pointer, + iwin->win->border, "move"); + } + else if (ev->button == 3) + { + E_Menu *mn; + int x, y; + + /* create the menu */ + mn = e_menu_new(); + e_menu_post_deactivate_callback_set(mn, _e_mod_ind_win_cb_menu_post, + iwin); + iwin->menu = mn; + + /* append menu items and show it */ + _e_mod_ind_win_cb_menu_append(iwin, mn); + e_gadcon_canvas_zone_geometry_get(iwin->gadcon, &x, &y, NULL, NULL); + e_menu_activate_mouse(mn, iwin->zone, + x + ev->output.x, y + ev->output.y, + 1, 1, E_MENU_POP_DIRECTION_AUTO, ev->timestamp); + } +} + +static void +_e_mod_ind_win_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event) +{ + Il_Ind_Win *iwin; + Evas_Event_Mouse_Up *ev; + Ecore_X_Window xwin; + + ev = event; + if (ev->button != 1) return; + if (!(iwin = data)) return; + xwin = iwin->win->border->zone->black_win; + if ((!iwin->drag.dnd) && (iwin->mouse_down == 1)) + { + /* show the quickpanel */ + ecore_x_e_illume_quickpanel_state_send + (xwin, ECORE_X_ILLUME_QUICKPANEL_STATE_ON); + } + else if (iwin->drag.dnd) + { + E_Border *bd; + + bd = iwin->win->border; + + /* reset mouse pointer */ + if (bd->pointer) e_pointer_type_pop(bd->pointer, bd, "move"); + + /* tell edj that we are done moving */ + edje_object_signal_emit(iwin->o_base, "e,action,move,stop", "e"); + + /* send msg that we are done dragging */ + ecore_x_e_illume_drag_end_send(bd->client.win); + + /* update quickpanel position */ + ecore_x_e_illume_quickpanel_position_update_send(bd->client.win); + } + iwin->drag.start = 0; + iwin->drag.dnd = 0; + iwin->drag.y = 0; + iwin->mouse_down = 0; +} + +static void +_e_mod_ind_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; + bd = iwin->win->border; + + if (iwin->drag.start) + { + iwin->drag.dnd = 1; + iwin->drag.start = 0; + + /* tell edj that we are gonna start moving */ + edje_object_signal_emit(iwin->o_base, "e,action,move,start", "e"); + + /* send msg that we are gonna start dragging */ + ecore_x_e_illume_drag_start_send(bd->client.win); + } + + /* if we are not dragging, leave */ + if (!iwin->drag.dnd) return; + + /* make sure we are not gonna drag past the zone boundary */ + if ((bd->y + bd->h + ev->cur.output.y) >= bd->zone->h) return; + + /* grab mouse position */ + 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 - iwin->drag.y) < dy) return; + } + else if (ev->cur.output.y < ev->prev.output.y) + { + if ((iwin->drag.y - py) < dy) return; + } + else return; + + if (py > iwin->drag.y) + ny = bd->y + dy; + else if (py < iwin->drag.y) + ny = bd->y - dy; + else return; + + if (bd->y != ny) + { + bd->x = bd->zone->x; + bd->y = ny; + bd->changes.pos = 1; + bd->changed = 1; + iwin->drag.y = py; + } +} + +static void +_e_mod_ind_win_cb_menu_items_append(void *data, E_Gadcon_Client *gcc, E_Menu *mn) +{ + Il_Ind_Win *iwin; + + if (!(iwin = data)) return; + _e_mod_ind_win_cb_menu_append(iwin, mn); +} + +static void +_e_mod_ind_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_ind_win_cb_menu_pre, iwin); + e_object_data_set(E_OBJECT(mi), iwin); + e_menu_item_submenu_set(mi, sm); +} + +static void +_e_mod_ind_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_ind_win_cb_menu_contents, iwin); +} + +static void +_e_mod_ind_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_ind_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_ind_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 * e_scale)) h = (32 * e_scale); + 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_ind_win_cb_size_request(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h) +{ + return; +} + +static Evas_Object * +_e_mod_ind_win_cb_frame_request(void *data, E_Gadcon_Client *gcc, const char *style) +{ + return NULL; +} diff --git a/src/modules/illume-indicator/e_mod_ind_win.h b/src/modules/illume-indicator/e_mod_ind_win.h new file mode 100644 index 000000000..7a5a4150c --- /dev/null +++ b/src/modules/illume-indicator/e_mod_ind_win.h @@ -0,0 +1,25 @@ +#ifndef E_MOD_IND_WIN_H +# define E_MOD_IND_WIN_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_Zone *zone; + E_Menu *menu; + E_Gadcon *gadcon; + E_Border_Hook *hook; + Evas_Object *o_base, *o_event; + struct + { + int y, start, dnd; + } drag; + int mouse_down; +}; + +Il_Ind_Win *e_mod_ind_win_new(E_Zone *zone); + +#endif diff --git a/src/modules/illume-indicator/e_mod_main.c b/src/modules/illume-indicator/e_mod_main.c new file mode 100644 index 000000000..930d86412 --- /dev/null +++ b/src/modules/illume-indicator/e_mod_main.c @@ -0,0 +1,74 @@ +#include "e.h" +#include "e_mod_main.h" +#include "e_mod_ind_win.h" + +/* local variables */ +static Eina_List *iwins = NULL; + +/* external variables */ +const char *_ind_mod_dir = NULL; + +EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume-Indicator" }; + +EAPI void * +e_modapi_init(E_Module *m) +{ + E_Manager *man; + Eina_List *l; + + /* setup variable to hold module directory */ + _ind_mod_dir = eina_stringshare_add(m->dir); + + /* loop through the managers (root windows) */ + EINA_LIST_FOREACH(e_manager_list(), l, man) + { + E_Container *con; + Eina_List *cl; + + /* loop through the containers */ + EINA_LIST_FOREACH(man->containers, cl, con) + { + E_Zone *zone; + Eina_List *zl; + + /* for each zone in this container, create a indicator window */ + EINA_LIST_FOREACH(con->zones, zl, zone) + { + Il_Ind_Win *iwin = NULL; + + if (!(iwin = e_mod_ind_win_new(zone))) continue; + iwins = eina_list_append(iwins, iwin); + } + } + } + + return m; +} + +EAPI int +e_modapi_shutdown(E_Module *m) +{ + Il_Ind_Win *iwin; + + /* destroy the indicator windows */ + EINA_LIST_FREE(iwins, iwin) + { + e_object_del(E_OBJECT(iwin)); + iwin = NULL; + } + + /* clear the module directory variable */ + if (_ind_mod_dir) eina_stringshare_del(_ind_mod_dir); + _ind_mod_dir = NULL; + + ecore_x_e_illume_top_shelf_geometry_set(ecore_x_window_root_first_get(), + 0, 0, 0, 0); + + return 1; +} + +EAPI int +e_modapi_save(E_Module *m) +{ + return 1; +} diff --git a/src/modules/illume-indicator/e_mod_main.h b/src/modules/illume-indicator/e_mod_main.h new file mode 100644 index 000000000..9591f0c1f --- /dev/null +++ b/src/modules/illume-indicator/e_mod_main.h @@ -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); + +extern const char *_ind_mod_dir; + +#endif diff --git a/src/modules/illume-indicator/e_mod_win.c b/src/modules/illume-indicator/e_mod_win.c new file mode 100644 index 000000000..678ffe2f7 --- /dev/null +++ b/src/modules/illume-indicator/e_mod_win.c @@ -0,0 +1,346 @@ +#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); + +Il_Ind_Win * +e_mod_win_new(E_Zone *zone) +{ + Il_Ind_Win *iwin; + Evas *evas; + Ecore_X_Window_State states[2]; + Ecore_X_Illume_Mode mode; + + iwin = E_OBJECT_ALLOC(Il_Ind_Win, IL_IND_WIN_TYPE, _e_mod_win_cb_free); + if (!iwin) return NULL; + + iwin->win = e_win_new(zone->container); + 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_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_scale); + e_win_move_resize(iwin->win, zone->x, zone->y, zone->w, 32 * e_scale); + e_win_show(iwin->win); + e_border_zone_set(iwin->win->border, zone); + + mode = ecore_x_e_illume_mode_get(zone->black_win); + if (mode < ECORE_X_ILLUME_MODE_DUAL_TOP) + iwin->win->border->client.illume.drag.locked = 1; + else if (mode == ECORE_X_ILLUME_MODE_DUAL_TOP) + iwin->win->border->client.illume.drag.locked = 0; + else if (mode == ECORE_X_ILLUME_MODE_DUAL_LEFT) + iwin->win->border->client.illume.drag.locked = 1; + + ecore_x_e_illume_top_shelf_geometry_set(ecore_x_window_root_first_get(), + zone->x, zone->y, zone->w, 32 * e_scale); + + 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 * e_scale)) h = (32 * e_scale); + 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->button == 1) + { + iwin->mouse_down = 1; + if (iwin->win->border->client.illume.drag.locked) return; + if (iwin->win->border->pointer) + e_pointer_type_push(iwin->win->border->pointer, + iwin->win->border, "move"); + iwin->drag.start = 1; + iwin->drag.dnd = 0; + ecore_x_pointer_last_xy_get(NULL, &iwin->drag.y); + } + 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; + Ecore_X_Window xwin; + + ev = event; + if (ev->button != 1) return; + if (!(iwin = data)) return; + xwin = iwin->win->border->zone->black_win; + if ((!iwin->drag.dnd) && (iwin->mouse_down == 1)) + { + ecore_x_e_illume_quickpanel_state_send + (xwin, ECORE_X_ILLUME_QUICKPANEL_STATE_ON); + } + else if (iwin->drag.dnd) + { + E_Border *bd; + + bd = iwin->win->border; + if (bd->pointer) + e_pointer_type_pop(bd->pointer, bd, "move"); + edje_object_signal_emit(iwin->o_base, "e,action,move,stop", "e"); + ecore_x_e_illume_top_shelf_geometry_set(xwin, bd->x, bd->y, bd->w, + (32 * e_scale)); + ecore_x_e_illume_drag_end_send(bd->client.win); + ecore_x_e_illume_quickpanel_position_update_send(bd->client.win); + } + iwin->drag.start = 0; + iwin->drag.dnd = 0; + iwin->drag.y = 0; + iwin->mouse_down = 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; + if (iwin->drag.start) + { + edje_object_signal_emit(iwin->o_base, "e,action,move,start", "e"); + ecore_x_e_illume_drag_start_send(iwin->win->border->client.win); + iwin->drag.dnd = 1; + iwin->drag.start = 0; + } + + if (!iwin->drag.dnd) return; + + ev = event; + bd = iwin->win->border; + 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 - iwin->drag.y) < dy) return; + } + else if (ev->cur.output.y < ev->prev.output.y) + { + if ((iwin->drag.y - py) < dy) return; + } + else return; + + if (py > iwin->drag.y) + ny = bd->y + dy; + else if (py < iwin->drag.y) + ny = bd->y - dy; + else return; + + if (bd->y != ny) + { + e_border_move(bd, bd->zone->x, ny); + iwin->drag.y = py; + } +} diff --git a/src/modules/illume-indicator/e_mod_win.h b/src/modules/illume-indicator/e_mod_win.h new file mode 100644 index 000000000..0e942c749 --- /dev/null +++ b/src/modules/illume-indicator/e_mod_win.h @@ -0,0 +1,6 @@ +#ifndef E_MOD_WIN_H +# define E_MOD_WIN_H + +Il_Ind_Win *e_mod_win_new(E_Zone *zone); + +#endif diff --git a/src/modules/illume-indicator/images/base_bg.png b/src/modules/illume-indicator/images/base_bg.png new file mode 100644 index 000000000..a47ea1659 Binary files /dev/null and b/src/modules/illume-indicator/images/base_bg.png differ diff --git a/src/modules/illume-indicator/images/module_icon.png b/src/modules/illume-indicator/images/module_icon.png new file mode 100644 index 000000000..82c1b76f3 Binary files /dev/null and b/src/modules/illume-indicator/images/module_icon.png differ diff --git a/src/modules/illume-indicator/module.desktop.in b/src/modules/illume-indicator/module.desktop.in new file mode 100644 index 000000000..296124868 --- /dev/null +++ b/src/modules/illume-indicator/module.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Link +Name=Illume-Indicator +Icon=e-module-illume-indicator +X-Enlightenment-ModuleType=system +Comment=Illume Indicator for Embedded +Comment[fr]=Illume pour l'embarqué – Indicator +Comment[it]=Illume per sistemi embedded – modulo Indicator diff --git a/src/modules/illume-softkey/Makefile.am b/src/modules/illume-softkey/Makefile.am new file mode 100644 index 000000000..780e65f5f --- /dev/null +++ b/src/modules/illume-softkey/Makefile.am @@ -0,0 +1,46 @@ +MAINTAINERCLEANFILES = Makefile.in +MODULE = illume-softkey + +EDJE_CC = @edje_cc@ +EDJE_FLAGS = -v \ + -id $(top_srcdir)/src/modules/$(MODULE)/images \ + @EDJE_DEF@ + +# data files for the module +filesdir = $(libdir)/enlightenment/modules/$(MODULE) +files_DATA = \ +e-module-$(MODULE).edj module.desktop + +EXTRA_DIST = \ + e-module-$(MODULE).edc \ + module.desktop.in + +# 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_sft_win.c \ + e_mod_sft_win.h \ + 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 + +e-module-$(MODULE).edj: Makefile $(EXTRA_DIST) + $(EDJE_CC) $(EDJE_FLAGS) \ + $(top_srcdir)/src/modules/$(MODULE)/e-module-$(MODULE).edc \ + $(top_builddir)/src/modules/$(MODULE)/e-module-$(MODULE).edj + +clean-local: + rm -f *.edj diff --git a/src/modules/illume-softkey/e-module-illume-softkey.edc b/src/modules/illume-softkey/e-module-illume-softkey.edc new file mode 100644 index 000000000..2f638437f --- /dev/null +++ b/src/modules/illume-softkey/e-module-illume-softkey.edc @@ -0,0 +1,115 @@ +collections +{ + group + { + images.image: "module_icon.png" COMP; + name: "icon"; + max: 128 128; + parts + { + part + { + name: "base"; + mouse_events: 0; + description + { + state: "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + image.normal: "module_icon.png"; + } + } + } + } + group + { + images + { + image: "shelf_alt_bg.png" COMP; + image: "shelf_alt_over.png" COMP; + image: "shelf_alt_shine.png" COMP; + } + name: "modules/illume-softkey/window"; + parts + { + part + { + name: "base"; + type: IMAGE; + mouse_events: 0; + description + { + state: "default" 0.0; + color_class: "shelf_base"; + image.normal: "shelf_alt_bg.png"; + fill.smooth: 0; + } + } + part + { + name: "e.swallow.buttons"; + type: SWALLOW; + description + { + state: "default" 0.0; + align: 1.0 0.5; + fixed: 0 1; + rel1 + { + relative: 1.0 0.0; + offset: -96 3; + } + rel2.offset: -4 -4; + } + } + part + { + name: "e.swallow.extra_buttons"; + type: SWALLOW; + description + { + state: "default" 0.0; + align: 0.0 0.5; + fixed: 0 1; + rel1.offset: 3 3; + rel2 + { + relative: 0.0 1.0; + offset: -1 -4; + to_x: "e.swallow.buttons"; + } + } + } + part + { + name: "shine"; + type: IMAGE; + mouse_events: 0; + description + { + state: "default" 0.0; + image.normal: "shelf_alt_shine.png"; + rel2.relative: 1.0 0.5; + fill.smooth: 0; + } + } + part + { + name: "over"; + type: IMAGE; + mouse_events: 0; + description + { + state: "default" 0.0; + image + { + normal: "shelf_alt_over.png"; + border: 5 5 5 5; + middle: 0; + } + fill.smooth: 0; + } + } + } + } +} diff --git a/src/modules/illume-softkey/e_mod_config.c b/src/modules/illume-softkey/e_mod_config.c new file mode 100644 index 000000000..54da81ffe --- /dev/null +++ b/src/modules/illume-softkey/e_mod_config.c @@ -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) +{ + +} diff --git a/src/modules/illume-softkey/e_mod_config.h b/src/modules/illume-softkey/e_mod_config.h new file mode 100644 index 000000000..735118a13 --- /dev/null +++ b/src/modules/illume-softkey/e_mod_config.h @@ -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 diff --git a/src/modules/illume-softkey/e_mod_main.c b/src/modules/illume-softkey/e_mod_main.c new file mode 100644 index 000000000..7ee9672ac --- /dev/null +++ b/src/modules/illume-softkey/e_mod_main.c @@ -0,0 +1,71 @@ +#include "e.h" +#include "e_mod_main.h" +#include "e_mod_sft_win.h" + +/* local variables */ +static Eina_List *swins = NULL; + +/* external variables */ +const char *_sft_mod_dir = NULL; + +EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume-Softkey" }; + +EAPI void * +e_modapi_init(E_Module *m) +{ + E_Manager *man; + Eina_List *l; + + /* setup variable to hold module directory */ + _sft_mod_dir = eina_stringshare_add(m->dir); + + /* loop through the managers (root windows) */ + EINA_LIST_FOREACH(e_manager_list(), l, man) + { + E_Container *con; + Eina_List *cl; + + /* loop through the containers */ + EINA_LIST_FOREACH(man->containers, cl, con) + { + E_Zone *zone; + Eina_List *zl; + + /* for each zone in this container, create a new softkey window */ + EINA_LIST_FOREACH(con->zones, zl, zone) + { + Il_Sft_Win *swin; + + if (!(swin = e_mod_sft_win_new(zone))) continue; + swins = eina_list_append(swins, swin); + } + } + } + + return m; +} + +EAPI int +e_modapi_shutdown(E_Module *m) +{ + Il_Sft_Win *swin; + + /* destroy the softkey windows */ + EINA_LIST_FREE(swins, swin) + { + e_object_del(E_OBJECT(swin)); + swin = NULL; + } + + /* clear the module directory variable */ + if (_sft_mod_dir) eina_stringshare_del(_sft_mod_dir); + _sft_mod_dir = NULL; + + return 1; +} + +EAPI int +e_modapi_save(E_Module *m) +{ + return 1; +} diff --git a/src/modules/illume-softkey/e_mod_main.h b/src/modules/illume-softkey/e_mod_main.h new file mode 100644 index 000000000..78ba22502 --- /dev/null +++ b/src/modules/illume-softkey/e_mod_main.h @@ -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); + +extern const char *_sft_mod_dir; + +#endif diff --git a/src/modules/illume-softkey/e_mod_sft_win.c b/src/modules/illume-softkey/e_mod_sft_win.c new file mode 100644 index 000000000..705429867 --- /dev/null +++ b/src/modules/illume-softkey/e_mod_sft_win.c @@ -0,0 +1,166 @@ +#include "e.h" +#include "e_mod_main.h" +#include "e_mod_sft_win.h" + +/* local function prototypes */ +static void _e_mod_sft_win_cb_free(Il_Sft_Win *swin); +static void _e_mod_sft_win_cb_hook_eval_end(void *data, void *data2); +static void _e_mod_sft_win_cb_resize(E_Win *win); +static void _e_mod_sft_win_cb_back_click(void *data, void *data2); +static void _e_mod_sft_win_cb_close_click(void *data, void *data2); + +Il_Sft_Win * +e_mod_sft_win_new(E_Zone *zone) +{ + Evas *evas; + Il_Sft_Win *swin; + Ecore_X_Window_State states[2]; + + /* allocate our new softkey window object */ + swin = E_OBJECT_ALLOC(Il_Sft_Win, IL_SFT_WIN_TYPE, _e_mod_sft_win_cb_free); + if (!swin) return NULL; + swin->zone = zone; + + /* hook into eval end so we can set on the correct zone */ + swin->hook = e_border_hook_add(E_BORDER_HOOK_EVAL_END, + _e_mod_sft_win_cb_hook_eval_end, swin); + + /* create the new softkey window */ + swin->win = e_win_new(zone->container); + swin->win->data = swin; + 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, _e_mod_sft_win_cb_resize); + + /* set this window to not show in taskbar or pager */ + states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR; + states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER; + ecore_x_netwm_window_state_set(swin->win->evas_win, states, 2); + + /* set this window to be a 'dock' window */ + ecore_x_netwm_window_type_set(swin->win->evas_win, ECORE_X_WINDOW_TYPE_DOCK); + + /* set this window to not accept or take focus */ + ecore_x_icccm_hints_set(swin->win->evas_win, 0, 0, 0, 0, 0, 0, 0); + + evas = e_win_evas_get(swin->win); + + /* create our base object */ + 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")) + { + char buff[PATH_MAX]; + + memset(buff, 0, sizeof(buff)); + snprintf(buff, sizeof(buff), "%s/e-module-illume-softkey.edj", + _sft_mod_dir); + edje_object_file_set(swin->o_base, buff, + "modules/illume-softkey/window"); + memset(buff, 0, sizeof(buff)); + } + evas_object_move(swin->o_base, 0, 0); + evas_object_show(swin->o_base); + + /* create the box object for packing buttons */ + swin->o_box = e_widget_list_add(evas, 1, 1); + edje_object_part_swallow(swin->o_base, "e.swallow.buttons", swin->o_box); + + /* create the back button */ + swin->b_back = + e_widget_button_add(evas, NULL, "go-previous", + _e_mod_sft_win_cb_back_click, swin, NULL); + e_widget_list_object_append(swin->o_box, swin->b_back, 1, 0, 0.5); + + /* create the close button */ + swin->b_close = + e_widget_button_add(evas, NULL, "window-close", + _e_mod_sft_win_cb_close_click, swin, NULL); + e_widget_list_object_append(swin->o_box, swin->b_close, 1, 0, 0.5); + + /* set the minimum window size */ + e_win_size_min_set(swin->win, zone->w, (32 * e_scale)); + + /* position and resize the window */ + e_win_move_resize(swin->win, zone->x, (zone->h - (32 * e_scale)), + zone->w, (32 * e_scale)); + + /* show the window */ + e_win_show(swin->win); + + /* tell illume conformant apps our position and size */ + ecore_x_e_illume_bottom_panel_geometry_set(ecore_x_window_root_first_get(), + zone->x, (zone->h - (32 * e_scale)), + zone->w, (32 * e_scale)); + return swin; +} + +/* local functions */ +static void +_e_mod_sft_win_cb_free(Il_Sft_Win *swin) +{ + /* delete the border hook */ + if (swin->hook) e_border_hook_del(swin->hook); + swin->hook = NULL; + + /* delete the objects */ + if (swin->b_close) evas_object_del(swin->b_close); + if (swin->b_back) evas_object_del(swin->b_back); + if (swin->o_box) evas_object_del(swin->o_box); + if (swin->o_base) evas_object_del(swin->o_base); + + /* delete the window */ + e_object_del(E_OBJECT(swin->win)); + swin->win = NULL; + + /* free the object */ + E_FREE(swin); +} + +static void +_e_mod_sft_win_cb_hook_eval_end(void *data, void *data2) +{ + Il_Sft_Win *swin; + E_Border *bd; + + if (!(swin = data)) return; + if (!(bd = data2)) return; + if (bd != swin->win->border) return; + if (bd->zone != swin->zone) + { + bd->x = swin->zone->x; + bd->y = (swin->zone->h - bd->h); + bd->changes.pos = 1; + bd->changed = 1; + e_border_zone_set(bd, swin->zone); + } + bd->lock_user_location = 1; +} + +static void +_e_mod_sft_win_cb_resize(E_Win *win) +{ + Il_Sft_Win *swin; + + if (!(swin = win->data)) return; + evas_object_resize(swin->o_base, swin->win->w, swin->win->h); +} + +static void +_e_mod_sft_win_cb_back_click(void *data, void *data2) +{ + Il_Sft_Win *swin; + + if (!(swin = data)) return; + ecore_x_e_illume_back_send(swin->zone->black_win); +} + +static void +_e_mod_sft_win_cb_close_click(void *data, void *data2) +{ + Il_Sft_Win *swin; + + if (!(swin = data)) return; + ecore_x_e_illume_close_send(swin->zone->black_win); +} diff --git a/src/modules/illume-softkey/e_mod_sft_win.h b/src/modules/illume-softkey/e_mod_sft_win.h new file mode 100644 index 000000000..0b5cb12b2 --- /dev/null +++ b/src/modules/illume-softkey/e_mod_sft_win.h @@ -0,0 +1,19 @@ +#ifndef E_MOD_SFT_WIN_H +# define E_MOD_SFT_WIN_H + +# define IL_SFT_WIN_TYPE 0xE1b0784 + +typedef struct _Il_Sft_Win Il_Sft_Win; +struct _Il_Sft_Win +{ + E_Object e_obj_inherit; + E_Win *win; + E_Zone *zone; + E_Border_Hook *hook; + Evas_Object *o_base, *o_box; + Evas_Object *b_close, *b_back; +}; + +Il_Sft_Win *e_mod_sft_win_new(E_Zone *zone); + +#endif diff --git a/src/modules/illume-softkey/images/module_icon.png b/src/modules/illume-softkey/images/module_icon.png new file mode 100644 index 000000000..82c1b76f3 Binary files /dev/null and b/src/modules/illume-softkey/images/module_icon.png differ diff --git a/src/modules/illume-softkey/images/shelf_alt_bg.png b/src/modules/illume-softkey/images/shelf_alt_bg.png new file mode 100644 index 000000000..64e2b2c2c Binary files /dev/null and b/src/modules/illume-softkey/images/shelf_alt_bg.png differ diff --git a/src/modules/illume-softkey/images/shelf_alt_over.png b/src/modules/illume-softkey/images/shelf_alt_over.png new file mode 100644 index 000000000..cef17132f Binary files /dev/null and b/src/modules/illume-softkey/images/shelf_alt_over.png differ diff --git a/src/modules/illume-softkey/images/shelf_alt_shine.png b/src/modules/illume-softkey/images/shelf_alt_shine.png new file mode 100644 index 000000000..5c0588d8b Binary files /dev/null and b/src/modules/illume-softkey/images/shelf_alt_shine.png differ diff --git a/src/modules/illume-softkey/module.desktop.in b/src/modules/illume-softkey/module.desktop.in new file mode 100644 index 000000000..14b4a406d --- /dev/null +++ b/src/modules/illume-softkey/module.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Link +Name=Illume-Softkey +Icon=e-module-illume-softkey +X-Enlightenment-ModuleType=system +Comment=Illume Softkey for Embedded +Comment[fr]=Illume pour l'embarqué – Softkey +Comment[it]=Illume per sistemi embedded – modulo Softkey