Example #1
0
/* Externally accesible functions */
EAPI E_Entry_Dialog *
e_entry_dialog_show(const char *title, const char *icon, const char *text,
                    const char *initial_text,
                    const char *button_text, const char *button2_text,
                    void (*ok_func)(void *data, char *text),
                    void (*cancel_func)(void *data), void *data)
{
   E_Entry_Dialog *ed;
   E_Dialog *dia;
   Evas_Object *o, *ob;
   Evas_Modifier_Mask mask;
   int w, h;

   ed = E_OBJECT_ALLOC(E_Entry_Dialog, E_ENTRY_DIALOG_TYPE, _e_entry_dialog_free);
   ed->ok.func = ok_func;
   ed->ok.data = data;
   ed->cancel.func = cancel_func;
   ed->cancel.data = data;
   if (initial_text)
     ed->text = strdup(initial_text);

   dia = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_entry_dialog");
   if (!dia)
     {
        e_object_del(E_OBJECT(ed));
        return NULL;
     }
   dia->data = ed;
   ed->dia = dia;

   mask = 0;
   evas_object_key_ungrab(dia->event_object, "space", mask, ~mask);
   e_object_del_attach_func_set(E_OBJECT(dia), _e_entry_dia_del);
   e_win_delete_callback_set(dia->win, _e_entry_dialog_delete);

   if (title) e_dialog_title_set(dia, title);
   if (icon) e_dialog_icon_set(dia, icon, 64);

   o = e_widget_list_add(dia->win->evas, 0, 0);
   if (text)
     {
        ob = e_widget_label_add(dia->win->evas, text);
        e_widget_list_object_append(o, ob, 1, 0, 0.5);
     }

   ed->entry = e_widget_entry_add(dia->win->evas, &(ed->text), NULL, NULL, NULL);
   evas_object_smart_callback_add(ed->entry, "key_down", _e_entry_cb_key_down, ed);
   e_widget_list_object_append(o, ed->entry, 1, 1, 0.5);
   e_widget_size_min_get(o, &w, &h);
   e_dialog_content_set(dia, o, w, h);

   e_dialog_button_add(dia, !button_text ? _("OK") : button_text, NULL, _e_entry_dialog_ok, ed);
   e_dialog_button_add(dia, !button2_text ? _("Cancel") : button2_text, NULL, _e_entry_dialog_cancel, ed);

   e_win_centered_set(dia->win, 1);
   e_dialog_show(dia);
   e_widget_focus_set(ed->entry, 1);
   e_editable_select_all(e_widget_entry_editable_object_get(ed->entry));
   return ed;
}
Example #2
0
E_API E_Dialog *
e_util_dialog_internal(const char *title, const char *txt)
{
   E_Dialog *dia;

   dia = e_dialog_new(NULL, "E", "_error_dialog");
   if (!dia) return NULL;
   e_dialog_title_set(dia, title);
   e_dialog_text_set(dia, txt);
   e_dialog_icon_set(dia, "dialog-error", 64);
   e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
   e_dialog_button_focus_num(dia, 0);
   elm_win_center(dia->win, 1, 1);
   e_dialog_show(dia);
   return dia;
}
/********** externally accesible functions ****************/
EAPI E_Confirm_Dialog *
e_confirm_dialog_show(const char *title, const char *icon, const char *text,
                      const char *button_text, const char *button2_text,
                      void (*func)(void *data), void (*func2)(void *data),
                      void *data, void *data2,
                      void (*del_func)(void *data), void *del_data)
{
    E_Confirm_Dialog *cd;
    E_Dialog *dia;

    cd = E_OBJECT_ALLOC(E_Confirm_Dialog, E_CONFIRM_DIALOG_TYPE, _e_confirm_dialog_free);
    cd->yes.func = func;
    cd->yes.data = data;
    cd->no.func = func2;
    cd->no.data = data2;
    cd->del.func = del_func;
    cd->del.data = del_data;

    dia = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_confirm_dialog");
    if (!dia)
    {
        e_object_del(E_OBJECT(cd));
        return NULL;
    }
    dia->data = cd;
    cd->dia = dia;

    e_win_delete_callback_set(dia->win, _e_confirm_dialog_delete);

    if (title) e_dialog_title_set(dia, title);
    if (icon) e_dialog_icon_set(dia, icon, 64);
    if (text) e_dialog_text_set(dia, text);

    e_dialog_button_add(dia, !button_text ? _("Yes") : button_text, NULL, _e_confirm_dialog_yes, cd);
    e_dialog_button_add(dia, !button2_text ? _("No") : button2_text, NULL, _e_confirm_dialog_no, cd);

    e_dialog_button_focus_num(dia, 1);
    e_win_centered_set(dia->win, 1);
    e_dialog_show(dia);

    return cd;
}