enventor: Support "edc,modified" smart callback.

Summary: Support "edc,modified" smart callback. The event_info of edc,modified smart callback indicates whether the modification is done by itself or by other process.

Reviewers: Hermet

Differential Revision: https://phab.enlightenment.org/D1551
This commit is contained in:
Jaehyun Cho 2014-10-23 16:39:31 +09:00 committed by ChunEon Park
parent c62b19e9c7
commit 72e28a7310
6 changed files with 37 additions and 0 deletions

View File

@ -22,6 +22,11 @@ typedef struct
Evas_Coord h;
} Enventor_Live_View_Size;
typedef struct
{
Eina_Bool self_changed : 1;
} Enventor_EDC_Modified;
EAPI int enventor_init(int argc, char **argv);
EAPI int enventor_shutdown(void);
EAPI Evas_Object *enventor_object_add(Evas_Object *parent);

View File

@ -54,6 +54,7 @@ struct editor_s
Eina_Bool auto_indent : 1;
Eina_Bool part_highlight : 1;
Eina_Bool ctxpopup: 1;
Eina_Bool on_save : 1;
};
/*****************************************************************************/
@ -792,6 +793,18 @@ edit_view_sync_cb_set(edit_data *ed,
ed->view_sync_cb_data = data;
}
Eina_Bool
edit_saved_get(edit_data *ed)
{
return ed->on_save;
}
void
edit_saved_set(edit_data *ed, Eina_Bool saved)
{
ed->on_save = saved;
}
Eina_Bool
edit_save(edit_data *ed, const char *file)
{
@ -812,6 +825,8 @@ edit_save(edit_data *ed, const char *file)
edit_view_sync(ed);
ed->on_save = EINA_TRUE;
return EINA_TRUE;
}

View File

@ -18,6 +18,7 @@ const char SIG_COMPILE_ERROR[] = "compile,error";
const char SIG_PROGRAM_RUN[] = "program,run";
const char SIG_CTXPOPUP_SELECTED[] = "ctxpopup,selected";
const char SIG_CTXPOPUP_DISMISSED[] = "ctxpopup,dismissed";
const char SIG_EDC_MODIFIED[] = "edc,modified";
static int _enventor_init_count = 0;
static int _enventor_log_dom = -1;

View File

@ -404,5 +404,6 @@ class Enventor.Object (Elm_Widget, Efl.File) {
program,run;
ctxpopup,selected;
ctxpopup,dismissed;
edc,modified;
}
}

View File

@ -25,6 +25,7 @@ extern const char SIG_LIVE_VIEW_RESIZED[];
extern const char SIG_PROGRAM_RUN[];
extern const char SIG_CTXPOPUP_SELECTED[];
extern const char SIG_CTXPOPUP_DISMISSED[];
extern const char SIG_EDC_MODIFIED[];
typedef struct viewer_s view_data;
typedef struct syntax_color_s color_data;
@ -193,6 +194,8 @@ Eina_Bool edit_changed_get(edit_data *ed);
void edit_changed_set(edit_data *ed, Eina_Bool changed);
void edit_linenumber_set(edit_data *ed, Eina_Bool linenumber);
Eina_Bool edit_linenumber_get(edit_data *ed);
Eina_Bool edit_saved_get(edit_data *ed);
void edit_saved_set(edit_data *ed, Eina_Bool saved);
Eina_Bool edit_save(edit_data *ed, const char *file);
void edit_new(edit_data* ed);
void edit_view_sync_cb_set(edit_data *ed, void (*cb)(void *data, Eina_Stringshare *part_name, Eina_Stringshare *group_name), void *data);

View File

@ -41,6 +41,7 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
{SIG_PROGRAM_RUN, ""},
{SIG_CTXPOPUP_SELECTED, ""},
{SIG_CTXPOPUP_DISMISSED, ""},
{SIG_EDC_MODIFIED, ""},
{NULL, NULL}
};
@ -52,14 +53,25 @@ file_modified_cb(void *data, int type EINA_UNUSED, void *event)
{
Eio_Monitor_Event *ev = event;
Enventor_Object_Data *pd = data;
Enventor_EDC_Modified modified;
if (ev->monitor != pd->edc_monitor) return ECORE_CALLBACK_PASS_ON;
if (!edit_saved_get(pd->ed))
{
modified.self_changed = EINA_FALSE;
evas_object_smart_callback_call(pd->obj, SIG_EDC_MODIFIED, &modified);
return ECORE_CALLBACK_DONE;
}
if (!edit_changed_get(pd->ed)) return ECORE_CALLBACK_DONE;
if (strcmp(ev->filename, build_edc_path_get())) return ECORE_CALLBACK_DONE;
build_edc();
edit_changed_set(pd->ed, EINA_FALSE);
edit_saved_set(pd->ed, EINA_FALSE);
modified.self_changed = EINA_TRUE;
evas_object_smart_callback_call(pd->obj, SIG_EDC_MODIFIED, &modified);
return ECORE_CALLBACK_DONE;
}