use all dem cursor api's... and module it up bro

SVN revision: 44088
This commit is contained in:
Carsten Haitzler 2009-12-01 11:03:14 +00:00
parent cd2180a2ea
commit 07eee5720e
13 changed files with 522 additions and 71 deletions

View File

@ -273,6 +273,8 @@ src/Makefile
src/lib/Makefile src/lib/Makefile
src/lib/Elementary.h src/lib/Elementary.h
src/bin/Makefile src/bin/Makefile
src/modules/Makefile
src/modules/test_entry/Makefile
data/Makefile data/Makefile
data/themes/Makefile data/themes/Makefile
data/images/Makefile data/images/Makefile

View File

@ -1,4 +1,4 @@
AUTOMAKE_OPTIONS = 1.4 foreign AUTOMAKE_OPTIONS = 1.4 foreign
MAINTAINERCLEANFILES = Makefile.in MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = lib bin SUBDIRS = lib bin modules

View File

@ -56,6 +56,22 @@ my_bt_38_rot_270(void *data, Evas_Object *obj, void *event_info)
elm_win_rotation_set(win, 270); elm_win_rotation_set(win, 270);
} }
static void
my_win_move(void *data, Evas_Object *obj, void *event_info)
{
Evas_Coord x, y;
elm_win_screen_position_get(obj, &x, &y);
printf("MOVE - win geom: %4i %4i\n", x, y);
}
static void
_win_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Coord w, h;
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
printf("RESIZE - win geom: %4ix%4i\n", w, h);
}
void void
test_win_state(void *data, Evas_Object *obj, void *event_info) test_win_state(void *data, Evas_Object *obj, void *event_info)
{ {
@ -65,6 +81,8 @@ test_win_state(void *data, Evas_Object *obj, void *event_info)
win = elm_win_add(NULL, "window-state", ELM_WIN_BASIC); win = elm_win_add(NULL, "window-state", ELM_WIN_BASIC);
elm_win_title_set(win, "Window States"); elm_win_title_set(win, "Window States");
evas_object_smart_callback_add(win, "moved", my_win_move, NULL);
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize, NULL);
elm_win_autodel_set(win, 1); elm_win_autodel_set(win, 1);
bg = elm_bg_add(win); bg = elm_bg_add(win);

View File

@ -247,7 +247,9 @@ extern "C" {
*/ */
EAPI void elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode); EAPI void elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode);
EAPI void elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard); EAPI void elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard);
EAPI void elm_win_screen_position_get(Evas_Object *obj, int *x, int *y);
EAPI Evas_Object *elm_win_inwin_add(Evas_Object *obj); EAPI Evas_Object *elm_win_inwin_add(Evas_Object *obj);
EAPI void elm_win_inwin_activate(Evas_Object *obj); EAPI void elm_win_inwin_activate(Evas_Object *obj);
EINA_DEPRECATED EAPI void elm_win_inwin_style_set(Evas_Object *obj, const char *style); EINA_DEPRECATED EAPI void elm_win_inwin_style_set(Evas_Object *obj, const char *style);
@ -264,6 +266,7 @@ extern "C" {
* "delete,request" - the user requested to delete the window * "delete,request" - the user requested to delete the window
* "focus,on" - window got focus * "focus,on" - window got focus
* "focus,out" - window lost focus * "focus,out" - window lost focus
* "moved" - window that holds the canvas was moved
*/ */
EAPI Evas_Object *elm_bg_add(Evas_Object *parent); EAPI Evas_Object *elm_bg_add(Evas_Object *parent);
@ -498,17 +501,22 @@ extern "C" {
EAPI void elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable); EAPI void elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable);
EAPI void elm_entry_select_none(Evas_Object *obj); EAPI void elm_entry_select_none(Evas_Object *obj);
EAPI void elm_entry_select_all(Evas_Object *obj); EAPI void elm_entry_select_all(Evas_Object *obj);
#if 0 EAPI Eina_Bool elm_entry_cursor_next(Evas_Object *obj);
//next char (char # -= 1) EAPI Eina_Bool elm_entry_cursor_prev(Evas_Object *obj);
//prev char (char # += 1) EAPI Eina_Bool elm_entry_cursor_up(Evas_Object *obj);
//get cur char pos (char #) EAPI Eina_Bool elm_entry_cursor_down(Evas_Object *obj);
//set cur char pos (char #) EAPI void elm_entry_cursor_begin_set(Evas_Object *obj);
//get char len (# of chars) EAPI void elm_entry_cursor_end_set(Evas_Object *obj);
//get cur char (utf8) EAPI void elm_entry_cursor_line_begin_set(Evas_Object *obj);
//get text from char pos 1 to char pos 2 (inclusive) EAPI void elm_entry_cursor_line_end_set(Evas_Object *obj);
//sel text from char pos 1 to char pos 2 (inclusive) EAPI void elm_entry_cursor_selection_begin(Evas_Object *obj);
//clean sel (already have with select_abort) EAPI void elm_entry_cursor_selection_end(Evas_Object *obj);
#endif EAPI Eina_Bool elm_entry_cursor_is_format_get(Evas_Object *obj);
EAPI Eina_Bool elm_entry_cursor_is_visible_format_get(Evas_Object *obj);
EAPI const char *elm_entry_cursor_content_get(Evas_Object *obj);
EAPI void elm_entry_selection_cut(Evas_Object *obj);
EAPI void elm_entry_selection_copy(Evas_Object *obj);
EAPI void elm_entry_selection_paste(Evas_Object *obj);
EAPI void elm_entry_context_menu_clear(Evas_Object *obj); EAPI void elm_entry_context_menu_clear(Evas_Object *obj);
EAPI void elm_entry_context_menu_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data); EAPI void elm_entry_context_menu_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data);
EAPI void elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled); EAPI void elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled);
@ -527,6 +535,10 @@ extern "C" {
* "cursor,changed" - the cursor changed position * "cursor,changed" - the cursor changed position
* "anchor,clicked" - achor called was clicked | event_info = Elm_Entry_Anchor_Info * "anchor,clicked" - achor called was clicked | event_info = Elm_Entry_Anchor_Info
* "activated" - when the enter key is pressed (useful for single line) * "activated" - when the enter key is pressed (useful for single line)
* "press" - when finger/mouse is pressed down
* "clicked" - when finger/mouse is pressed and released (without a drag etc.)
* "clicked,double" - when finger/mouse is double-pressed
* "longpressed" - the entry has been longpressed
*/ */
/* composite widgets - these basically put together basic widgets above /* composite widgets - these basically put together basic widgets above

View File

@ -1,6 +1,8 @@
#include <Elementary.h> #include <Elementary.h>
#include "elm_priv.h" #include "elm_priv.h"
typedef struct _Mod_Api Mod_Api;
typedef struct _Widget_Data Widget_Data; typedef struct _Widget_Data Widget_Data;
typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item; typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
@ -18,6 +20,7 @@ struct _Widget_Data
Evas_Coord downx, downy; Evas_Coord downx, downy;
Evas_Coord cx, cy, cw, ch; Evas_Coord cx, cy, cw, ch;
Eina_List *items; Eina_List *items;
Mod_Api *api; // module api if supplied
Eina_Bool changed : 1; Eina_Bool changed : 1;
Eina_Bool linewrap : 1; Eina_Bool linewrap : 1;
Eina_Bool char_linewrap : 1; Eina_Bool char_linewrap : 1;
@ -61,6 +64,32 @@ static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emi
static Eina_List *entries = NULL; static Eina_List *entries = NULL;
struct _Mod_Api
{
void (*obj_hook) (Evas_Object *obj);
void (*obj_unhook) (Evas_Object *obj);
void (*obj_longpress) (Evas_Object *obj);
};
static Mod_Api *
_module(Evas_Object *obj)
{
static Elm_Module *m = NULL;
if (m) goto ok; // already found - just use
if (!(m = _elm_module_find_as("entry/api"))) return NULL;
// get module api
m->api = malloc(sizeof(Mod_Api));
if (!m->api) return NULL;
((Mod_Api *)(m->api) )->obj_hook = // called on creation
_elm_module_symbol_get(m, "obj_hook");
((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
_elm_module_symbol_get(m, "obj_unhook");
((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
_elm_module_symbol_get(m, "obj_longpress");
ok: // ok - return api
return m->api;
}
static void static void
_del_hook(Evas_Object *obj) _del_hook(Evas_Object *obj)
{ {
@ -68,6 +97,8 @@ _del_hook(Evas_Object *obj)
Eina_List *l; Eina_List *l;
Elm_Entry_Context_Menu_Item *it; Elm_Entry_Context_Menu_Item *it;
if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
entries = eina_list_remove(entries, obj); entries = eina_list_remove(entries, obj);
#ifdef HAVE_ELEMENTARY_X #ifdef HAVE_ELEMENTARY_X
ecore_event_handler_del(wd->sel_notify_handler); ecore_event_handler_del(wd->sel_notify_handler);
@ -344,47 +375,55 @@ _long_press(void *data)
const Eina_List *l; const Eina_List *l;
const Elm_Entry_Context_Menu_Item *it; const Elm_Entry_Context_Menu_Item *it;
if (wd->hoversel) evas_object_del(wd->hoversel); if ((wd->api) && (wd->api->obj_longpress))
else elm_widget_scroll_freeze_push(data);
wd->hoversel = elm_hoversel_add(data);
elm_object_style_set(wd->hoversel, "entry");
elm_widget_sub_object_add(data, wd->hoversel);
elm_hoversel_label_set(wd->hoversel, "Text");
top = elm_widget_top_get(data);
if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
if (!wd->selmode)
{ {
elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE, wd->api->obj_longpress(data);
_select, data);
if (wd->editable)
elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
_paste, data);
} }
else else
{ {
elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE, if (wd->hoversel) evas_object_del(wd->hoversel);
_copy, data); else elm_widget_scroll_freeze_push(data);
if (wd->editable) wd->hoversel = elm_hoversel_add(data);
elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE, elm_object_style_set(wd->hoversel, "entry");
_cut, data); elm_widget_sub_object_add(data, wd->hoversel);
elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE, elm_hoversel_label_set(wd->hoversel, "Text");
_cancel, data); top = elm_widget_top_get(data);
} if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
EINA_LIST_FOREACH(wd->items, l, it) evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
{ if (!wd->selmode)
elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file, {
it->icon_type, _item_clicked, it); elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
} _select, data);
if (wd->hoversel) if (wd->editable)
{ elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
_hoversel_position(data); _paste, data);
evas_object_show(wd->hoversel); }
elm_hoversel_hover_begin(wd->hoversel); else
{
elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
_copy, data);
if (wd->editable)
elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
_cut, data);
elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
_cancel, data);
}
EINA_LIST_FOREACH(wd->items, l, it)
{
elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
it->icon_type, _item_clicked, it);
}
if (wd->hoversel)
{
_hoversel_position(data);
evas_object_show(wd->hoversel);
elm_hoversel_hover_begin(wd->hoversel);
}
} }
wd->longpress_timer = NULL; wd->longpress_timer = NULL;
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0); edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
edje_object_part_text_select_abort(wd->ent, "elm.text"); edje_object_part_text_select_abort(wd->ent, "elm.text");
evas_object_smart_callback_call(data, "longpressed", NULL);
return 0; return 0;
} }
@ -954,10 +993,30 @@ static void
_signal_key_enter(void *data, Evas_Object *obj, const char *emission, const char *source) _signal_key_enter(void *data, Evas_Object *obj, const char *emission, const char *source)
{ {
Widget_Data *wd = elm_widget_data_get(data); Widget_Data *wd = elm_widget_data_get(data);
evas_object_smart_callback_call(data, "activated", NULL); evas_object_smart_callback_call(data, "activated", NULL);
} }
static void
_signal_mouse_down(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(data);
evas_object_smart_callback_call(data, "press", NULL);
}
static void
_signal_mouse_up(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(data);
evas_object_smart_callback_call(data, "clicked", NULL);
}
static void
_signal_mouse_double(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(data);
evas_object_smart_callback_call(data, "clicked,double", NULL);
}
#ifdef HAVE_ELEMENTARY_X #ifdef HAVE_ELEMENTARY_X
static int static int
_event_selection_notify(void *data, int type, void *event) _event_selection_notify(void *data, int type, void *event)
@ -1070,6 +1129,12 @@ elm_entry_add(Evas_Object *parent)
_signal_anchor_out, obj); _signal_anchor_out, obj);
edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text", edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
_signal_key_enter, obj); _signal_key_enter, obj);
edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
_signal_mouse_down, obj);
edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
_signal_mouse_up, obj);
edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
_signal_mouse_double, obj);
edje_object_part_text_set(wd->ent, "elm.text", "<br>"); edje_object_part_text_set(wd->ent, "elm.text", "<br>");
elm_widget_resize_object_set(obj, wd->ent); elm_widget_resize_object_set(obj, wd->ent);
_sizing_eval(obj); _sizing_eval(obj);
@ -1088,6 +1153,12 @@ elm_entry_add(Evas_Object *parent)
#endif #endif
entries = eina_list_prepend(entries, obj); entries = eina_list_prepend(entries, obj);
// module - find module for entry
wd->api = _module(obj);
// if found - hook in
if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
return obj; return obj;
} }
@ -1133,17 +1204,6 @@ elm_entry_entry_set(Evas_Object *obj, const char *entry)
if (!entry) entry = "<br>"; if (!entry) entry = "<br>";
edje_object_part_text_set(wd->ent, "elm.text", entry); edje_object_part_text_set(wd->ent, "elm.text", entry);
// debug
#if 0
{
const Eina_List *l, *an;
const char *anchor;
an = edje_object_part_text_anchor_list_get(wd->ent, "elm.text");
EINA_LIST_FOREACH(an, l, anchor)
printf("ANCHOR: %s\n", anchor);
}
#endif
wd->changed = EINA_TRUE; wd->changed = EINA_TRUE;
_sizing_eval(obj); _sizing_eval(obj);
} }
@ -1263,6 +1323,120 @@ elm_entry_select_all(Evas_Object *obj)
edje_object_part_text_select_all(wd->ent, "elm.text"); edje_object_part_text_select_all(wd->ent, "elm.text");
} }
EAPI Eina_Bool
elm_entry_cursor_next(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
}
EAPI Eina_Bool
elm_entry_cursor_prev(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
}
EAPI Eina_Bool
elm_entry_cursor_up(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
}
EAPI Eina_Bool
elm_entry_cursor_down(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
}
EAPI void
elm_entry_cursor_begin_set(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
}
EAPI void
elm_entry_cursor_end_set(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
}
EAPI void
elm_entry_cursor_line_begin_set(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
}
EAPI void
elm_entry_cursor_line_end_set(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
}
EAPI void
elm_entry_cursor_selection_begin(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
edje_object_part_text_select_all(wd->ent, "elm.text");
edje_object_part_text_cursor_copy(wd->ent, "elm.text", EDJE_CURSOR_MAIN, EDJE_CURSOR_SELECTION_BEGIN);
edje_object_part_text_cursor_copy(wd->ent, "elm.text", EDJE_CURSOR_MAIN, EDJE_CURSOR_SELECTION_END);
}
EAPI void
elm_entry_cursor_selection_end(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
edje_object_part_text_cursor_copy(wd->ent, "elm.text", EDJE_CURSOR_MAIN, EDJE_CURSOR_SELECTION_END);
}
EAPI Eina_Bool
elm_entry_cursor_is_format_get(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
}
EAPI Eina_Bool
elm_entry_cursor_is_visible_format_get(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
}
EAPI const char *
elm_entry_cursor_content_get(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
}
EAPI void
elm_entry_selection_cut(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
_cut(obj, NULL, NULL);
}
EAPI void
elm_entry_selection_copy(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
_copy(obj, NULL, NULL);
}
EAPI void
elm_entry_selection_paste(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
_paste(obj, NULL, NULL);
}
EAPI void EAPI void
elm_entry_context_menu_clear(Evas_Object *obj) elm_entry_context_menu_clear(Evas_Object *obj)
{ {

View File

@ -271,6 +271,8 @@ static Ecore_Event_Handler *_elm_exit_handler = NULL;
static Ecore_Event_Handler *_elm_event_property_change = NULL; static Ecore_Event_Handler *_elm_event_property_change = NULL;
#ifdef HAVE_ELEMENTARY_X #ifdef HAVE_ELEMENTARY_X
static Ecore_X_Atom _elm_atom_enlightenment_scale = 0; static Ecore_X_Atom _elm_atom_enlightenment_scale = 0;
static Ecore_X_Atom _elm_atom_enlightenment_finger_size = 0;
static Ecore_X_Atom _elm_atom_enlightenment_theme = 0;
#endif #endif
static int static int
@ -303,6 +305,34 @@ _elm_window_property_change(void *data, int ev_type, void *ev)
if (pscale != _elm_config->scale) _elm_rescale(); if (pscale != _elm_config->scale) _elm_rescale();
} }
} }
else if (event->atom == _elm_atom_enlightenment_finger_size)
{
int val = 1000;
if (ecore_x_window_prop_card32_get(event->win,
event->atom,
&val, 1) > 0)
{
int pfinger_size;
pfinger_size = _elm_config->finger_size;
_elm_config->finger_size = val;
if (pfinger_size != _elm_config->finger_size) _elm_rescale();
}
}
else if (event->atom == _elm_atom_enlightenment_theme)
{
char *val = NULL;
val = ecore_x_window_prop_string_get(event->win,
event->atom);
if (val)
{
_elm_theme_parse(val);
free(val);
_elm_rescale();
}
}
} }
return 1; return 1;
} }
@ -518,7 +548,8 @@ elm_quicklaunch_init(int argc, char **argv)
if (!_elm_lib_dir) if (!_elm_lib_dir)
_elm_lib_dir = eina_stringshare_add("/"); _elm_lib_dir = eina_stringshare_add("/");
// FIXME: actually load config // FIXME: actually load config from file - use eet. also for X properties,
// reduce to single x property with eet data encoded in it.
_elm_config = ELM_NEW(Elm_Config); _elm_config = ELM_NEW(Elm_Config);
_elm_config->engine = ELM_SOFTWARE_X11; _elm_config->engine = ELM_SOFTWARE_X11;
_elm_config->thumbscroll_enable = 1; _elm_config->thumbscroll_enable = 1;
@ -598,15 +629,12 @@ elm_quicklaunch_init(int argc, char **argv)
else _elm_theme_parse("default"); else _elm_theme_parse("default");
_elm_config->font_hinting = 2; _elm_config->font_hinting = 2;
s= getenv("ELM_FONT_HINTING"); s = getenv("ELM_FONT_HINTING");
if (s) if (s)
{ {
if (!strcasecmp(s, "none")) if (!strcasecmp(s, "none")) _elm_config->font_hinting = 0;
_elm_config->font_hinting = 0; else if (!strcasecmp(s, "auto")) _elm_config->font_hinting = 1;
else if (!strcasecmp(s, "auto")) else if (!strcasecmp(s, "bytecode")) _elm_config->font_hinting = 2;
_elm_config->font_hinting = 1;
else if (!strcasecmp(s, "bytecode"))
_elm_config->font_hinting = 2;
} }
s = getenv("ELM_FONT_PATH"); s = getenv("ELM_FONT_PATH");
@ -663,6 +691,9 @@ elm_quicklaunch_init(int argc, char **argv)
ecore_animator_frametime_set(1.0 / _elm_config->fps); ecore_animator_frametime_set(1.0 / _elm_config->fps);
edje_frametime_set(1.0 / 60.0); edje_frametime_set(1.0 / 60.0);
edje_scale_set(_elm_config->scale); edje_scale_set(_elm_config->scale);
s = getenv("ELM_MODULES");
if (s) _elm_module_parse(s);
} }
EAPI void EAPI void
@ -684,7 +715,11 @@ elm_quicklaunch_sub_init(int argc, char **argv)
} }
if (!ecore_x_screen_is_composited(0)) if (!ecore_x_screen_is_composited(0))
_elm_config->compositing = 0; _elm_config->compositing = 0;
_elm_atom_enlightenment_scale = ecore_x_atom_get("ENLIGHTENMENT_SCALE");
_elm_atom_enlightenment_scale = ecore_x_atom_get("ENLIGHTENMENT_SCALE");
_elm_atom_enlightenment_finger_size = ecore_x_atom_get("ENLIGHTENMENT_FINGER_SIZE");
_elm_atom_enlightenment_theme = ecore_x_atom_get("ENLIGHTENMENT_THEME");
ecore_x_event_mask_set(ecore_x_window_root_first_get(), ecore_x_event_mask_set(ecore_x_window_root_first_get(),
ECORE_X_EVENT_MASK_WINDOW_PROPERTY); ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
_elm_event_property_change = ecore_event_handler_add _elm_event_property_change = ecore_event_handler_add
@ -704,6 +739,30 @@ elm_quicklaunch_sub_init(int argc, char **argv)
} }
} }
} }
if (!getenv("ELM_FINGER_SIZE"))
{
if (ecore_x_window_prop_card32_get(ecore_x_window_root_first_get(),
_elm_atom_enlightenment_finger_size,
&val, 1) > 0)
{
if (val > 0)
{
_elm_config->finger_size = val;
}
}
}
if (!getenv("ELM_THEME"))
{
char *s;
s = ecore_x_window_prop_string_get(ecore_x_window_root_first_get(),
_elm_atom_enlightenment_theme);
if (s)
{
_elm_theme_parse(s);
free(s);
}
}
#endif #endif
} }
} }

View File

@ -1,6 +1,30 @@
#include <Elementary.h> #include <Elementary.h>
#include "elm_priv.h" #include "elm_priv.h"
/* what are moodules in elementary for? for modularising behavior and features
* so they can be plugged in and out where you dont want the core source to
* alwyas behave like that or do it that way. plug it at runtime!
*
* they have module names (in config) and "slots" to plug that module into
* to server a purpose. eg you plug plugin "xx" into the "entry-copy-paste"
* slot so it would provide replacement copy & paste ui functionality and
* specific symbols
*
* config is something like:
*
* export ELM_MODULES="xx>slot1:yy>slot2"
*
* where a module named xx is plugged into slot1 & yy is plugged into slot2
*
* real examples:
*
* export ELM_MODULES="my_module>entry/api"
*
* this loads the module called "my_module" into the slot "entry/api" which
* is an api slot for entry modules to modify behavior and hook to
* creation/deletion of the entry as well as replace the longpress behavior.
*/
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
# define _GNU_SOURCE # define _GNU_SOURCE
#endif #endif
@ -12,11 +36,13 @@
#include <dlfcn.h> /* dlopen,dlclose,etc */ #include <dlfcn.h> /* dlopen,dlclose,etc */
static Eina_Hash *modules = NULL; static Eina_Hash *modules = NULL;
static Eina_Hash *modules_as = NULL;
void void
_elm_module_init(void) _elm_module_init(void)
{ {
modules = eina_hash_string_small_new(NULL); modules = eina_hash_string_small_new(NULL);
modules_as = eina_hash_string_small_new(NULL);
} }
void void
@ -25,10 +51,61 @@ _elm_module_shutdown(void)
// FIXME: unload all modules // FIXME: unload all modules
eina_hash_free(modules); eina_hash_free(modules);
modules = NULL; modules = NULL;
eina_hash_free(modules_as);
modules_as = NULL;
}
void
_elm_module_parse(const char *s)
{
Eina_List *names = NULL;
const char *p, *pe;
p = s;
pe = p;
for (;;)
{
if ((*pe == ':') || (*pe == 0))
{ // p -> pe == 'name:'
if (pe > p)
{
char *n = malloc(pe - p + 1);
if (n)
{
char *nn;
strncpy(n, p, pe - p);
n[pe - p] = 0;
nn = strchr(n, '>');
if (nn)
{
*nn = 0;
nn++;
_elm_module_add(n, nn);
}
free(n);
}
}
if (*pe == 0) break;
p = pe + 1;
pe = p;
}
else
pe++;
}
} }
Elm_Module * Elm_Module *
_elm_module_add(const char *name) _elm_module_find_as(const char *as)
{
Elm_Module *m;
m = eina_hash_find(modules_as, as);
return m;
}
Elm_Module *
_elm_module_add(const char *name, const char *as)
{ {
Elm_Module *m; Elm_Module *m;
char buf[PATH_MAX]; char buf[PATH_MAX];
@ -114,6 +191,8 @@ _elm_module_add(const char *name)
} }
m->references = 1; m->references = 1;
eina_hash_direct_add(modules, m->name, m); eina_hash_direct_add(modules, m->name, m);
m->as = eina_stringshare_add(as);
eina_hash_direct_add(modules_as, m->as, m);
return m; return m;
} }
@ -124,11 +203,14 @@ _elm_module_del(Elm_Module *m)
if (m->references > 0) return; if (m->references > 0) return;
if (m->shutdown_func) m->shutdown_func(m); if (m->shutdown_func) m->shutdown_func(m);
eina_hash_del(modules, m->name, m); eina_hash_del(modules, m->name, m);
dlclose(m->handle); eina_hash_del(modules_as, m->as, m);
if (m->api) free(m->api);
eina_stringshare_del(m->name); eina_stringshare_del(m->name);
eina_stringshare_del(m->as);
eina_stringshare_del(m->so_path); eina_stringshare_del(m->so_path);
eina_stringshare_del(m->data_dir); eina_stringshare_del(m->data_dir);
eina_stringshare_del(m->bin_dir); eina_stringshare_del(m->bin_dir);
dlclose(m->handle);
free(m); free(m);
} }

