Eina_Bool deferred_cur : 1;
Eina_Bool disabled : 1;
Eina_Bool context_menu : 1;
+ Eina_Bool drag_selection_asked : 1;
Eina_Bool bgcolor : 1;
Eina_Bool ellipsis : 1;
Eina_Bool autoreturnkey : 1;
};
static const char *widtype = NULL;
+
+static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Drop_Data *);
static void _del_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj);
static void _disable_hook(Evas_Object *obj);
}
static void
+_signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
+}
+
+static void *
+_signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source))
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ return edje_object_signal_callback_del(wd->ent, emission, source, func_cb);
+}
+
+static void
_hoversel_position(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Widget_Data *wd = elm_widget_data_get(data);
Ecore_X_Event_Selection_Notify *ev = event;
if (!wd) return ECORE_CALLBACK_PASS_ON;
- if (!wd->selection_asked) return ECORE_CALLBACK_PASS_ON;
+ if (!wd->selection_asked && !wd->drag_selection_asked)
+ return ECORE_CALLBACK_PASS_ON;
if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
(ev->selection == ECORE_X_SELECTION_PRIMARY))
}
wd->selection_asked = EINA_FALSE;
}
+ else if (ev->selection == ECORE_X_SELECTION_XDND)
+ {
+ Ecore_X_Selection_Data_Text *text_data;
+
+ text_data = ev->data;
+ if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
+ {
+ if (text_data->text)
+ {
+ char *txt = _text_to_mkup(text_data->text);
+
+ if (txt)
+ {
+ /* Massive FIXME: this should be at the drag point */
+ elm_entry_entry_insert(data, txt);
+ free(txt);
+ }
+ }
+ }
+ wd->drag_selection_asked = EINA_FALSE;
+
+ ecore_x_dnd_send_finished();
+
+ }
return ECORE_CALLBACK_PASS_ON;
}
// end for cbhm
return ECORE_CALLBACK_PASS_ON;
}
+
+
+static Eina_Bool
+_drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Drop_Data *drop)
+{
+ Widget_Data *wd;
+ Eina_Bool rv;
+
+ wd = elm_widget_data_get(obj);
+
+ if (!wd) return EINA_FALSE;
+printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
+
+ edje_object_part_text_cursor_copy(wd->ent, "elm.text",
+ EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
+ rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
+ EDJE_CURSOR_MAIN,drop->x,drop->y);
+ if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
+ elm_entry_entry_insert(obj, drop->data);
+ edje_object_part_text_cursor_copy(wd->ent, "elm.text",
+ EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
+
+ return EINA_TRUE;
+}
#endif
static Evas_Object *
elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_disable_hook_set(obj, _disable_hook);
elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
+ elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
+ elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
elm_widget_can_focus_set(obj, 1);
wd->linewrap = EINA_TRUE;
top = elm_widget_top_get(obj);
if ((top) && (elm_win_xwindow_get(top)))
{
- wd->sel_notify_handler =
- ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
- _event_selection_notify, obj);
- wd->sel_clear_handler =
- ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
- _event_selection_clear, obj);
+ wd->sel_notify_handler =
+ ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
+ _event_selection_notify, obj);
+ wd->sel_clear_handler =
+ ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
+ _event_selection_clear, obj);
}
+
+ elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
#endif
entries = eina_list_prepend(entries, obj);
text = edje_object_part_text_get(wd->ent, "elm.text");
if (!text)
{
-ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
-return NULL;
+ ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
+ return NULL;
}
eina_stringshare_replace(&wd->text, text);
return wd->text;
elm_entry_entry_set(obj, t);
eina_stringshare_del(t);
_sizing_eval(obj);
+
+#ifdef HAVE_ELEMENTARY_X
+ if (editable)
+ elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
+ else
+ elm_drop_target_del(obj);
+#endif
}
/**
if (!wd) return;
if (wd->selmode)
{
- wd->selmode = EINA_FALSE;
- edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
- edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
+ wd->selmode = EINA_FALSE;
+ edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
+ edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
}
wd->have_selection = EINA_FALSE;
edje_object_part_text_select_none(wd->ent, "elm.text");
if (!wd) return;
if (wd->selmode)
{
- wd->selmode = EINA_FALSE;
- edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
- edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
+ wd->selmode = EINA_FALSE;
+ edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
+ edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
}
wd->have_selection = EINA_TRUE;
edje_object_part_text_select_all(wd->ent, "elm.text");
ecore_imf_context_input_panel_layout_set(ic, (Ecore_IMF_Input_Panel_Layout)layout);
}
+
+/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/