unifying txt/img queue to history queue
authorHyoyoung Chang <hyoyoung.chang@samsung.com>
Tue, 14 Dec 2010 06:54:36 +0000 (15:54 +0900)
committerHyoyoung Chang <hyoyoung.chang@samsung.com>
Tue, 14 Dec 2010 06:54:36 +0000 (15:54 +0900)
src/clipdrawer.c
src/clipdrawer.h
src/common.h
src/storage.c
src/xcnphandler.c

index 615a56d..04b588b 100644 (file)
@@ -76,7 +76,7 @@ static void _list_click_paste(void *data, Evas_Object *obj, void *event_info)
 
        int     pos = get_current_history_position()-hc;
        if (pos < 0)
-               pos = pos+(HISTORY_QUEUE_MAX_TXT_ITEMS);
+               pos = pos+(HISTORY_QUEUE_MAX_ITEMS);
 
        fprintf(stderr, "## pos = %d, %s\n", pos, get_item_contents_by_pos(pos));
        char *p = strdup(get_item_contents_by_pos(pos));
@@ -111,11 +111,11 @@ int clipdrawer_update_contents(void *data)
 //     if (get_clipdrawer_mode())
 //             clipdrawer_change_mode(ad);
 
-       for (i = 0; i < HISTORY_QUEUE_MAX_TXT_ITEMS; i++)
+       for (i = 0; i < HISTORY_QUEUE_MAX_ITEMS; i++)
        {
                pos = get_current_history_position() - i;
                if (pos < 0)
-                       pos = pos+HISTORY_QUEUE_MAX_TXT_ITEMS;
+                       pos = pos+HISTORY_QUEUE_MAX_ITEMS;
 
                if (get_item_contents_by_pos(pos) != NULL && strlen(get_item_contents_by_pos(pos)) > 0)
                {
@@ -435,7 +435,6 @@ int clipdrawer_add_item(char *idata, int type)
 {
        struct appdata *ad = g_get_main_appdata();
        griditem_t *newgi = NULL;
-       char* filepath = NULL;
        Eina_List *igl = NULL;
        unsigned int igl_counter = 0;
 
@@ -443,63 +442,11 @@ int clipdrawer_add_item(char *idata, int type)
 //     if (get_clipdrawer_mode())
 //             clipdrawer_change_mode(ad);
 
-/*
-       if (!check_regular_file(imagepath))
-       {
-               DTRACE("Error : it isn't normal file = %s\n", imagepath);
-               return -1;
-       }
-
-       igl = elm_gengrid_items_get(ad->hig);
-       igl_counter = eina_list_count(igl);
-
-       Eina_List *l;
-       Elm_Gengrid_Item *item;
-       griditem_t *ti = NULL;
-
-       EINA_LIST_FOREACH(igl, l, item)
-       {
-               ti = elm_gengrid_item_data_get(item);
-               if (!strcmp(ti->path, imagepath))
-               {
-                       DTRACE("Error : duplicated file path = %s\n", imagepath);
-                       return -1;
-               }
-       }
-
-       if (igl_counter >= HISTORY_QUEUE_MAX_IMG_ITEMS)
-       {
-               elm_gengrid_item_del(eina_list_data_get(eina_list_last(igl)));
-       }
-
-       newgi = malloc(sizeof(griditem_t));
-       newgi->itype = GI_IMAGE;
-       newgi->idata = eina_stringshare_add(imagepath);
-       newgi->item = elm_gengrid_item_prepend(ad->hig, &gic, newgi, NULL, NULL);
-*/
-
-/*
-       static int testmode = 0;
-       testmode++;
-
-       newgi = malloc(sizeof(griditem_t));
-       if (testmode % 3)
-       {
-       newgi->itype = GI_IMAGE;
-       newgi->idata = eina_stringshare_add(imagepath);
-       }
-       else
-       {
-       newgi->itype = GI_TEXT;
-       newgi->idata = eina_strbuf_new();
-       eina_strbuf_append(newgi->idata, "hello!! <item absize=40x30 href=file:///usr/share/icon/cbhm/cbhm_default_img.png></item>");
-
-       }
-       newgi->item = elm_gengrid_item_append(ad->hig, &gic, newgi, NULL, NULL);
-*/
 
        newgi = malloc(sizeof(griditem_t));
        newgi->itype = type;
+       igl = elm_gengrid_items_get(ad->hig);
+       igl_counter = eina_list_count(igl);
 
        fprintf(stderr, "## add - %d : %s\n", newgi->itype, idata);
        if (type == GI_TEXT)
@@ -509,8 +456,34 @@ int clipdrawer_add_item(char *idata, int type)
        }
        else //if (type == GI_IMAGE)
        {
+               Eina_List *l;
+               Elm_Gengrid_Item *item;
+               griditem_t *ti = NULL;
+
+               if (!check_regular_file(idata))
+               {
+                       DTRACE("Error : it isn't normal file = %s\n", idata);
+                       return -1;
+               }
+
+               EINA_LIST_FOREACH(igl, l, item)
+               {
+                       ti = elm_gengrid_item_data_get(item);
+                       if ((ti->itype == type) && !strcmp(ti->ipathdata, idata))
+                       {
+                               DTRACE("Error : duplicated file path = %s\n", idata);
+                               return -1;
+                       }
+               }
+
                newgi->ipathdata = eina_stringshare_add(idata);
        }
+
+       if (igl_counter >= HISTORY_QUEUE_MAX_ITEMS)
+       {
+               elm_gengrid_item_del(eina_list_data_get(eina_list_last(igl)));
+       }
+
        newgi->item = elm_gengrid_item_prepend(ad->hig, &gic, newgi, NULL, NULL);
 
        return TRUE;
index 14a06dd..a36dd07 100644 (file)
@@ -12,7 +12,7 @@ enum {
        GI_TEXT = 0,
        GI_IMAGE,
 
-       GI_MAX_ITEM,
+       GI_MAX_ITEMS,
 };
 
 /* view maintains */
index 8359299..59b5b7a 100644 (file)
@@ -31,8 +31,7 @@
 
 struct appdata;
 
-#define HISTORY_QUEUE_MAX_TXT_ITEMS 5
-#define HISTORY_QUEUE_TXT_ITEM_SIZE (4 * 1024) // 4Kilo 
-#define HISTORY_QUEUE_MAX_IMG_ITEMS 10
+#define HISTORY_QUEUE_ITEM_SIZE (5 * 1024) // 4Kilo 
+#define HISTORY_QUEUE_MAX_ITEMS 12
 
 #endif // _common_h_
index 77013a0..94d7086 100644 (file)
@@ -2,9 +2,9 @@
 #include "storage.h"
 
 #define STORAGE_FILEPATH "/opt/var/.savecbh"
-#define STORAGE_MAX_ITEMS HISTORY_QUEUE_MAX_TXT_ITEMS
+#define STORAGE_MAX_ITEMS HISTORY_QUEUE_MAX_ITEMS
 #define HEADER_ITEM_SIZE (sizeof(int)) 
-#define BODY_ITEM_SIZE HISTORY_QUEUE_TXT_ITEM_SIZE
+#define BODY_ITEM_SIZE HISTORY_QUEUE_ITEM_SIZE
 #define STORAGE_HEADER_SIZE (STORAGE_MAX_ITEMS * HEADER_ITEM_SIZE)
 #define STORAGE_BODY_SIZE (STORAGE_MAX_ITEMS * BODY_ITEM_SIZE) 
 #define TOTAL_STORAGE_SIZE (STORAGE_HEADER_SIZE+STORAGE_BODY_SIZE)
index a33b456..128a595 100755 (executable)
@@ -93,7 +93,7 @@ static void _set_cbhmwin_prop()
 int increment_current_history_position()
 {
        int pos = g_history_pos+1;
-       if (pos >= HISTORY_QUEUE_MAX_TXT_ITEMS)
+       if (pos >= HISTORY_QUEUE_MAX_ITEMS)
                pos = 0;
        g_history_pos = pos;
        return pos;
@@ -103,7 +103,7 @@ int get_current_history_position()
 {
        int pos = g_history_pos-1;
        if (pos < 0)
-               pos = HISTORY_QUEUE_MAX_TXT_ITEMS-1;
+               pos = HISTORY_QUEUE_MAX_ITEMS-1;
        
        return pos;
 }
@@ -116,8 +116,8 @@ int add_to_storage_buffer(void *data, char *src, int len)
                return -1;
 
        if (g_lastest_content == NULL)
-               g_lastest_content = malloc(sizeof(char)*(HISTORY_QUEUE_TXT_ITEM_SIZE));
-       if (g_history_pos >= HISTORY_QUEUE_MAX_TXT_ITEMS)
+               g_lastest_content = malloc(sizeof(char)*(HISTORY_QUEUE_ITEM_SIZE));
+       if (g_history_pos >= HISTORY_QUEUE_MAX_ITEMS)
                g_history_pos = 0;
 
        // FIXME: remove g_lasteset_content
@@ -144,11 +144,11 @@ int print_storage_buffer()
 {
        int pos;
        int i = 0;
-       for (i = 0; i < HISTORY_QUEUE_MAX_TXT_ITEMS; i++)
+       for (i = 0; i < HISTORY_QUEUE_MAX_ITEMS; i++)
        {
                pos = get_current_history_position()+i;
-               if (pos > HISTORY_QUEUE_MAX_TXT_ITEMS-1)
-                       pos = pos-HISTORY_QUEUE_MAX_TXT_ITEMS;
+               if (pos > HISTORY_QUEUE_MAX_ITEMS-1)
+                       pos = pos-HISTORY_QUEUE_MAX_ITEMS;
                DTRACE("%d: %s\n", i, get_item_contents_by_pos(pos) != NULL ? get_item_contents_by_pos(pos) : "NULL");
        }
 }
@@ -499,7 +499,7 @@ static int _xclient_msg_cb(void *data, int ev_type, void *event)
        Atom atomCBHM_cRAW = XInternAtom(g_disp, "CBHM_cRAW", False);
        Atom atomXKey_MSG = XInternAtom(g_disp, "_XKEY_COMPOSITION", False);
        char atomname[10];
-       Atom cbhm_atoms[HISTORY_QUEUE_MAX_TXT_ITEMS];
+       Atom cbhm_atoms[HISTORY_QUEUE_MAX_ITEMS];
        Ecore_X_Window reqwin = ev->win;
        int i, pos;
 
@@ -539,10 +539,10 @@ static int _xclient_msg_cb(void *data, int ev_type, void *event)
                int num = ev->data.b[5] - '0';
                int cur = get_current_history_position();
                num = cur + num - 1;
-               if (num > HISTORY_QUEUE_MAX_TXT_ITEMS-1)
-                       num = num-HISTORY_QUEUE_MAX_TXT_ITEMS;
+               if (num > HISTORY_QUEUE_MAX_ITEMS-1)
+                       num = num-HISTORY_QUEUE_MAX_ITEMS;
 
-               if (num >= 0 && num < HISTORY_QUEUE_MAX_TXT_ITEMS)
+               if (num >= 0 && num < HISTORY_QUEUE_MAX_ITEMS)
                {
                        DTRACE("## pos : #%d\n", num);
                        // FIXME : handle with correct atom
@@ -575,7 +575,7 @@ static int _xclient_msg_cb(void *data, int ev_type, void *event)
                        }
                        pos--;
                        if (pos < 0)
-                               pos = HISTORY_QUEUE_MAX_TXT_ITEMS-1;
+                               pos = HISTORY_QUEUE_MAX_ITEMS-1;
                }
        }
        else if (strcmp("get raw", ev->data.b) == 0)