void dialogs_load_recent_docks (Gimp *gimp) { gchar *filename; GError *error = NULL; g_return_if_fail (GIMP_IS_GIMP (gimp)); filename = dialogs_get_dockrc_filename (); if (gimp->be_verbose) g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename)); if (! gimp_config_deserialize_file (GIMP_CONFIG (global_recent_docks), filename, NULL, &error)) { if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT) gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); } /* In GIMP 2.6 dockrc did not contain the factory entries for the * session infos, so set that up manually if needed */ gimp_container_foreach (global_recent_docks, (GFunc) dialogs_ensure_factory_entry_on_recent_dock, NULL); gimp_list_reverse (GIMP_LIST (global_recent_docks)); g_free (filename); }
void documents_raise_or_open_cmd_callback (GtkAction *action, gpointer data) { GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data); GimpContext *context; GimpContainer *container; GimpImagefile *imagefile; context = gimp_container_view_get_context (editor->view); container = gimp_container_view_get_container (editor->view); imagefile = gimp_context_get_imagefile (context); if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile))) { RaiseClosure closure; closure.name = gimp_object_get_name (imagefile); closure.found = FALSE; gimp_container_foreach (context->gimp->displays, (GFunc) documents_raise_display, &closure); if (! closure.found) documents_open_image (GTK_WIDGET (editor), context, imagefile); } }
static GValueArray * displays_flush_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gimp_container_foreach (gimp->images, (GFunc) gimp_image_flush, NULL); return gimp_procedure_get_return_values (procedure, TRUE); }
void documents_remove_dangling_cmd_callback (GtkAction *action, gpointer data) { GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data); GimpContainer *container; container = gimp_container_view_get_container (editor->view); gimp_container_foreach (container, (GFunc) documents_remove_dangling_foreach, container); }
void documents_reload_previews_cmd_callback (GtkAction *action, gpointer data) { GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data); GimpContainer *container; container = gimp_container_view_get_container (editor->view); gimp_container_foreach (container, (GFunc) gimp_imagefile_update, editor->view); }
void gimp_paint_exit (Gimp *gimp) { g_return_if_fail (GIMP_IS_GIMP (gimp)); gimp_paint_info_set_standard (gimp, NULL); if (gimp->paint_info_list) { gimp_container_foreach (gimp->paint_info_list, (GFunc) g_object_run_dispose, NULL); g_object_unref (gimp->paint_info_list); gimp->paint_info_list = NULL; } }
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); }
static void gimp_finalize (GObject *object) { Gimp *gimp = GIMP (object); GList *standards = NULL; if (gimp->be_verbose) g_print ("EXIT: %s\n", G_STRFUNC); standards = g_list_prepend (standards, gimp_brush_get_standard (gimp->user_context)); standards = g_list_prepend (standards, gimp_dynamics_get_standard (gimp->user_context)); standards = g_list_prepend (standards, gimp_mybrush_get_standard (gimp->user_context)); standards = g_list_prepend (standards, gimp_pattern_get_standard (gimp->user_context)); standards = g_list_prepend (standards, gimp_gradient_get_standard (gimp->user_context)); standards = g_list_prepend (standards, gimp_palette_get_standard (gimp->user_context)); gimp_contexts_exit (gimp); if (gimp->image_new_last_template) { g_object_unref (gimp->image_new_last_template); gimp->image_new_last_template = NULL; } if (gimp->templates) { g_object_unref (gimp->templates); gimp->templates = NULL; } if (gimp->documents) { g_object_unref (gimp->documents); gimp->documents = NULL; } gimp_tool_info_set_standard (gimp, NULL); if (gimp->tool_info_list) { gimp_container_foreach (gimp->tool_info_list, (GFunc) g_object_run_dispose, NULL); g_object_unref (gimp->tool_info_list); gimp->tool_info_list = NULL; } xcf_exit (gimp); if (gimp->pdb) { g_object_unref (gimp->pdb); gimp->pdb = NULL; } if (gimp->brush_factory) { g_object_unref (gimp->brush_factory); gimp->brush_factory = NULL; } if (gimp->dynamics_factory) { g_object_unref (gimp->dynamics_factory); gimp->dynamics_factory = NULL; } if (gimp->mybrush_factory) { g_object_unref (gimp->mybrush_factory); gimp->mybrush_factory = NULL; } if (gimp->pattern_factory) { g_object_unref (gimp->pattern_factory); gimp->pattern_factory = NULL; } if (gimp->gradient_factory) { g_object_unref (gimp->gradient_factory); gimp->gradient_factory = NULL; } if (gimp->palette_factory) { g_object_unref (gimp->palette_factory); gimp->palette_factory = NULL; } if (gimp->tool_preset_factory) { g_object_unref (gimp->tool_preset_factory); gimp->tool_preset_factory = NULL; } if (gimp->tag_cache) { g_object_unref (gimp->tag_cache); gimp->tag_cache = NULL; } if (gimp->fonts) { g_object_unref (gimp->fonts); gimp->fonts = NULL; } if (gimp->named_buffers) { g_object_unref (gimp->named_buffers); gimp->named_buffers = NULL; } if (gimp->global_buffer) { g_object_unref (gimp->global_buffer); gimp->global_buffer = NULL; } if (gimp->displays) { g_object_unref (gimp->displays); gimp->displays = NULL; } if (gimp->item_table) { g_object_unref (gimp->item_table); gimp->item_table = NULL; } if (gimp->image_table) { g_object_unref (gimp->image_table); gimp->image_table = NULL; } if (gimp->images) { g_object_unref (gimp->images); gimp->images = NULL; } if (gimp->plug_in_manager) { g_object_unref (gimp->plug_in_manager); gimp->plug_in_manager = NULL; } if (gimp->module_db) gimp_modules_exit (gimp); gimp_paint_exit (gimp); if (gimp->parasites) { g_object_unref (gimp->parasites); gimp->parasites = NULL; } if (gimp->edit_config) { g_object_unref (gimp->edit_config); gimp->edit_config = NULL; } if (gimp->default_folder) { g_object_unref (gimp->default_folder); gimp->default_folder = NULL; } if (gimp->session_name) { g_free (gimp->session_name); gimp->session_name = NULL; } if (gimp->context_list) { GList *list; g_warning ("%s: list of contexts not empty upon exit (%d contexts left)\n", G_STRFUNC, g_list_length (gimp->context_list)); for (list = gimp->context_list; list; list = g_list_next (list)) g_printerr ("stale context: %s\n", gimp_object_get_name (list->data)); g_list_free (gimp->context_list); gimp->context_list = NULL; } g_list_foreach (standards, (GFunc) g_object_unref, NULL); g_list_free (standards); gimp_units_exit (gimp); G_OBJECT_CLASS (parent_class)->finalize (object); }