Initial welcome screen, working on adding the create project support

This commit is contained in:
Andy Williams 2014-06-29 23:54:29 +01:00
parent 2de3879b6c
commit 6a6851fd4a
9 changed files with 212 additions and 61 deletions

View File

@ -63,6 +63,7 @@ AM_GNU_GETTEXT([external])
AC_CONFIG_FILES([
Makefile
data/Makefile
data/images/Makefile
data/desktop/Makefile
data/desktop/edi.desktop
data/themes/Makefile

View File

@ -1,3 +1,4 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = themes desktop
SUBDIRS = themes desktop images

6
data/images/Makefile.am Normal file
View File

@ -0,0 +1,6 @@
MAINTAINERCLEANFILES = Makefile.in
imagesdir = $(datadir)/$(PACKAGE)/images
images_DATA = welcome.png
EXTRA_DIST = $(images_DATA)

BIN
data/images/welcome.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

View File

@ -1,4 +1,5 @@
MAINTAINERCLEANFILES = Makefile.in
AUTOMAKE_OPTIONS = subdir-objects
bin_PROGRAMS = edi edi_build
@ -12,6 +13,7 @@ AM_CPPFLAGS = -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
edi_SOURCES = \
editor/edi_editor_search.c \
editor/edi_editor.c \
welcome/edi_welcome.c \
edi_filepanel.c \
edi_logpanel.c \
edi_consolepanel.c \

View File

@ -17,6 +17,7 @@
#include "edi_logpanel.h"
#include "edi_consolepanel.h"
#include "edi_mainview.h"
#include "welcome/edi_welcome.h"
#include "edi_private.h"
@ -25,14 +26,6 @@
static Evas_Object *_edi_filepanel, *_edi_logpanel, *_edi_consolepanel;
static Evas_Object *_edi_main_win, *_edi_new_popup, *_edi_goto_popup;
static Evas_Object *edi_win_setup(const char *path);
static void
_edi_exit(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_exit();
}
static void
_edi_file_open_cb(const char *path, const char *type, Eina_Bool newwin)
{
@ -369,54 +362,6 @@ edi_toolbar_setup(Evas_Object *win)
return tb;
}
static void
_edi_project_chosen_cb(void *data,
Evas_Object *obj EINA_UNUSED,
void *event_info)
{
evas_object_del(data);
if (event_info)
{
edi_project_set(event_info);
edi_win_setup(edi_project_get());
}
else
elm_exit();
}
static Evas_Object *
_edi_project_choose()
{
Evas_Object *win, *fs;
elm_need_ethumb();
elm_need_efreet();
win = elm_win_util_standard_add("projectselector", "Choose a Project Folder");
if (!win) return NULL;
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
evas_object_smart_callback_add(win, "delete,request", _edi_exit, NULL);
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_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);
return win;
}
static char *
_edi_win_title_get(const char *path)
{
@ -429,13 +374,18 @@ _edi_win_title_get(const char *path)
return winname;
}
static Evas_Object *
edi_win_setup(const char *path)
static void
_edi_exit(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
edi_close();
}
EAPI Evas_Object *
edi_open(const char *path)
{
Evas_Object *win, *vbx, *content, *tb;
const char *winname;
if (!path) return _edi_project_choose();
edi_project_set(path);
elm_need_ethumb();
@ -470,6 +420,12 @@ edi_win_setup(const char *path)
return win;
}
EAPI void
edi_close()
{
elm_exit();
}
static const Ecore_Getopt optdesc = {
"edi",
"%prog [options] [project-dir]",
@ -530,7 +486,12 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
elm_app_info_set(elm_main, "edi", "images/edi.png");
if (!(win = edi_win_setup(project_path)))
if (!project_path)
{
if (!edi_welcome_show())
goto end;
}
else if (!(win = edi_open(project_path)))
goto end;
elm_run();

View File

@ -26,4 +26,8 @@ extern int _edi_lib_log_dom;
#define EDI_CONTENT_AUTOSAVE EINA_TRUE
EAPI Evas_Object *edi_open(const char *path);
EAPI void edi_close();
#endif

View File

@ -0,0 +1,135 @@
#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;
}

View File

@ -0,0 +1,41 @@
#ifndef EDI_WELCOME_H_
# define EDI_WELCOME_H_
#include <Elementary.h>
#include "Edi.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @file
* @brief These routines control the intro wizard for Edi.
*/
/**
* @brief UI management functions.
* @defgroup UI Initialisation and management of the welcome UI
*
* @{
*
*/
/**
* Initialize a new Edi welcome window and display it.
*
* @return The welcome window that is created
* * @ingroup UI
*/
EAPI Evas_Object *edi_welcome_show();
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* EDI_CONSOLEPANEL_H_ */