forked from enlightenment/edi
Don't try to open recent projects if they can't be found.
Allow the user to choose if it should be deleted or not before returning. Submitted by Kelly Wilson
This commit is contained in:
parent
e33b39aa2a
commit
123c137a24
|
@ -279,3 +279,21 @@ _edi_config_project_add(const char *path)
|
|||
_edi_cfg->projects = eina_list_prepend(_edi_cfg->projects, project);
|
||||
_edi_config_save();
|
||||
}
|
||||
|
||||
void
|
||||
_edi_config_project_remove(const char *path)
|
||||
{
|
||||
Edi_Config_Project *project;
|
||||
Eina_List *list, *next;
|
||||
|
||||
EINA_LIST_FOREACH_SAFE(_edi_cfg->projects, list, next, project)
|
||||
{
|
||||
if (!strncmp(project->path, path, strlen(project->path)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_edi_cfg->projects = eina_list_remove(_edi_cfg->projects, project);
|
||||
_edi_config_save();
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ void _edi_config_load(void);
|
|||
void _edi_config_save(void);
|
||||
|
||||
void _edi_config_project_add(const char *path);
|
||||
void _edi_config_project_remove(const char *path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -15,15 +15,73 @@
|
|||
#define _EDI_WELCOME_PROJECT_NEW_TABLE_WIDTH 4
|
||||
|
||||
static Evas_Object *_welcome_window;
|
||||
static Evas_Object *_edi_new_popup;
|
||||
static Evas_Object *_edi_welcome_list;
|
||||
static Evas_Object *_edi_project_box;
|
||||
static Evas_Object *_create_inputs[5];
|
||||
static const char *_edi_message_path;
|
||||
|
||||
static void _edi_welcome_add_recent_projects(Evas_Object *);
|
||||
|
||||
static void
|
||||
_edi_welcome_project_open(const char *path)
|
||||
_edi_on_close_message(void *data,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
evas_object_del(_welcome_window);
|
||||
evas_object_del(data);
|
||||
evas_object_del(_edi_new_popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_on_delete_message(void *data,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
_edi_config_project_remove(_edi_message_path);
|
||||
|
||||
evas_object_del(_edi_welcome_list);
|
||||
_edi_welcome_add_recent_projects(_edi_project_box);
|
||||
evas_object_del(data);
|
||||
evas_object_del(_edi_new_popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_message_open(const char *message)
|
||||
{
|
||||
Evas_Object *popup, *button;
|
||||
|
||||
popup = elm_popup_add(_welcome_window);
|
||||
_edi_new_popup = popup;
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
message);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "Ok");
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_on_close_message, NULL);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "Delete");
|
||||
elm_object_part_content_set(popup, "button2", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_on_delete_message, NULL);
|
||||
|
||||
evas_object_show(popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_welcome_project_open(const char *path, const uint _edi_creating)
|
||||
{
|
||||
edi_project_set(path);
|
||||
edi_open(edi_project_get());
|
||||
|
||||
if ((edi_open(edi_project_get()) == NULL) && !_edi_creating)
|
||||
{
|
||||
_edi_message_path = path;
|
||||
_edi_message_open("Apparently that project directory doesn't exist");
|
||||
}
|
||||
else
|
||||
evas_object_del(_welcome_window);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -35,7 +93,7 @@ _edi_welcome_project_chosen_cb(void *data,
|
|||
|
||||
if (event_info)
|
||||
{
|
||||
_edi_welcome_project_open((const char*)event_info);
|
||||
_edi_welcome_project_open((const char*)event_info, EINA_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +213,7 @@ _edi_welcome_project_new_create_cb(void *data EINA_UNUSED, Evas_Object *obj EINA
|
|||
exit(0);
|
||||
}
|
||||
waitpid(pid, NULL, 0);
|
||||
_edi_welcome_project_open(fullpath);
|
||||
_edi_welcome_project_open(fullpath, EINA_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -206,7 +264,7 @@ static void
|
|||
_project_list_clicked(void *data, Evas_Object *li EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
_edi_welcome_project_open((const char *)data);
|
||||
_edi_welcome_project_open((const char *)data, EINA_FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -219,6 +277,7 @@ _edi_welcome_add_recent_projects(Evas_Object *box)
|
|||
int displen;
|
||||
|
||||
list = elm_list_add(box);
|
||||
_edi_welcome_list = list;
|
||||
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
|
||||
|
@ -280,15 +339,9 @@ Evas_Object *edi_welcome_show()
|
|||
elm_box_pack_end(box, label);
|
||||
evas_object_show(label);
|
||||
|
||||
_edi_project_box = box;
|
||||
_edi_welcome_add_recent_projects(box);
|
||||
|
||||
button = elm_button_add(box);
|
||||
elm_object_text_set(button, "Open Existing Project");
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_welcome_project_choose_cb, NULL);
|
||||
elm_box_pack_end(box, button);
|
||||
evas_object_show(button);
|
||||
|
||||
/* New project area */
|
||||
box = elm_box_add(hbx);
|
||||
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
@ -303,6 +356,14 @@ Evas_Object *edi_welcome_show()
|
|||
evas_object_size_hint_align_set(image, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(box, image);
|
||||
evas_object_show(image);
|
||||
|
||||
button = elm_button_add(box);
|
||||
elm_object_text_set(button, "Open Existing Project");
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_welcome_project_choose_cb, NULL);
|
||||
elm_box_pack_end(box, button);
|
||||
evas_object_show(button);
|
||||
|
||||
button = elm_button_add(box);
|
||||
elm_object_text_set(button, "Create New Project");
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
|
|
Loading…
Reference in New Issue