[Copy&Paste] Add notify when click on Copy/Cut item
authorThiep Ha <thiep.ha@samsung.com>
Fri, 5 Apr 2013 04:47:46 +0000 (13:47 +0900)
committerSungho Kwak <sungho1.kwak@samsung.com>
Sat, 6 Apr 2013 01:35:58 +0000 (10:35 +0900)
Change-Id: Iaae2abaa7ea5628b571efd5137bc48a4947a9ec7

src/lib/elm_module_priv.h
src/modules/ctxpopup_copypasteUI/copypaste.c

index 0a5f6c6..e9b9b7f 100644 (file)
@@ -9,6 +9,7 @@ struct _Elm_Entry_Extension_data
        Evas_Object *popup;
        Evas_Object *ent;
        Evas_Object *caller;
+       Evas_Object *notify; // TEMP: will be done by clipboard
        Evas_Coord_Rectangle viewport_rect;
        Eina_List *items;
        cpfunc select;
index 45b3bce..a571c5d 100644 (file)
 #define S_CLIPBOARD MULTI_(IDS_COM_BODY_CLIPBOARD)
 #define S_COPIED MULTI_(IDS_COM_POP_COPIED_TO_CLIPBOARD)
 
+// TEMP: Will be done by clipboard - start
+#define NOTIFY_TIMEOUT 2.0
+#define DATA_KEY "_data"
+// TEMP - end
+
 Elm_Entry_Extension_data *ext_mod;
 static int _mod_hook_count = 0;
 
 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
+typedef struct _Tickernoti_Data Tickernoti_Data;
+
 struct _Elm_Entry_Context_Menu_Item
 {
    Evas_Object *obj;
@@ -28,6 +35,13 @@ struct _Elm_Entry_Context_Menu_Item
    void *data;
 };
 
+// TEMP: Will be done by clipboard - start
+struct _Tickernoti_Data
+{
+   Ecore_Timer *timer;
+};
+// TEMP - end
+
 static void _ctxpopup_hide(Evas_Object *popup);
 static void _ctxpopup_position(Evas_Object *obj);
 
@@ -252,6 +266,116 @@ _ctxpopup_position(Evas_Object *obj __UNUSED__)
      }
 }
 
