ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=1867697292cbaa43b93d17de1aeca6c4e67fa0b1

commit 1867697292cbaa43b93d17de1aeca6c4e67fa0b1
Author: Andy Williams <a...@andywilliams.me>
Date:   Sun Feb 21 23:46:44 2016 +0000

    [ui] re-add the undo button, it's back
    
    Now that most keyboard actions can be undone it seemed
    sensible to get the ui elements back again.
---
 src/bin/edi_main.c              | 18 ++++++++++++++++++
 src/bin/mainview/edi_mainview.c | 15 +++++++++++++++
 src/bin/mainview/edi_mainview.h |  9 ++++++++-
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/src/bin/edi_main.c b/src/bin/edi_main.c
index 9358574..04f5201 100644
--- a/src/bin/edi_main.c
+++ b/src/bin/edi_main.c
@@ -581,6 +581,13 @@ _tb_close_cb(void *data EINA_UNUSED, Evas_Object *obj, 
void *event_info EINA_UNU
 }
 
 static void
+_tb_undo_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info 
EINA_UNUSED)
+{
+   elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), 
EINA_FALSE);
+   edi_mainview_undo();
+}
+
+static void
 _tb_cut_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info 
EINA_UNUSED)
 {
    elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), 
EINA_FALSE);
@@ -726,6 +733,13 @@ _edi_menu_quit_cb(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED,
 }
 
 static void
+_edi_menu_undo_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+                  void *event_info EINA_UNUSED)
+{
+   edi_mainview_undo();
+}
+
+static void
 _edi_menu_cut_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
                  void *event_info EINA_UNUSED)
 {
@@ -829,6 +843,8 @@ _edi_menu_setup(Evas_Object *win)
    elm_menu_item_add(menu, menu_it, "application-exit", "Quit", 
_edi_menu_quit_cb, NULL);
 
    menu_it = elm_menu_item_add(menu, NULL, NULL, "Edit", NULL, NULL);
+   elm_menu_item_add(menu, menu_it, "edit-undo", "Undo", _edi_menu_undo_cb, 
NULL);
+   elm_menu_item_separator_add(menu, menu_it);
    elm_menu_item_add(menu, menu_it, "edit-cut", "Cut", _edi_menu_cut_cb, NULL);
    elm_menu_item_add(menu, menu_it, "edit-copy", "Copy", _edi_menu_copy_cb, 
NULL);
    elm_menu_item_add(menu, menu_it, "edit-paste", "Paste", _edi_menu_paste_cb, 
NULL);
@@ -879,6 +895,8 @@ edi_toolbar_setup(Evas_Object *win)
    tb_it = elm_toolbar_item_append(tb, "separator", "", NULL, NULL);
    elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
 
+   tb_it = elm_toolbar_item_append(tb, "edit-undo", "Undo", _tb_undo_cb, NULL);
+   tb_it = elm_toolbar_item_append(tb, "separator", "", NULL, NULL);
    tb_it = elm_toolbar_item_append(tb, "edit-cut", "Cut", _tb_cut_cb, NULL);
    tb_it = elm_toolbar_item_append(tb, "edit-copy", "Copy", _tb_copy_cb, NULL);
    tb_it = elm_toolbar_item_append(tb, "edit-paste", "Paste", _tb_paste_cb, 
NULL);
diff --git a/src/bin/mainview/edi_mainview.c b/src/bin/mainview/edi_mainview.c
index 4fb2e26..3cf3f2f 100644
--- a/src/bin/mainview/edi_mainview.c
+++ b/src/bin/mainview/edi_mainview.c
@@ -524,6 +524,21 @@ edi_mainview_closeall()
 }
 
 void
+edi_mainview_undo()
+{
+   Evas_Object *content;
+   Elm_Object_Item *it;
+   Edi_Editor *editor;
+
+   it = elm_naviframe_top_item_get(nf);
+   content = elm_object_item_content_get(it);
+   editor = (Edi_Editor *)evas_object_data_get(content, "editor");
+
+   if (editor)
+     elm_code_widget_undo(editor->entry);
+}
+
+void
 edi_mainview_cut()
 {
    Evas_Object *content;
diff --git a/src/bin/mainview/edi_mainview.h b/src/bin/mainview/edi_mainview.h
index cd815b1..87268b6 100644
--- a/src/bin/mainview/edi_mainview.h
+++ b/src/bin/mainview/edi_mainview.h
@@ -40,7 +40,7 @@ void edi_mainview_add(Evas_Object *parent, Evas_Object *win);
 /**
  * @}
  *
- * 
+ *
  * @brief Content management functions.
  * @defgroup Content
  *
@@ -118,6 +118,13 @@ void edi_mainview_close();
 void edi_mainview_closeall();
 
 /**
+ * Undo the most recent change in the current view.
+ *
+ * @ingroup Content
+ */
+void edi_mainview_undo();
+
+/**
  * Cut the current selection into the clipboard.
  *
  * @ingroup Content

-- 


Reply via email to