void gegl_init (gint *argc, gchar ***argv) { GOptionContext *context; GError *error = NULL; static gboolean initialized = FALSE; if (initialized) return; initialized = TRUE; context = g_option_context_new (NULL); g_option_context_set_ignore_unknown_options (context, TRUE); g_option_context_set_help_enabled (context, FALSE); g_option_context_set_main_group (context, gegl_get_option_group ()); if (!g_option_context_parse (context, argc, argv, &error)) { g_warning ("%s", error->message); g_error_free (error); } g_option_context_free (context); }
gint main (gint argc, gchar **argv) { gboolean result; GError *error = NULL; GOptionContext *context; setlocale (LC_ALL, ""); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, options, NULL); g_option_context_add_group (context, gegl_get_option_group ()); g_object_set (gegl_config (), "application-license", "GPL3", NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printf ("%s\n", error->message); g_error_free (error); result = FALSE; } else if (output_all && !(data_dir && output_dir)) { g_printf ("Data and output directories must be specified\n"); result = FALSE; } else if (!(output_all || (data_dir && output_dir && reference_dir))) { g_printf ("Data, reference and output directories must be specified\n"); result = FALSE; } else { regex = g_regex_new (pattern, 0, 0, NULL); exc_regex = g_regex_new (exclusion_pattern, 0, 0, NULL); result = process_operations (GEGL_TYPE_OPERATION); g_regex_unref (regex); g_regex_unref (exc_regex); } gegl_exit (); if (output_all) return 0; else return result; }
void app_libs_init (GOptionContext *context, gboolean no_interface) { g_option_context_add_group (context, gegl_get_option_group ()); #ifndef GIMP_CONSOLE_COMPILATION if (! no_interface) { gui_libs_init (context); } #endif }
void app_libs_init (GOptionContext *context, gboolean no_interface) { /* disable OpenCL before GEGL is even initialized; this way we only * enable if wanted in gimprc, instead of always enabling, and then * disabling again if wanted in gimprc */ g_object_set (gegl_config (), "use-opencl", FALSE, "application-license", "GPL3", NULL); g_option_context_add_group (context, gegl_get_option_group ()); #ifndef GIMP_CONSOLE_COMPILATION if (! no_interface) { gui_libs_init (context); } #endif }
/** * gegl_init: * @argc: a pointer to the number of command line arguments. * @argv: a pointer to the array of command line arguments. * * Call this function before using any other GEGL functions. It will initialize * everything needed to operate GEGL and parses some standard command line * options. @argc and @argv are adjusted accordingly so your own code will * never see those standard arguments. * * Note that there is an alternative ways to initialize GEGL: if you are * calling g_option_context_parse() with the option group returned by * gegl_get_option_group(), you don't have to call gegl_init(). **/ void gegl_init (gint *argc, gchar ***argv) { GOptionContext *context; GError *error = NULL; if (config) return; /* If any command-line actions are ever added to GEGL, then the commented * out code below should be used. Until then, we simply call the parse hook * directly. */ #if 0 gegl_post_parse_hook (NULL, NULL, NULL, NULL); #else context = g_option_context_new (NULL); g_option_context_set_ignore_unknown_options (context, TRUE); g_option_context_set_help_enabled (context, FALSE); g_option_context_set_main_group (context, gegl_get_option_group ()); if (!g_option_context_parse (context, argc, argv, &error)) { g_warning ("%s", error->message); g_error_free (error); } g_option_context_free (context); #endif /* Not the best place for this ... better to put it in post_parse and just * save argv[0] here. */ vips_init (*argv[0]); }