+// TEMP: Will be done by clipboard - start
+static Eina_Bool
+_hide_notify_cb(void *data __UNUSED__)
+{
+   Tickernoti_Data *td;
+   if (!ext_mod) return ECORE_CALLBACK_CANCEL;
+   if (!ext_mod->notify) return ECORE_CALLBACK_CANCEL;
+   evas_object_hide(ext_mod->notify);
+   elm_win_indicator_mode_set(ext_mod->notify, ELM_WIN_INDICATOR_SHOW);
+
+   td = evas_object_data_get(ext_mod->notify, DATA_KEY);
+   if (!td) return ECORE_CALLBACK_CANCEL;
+   if (td->timer)
+     ecore_timer_del(td->timer);
+   td->timer = NULL;
+   return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_notify_create(Evas_Object *parent)
+{
+   Evas_Object *content;
+   Tickernoti_Data *td;
+   Evas_Object *content_edje;
+   Evas_Coord nx, ny, nw, nh;
+   Evas_Coord x, y, h;
+   int angle;
+
+   if (!ext_mod) return;
+
+   if (ext_mod->notify)
+     {
+        free(evas_object_data_get(ext_mod->notify, DATA_KEY));
+        evas_object_del(ext_mod->notify);
+     }
+
+   //win
+   ext_mod->notify = elm_win_add(parent, NULL, ELM_WIN_NOTIFICATION);
+   elm_win_borderless_set(ext_mod->notify, EINA_TRUE);
+   elm_win_autodel_set(ext_mod->notify, EINA_TRUE);
+   elm_win_alpha_set(ext_mod->notify, EINA_TRUE);
+   evas_object_size_hint_weight_set(ext_mod->notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+   //content
+   content = elm_layout_add(ext_mod->notify);
+   elm_layout_theme_set(content, "tickernoti", "base", "textonly");
+   elm_object_text_set(content, S_COPIED);
+   evas_object_show(content);
+   evas_object_size_hint_weight_set(content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(ext_mod->notify, content);
+
+   //position
+   content_edje = elm_layout_edje_get(content);
+   edje_object_part_geometry_get(content_edje, "bg", NULL, NULL, NULL, &h);
+   ecore_x_window_size_get(ecore_x_window_root_first_get(), &x, &y);
+
+   angle = elm_win_rotation_get(elm_widget_top_get(parent));
+   switch (angle)
+     {
+      case 0:
+         nx = ny = 0;
+         nw = x;
+         nh = h;
+         break;
+
+      case 90:
+         nx = ny = 0;
+         nw = h;
+         nh = y;
+         break;
+
+      case 180:
+         nx = 0;
+         ny = y - h;
+         nw = x;
+         nh = h;
+         break;
+
+      case 270:
+      case -90:
+         nx = x -h;
+         ny = 0;
+         nw = h;
+         nh = y;
+         angle = 270;
+         break;
+
+      default:
+         nx = ny = 0;
+         nw = x;
+         nh = h;
+         angle = 0;
+         break;
+     }
+   evas_object_move(ext_mod->notify, nx, ny);
+   evas_object_resize(ext_mod->notify, nw, nh);
+   elm_win_rotation_set(ext_mod->notify, angle);
+
+   //timer to hide notify
+   td = (Tickernoti_Data *)calloc(1, sizeof(Tickernoti_Data));
+   if (!td) return;
+   td->timer = ecore_timer_add(NOTIFY_TIMEOUT, _hide_notify_cb, NULL);
+   evas_object_data_set(ext_mod->notify, DATA_KEY, td);
+
+   elm_win_prop_focus_skip_set(ext_mod->notify, EINA_TRUE);
+   evas_object_show(ext_mod->notify);
+   elm_win_indicator_mode_set(ext_mod->notify, ELM_WIN_INDICATOR_HIDE);
+}
+// TEMP - end
+
 static void
 _select_all(void *data, Evas_Object *obj, void *event_info)
 {
@@ -287,6 +411,8 @@ _cut(void *data, Evas_Object *obj, void *event_info)
    ext_mod->cut(data,obj,event_info);
    _ctxpopup_hide(obj);
 
+   _notify_create((Evas_Object *)data); // TEMP: will be done by clipboard
+
    //elm_object_scroll_freeze_pop(ext_mod->popup);
 }
 
@@ -297,6 +423,7 @@ _copy(void *data, Evas_Object *obj, void *event_info)
 
    ext_mod->copy(data,obj,event_info);
    _ctxpopup_hide(obj);
+   _notify_create((Evas_Object *) data); // TEMP: will be done by clipboard
 
    //elm_object_scroll_freeze_pop(ext_mod->popup);
 }
@@ -418,11 +545,29 @@ obj_hook(Evas_Object *obj)
 EAPI void
 obj_unhook(Evas_Object *obj)
 {
+   Tickernoti_Data *td;
+
    _mod_hook_count--;
    if(_mod_hook_count > 0) return;
 
    if(ext_mod)
      {
+        // TEMP: Will be done by clipboard - start
+        if (ext_mod->notify)
+          {
+             evas_object_hide(ext_mod->notify);
+             elm_win_indicator_mode_set(ext_mod->notify, ELM_WIN_INDICATOR_SHOW);
+             td = evas_object_data_get(ext_mod->notify, DATA_KEY);
+             if (td)
+               {
+                  if (td->timer)
+                    ecore_timer_del(td->timer);
+                  td->timer = NULL;
+                  free(td);
+                  td = NULL;
+               }
+          }
+        // TEMP: Will be done by clipboard - end
         free(ext_mod);
         ext_mod = NULL;
      }