summaryrefslogtreecommitdiff
path: root/src/bin/win.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/win.c')
-rw-r--r--src/bin/win.c144
1 files changed, 144 insertions, 0 deletions
diff --git a/src/bin/win.c b/src/bin/win.c
index c4c8be9..3ad2080 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -199,6 +199,150 @@ static void _term_tabregion_free(Term *term);
199static void _set_trans(Config *config, Evas_Object *bg, Evas_Object *base); 199static void _set_trans(Config *config, Evas_Object *bg, Evas_Object *base);
200static void _imf_event_commit_cb(void *data, Ecore_IMF_Context *_ctx EINA_UNUSED, void *event); 200static void _imf_event_commit_cb(void *data, Ecore_IMF_Context *_ctx EINA_UNUSED, void *event);
201 201
202static void
203_scale_round(void *data EINA_UNUSED,
204 Evas_Object *obj,
205 void *event_info EINA_UNUSED)
206{
207 double val = elm_slider_value_get(obj);
208 double v;
209
210 v = ((double)((int)(val * 10.0))) / 10.0;
211 if (v != val) elm_slider_value_set(obj, v);
212}
213
214static void
215_scale_change(void *data EINA_UNUSED,
216 Evas_Object *obj,
217 void *event_info EINA_UNUSED)
218{
219 double scale = elm_config_scale_get();
220 double val = elm_slider_value_get(obj);
221
222 if (scale == val)
223 return;
224 elm_config_scale_set(val);
225 elm_config_all_flush();
226}
227
228typedef struct _Scale_Ctx
229{
230 Evas_Object *hv;
231 Term *term;
232} Scale_Ctx;
233
234static void
235_scale_done(void *data,
236 Evas_Object *obj EINA_UNUSED,
237 void *event_info EINA_UNUSED)
238{
239 Scale_Ctx *ctx = data;
240
241 evas_object_smart_callback_del_full(ctx->hv, "dismissed",
242 _scale_done, ctx);
243 evas_object_del(ctx->hv);
244 ctx->term->wn->on_popover--;
245 term_unref(ctx->term);
246 elm_config_save();
247 config_save(ctx->term->config, NULL);
248 free(ctx);
249}
250
251void
252win_scale_wizard(Evas_Object *win, Term *term)
253{
254 Evas_Object *bx, *lbl, *sl, *fr, *bt;
255 const char *txt;
256 Scale_Ctx *ctx;
257
258 EINA_SAFETY_ON_NULL_RETURN(term);
259 if (!utils_need_scale_wizard())
260 return;
261
262 ctx = calloc(1, sizeof(*ctx));
263 if (!ctx)
264 return;
265
266 ctx->term = term;
267
268 term->wn->on_popover++;
269
270 term_ref(term);
271
272 ctx->hv = elm_hover_add(win);
273 evas_object_size_hint_weight_set(ctx->hv, EVAS_HINT_EXPAND, 0.0);
274 evas_object_size_hint_align_set(ctx->hv, EVAS_HINT_FILL, 0.5);
275 elm_hover_parent_set(ctx->hv, win);
276 elm_hover_target_set(ctx->hv, win);
277 evas_object_smart_callback_add(ctx->hv, "dismissed", _scale_done, ctx);
278
279 fr = elm_frame_add(win);
280 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
281 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, 0.5);
282 elm_object_text_set(fr, _("Scale"));
283 elm_object_part_content_set(ctx->hv, "middle", fr);
284 evas_object_show(fr);
285
286 bx = elm_box_add(win);
287 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
288 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5);
289 elm_object_content_set(fr, bx);
290 evas_object_show(bx);
291
292 fr = elm_frame_add(win);
293 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
294 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, 0.5);
295 elm_object_style_set(fr, "pad_medium");
296 elm_box_pack_end(bx, fr);
297 evas_object_show(fr);
298
299 lbl = elm_label_add(win);
300 evas_object_size_hint_weight_set(lbl, EVAS_HINT_EXPAND, 0.0);
301 evas_object_size_hint_align_set(lbl, EVAS_HINT_FILL, 0.5);
302 txt = eina_stringshare_printf("<hilight>%s</>",_("Scale"));
303 elm_object_text_set(lbl, txt);
304 eina_stringshare_del(txt);
305 elm_object_content_set(fr, lbl);
306 elm_box_pack_end(bx, lbl);
307 evas_object_show(lbl);
308
309 sl = elm_slider_add(win);
310 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
311 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
312 elm_slider_span_size_set(sl, 120);
313 elm_slider_unit_format_set(sl, "%1.2f");
314 elm_slider_indicator_format_set(sl, "%1.2f");
315 elm_slider_min_max_set(sl, 0.25, 5.0);
316 elm_slider_value_set(sl, elm_config_scale_get());
317 elm_box_pack_end(bx, sl);
318 evas_object_show(sl);
319 evas_object_smart_callback_add(sl, "changed", _scale_round, NULL);
320 evas_object_smart_callback_add(sl, "delay,changed", _scale_change, NULL);
321
322 lbl = elm_label_add(win);
323 evas_object_size_hint_weight_set(lbl, EVAS_HINT_EXPAND, 0.0);
324 evas_object_size_hint_align_set(lbl, EVAS_HINT_FILL, 0.5);
325 elm_object_text_set(lbl, _("Select prefered size so that is text is readable"));
326 elm_box_pack_end(bx, lbl);
327 evas_object_show(lbl);
328
329 lbl = elm_label_add(win);
330 evas_object_size_hint_weight_set(lbl, EVAS_HINT_EXPAND, 0.0);
331 evas_object_size_hint_align_set(lbl, EVAS_HINT_FILL, 0.5);
332 elm_object_text_set(lbl, _("The scale configuration can be changed in the Settings (right click on the terminal) → Toolkit, or by starting the command <keyword>elementary_config</keyword>"));
333 elm_box_pack_end(bx, lbl);
334 evas_object_show(lbl);
335
336 bt = elm_button_add(win);
337 elm_object_text_set(bt, _("Done"));
338 elm_box_pack_end(bx, bt);
339 evas_object_smart_callback_add(bt, "clicked", _scale_done, ctx);
340 evas_object_show(bt);
341
342 evas_object_show(ctx->hv);
343
344 elm_object_focus_set(ctx->hv, EINA_TRUE);
345}
202 346
203/* {{{ Solo */ 347/* {{{ Solo */
204 348