raster pushed a commit to branch master. http://git.enlightenment.org/apps/ecrire.git/commit/?id=5a0b895521e3527ec3d2b85f69e88c7ccd74c737
commit 5a0b895521e3527ec3d2b85f69e88c7ccd74c737 Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com> Date: Wed Apr 15 13:14:19 2020 +0100 ui - move to menu bar from toolbar - a bit more basic and simple --- src/bin/main.c | 114 ++++++++++++++++++++++++----------------------- src/bin/ui/font_dialog.c | 1 + 2 files changed, 60 insertions(+), 55 deletions(-) diff --git a/src/bin/main.c b/src/bin/main.c index dc8589f..6f99074 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -437,6 +437,12 @@ _save_as(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) ui_file_open_save_dialog_open(ent->win, _fs_save_done, EINA_TRUE); } +static void +_win_del_do(void *data EINA_UNUSED) +{ + elm_exit(); +} + static void _new_do(void *data) { @@ -454,6 +460,13 @@ _new(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) _alert_if_need_saving(_new_do, ent); } +static void +_app_exit(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Ecrire_Entry *ent = data; + _alert_if_need_saving(_win_del_do, ent); +} + static void _cut(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { @@ -490,12 +503,6 @@ _font_settings(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_U } -static void -_win_del_do(void *data EINA_UNUSED) -{ - elm_exit(); -} - static void my_win_del(void *data, Evas_Object *obj, void *event_info) { @@ -608,8 +615,9 @@ _key_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event) EAPI_MAIN int elm_main(int argc, char **argv) { - Evas_Object *bg, *tbar, *bx, *cur_info; + Evas_Object *pad, *bx, *cur_info, *menu, *bx2; Evas_Coord w = 600, h = 600; + Elm_Widget_Item *mit; int c; opterr = 0; @@ -671,30 +679,42 @@ elm_main(int argc, char **argv) DBG("Opening filename: '%s'", main_ec_ent->filename); - main_ec_ent->win = elm_win_add(NULL, "Ecrire", ELM_WIN_BASIC); + main_ec_ent->win = elm_win_util_standard_add("erire", "Ecrire"); elm_win_autodel_set(main_ec_ent->win, EINA_FALSE); - bg = elm_bg_add(main_ec_ent->win); - elm_win_resize_object_add(main_ec_ent->win, bg); - evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(bg); + menu = elm_win_main_menu_get(main_ec_ent->win); + mit = elm_menu_item_add(menu, NULL, NULL, _("File"), NULL, NULL); + elm_menu_item_add(menu, mit, "document-new", _("New"), _new, main_ec_ent); + elm_menu_item_add(menu, mit, "document-open", _("Open"), _open, main_ec_ent); + main_ec_ent->save_item = + elm_menu_item_add(menu, mit, "document-save", _("Save"), _save, main_ec_ent); + elm_menu_item_add(menu, mit, "document-save-as", _("Save As"), _save_as, main_ec_ent); + elm_menu_item_separator_add(menu, mit); + elm_menu_item_add(menu, mit, "application-exit", _("Exit"), _app_exit, main_ec_ent); + + mit = elm_menu_item_add(menu, NULL, NULL, _("Edit"), NULL, NULL); + main_ec_ent->cut_item = + elm_menu_item_add(menu, mit, "edit-cut", _("Cut"), _cut, main_ec_ent); + main_ec_ent->copy_item = + elm_menu_item_add(menu, mit, "edit-copy", _("Copy"), _copy, main_ec_ent); + main_ec_ent->paste_item = + elm_menu_item_add(menu, mit, "edit-paste", _("Paste"), _paste, main_ec_ent); + elm_menu_item_separator_add(menu, mit); + main_ec_ent->undo_item = + elm_menu_item_add(menu, mit, "edit-undo", _("Undo"), _undo, main_ec_ent); + main_ec_ent->redo_item = + elm_menu_item_add(menu, mit, "edit-redo", _("Redo"), _redo, main_ec_ent); + elm_menu_item_separator_add(menu, mit); + elm_menu_item_add(menu, mit, "edit-find-replace", _("Find"), _find, main_ec_ent); + elm_menu_item_add(menu, mit, "go-jump", _("Go to line.."), _goto_line, main_ec_ent); + elm_menu_item_separator_add(menu, mit); + elm_menu_item_add(menu, mit, "preferences-system", _("Settings"), _font_settings, main_ec_ent); bx = elm_box_add(main_ec_ent->win); elm_win_resize_object_add(main_ec_ent->win, bx); evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(bx); - tbar = elm_toolbar_add(main_ec_ent->win); - elm_toolbar_homogeneous_set(tbar, 0); - elm_toolbar_shrink_mode_set(tbar, ELM_TOOLBAR_SHRINK_SCROLL); - elm_toolbar_select_mode_set(tbar, ELM_OBJECT_SELECT_MODE_NONE); - elm_toolbar_align_set(tbar, 0.0); - evas_object_size_hint_weight_set(tbar, 0.0, 0.0); - evas_object_size_hint_align_set(tbar, EVAS_HINT_FILL, 0.0); - - elm_box_pack_end(bx, tbar); - evas_object_show(tbar); - main_ec_ent->entry = elm_entry_add(main_ec_ent->win); elm_entry_scrollable_set(main_ec_ent->entry, EINA_TRUE); elm_entry_line_wrap_set(main_ec_ent->entry, _ent_cfg->wrap_type); @@ -704,11 +724,25 @@ elm_main(int argc, char **argv) elm_box_pack_end(bx, main_ec_ent->entry); evas_object_show(main_ec_ent->entry); + pad = elm_frame_add(main_ec_ent->win); + elm_object_style_set(pad, "pad_medium"); + evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, 1.0); + evas_object_size_hint_weight_set(pad, EVAS_HINT_EXPAND, 0.0); + elm_box_pack_end(bx, pad); + evas_object_show(pad); + + bx2 = elm_box_add(main_ec_ent->win); + elm_box_horizontal_set(bx2, EINA_TRUE); + evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, 0.5); + evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_content_set(pad, bx2); + evas_object_show(bx2); + cur_info = elm_label_add(main_ec_ent->win); _cur_changed(cur_info, main_ec_ent->entry, NULL); evas_object_size_hint_align_set(cur_info, 1.0, 0.5); evas_object_size_hint_weight_set(cur_info, EVAS_HINT_EXPAND, 0.0); - elm_box_pack_end(bx, cur_info); + elm_box_pack_end(bx2, cur_info); evas_object_show(cur_info); evas_object_smart_callback_add(main_ec_ent->entry, "cursor,changed", @@ -722,35 +756,6 @@ elm_main(int argc, char **argv) evas_object_smart_callback_add(main_ec_ent->entry, "selection,cleared", _sel_clear, main_ec_ent); evas_object_event_callback_add(main_ec_ent->entry, EVAS_CALLBACK_KEY_DOWN, _key_cb, main_ec_ent); - elm_toolbar_item_append(tbar, "document-new", _("New"), _new, main_ec_ent); - elm_toolbar_item_append(tbar, "document-open", _("Open"), _open, main_ec_ent); - main_ec_ent->save_item = - elm_toolbar_item_append(tbar, "document-save", _("Save"), _save, main_ec_ent); - elm_toolbar_item_append(tbar, "document-save-as", _("Save As"), _save_as, - main_ec_ent); - elm_toolbar_item_separator_set( - elm_toolbar_item_append(tbar, "", "", NULL, NULL), EINA_TRUE); - main_ec_ent->undo_item = - elm_toolbar_item_append(tbar, "edit-undo", _("Undo"), _undo, main_ec_ent); - main_ec_ent->redo_item = - elm_toolbar_item_append(tbar, "edit-redo", _("Redo"), _redo, main_ec_ent); - elm_toolbar_item_separator_set( - elm_toolbar_item_append(tbar, "", "", NULL, NULL), EINA_TRUE); - main_ec_ent->cut_item = elm_toolbar_item_append(tbar, "edit-cut", _("Cut"), _cut, main_ec_ent); - main_ec_ent->copy_item = - elm_toolbar_item_append(tbar, "edit-copy", _("Copy"), _copy, main_ec_ent); - main_ec_ent->paste_item = - elm_toolbar_item_append(tbar, "edit-paste", _("Paste"), _paste, main_ec_ent); - elm_toolbar_item_separator_set( - elm_toolbar_item_append(tbar, "", "", NULL, NULL), EINA_TRUE); - elm_toolbar_item_append(tbar, "edit-find-replace", _("Search"), - _find, main_ec_ent); - elm_toolbar_item_append(tbar, "go-jump", _("Jump to"), _goto_line, main_ec_ent); - elm_toolbar_item_separator_set( - elm_toolbar_item_append(tbar, "", "", NULL, NULL), EINA_TRUE); - elm_toolbar_item_append(tbar, "preferences-system", _("Settings"), - _font_settings, main_ec_ent); - /* #ifdef HAVE_ECORE_X if (!ecore_x_selection_owner_get(ECORE_X_ATOM_SELECTION_CLIPBOARD)) @@ -790,6 +795,5 @@ ELM_MAIN() static void print_usage(const char *bin) { - fprintf(stderr, - "Usage: %s [filename]\n", bin); + fprintf(stderr, "Usage: %s [filename]\n", bin); } diff --git a/src/bin/ui/font_dialog.c b/src/bin/ui/font_dialog.c index f2ded5d..c18d080 100644 --- a/src/bin/ui/font_dialog.c +++ b/src/bin/ui/font_dialog.c @@ -26,6 +26,7 @@ _font_list_get(const Evas *e) Elm_Font_Properties *efp; efp = elm_font_properties_get(font); + if (!efp) continue; /* Remove dups */ if (prev_font && !strcmp(efp->name, prev_font)) { --