GimpUndo * gimp_undo_stack_free_bottom (GimpUndoStack *stack, GimpUndoMode undo_mode) { GimpUndo *undo; gint n_children; g_return_val_if_fail (GIMP_IS_UNDO_STACK (stack), NULL); n_children = gimp_container_num_children (GIMP_CONTAINER (stack->undos)); undo = (GimpUndo *) gimp_container_get_child_by_index (GIMP_CONTAINER (stack->undos), n_children - 1); if (undo) { gimp_container_remove (GIMP_CONTAINER (stack->undos), GIMP_OBJECT (undo)); gimp_undo_free (undo, undo_mode); return undo; } return NULL; }
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)); }
/** * 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); }
static void gimp_font_list_add_font (GimpFontList *list, PangoContext *context, PangoFontDescription *desc) { gchar *name; if (! desc) return; name = pango_font_description_to_string (desc); if (g_utf8_validate (name, -1, NULL)) { GimpFont *font; font = g_object_new (GIMP_TYPE_FONT, "name", name, "pango-context", context, NULL); gimp_container_add (GIMP_CONTAINER (list), GIMP_OBJECT (font)); g_object_unref (font); } g_free (name); }
static void gimp_tagged_container_src_add (GimpFilteredContainer *filtered_container, GimpObject *object) { GimpTaggedContainer *tagged_container = GIMP_TAGGED_CONTAINER (filtered_container); GList *list; for (list = gimp_tagged_get_tags (GIMP_TAGGED (object)); list; list = g_list_next (list)) { gimp_tagged_container_ref_tag (tagged_container, list->data); } g_signal_connect (object, "tag-added", G_CALLBACK (gimp_tagged_container_tag_added), tagged_container); g_signal_connect (object, "tag-removed", G_CALLBACK (gimp_tagged_container_tag_removed), tagged_container); if (gimp_tagged_container_object_matches (tagged_container, object)) { gimp_container_add (GIMP_CONTAINER (tagged_container), object); } }
static void gimp_tagged_container_src_remove (GimpFilteredContainer *filtered_container, GimpObject *object) { GimpTaggedContainer *tagged_container = GIMP_TAGGED_CONTAINER (filtered_container); GList *list; g_signal_handlers_disconnect_by_func (object, gimp_tagged_container_tag_added, tagged_container); g_signal_handlers_disconnect_by_func (object, gimp_tagged_container_tag_removed, tagged_container); for (list = gimp_tagged_get_tags (GIMP_TAGGED (object)); list; list = g_list_next (list)) { gimp_tagged_container_unref_tag (tagged_container, list->data); } if (gimp_tagged_container_object_matches (tagged_container, object)) { gimp_container_remove (GIMP_CONTAINER (tagged_container), object); } }
static void gimp_tagged_container_tag_removed (GimpTagged *tagged, GimpTag *tag, GimpTaggedContainer *tagged_container) { gimp_tagged_container_unref_tag (tagged_container, tag); if (! gimp_tagged_container_object_matches (tagged_container, GIMP_OBJECT (tagged)) && gimp_container_have (GIMP_CONTAINER (tagged_container), GIMP_OBJECT (tagged))) { gimp_container_remove (GIMP_CONTAINER (tagged_container), GIMP_OBJECT (tagged)); } }
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)); }
static void gimp_filter_stack_add_node (GimpFilterStack *stack, GimpFilter *filter) { GimpFilter *filter_below; GeglNode *node_above; GeglNode *node_below; GeglNode *node; gint index; node = gimp_filter_get_node (filter); index = gimp_container_get_child_index (GIMP_CONTAINER (stack), GIMP_OBJECT (filter)); if (index == 0) { node_above = gegl_node_get_output_proxy (stack->graph, "output"); } else { GimpFilter *filter_above = (GimpFilter *) gimp_container_get_child_by_index (GIMP_CONTAINER (stack), index - 1); node_above = gimp_filter_get_node (filter_above); } gegl_node_connect_to (node, "output", node_above, "input"); filter_below = (GimpFilter *) gimp_container_get_child_by_index (GIMP_CONTAINER (stack), index + 1); if (filter_below) { node_below = gimp_filter_get_node (filter_below); } else { node_below = gegl_node_get_input_proxy (stack->graph, "input"); } gegl_node_connect_to (node_below, "output", node, "input"); }
void gimp_undo_stack_push_undo (GimpUndoStack *stack, GimpUndo *undo) { g_return_if_fail (GIMP_IS_UNDO_STACK (stack)); g_return_if_fail (GIMP_IS_UNDO (undo)); gimp_container_add (GIMP_CONTAINER (stack->undos), GIMP_OBJECT (undo)); }
static void gimp_filter_stack_constructed (GObject *object) { GimpContainer *container = GIMP_CONTAINER (object); G_OBJECT_CLASS (parent_class)->constructed (object); g_assert (g_type_is_a (gimp_container_get_children_type (container), GIMP_TYPE_FILTER)); }
GimpUndo * gimp_undo_stack_peek (GimpUndoStack *stack) { GimpObject *object; g_return_val_if_fail (GIMP_IS_UNDO_STACK (stack), NULL); object = gimp_container_get_child_by_index (GIMP_CONTAINER (stack->undos), 0); return (object ? GIMP_UNDO (object) : NULL); }
static gint64 gimp_list_get_memsize (GimpObject *object, gint64 *gui_size) { GimpList *list = GIMP_LIST (object); gint64 memsize = 0; memsize += (gimp_container_num_children (GIMP_CONTAINER (list)) * sizeof (GList)); if (gimp_container_policy (GIMP_CONTAINER (list)) == GIMP_CONTAINER_POLICY_STRONG) { GList *glist; for (glist = list->list; glist; glist = g_list_next (glist)) memsize += gimp_object_get_memsize (GIMP_OBJECT (glist->data), gui_size); } return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, gui_size); }
static void gimp_filter_stack_constructed (GObject *object) { GimpContainer *container = GIMP_CONTAINER (object); G_OBJECT_CLASS (parent_class)->constructed (object); g_assert (g_type_is_a (gimp_container_get_children_type (container), GIMP_TYPE_FILTER)); gimp_container_add_handler (container, "visibility-changed", G_CALLBACK (gimp_filter_stack_filter_visible), container); }
GimpUndo * gimp_undo_stack_pop_undo (GimpUndoStack *stack, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { GimpUndo *undo; g_return_val_if_fail (GIMP_IS_UNDO_STACK (stack), NULL); g_return_val_if_fail (accum != NULL, NULL); undo = (GimpUndo *) gimp_container_get_child_by_index (GIMP_CONTAINER (stack->undos), 0); if (undo) { gimp_container_remove (GIMP_CONTAINER (stack->undos), GIMP_OBJECT (undo)); gimp_undo_pop (undo, undo_mode, accum); return undo; } return NULL; }
/** * gimp_list_new_weak: * @children_type: the #GType of objects the list is going to hold * @unique_names: if the list should ensure that all its children * have unique names. * * Creates a new #GimpList object. Since #GimpList is a #GimpContainer * implementation, it holds GimpObjects. Thus @children_type must be * GIMP_TYPE_OBJECT or a type derived from it. * * The returned list has the #GIMP_CONTAINER_POLICY_WEAK. * * Return value: a new #GimpList object **/ GimpContainer * gimp_list_new_weak (GType children_type, gboolean unique_names) { GimpList *list; g_return_val_if_fail (g_type_is_a (children_type, GIMP_TYPE_OBJECT), NULL); list = g_object_new (GIMP_TYPE_LIST, "children-type", children_type, "policy", GIMP_CONTAINER_POLICY_WEAK, "unique-names", unique_names ? TRUE : FALSE, NULL); /* for debugging purposes only */ gimp_object_set_static_name (GIMP_OBJECT (list), g_type_name (children_type)); return GIMP_CONTAINER (list); }
GimpContainer * gimp_font_list_new (gdouble xresolution, gdouble yresolution) { GimpFontList *list; g_return_val_if_fail (xresolution > 0.0, NULL); g_return_val_if_fail (yresolution > 0.0, NULL); list = g_object_new (GIMP_TYPE_FONT_LIST, "children-type", GIMP_TYPE_FONT, "policy", GIMP_CONTAINER_POLICY_STRONG, NULL); list->xresolution = xresolution; list->yresolution = yresolution; return GIMP_CONTAINER (list); }
static void gimp_list_object_renamed (GimpObject *object, GimpList *list) { if (list->unique_names) { g_signal_handlers_block_by_func (object, gimp_list_object_renamed, list); gimp_list_uniquefy_name (list, object); g_signal_handlers_unblock_by_func (object, gimp_list_object_renamed, list); } if (list->sort_func) { GList *glist; gint old_index; gint new_index = 0; old_index = g_list_index (list->list, object); for (glist = list->list; glist; glist = g_list_next (glist)) { GimpObject *object2 = GIMP_OBJECT (glist->data); if (object == object2) continue; if (list->sort_func (object, object2) > 0) new_index++; else break; } if (new_index != old_index) gimp_container_reorder (GIMP_CONTAINER (list), object, new_index); } }
static void gimp_undo_stack_free (GimpUndo *undo, GimpUndoMode undo_mode) { GimpUndoStack *stack = GIMP_UNDO_STACK (undo); GList *list; for (list = GIMP_LIST (stack->undos)->list; list; list = g_list_next (list)) { GimpUndo *child = list->data; gimp_undo_free (child, undo_mode); g_object_unref (child); } while (GIMP_LIST (stack->undos)->list) gimp_container_remove (GIMP_CONTAINER (stack->undos), GIMP_LIST (stack->undos)->list->data); }
/** * gimp_tagged_container_new: * @src_container: container to be filtered. * * Creates a new #GimpTaggedContainer object which creates filtered * data view of #GimpTagged objects. It filters @src_container for * objects containing all of the filtering tags. Synchronization with * @src_container data is performed automatically. * * Return value: a new #GimpTaggedContainer object. **/ GimpContainer * gimp_tagged_container_new (GimpContainer *src_container) { GimpTaggedContainer *tagged_container; GType children_type; GCompareFunc sort_func; g_return_val_if_fail (GIMP_IS_LIST (src_container), NULL); children_type = gimp_container_get_children_type (src_container); sort_func = GIMP_LIST (src_container)->sort_func; tagged_container = g_object_new (GIMP_TYPE_TAGGED_CONTAINER, "sort-func", sort_func, "children-type", children_type, "policy", GIMP_CONTAINER_POLICY_WEAK, "unique-names", FALSE, "src-container", src_container, NULL); return GIMP_CONTAINER (tagged_container); }
static void gimp_font_list_add_font (GimpFontList *list, PangoContext *context, PangoFontDescription *desc) { GimpFont *font; gchar *name; gsize len; if (! desc) return; name = font_desc_to_string (desc); len = strlen (name); if (! g_utf8_validate (name, len, NULL)) { g_free (name); return; } #ifdef __GNUC__ #warning remove this as soon as we depend on Pango 1.16.5 #endif if (g_str_has_suffix (name, " Not-Rotated")) name[len - strlen (" Not-Rotated")] = '\0'; font = g_object_new (GIMP_TYPE_FONT, "name", name, "pango-context", context, NULL); g_free (name); gimp_container_add (GIMP_CONTAINER (list), GIMP_OBJECT (font)); g_object_unref (font); }
static void gimp_tag_popup_toggle_tag (GimpTagPopup *popup, PopupTagData *tag_data) { gchar **current_tags; GString *tag_str; gint length; gint i; gboolean tag_toggled_off = FALSE; if (tag_data->state == GTK_STATE_NORMAL) { tag_data->state = GTK_STATE_SELECTED; } else if (tag_data->state == GTK_STATE_SELECTED) { tag_data->state = GTK_STATE_NORMAL; } else { return; } current_tags = gimp_tag_entry_parse_tags (GIMP_TAG_ENTRY (popup->combo_entry)); tag_str = g_string_new (""); length = g_strv_length (current_tags); for (i = 0; i < length; i++) { if (! gimp_tag_compare_with_string (tag_data->tag, current_tags[i])) { tag_toggled_off = TRUE; } else { if (tag_str->len) { g_string_append (tag_str, gimp_tag_entry_get_separator ()); g_string_append_c (tag_str, ' '); } g_string_append (tag_str, current_tags[i]); } } if (! tag_toggled_off) { /* this tag was not selected yet, so it needs to be toggled on */ if (tag_str->len) { g_string_append (tag_str, gimp_tag_entry_get_separator ()); g_string_append_c (tag_str, ' '); } g_string_append (tag_str, gimp_tag_get_name (tag_data->tag)); } gimp_tag_entry_set_tag_string (GIMP_TAG_ENTRY (popup->combo_entry), tag_str->str); g_string_free (tag_str, TRUE); g_strfreev (current_tags); if (GIMP_TAG_ENTRY (popup->combo_entry)->mode == GIMP_TAG_ENTRY_MODE_QUERY) { GimpTaggedContainer *container; container = GIMP_TAG_ENTRY (popup->combo_entry)->container; for (i = 0; i < popup->tag_count; i++) { if (popup->tag_data[i].state != GTK_STATE_SELECTED) { popup->tag_data[i].state = GTK_STATE_INSENSITIVE; } } gimp_container_foreach (GIMP_CONTAINER (container), (GFunc) gimp_tag_popup_check_can_toggle, popup); } }
static void gimp_tag_popup_constructed (GObject *object) { GimpTagPopup *popup = GIMP_TAG_POPUP (object); GimpTaggedContainer *container; GtkWidget *entry; GtkAllocation entry_allocation; GtkStyle *frame_style; gint x; gint y; gint width; gint height; gint popup_height; GHashTable *tag_hash; GList *tag_list; GList *tag_iterator; gint i; gint max_height; gint screen_height; gchar **current_tags; gint current_count; GdkRectangle popup_rects[2]; /* variants of popup placement */ GdkRectangle popup_rect; /* best popup rect in screen coordinates */ if (G_OBJECT_CLASS (parent_class)->constructed) G_OBJECT_CLASS (parent_class)->constructed (object); entry = GTK_WIDGET (popup->combo_entry); gtk_window_set_screen (GTK_WINDOW (popup), gtk_widget_get_screen (entry)); popup->context = gtk_widget_create_pango_context (GTK_WIDGET (popup)); popup->layout = pango_layout_new (popup->context); gtk_widget_get_allocation (entry, &entry_allocation); gtk_widget_style_get (GTK_WIDGET (popup), "scroll-arrow-vlength", &popup->scroll_arrow_height, NULL); pango_layout_set_attributes (popup->layout, popup->combo_entry->normal_item_attr); current_tags = gimp_tag_entry_parse_tags (GIMP_TAG_ENTRY (popup->combo_entry)); current_count = g_strv_length (current_tags); container = GIMP_TAG_ENTRY (popup->combo_entry)->container; tag_hash = container->tag_ref_counts; tag_list = g_hash_table_get_keys (tag_hash); tag_list = g_list_sort (tag_list, gimp_tag_compare_func); popup->tag_count = g_list_length (tag_list); popup->tag_data = g_new0 (PopupTagData, popup->tag_count); for (i = 0, tag_iterator = tag_list; i < popup->tag_count; i++, tag_iterator = g_list_next (tag_iterator)) { PopupTagData *tag_data = &popup->tag_data[i]; gint j; tag_data->tag = tag_iterator->data; tag_data->state = GTK_STATE_NORMAL; for (j = 0; j < current_count; j++) { if (! gimp_tag_compare_with_string (tag_data->tag, current_tags[j])) { tag_data->state = GTK_STATE_SELECTED; break; } } } g_list_free (tag_list); g_strfreev (current_tags); if (GIMP_TAG_ENTRY (popup->combo_entry)->mode == GIMP_TAG_ENTRY_MODE_QUERY) { for (i = 0; i < popup->tag_count; i++) { if (popup->tag_data[i].state != GTK_STATE_SELECTED) { popup->tag_data[i].state = GTK_STATE_INSENSITIVE; } } gimp_container_foreach (GIMP_CONTAINER (container), (GFunc) gimp_tag_popup_check_can_toggle, popup); } frame_style = gtk_widget_get_style (popup->frame); width = (entry_allocation.width - 2 * frame_style->xthickness); height = (gimp_tag_popup_layout_tags (popup, width) + 2 * frame_style->ythickness); gdk_window_get_origin (gtk_widget_get_window (entry), &x, &y); max_height = entry_allocation.height * 10; screen_height = gdk_screen_get_height (gtk_widget_get_screen (entry)); popup_height = MIN (height, max_height); popup_rects[0].x = x; popup_rects[0].y = 0; popup_rects[0].width = entry_allocation.width; popup_rects[0].height = y + entry_allocation.height; popup_rects[1].x = x; popup_rects[1].y = y; popup_rects[1].width = popup_rects[0].width; popup_rects[1].height = screen_height - popup_rects[0].height; if (popup_rects[0].height >= popup_height) { popup_rect = popup_rects[0]; popup_rect.y += popup_rects[0].height - popup_height; popup_rect.height = popup_height; } else if (popup_rects[1].height >= popup_height) { popup_rect = popup_rects[1]; popup_rect.height = popup_height; } else { if (popup_rects[0].height >= popup_rects[1].height) { popup_rect = popup_rects[0]; popup_rect.y += popup->scroll_arrow_height + frame_style->ythickness; } else { popup_rect = popup_rects[1]; popup_rect.y -= popup->scroll_arrow_height + frame_style->ythickness; } popup_height = popup_rect.height; } if (popup_height < height) { popup->arrows_visible = TRUE; popup->upper_arrow_state = GTK_STATE_INSENSITIVE; gtk_alignment_set_padding (GTK_ALIGNMENT (popup->alignment), popup->scroll_arrow_height + 2, popup->scroll_arrow_height + 2, 0, 0); popup_height -= 2 * popup->scroll_arrow_height + 4; popup->scroll_height = height - popup_rect.height; popup->scroll_y = 0; popup->scroll_step = 0; } gtk_widget_set_size_request (popup->tag_area, width, popup_height); gtk_window_move (GTK_WINDOW (popup), popup_rect.x, popup_rect.y); gtk_window_resize (GTK_WINDOW (popup), popup_rect.width, popup_rect.height); }
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); }
static void gimp_tagged_container_src_freeze (GimpFilteredContainer *filtered_container) { gimp_container_clear (GIMP_CONTAINER (filtered_container)); }