summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2014-09-24 16:24:39 +0100
committerTom Hacohen <tom@stosb.com>2014-09-24 16:24:39 +0100
commit0c6d60e2325d9ed863fff376d14bdd18ccf6a32d (patch)
treee153b1710c2bb39d55e58d95b0c61824d23f0b04
parent7b8cf03c5f170f905a04ea40bf50b3c863af062f (diff)
Correctly handle pages at the end/beginning.
-rw-r--r--data/default.edc9
-rw-r--r--src/bin/main.c25
2 files changed, 28 insertions, 6 deletions
diff --git a/data/default.edc b/data/default.edc
index f8d6741..bcf7894 100644
--- a/data/default.edc
+++ b/data/default.edc
@@ -84,4 +84,13 @@ collections {
84 } 84 }
85 } 85 }
86 } 86 }
87 group { name: "no_next_preview";
88 parts {
89 rect { name: "bg";
90 desc {
91 color: 0 0 0 0;
92 }
93 }
94 }
95 }
87} 96}
diff --git a/src/bin/main.c b/src/bin/main.c
index 129ae0e..57782ed 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -29,6 +29,7 @@ typedef struct _Gifter_Context {
29} Gifter_Context; 29} Gifter_Context;
30 30
31static Gifter_Context ctx; 31static Gifter_Context ctx;
32static char theme_filename[PATH_MAX];
32 33
33static void 34static void
34my_win_del(void *data, Evas_Object *obj, void *event_info) 35my_win_del(void *data, Evas_Object *obj, void *event_info)
@@ -56,8 +57,17 @@ _pdf_page_set_all(int page)
56 for (i = 0 ; i < EINA_C_ARRAY_LENGTH(ctx.main.pdf) ; i++) 57 for (i = 0 ; i < EINA_C_ARRAY_LENGTH(ctx.main.pdf) ; i++)
57 { 58 {
58 int cur_page = page + i - 1; 59 int cur_page = page + i - 1;
59 eo_do(ctx.main.pdf[i], _pdf_page_set(cur_page)); 60
60 eo_do(ctx.preview.pdf[i], _pdf_page_set(cur_page)); 61 if ((cur_page < 0) || (cur_page >= ctx.num_pages))
62 {
63 eo_do(ctx.main.pdf[i], efl_file_set(theme_filename, "no_next_preview"));
64 eo_do(ctx.preview.pdf[i], efl_file_set(theme_filename, "no_next_preview"));
65 }
66 else
67 {
68 eo_do(ctx.main.pdf[i], _pdf_page_set(cur_page));
69 eo_do(ctx.preview.pdf[i], _pdf_page_set(cur_page));
70 }
61 } 71 }
62 72
63 DBG("Set page: %s:%d", ctx.filename, page); 73 DBG("Set page: %s:%d", ctx.filename, page);
@@ -71,8 +81,11 @@ _global_key_down_cb(void *data EINA_UNUSED, Eo *eo_obj EINA_UNUSED, const Eo_Eve
71 if (!strcmp(ev->key, "Right") || 81 if (!strcmp(ev->key, "Right") ||
72 !strcmp(ev->key, "space")) 82 !strcmp(ev->key, "space"))
73 { 83 {
74 ctx.page++; 84 if (ctx.page + 1 < ctx.num_pages)
75 _pdf_page_set_all(ctx.page); 85 {
86 ctx.page++;
87 _pdf_page_set_all(ctx.page);
88 }
76 } 89 }
77 else if (!strcmp(ev->key, "Left")) 90 else if (!strcmp(ev->key, "Left"))
78 { 91 {
@@ -131,7 +144,6 @@ static void
131_create_win(Gifter_Win *win, const char *group_name) 144_create_win(Gifter_Win *win, const char *group_name)
132{ 145{
133 Evas_Object *bg, *dummy_key; 146 Evas_Object *bg, *dummy_key;
134 char theme_filename[PATH_MAX];
135 unsigned int i = 0; 147 unsigned int i = 0;
136 148
137 snprintf(theme_filename, sizeof(theme_filename), "%s/themes/default.edj", elm_app_data_dir_get()); 149 snprintf(theme_filename, sizeof(theme_filename), "%s/themes/default.edj", elm_app_data_dir_get());
@@ -159,7 +171,6 @@ _create_win(Gifter_Win *win, const char *group_name)
159 win->pdf[i] = eo_add(ELM_IMAGE_CLASS, win->layout, 171 win->pdf[i] = eo_add(ELM_IMAGE_CLASS, win->layout,
160 elm_obj_image_smooth_set(EINA_TRUE), 172 elm_obj_image_smooth_set(EINA_TRUE),
161 elm_obj_image_aspect_fixed_set(EINA_TRUE), 173 elm_obj_image_aspect_fixed_set(EINA_TRUE),
162 _pdf_page_set(ctx.page + i - 1),
163 evas_obj_visibility_set(EINA_TRUE)); 174 evas_obj_visibility_set(EINA_TRUE));
164 eo_unref(win->pdf[i]); 175 eo_unref(win->pdf[i]);
165 } 176 }
@@ -258,6 +269,8 @@ main(int argc, char *argv[])
258 h = w / ctx.ratio; 269 h = w / ctx.ratio;
259 } 270 }
260 271
272 _pdf_page_set_all(ctx.page);
273
261 evas_object_resize(ctx.main.win, w, h); 274 evas_object_resize(ctx.main.win, w, h);
262 evas_object_resize(ctx.preview.win, w, h); 275 evas_object_resize(ctx.preview.win, w, h);
263 276