View File

@ -65,11 +65,13 @@ struct _Elm_Module
{ {
int version; int version;
const char *name; const char *name;
const char *as;
const char *so_path; const char *so_path;
const char *data_dir; const char *data_dir;
const char *bin_dir; const char *bin_dir;
void *handle; void *handle;
void *data; void *data;
void *api;
int (*init_func) (Elm_Module *m); int (*init_func) (Elm_Module *m);
int (*shutdown_func) (Elm_Module *m); int (*shutdown_func) (Elm_Module *m);
int references; int references;
@ -86,7 +88,9 @@ int _elm_theme_parse(const char *theme);
void _elm_module_init(void); void _elm_module_init(void);
void _elm_module_shutdown(void); void _elm_module_shutdown(void);
Elm_Module *_elm_module_add(const char *name); void _elm_module_parse(const char *s);
Elm_Module *_elm_module_find_as(const char *as);
Elm_Module *_elm_module_add(const char *name, const char *as);
void _elm_module_del(Elm_Module *m); void _elm_module_del(Elm_Module *m);
const void *_elm_module_symbol_get(Elm_Module *m, const char *name); const void *_elm_module_symbol_get(Elm_Module *m, const char *name);

View File

@ -195,7 +195,7 @@ _elm_theme_parse(const char *theme)
for (;;) for (;;)
{ {
if ((*pe == ':') || (*pe == 0)) if ((*pe == ':') || (*pe == 0))
{ // p -> pe == 'name/' { // p -> pe == 'name:'
if (pe > p) if (pe > p)
{ {
char *n = malloc(pe - p + 1); char *n = malloc(pe - p + 1);

View File

@ -17,10 +17,14 @@ struct _Elm_Win
Elm_Win_Keyboard_Mode kbdmode; Elm_Win_Keyboard_Mode kbdmode;
Eina_Bool autodel : 1; Eina_Bool autodel : 1;
int *autodel_clear, rot; int *autodel_clear, rot;
struct {
int x, y;
} screen;
}; };
static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj); static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
static void _elm_win_move(Ecore_Evas *ee);
static void _elm_win_resize(Ecore_Evas *ee); static void _elm_win_resize(Ecore_Evas *ee);
static void _elm_win_delete_request(Ecore_Evas *ee); static void _elm_win_delete_request(Ecore_Evas *ee);
static void _elm_win_resize_job(void *data); static void _elm_win_resize_job(void *data);
@ -33,6 +37,21 @@ static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Eva
static Eina_List *_elm_win_list = NULL; static Eina_List *_elm_win_list = NULL;
static void
_elm_win_move(Ecore_Evas *ee)
{
Evas_Object *obj = ecore_evas_object_associate_get(ee);
Elm_Win *win;
int x, y;
if (strcmp(elm_widget_type_get(obj), "win")) return;
win = elm_widget_data_get(obj);
if (!win) return;
ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
win->screen.x = x;
win->screen.y = y;
evas_object_smart_callback_call(win->win_obj, "moved", NULL);
}
static void static void
_elm_win_resize(Ecore_Evas *ee) _elm_win_resize(Ecore_Evas *ee)
{ {
@ -387,6 +406,7 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
ecore_evas_callback_resize_set(win->ee, _elm_win_resize); ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in); ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out); ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
ecore_evas_callback_move_set(win->ee, _elm_win_move);
evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024)); evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024)); evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath) EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
@ -788,6 +808,17 @@ elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
#endif #endif
} }
EAPI void
elm_win_screen_position_get(Evas_Object *obj, int *x, int *y)
{
Elm_Win *win;
if (strcmp(elm_widget_type_get(obj), "win")) return;
win = elm_widget_data_get(obj);
if (!win) return;
if (x) *x = win->screen.x;
if (y) *y = win->screen.y;
}
typedef struct _Widget_Data Widget_Data; typedef struct _Widget_Data Widget_Data;
struct _Widget_Data struct _Widget_Data

