GOptionGroup * gegl_get_option_group (void) { GOptionGroup *group; gegl_init_i18n (); group = g_option_group_new ("gegl", "GEGL Options", "Show GEGL Options", NULL, NULL); g_option_group_add_entries (group, cmd_entries); g_option_group_set_parse_hooks (group, NULL, gegl_post_parse_hook); return group; }
static gboolean gegl_post_parse_hook (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error) { glong time; if (config) return TRUE; g_assert (global_time == 0); global_time = gegl_ticks (); g_type_init (); gegl_instrument ("gegl", "gegl_init", 0); config = (void*)gegl_config (); if (cmd_gegl_swap) g_object_set (config, "swap", cmd_gegl_swap, NULL); if (cmd_gegl_quality) config->quality = atof (cmd_gegl_quality); if (cmd_gegl_cache_size) config->cache_size = atoi (cmd_gegl_cache_size)*1024*1024; if (cmd_gegl_chunk_size) config->chunk_size = atoi (cmd_gegl_chunk_size); if (cmd_gegl_tile_size) { const gchar *str = cmd_gegl_tile_size; config->tile_width = atoi(str); str = strchr (str, 'x'); if (str) config->tile_height = atoi(str+1); } if (cmd_gegl_threads) config->threads = atoi (cmd_gegl_threads); if (cmd_babl_tolerance) g_object_set (config, "babl-tolerance", atof(cmd_babl_tolerance), NULL); #ifdef GEGL_ENABLE_DEBUG { const char *env_string; env_string = g_getenv ("GEGL_DEBUG"); if (env_string != NULL) { gegl_debug_flags = g_parse_debug_string (env_string, gegl_debug_keys, G_N_ELEMENTS (gegl_debug_keys)); env_string = NULL; } } #endif /* GEGL_ENABLE_DEBUG */ time = gegl_ticks (); babl_init (); gegl_instrument ("gegl_init", "babl_init", gegl_ticks () - time); gegl_init_i18n (); time = gegl_ticks (); if (!module_db) { const gchar *gegl_path = g_getenv ("GEGL_PATH"); module_db = gegl_module_db_new (FALSE); if (gegl_path) { gegl_module_db_load (module_db, gegl_path); } else { gchar *module_path; #ifdef G_OS_WIN32 { gchar *prefix; prefix = g_win32_get_package_installation_directory_of_module ( hLibGeglModule ); module_path = g_build_filename (prefix, "lib", GEGL_LIBRARY, NULL); g_free(prefix); } #else module_path = g_build_filename (LIBDIR, GEGL_LIBRARY, NULL); #endif gegl_module_db_load (module_db, module_path); g_free (module_path); /* also load plug-ins from ~/.local/share/gegl-0.0/plugins */ module_path = g_build_filename (g_get_user_data_dir (), GEGL_LIBRARY, "plug-ins", NULL); if (g_mkdir_with_parents (module_path, S_IRUSR | S_IWUSR | S_IXUSR) == 0) { gchar *makefile_path = g_build_filename (module_path, "Makefile", NULL); if (! g_file_test (makefile_path, G_FILE_TEST_EXISTS)) g_file_set_contents (makefile_path, makefile (), -1, NULL); g_free (makefile_path); } gegl_module_db_load (module_db, module_path); g_free (module_path); } gegl_instrument ("gegl_init", "load modules", gegl_ticks () - time); } gegl_instrument ("gegl", "gegl_init", gegl_ticks () - global_time); if (g_getenv ("GEGL_SWAP")) g_object_set (config, "swap", g_getenv ("GEGL_SWAP"), NULL); if (g_getenv ("GEGL_QUALITY")) { const gchar *quality = g_getenv ("GEGL_QUALITY"); if (g_str_equal (quality, "fast")) g_object_set (config, "quality", 0.0, NULL); if (g_str_equal (quality, "good")) g_object_set (config, "quality", 0.5, NULL); if (g_str_equal (quality, "best")) g_object_set (config, "quality", 1.0, NULL); } swap_clean (); return TRUE; }