summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-26 16:41:21 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2020-03-31 14:56:21 +0200
commit4ecc94f84afdb0d627c9f1809786d33300f23c85 (patch)
tree79e0ba671ccd2624f71bde873355a0eead502bf7
parent9fbe26998b42ad55301d012c3d7df2898d6283b8 (diff)
exactness_recorder: refactor main method
all calls taht are not related to env var checking, are moved out of the main method. That is in preparation for later refactorings. Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org> Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D11623
-rw-r--r--src/bin/exactness/common.c6
-rw-r--r--src/bin/exactness/common.h1
-rw-r--r--src/bin/exactness/recorder.c95
3 files changed, 67 insertions, 35 deletions
diff --git a/src/bin/exactness/common.c b/src/bin/exactness/common.c
index 72d02116b1..83b972057e 100644
--- a/src/bin/exactness/common.c
+++ b/src/bin/exactness/common.c
@@ -4,6 +4,12 @@
4 4
5#include "common.h" 5#include "common.h"
6 6
7void
8ex_prepare_elm_overloay(void)
9{
10 elm_theme_overlay_add(NULL, DATA_DIR"/exactness_play.edj");
11}
12
7int 13int
8ex_prg_invoke(const char *full_path, int argc, char **argv, Eina_Bool player) 14ex_prg_invoke(const char *full_path, int argc, char **argv, Eina_Bool player)
9{ 15{
diff --git a/src/bin/exactness/common.h b/src/bin/exactness/common.h
index 08a59ad935..27cf08b146 100644
--- a/src/bin/exactness/common.h
+++ b/src/bin/exactness/common.h
@@ -278,3 +278,4 @@ void exactness_image_free(Exactness_Image *img);
278 278
279int ex_prg_invoke(const char *full_path, int argc, char **argv, Eina_Bool player); 279int ex_prg_invoke(const char *full_path, int argc, char **argv, Eina_Bool player);
280Eina_Stringshare *ex_prg_full_path_guess(const char *prg); 280Eina_Stringshare *ex_prg_full_path_guess(const char *prg);
281void ex_prepare_elm_overloay(void);
diff --git a/src/bin/exactness/recorder.c b/src/bin/exactness/recorder.c
index 75b5cebb52..67b7becd57 100644
--- a/src/bin/exactness/recorder.c
+++ b/src/bin/exactness/recorder.c
@@ -236,6 +236,61 @@ _my_evas_new(int w EINA_UNUSED, int h EINA_UNUSED)
236 return e; 236 return e;
237} 237}
238 238
239static void
240_setup_unit(void)
241{
242 if (_unit) return;
243
244 _unit = calloc(1, sizeof(*_unit));
245}
246
247static Eina_Bool
248_setup_fonts_dir(const char *fonts_dir)
249{
250 if (fonts_dir)
251 {
252 Eina_Tmpstr *fonts_conf_name = NULL;
253 if (!ecore_file_exists(fonts_dir))
254 {
255 fprintf(stderr, "Unable to find fonts directory %s\n", fonts_dir);
256 return EINA_FALSE;
257 }
258 Eina_List *dated_fonts = ecore_file_ls(fonts_dir);
259 char *date_dir;
260 _unit->fonts_path = strdup(eina_list_last_data_get(dated_fonts));
261 EINA_LIST_FREE(dated_fonts, date_dir) free(date_dir);
262 if (_unit->fonts_path)
263 {
264 int tmp_fd = eina_file_mkstemp("/tmp/fonts_XXXXXX.conf", &fonts_conf_name);
265 FILE *tmp_f = fdopen(tmp_fd, "wb");
266 fprintf(tmp_f,
267 "<?xml version=\"1.0\"?>\n<!DOCTYPE fontconfig SYSTEM \"fonts.dtd\">\n<fontconfig>\n"
268 "<dir prefix=\"default\">%s/%s</dir>\n</fontconfig>\n",
269 fonts_dir, _unit->fonts_path);
270 fclose(tmp_f);
271 close(tmp_fd);
272
273 setenv("FONTCONFIG_FILE", fonts_conf_name, 1);
274 }
275 }
276 return EINA_TRUE;
277}
278
279static void
280_setup_shot_key(void)
281{
282 if (!_shot_key) _shot_key = getenv("SHOT_KEY");
283 if (!_shot_key) _shot_key = SHOT_KEY_STR;
284}
285
286static void
287_setup_ee_creation(void)
288{
289 ecore_evas_callback_new_set(_my_evas_new);
290 _last_timestamp = ecore_time_get() * 1000;
291}
292
293
239static const Ecore_Getopt optdesc = { 294static const Ecore_Getopt optdesc = {
240 "exactness_record", 295 "exactness_record",
241 "%prog [options] <-v|-t|-h> command", 296 "%prog [options] <-v|-t|-h> command",
@@ -345,37 +400,9 @@ int main(int argc, char **argv)
345 goto end; 400 goto end;
346 } 401 }
347 402
348 if (!_unit) 403 _setup_unit();
349 { 404 if (!_setup_fonts_dir(fonts_dir))
350 _unit = calloc(1, sizeof(*_unit)); 405 goto end;
351 }
352
353 if (fonts_dir)
354 {
355 Eina_Tmpstr *fonts_conf_name = NULL;
356 if (!ecore_file_exists(fonts_dir))
357 {
358 fprintf(stderr, "Unable to find fonts directory %s\n", fonts_dir);
359 goto end;
360 }
361 Eina_List *dated_fonts = ecore_file_ls(fonts_dir);
362 char *date_dir;
363 _unit->fonts_path = strdup(eina_list_last_data_get(dated_fonts));
364 EINA_LIST_FREE(dated_fonts, date_dir) free(date_dir);
365 if (_unit->fonts_path)
366 {
367 int tmp_fd = eina_file_mkstemp("/tmp/fonts_XXXXXX.conf", &fonts_conf_name);
368 FILE *tmp_f = fdopen(tmp_fd, "wb");
369 fprintf(tmp_f,
370 "<?xml version=\"1.0\"?>\n<!DOCTYPE fontconfig SYSTEM \"fonts.dtd\">\n<fontconfig>\n"
371 "<dir prefix=\"default\">%s/%s</dir>\n</fontconfig>\n",
372 fonts_dir, _unit->fonts_path);
373 fclose(tmp_f);
374 close(tmp_fd);
375
376 setenv("FONTCONFIG_FILE", fonts_conf_name, 1);
377 }
378 }
379 406
380 /* Replace the current command line to hide the Exactness part */ 407 /* Replace the current command line to hide the Exactness part */
381 char **new_argv; 408 char **new_argv;
@@ -390,11 +417,9 @@ int main(int argc, char **argv)
390 new_argv[i] = NULL; 417 new_argv[i] = NULL;
391 } 418 }
392 419
393 if (!_shot_key) _shot_key = getenv("SHOT_KEY"); 420 _setup_shot_key();
394 if (!_shot_key) _shot_key = SHOT_KEY_STR; 421 _setup_ee_creation();
395 422
396 ecore_evas_callback_new_set(_my_evas_new);
397 _last_timestamp = ecore_time_get() * 1000;
398 pret = ex_prg_invoke(ex_prg_full_path_guess(argv[opt_args]), argc - opt_args, new_argv, EINA_FALSE); 423 pret = ex_prg_invoke(ex_prg_full_path_guess(argv[opt_args]), argc - opt_args, new_argv, EINA_FALSE);
399 424
400 _output_write(); 425 _output_write();