diff --git a/Makefile.am b/Makefile.am index 3e59bc3..75beb48 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,6 +12,9 @@ MAINTAINERCLEANFILES = \ install-sh \ ltmain.sh \ missing \ + m4/intl.m4 \ + m4/intldir.m4 \ + m4/intlmacosx.m4 \ m4/libtool.m4 \ m4/ltoptions.m4 \ m4/ltsugar.m4 \ diff --git a/configure.ac b/configure.ac index 7bd54a2..c9b3a42 100644 --- a/configure.ac +++ b/configure.ac @@ -71,6 +71,12 @@ fi AC_SUBST(HAVE_LIBCLANG) +# if cross compiling, disable NLS support. +# It's not worth the trouble, at least for now. +if test "x$cross_compiling" = xyes; then + enable_nls=no +fi + EFL_TESTS([${build_tests}]) # doxygen program for documentation building diff --git a/data/extra/skeleton.tar.gz b/data/extra/skeleton.tar.gz index 62dd89b..d504336 100644 Binary files a/data/extra/skeleton.tar.gz and b/data/extra/skeleton.tar.gz differ diff --git a/elm_code/bin/Makefile.am b/elm_code/bin/Makefile.am index 363beb8..b081d5f 100644 --- a/elm_code/bin/Makefile.am +++ b/elm_code/bin/Makefile.am @@ -2,19 +2,17 @@ MAINTAINERCLEANFILES = Makefile.in bin_PROGRAMS = elm_code_test -AM_CPPFLAGS = -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ --I$(top_builddir)/elm_code/bin/ \ --I$(top_srcdir)/elm_code/bin/ \ --I$(top_builddir)/elm_code/lib/ \ +AM_CPPFLAGS = \ -I$(top_srcdir)/elm_code/lib/ \ +-DLOCALEDIR=\"$(datadir)/locale\" \ -DEFL_BETA_API_SUPPORT \ @EFL_CFLAGS@ -elm_code_test_SOURCES = elm_code_test_main.c +elm_code_test_SOURCES = \ +elm_code_test_main.c \ +elm_code_test_private.h + elm_code_test_LDADD = @EFL_LIBS@ $(top_builddir)/elm_code/lib/libelm_code.la -localedir = $(datadir)/locale -DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ - -EXTRA_DIST = elm_code_test_private.h +elm_code_test_LDFLAGS = @EFL_LTLIBRARY_FLAGS@ diff --git a/elm_code/bin/elm_code_test_main.c b/elm_code/bin/elm_code_test_main.c index bfb13bb..c422c7d 100644 --- a/elm_code/bin/elm_code_test_main.c +++ b/elm_code/bin/elm_code_test_main.c @@ -31,6 +31,18 @@ static void _append_line(Elm_Code_File *file, const char *line) elm_code_file_line_append(file, line, length); } +static Eina_Bool +_elm_code_test_line_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, + const Eo_Event_Description *desc EINA_UNUSED, void *event_info) +{ + Elm_Code_Line *line; + + line = (Elm_Code_Line *)event_info; + + printf("CLICKED line %d\n", line->number); + return EINA_TRUE; +} + static Evas_Object * _elm_code_test_welcome_setup(Evas_Object *parent) { @@ -41,6 +53,7 @@ _elm_code_test_welcome_setup(Evas_Object *parent) widget = elm_code_widget_add(parent, code); elm_code_widget_font_size_set(widget, 14); elm_code_widget_editable_set(widget, EINA_TRUE); + eo_do(widget,eo_event_callback_add(&ELM_CODE_WIDGET_EVENT_LINE_CLICKED, _elm_code_test_line_cb, code)); _append_line(code->file, "Hello World, Elm Code!"); elm_code_file_line_token_add(code->file, 1, 14, 21, ELM_CODE_TOKEN_TYPE_COMMENT); diff --git a/elm_code/lib/Elm_Code.h b/elm_code/lib/Elm_Code.h index 866ccc7..35071a2 100644 --- a/elm_code/lib/Elm_Code.h +++ b/elm_code/lib/Elm_Code.h @@ -1,15 +1,9 @@ #ifndef ELM_CODE_H_ # define ELM_CODE_H_ -#include -#include #include - -#include -#include -#include -#include -#include +#include +#include #ifdef EAPI # undef EAPI @@ -37,6 +31,12 @@ # endif #endif /* ! _WIN32 */ +#include "elm_code_common.h" +#include "elm_code_file.h" +#include "elm_code_parse.h" +#include "elm_code_widget.h" +#include "elm_code_diff_widget.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/elm_code/lib/Makefile.am b/elm_code/lib/Makefile.am index 36ecc74..9510cad 100644 --- a/elm_code/lib/Makefile.am +++ b/elm_code/lib/Makefile.am @@ -2,9 +2,6 @@ MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = \ -I$(top_srcdir)/elm_code/lib \ --I$(top_builddir)/elm_code/lib \ --DPACKAGE_LIB_DIR=\"$(libdir)\" \ --DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ -DEFL_BETA_API_SUPPORT \ @EFL_CFLAGS@ \ -DEFL_ELM_CODE_BUILD @@ -24,6 +21,7 @@ elm_code_file.c \ elm_code_parse.c \ elm_code_widget.c \ elm_code_diff_widget.c \ -elm_code.c +elm_code.c \ +elm_code_private.h libelm_code_la_LIBADD = @EFL_LIBS@ -lm libelm_code_la_LDFLAGS = -no-undefined @EFL_LTLIBRARY_FLAGS@ diff --git a/elm_code/lib/elm_code.c b/elm_code/lib/elm_code.c index 9b895f5..d1e3282 100644 --- a/elm_code/lib/elm_code.c +++ b/elm_code/lib/elm_code.c @@ -3,20 +3,21 @@ #endif #include +#include #include "Elm_Code.h" -#include "elm_code_parse.h" #include "elm_code_private.h" static int _elm_code_init = 0; int _elm_code_lib_log_dom = -1; -const Eo_Event_Description ELM_CODE_EVENT_LINE_SET_DONE = +EAPI const Eo_Event_Description ELM_CODE_EVENT_LINE_SET_DONE = EO_EVENT_DESCRIPTION("line,set,done", ""); -const Eo_Event_Description ELM_CODE_EVENT_FILE_LOAD_DONE = +EAPI const Eo_Event_Description ELM_CODE_EVENT_FILE_LOAD_DONE = EO_EVENT_DESCRIPTION("file,load,done", ""); + EAPI int elm_code_init(void) { diff --git a/elm_code/lib/elm_code_common.h b/elm_code/lib/elm_code_common.h index 2520356..617e837 100644 --- a/elm_code/lib/elm_code_common.h +++ b/elm_code/lib/elm_code_common.h @@ -1,10 +1,8 @@ #ifndef ELM_CODE_COMMON_H_ # define ELM_CODE_COMMON_H_ -#include -#include - typedef struct _Elm_Code Elm_Code; +typedef struct _Elm_Code_File Elm_Code_File; EAPI extern const Eo_Event_Description ELM_CODE_EVENT_LINE_SET_DONE; EAPI extern const Eo_Event_Description ELM_CODE_EVENT_FILE_LOAD_DONE; @@ -37,8 +35,6 @@ typedef enum { ELM_CODE_TOKEN_TYPE_COUNT } Elm_Code_Token_Type; -#include "elm_code_file.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/elm_code/lib/elm_code_diff_widget.c b/elm_code/lib/elm_code_diff_widget.c index 7e577ed..f008159 100644 --- a/elm_code/lib/elm_code_diff_widget.c +++ b/elm_code/lib/elm_code_diff_widget.c @@ -2,11 +2,7 @@ # include "config.h" #endif -#include -#include - #include "Elm_Code.h" -#include "elm_code_diff_widget.h" #include "elm_code_private.h" diff --git a/elm_code/lib/elm_code_diff_widget.h b/elm_code/lib/elm_code_diff_widget.h index ac9f6d4..b6605bb 100644 --- a/elm_code/lib/elm_code_diff_widget.h +++ b/elm_code/lib/elm_code_diff_widget.h @@ -1,9 +1,6 @@ #ifndef ELM_CODE_DIFF_WIDGET_H_ # define ELM_CODE_DIFF_WIDGET_H_ -#include -#include "elm_code_common.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/elm_code/lib/elm_code_file.c b/elm_code/lib/elm_code_file.c index 6c1944e..b4d7833 100644 --- a/elm_code/lib/elm_code_file.c +++ b/elm_code/lib/elm_code_file.c @@ -3,8 +3,6 @@ #endif #include "Elm_Code.h" -#include "elm_code_file.h" -#include "elm_code_parse.h" #include "elm_code_private.h" diff --git a/elm_code/lib/elm_code_file.h b/elm_code/lib/elm_code_file.h index ee177ed..b37de52 100644 --- a/elm_code/lib/elm_code_file.h +++ b/elm_code/lib/elm_code_file.h @@ -1,10 +1,6 @@ #ifndef ELM_CODE_FILE_H_ # define ELM_CODE_FILE_H_ -#include - -#include "elm_code_common.h" - #ifdef __cplusplus extern "C" { #endif @@ -35,7 +31,7 @@ typedef struct _Elm_Code_Line } Elm_Code_Line; -typedef struct _Elm_Code_File +struct _Elm_Code_File { void *parent; @@ -43,7 +39,7 @@ typedef struct _Elm_Code_File Eina_File *file; void *map; -} Elm_Code_File; +}; /** * @brief File handling functions. diff --git a/elm_code/lib/elm_code_parse.c b/elm_code/lib/elm_code_parse.c index 2b1ddc2..0503aa0 100644 --- a/elm_code/lib/elm_code_parse.c +++ b/elm_code/lib/elm_code_parse.c @@ -3,7 +3,6 @@ #endif #include "Elm_Code.h" -#include "elm_code_parse.h" #include "elm_code_private.h" diff --git a/elm_code/lib/elm_code_parse.h b/elm_code/lib/elm_code_parse.h index ab50c34..1c58d27 100644 --- a/elm_code/lib/elm_code_parse.h +++ b/elm_code/lib/elm_code_parse.h @@ -1,10 +1,6 @@ #ifndef ELM_CODE_PARSE_H_ # define ELM_CODE_PARSE_H_ -#include - -#include "elm_code_common.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/elm_code/lib/elm_code_widget.c b/elm_code/lib/elm_code_widget.c index bce5d61..d91412a 100644 --- a/elm_code/lib/elm_code_widget.c +++ b/elm_code/lib/elm_code_widget.c @@ -2,13 +2,13 @@ # include "config.h" #endif -#include -#include - -#include "elm_code_widget.h" +#include "Elm_Code.h" #include "elm_code_private.h" +EAPI const Eo_Event_Description ELM_CODE_WIDGET_EVENT_LINE_CLICKED = + EO_EVENT_DESCRIPTION("line,clicked", ""); + Eina_Unicode status_icons[] = { ' ', '!', @@ -188,8 +188,30 @@ _elm_code_widget_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, _elm_code_widget_fill(obj, code); } -EAPI Evas_Object * -elm_code_widget_add(Evas_Object *parent, Elm_Code *code) +static void +_elm_code_widget_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, + void *event_info) +{ + Elm_Code *code; + Elm_Code_Line *line; + Evas_Event_Mouse_Up *event; + Evas_Coord y; + int ch; + unsigned int row; + + code = (Elm_Code *)data; + event = (Evas_Event_Mouse_Up *)event_info; + y = event->canvas.y; + + evas_object_textgrid_cell_size_get(obj, NULL, &ch); + row = ((double) y / ch) + 1; + + line = elm_code_file_line_get(code->file, row); + if (line) + elm_code_callback_fire(code, &ELM_CODE_WIDGET_EVENT_LINE_CLICKED, line); +} + +EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code) { Evas_Object *o; Elm_Code_Widget *widget; @@ -231,6 +253,7 @@ elm_code_widget_add(Evas_Object *parent, Elm_Code *code) evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CURSOR, 205, 205, 54, 255); evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _elm_code_widget_resize_cb, code); + evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _elm_code_widget_clicked_cb, code); eo_do(o,eo_event_callback_add(&ELM_CODE_EVENT_LINE_SET_DONE, _elm_code_widget_line_cb, code)); eo_do(o,eo_event_callback_add(&ELM_CODE_EVENT_FILE_LOAD_DONE, _elm_code_widget_file_cb, code)); diff --git a/elm_code/lib/elm_code_widget.h b/elm_code/lib/elm_code_widget.h index b173a82..1a17203 100644 --- a/elm_code/lib/elm_code_widget.h +++ b/elm_code/lib/elm_code_widget.h @@ -1,8 +1,7 @@ #ifndef ELM_CODE_WIDGET_H_ # define ELM_CODE_WIDGET_H_ -#include -#include "elm_code_common.h" +EAPI extern const Eo_Event_Description ELM_CODE_WIDGET_EVENT_LINE_CLICKED; #ifdef __cplusplus extern "C" { diff --git a/src/bin/edi_config.c b/src/bin/edi_config.c index 1442f17..29d5d9e 100644 --- a/src/bin/edi_config.c +++ b/src/bin/edi_config.c @@ -216,7 +216,7 @@ _edi_config_load(void) if (!_edi_cfg) { - _edi_cfg = malloc(sizeof(Edi_Config)); + _edi_cfg = calloc(1, sizeof(Edi_Config)); save = EINA_TRUE; } @@ -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(); +} diff --git a/src/bin/edi_config.h b/src/bin/edi_config.h index 8df697a..28aaed7 100644 --- a/src/bin/edi_config.h +++ b/src/bin/edi_config.h @@ -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 } diff --git a/src/bin/edi_consolepanel.c b/src/bin/edi_consolepanel.c index 235cda7..0a300eb 100644 --- a/src/bin/edi_consolepanel.c +++ b/src/bin/edi_consolepanel.c @@ -20,6 +20,7 @@ static Evas_Object *_console_box; static const char *_current_dir = NULL; +static unsigned int _edi_strlen_current_dir; static int _edi_test_count; static int _edi_test_pass; static int _edi_test_fail; @@ -73,7 +74,8 @@ static void _edi_consolepanel_parse_directory(const char *line) if (_current_dir) eina_stringshare_del(_current_dir); - _current_dir = eina_stringshare_add_length(pos + 20, strlen(pos) - 21); + _edi_strlen_current_dir = strlen(pos) - 21; + _current_dir = eina_stringshare_add_length(pos + 20, _edi_strlen_current_dir); } } @@ -115,7 +117,7 @@ static void _edi_consolepanel_append_line_type(const char *line, Eina_Bool err) snprintf(buf, strlen(line) + 8, "%s%s/n", file, pos); elm_object_text_set(txt, buf); - length = strlen(_current_dir) + strlen(file) + 2; + length = _edi_strlen_current_dir + strlen(file) + 2; path = malloc(sizeof(char) * length); snprintf(path, length, "%s/%s\n", _current_dir, file); @@ -166,17 +168,17 @@ static void _edi_consolepanel_append_line_type(const char *line, Eina_Bool err) _edi_test_line_callback(line); } -void edi_consolepanel_append_line(const char *line) +EAPI void edi_consolepanel_append_line(const char *line) { _edi_consolepanel_append_line_type(line, EINA_FALSE); } -void edi_consolepanel_append_error_line(const char *line) +EAPI void edi_consolepanel_append_error_line(const char *line) { _edi_consolepanel_append_line_type(line, EINA_TRUE); } -void edi_consolepanel_clear() +EAPI void edi_consolepanel_clear() { elm_box_clear(_console_box); @@ -309,7 +311,7 @@ static void _edi_test_line_callback(const char *content) } } -void edi_consolepanel_add(Evas_Object *parent) +EAPI void edi_consolepanel_add(Evas_Object *parent) { Evas_Object *scroll, *vbx; @@ -331,7 +333,7 @@ void edi_consolepanel_add(Evas_Object *parent) ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, _exe_error, NULL); } -void edi_testpanel_add(Evas_Object *parent) +EAPI void edi_testpanel_add(Evas_Object *parent) { Elm_Code *code; Evas_Object *widget; diff --git a/src/bin/edi_logpanel.c b/src/bin/edi_logpanel.c index 3c7a40d..ebb0c02 100644 --- a/src/bin/edi_logpanel.c +++ b/src/bin/edi_logpanel.c @@ -13,7 +13,7 @@ static Evas_Object *_info_widget; static Elm_Code *_elm_code; -void print_cb(const Eina_Log_Domain *domain, +static void _print_cb(const Eina_Log_Domain *domain, Eina_Log_Level level, const char *file, const char *fnc, @@ -38,7 +38,7 @@ void print_cb(const Eina_Log_Domain *domain, } } -void edi_logpanel_add(Evas_Object *parent) +EAPI void edi_logpanel_add(Evas_Object *parent) { Evas_Object *widget; Elm_Code *code; @@ -53,7 +53,7 @@ void edi_logpanel_add(Evas_Object *parent) _elm_code = code; _info_widget = widget; - eina_log_print_cb_set(print_cb, NULL); + eina_log_print_cb_set(_print_cb, NULL); eina_log_color_disable_set(EINA_TRUE); elm_box_pack_end(parent, widget); diff --git a/src/bin/edi_main.c b/src/bin/edi_main.c index 69fa5e6..4024074 100644 --- a/src/bin/edi_main.c +++ b/src/bin/edi_main.c @@ -39,13 +39,48 @@ static Elm_Object_Item *_edi_logpanel_item, *_edi_consolepanel_item, *_edi_testp static Elm_Object_Item *_edi_selected_bottompanel; static Evas_Object *_edi_filepanel, *_edi_filepanel_icon; -static Evas_Object *_edi_main_win, *_edi_new_popup, *_edi_goto_popup; +static Evas_Object *_edi_main_win, *_edi_new_popup, *_edi_goto_popup,*_edi_message_popup; +int _edi_log_dom = -1; + +static void +_edi_on_close_message(void *data, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + evas_object_del(data); + evas_object_del(_edi_message_popup); +} + +static void +_edi_message_open(const char *message) +{ + Evas_Object *popup, *button; + + popup = elm_popup_add(_edi_main_win); + _edi_message_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); + + evas_object_show(popup); +} static void _edi_file_open_cb(const char *path, const char *type, Eina_Bool newwin) { Edi_Path_Options *options; + if (path == NULL) + { + _edi_message_open("Please choose a file from the list"); + return; + } + options = edi_path_options_create(path); options->type = type; @@ -247,14 +282,14 @@ _edi_panel_dragged_cb(void *data, Evas_Object *obj EINA_UNUSED, _edi_panel_size_save(data == _edi_filepanel); } -void +EAPI void edi_consolepanel_show() { if (_edi_selected_bottompanel != _edi_consolepanel_item) elm_toolbar_item_selected_set(_edi_consolepanel_item, EINA_TRUE); } -void +EAPI void edi_testpanel_show() { if (_edi_selected_bottompanel != _edi_testpanel_item) @@ -374,20 +409,20 @@ edi_content_setup(Evas_Object *win, const char *path) { elm_panes_content_right_size_set(logpane, _edi_cfg->gui.bottomsize); if (_edi_cfg->gui.bottomtab == 1) - { - elm_toolbar_item_icon_set(_edi_consolepanel_item, "stock_down"); -_edi_selected_bottompanel = _edi_consolepanel_item; -} + { + elm_toolbar_item_icon_set(_edi_consolepanel_item, "stock_down"); + _edi_selected_bottompanel = _edi_consolepanel_item; + } else if (_edi_cfg->gui.bottomtab == 2) -{ - elm_toolbar_item_icon_set(_edi_testpanel_item, "stock_down"); -_edi_selected_bottompanel = _edi_testpanel_item; -} + { + elm_toolbar_item_icon_set(_edi_testpanel_item, "stock_down"); + _edi_selected_bottompanel = _edi_testpanel_item; + } else -{ - elm_toolbar_item_icon_set(_edi_logpanel_item, "stock_down"); -_edi_selected_bottompanel = _edi_logpanel_item; -} + { + elm_toolbar_item_icon_set(_edi_logpanel_item, "stock_down"); + _edi_selected_bottompanel = _edi_logpanel_item; + } } else elm_panes_content_right_size_set(logpane, 0.0); @@ -740,6 +775,26 @@ edi_close() elm_exit(); } +static Eina_Bool +_edi_log_init() +{ + _edi_log_dom = eina_log_domain_register("edi", EINA_COLOR_GREEN); + if (_edi_log_dom < 0) + { + EINA_LOG_ERR("Edi can not create its log domain."); + return EINA_FALSE; + } + + return EINA_TRUE; +} + +static void +_edi_log_shutdown() +{ + eina_log_domain_unregister(_edi_log_dom); + _edi_log_dom = -1; +} + static const Ecore_Getopt optdesc = { "edi", "%prog [options] [project-dir]", @@ -784,6 +839,8 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) goto config_error; edi_init(); + if (!_edi_log_init()) + goto end; args = ecore_getopt_parse(&optdesc, values, argc, argv); if (args < 0) @@ -814,6 +871,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) elm_run(); end: + _edi_log_shutdown(); elm_shutdown(); edi_shutdown(); diff --git a/src/bin/edi_private.h b/src/bin/edi_private.h index 0cbe1f3..43f2a4c 100644 --- a/src/bin/edi_private.h +++ b/src/bin/edi_private.h @@ -3,28 +3,28 @@ #include -extern int _edi_lib_log_dom; +extern int _edi_log_dom; #ifdef CRIT # undef CRIT #endif -#define CRIT(...) EINA_LOG_DOM_CRIT(_edi_lib_log_dom, __VA_ARGS__) +#define CRIT(...) EINA_LOG_DOM_CRIT(_edi_log_dom, __VA_ARGS__) #ifdef ERR # undef ERR #endif -#define ERR(...) EINA_LOG_DOM_ERR(_edi_lib_log_dom, __VA_ARGS__) +#define ERR(...) EINA_LOG_DOM_ERR(_edi_log_dom, __VA_ARGS__) #ifdef WRN # undef WRN #endif -#define WRN(...) EINA_LOG_DOM_WARN(_edi_lib_log_dom, __VA_ARGS__) +#define WRN(...) EINA_LOG_DOM_WARN(_edi_log_dom, __VA_ARGS__) #ifdef INF # undef INF #endif -#define INF(...) EINA_LOG_DOM_INFO(_edi_lib_log_dom, __VA_ARGS__) +#define INF(...) EINA_LOG_DOM_INFO(_edi_log_dom, __VA_ARGS__) #ifdef DBG # undef DBG #endif -#define DBG(...) EINA_LOG_DOM_DBG(_edi_lib_log_dom, __VA_ARGS__) +#define DBG(...) EINA_LOG_DOM_DBG(_edi_log_dom, __VA_ARGS__) #define EDI_CONTENT_AUTOSAVE EINA_TRUE diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c index b65ec09..32b5899 100644 --- a/src/bin/editor/edi_editor.c +++ b/src/bin/editor/edi_editor.c @@ -316,7 +316,7 @@ _edi_editor_statusbar_add(Evas_Object *panel, Edi_Editor *editor, Edi_Mainview_I #if HAVE_LIBCLANG // TODO on any refresh heck mtime - then re-run clang if changed - it should be fast enough now... static void -_clang_remove_highlighting(Edi_Editor *editor) +_edi_line_color_remove(Edi_Editor *editor, unsigned int line) { Eina_List *formats; Evas_Object *textblock; @@ -324,12 +324,13 @@ _clang_remove_highlighting(Edi_Editor *editor) Evas_Object_Textblock_Node_Format *format; unsigned int i; - ecore_thread_main_loop_begin(); textblock = elm_entry_textblock_get(editor->entry); start = evas_object_textblock_cursor_new(textblock); + evas_textblock_cursor_line_set(start, line); + evas_textblock_cursor_pos_set(start, evas_textblock_cursor_pos_get(start)); end = evas_object_textblock_cursor_new(textblock); - - evas_textblock_cursor_visible_range_get(start, end); + evas_textblock_cursor_line_set(end, line); + evas_textblock_cursor_pos_set(end, evas_textblock_cursor_pos_get(end) - 1); i = 0; formats = evas_textblock_cursor_range_formats_get(start, end); @@ -344,9 +345,9 @@ _clang_remove_highlighting(Edi_Editor *editor) formats = evas_textblock_cursor_range_formats_get(start, end); } + evas_textblock_cursor_free(start); evas_textblock_cursor_free(end); - ecore_thread_main_loop_end(); } static void @@ -360,6 +361,14 @@ _edi_range_color_set(Edi_Editor *editor, Edi_Range range, Edi_Color color) if (!((Evas_Coord)range.start.line > editor->format_end || (Evas_Coord)range.end.line < editor->format_start)) { textblock = elm_entry_textblock_get(editor->entry); + + if (editor->format_line == -1) + editor->format_line = range.start.line - 1; + while (editor->format_line < (int) range.end.line) + { + _edi_line_color_remove(editor, ++editor->format_line); + } + cursor = evas_object_textblock_cursor_new(textblock); evas_textblock_cursor_line_set(cursor, range.start.line - 1); evas_textblock_cursor_pos_set(cursor, evas_textblock_cursor_pos_get(cursor) + range.start.col - 1); @@ -367,7 +376,7 @@ _edi_range_color_set(Edi_Editor *editor, Edi_Range range, Edi_Color color) evas_textblock_cursor_line_set(cursor, range.end.line - 1); evas_textblock_cursor_pos_set(cursor, evas_textblock_cursor_pos_get(cursor) + range.end.col - 1); - evas_textblock_cursor_format_append(cursor, ""); + evas_textblock_cursor_format_prepend(cursor, ""); evas_textblock_cursor_free(cursor); } @@ -397,7 +406,7 @@ _clang_show_highlighting(void *data) unsigned int i = 0; editor = (Edi_Editor *)data; - _clang_remove_highlighting(editor); + editor->format_line = -1; for (i = 0 ; i < editor->token_count ; i++) { Edi_Range range; @@ -611,7 +620,6 @@ _edi_clang_setup(void *data) /* FIXME: Possibly activate more options? */ editor->tx_unit = clang_parseTranslationUnit(editor->idx, path, clang_argv, clang_argc, NULL, 0, clang_defaultEditingTranslationUnitOptions() | CXTranslationUnit_DetailedPreprocessingRecord); - _clang_remove_highlighting(editor); _clang_load_errors(path, editor); _clang_load_highlighting(path, editor); diff --git a/src/bin/editor/edi_editor.h b/src/bin/editor/edi_editor.h index 844d4e1..bd649bc 100644 --- a/src/bin/editor/edi_editor.h +++ b/src/bin/editor/edi_editor.h @@ -55,7 +55,7 @@ struct _Edi_Editor #endif Ecore_Timer *delay_highlight; - int format_start, format_end; + int format_start, format_end, format_line; }; /** diff --git a/src/bin/welcome/edi_welcome.c b/src/bin/welcome/edi_welcome.c index 3c34f6c..5606730 100644 --- a/src/bin/welcome/edi_welcome.c +++ b/src/bin/welcome/edi_welcome.c @@ -9,21 +9,79 @@ #include "edi_private.h" -#include -#include - #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 void -_edi_welcome_project_open(const char *path) -{ - evas_object_del(_welcome_window); +static Evas_Object *_edi_create_button, *_edi_open_button; +static const char *_edi_message_path; + +static void _edi_welcome_add_recent_projects(Evas_Object *); + +static void +_edi_on_close_message(void *data, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + 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 unsigned int _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); } } @@ -43,6 +101,8 @@ static void _edi_welcome_choose_exit(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { evas_object_del(data); + elm_object_disabled_set(_edi_open_button, EINA_FALSE); + elm_object_disabled_set(_edi_create_button, EINA_FALSE); } static void @@ -50,6 +110,9 @@ _edi_welcome_project_choose_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU { Evas_Object *win, *fs; + elm_object_disabled_set(_edi_open_button, EINA_TRUE); + elm_object_disabled_set(_edi_create_button, EINA_TRUE); + elm_need_ethumb(); elm_need_efreet(); @@ -131,11 +194,23 @@ _edi_welcome_project_new_input_row_add(const char *text, const char *placeholder _create_inputs[row] = input; } +static void +_edi_welcome_project_new_create_done_cb(const char *path, Eina_Bool success) +{ + if (!success) + { + ERR("Unable to create project at path %s", path); + + return; + } + + _edi_welcome_project_open(path, EINA_TRUE); +} + static void _edi_welcome_project_new_create_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { const char *path, *name, *user, *email, *url; - char script[PATH_MAX], fullpath[PATH_MAX]; path = elm_fileselector_path_get(_create_inputs[0]); name = elm_object_text_get(_create_inputs[1]); @@ -143,19 +218,7 @@ _edi_welcome_project_new_create_cb(void *data EINA_UNUSED, Evas_Object *obj EINA user = elm_object_text_get(_create_inputs[3]); email = elm_object_text_get(_create_inputs[4]); - snprintf(script, sizeof(script), "%s/skeleton/eflprj", elm_app_data_dir_get()); - snprintf(fullpath, sizeof(fullpath), "%s/%s", path, name); - int pid = fork(); - - if (pid == 0) - { - printf("Creating project \"%s\" at path %s for %s<%s>\n", name, fullpath, user, email); - - execlp(script, script, fullpath, name, user, email, url, NULL); - exit(0); - } - waitpid(pid, NULL, 0); - _edi_welcome_project_open(fullpath); + edi_create_project(path, name, url, user, email, _edi_welcome_project_new_create_done_cb); } static void @@ -206,7 +269,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 +282,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); @@ -243,7 +307,7 @@ _edi_welcome_add_recent_projects(Evas_Object *box) evas_object_show(list); } -Evas_Object *edi_welcome_show() +EAPI Evas_Object *edi_welcome_show() { Evas_Object *win, *hbx, *box, *button, *label, *image, *naviframe; Elm_Object_Item *item; @@ -280,15 +344,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,7 +361,17 @@ 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); + _edi_open_button = button; + 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); + _edi_create_button = button; elm_object_text_set(button, "Create New Project"); evas_object_smart_callback_add(button, "clicked", _edi_welcome_project_new_cb, naviframe); diff --git a/src/lib/Edi.h b/src/lib/Edi.h index aff9918..b1e5330 100644 --- a/src/lib/Edi.h +++ b/src/lib/Edi.h @@ -34,6 +34,7 @@ extern "C" { #endif +#include #include #include diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 03684f1..27e9be4 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -12,13 +12,15 @@ lib_LTLIBRARIES = libedi.la includes_HEADERS = \ edi_builder.h \ +edi_create.h \ edi_path.h \ Edi.h includesdir = $(includedir)/edi-@VMAJ@ libedi_la_SOURCES = \ -edi_path.c \ edi_builder.c \ +edi_create.c \ +edi_path.c \ edi.c libedi_la_LIBADD = @EFL_LIBS@ -lm libedi_la_LDFLAGS = -no-undefined @EFL_LTLIBRARY_FLAGS@ diff --git a/src/lib/edi.c b/src/lib/edi.c index 3c4aec4..768a07f 100644 --- a/src/lib/edi.c +++ b/src/lib/edi.c @@ -22,12 +22,13 @@ edi_init(void) eina_init(); - _edi_lib_log_dom = eina_log_domain_register("edi", EINA_COLOR_CYAN); + _edi_lib_log_dom = eina_log_domain_register("edi-lib", EINA_COLOR_CYAN); if (_edi_lib_log_dom < 0) { - EINA_LOG_ERR("Edi can not create its log domain."); + EINA_LOG_ERR("Edi lib cannot create its log domain."); goto shutdown_eina; } + INF("Edi library loaded"); // Put here your initialization logic of your library @@ -52,6 +53,8 @@ edi_shutdown(void) EINA_LOG_STATE_START, EINA_LOG_STATE_SHUTDOWN); + INF("Edi library shut down"); + // Put here your shutdown logic eina_log_domain_unregister(_edi_lib_log_dom); diff --git a/src/lib/edi_builder.c b/src/lib/edi_builder.c index eebeedc..3e66687 100644 --- a/src/lib/edi_builder.c +++ b/src/lib/edi_builder.c @@ -3,7 +3,6 @@ #endif #include "Edi.h" -#include "edi_builder.h" #include "edi_private.h" diff --git a/src/lib/edi_create.c b/src/lib/edi_create.c new file mode 100644 index 0000000..26dbfd6 --- /dev/null +++ b/src/lib/edi_create.c @@ -0,0 +1,54 @@ +#ifdef HAVE_CONFIG +# include "config.h" +#endif + +#include "Edi.h" + +#include "edi_private.h" + +static Eina_Bool +_edi_create_project_done(void *data, int type EINA_UNUSED, void *event EINA_UNUSED) +{ + Edi_Create *create; + + create = (Edi_Create *)data; + + ecore_event_handler_del(create->handler); + create->callback(create->path, EINA_TRUE); + free(create->path); + free(data); + + return ECORE_CALLBACK_DONE; // or ECORE_CALLBACK_PASS_ON +} + +EAPI void +edi_create_project(const char *path, const char *name, const char *url, + const char *user, const char *email, Edi_Create_Cb func) +{ + char script[PATH_MAX], fullpath[PATH_MAX]; + char *cmd; + int cmdlen; + Edi_Create *data; + Ecore_Event_Handler *handler; + + data = calloc(1, sizeof(Edi_Create)); + handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _edi_create_project_done, data); + snprintf(script, sizeof(script), "%s/skeleton/eflprj", elm_app_data_dir_get() +); + snprintf(fullpath, sizeof(fullpath), "%s/%s", path, name); + + data->path = strdup(fullpath); + data->callback = func; + data->handler = handler; + + cmdlen = strlen(script) + 19 + strlen(path) + strlen(name) + strlen(url) + strlen(user) + strlen(email); + cmd = malloc(sizeof(char) * cmdlen); + snprintf(cmd, cmdlen, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", + script, fullpath, name, user, email, url); + + INF("Creating project \"%s\" at path %s for %s<%s>\n", name, fullpath, user, email); + ecore_exe_run(cmd, data); + free(cmd); +} + + diff --git a/src/lib/edi_create.h b/src/lib/edi_create.h new file mode 100644 index 0000000..80c3eee --- /dev/null +++ b/src/lib/edi_create.h @@ -0,0 +1,52 @@ +#ifndef EDI_CREATE_H_ +# define EDI_CREATE_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file + * @brief These routines are used for creating new projects. + */ + +typedef void (*Edi_Create_Cb)(const char *path, Eina_Bool success); + +typedef struct _Edi_Create +{ + char *path; + + Edi_Create_Cb callback; + Ecore_Event_Handler *handler; +} Edi_Create; + +/** + * @brief Main builder management + * @defgroup Creation + * + * @{ + * + * Functions of project creation from skeletons. + * + */ + +/** + * Create a new standard EFL project. + * + * @ingroup Creation + */ +EAPI void +edi_create_project(const char *path, const char *name, const char *url, + const char *user, const char *email, Edi_Create_Cb func); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* EDI_CREATE_H_ */