rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=a00c65a41a97976ed88c83d0de13becab6ce9e47
commit a00c65a41a97976ed88c83d0de13becab6ce9e47 Author: Andrii Kroitor <[email protected]> Date: Thu Apr 14 10:53:20 2016 +0300 eflete: add command line option to create new project you can add widgets using -w option. if widget specified by -w is not found it will be ignored --- src/bin/main.c | 40 +++++++++++++++++++++++++++++++++---- src/bin/ui/tab_home_new.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++ src/bin/ui/tabs.c | 6 ++++++ src/bin/ui/tabs.h | 8 ++++++++ src/bin/ui/tabs_private.h | 3 +++ 5 files changed, 104 insertions(+), 4 deletions(-) diff --git a/src/bin/main.c b/src/bin/main.c index 212b20a..7d9aee4 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -35,6 +35,7 @@ static Eina_List *img_dirs = NULL; static Eina_List *snd_dirs = NULL; static Eina_List *fnt_dirs = NULL; static Eina_List *data_dirs = NULL; +static Eina_List *widgets = NULL; #define _ERR_EXIT(MSG, ...) \ do { \ @@ -63,6 +64,7 @@ static const Ecore_Getopt options = { ECORE_GETOPT_APPEND_METAVAR('s', "sd", "Add sound directory for edc compilation", "DIR_NAME", ECORE_GETOPT_TYPE_STR), ECORE_GETOPT_APPEND_METAVAR('f', "fd", "Add font directory for edc compilation", "DIR_NAME", ECORE_GETOPT_TYPE_STR), ECORE_GETOPT_APPEND_METAVAR('d', "dd", "Add data directory for edc compilation", "DIR_NAME", ECORE_GETOPT_TYPE_STR), + ECORE_GETOPT_APPEND_METAVAR('w', "widget", "Add widget to new project", "WIDGET_NAME", ECORE_GETOPT_TYPE_STR), ECORE_GETOPT_STORE_TRUE('r', "reopen", "reopen last project"), ECORE_GETOPT_VERSION ('v', "version"), ECORE_GETOPT_COPYRIGHT('c', "copyright"), @@ -148,6 +150,25 @@ _import_edc(void *data __UNUSED__) tabs_menu_tab_open(TAB_HOME_IMPORT_EDC); } +static void +_new_project(void *data __UNUSED__) +{ + const char *name; + Eina_Tmpstr *proj_name; + if (pro_name) + { + tabs_menu_new_data_set(pro_name, pro_path, widgets); + } + else + { + name = ecore_file_file_get(file); + proj_name = eina_tmpstr_add_length(name, strlen(name) - 4); + tabs_menu_new_data_set(proj_name, pro_path, widgets); + eina_tmpstr_del(proj_name); + } + tabs_menu_tab_open(TAB_HOME_NEW_PROJECT); +} + EAPI_MAIN int elm_main(int argc, char **argv) { @@ -163,6 +184,7 @@ elm_main(int argc, char **argv) ECORE_GETOPT_VALUE_LIST(snd_dirs), ECORE_GETOPT_VALUE_LIST(fnt_dirs), ECORE_GETOPT_VALUE_LIST(data_dirs), + ECORE_GETOPT_VALUE_LIST(widgets), ECORE_GETOPT_VALUE_BOOL(reopen), ECORE_GETOPT_VALUE_BOOL(info_only), ECORE_GETOPT_VALUE_BOOL(info_only), @@ -214,6 +236,8 @@ elm_main(int argc, char **argv) _ERR_EXIT(_("--reopen is given but --fd specified.")); if (data_dirs) _ERR_EXIT(_("--reopen is given but --dd specified.")); + if (widgets) + _ERR_EXIT(_("widgets can be added only to new project.")); config = config_get(); if (!config->recents) @@ -230,6 +254,8 @@ elm_main(int argc, char **argv) _ERR_EXIT(_("File '%s' doesn't exists."), file); if (ecore_file_is_dir(file)) _ERR_EXIT(_("'%s' is a directory."), file); + if (widgets) + _ERR_EXIT(_("widgets can be added only to new project.")); if (eina_str_has_suffix(file, ".pro")) { @@ -274,10 +300,8 @@ elm_main(int argc, char **argv) else { TODO("Remove this after adding new project creation when --name is given without filename"); - if (pro_name) - _ERR_EXIT(_("no file is given but --name specified.")); - if (pro_path) - _ERR_EXIT(_("no file is given but --path specified.")); + if (!pro_name && pro_path) + _ERR_EXIT(_("no file or --name are given but --path specified.")); if (img_dirs) _ERR_EXIT(_("no file is given but --id specified.")); if (snd_dirs) @@ -286,6 +310,14 @@ elm_main(int argc, char **argv) _ERR_EXIT(_("no file is given but --fd specified.")); if (data_dirs) _ERR_EXIT(_("no file is given but --dd specified.")); + + if (pro_name) + { + ecore_job_add(_new_project, NULL); + goto run; + } + else if (widgets) + _ERR_EXIT(_("widgets can be added only to new project.")); } run: diff --git a/src/bin/ui/tab_home_new.c b/src/bin/ui/tab_home_new.c index 2042aca..a729b81 100644 --- a/src/bin/ui/tab_home_new.c +++ b/src/bin/ui/tab_home_new.c @@ -630,3 +630,54 @@ _tab_new_project_add(void) return tab_new.layout; } + +static void +_delayed_popup(void *data) +{ + char *msg = data; + popup_want_action(_("New project"), msg, NULL, NULL, BTN_OK, NULL, NULL); + free(msg); +} + +void +_tab_new_data_set(const char *name, const char *path, const Eina_List *widgets) +{ + const Eina_List *l; + const char *str; + Widget_Item_Data *widget_item_data_iterator; + Eina_Strbuf *buf = eina_strbuf_new(); + Eina_Bool first_not_found = true; + + assert(tab_new.layout != NULL); + + elm_entry_entry_set(tab_new.name, name); + + if (path) elm_entry_entry_set(tab_new.path, path); + else elm_entry_entry_set(tab_new.path, profile_get()->general.projects_folder); + + EINA_LIST_FOREACH(widgets, l, str) + { + widget_item_data_iterator = widget_item_data; + while (widget_item_data_iterator->name) + { + if (!strcasecmp(str, widget_item_data_iterator->name)) + break; + widget_item_data_iterator++; + } + if (widget_item_data_iterator->name) + widget_item_data_iterator->check = true; + else + { + eina_strbuf_append_printf(buf, first_not_found ? "%s" : ", %s", str); + first_not_found = false; + } + } + elm_genlist_realized_items_update(tab_new.genlist); + if (eina_strbuf_length_get(buf)) + { + eina_strbuf_prepend(buf, _("Following widgets were not found and ignored: ")); + ERR("%s", eina_strbuf_string_get(buf)); + ecore_job_add(_delayed_popup, eina_strbuf_string_steal(buf)); + } + eina_strbuf_free(buf); +} diff --git a/src/bin/ui/tabs.c b/src/bin/ui/tabs.c index b46e303..142edca 100644 --- a/src/bin/ui/tabs.c +++ b/src/bin/ui/tabs.c @@ -1099,6 +1099,12 @@ tabs_menu_import_edc_data_set(const char *name, const char *path, const char *ed _tab_import_edc_data_set(name, path, edc, img, snd, fnt, dd); } +void +tabs_menu_new_data_set(const char *name, const char *path, const Eina_List *widgets) +{ + _tab_new_data_set(name, path, widgets); +} + static void _tab_close(void *data, Elm_Object_Item *it __UNUSED__, diff --git a/src/bin/ui/tabs.h b/src/bin/ui/tabs.h index 3f3a28a..a6ad43a 100644 --- a/src/bin/ui/tabs.h +++ b/src/bin/ui/tabs.h @@ -78,6 +78,14 @@ tabs_menu_import_edc_data_set(const char *name, const char *path, const char *ed const Eina_List *img, const Eina_List *snd, const Eina_List *fnt, const Eina_List *dd); /** + * Fill the new project tab fields + * + * @ingroup Tabs + */ +void +tabs_menu_new_data_set(const char *name, const char *path, const Eina_List *widgets); + +/** * Add new tab. This tab consist a workspace and a liveview. * * @param group The Group object diff --git a/src/bin/ui/tabs_private.h b/src/bin/ui/tabs_private.h index ccdd194..f5670bb 100644 --- a/src/bin/ui/tabs_private.h +++ b/src/bin/ui/tabs_private.h @@ -58,6 +58,9 @@ void _tab_import_edc_data_set(const char *name, const char *path, const char *edc, const Eina_List *img, const Eina_List *snd, const Eina_List *fnt, const Eina_List *dd); +void +_tab_new_data_set(const char *name, const char *path, const Eina_List *widgets); + Evas_Object * _tab_import_edc_add(void); --
