136 lines
4.2 KiB
C
136 lines
4.2 KiB
C
|
#ifdef HAVE_CONFIG_H
|
||
|
# include "config.h"
|
||
|
#endif
|
||
|
|
||
|
#include <Elementary.h>
|
||
|
|
||
|
#include "edi_welcome.h"
|
||
|
#include "edi_private.h"
|
||
|
|
||
|
static Evas_Object *_welcome_window;
|
||
|
|
||
|
|
||
|
static void
|
||
|
_edi_welcome_project_chosen_cb(void *data,
|
||
|
Evas_Object *obj EINA_UNUSED,
|
||
|
void *event_info)
|
||
|
{
|
||
|
evas_object_del(data);
|
||
|
|
||
|
if (event_info)
|
||
|
{
|
||
|
evas_object_del(_welcome_window);
|
||
|
|
||
|
edi_project_set(event_info);
|
||
|
edi_open(edi_project_get());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
_edi_welcome_choose_exit(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||
|
{
|
||
|
evas_object_del(data);
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
_edi_welcome_project_choose_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||
|
{
|
||
|
Evas_Object *win, *fs;
|
||
|
|
||
|
elm_need_ethumb();
|
||
|
elm_need_efreet();
|
||
|
|
||
|
win = elm_win_util_standard_add("projectselector", "Choose a Project Folder");
|
||
|
if (!win) return;
|
||
|
|
||
|
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
|
||
|
evas_object_smart_callback_add(win, "delete,request", _edi_welcome_choose_exit, win);
|
||
|
|
||
|
fs = elm_fileselector_add(win);
|
||
|
evas_object_size_hint_weight_set(fs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||
|
evas_object_size_hint_align_set(fs, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||
|
evas_object_smart_callback_add(fs, "done", _edi_welcome_project_chosen_cb, win);
|
||
|
elm_win_resize_object_add(win, fs);
|
||
|
evas_object_show(fs);
|
||
|
|
||
|
elm_fileselector_expandable_set(fs, EINA_TRUE);
|
||
|
elm_fileselector_folder_only_set(fs, EINA_TRUE);
|
||
|
elm_fileselector_path_set(fs, getenv("HOME"));
|
||
|
elm_fileselector_sort_method_set(fs, ELM_FILESELECTOR_SORT_BY_FILENAME_ASC);
|
||
|
|
||
|
evas_object_resize(win, 380 * elm_config_scale_get(), 260 * elm_config_scale_get());
|
||
|
evas_object_show(win);
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
_edi_welcome_exit(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||
|
{
|
||
|
evas_object_del(data);
|
||
|
edi_close();
|
||
|
}
|
||
|
|
||
|
Evas_Object *edi_welcome_show()
|
||
|
{
|
||
|
Evas_Object *win, *hbx, *box, *button, *label, *image;
|
||
|
char buf[PATH_MAX];
|
||
|
|
||
|
win = elm_win_util_standard_add("main", "Welcome to Edi");
|
||
|
if (!win) return NULL;
|
||
|
|
||
|
_welcome_window = win;
|
||
|
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
|
||
|
evas_object_smart_callback_add(win, "delete,request", _edi_welcome_exit, win);
|
||
|
|
||
|
hbx = elm_box_add(win);
|
||
|
elm_box_horizontal_set(hbx, EINA_TRUE);
|
||
|
evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||
|
elm_win_resize_object_add(win, hbx);
|
||
|
evas_object_show(hbx);
|
||
|
|
||
|
/* Existing projects area */
|
||
|
box = elm_box_add(hbx);
|
||
|
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||
|
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||
|
elm_box_pack_end(hbx, box);
|
||
|
evas_object_show(box);
|
||
|
|
||
|
label = elm_label_add(box);
|
||
|
elm_object_text_set(label, "Recent Projects:");
|
||
|
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||
|
evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||
|
elm_box_pack_end(box, label);
|
||
|
evas_object_show(label);
|
||
|
|
||
|
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);
|
||
|
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||
|
elm_box_pack_end(hbx, box);
|
||
|
evas_object_show(box);
|
||
|
|
||
|
snprintf(buf, sizeof(buf), "%s/images/welcome.png", elm_app_data_dir_get());
|
||
|
image = elm_image_add(box);
|
||
|
elm_image_file_set(image, buf, NULL);
|
||
|
evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||
|
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, "Create New Project");
|
||
|
elm_object_disabled_set(button, EINA_TRUE);
|
||
|
elm_box_pack_end(box, button);
|
||
|
evas_object_show(button);
|
||
|
|
||
|
evas_object_resize(win, 320 * elm_config_scale_get(), 240 * elm_config_scale_get());
|
||
|
evas_object_show(win);
|
||
|
|
||
|
return win;
|
||
|
}
|