forked from enlightenment/ecrire
opensave: save/open directories.
Guards against one action (selecting a directory). Show a little popup.
This commit is contained in:
parent
b2a6f80ed7
commit
6d63c0cb09
|
@ -1,20 +1,71 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
|
|
||||||
|
#include "../mess_header.h"
|
||||||
|
|
||||||
typedef struct _File_Selector_Data
|
typedef struct _File_Selector_Data
|
||||||
{
|
{
|
||||||
|
Evas_Object *parent;
|
||||||
Evas_Object *inwin;
|
Evas_Object *inwin;
|
||||||
|
Eina_Bool save;
|
||||||
void (*func)(void *, Evas_Object *, void *);
|
void (*func)(void *, Evas_Object *, void *);
|
||||||
void *data;
|
void *data;
|
||||||
} File_Selector_Data;
|
} File_Selector_Data;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_warning_popup_close_cb(void *data, Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
evas_object_del((Evas_Object *) data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_warning_popup(Evas_Object *parent, const char *msg)
|
||||||
|
{
|
||||||
|
Evas_Object *popup, *btn;
|
||||||
|
|
||||||
|
popup = elm_popup_add(parent);
|
||||||
|
elm_object_part_text_set(popup, "title,text", _("Warning"));
|
||||||
|
elm_object_text_set(popup, eina_slstr_printf("<align=center>%s.</>", msg));
|
||||||
|
|
||||||
|
btn = elm_button_add(popup);
|
||||||
|
elm_object_text_set(btn, _("Close"));
|
||||||
|
evas_object_show(btn);
|
||||||
|
evas_object_smart_callback_add(btn, "clicked", _warning_popup_close_cb, popup);
|
||||||
|
elm_object_part_content_set(popup, "button1", btn);
|
||||||
|
|
||||||
|
elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
|
||||||
|
evas_object_show(popup);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cleaning_cb(void *data, Evas_Object *obj, void *event_info)
|
_cleaning_cb(void *data, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
|
char *path;
|
||||||
|
const char *error = NULL;
|
||||||
File_Selector_Data *fsdata = data;
|
File_Selector_Data *fsdata = data;
|
||||||
fsdata->func(fsdata->data, obj, event_info);
|
path = event_info;
|
||||||
evas_object_del(fsdata->inwin);
|
|
||||||
free(fsdata);
|
if (fsdata->save)
|
||||||
|
{
|
||||||
|
if (ecore_file_is_dir(path))
|
||||||
|
error = eina_slstr_printf(_("Unable to save to directory '%s'"), path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ecore_file_is_dir(path))
|
||||||
|
error = eina_slstr_printf(_("Unable to open directory '%s'"), path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
_warning_popup(fsdata->parent, error);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (path)
|
||||||
|
fsdata->func(fsdata->data, obj, path);
|
||||||
|
|
||||||
|
evas_object_del(fsdata->inwin);
|
||||||
|
free(fsdata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -36,9 +87,11 @@ ui_file_open_save_dialog_open(Evas_Object *parent, Eina_Bool save,
|
||||||
evas_object_show(fs);
|
evas_object_show(fs);
|
||||||
|
|
||||||
fsdata = malloc(sizeof(File_Selector_Data));
|
fsdata = malloc(sizeof(File_Selector_Data));
|
||||||
fsdata->inwin = inwin;
|
fsdata->parent = parent;
|
||||||
fsdata->func = func;
|
fsdata->inwin = inwin;
|
||||||
fsdata->data = data;
|
fsdata->save = save;
|
||||||
|
fsdata->func = func;
|
||||||
|
fsdata->data = data;
|
||||||
|
|
||||||
evas_object_smart_callback_add(fs, "done", _cleaning_cb, fsdata);
|
evas_object_smart_callback_add(fs, "done", _cleaning_cb, fsdata);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue