From 417e263be8215e4fb94d9d90ddd60a165fcf84c1 Mon Sep 17 00:00:00 2001 From: Hyoyoung Chang Date: Sat, 23 Oct 2010 14:53:53 +0900 Subject: [PATCH] add restricting img history item to 10 --- CMakeLists.txt | 2 +- debian/control | 2 +- src/cbhm_main.c | 9 +++++++++ src/cbhm_main.h | 2 ++ src/clipdrawer.c | 23 +++++++++++++---------- src/storage.c | 2 +- 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90aabde..5cdec93 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ SET(SRCS src/cbhm_main.c INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED elementary appcore-efl appcore-common x11 ecore-x utilX) +pkg_check_modules(pkgs REQUIRED eina elementary appcore-efl appcore-common x11 ecore-x utilX) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/debian/control b/debian/control index 84b0a92..bc89196 100755 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: cbhm Section: devel Priority: extra Maintainer: Hyoyoung Chang -Build-Depends: debhelper (>= 5), libelm-dev, libappcore-efl-dev, libappcore-common-dev, libx11-dev, libecore-dev, libslp-utilx-dev, x11-xserver-utils-ex +Build-Depends: debhelper (>= 5), libeina-dev, libelm-dev, libappcore-efl-dev, libappcore-common-dev, libx11-dev, libecore-dev, libslp-utilx-dev, x11-xserver-utils-ex Standards-Version: 0.1.1 Package: cbhm diff --git a/src/cbhm_main.c b/src/cbhm_main.c index 2d46be6..d7aebaf 100644 --- a/src/cbhm_main.c +++ b/src/cbhm_main.c @@ -16,6 +16,9 @@ #include "clipdrawer.h" #include "scrcapture.h" +// FIXME: how to remove g_main_ad? +static struct appdata *g_main_ad = NULL; + static Evas_Object* create_win(const char *name); static Evas_Object* load_edj(Evas_Object *parent, const char *file, const char *group); @@ -32,6 +35,11 @@ static void main_quit_cb(void *data, Evas_Object* obj, void* event_info) elm_exit(); } +void* g_get_main_appdata() +{ + return (void*)g_main_ad; +} + int init_appview(void *data) { struct appdata *ad = (struct appdata *) data; @@ -126,6 +134,7 @@ static void fini(struct appdata *ad) static void init_ad(struct appdata *ad) { memset(ad, 0x0, sizeof(struct appdata)); + g_main_ad = ad; } EAPI int elm_main(int argc, char **argv) diff --git a/src/cbhm_main.h b/src/cbhm_main.h index af164e7..a55d114 100755 --- a/src/cbhm_main.h +++ b/src/cbhm_main.h @@ -20,5 +20,7 @@ struct appdata Evas_Object *txtlist; }; +void* g_get_main_appdata(); + #endif /* _cbhm_main_h_ */ diff --git a/src/clipdrawer.c b/src/clipdrawer.c index 7b1daae..315ebb5 100644 --- a/src/clipdrawer.c +++ b/src/clipdrawer.c @@ -17,10 +17,6 @@ static const char *g_images_path[] = { }; #define N_IMAGES (1) -// FIXME: how to remove main_ad? -// it's mainly used at 'clipdrawer_add_image_item' -struct appdata *g_main_ad = NULL; - // gic should live at gengrid callback functions Elm_Gengrid_Item_Class gic; @@ -136,15 +132,24 @@ void grid_del(const void *data, Evas_Object *obj) // it's mainly used at 'clipdrawer_add_image_item' int clipdrawer_add_image_item(char *imagepath) { -// struct appdata *ad = data; + struct appdata *ad = g_get_main_appdata(); gridimgitem_t *newgenimg = NULL; char* filepath = NULL; + Eina_List *igl = NULL; + unsigned int igl_counter = 0; filepath = &imagepath[7]; // skip 'file://' + igl = elm_gengrid_items_get(ad->imggrid); + igl_counter = eina_list_count(igl); + if (igl_counter >= 10) + { + elm_gengrid_item_del(eina_list_nth(igl, 0)); + } + newgenimg = malloc(sizeof(gridimgitem_t)); newgenimg->path = eina_stringshare_add(filepath); - newgenimg->item = elm_gengrid_item_append(g_main_ad->imggrid, &gic, newgenimg, NULL, NULL); - + newgenimg->item = elm_gengrid_item_append(ad->imggrid, &gic, newgenimg, NULL, NULL); + return TRUE; } @@ -163,7 +168,6 @@ clipdrawer_ly_clicked(void *data, Evas_Object *obj, const char *emission, const int clipdrawer_init(void *data) { struct appdata *ad = data; - g_main_ad = ad; evas_object_resize(ad->win_main, CLIPDRAWER_WIDTH, CLIPDRAWER_HEIGHT); evas_object_move(ad->win_main, CLIPDRAWER_POS_X, CLIPDRAWER_POS_Y); @@ -183,7 +187,6 @@ int clipdrawer_init(void *data) evas_object_smart_callback_add(ad->imggrid, "selected", grid_selected, ad); evas_object_size_hint_weight_set(ad->imggrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_gengrid_clear(ad->imggrid); gic.item_style = "default_grid"; @@ -240,7 +243,7 @@ int clipdrawer_create_view(void *data) // for debug // at starting, showing app view -// clipdrawer_activate_view(ad); + //clipdrawer_activate_view(ad); return 0; } diff --git a/src/storage.c b/src/storage.c index 014fb90..deb93df 100644 --- a/src/storage.c +++ b/src/storage.c @@ -1,7 +1,7 @@ #include "common.h" #include "storage.h" -#define STORAGE_FILEPATH "/tmp/.savecbh" +#define STORAGE_FILEPATH "/opt/var/.savecbh" #define STORAGE_MAX_ITEMS HISTORY_QUEUE_NUMBER #define HEADER_ITEM_SIZE (sizeof(int)) #define BODY_ITEM_SIZE (4 * 1024) // 4Kilo -- 2.7.4