aboutsummaryrefslogtreecommitdiffstats
path: root/legacy/elementary/src/bin/test_gengrid.c
diff options
context:
space:
mode:
authorRafael Fonseca <rfonseca@profusion.mobi>2010-10-10 21:05:23 +0000
committerRafael Fonseca <rfonseca@profusion.mobi>2010-10-10 21:05:23 +0000
commit0090ce210c360bcd78bcc30ffd785c55183d5662 (patch)
tree8f9a493c09dcb10ab199c042ec585ec1259c6dc0 /legacy/elementary/src/bin/test_gengrid.c
parentDon't change no_select state when adding item to Gengrid. (diff)
downloadefl-0090ce210c360bcd78bcc30ffd785c55183d5662.tar.gz
Add more insertion types to Gengrid.
Gengrid now has modes append, prepend, insert_before and insert_after. To see them working check the Gengrid 2 test on elementary_test. SVN revision: 53242
Diffstat (limited to 'legacy/elementary/src/bin/test_gengrid.c')
-rw-r--r--legacy/elementary/src/bin/test_gengrid.c156
1 files changed, 144 insertions, 12 deletions
diff --git a/legacy/elementary/src/bin/test_gengrid.c b/legacy/elementary/src/bin/test_gengrid.c
index 90c6a172f7..5bd1ed8f98 100644
--- a/legacy/elementary/src/bin/test_gengrid.c
+++ b/legacy/elementary/src/bin/test_gengrid.c
@@ -8,6 +8,19 @@ typedef struct _Testitem
int onoff;
} Testitem;
+static const char *img[9] =
+{
+ "panel_01.jpg",
+ "plant_01.jpg",
+ "rock_01.jpg",
+ "rock_02.jpg",
+ "sky_01.jpg",
+ "sky_02.jpg",
+ "sky_03.jpg",
+ "sky_04.jpg",
+ "wood_01.jpg",
+};
+
static Elm_Gengrid_Item_Class gic;
static void
@@ -125,18 +138,6 @@ test_gengrid(void *data, Evas_Object *obj, void *event_info)
static Testitem ti[144];
int i, n;
char buf[PATH_MAX];
- const char *img[9] =
- {
- "panel_01.jpg",
- "plant_01.jpg",
- "rock_01.jpg",
- "rock_02.jpg",
- "sky_01.jpg",
- "sky_02.jpg",
- "sky_03.jpg",
- "sky_04.jpg",
- "wood_01.jpg",
- };
win = elm_win_add(NULL, "grid", ELM_WIN_BASIC);
elm_win_title_set(win, "Grid");
@@ -185,4 +186,135 @@ test_gengrid(void *data, Evas_Object *obj, void *event_info)
evas_object_resize(win, 600, 600);
evas_object_show(win);
}
+
+static void
+_before_bt_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ Testitem *ti;
+ Evas_Object *grid = data;
+ Elm_Gengrid_Item *sel;
+ char buf[PATH_MAX];
+
+ sel = elm_gengrid_selected_item_get(grid);
+ snprintf(buf, sizeof(buf), "%s/images/%s", PACKAGE_DATA_DIR, img[rand() % 9]);
+ ti = malloc(sizeof(*ti));
+ ti->mode = 0;
+ ti->path = eina_stringshare_add(buf);
+ ti->item = elm_gengrid_item_insert_before(grid, &gic, ti, sel, grid_sel,
+ NULL);
+}
+
+static void
+_after_bt_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ Testitem *ti;
+ Evas_Object *grid = data;
+ Elm_Gengrid_Item *sel;
+ char buf[PATH_MAX];
+
+ sel = elm_gengrid_selected_item_get(grid);
+ snprintf(buf, sizeof(buf), "%s/images/%s", PACKAGE_DATA_DIR, img[rand() % 9]);
+ ti = malloc(sizeof(*ti));
+ ti->mode = 0;
+ ti->path = eina_stringshare_add(buf);
+ ti->item = elm_gengrid_item_insert_after(grid, &gic, ti, sel, grid_sel,
+ NULL);
+}
+
+static void
+_prepend_bt_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ Testitem *ti;
+ Evas_Object *grid = data;
+ char buf[PATH_MAX];
+
+ snprintf(buf, sizeof(buf), "%s/images/%s", PACKAGE_DATA_DIR, img[rand() % 9]);
+ ti = malloc(sizeof(*ti));
+ ti->mode = 0;
+ ti->path = eina_stringshare_add(buf);
+ ti->item = elm_gengrid_item_prepend(grid, &gic, ti, grid_sel, NULL);
+}
+
+static void
+_append_bt_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ Testitem *ti;
+ Evas_Object *grid = data;
+ char buf[PATH_MAX];
+
+ snprintf(buf, sizeof(buf), "%s/images/%s", PACKAGE_DATA_DIR, img[rand() % 9]);
+ ti = malloc(sizeof(*ti));
+ ti->mode = 0;
+ ti->path = eina_stringshare_add(buf);
+ ti->item = elm_gengrid_item_append(grid, &gic, ti, grid_sel, NULL);
+}
+
+void
+test_gengrid2(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *win, *bg, *grid, *bx, *hbx, *bt;
+
+ win = elm_win_add(NULL, "grid2", ELM_WIN_BASIC);
+ elm_win_title_set(win, "Grid2");
+ elm_win_autodel_set(win, 1);
+
+ bg = elm_bg_add(win);
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bg);
+ evas_object_show(bg);
+
+ bx = elm_box_add(win);
+ evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bx);
+ evas_object_show(bx);
+
+ grid = elm_gengrid_add(win);
+ elm_gengrid_item_size_set(grid, 150, 150);
+ elm_gengrid_horizontal_set(grid, EINA_FALSE);
+ elm_gengrid_multi_select_set(grid, EINA_FALSE);
+ evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
+ evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_min_set(grid, 600, 500);
+ elm_box_pack_end(bx, grid);
+ evas_object_show(grid);
+
+ hbx = elm_box_add(win);
+ evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_box_horizontal_set(hbx, EINA_TRUE);
+ elm_box_pack_end(bx, hbx);
+ evas_object_show(hbx);
+
+ bt = elm_button_add(win);
+ elm_button_label_set(bt, "Append");
+ evas_object_smart_callback_add(bt, "clicked", _append_bt_clicked, grid);
+ elm_box_pack_end(hbx, bt);
+ evas_object_show(bt);
+
+ bt = elm_button_add(win);
+ elm_button_label_set(bt, "Prepend");
+ evas_object_smart_callback_add(bt, "clicked", _prepend_bt_clicked, grid);
+ elm_box_pack_end(hbx, bt);
+ evas_object_show(bt);
+
+ bt = elm_button_add(win);
+ elm_button_label_set(bt, "Insert before");
+ evas_object_smart_callback_add(bt, "clicked", _before_bt_clicked, grid);
+ elm_box_pack_end(hbx, bt);
+ evas_object_show(bt);
+
+ bt = elm_button_add(win);
+ elm_button_label_set(bt, "Insert after");
+ evas_object_smart_callback_add(bt, "clicked", _after_bt_clicked, grid);
+ elm_box_pack_end(hbx, bt);
+ evas_object_show(bt);
+
+ gic.item_style = "default";
+ gic.func.label_get = grid_label_get;
+ gic.func.icon_get = grid_icon_get;
+ gic.func.state_get = grid_state_get;
+ gic.func.del = grid_del;
+
+ evas_object_resize(win, 600, 600);
+ evas_object_show(win);
+}
#endif