summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/main.c19
-rw-r--r--src/bin/utils.c30
-rw-r--r--src/bin/utils.h1
-rw-r--r--src/bin/win.c144
-rw-r--r--src/bin/win.h1
5 files changed, 187 insertions, 8 deletions
diff --git a/src/bin/main.c b/src/bin/main.c
index 9e77386..0cc1252 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -94,10 +94,10 @@ main_ipc_new(Ipc_Instance *inst)
94 if (inst->xterm_256color) nargc += 1; 94 if (inst->xterm_256color) nargc += 1;
95 if (inst->active_links) nargc += 1; 95 if (inst->active_links) nargc += 1;
96 if (inst->cmd) nargc += 2; 96 if (inst->cmd) nargc += 2;
97 97
98 nargv = calloc(nargc + 1, sizeof(char *)); 98 nargv = calloc(nargc + 1, sizeof(char *));
99 if (!nargv) return; 99 if (!nargv) return;
100 100
101 i = 0; 101 i = 0;
102 nargv[i++] = pargv[0]; 102 nargv[i++] = pargv[0];
103 if (inst->cd) 103 if (inst->cd)
@@ -261,13 +261,13 @@ main_ipc_new(Ipc_Instance *inst)
261 { 261 {
262 char *fname = alloca(strlen(inst->font) + 1); 262 char *fname = alloca(strlen(inst->font) + 1);
263 char *p; 263 char *p;
264 264
265 strcpy(fname, inst->font); 265 strcpy(fname, inst->font);
266 p = strrchr(fname, '/'); 266 p = strrchr(fname, '/');
267 if (p) 267 if (p)
268 { 268 {
269 int sz; 269 int sz;
270 270
271 *p = 0; 271 *p = 0;
272 p++; 272 p++;
273 sz = atoi(p); 273 sz = atoi(p);
@@ -281,7 +281,7 @@ main_ipc_new(Ipc_Instance *inst)
281 char buf[4096], *file; 281 char buf[4096], *file;
282 Eina_List *files; 282 Eina_List *files;
283 int n = strlen(inst->font); 283 int n = strlen(inst->font);
284 284
285 snprintf(buf, sizeof(buf), "%s/fonts", elm_app_data_dir_get()); 285 snprintf(buf, sizeof(buf), "%s/fonts", elm_app_data_dir_get());
286 files = ecore_file_ls(buf); 286 files = ecore_file_ls(buf);
287 EINA_LIST_FREE(files, file) 287 EINA_LIST_FREE(files, file)
@@ -809,7 +809,7 @@ elm_main(int argc, char **argv)
809 pos_set = 1; 809 pos_set = 1;
810 } 810 }
811 } 811 }
812 812
813 if (!size_set) 813 if (!size_set)
814 { 814 {
815 if (config->custom_geometry) 815 if (config->custom_geometry)
@@ -839,9 +839,9 @@ remote:
839 { 839 {
840 Ipc_Instance inst; 840 Ipc_Instance inst;
841 char cwdbuf[4096]; 841 char cwdbuf[4096];
842 842
843 memset(&inst, 0, sizeof(Ipc_Instance)); 843 memset(&inst, 0, sizeof(Ipc_Instance));
844 844
845 inst.cmd = cmd; 845 inst.cmd = cmd;
846 if (cd) inst.cd = cd; 846 if (cd) inst.cd = cd;
847 else inst.cd = getcwd(cwdbuf, sizeof(cwdbuf)); 847 else inst.cd = getcwd(cwdbuf, sizeof(cwdbuf));
@@ -970,6 +970,9 @@ remote:
970 ecore_con_url_init(); 970 ecore_con_url_init();
971 971
972 controls_init(); 972 controls_init();
973
974 win_scale_wizard(win, term);
975
973 terminology_starting_up = EINA_FALSE; 976 terminology_starting_up = EINA_FALSE;
974 977
975 elm_run(); 978 elm_run();
diff --git a/src/bin/utils.c b/src/bin/utils.c
index ecd2da3..fddb016 100644
--- a/src/bin/utils.c
+++ b/src/bin/utils.c
@@ -145,6 +145,36 @@ homedir_get(char *buf, size_t size)
145} 145}
146 146
147Eina_Bool 147Eina_Bool
148utils_need_scale_wizard(void)
149{
150 static char path[PATH_MAX] = "";
151 struct stat st;
152 int res;
153 char *tmp;
154 Eina_Bool use_xdg_config;
155
156
157 snprintf(path, sizeof(path) -1, "%s/terminology/config/",
158 efreet_config_home_get());
159 res = stat(path, &st);
160 if (res == 0)
161 return EINA_FALSE;
162
163 use_xdg_config = (getenv("ELM_CONFIG_DIR_XDG") != NULL);
164
165 if (use_xdg_config)
166 tmp = eina_vpath_resolve("(:usr.config:)/elementary");
167 else
168 tmp = eina_vpath_resolve("(:home:)/" ".elementary");
169 res = stat(tmp, &st);
170 free(tmp);
171 if (res == 0)
172 return EINA_FALSE;
173
174 return EINA_TRUE;
175}
176
177Eina_Bool
148link_is_protocol(const char *str) 178link_is_protocol(const char *str)
149{ 179{
150 const char *p = str; 180 const char *p = str;
diff --git a/src/bin/utils.h b/src/bin/utils.h
index 73476de..01318ba 100644
--- a/src/bin/utils.h
+++ b/src/bin/utils.h
@@ -12,6 +12,7 @@ void theme_auto_reload_enable(Evas_Object *edje);
12const char *theme_path_get(const char *name); 12const char *theme_path_get(const char *name);
13 13
14Eina_Bool homedir_get(char *buf, size_t size); 14Eina_Bool homedir_get(char *buf, size_t size);
15Eina_Bool utils_need_scale_wizard(void);
15 16
16Eina_Bool link_is_protocol(const char *str); 17Eina_Bool link_is_protocol(const char *str);
17Eina_Bool link_is_url(const char *str); 18Eina_Bool link_is_url(const char *str);
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
diff --git a/src/bin/win.h b/src/bin/win.h
index af4bf16..2986dac 100644
--- a/src/bin/win.h
+++ b/src/bin/win.h
@@ -50,6 +50,7 @@ void win_toggle_visible_group(Win *wn);
50void win_toggle_all_group(Win *wn); 50void win_toggle_all_group(Win *wn);
51Eina_Bool win_is_group_action_handled(Win *wn); 51Eina_Bool win_is_group_action_handled(Win *wn);
52Eina_Bool win_is_group_input(Win *wn); 52Eina_Bool win_is_group_input(Win *wn);
53void win_scale_wizard(Evas_Object *win, Term *term);
53 54
54 55
55void term_ref(Term *term); 56void term_ref(Term *term);