gboolean gimp_data_factory_view_construct (GimpDataFactoryView *factory_view, GimpViewType view_type, GimpDataFactory *factory, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory, const gchar *menu_identifier, const gchar *ui_identifier, const gchar *action_group) { GimpContainerEditor *editor; gchar *str; g_return_val_if_fail (GIMP_IS_DATA_FACTORY_VIEW (factory_view), FALSE); g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), FALSE); g_return_val_if_fail (view_size > 0 && view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, FALSE); g_return_val_if_fail (view_border_width >= 0 && view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH, FALSE); factory_view->factory = factory; if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (factory_view), view_type, factory->container, context, view_size, view_border_width, menu_factory, menu_identifier, ui_identifier)) { return FALSE; } editor = GIMP_CONTAINER_EDITOR (factory_view); if (GIMP_IS_CONTAINER_TREE_VIEW (editor->view)) { GimpContainerTreeView *tree_view; tree_view = GIMP_CONTAINER_TREE_VIEW (editor->view); gimp_container_tree_view_connect_name_edited (tree_view, G_CALLBACK (gimp_data_factory_view_tree_name_edited), factory_view); } str = g_strdup_printf ("%s-edit", action_group); factory_view->edit_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group, str, NULL); g_free (str); if (factory_view->factory->data_new_func) { str = g_strdup_printf ("%s-new", action_group); factory_view->new_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group, str, NULL); g_free (str); } str = g_strdup_printf ("%s-duplicate", action_group); factory_view->duplicate_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group, str, NULL); g_free (str); str = g_strdup_printf ("%s-delete", action_group); factory_view->delete_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group, str, NULL); g_free (str); str = g_strdup_printf ("%s-refresh", action_group); factory_view->refresh_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group, str, NULL); g_free (str); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (factory_view->edit_button), factory->container->children_type); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (factory_view->duplicate_button), factory->container->children_type); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (factory_view->delete_button), factory->container->children_type); gimp_ui_manager_update (GIMP_EDITOR (editor->view)->ui_manager, editor); return TRUE; }
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); }