View File

@ -0,0 +1,5 @@
AUTOMAKE_OPTIONS = 1.4 foreign
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = \
test_entry

View File

@ -0,0 +1,31 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = \
-I. \
-I$(top_builddir) \
-I$(top_srcdir) \
-I$(top_srcdir)/src/lib \
-I$(top_builddir)/src/lib \
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
@ELEMENTARY_CFLAGS@ \
@ELEMENTARY_X_CFLAGS@ \
@ELEMENTARY_FB_CFLAGS@ \
@ELEMENTARY_WIN32_CFLAGS@ \
@ELEMENTARY_WINCE_CFLAGS@ \
@ELEMENTARY_EDBUS_CFLAGS@ \
@ELEMENTARY_EFREET_CFLAGS@
if ELEMENTARY_WINDOWS_BUILD
AM_CPPFLAGS += -DELEMENTARY_BUILD
endif
pkgdir = $(libdir)/elementary/modules/test_entry/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = mod.c
module_la_LIBADD = $(top_builddir)/src/lib/libelementary.la
module_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
module_la_LIBTOOLFLAGS = --tag=disable-static

View File

@ -0,0 +1,33 @@
#include <Elementary.h>
// module api funcs needed
EAPI int
elm_modapi_init(void *m)
{
return 1; // succeed always
}
EAPI int
elm_modapi_shutdown(void *m)
{
return 1; // succeed always
}
// module fucns for the specific module type
EAPI void
obj_hook(Evas_Object *obj)
{
printf("hook: %p\n", obj);
}
EAPI void
obj_unhook(Evas_Object *obj)
{
printf("unhook: %p\n", obj);
}
EAPI void
obj_longpress(Evas_Object *obj)
{
printf("longpress: %p\n", obj);
}