void gimp_font_list_restore (GimpFontList *list) { PangoFontMap *fontmap; PangoContext *context; g_return_if_fail (GIMP_IS_FONT_LIST (list)); fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT); if (! fontmap) g_error ("You are using a Pango that has been built against a cairo " "that lacks the Freetype font backend"); pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (fontmap), list->yresolution); context = pango_font_map_create_context (fontmap); g_object_unref (fontmap); gimp_container_freeze (GIMP_CONTAINER (list)); gimp_font_list_load_names (list, PANGO_FONT_MAP (fontmap), context); g_object_unref (context); gimp_list_sort_by_name (GIMP_LIST (list)); gimp_container_thaw (GIMP_CONTAINER (list)); }
void gimp_paint_init (Gimp *gimp) { GimpPaintRegisterFunc register_funcs[] = { gimp_dodge_burn_register, gimp_smudge_register, gimp_convolve_register, gimp_perspective_clone_register, gimp_heal_register, gimp_clone_register, gimp_ink_register, gimp_airbrush_register, gimp_eraser_register, gimp_paintbrush_register, gimp_pencil_register }; gint i; g_return_if_fail (GIMP_IS_GIMP (gimp)); gimp->paint_info_list = gimp_list_new (GIMP_TYPE_PAINT_INFO, FALSE); gimp_object_set_static_name (GIMP_OBJECT (gimp->paint_info_list), "paint infos"); gimp_container_freeze (gimp->paint_info_list); for (i = 0; i < G_N_ELEMENTS (register_funcs); i++) { register_funcs[i] (gimp, gimp_paint_register); } gimp_container_thaw (gimp->paint_info_list); }
/** * gimp_list_reverse: * @list: a #GimpList * * Reverses the order of elements in a #GimpList. **/ void gimp_list_reverse (GimpList *list) { g_return_if_fail (GIMP_IS_LIST (list)); if (GIMP_CONTAINER (list)->num_children > 1) { gimp_container_freeze (GIMP_CONTAINER (list)); list->list = g_list_reverse (list->list); gimp_container_thaw (GIMP_CONTAINER (list)); } }
/** * gimp_list_sort: * @list: a #GimpList * @sort_func: a #GCompareFunc * * Sorts the elements of a #GimpList according to the given @sort_func. * See g_list_sort() for a detailed description of this function. **/ void gimp_list_sort (GimpList *list, GCompareFunc sort_func) { g_return_if_fail (GIMP_IS_LIST (list)); g_return_if_fail (sort_func != NULL); if (GIMP_CONTAINER (list)->num_children > 1) { gimp_container_freeze (GIMP_CONTAINER (list)); list->list = g_list_sort (list->list, sort_func); gimp_container_thaw (GIMP_CONTAINER (list)); } }
void gimp_fonts_load (Gimp *gimp) { FcConfig *config; GFile *fonts_conf; GList *path; g_return_if_fail (GIMP_IS_FONT_LIST (gimp->fonts)); gimp_set_busy (gimp); if (gimp->be_verbose) g_print ("Loading fonts\n"); gimp_container_freeze (GIMP_CONTAINER (gimp->fonts)); gimp_container_clear (GIMP_CONTAINER (gimp->fonts)); config = FcInitLoadConfig (); if (! config) goto cleanup; fonts_conf = gimp_directory_file (CONF_FNAME, NULL); if (! gimp_fonts_load_fonts_conf (config, fonts_conf)) goto cleanup; fonts_conf = gimp_sysconf_directory_file (CONF_FNAME, NULL); if (! gimp_fonts_load_fonts_conf (config, fonts_conf)) goto cleanup; path = gimp_config_path_expand_to_files (gimp->config->font_path, FALSE); gimp_fonts_add_directories (config, path); g_list_free_full (path, (GDestroyNotify) g_object_unref); if (! FcConfigBuildFonts (config)) { FcConfigDestroy (config); goto cleanup; } FcConfigSetCurrent (config); gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts)); cleanup: gimp_container_thaw (GIMP_CONTAINER (gimp->fonts)); gimp_unset_busy (gimp); }
void gimp_fonts_load (Gimp *gimp) { FcConfig *config; gchar *fonts_conf; gchar *path; g_return_if_fail (GIMP_IS_FONT_LIST (gimp->fonts)); gimp_set_busy (gimp); if (gimp->be_verbose) g_print ("Loading fonts\n"); gimp_container_freeze (GIMP_CONTAINER (gimp->fonts)); gimp_container_clear (GIMP_CONTAINER (gimp->fonts)); config = FcInitLoadConfig (); if (! config) goto cleanup; fonts_conf = gimp_personal_rc_file (CONF_FNAME); if (! gimp_fonts_load_fonts_conf (config, fonts_conf)) goto cleanup; fonts_conf = g_build_filename (gimp_sysconf_directory (), CONF_FNAME, NULL); if (! gimp_fonts_load_fonts_conf (config, fonts_conf)) goto cleanup; path = gimp_config_path_expand (gimp->config->font_path, TRUE, NULL); gimp_fonts_add_directories (config, path); g_free (path); if (! FcConfigBuildFonts (config)) { FcConfigDestroy (config); goto cleanup; } FcConfigSetCurrent (config); gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts)); cleanup: gimp_container_thaw (GIMP_CONTAINER (gimp->fonts)); gimp_unset_busy (gimp); }
void gimp_font_list_restore (GimpFontList *list) { PangoFontMap *fontmap; PangoContext *context; g_return_if_fail (GIMP_IS_FONT_LIST (list)); if (font_desc_to_string == NULL) { PangoFontDescription *desc; gchar *name; gchar last_char; desc = pango_font_description_new (); pango_font_description_set_family (desc, "Wilber 12"); name = pango_font_description_to_string (desc); last_char = name[strlen (name) - 1]; g_free (name); pango_font_description_free (desc); if (last_char != ',') font_desc_to_string = &gimp_font_util_pango_font_description_to_string; else font_desc_to_string = &pango_font_description_to_string; } fontmap = pango_ft2_font_map_new (); pango_ft2_font_map_set_resolution (PANGO_FT2_FONT_MAP (fontmap), list->xresolution, list->yresolution); context = pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (fontmap)); g_object_unref (fontmap); gimp_container_freeze (GIMP_CONTAINER (list)); gimp_font_list_load_names (list, fontmap, context); g_object_unref (context); gimp_list_sort_by_name (GIMP_LIST (list)); gimp_container_thaw (GIMP_CONTAINER (list)); }
void gimp_tools_init (Gimp *gimp) { GimpToolRegisterFunc register_funcs[] = { /* register tools in reverse order */ /* color tools */ gimp_operation_tool_register, gimp_gegl_tool_register, gimp_curves_tool_register, gimp_levels_tool_register, gimp_threshold_tool_register, gimp_brightness_contrast_tool_register, gimp_colorize_tool_register, gimp_hue_saturation_tool_register, gimp_color_balance_tool_register, /* paint tools */ gimp_dodge_burn_tool_register, gimp_smudge_tool_register, gimp_convolve_tool_register, gimp_perspective_clone_tool_register, gimp_heal_tool_register, gimp_clone_tool_register, gimp_mybrush_tool_register, gimp_ink_tool_register, gimp_airbrush_tool_register, gimp_eraser_tool_register, gimp_paintbrush_tool_register, gimp_pencil_tool_register, gimp_blend_tool_register, gimp_bucket_fill_tool_register, gimp_text_tool_register, gimp_seamless_clone_tool_register, /* transform tools */ gimp_n_point_deformation_tool_register, gimp_warp_tool_register, gimp_cage_tool_register, gimp_flip_tool_register, gimp_perspective_tool_register, gimp_handle_transform_tool_register, gimp_shear_tool_register, gimp_scale_tool_register, gimp_rotate_tool_register, gimp_unified_transform_tool_register, gimp_crop_tool_register, gimp_align_tool_register, gimp_move_tool_register, /* non-modifying tools */ gimp_measure_tool_register, gimp_magnify_tool_register, gimp_color_picker_tool_register, /* path tool */ gimp_vector_tool_register, /* selection tools */ gimp_foreground_select_tool_register, gimp_iscissors_tool_register, gimp_by_color_select_tool_register, gimp_fuzzy_select_tool_register, gimp_free_select_tool_register, gimp_ellipse_select_tool_register, gimp_rectangle_select_tool_register }; GList *default_order = NULL; GList *list; gint i; g_return_if_fail (GIMP_IS_GIMP (gimp)); gimp_tool_options_create_folder (); tool_manager_init (gimp); gimp_container_freeze (gimp->tool_info_list); for (i = 0; i < G_N_ELEMENTS (register_funcs); i++) { register_funcs[i] (gimp_tools_register, gimp); } gimp_container_thaw (gimp->tool_info_list); for (list = gimp_get_tool_info_iter (gimp); list; list = g_list_next (list)) { const gchar *identifier = gimp_object_get_name (list->data); default_order = g_list_prepend (default_order, g_strdup (identifier)); } default_order = g_list_reverse (default_order); g_object_set_data (G_OBJECT (gimp), "gimp-tools-default-order", default_order); }
void gimp_fonts_load (Gimp *gimp, GimpInitStatusFunc status_callback) { FcConfig *config; GFile *fonts_conf; GList *path; g_return_if_fail (GIMP_IS_FONT_LIST (gimp->fonts)); gimp_set_busy (gimp); if (gimp->be_verbose) g_print ("Loading fonts\n"); gimp_container_freeze (GIMP_CONTAINER (gimp->fonts)); gimp_container_clear (GIMP_CONTAINER (gimp->fonts)); config = FcInitLoadConfig (); if (! config) goto cleanup; fonts_conf = gimp_directory_file (CONF_FNAME, NULL); if (! gimp_fonts_load_fonts_conf (config, fonts_conf)) goto cleanup; fonts_conf = gimp_sysconf_directory_file (CONF_FNAME, NULL); if (! gimp_fonts_load_fonts_conf (config, fonts_conf)) goto cleanup; path = gimp_config_path_expand_to_files (gimp->config->font_path, FALSE); gimp_fonts_add_directories (config, path); g_list_free_full (path, (GDestroyNotify) g_object_unref); if (status_callback) { gint64 end_time; GThread *cache_thread; GimpFontsLoadFuncData data; /* We perform font cache initialization in a separate thread, so * in the case a cache rebuild is to be done it will not block * the UI. */ data.config = config; g_mutex_init (&data.mutex); g_cond_init (&data.cond); data.caching_complete = FALSE; cache_thread = g_thread_new ("font-cacher", (GThreadFunc) gimp_fonts_load_thread, &data); g_mutex_lock (&data.mutex); end_time = g_get_monotonic_time () + 0.1 * G_TIME_SPAN_SECOND; while (! data.caching_complete) if (! g_cond_wait_until (&data.cond, &data.mutex, end_time)) { status_callback (NULL, NULL, 0.6); end_time += 0.1 * G_TIME_SPAN_SECOND; continue; } g_mutex_unlock (&data.mutex); g_thread_join (cache_thread); g_mutex_clear (&data.mutex); g_cond_clear (&data.cond); } else { gimp_fonts_load_func (config); } gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts)); cleanup: gimp_container_thaw (GIMP_CONTAINER (gimp->fonts)); gimp_unset_busy (gimp); }