GimpImage * gimp_image_editor_get_image (GimpImageEditor *editor) { g_return_val_if_fail (GIMP_IS_IMAGE_EDITOR (editor), NULL); return editor->image; }
void gimp_image_editor_set_image (GimpImageEditor *editor, GimpImage *image) { g_return_if_fail (GIMP_IS_IMAGE_EDITOR (editor)); g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image)); if (image != editor->image) { GIMP_IMAGE_EDITOR_GET_CLASS (editor)->set_image (editor, image); if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor))) gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)), gimp_editor_get_popup_data (GIMP_EDITOR (editor))); } }
GimpContext * action_data_get_context (gpointer data) { GimpContext *result = NULL; static gboolean recursion = FALSE; if (! data || recursion) return NULL; recursion = TRUE; if (GIMP_IS_DOCK (data)) result = gimp_dock_get_context ((GimpDock *) data); else if (GIMP_IS_DOCK_WINDOW (data)) result = gimp_dock_window_get_context (((GimpDockWindow *) data)); else if (GIMP_IS_CONTAINER_VIEW (data)) result = gimp_container_view_get_context ((GimpContainerView *) data); else if (GIMP_IS_CONTAINER_EDITOR (data)) result = gimp_container_view_get_context (((GimpContainerEditor *) data)->view); else if (GIMP_IS_IMAGE_EDITOR (data)) result = ((GimpImageEditor *) data)->context; else if (GIMP_IS_NAVIGATION_EDITOR (data)) result = ((GimpNavigationEditor *) data)->context; if (! result) { Gimp *gimp = action_data_get_gimp (data); if (gimp) result = gimp_get_user_context (gimp); } recursion = FALSE; return result; }
GimpImage * action_data_get_image (gpointer data) { GimpImage *result = NULL; static gboolean recursion = FALSE; if (! data || recursion) return NULL; recursion = TRUE; if (GIMP_IS_ITEM_TREE_VIEW (data)) result = gimp_item_tree_view_get_image ((GimpItemTreeView *) data); else if (GIMP_IS_IMAGE_EDITOR (data)) result = ((GimpImageEditor *) data)->image; if (! result) { GimpDisplay *display = action_data_get_display (data); if (display) result = gimp_display_get_image (display); } if (! result) { GimpContext *context = action_data_get_context (data); if (context) result = gimp_context_get_image (context); } recursion = FALSE; return result; }
void plug_in_run_cmd_callback (GtkAction *action, GimpPlugInProcedure *proc, gpointer data) { GimpProcedure *procedure = GIMP_PROCEDURE (proc); Gimp *gimp; GimpValueArray *args; gint n_args = 0; GimpDisplay *display = NULL; return_if_no_gimp (gimp, data); args = gimp_procedure_get_arguments (procedure); /* initialize the first argument */ g_value_set_int (gimp_value_array_index (args, n_args), GIMP_RUN_INTERACTIVE); n_args++; switch (procedure->proc_type) { case GIMP_EXTENSION: break; case GIMP_PLUGIN: case GIMP_TEMPORARY: if (GIMP_IS_DATA_FACTORY_VIEW (data) || GIMP_IS_FONT_VIEW (data) || GIMP_IS_BUFFER_VIEW (data)) { GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data); GimpContainer *container; GimpContext *context; GimpObject *object; container = gimp_container_view_get_container (editor->view); context = gimp_container_view_get_context (editor->view); object = gimp_context_get_by_type (context, gimp_container_get_children_type (container)); n_args = plug_in_collect_data_args (action, object, procedure->args, args, n_args); } else if (GIMP_IS_IMAGE_EDITOR (data)) { GimpImageEditor *editor = GIMP_IMAGE_EDITOR (data); GimpImage *image; image = gimp_image_editor_get_image (editor); n_args = plug_in_collect_image_args (action, image, procedure->args, args, n_args); } else if (GIMP_IS_ITEM_TREE_VIEW (data)) { GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (data); GimpImage *image; GimpItem *item; image = gimp_item_tree_view_get_image (view); if (image) item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (image); else item = NULL; n_args = plug_in_collect_item_args (action, image, item, procedure->args, args, n_args); } else { display = action_data_get_display (data); n_args = plug_in_collect_display_args (action, display, procedure->args, args, n_args); } break; case GIMP_INTERNAL: g_warning ("Unhandled procedure type."); n_args = -1; break; } if (n_args >= 1) plug_in_procedure_execute (proc, gimp, display, args, n_args); gimp_value_array_unref (args); }