rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=1bfdec3f65add84f445dfcd8fff7cd62c68426fe

commit 1bfdec3f65add84f445dfcd8fff7cd62c68426fe
Author: Andrii Kroitor <an.kroi...@samsung.com>
Date:   Mon Feb 8 14:36:03 2016 +0200

    shortcuts: implement hisoty undo/redo
    
    Add undo and redo to Ctrl+x and Ctrl+y
    keys binding.
---
 src/bin/common/signals.h         | 15 +++++++++++++++
 src/bin/ui/history_ui.c          | 36 ++++++++++++++++++++++++++++++++++++
 src/bin/ui/shortcuts/shortcuts.c | 16 ++++++----------
 3 files changed, 57 insertions(+), 10 deletions(-)

diff --git a/src/bin/common/signals.h b/src/bin/common/signals.h
index 85aa3ee..b0db11e 100644
--- a/src/bin/common/signals.h
+++ b/src/bin/common/signals.h
@@ -441,4 +441,19 @@ typedef struct {
  */
 #define SIGNAL_DEMO_SIGNAL_SEND "SIGNAL_DEMO_SIGNAL_SEND"
 
+/**
+ * emited when undo shortcut is pressed.
+ * eventinfo - NULL.
+ *
+ * @ingroup Window
+ */
+#define SIGNAL_SHORTCUT_UNDO "SIGNAL_SHORTCUT_UNDO"
+/**
+ * emited redo shortcut is pressed.
+ * eventinfo - NULL.
+ *
+ * @ingroup Window
+ */
+#define SIGNAL_SHORTCUT_REDO "SIGNAL_SHORTCUT_REDO"
+
 #endif /* SIGNALS_H*/
diff --git a/src/bin/ui/history_ui.c b/src/bin/ui/history_ui.c
index 44611e7..ff04b81 100644
--- a/src/bin/ui/history_ui.c
+++ b/src/bin/ui/history_ui.c
@@ -180,6 +180,40 @@ _history_set(void *data __UNUSED__,
      }
 }
 
+static void
+_undo_shortcut(void *data __UNUSED__,
+               Evas_Object *obj __UNUSED__,
+               void * ei __UNUSED__)
+{
+   Elm_Genlist_Item *glit;
+
+   if (!hd.history)
+     return;
+
+   assert(hd.active_item != NULL);
+
+   glit = elm_genlist_item_prev_get(hd.active_item);
+   if (glit)
+     elm_genlist_item_selected_set(glit, true);
+}
+
+static void
+_redo_shortcut(void *data __UNUSED__,
+               Evas_Object *obj __UNUSED__,
+               void * ei __UNUSED__)
+{
+   Elm_Genlist_Item *glit;
+
+   if (!hd.history)
+     return;
+
+   assert(hd.active_item != NULL);
+
+   glit = elm_genlist_item_next_get(hd.active_item);
+   if (glit)
+     elm_genlist_item_selected_set(glit, true);
+}
+
 Evas_Object *
 history_ui_add(void)
 {
@@ -212,6 +246,8 @@ history_ui_add(void)
 
    evas_object_smart_callback_add(ap.win, SIGNAL_HISTORY_CHANGE_ADDED, 
_on_change_added, NULL);
    evas_object_smart_callback_add(ap.win, SIGNAL_TAB_CHANGED, _history_set, 
NULL);
+   evas_object_smart_callback_add(ap.win, SIGNAL_SHORTCUT_UNDO, 
_undo_shortcut, NULL);
+   evas_object_smart_callback_add(ap.win, SIGNAL_SHORTCUT_REDO, 
_redo_shortcut, NULL);
 
    TODO("Add clean-up callbacks here")
    return hd.layout;
diff --git a/src/bin/ui/shortcuts/shortcuts.c b/src/bin/ui/shortcuts/shortcuts.c
index 4d05400..b338a04 100644
--- a/src/bin/ui/shortcuts/shortcuts.c
+++ b/src/bin/ui/shortcuts/shortcuts.c
@@ -559,22 +559,18 @@ static Eina_Bool
 _undo_cb(void)
 {
    SKIP_IN_ENVENTOR_MODE
-/*   if ((ap.project) && (ap.project->current_style))
-     history_undo(ap.project->current_style->obj, 1);
-   return true;*/
-   return false;
-   TODO("Implement undo shortcut");
+
+   evas_object_smart_callback_call(ap.win, SIGNAL_SHORTCUT_UNDO, NULL);
+   return true;
 }
 
 static Eina_Bool
 _redo_cb(void)
 {
    SKIP_IN_ENVENTOR_MODE
-/*   if ((ap.project) && (ap.project->current_style))
-     history_redo(ap.project->current_style->obj, 1);
-   return true;*/
-   return false;
-   TODO("Implement redo shortcut");
+
+   evas_object_smart_callback_call(ap.win, SIGNAL_SHORTCUT_REDO, NULL);
+   return true;
 }
 
 /*========================================================*/

-- 


Reply via email to