3 /* Private function definitions */
4 static void _e_entry_dia_del(void *data);
5 static void _e_entry_dialog_free(E_Entry_Dialog *dia);
6 static void _e_entry_dialog_ok(void *data, E_Dialog *dia);
7 static void _e_entry_dialog_cancel(void *data, E_Dialog *dia);
8 static void _e_entry_dialog_delete(E_Win *win);
9 static void _e_entry_cb_key_down(void *data, Evas_Object *obj, void *event_info);
11 /* Externally accesible functions */
13 e_entry_dialog_show(const char *title, const char *icon, const char *text,
14 const char *initial_text,
15 const char *button_text, const char *button2_text,
16 void (*ok_func)(void *data, char *text),
17 void (*cancel_func)(void *data), void *data)
22 Evas_Modifier_Mask mask;
25 ed = E_OBJECT_ALLOC(E_Entry_Dialog, E_ENTRY_DIALOG_TYPE, _e_entry_dialog_free);
26 ed->ok.func = ok_func;
28 ed->cancel.func = cancel_func;
29 ed->cancel.data = data;
31 ed->text = strdup(initial_text);
33 dia = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_entry_dialog");
36 e_object_del(E_OBJECT(ed));
43 evas_object_key_ungrab(dia->event_object, "space", mask, ~mask);
44 e_object_del_attach_func_set(E_OBJECT(dia), _e_entry_dia_del);
45 e_win_delete_callback_set(dia->win, _e_entry_dialog_delete);
47 if (title) e_dialog_title_set(dia, title);
48 if (icon) e_dialog_icon_set(dia, icon, 64);
50 o = e_widget_list_add(dia->win->evas, 0, 0);
53 ob = e_widget_label_add(dia->win->evas, text);
54 e_widget_list_object_append(o, ob, 1, 0, 0.5);
57 ed->entry = e_widget_entry_add(dia->win->evas, &(ed->text), NULL, NULL, NULL);
58 evas_object_smart_callback_add(ed->entry, "key_down", _e_entry_cb_key_down, ed);
59 e_widget_list_object_append(o, ed->entry, 1, 1, 0.5);
60 e_widget_size_min_get(o, &w, &h);
61 e_dialog_content_set(dia, o, 2 * w, h);
63 e_dialog_button_add(dia, !button_text ? _("OK") : button_text, NULL, _e_entry_dialog_ok, ed);
64 e_dialog_button_add(dia, !button2_text ? _("Cancel") : button2_text, NULL, _e_entry_dialog_cancel, ed);
66 e_win_centered_set(dia->win, 1);
68 e_widget_focus_set(ed->entry, 1);
69 e_editable_select_all(e_widget_entry_editable_object_get(ed->entry));
73 /* Private Function Bodies */
75 _e_entry_dia_del(void *data)
79 e_object_del(dia->data);
83 _e_entry_dialog_free(E_Entry_Dialog *ed)
85 e_object_del(E_OBJECT(ed->dia));
91 _e_entry_dialog_ok(void *data, E_Dialog *dia __UNUSED__)
96 e_object_ref(E_OBJECT(ed));
97 if (ed->ok.func) ed->ok.func(ed->ok.data, ed->text);
98 e_object_del(E_OBJECT(ed));
99 e_object_unref(E_OBJECT(ed));
103 _e_entry_dialog_cancel(void *data, E_Dialog *dia __UNUSED__)
108 e_object_ref(E_OBJECT(ed));
109 if (ed->cancel.func) ed->cancel.func(ed->cancel.data);
110 e_object_del(E_OBJECT(ed));
111 e_object_unref(E_OBJECT(ed));
115 _e_entry_dialog_delete(E_Win *win)
122 e_object_del(E_OBJECT(ed));
126 _e_entry_cb_key_down(void *data, Evas_Object *obj __UNUSED__, void *event_info)
128 Evas_Event_Key_Down *ev;
132 if (!(ed = data)) return;
133 if (!strcmp(ev->keyname, "Return"))
134 _e_entry_dialog_ok(data, ed->dia);
136 if (!strcmp(ev->keyname, "Escape"))
137 _e_entry_dialog_cancel(data, ed->dia);