forked from enlightenment/ecrire
ecrire: naming.
This commit is contained in:
parent
221fc9dd50
commit
d5848bfda6
|
@ -18,6 +18,8 @@ typedef struct _Ecrire_Editor
|
||||||
Evas_Object *frame;
|
Evas_Object *frame;
|
||||||
Evas_Object *entry;
|
Evas_Object *entry;
|
||||||
|
|
||||||
|
Evas_Object *settings_popup;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
Elm_Object_Item *copy, *cut, *save, *paste, *undo, *redo;
|
Elm_Object_Item *copy, *cut, *save, *paste, *undo, *redo;
|
||||||
|
@ -28,7 +30,6 @@ typedef struct _Ecrire_Editor
|
||||||
Elm_Object_Item *copy, *cut, *save, *paste, *undo, *redo;
|
Elm_Object_Item *copy, *cut, *save, *paste, *undo, *redo;
|
||||||
} toolbar;
|
} toolbar;
|
||||||
|
|
||||||
|
|
||||||
const char *filename;
|
const char *filename;
|
||||||
int unsaved;
|
int unsaved;
|
||||||
|
|
||||||
|
@ -45,10 +46,10 @@ typedef struct _Ecrire_Editor
|
||||||
Eina_Bool undo_stack_can_merge;
|
Eina_Bool undo_stack_can_merge;
|
||||||
} Ecrire_Editor;
|
} Ecrire_Editor;
|
||||||
|
|
||||||
void ecrire_editor_open(const char *filename, const char *font_name, int font_size);
|
void ecrire_editor_add(const char *filename, const char *font_name, int font_size);
|
||||||
void ecrire_editor_font_set_save(Ecrire_Editor *inst, const char *font, int size);
|
void ecrire_editor_font_save(Ecrire_Editor *inst, const char *font, int size);
|
||||||
void ecrire_editor_font_set(Ecrire_Editor *inst, const char *font, int font_size);
|
void ecrire_editor_font_set(Ecrire_Editor *inst, const char *font, int font_size);
|
||||||
void ecrire_editor_save_then(Ecrire_Editor *inst, void *callback_func);
|
void ecrire_editor_try_save(Ecrire_Editor *inst, void *callback_func);
|
||||||
void ecrire_editor_save(Ecrire_Editor *inst, const char *file);
|
void ecrire_editor_save(Ecrire_Editor *inst, const char *file);
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
|
|
|
@ -9,13 +9,11 @@
|
||||||
|
|
||||||
static Eina_Unicode plain_utf8 = EINA_TRUE;
|
static Eina_Unicode plain_utf8 = EINA_TRUE;
|
||||||
|
|
||||||
static void print_usage(const char *bin);
|
|
||||||
|
|
||||||
/* specific log domain to help debug only ecrire */
|
/* specific log domain to help debug only ecrire */
|
||||||
int _ecrire_log_dom = -1;
|
int _ecrire_log_dom = -1;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_win_del_do(void *data)
|
_editor_del(void *data)
|
||||||
{
|
{
|
||||||
Ecrire_Editor *inst = data;
|
Ecrire_Editor *inst = data;
|
||||||
evas_object_del(inst->win);
|
evas_object_del(inst->win);
|
||||||
|
@ -391,7 +389,7 @@ _cb_fs_open_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
|
|
||||||
if (!selected) return;
|
if (!selected) return;
|
||||||
|
|
||||||
ecrire_editor_open(selected, _ent_cfg->font.name, _ent_cfg->font.size);
|
ecrire_editor_add(selected, _ent_cfg->font.name, _ent_cfg->font.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -453,7 +451,7 @@ _cb_open(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ecrire_editor_save_then(Ecrire_Editor *inst, void *callback_func)
|
ecrire_editor_try_save(Ecrire_Editor *inst, void *callback_func)
|
||||||
{
|
{
|
||||||
if (inst->filename)
|
if (inst->filename)
|
||||||
ecrire_editor_save(inst, inst->filename);
|
ecrire_editor_save(inst, inst->filename);
|
||||||
|
@ -465,7 +463,7 @@ static void
|
||||||
_cb_save(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
_cb_save(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Ecrire_Editor *inst = data;
|
Ecrire_Editor *inst = data;
|
||||||
ecrire_editor_save_then(inst, _cb_fs_ecrire_editor_save);
|
ecrire_editor_try_save(inst, _cb_fs_ecrire_editor_save);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -478,14 +476,14 @@ _cb_save_as(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
||||||
static void
|
static void
|
||||||
_cb_new(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
_cb_new(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
ecrire_editor_open(NULL, _ent_cfg->font.name, _ent_cfg->font.size);
|
ecrire_editor_add(NULL, _ent_cfg->font.name, _ent_cfg->font.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cb_close(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
_cb_close(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Ecrire_Editor *inst = data;
|
Ecrire_Editor *inst = data;
|
||||||
_alert_if_need_saving(_win_del_do, inst);
|
_alert_if_need_saving(_editor_del, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -528,7 +526,7 @@ _cb_win_del(void *data, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
Ecrire_Editor *inst = data;
|
Ecrire_Editor *inst = data;
|
||||||
(void) data;
|
(void) data;
|
||||||
_alert_if_need_saving(_win_del_do, inst);
|
_alert_if_need_saving(_editor_del, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -561,9 +559,10 @@ _cb_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event)
|
||||||
void
|
void
|
||||||
ecrire_editor_font_set(Ecrire_Editor *inst, const char *font, int font_size)
|
ecrire_editor_font_set(Ecrire_Editor *inst, const char *font, int font_size)
|
||||||
{
|
{
|
||||||
const Evas_Object *tb = elm_entry_textblock_get(inst->entry);
|
|
||||||
Eina_Strbuf *sbuf;
|
Eina_Strbuf *sbuf;
|
||||||
|
const Evas_Object *tb;
|
||||||
|
|
||||||
|
tb = elm_entry_textblock_get(inst->entry);
|
||||||
sbuf = eina_strbuf_new();
|
sbuf = eina_strbuf_new();
|
||||||
|
|
||||||
if (font)
|
if (font)
|
||||||
|
@ -590,7 +589,7 @@ ecrire_editor_font_set(Ecrire_Editor *inst, const char *font, int font_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ecrire_editor_font_set_save(Ecrire_Editor *inst, const char *font, int size)
|
ecrire_editor_font_save(Ecrire_Editor *inst, const char *font, int size)
|
||||||
{
|
{
|
||||||
ecrire_editor_font_set(inst, font, size);
|
ecrire_editor_font_set(inst, font, size);
|
||||||
|
|
||||||
|
@ -629,6 +628,8 @@ _ecrire_toolbar_add(Ecrire_Editor *inst)
|
||||||
elm_toolbar_item_separator_set(it, 1);
|
elm_toolbar_item_separator_set(it, 1);
|
||||||
inst->toolbar.undo = elm_toolbar_item_append(tb, "edit-undo", _("Undo"), _cb_undo, inst);
|
inst->toolbar.undo = elm_toolbar_item_append(tb, "edit-undo", _("Undo"), _cb_undo, inst);
|
||||||
inst->toolbar.redo = elm_toolbar_item_append(tb, "edit-redo", _("Redo"), _cb_redo, inst);
|
inst->toolbar.redo = elm_toolbar_item_append(tb, "edit-redo", _("Redo"), _cb_redo, inst);
|
||||||
|
it = elm_toolbar_item_append(tb, "separator", "", NULL, NULL);
|
||||||
|
elm_toolbar_item_separator_set(it, 1);
|
||||||
elm_toolbar_item_append(tb, "edit-find-replace", _("Find"), _cb_find, inst);
|
elm_toolbar_item_append(tb, "edit-find-replace", _("Find"), _cb_find, inst);
|
||||||
elm_toolbar_item_append(tb, "go-jump", _("Go to..."), _cb_goto_line, inst);
|
elm_toolbar_item_append(tb, "go-jump", _("Go to..."), _cb_goto_line, inst);
|
||||||
it = elm_toolbar_item_append(tb, "separator", "", NULL, NULL);
|
it = elm_toolbar_item_append(tb, "separator", "", NULL, NULL);
|
||||||
|
@ -638,6 +639,7 @@ _ecrire_toolbar_add(Ecrire_Editor *inst)
|
||||||
elm_object_item_disabled_set(inst->toolbar.copy, EINA_TRUE);
|
elm_object_item_disabled_set(inst->toolbar.copy, EINA_TRUE);
|
||||||
elm_object_item_disabled_set(inst->toolbar.cut, EINA_TRUE);
|
elm_object_item_disabled_set(inst->toolbar.cut, EINA_TRUE);
|
||||||
elm_object_item_disabled_set(inst->toolbar.save, EINA_TRUE);
|
elm_object_item_disabled_set(inst->toolbar.save, EINA_TRUE);
|
||||||
|
|
||||||
return tb;
|
return tb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,7 +685,7 @@ _ecrire_menu_add(Ecrire_Editor *inst)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ecrire_editor_open(const char *filename, const char *font_name, int font_size)
|
ecrire_editor_add(const char *filename, const char *font_name, int font_size)
|
||||||
{
|
{
|
||||||
Evas_Object *win, *pad, *fr, *bx, *entry, *cur_info;
|
Evas_Object *win, *pad, *fr, *bx, *entry, *cur_info;
|
||||||
Evas_Object *toolbar;
|
Evas_Object *toolbar;
|
||||||
|
@ -788,7 +790,7 @@ elm_main(int argc, char **argv)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '?':
|
case '?':
|
||||||
print_usage(argv[0]);
|
fprintf(stderr, "Usage: %s [filename]\n", argv[0]);
|
||||||
if (isprint (optopt))
|
if (isprint (optopt))
|
||||||
{
|
{
|
||||||
ERR("Unknown option or requires an argument `-%c'.",
|
ERR("Unknown option or requires an argument `-%c'.",
|
||||||
|
@ -834,7 +836,7 @@ elm_main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ecrire_editor_open(filename, _ent_cfg->font.name, _ent_cfg->font.size);
|
ecrire_editor_add(filename, _ent_cfg->font.name, _ent_cfg->font.size);
|
||||||
|
|
||||||
elm_run();
|
elm_run();
|
||||||
|
|
||||||
|
@ -843,10 +845,6 @@ elm_main(int argc, char **argv)
|
||||||
_ecrire_log_dom = -1;
|
_ecrire_log_dom = -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ELM_MAIN()
|
ELM_MAIN()
|
||||||
|
|
||||||
static void
|
|
||||||
print_usage(const char *bin)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Usage: %s [filename]\n", bin);
|
|
||||||
}
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ _save(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
Ecrire_Editor *inst = done_data;
|
Ecrire_Editor *inst = done_data;
|
||||||
|
|
||||||
evas_object_del(data);
|
evas_object_del(data);
|
||||||
ecrire_editor_save_then(inst, _fs_save_done);
|
ecrire_editor_try_save(inst, _fs_save_done);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
|
|
||||||
#include "../Ecrire.h"
|
#include "../Ecrire.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
typedef struct _File_Selector_Data
|
typedef struct _File_Selector_Data
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
#include "../Ecrire.h"
|
#include "../Ecrire.h"
|
||||||
|
|
||||||
Evas_Object *_settings_popup;
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Evas_Object *list;
|
Evas_Object *list;
|
||||||
|
@ -16,15 +14,14 @@ typedef struct
|
||||||
static Settings _settings;
|
static Settings _settings;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cb_popup_del(void *data, Evas_Object *obj EINA_UNUSED,
|
_cb_popup_hide(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
void *event_info EINA_UNUSED)
|
void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Ecrire_Editor *inst = data;
|
Ecrire_Editor *inst = data;
|
||||||
|
|
||||||
|
if (inst->settings_popup)
|
||||||
|
evas_object_hide(inst->settings_popup);
|
||||||
elm_object_focus_set(inst->win, 1);
|
elm_object_focus_set(inst->win, 1);
|
||||||
if (_settings_popup)
|
|
||||||
evas_object_del(_settings_popup);
|
|
||||||
_settings_popup = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_List *
|
static Eina_List *
|
||||||
|
@ -72,7 +69,7 @@ _cb_font_selected(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
eina_stringshare_replace(&inst->font.name, selected);
|
eina_stringshare_replace(&inst->font.name, selected);
|
||||||
ecrire_editor_font_set_save(inst, inst->font.name, inst->font.size);
|
ecrire_editor_font_save(inst, inst->font.name, inst->font.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -84,7 +81,7 @@ _cb_spinner_delay_changed(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
inst->font.size = elm_spinner_value_get(obj);
|
inst->font.size = elm_spinner_value_get(obj);
|
||||||
|
|
||||||
if (inst->font.name)
|
if (inst->font.name)
|
||||||
ecrire_editor_font_set_save(inst, inst->font.name, inst->font.size);
|
ecrire_editor_font_save(inst, inst->font.name, inst->font.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -102,11 +99,11 @@ _cb_check_changed(void *data, Evas_Object *obj,
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
inst->font.name = NULL;
|
inst->font.name = NULL;
|
||||||
ecrire_editor_font_set_save(inst, NULL, 0);
|
ecrire_editor_font_save(inst, NULL, 0);
|
||||||
}
|
}
|
||||||
else if (inst->font.name)
|
else if (inst->font.name)
|
||||||
{
|
{
|
||||||
ecrire_editor_font_set_save(inst, inst->font.name, inst->font.size);
|
ecrire_editor_font_save(inst, inst->font.name, inst->font.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +112,7 @@ _cb_btn_clicked(void *data, Evas_Object *obj,
|
||||||
void *event_info EINA_UNUSED)
|
void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Ecrire_Editor *inst = data;
|
Ecrire_Editor *inst = data;
|
||||||
_cb_popup_del(inst, NULL, NULL);
|
_cb_popup_hide(inst, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Evas_Object *
|
Evas_Object *
|
||||||
|
@ -123,13 +120,16 @@ ui_settings_open(Evas_Object *parent, Ecrire_Editor *inst)
|
||||||
{
|
{
|
||||||
Evas_Object *pop, *tb, *rec, *bx, *hbx, *btn, *list, *lb, *sp, *ck;
|
Evas_Object *pop, *tb, *rec, *bx, *hbx, *btn, *list, *lb, *sp, *ck;
|
||||||
|
|
||||||
if (_settings_popup)
|
if (inst->settings_popup)
|
||||||
return _settings_popup;
|
{
|
||||||
|
evas_object_show(inst->settings_popup);
|
||||||
|
return inst->settings_popup;
|
||||||
|
}
|
||||||
|
|
||||||
_settings_popup = pop = elm_popup_add(parent);
|
inst->settings_popup = pop = elm_popup_add(parent);
|
||||||
elm_object_style_set(pop, "transparent");
|
elm_object_style_set(pop, "transparent");
|
||||||
evas_object_size_hint_weight_set(pop, 1, 1);
|
evas_object_size_hint_weight_set(pop, 1, 1);
|
||||||
evas_object_smart_callback_add(pop, "dismissed", _cb_popup_del, inst);
|
evas_object_smart_callback_add(pop, "dismissed", _cb_popup_hide, inst);
|
||||||
elm_object_part_text_set(pop, "title,text", _("Settings"));
|
elm_object_part_text_set(pop, "title,text", _("Settings"));
|
||||||
|
|
||||||
bx = elm_box_add(pop);
|
bx = elm_box_add(pop);
|
||||||
|
|
Loading…
Reference in New Issue