summaryrefslogtreecommitdiff
path: root/src/bin/options_font.c
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2018-01-12 23:27:19 +0100
committerBoris Faure <billiob@gmail.com>2018-01-12 23:27:19 +0100
commit85ba7447715b9c00108ab252471ee1263b2f6715 (patch)
treec3b069faaa2014297d74ee794da49d1c62cc813f /src/bin/options_font.c
parent32209a6dfdebd7ea27e411f1e43a0109ad5e58a6 (diff)
options_font: be able to have multiple instances
Diffstat (limited to 'src/bin/options_font.c')
-rw-r--r--src/bin/options_font.c232
1 files changed, 131 insertions, 101 deletions
diff --git a/src/bin/options_font.c b/src/bin/options_font.c
index f856c71..b329b8d 100644
--- a/src/bin/options_font.c
+++ b/src/bin/options_font.c
@@ -1,6 +1,7 @@
1#include "private.h" 1#include "private.h"
2 2
3#include <Elementary.h> 3#include <Elementary.h>
4#include <assert.h>
4#include "config.h" 5#include "config.h"
5#include "termio.h" 6#include "termio.h"
6#include "options.h" 7#include "options.h"
@@ -12,37 +13,47 @@
12#define FONT_MAX 45 13#define FONT_MAX 45
13#define FONT_STEP (1.0 / (FONT_MAX - FONT_MIN)) 14#define FONT_STEP (1.0 / (FONT_MAX - FONT_MIN))
14 15
15static Evas_Object *op_fontslider, *op_fontlist, *op_fsml, *op_fbig;
16 16
17typedef struct _Font Font; 17typedef struct _Font_Ctx
18{
19 Evas_Object *op_fontslider;
20 Evas_Object *op_fontlist;
21 Evas_Object *op_fsml;
22 Evas_Object *op_fbig;
23 Evas_Object *term;
24 Eina_List *fonts;
25 Eina_Hash *fonthash;
26 Config *config;
27 Evas_Coord tsize_w;
28 Evas_Coord tsize_h;
29 int expecting_resize;
30} Font_Ctx;
18 31
19struct _Font 32typedef struct _Font
20{ 33{
21 Elm_Object_Item *item; 34 Elm_Object_Item *item;
22 const char *pretty_name; 35 const char *pretty_name;
23 const char *full_name; 36 const char *full_name;
24 Evas_Object *term; 37 Font_Ctx *ctx;
25 unsigned char bitmap : 1; 38 unsigned char bitmap : 1;
26}; 39} Font;
27 40
28static Eina_List *fonts = NULL;
29static Eina_Hash *fonthash = NULL;
30static Evas_Coord tsize_w = 0, tsize_h = 0;
31static int expecting_resize = 0;
32 41
33static void 42static void
34_update_sizing(Evas_Object *term) 43_update_sizing(Font_Ctx *ctx)
35{ 44{
36 Evas_Coord mw = 1, mh = 1, w, h; 45 Evas_Coord mw = 1, mh = 1, w, h;
37 46
38 termio_config_update(term); 47 termio_config_update(ctx->term);
39 evas_object_size_hint_min_get(term, &mw, &mh); 48 evas_object_size_hint_min_get(ctx->term, &mw, &mh);
40 if (mw < 1) mw = 1; 49 if (mw < 1)
41 if (mh < 1) mh = 1; 50 mw = 1;
42 w = tsize_w / mw; 51 if (mh < 1)
43 h = tsize_h / mh; 52 mh = 1;
44 evas_object_size_hint_request_set(term, w * mw, h * mh); 53 w = ctx->tsize_w / mw;
45 expecting_resize = 1; 54 h = ctx->tsize_h / mh;
55 evas_object_size_hint_request_set(ctx->term, w * mw, h * mh);
56 ctx->expecting_resize = 1;
46} 57}
47 58
48static int 59static int
@@ -133,18 +144,19 @@ _cb_op_font_sel(void *data,
133 void *_event EINA_UNUSED) 144 void *_event EINA_UNUSED)
134{ 145{
135 Font *f = data; 146 Font *f = data;
136 Config *config = termio_config_get(f->term); 147 Font_Ctx *ctx = f->ctx;
137 Term *term = termio_term_get(f->term); 148 Config *config = ctx->config;
149 Term *term = termio_term_get(ctx->term);
138 150
139 if ((config->font.name) && (!strcmp(f->full_name, config->font.name))) 151 if ((config->font.name) && (!strcmp(f->full_name, config->font.name)))
140 return; 152 return;
141 if (config->font.name) eina_stringshare_del(config->font.name); 153 if (config->font.name) eina_stringshare_del(config->font.name);
142 config->font.name = eina_stringshare_add(f->full_name); 154 config->font.name = eina_stringshare_add(f->full_name);
143 config->font.bitmap = f->bitmap; 155 config->font.bitmap = f->bitmap;
144 _update_sizing(f->term); 156 _update_sizing(ctx);
145 elm_object_disabled_set(op_fsml, f->bitmap); 157 elm_object_disabled_set(ctx->op_fsml, f->bitmap);
146 elm_object_disabled_set(op_fontslider, f->bitmap); 158 elm_object_disabled_set(ctx->op_fontslider, f->bitmap);
147 elm_object_disabled_set(op_fbig, f->bitmap); 159 elm_object_disabled_set(ctx->op_fbig, f->bitmap);
148 config_save(config, NULL); 160 config_save(config, NULL);
149 win_font_update(term); 161 win_font_update(term);
150} 162}
@@ -154,15 +166,16 @@ _cb_op_fontsize_sel(void *data,
154 Evas_Object *obj, 166 Evas_Object *obj,
155 void *_event EINA_UNUSED) 167 void *_event EINA_UNUSED)
156{ 168{
157 Evas_Object *termio_obj = data; 169 Font_Ctx *ctx = data;
158 Config *config = termio_config_get(termio_obj); 170 Config *config = ctx->config;
159 Term *term = termio_term_get(termio_obj); 171 Term *term = termio_term_get(ctx->term);
160 int size = elm_slider_value_get(obj) + 0.5; 172 int size = elm_slider_value_get(obj) + 0.5;
161 173
162 if (config->font.size == size) return; 174 if (config->font.size == size)
175 return;
163 config->font.size = size; 176 config->font.size = size;
164 _update_sizing(termio_obj); 177 _update_sizing(ctx);
165 elm_genlist_realized_items_update(op_fontlist); 178 elm_genlist_realized_items_update(ctx->op_fontlist);
166 config_save(config, NULL); 179 config_save(config, NULL);
167 win_font_update(term); 180 win_font_update(term);
168} 181}
@@ -181,7 +194,7 @@ _cb_op_font_preview_del(void *_data EINA_UNUSED,
181{ 194{
182 Evas_Object *o; 195 Evas_Object *o;
183 Ecore_Timer *timer = evas_object_data_get(obj, "delay"); 196 Ecore_Timer *timer = evas_object_data_get(obj, "delay");
184 197
185 if (timer) 198 if (timer)
186 { 199 {
187 ecore_timer_del(timer); 200 ecore_timer_del(timer);
@@ -203,22 +216,27 @@ _cb_op_font_preview_delayed_eval(void *data)
203 Evas_Object *o; 216 Evas_Object *o;
204 Evas_Coord ox, oy, ow, oh, vx, vy, vw, vh; 217 Evas_Coord ox, oy, ow, oh, vx, vy, vw, vh;
205 Config *config; 218 Config *config;
206 219
207 if (!evas_object_visible_get(obj)) goto done; 220 if (!evas_object_visible_get(obj))
208 if (edje_object_part_swallow_get(obj, "terminology.text.preview")) goto done; 221 goto done;
222 if (edje_object_part_swallow_get(obj, "terminology.text.preview"))
223 goto done;
209 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh); 224 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
210 if ((ow < 2) || (oh < 2)) goto done; 225 if ((ow < 2) || (oh < 2))
226 goto done;
211 evas_output_viewport_get(evas_object_evas_get(obj), &vx, &vy, &vw, &vh); 227 evas_output_viewport_get(evas_object_evas_get(obj), &vx, &vy, &vw, &vh);
212 f = evas_object_data_get(obj, "font"); 228 f = evas_object_data_get(obj, "font");
213 if (!f) goto done; 229 if (!f)
214 config = termio_config_get(f->term); 230 goto done;
215 if (!config) goto done; 231 config = f->ctx->config;
232 if (!config)
233 goto done;
216 if (ELM_RECTS_INTERSECT(ox, oy, ow, oh, vx, vy, vw, vh)) 234 if (ELM_RECTS_INTERSECT(ox, oy, ow, oh, vx, vy, vw, vh))
217 { 235 {
218 char buf[4096]; 236 char buf[4096];
219 int r, g, b, a; 237 int r, g, b, a;
220 Evas *evas = evas_object_evas_get(obj); 238 Evas *evas = evas_object_evas_get(obj);
221 Evas_Object *textgrid = termio_textgrid_get(f->term); 239 Evas_Object *textgrid = termio_textgrid_get(f->ctx->term);
222 240
223 evas_object_textgrid_palette_get(textgrid, EVAS_TEXTGRID_PALETTE_STANDARD, 241 evas_object_textgrid_palette_get(textgrid, EVAS_TEXTGRID_PALETTE_STANDARD,
224 0, &r, &g, &b, &a); 242 0, &r, &g, &b, &a);
@@ -252,11 +270,14 @@ _cb_op_font_preview_eval(void *data,
252{ 270{
253 Font *f = data; 271 Font *f = data;
254 Evas_Coord ox, oy, ow, oh, vx, vy, vw, vh; 272 Evas_Coord ox, oy, ow, oh, vx, vy, vw, vh;
255 273
256 if (!evas_object_visible_get(obj)) return; 274 if (!evas_object_visible_get(obj))
257 if (edje_object_part_swallow_get(obj, "terminology.text.preview")) return; 275 return;
276 if (edje_object_part_swallow_get(obj, "terminology.text.preview"))
277 return;
258 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh); 278 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
259 if ((ow < 2) || (oh < 2)) return; 279 if ((ow < 2) || (oh < 2))
280 return;
260 evas_output_viewport_get(evas_object_evas_get(obj), &vx, &vy, &vw, &vh); 281 evas_output_viewport_get(evas_object_evas_get(obj), &vx, &vy, &vw, &vh);
261 if (ELM_RECTS_INTERSECT(ox, oy, ow, oh, vx, vy, vw, vh)) 282 if (ELM_RECTS_INTERSECT(ox, oy, ow, oh, vx, vy, vw, vh))
262 { 283 {
@@ -264,8 +285,10 @@ _cb_op_font_preview_eval(void *data,
264 double rnd = 0.2; 285 double rnd = 0.2;
265 286
266 timer = evas_object_data_get(obj, "delay"); 287 timer = evas_object_data_get(obj, "delay");
267 if (timer) return; 288 if (timer)
268 else evas_object_data_set(obj, "font", f); 289 return;
290 else
291 evas_object_data_set(obj, "font", f);
269 rnd += (double)(rand() % 100) / 500.0; 292 rnd += (double)(rand() % 100) / 500.0;
270 timer = ecore_timer_add(rnd, _cb_op_font_preview_delayed_eval, obj); 293 timer = ecore_timer_add(rnd, _cb_op_font_preview_delayed_eval, obj);
271 evas_object_data_set(obj, "delay", timer); 294 evas_object_data_set(obj, "delay", timer);
@@ -280,8 +303,8 @@ _cb_op_font_content_get(void *data, Evas_Object *obj, const char *part)
280 if (!strcmp(part, "elm.swallow.icon")) 303 if (!strcmp(part, "elm.swallow.icon"))
281 { 304 {
282 Evas_Object *o; 305 Evas_Object *o;
283 Config *config = termio_config_get(f->term); 306 Config *config = f->ctx->config;
284 307
285 o = edje_object_add(evas_object_evas_get(obj)); 308 o = edje_object_add(evas_object_evas_get(obj));
286 theme_apply(o, config, "terminology/fontpreview"); 309 theme_apply(o, config, "terminology/fontpreview");
287 theme_auto_reload_enable(o); 310 theme_auto_reload_enable(o);
@@ -324,13 +347,14 @@ _cb_term_resize(void *data,
324 Evas_Object *_obj EINA_UNUSED, 347 Evas_Object *_obj EINA_UNUSED,
325 void *_event EINA_UNUSED) 348 void *_event EINA_UNUSED)
326{ 349{
327 Evas_Object *term = data; 350 Font_Ctx *ctx = data;
328 if (expecting_resize) 351
352 if (ctx->expecting_resize)
329 { 353 {
330 expecting_resize = 0; 354 ctx->expecting_resize = 0;
331 return; 355 return;
332 } 356 }
333 evas_object_geometry_get(term, NULL, NULL, &tsize_w, &tsize_h); 357 evas_object_geometry_get(ctx->term, NULL, NULL, &ctx->tsize_w, &ctx->tsize_h);
334} 358}
335 359
336static void 360static void
@@ -339,32 +363,29 @@ _cb_font_del(void *data,
339 Evas_Object *_obj EINA_UNUSED, 363 Evas_Object *_obj EINA_UNUSED,
340 void *_event EINA_UNUSED) 364 void *_event EINA_UNUSED)
341{ 365{
342 Evas_Object *term = data; 366 Font_Ctx *ctx = data;
343 evas_object_event_callback_del_full(term, EVAS_CALLBACK_RESIZE, 367 evas_object_event_callback_del_full(ctx->term, EVAS_CALLBACK_RESIZE,
344 _cb_term_resize, term); 368 _cb_term_resize, ctx);
345} 369}
346 370
347void 371static void
348options_font_clear(void) 372_parent_del_cb(void *data,
373 Evas *_e EINA_UNUSED,
374 Evas_Object *_obj EINA_UNUSED,
375 void *_event_info EINA_UNUSED)
349{ 376{
377 Font_Ctx *ctx = data;
350 Font *f; 378 Font *f;
351 379
352 op_fontslider = NULL; 380 EINA_LIST_FREE(ctx->fonts, f)
353 op_fontlist = NULL;
354 op_fsml = NULL;
355 op_fbig = NULL;
356
357 EINA_LIST_FREE(fonts, f)
358 { 381 {
359 eina_stringshare_del(f->full_name); 382 eina_stringshare_del(f->full_name);
360 eina_stringshare_del(f->pretty_name); 383 eina_stringshare_del(f->pretty_name);
361 free(f); 384 free(f);
362 } 385 }
363 if (fonthash) 386 eina_hash_free(ctx->fonthash);
364 { 387
365 eina_hash_free(fonthash); 388 free(ctx);
366 fonthash = NULL;
367 }
368} 389}
369 390
370static void 391static void
@@ -372,11 +393,11 @@ _cb_font_bolditalic(void *data,
372 Evas_Object *obj, 393 Evas_Object *obj,
373 void *_event EINA_UNUSED) 394 void *_event EINA_UNUSED)
374{ 395{
375 Evas_Object *term = data; 396 Font_Ctx *ctx = data;
376 Config *config = termio_config_get(term); 397 Config *config = ctx->config;
377 398
378 config->font.bolditalic = elm_check_state_get(obj); 399 config->font.bolditalic = elm_check_state_get(obj);
379 termio_config_update(term); 400 termio_config_update(ctx->term);
380 config_save(config, NULL); 401 config_save(config, NULL);
381} 402}
382 403
@@ -390,33 +411,41 @@ options_font(Evas_Object *opbox, Evas_Object *term)
390 Elm_Object_Item *it, *sel_it = NULL, *sel_it2 = NULL, *grp_it = NULL; 411 Elm_Object_Item *it, *sel_it = NULL, *sel_it2 = NULL, *grp_it = NULL;
391 Elm_Genlist_Item_Class *it_class, *it_group; 412 Elm_Genlist_Item_Class *it_class, *it_group;
392 Config *config = termio_config_get(term); 413 Config *config = termio_config_get(term);
414 Font_Ctx *ctx;
415
416 ctx = calloc(1, sizeof(*ctx));
417 assert(ctx);
418
419 ctx->config = config;
420 ctx->term = term;
393 421
394 options_font_clear();
395
396 fr = o = elm_frame_add(opbox); 422 fr = o = elm_frame_add(opbox);
397 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 423 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
398 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); 424 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
399 elm_object_text_set(o, _("Font")); 425 elm_object_text_set(o, _("Font"));
400 elm_box_pack_end(opbox, o); 426 elm_box_pack_end(opbox, o);
401 evas_object_show(o); 427 evas_object_show(o);
402 428
429 evas_object_event_callback_add(fr, EVAS_CALLBACK_DEL,
430 _parent_del_cb, ctx);
431
403 bx0 = o = elm_box_add(opbox); 432 bx0 = o = elm_box_add(opbox);
404 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 433 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
405 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); 434 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
406 elm_object_content_set(fr, o); 435 elm_object_content_set(fr, o);
407 evas_object_show(o); 436 evas_object_show(o);
408 437
409 bx = o = elm_box_add(opbox); 438 bx = o = elm_box_add(opbox);
410 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0); 439 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
411 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5); 440 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5);
412 elm_box_horizontal_set(o, EINA_TRUE); 441 elm_box_horizontal_set(o, EINA_TRUE);
413 442
414 op_fsml = o = elm_label_add(opbox); 443 ctx->op_fsml = o = elm_label_add(opbox);
415 elm_object_text_set(o, "<font_size=6>A</font_size>"); 444 elm_object_text_set(o, "<font_size=6>A</font_size>");
416 elm_box_pack_end(bx, o); 445 elm_box_pack_end(bx, o);
417 evas_object_show(o); 446 evas_object_show(o);
418 447
419 op_fontslider = o = elm_slider_add(opbox); 448 ctx->op_fontslider = o = elm_slider_add(opbox);
420 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0); 449 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
421 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5); 450 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
422 elm_slider_span_size_set(o, 40); 451 elm_slider_span_size_set(o, 40);
@@ -429,28 +458,28 @@ options_font(Evas_Object *opbox, Evas_Object *term)
429 elm_slider_value_set(o, config->font.size); 458 elm_slider_value_set(o, config->font.size);
430 elm_box_pack_end(bx, o); 459 elm_box_pack_end(bx, o);
431 evas_object_show(o); 460 evas_object_show(o);
432 461
433 evas_object_smart_callback_add(o, "delay,changed", 462 evas_object_smart_callback_add(o, "delay,changed",
434 _cb_op_fontsize_sel, term); 463 _cb_op_fontsize_sel, ctx);
435 464
436 op_fbig = o = elm_label_add(opbox); 465 ctx->op_fbig = o = elm_label_add(opbox);
437 elm_object_text_set(o, "<font_size=24>A</font_size>"); 466 elm_object_text_set(o, "<font_size=24>A</font_size>");
438 elm_box_pack_end(bx, o); 467 elm_box_pack_end(bx, o);
439 evas_object_show(o); 468 evas_object_show(o);
440 469
441 elm_box_pack_end(bx0, bx); 470 elm_box_pack_end(bx0, bx);
442 evas_object_show(bx); 471 evas_object_show(bx);
443 472
444 it_class = elm_genlist_item_class_new(); 473 it_class = elm_genlist_item_class_new();
445 it_class->item_style = "end_icon"; 474 it_class->item_style = "end_icon";
446 it_class->func.text_get = _cb_op_font_text_get; 475 it_class->func.text_get = _cb_op_font_text_get;
447 it_class->func.content_get = _cb_op_font_content_get; 476 it_class->func.content_get = _cb_op_font_content_get;
448 477
449 it_group = elm_genlist_item_class_new(); 478 it_group = elm_genlist_item_class_new();
450 it_group->item_style = "group_index"; 479 it_group->item_style = "group_index";
451 it_group->func.text_get = _cb_op_font_group_text_get; 480 it_group->func.text_get = _cb_op_font_group_text_get;
452 481
453 op_fontlist = o = elm_genlist_add(opbox); 482 ctx->op_fontlist = o = elm_genlist_add(opbox);
454 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 483 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
455 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); 484 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
456 elm_genlist_mode_set(o, ELM_LIST_COMPRESS); 485 elm_genlist_mode_set(o, ELM_LIST_COMPRESS);
@@ -476,9 +505,9 @@ options_font(Evas_Object *opbox, Evas_Object *term)
476 s = strchr(file, '.'); 505 s = strchr(file, '.');
477 if (s != NULL) *s = '\0'; 506 if (s != NULL) *s = '\0';
478 f->pretty_name = eina_stringshare_add(file); 507 f->pretty_name = eina_stringshare_add(file);
479 f->term = term; 508 f->ctx = ctx;
480 f->bitmap = EINA_TRUE; 509 f->bitmap = EINA_TRUE;
481 fonts = eina_list_append(fonts, f); 510 ctx->fonts = eina_list_append(ctx->fonts, f);
482 511
483 f->item = it = elm_genlist_item_append(o, it_class, f, grp_it, 512 f->item = it = elm_genlist_item_append(o, it_class, f, grp_it,
484 ELM_GENLIST_ITEM_NONE, 513 ELM_GENLIST_ITEM_NONE,
@@ -488,9 +517,9 @@ options_font(Evas_Object *opbox, Evas_Object *term)
488 (!strcmp(config->font.name, file)))) 517 (!strcmp(config->font.name, file))))
489 { 518 {
490 sel_it = it; 519 sel_it = it;
491 elm_object_disabled_set(op_fsml, EINA_TRUE); 520 elm_object_disabled_set(ctx->op_fsml, EINA_TRUE);
492 elm_object_disabled_set(op_fontslider, EINA_TRUE); 521 elm_object_disabled_set(ctx->op_fontslider, EINA_TRUE);
493 elm_object_disabled_set(op_fbig, EINA_TRUE); 522 elm_object_disabled_set(ctx->op_fbig, EINA_TRUE);
494 } 523 }
495 free(file); 524 free(file);
496 } 525 }
@@ -499,8 +528,8 @@ options_font(Evas_Object *opbox, Evas_Object *term)
499 fontlist = evas_font_available_list(evas_object_evas_get(opbox)); 528 fontlist = evas_font_available_list(evas_object_evas_get(opbox));
500 fontlist = eina_list_sort(fontlist, eina_list_count(fontlist), 529 fontlist = eina_list_sort(fontlist, eina_list_count(fontlist),
501 _cb_op_font_sort); 530 _cb_op_font_sort);
502 fonthash = eina_hash_string_superfast_new(NULL); 531 ctx->fonthash = eina_hash_string_superfast_new(NULL);
503 if (fonts) 532 if (ctx->fonts)
504 { 533 {
505 grp_it = elm_genlist_item_append(o, it_group, _("Standard"), NULL, 534 grp_it = elm_genlist_item_append(o, it_group, _("Standard"), NULL,
506 ELM_GENLIST_ITEM_GROUP, 535 ELM_GENLIST_ITEM_GROUP,
@@ -510,19 +539,20 @@ options_font(Evas_Object *opbox, Evas_Object *term)
510 } 539 }
511 EINA_LIST_FOREACH(fontlist, l, fname) 540 EINA_LIST_FOREACH(fontlist, l, fname)
512 { 541 {
513 if (!eina_hash_find(fonthash, fname)) 542 if (!eina_hash_find(ctx->fonthash, fname))
514 { 543 {
515 f = calloc(1, sizeof(Font)); 544 f = calloc(1, sizeof(Font));
516 if (!f) break; 545 if (!f)
546 break;
517 if (_parse_font_name(fname, &f->full_name, &f->pretty_name) <0) 547 if (_parse_font_name(fname, &f->full_name, &f->pretty_name) <0)
518 { 548 {
519 free(f); 549 free(f);
520 continue; 550 continue;
521 } 551 }
522 f->term = term; 552 f->ctx = ctx;
523 f->bitmap = EINA_FALSE; 553 f->bitmap = EINA_FALSE;
524 eina_hash_add(fonthash, eina_stringshare_add(fname), f); 554 eina_hash_add(ctx->fonthash, eina_stringshare_add(fname), f);
525 fonts = eina_list_append(fonts, f); 555 ctx->fonts = eina_list_append(ctx->fonts, f);
526 f->item = it = elm_genlist_item_append(o, it_class, f, grp_it, 556 f->item = it = elm_genlist_item_append(o, it_class, f, grp_it,
527 ELM_GENLIST_ITEM_NONE, 557 ELM_GENLIST_ITEM_NONE,
528 _cb_op_font_sel, f); 558 _cb_op_font_sel, f);
@@ -568,12 +598,12 @@ options_font(Evas_Object *opbox, Evas_Object *term)
568 elm_box_pack_end(bx0, o); 598 elm_box_pack_end(bx0, o);
569 evas_object_show(o); 599 evas_object_show(o);
570 evas_object_smart_callback_add(o, "changed", 600 evas_object_smart_callback_add(o, "changed",
571 _cb_font_bolditalic, term); 601 _cb_font_bolditalic, ctx);
572 602
573 expecting_resize = 0; 603 ctx->expecting_resize = 0;
574 evas_object_geometry_get(term, NULL, NULL, &tsize_w, &tsize_h); 604 evas_object_geometry_get(term, NULL, NULL, &ctx->tsize_w, &ctx->tsize_h);
575 evas_object_event_callback_add(term, EVAS_CALLBACK_RESIZE, 605 evas_object_event_callback_add(term, EVAS_CALLBACK_RESIZE,
576 _cb_term_resize, term); 606 _cb_term_resize, ctx);
577 evas_object_event_callback_add(opbox, EVAS_CALLBACK_DEL, 607 evas_object_event_callback_add(opbox, EVAS_CALLBACK_DEL,
578 _cb_font_del, term); 608 _cb_font_del, ctx);
579} 609}