On Wed, 22 Apr 2009 22:11:19 +0400 Sergey Semernin <sergey.semer...@gmail.com> said:
hmmm ... not what i wanted. i wanted edje's entry used as it can actually follow theme styles etc. etc. this uses e's entry which is old (and should now be replaced/deprecated). see elementary's elm_entry.c > Hello, All. > > This is patch for in-place files renaming in efm2. > > I was guided by next reasons: > - leave usual rename dialog, where it is more convenient; > - using theme for entry field (all entries looks the same); > > For theme elements: > e/fileman/default/icon/variable, > e/fileman/default/icon/fixed, > e/fileman/default/list/variable, > e/fileman/default/list_odd/variable, > e/fileman/default/list/fixed, > e/fileman/default/list_odd/fixed, > I have added entry pbject placement named "e.swallow.entry". > It could be any entry or editing widget, I'm using e_widget_entry. > > In e_fm.c I have added handlers for entry object: > _e_fm2_icon_entry_widget_add - create and focus entry field; > _e_fm2_icon_entry_widget_del - destroy entry field and return focus to > efm2 window; _e_fm2_icon_entry_widget_cb_key_down - key down handler for > entry widget; _e_fm2_icon_entry_widget_accept - do file rename and destroy > entry widget; Also in mouse and keyboard handlers of efm2 window I have added > conditions to prevent double event processing (with entry and then rest > objects of window). > > Renaming accepted when enter key pressed or other icon selected or icon > deselected. Renaming cancelling when escape key pressed or efm2 window closed. > Only one renaming allowed in efm2 window. > > data/themes/default.edc | 42 ++++++++++++ > src/bin/e_fm.c | 161 ++++++++++++++++++++++++++++++++++++ > +----------- 2 files changed, 169 insertions(+), 34 deletions(-) > > Index: e/data/themes/default.edc > =================================================================== > --- e/data/themes/default.edc (revision 40283) > +++ e/data/themes/default.edc (working copy) > @@ -13427,6 +13427,13 @@ > image.normal: "icon_efm_dnd_move.png"; > } > } > + part { name: "e.swallow.entry"; > + type: SWALLOW; > + description { state: "default" 0.0; > + rel1.to: "e.text.label"; > + rel2.to: "e.text.label"; > + } > + } > } > programs { > program { name: "go_active"; > @@ -13840,6 +13847,13 @@ > image.normal: "icon_efm_dnd_move.png"; > } > } > + part { name: "e.swallow.entry"; > + type: SWALLOW; > + description { state: "default" 0.0; > + rel1.to: "e.text.label"; > + rel2.to: "e.text.label"; > + } > + } > } > programs { > program { name: "go_active"; > @@ -15082,6 +15096,13 @@ > color: 0 0 0 0; > } > } > + part { name: "e.swallow.entry"; > + type: SWALLOW; > + description { state: "default" 0.0; > + rel1.to: "e.text.label"; > + rel2.to: "e.text.label"; > + } > + } > } > programs { > program { name: "go_active"; > @@ -15547,6 +15568,13 @@ > color: 0 0 0 0; > } > } > + part { name: "e.swallow.entry"; > + type: SWALLOW; > + description { state: "default" 0.0; > + rel1.to: "e.text.label"; > + rel2.to: "e.text.label"; > + } > + } > } > programs { > program { name: "go_active"; > @@ -16014,6 +16042,13 @@ > color: 0 0 0 0; > } > } > + part { name: "e.swallow.entry"; > + type: SWALLOW; > + description { state: "default" 0.0; > + rel1.to: "e.text.label"; > + rel2.to: "e.text.label"; > + } > + } > } > programs { > program { name: "go_active"; > @@ -16480,6 +16515,13 @@ > color: 0 0 0 0; > } > } > + part { name: "e.swallow.entry"; > + type: SWALLOW; > + description { state: "default" 0.0; > + rel1.to: "e.text.label"; > + rel2.to: "e.text.label"; > + } > + } > } > programs { > program { name: "go_active"; > Index: e/src/bin/e_fm.c > =================================================================== > --- e/src/bin/e_fm.c (revision 40283) > +++ e/src/bin/e_fm.c (working copy) > @@ -127,6 +127,8 @@ > int ox, oy; > int x, y, w, h; > } selrect; > + > + E_Fm2_Icon *iop_icon; > }; > > struct _E_Fm2_Region > @@ -147,6 +149,7 @@ > int saved_rel; > E_Menu *menu; > E_Entry_Dialog *entry_dialog; > + Evas_Object *entry_widget; > E_Config_Dialog *prop_dialog; > E_Dialog *dialog; > > @@ -324,7 +327,13 @@ > static void _e_fm2_file_rename_no_cb(void *data); > static void _e_fm2_file_properties(void *data, E_Menu *m, E_Menu_Item *mi); > static void _e_fm2_file_properties_delete_cb(void *obj); > +static void _e_fm2_file_do_rename(const char *text, E_Fm2_Icon *ic); > > +static Evas_Object* _e_fm2_icon_entry_widget_add(E_Fm2_Icon *ic); > +static void _e_fm2_icon_entry_widget_del(E_Fm2_Icon *ic); > +static void _e_fm2_icon_entry_widget_cb_key_down(void *data, Evas > *e, Evas_Object *obj, void *event_info); +static void > _e_fm2_icon_entry_widget_accept(E_Fm2_Icon *ic); + > static void _e_fm_retry_abort_dialog(int pid, const char *str); > static void _e_fm_retry_abort_delete_cb(void *obj); > static void _e_fm_retry_abort_retry_cb(void *data, E_Dialog *dialog); > @@ -4453,6 +4462,8 @@ > e_object_del(E_OBJECT(ic->entry_dialog)); > ic->entry_dialog = NULL; > } > + if (ic->entry_widget) > + _e_fm2_icon_entry_widget_del(ic); > if (ic->prop_dialog) > { > e_object_del(E_OBJECT(ic->prop_dialog)); > @@ -4669,6 +4680,9 @@ > { > const char *selectraise; > > + if(ic->sd->iop_icon) > + _e_fm2_icon_entry_widget_accept(ic->sd->iop_icon); > + > edje_object_signal_emit(ic->obj, "e,state,selected", "e"); > edje_object_signal_emit(ic->obj_icon, "e,state,selected", "e"); > evas_object_stack_below(ic->obj, ic->sd->drop); > @@ -4688,6 +4702,9 @@ > { > const char *stacking, *selectraise; > > + if(ic->entry_widget) > + _e_fm2_icon_entry_widget_accept(ic); > + > edje_object_signal_emit(ic->obj, "e,state,unselected", "e"); > edje_object_signal_emit(ic->obj_icon, "e,state,unselected", "e"); > stacking = edje_object_data_get(ic->obj, "stacking"); > @@ -6297,6 +6314,10 @@ > > ic = data; > ev = event_info; > + > + if (ic->entry_widget) > + return; > + > if ((ev->button == 1) && (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)) > { > /* if its a directory && open dirs in-place is set then change the > dir @@ -6340,6 +6361,9 @@ > ic = data; > ev = event_info; > > + if (ic->entry_widget) > + return; > + > if ((ev->button == 1) && (!ic->drag.dnd)) > { > if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)) > @@ -6449,6 +6473,10 @@ > > ic = data; > ev = event_info; > + > + if (ic->entry_widget) > + return; > + > if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; > if ((ic->drag.start) && (ic->sd->eobj)) > { > @@ -6656,6 +6684,9 @@ > sd = data; > ev = event_info; > > + if(sd->iop_icon) > + return; > + > if (evas_key_modifier_is_set(ev->modifiers, "Control")) > { > if (!strcmp(ev->key, "x")) > @@ -8370,30 +8401,84 @@ > _e_fm2_file_rename(void *data, E_Menu *m, E_Menu_Item *mi) > { > E_Fm2_Icon *ic; > - E_Manager *man; > - E_Container *con; > char text[PATH_MAX + 256]; > > ic = data; > - if (ic->entry_dialog) return; > + if (ic->entry_dialog || ic->entry_widget) return; > > - man = e_manager_current_get(); > - if (!man) return; > - con = e_container_current_get(man); > - if (!con) return; > + if (!_e_fm2_icon_entry_widget_add(ic)) > + { > + snprintf(text, PATH_MAX + 256, > + _("Rename %s to:"), > + ic->info.file); > + ic->entry_dialog = e_entry_dialog_show(_("Rename File"), > "edit-rename", > + text, ic->info.file, NULL, NULL, > + _e_fm2_file_rename_yes_cb, > + _e_fm2_file_rename_no_cb, ic); > + E_OBJECT(ic->entry_dialog)->data = ic; > + e_object_del_attach_func_set(E_OBJECT(ic->entry_dialog), > _e_fm2_file_rename_delete_cb); > + } > +} > > - snprintf(text, PATH_MAX + 256, > - _("Rename %s to:"), > - ic->info.file); > - ic->entry_dialog = e_entry_dialog_show(_("Rename File"), "edit-rename", > - text, ic->info.file, NULL, NULL, > - _e_fm2_file_rename_yes_cb, > - _e_fm2_file_rename_no_cb, ic); > - E_OBJECT(ic->entry_dialog)->data = ic; > - e_object_del_attach_func_set(E_OBJECT(ic->entry_dialog), > _e_fm2_file_rename_delete_cb); +static Evas_Object* > +_e_fm2_icon_entry_widget_add(E_Fm2_Icon *ic) > +{ > + Evas_Object *eo; > + > + if (ic->sd->iop_icon) > + _e_fm2_icon_entry_widget_accept(ic->sd->iop_icon); > + > + if (!edje_object_part_exists(ic->obj, "e.swallow.entry")) > + return NULL; > + > + ic->entry_widget = e_widget_entry_add(evas_object_evas_get(ic->obj), > + NULL, NULL, NULL, NULL); > + evas_object_event_callback_add(ic->entry_widget, EVAS_CALLBACK_KEY_DOWN, > + _e_fm2_icon_entry_widget_cb_key_down, ic); > + edje_object_part_swallow(ic->obj, "e.swallow.entry", ic->entry_widget); > + evas_object_show(ic->entry_widget); > + e_widget_entry_text_set(ic->entry_widget, ic->info.file); > + e_widget_focus_set(ic->entry_widget, 0); > + eo = e_widget_entry_editable_object_get(ic->entry_widget); > + e_editable_cursor_move_to_start(eo); > + e_editable_selection_move_to_end(eo); > + ic->sd->iop_icon = ic; > + > + return ic->entry_widget; > } > > static void > +_e_fm2_icon_entry_widget_del(E_Fm2_Icon *ic) > +{ > + ic->sd->iop_icon = NULL; > + evas_object_focus_set(ic->sd->obj, 1); > + evas_object_del(ic->entry_widget); > + ic->entry_widget = NULL; > +} > + > +static void > +_e_fm2_icon_entry_widget_cb_key_down(void *data, Evas *e, Evas_Object *obj, > void *event_info) +{ > + Evas_Event_Key_Down *ev; > + E_Fm2_Icon *ic; > + > + ev = event_info; > + ic = data; > + > + if (!strcmp(ev->key, "Escape")) > + _e_fm2_icon_entry_widget_del(ic); > + else if (!strcmp(ev->key, "Return")) > + _e_fm2_icon_entry_widget_accept(ic); > +} > + > +static void > +_e_fm2_icon_entry_widget_accept(E_Fm2_Icon *ic) > +{ > + _e_fm2_file_do_rename(e_widget_entry_text_get(ic->entry_widget), ic); > + _e_fm2_icon_entry_widget_del(ic); > +} > + > +static void > _e_fm2_file_rename_delete_cb(void *obj) > { > E_Fm2_Icon *ic; > @@ -8406,27 +8491,11 @@ > _e_fm2_file_rename_yes_cb(char *text, void *data) > { > E_Fm2_Icon *ic; > - char oldpath[PATH_MAX]; > - char newpath[PATH_MAX]; > - char *args = NULL; > - size_t size = 0; > - size_t length = 0; > > ic = data; > ic->entry_dialog = NULL; > - if ((text) && (strcmp(text, ic->info.file))) > - { > - _e_fm2_icon_realpath(ic, oldpath, sizeof(oldpath)); > - snprintf(newpath, sizeof(newpath), "%s/%s", ic->sd->realpath, text); > - if (e_filereg_file_protected(oldpath)) return; > > - args = _e_fm_string_append_quoted(args, &size, &length, oldpath); > - args = _e_fm_string_append_char(args, &size, &length, ' '); > - args = _e_fm_string_append_quoted(args, &size, &length, newpath); > - > - _e_fm_client_file_move(args, ic->sd->obj); > - free(args); > - } > + _e_fm2_file_do_rename(text, ic); > } > > static void > @@ -8438,6 +8507,30 @@ > ic->entry_dialog = NULL; > } > > +static void > +_e_fm2_file_do_rename(const char *text, E_Fm2_Icon *ic) > +{ > + char oldpath[PATH_MAX]; > + char newpath[PATH_MAX]; > + char *args = NULL; > + size_t size = 0; > + size_t length = 0; > + > + if ((text) && (strcmp(text, ic->info.file))) > + { > + _e_fm2_icon_realpath(ic, oldpath, sizeof(oldpath)); > + snprintf(newpath, sizeof(newpath), "%s/%s", ic->sd->realpath, text); > + if (e_filereg_file_protected(oldpath)) return; > + > + args = _e_fm_string_append_quoted(args, &size, &length, oldpath); > + args = _e_fm_string_append_char(args, &size, &length, ' '); > + args = _e_fm_string_append_quoted(args, &size, &length, newpath); > + > + _e_fm_client_file_move(args, ic->sd->obj); > + free(args); > + } > +} > + > static void _e_fm_retry_abort_dialog(int pid, const char *str) > { > E_Manager *man; > @@ -8662,7 +8755,7 @@ > E_Container *con; > > ic = data; > - if (ic->entry_dialog) return; > + if (ic->entry_dialog || ic->entry_widget) return; > > man = e_manager_current_get(); > if (!man) return; > > > Sincerely yours, Sergey. > > -- > Jabber/XMPP: sergey.semer...@gmail.com > Cellular: +7-909-206-5992 > -- ------------- Codito, ergo sum - "I code, therefore I am" -------------- The Rasterman (Carsten Haitzler) ras...@rasterman.com ------------------------------------------------------------------------------ Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel