main: naming.
This commit is contained in:
parent
4d4882f09b
commit
7bac08fc80
108
src/bin/main.c
108
src/bin/main.c
|
@ -96,6 +96,7 @@ _cb_sel_start(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
elm_object_item_disabled_set(inst->menu.copy, EINA_FALSE);
|
||||
elm_object_item_disabled_set(inst->menu.cut, EINA_FALSE);
|
||||
elm_object_item_disabled_set(inst->toolbar.copy, EINA_FALSE);
|
||||
|
@ -107,6 +108,7 @@ _cb_sel_clear(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
elm_object_item_disabled_set(inst->menu.copy, EINA_TRUE);
|
||||
elm_object_item_disabled_set(inst->menu.cut, EINA_TRUE);
|
||||
elm_object_item_disabled_set(inst->toolbar.copy, EINA_TRUE);
|
||||
|
@ -116,30 +118,30 @@ _cb_sel_clear(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
static void
|
||||
_update_cur_file(const char *file, Ecrire_Editor *inst)
|
||||
{
|
||||
const char *saving = (!elm_object_item_disabled_get(inst->menu.save)) ?
|
||||
"*" : "";
|
||||
eina_stringshare_replace(&inst->filename, file);
|
||||
{
|
||||
char buf[1024];
|
||||
if (inst->filename)
|
||||
snprintf(buf, sizeof(buf), _("%s%s - %s"), saving, inst->filename,
|
||||
PACKAGE_NAME);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), _("%sUntitled %d - %s"), saving,
|
||||
inst->unsaved, PACKAGE_NAME);
|
||||
char buf[1024];
|
||||
const char *saving = (!elm_object_item_disabled_get(inst->menu.save)) ? "*" : "";
|
||||
|
||||
if (inst->filename)
|
||||
elm_object_text_set(inst->frame, inst->filename);
|
||||
else
|
||||
elm_object_text_set(inst->frame, buf);
|
||||
elm_win_title_set(inst->win, buf);
|
||||
}
|
||||
eina_stringshare_replace(&inst->filename, file);
|
||||
|
||||
if (inst->filename)
|
||||
snprintf(buf, sizeof(buf), _("%s%s - %s"), saving, inst->filename,
|
||||
PACKAGE_NAME);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), _("%sUntitled %d - %s"), saving,
|
||||
inst->unsaved, PACKAGE_NAME);
|
||||
|
||||
if (inst->filename)
|
||||
elm_object_text_set(inst->frame, inst->filename);
|
||||
else
|
||||
elm_object_text_set(inst->frame, buf);
|
||||
|
||||
elm_win_title_set(inst->win, buf);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_cur_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
char buf[50];
|
||||
char buf[64];
|
||||
int line;
|
||||
int col;
|
||||
const Evas_Object *tb = elm_entry_textblock_get(obj);
|
||||
|
@ -254,13 +256,13 @@ _undo_stack_add(Ecrire_Editor *inst, Elm_Entry_Change_Info *_info)
|
|||
static void
|
||||
_undo_redo_do(Ecrire_Editor *inst, Elm_Entry_Change_Info *inf, Eina_Bool undo)
|
||||
{
|
||||
DBG("%s: %s", (undo) ? "Undo" : "Redo",
|
||||
inf->change.insert.content);
|
||||
DBG("%s: %s", (undo) ? "Undo" : "Redo", inf->change.insert.content);
|
||||
|
||||
if ((inf->insert && undo) || (!inf->insert && !undo))
|
||||
{
|
||||
const Evas_Object *tb = elm_entry_textblock_get(inst->entry);
|
||||
Evas_Textblock_Cursor *mcur, *end;
|
||||
const Evas_Object *tb = elm_entry_textblock_get(inst->entry);
|
||||
|
||||
mcur = (Evas_Textblock_Cursor *) evas_object_textblock_cursor_get(tb);
|
||||
end = evas_object_textblock_cursor_new(tb);
|
||||
|
||||
|
@ -268,7 +270,7 @@ _undo_redo_do(Ecrire_Editor *inst, Elm_Entry_Change_Info *inf, Eina_Bool undo)
|
|||
{
|
||||
elm_entry_cursor_pos_set(inst->entry, inf->change.insert.pos);
|
||||
evas_textblock_cursor_pos_set(end, inf->change.insert.pos +
|
||||
inf->change.insert.plain_length);
|
||||
inf->change.insert.plain_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -310,6 +312,7 @@ _cb_undo(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|||
/* In undo we care about the current item */
|
||||
Ecrire_Editor *inst = data;
|
||||
Elm_Entry_Change_Info *inf = NULL;
|
||||
|
||||
if (!eina_list_next(inst->undo_stack_ptr))
|
||||
return;
|
||||
|
||||
|
@ -338,6 +341,7 @@ _cb_redo(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
Elm_Entry_Change_Info *inf = NULL;
|
||||
|
||||
if (!eina_list_prev(inst->undo_stack_ptr))
|
||||
return;
|
||||
|
||||
|
@ -370,8 +374,10 @@ static void
|
|||
_cb_ent_changed(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
elm_object_item_disabled_set(inst->menu.save, EINA_FALSE);
|
||||
elm_object_item_disabled_set(inst->toolbar.save, EINA_FALSE);
|
||||
|
||||
_update_cur_file(inst->filename, inst);
|
||||
|
||||
/* Undo/redo */
|
||||
|
@ -379,7 +385,7 @@ _cb_ent_changed(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
|||
}
|
||||
|
||||
static void
|
||||
_load_to_entry(Ecrire_Editor *inst, const char *file)
|
||||
_editor_file_open(Ecrire_Editor *inst, const char *file)
|
||||
{
|
||||
Eina_Bool ok = 1;
|
||||
|
||||
|
@ -410,17 +416,6 @@ _load_to_entry(Ecrire_Editor *inst, const char *file)
|
|||
_update_cur_file(file, inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_fs_open_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
const char *selected = event_info;
|
||||
|
||||
if (!selected) return;
|
||||
|
||||
ecrire_editor_add(selected, _ent_cfg->font.name, _ent_cfg->font.size);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_fs_ecrire_editor_save(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
|
@ -456,27 +451,31 @@ ecrire_editor_save(Ecrire_Editor *inst, const char *file)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_open_do(void *data)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
ui_file_open_save_dialog_open(inst->win, EINA_FALSE, _cb_fs_open_done, inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_goto_line(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
ui_goto_dialog_open(inst->win, inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_fs_open_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
const char *selected = event_info;
|
||||
|
||||
if (!selected) return;
|
||||
|
||||
ecrire_editor_add(selected, _ent_cfg->font.name, _ent_cfg->font.size);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_open(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
_open_do(inst);
|
||||
ui_file_open_save_dialog_open(inst->win, EINA_FALSE, _cb_fs_open_done, inst);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -492,6 +491,7 @@ static void
|
|||
_cb_save(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
ecrire_editor_try_save(inst, _cb_fs_ecrire_editor_save);
|
||||
}
|
||||
|
||||
|
@ -499,6 +499,7 @@ static void
|
|||
_cb_save_as(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
ui_file_open_save_dialog_open(inst->win, EINA_TRUE, _cb_fs_ecrire_editor_save, inst);
|
||||
}
|
||||
|
||||
|
@ -512,6 +513,7 @@ static void
|
|||
_cb_close(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
_alert_if_need_saving(_editor_del, inst);
|
||||
}
|
||||
|
||||
|
@ -519,6 +521,7 @@ static void
|
|||
_cb_cut(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
elm_entry_selection_cut(inst->entry);
|
||||
}
|
||||
|
||||
|
@ -526,6 +529,7 @@ static void
|
|||
_cb_copy(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
elm_entry_selection_copy(inst->entry);
|
||||
}
|
||||
|
||||
|
@ -533,6 +537,7 @@ static void
|
|||
_cb_paste(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
elm_entry_selection_paste(inst->entry);
|
||||
}
|
||||
|
||||
|
@ -540,6 +545,7 @@ static void
|
|||
_cb_find(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
ui_find_dialog_open(inst->win, inst);
|
||||
}
|
||||
|
||||
|
@ -547,14 +553,15 @@ static void
|
|||
_cb_font_settings(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
ui_settings_open(elm_object_top_widget_get(inst->win), inst);
|
||||
|
||||
ui_settings_open(inst->win, inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_win_del(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
(void) data;
|
||||
|
||||
_alert_if_need_saving(_editor_del, inst);
|
||||
}
|
||||
|
||||
|
@ -562,6 +569,7 @@ static void
|
|||
_cb_win_focused(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecrire_Editor *inst = data;
|
||||
|
||||
elm_object_focus_set(inst->entry, 1);
|
||||
}
|
||||
|
||||
|
@ -575,6 +583,7 @@ _cb_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event)
|
|||
ctrl = evas_key_modifier_is_set(ev->modifiers, "Control");
|
||||
alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
|
||||
shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
|
||||
|
||||
if ((ctrl) && (!alt) && (!shift))
|
||||
{
|
||||
if (!strcmp(ev->keyname, "a")) elm_entry_select_all(inst->entry);
|
||||
|
@ -590,7 +599,7 @@ ecrire_editor_font_set(Ecrire_Editor *inst, const char *font, int font_size)
|
|||
{
|
||||
Eina_Strbuf *sbuf;
|
||||
const Evas_Object *tb;
|
||||
|
||||
|
||||
tb = elm_entry_textblock_get(inst->entry);
|
||||
sbuf = eina_strbuf_new();
|
||||
|
||||
|
@ -612,7 +621,7 @@ ecrire_editor_font_set(Ecrire_Editor *inst, const char *font, int font_size)
|
|||
|
||||
evas_object_textblock_style_user_push((Evas_Object *) tb, ts);
|
||||
|
||||
evas_textblock_style_free(ts);
|
||||
evas_textblock_style_free(ts);
|
||||
}
|
||||
|
||||
elm_entry_calc_force(inst->entry);
|
||||
|
@ -708,11 +717,9 @@ _ecrire_menu_add(Ecrire_Editor *inst)
|
|||
elm_menu_item_separator_add(menu, it);
|
||||
elm_menu_item_add(menu, it, "preferences-system", _("Settings"), _cb_font_settings, inst);
|
||||
|
||||
/* We don't have a selection when we start, make the items disabled */
|
||||
elm_object_item_disabled_set(inst->menu.copy, EINA_TRUE);
|
||||
elm_object_item_disabled_set(inst->menu.cut, EINA_TRUE);
|
||||
elm_object_item_disabled_set(inst->menu.save, EINA_TRUE);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -802,7 +809,7 @@ ecrire_editor_add(const char *filename, const char *font_name, int font_size)
|
|||
elm_win_center(win, 1, 1);
|
||||
evas_object_show(win);
|
||||
|
||||
_load_to_entry(inst, inst->filename);
|
||||
_editor_file_open(inst, inst->filename);
|
||||
}
|
||||
|
||||
EAPI_MAIN int
|
||||
|
@ -878,6 +885,7 @@ elm_main(int argc, char **argv)
|
|||
ecrire_cfg_shutdown();
|
||||
eina_log_domain_unregister(_ecrire_log_dom);
|
||||
_ecrire_log_dom = -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue