static void gimp_container_popup_confirm (GimpPopup *popup) { GimpContainerPopup *c_popup = GIMP_CONTAINER_POPUP (popup); GimpObject *object; object = gimp_context_get_by_type (c_popup->context, gimp_container_get_children_type (c_popup->container)); gimp_context_set_by_type (c_popup->orig_context, gimp_container_get_children_type (c_popup->container), object); GIMP_POPUP_CLASS (parent_class)->confirm (popup); }
static void context_select_object (GimpActionSelectType select_type, GimpContext *context, GimpContainer *container) { GimpObject *current; current = gimp_context_get_by_type (context, gimp_container_get_children_type (container)); current = action_select_object (select_type, container, current); if (current) gimp_context_set_by_type (context, gimp_container_get_children_type (container), current); }
static void gimp_container_popup_real_confirm (GimpContainerPopup *popup) { GtkWidget *widget = GTK_WIDGET (popup); GimpObject *object; object = gimp_context_get_by_type (popup->context, gimp_container_get_children_type (popup->container)); gimp_context_set_by_type (popup->orig_context, gimp_container_get_children_type (popup->container), object); if (gtk_grab_get_current () == widget) gtk_grab_remove (widget); gtk_widget_destroy (widget); }
static void data_delete_dialog_response (GtkWidget *dialog, gint response_id, DataDeleteDialog *delete_data) { gtk_widget_destroy (dialog); if (response_id == GTK_RESPONSE_OK) { GimpDataFactory *factory = delete_data->factory; GimpData *data = delete_data->data; GimpContainer *container; GimpObject *new_active = NULL; GError *error = NULL; container = gimp_data_factory_get_container (factory); if (delete_data->context && GIMP_OBJECT (data) == gimp_context_get_by_type (delete_data->context, gimp_container_get_children_type (container))) { new_active = gimp_container_get_neighbor_of (container, GIMP_OBJECT (data)); } if (! gimp_data_factory_data_delete (factory, data, TRUE, &error)) { gimp_message (gimp_data_factory_get_gimp (factory), G_OBJECT (delete_data->parent), GIMP_MESSAGE_ERROR, "%s", error->message); g_clear_error (&error); } if (new_active) gimp_context_set_by_type (delete_data->context, gimp_container_get_children_type (container), new_active); } g_slice_free (DataDeleteDialog, delete_data); }
static void gimp_data_editor_set_context (GimpDocked *docked, GimpContext *context) { GimpDataEditor *editor = GIMP_DATA_EDITOR (docked); if (context == editor->context) return; if (parent_docked_iface->set_context) parent_docked_iface->set_context (docked, context); if (editor->context) { g_signal_handlers_disconnect_by_func (editor->context, gimp_data_editor_data_changed, editor); g_object_unref (editor->context); } editor->context = context; if (editor->context) { GType data_type; GimpData *data; g_object_ref (editor->context); data_type = gimp_data_factory_get_data_type (editor->data_factory); data = GIMP_DATA (gimp_context_get_by_type (editor->context, data_type)); g_signal_connect (editor->context, gimp_context_type_to_signal_name (data_type), G_CALLBACK (gimp_data_editor_data_changed), editor); gimp_data_editor_data_changed (editor->context, data, editor); } }
void gimp_data_editor_set_edit_active (GimpDataEditor *editor, gboolean edit_active) { g_return_if_fail (GIMP_IS_DATA_EDITOR (editor)); if (editor->edit_active != edit_active) { editor->edit_active = edit_active; if (editor->edit_active && editor->context) { GType data_type; GimpData *data; data_type = gimp_data_factory_get_data_type (editor->data_factory); data = GIMP_DATA (gimp_context_get_by_type (editor->context, data_type)); gimp_data_editor_set_data (editor, data); } } }
gboolean gimp_container_editor_construct (GimpContainerEditor *editor, GimpViewType view_type, GimpContainer *container, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory, const gchar *menu_identifier, const gchar *ui_identifier) { g_return_val_if_fail (GIMP_IS_CONTAINER_EDITOR (editor), FALSE); g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE); g_return_val_if_fail (GIMP_IS_CONTEXT (context), 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); g_return_val_if_fail (menu_factory == NULL || GIMP_IS_MENU_FACTORY (menu_factory), FALSE); switch (view_type) { case GIMP_VIEW_TYPE_GRID: #if 0 editor->view = GIMP_CONTAINER_VIEW (gimp_container_icon_view_new (container, context, view_size, view_border_width)); #else editor->view = GIMP_CONTAINER_VIEW (gimp_container_grid_view_new (container, context, view_size, view_border_width)); #endif break; case GIMP_VIEW_TYPE_LIST: editor->view = GIMP_CONTAINER_VIEW (gimp_container_tree_view_new (container, context, view_size, view_border_width)); break; default: g_warning ("%s: unknown GimpViewType passed", G_STRFUNC); return FALSE; } if (GIMP_IS_LIST (container)) gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (editor->view), ! GIMP_LIST (container)->sort_func); if (menu_factory && menu_identifier && ui_identifier) gimp_editor_create_menu (GIMP_EDITOR (editor->view), menu_factory, menu_identifier, ui_identifier, editor); gtk_box_pack_start (GTK_BOX (editor), GTK_WIDGET (editor->view), TRUE, TRUE, 0); gtk_widget_show (GTK_WIDGET (editor->view)); g_signal_connect_object (editor->view, "select-item", G_CALLBACK (gimp_container_editor_select_item), editor, 0); g_signal_connect_object (editor->view, "activate-item", G_CALLBACK (gimp_container_editor_activate_item), editor, 0); g_signal_connect_object (editor->view, "context-item", G_CALLBACK (gimp_container_editor_context_item), editor, 0); { GimpObject *object = gimp_context_get_by_type (context, gimp_container_get_children_type (container)); gimp_container_editor_select_item (GTK_WIDGET (editor->view), (GimpViewable *) object, NULL, 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); }
static gboolean gui_pdb_dialog_new (Gimp *gimp, GimpContext *context, GimpProgress *progress, GimpContainer *container, const gchar *title, const gchar *callback_name, const gchar *object_name, va_list args) { GType dialog_type = G_TYPE_NONE; const gchar *dialog_role = NULL; const gchar *help_id = NULL; if (gimp_container_get_children_type (container) == GIMP_TYPE_BRUSH) { dialog_type = GIMP_TYPE_BRUSH_SELECT; dialog_role = "gimp-brush-selection"; help_id = GIMP_HELP_BRUSH_DIALOG; } else if (gimp_container_get_children_type (container) == GIMP_TYPE_FONT) { dialog_type = GIMP_TYPE_FONT_SELECT; dialog_role = "gimp-font-selection"; help_id = GIMP_HELP_FONT_DIALOG; } else if (gimp_container_get_children_type (container) == GIMP_TYPE_GRADIENT) { dialog_type = GIMP_TYPE_GRADIENT_SELECT; dialog_role = "gimp-gradient-selection"; help_id = GIMP_HELP_GRADIENT_DIALOG; } else if (gimp_container_get_children_type (container) == GIMP_TYPE_PALETTE) { dialog_type = GIMP_TYPE_PALETTE_SELECT; dialog_role = "gimp-palette-selection"; help_id = GIMP_HELP_PALETTE_DIALOG; } else if (gimp_container_get_children_type (container) == GIMP_TYPE_PATTERN) { dialog_type = GIMP_TYPE_PATTERN_SELECT; dialog_role = "gimp-pattern-selection"; help_id = GIMP_HELP_PATTERN_DIALOG; } if (dialog_type != G_TYPE_NONE) { GimpObject *object = NULL; if (object_name && strlen (object_name)) object = gimp_container_get_child_by_name (container, object_name); if (! object) object = gimp_context_get_by_type (context, gimp_container_get_children_type (container)); if (object) { GParameter *params = NULL; gint n_params = 0; GtkWidget *dialog; GtkWidget *view; params = gimp_parameters_append (dialog_type, params, &n_params, "title", title, "role", dialog_role, "help-func", gimp_standard_help_func, "help-id", help_id, "pdb", gimp->pdb, "context", context, "select-type", gimp_container_get_children_type (container), "initial-object", object, "callback-name", callback_name, "menu-factory", global_menu_factory, NULL); params = gimp_parameters_append_valist (dialog_type, params, &n_params, args); dialog = g_object_newv (dialog_type, n_params, params); gimp_parameters_free (params, n_params); view = GIMP_PDB_DIALOG (dialog)->view; if (view) gimp_docked_set_show_button_bar (GIMP_DOCKED (view), FALSE); if (progress) { guint32 window_id = gimp_progress_get_window_id (progress); if (window_id) gimp_window_set_transient_for (GTK_WINDOW (dialog), window_id); } gtk_widget_show (dialog); /* workaround for bug #360106 */ { GSource *source = g_timeout_source_new (100); GClosure *closure; closure = g_cclosure_new_object (G_CALLBACK (gui_pdb_dialog_present), G_OBJECT (dialog)); g_source_set_closure (source, closure); g_source_attach (source, NULL); g_source_unref (source); } return TRUE; } } return FALSE; }