summaryrefslogtreecommitdiff
path: root/src/bin/options_font.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-06-18 06:32:56 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-06-18 06:32:56 +0000
commita97e4a87637125d7d7a0eef4b119c7a246282ae3 (patch)
tree72a47f9e494c79a3c09a7d8a2b88d15f43f9a231 /src/bin/options_font.c
parentfa397e90f68a67e38f8df86e4a3e48421d25fe9b (diff)
sorry gustavo -> font preview has gone back to how it was before. it
was bithc-slow on creation and its a shame to waste the spare icon slot. i'll add a new style ot genlist in e17 to have ONLy a start or end icon and then use that. the preview text entry i feel has dubious use... lets discuss, but it doesnt belong in that dialog/pane. SVN revision: 72335
Diffstat (limited to 'src/bin/options_font.c')
-rw-r--r--src/bin/options_font.c127
1 files changed, 72 insertions, 55 deletions
diff --git a/src/bin/options_font.c b/src/bin/options_font.c
index b06d34d..b15a3ed 100644
--- a/src/bin/options_font.c
+++ b/src/bin/options_font.c
@@ -15,7 +15,6 @@ struct _Font
15 Elm_Object_Item *item; 15 Elm_Object_Item *item;
16 const char *name; 16 const char *name;
17 Evas_Object *term; 17 Evas_Object *term;
18 Evas_Object *preview; /* TODO: move preview and term to a parent struct */
19 Eina_Bool bitmap : 1; 18 Eina_Bool bitmap : 1;
20}; 19};
21 20
@@ -35,15 +34,6 @@ _reload_theme(void *data __UNUSED__, Evas_Object *obj,
35} 34}
36 35
37static void 36static void
38_update_preview(void)
39{
40 const Eina_List *l;
41 const Font *f;
42 EINA_LIST_FOREACH(fonts, l, f)
43 elm_genlist_item_update(f->item);
44}
45
46static void
47_update_sizing(Evas_Object *term) 37_update_sizing(Evas_Object *term)
48{ 38{
49 Evas_Coord ow = 0, oh = 0, mw = 1, mh = 1, w, h; 39 Evas_Coord ow = 0, oh = 0, mw = 1, mh = 1, w, h;
@@ -86,7 +76,6 @@ _cb_op_fontsize_sel(void *data, Evas_Object *obj, void *event __UNUSED__)
86 _update_sizing(term); 76 _update_sizing(term);
87 elm_genlist_realized_items_update(op_fontlist); 77 elm_genlist_realized_items_update(op_fontlist);
88 config_save(config, NULL); 78 config_save(config, NULL);
89 _update_preview();
90} 79}
91 80
92static int 81static int
@@ -95,37 +84,84 @@ _cb_op_font_sort(const void *d1, const void *d2)
95 return strcasecmp(d1, d2); 84 return strcasecmp(d1, d2);
96} 85}
97 86
98static Evas_Object * 87static void
99_cb_op_font_content_get(void *data, Evas_Object *obj, const char *part) 88_cb_op_font_preview_del(void *data, Evas *e, Evas_Object *obj, void *event)
100{ 89{
101 Font *f = data;
102 Config *config = termio_config_get(f->term);
103 Evas_Object *o; 90 Evas_Object *o;
104 const char *font, *s = elm_object_text_get(f->preview); 91 o = edje_object_part_swallow_get(obj, "terminology.text.preview");
105 char buf[PATH_MAX]; 92 if (o) evas_object_del(o);
106 93}
107 if (strcmp(part, "elm.swallow.end") != 0) return NULL;
108
109 o = edje_object_add(evas_object_evas_get(obj));
110 edje_object_file_set(o, config_theme_path_get(config),
111 "terminology/fontpreview");
112 edje_object_signal_callback_add(o, "edje,change,file", "edje", _reload_theme, NULL);
113 94
114 if (!f->bitmap) 95static void
115 font = f->name; 96_cb_op_font_preview_eval(void *data, Evas *e, Evas_Object *obj, void *event)
116 else 97{
98 Font *f = data;
99 Evas_Object *o;
100 Evas_Coord ox, oy, ow, oh, vx, vy, vw, vh;
101 Config *config = termio_config_get(f->term);
102 char buf[4096];
103
104 if (!evas_object_visible_get(obj)) return;
105 if (edje_object_part_swallow_get(obj, "terminology.text.preview")) return;
106 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
107 if ((ow < 2) || (oh < 2)) return;
108 evas_output_viewport_get(evas_object_evas_get(obj), &vx, &vy, &vw, &vh);
109 if (ELM_RECTS_INTERSECT(ox, oy, ow, oh, vx, vy, vw, vh))
117 { 110 {
118 snprintf(buf, sizeof(buf), "%s/fonts/%s", 111 o = evas_object_text_add(evas_object_evas_get(obj));
119 elm_app_data_dir_get(), f->name); 112 evas_object_color_set(o, 0, 0, 0, 255);
120 font = buf; 113 if (evas_object_data_get(obj, "_f"))
114 evas_object_text_text_set(o, "Abc");
115 else
116 evas_object_text_text_set(o, "123");
117 if (f->bitmap)
118 {
119 snprintf(buf, sizeof(buf), "%s/fonts/%s",
120 elm_app_data_dir_get(), f->name);
121 evas_object_text_font_set(o, buf, config->font.size);
122 }
123 else
124 evas_object_text_font_set(o, f->name, config->font.size);
125 evas_object_geometry_get(o, NULL, NULL, &ow, &oh);
126 evas_object_size_hint_min_set(o, ow, oh);
127 edje_object_part_swallow(obj, "terminology.text.preview", o);
121 } 128 }
129}
122 130
123 edje_object_text_class_set(o, "terminology.preview",
124 font, config->font.size);
125 edje_object_part_text_set(o, "terminology.text.preview", s);
126 edje_object_update_hints_set(o, EINA_TRUE);
127 131
128 return o; 132static Evas_Object *
133_cb_op_font_content_get(void *data, Evas_Object *obj, const char *part)
134{
135 Font *f = data;
136 if ((!strcmp(part, "elm.swallow.icon")) ||
137 (!strcmp(part, "elm.swallow.end")))
138 {
139 Evas_Object *o;
140 char buf[4096];
141 Config *config = termio_config_get(f->term);
142
143 o = edje_object_add(evas_object_evas_get(obj));
144 snprintf(buf, sizeof(buf), "%s/themes/%s",
145 elm_app_data_dir_get(), config->theme);
146 edje_object_file_set(o, buf, "terminology/fontpreview");
147 edje_object_signal_callback_add(o, "edje,change,file", "edje",
148 _reload_theme, NULL);
149 evas_object_size_hint_min_set(o,
150 40 * elm_config_scale_get(),
151 40 * elm_config_scale_get());
152 evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE,
153 _cb_op_font_preview_eval, f);
154 evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE,
155 _cb_op_font_preview_eval, f);
156 evas_object_event_callback_add(o, EVAS_CALLBACK_SHOW,
157 _cb_op_font_preview_eval, f);
158 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
159 _cb_op_font_preview_del, f);
160 if (!strcmp(part, "elm.swallow.icon"))
161 evas_object_data_set(o, "_f", o);
162 return o;
163 }
164 return NULL;
129} 165}
130 166
131static char * 167static char *
@@ -147,12 +183,6 @@ _cb_op_font_group_text_get(void *data, Evas_Object *obj __UNUSED__, const char *
147 return strdup(data); 183 return strdup(data);
148} 184}
149 185
150static void
151_cb_op_text_changed(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
152{
153 _update_preview();
154}
155
156void 186void
157options_font_clear(void) 187options_font_clear(void)
158{ 188{
@@ -173,7 +203,7 @@ options_font_clear(void)
173void 203void
174options_font(Evas_Object *opbox, Evas_Object *term) 204options_font(Evas_Object *opbox, Evas_Object *term)
175{ 205{
176 Evas_Object *o, *bx, *preview; 206 Evas_Object *o, *bx;
177 char buf[4096], *file, *fname, *s; 207 char buf[4096], *file, *fname, *s;
178 Eina_List *files, *fontlist, *l; 208 Eina_List *files, *fontlist, *l;
179 Font *f; 209 Font *f;
@@ -212,17 +242,6 @@ options_font(Evas_Object *opbox, Evas_Object *term)
212 242
213 elm_box_pack_end(opbox, bx); 243 elm_box_pack_end(opbox, bx);
214 evas_object_show(bx); 244 evas_object_show(bx);
215
216 preview = o = elm_entry_add(opbox);
217 elm_entry_scrollable_set(o, EINA_TRUE);
218 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
219 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
220 elm_entry_scrollbar_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
221 elm_entry_single_line_set(o, EINA_TRUE);
222 elm_object_text_set(o, "Abc-123, O0, l1");
223 evas_object_smart_callback_add(o, "changed,user", _cb_op_text_changed, NULL);
224 elm_box_pack_end(opbox, o);
225 evas_object_show(o);
226 245
227 it_class = elm_genlist_item_class_new(); 246 it_class = elm_genlist_item_class_new();
228 it_class->item_style = "default"; 247 it_class->item_style = "default";
@@ -256,7 +275,6 @@ options_font(Evas_Object *opbox, Evas_Object *term)
256 f = calloc(1, sizeof(Font)); 275 f = calloc(1, sizeof(Font));
257 f->name = eina_stringshare_add(file); 276 f->name = eina_stringshare_add(file);
258 f->term = term; 277 f->term = term;
259 f->preview = preview;
260 f->bitmap = EINA_TRUE; 278 f->bitmap = EINA_TRUE;
261 fonts = eina_list_append(fonts, f); 279 fonts = eina_list_append(fonts, f);
262 280
@@ -296,7 +314,6 @@ options_font(Evas_Object *opbox, Evas_Object *term)
296 f = calloc(1, sizeof(Font)); 314 f = calloc(1, sizeof(Font));
297 f->name = eina_stringshare_add(fname); 315 f->name = eina_stringshare_add(fname);
298 f->term = term; 316 f->term = term;
299 f->preview = preview;
300 f->bitmap = EINA_FALSE; 317 f->bitmap = EINA_FALSE;
301 eina_hash_add(fonthash, fname, f); 318 eina_hash_add(fonthash, fname, f);
302 fonts = eina_list_append(fonts, f); 319 fonts = eina_list_append(fonts, f);