GimpDisplay * action_data_get_display (gpointer data) { GimpDisplay *result = NULL; static gboolean recursion = FALSE; if (! data || recursion) return NULL; recursion = TRUE; if (GIMP_IS_DISPLAY (data)) result = data; else if (GIMP_IS_IMAGE_WINDOW (data)) { GimpDisplayShell *shell = gimp_image_window_get_active_shell (data); result = shell ? shell->display : NULL; } if (! result) { GimpContext *context = action_data_get_context (data); if (context) result = gimp_context_get_display (context); } recursion = FALSE; return result; }
static void gimp_navigation_editor_set_context (GimpDocked *docked, GimpContext *context) { GimpNavigationEditor *editor = GIMP_NAVIGATION_EDITOR (docked); GimpDisplay *display = NULL; if (editor->context) { g_signal_handlers_disconnect_by_func (editor->context, gimp_navigation_editor_display_changed, editor); } editor->context = context; if (editor->context) { g_signal_connect (context, "display-changed", G_CALLBACK (gimp_navigation_editor_display_changed), editor); display = gimp_context_get_display (context); } gimp_view_renderer_set_context (GIMP_VIEW (editor->view)->renderer, context); gimp_navigation_editor_display_changed (editor->context, display, editor); }
/* This function is called for filenames passed on the command-line * or from the D-Bus service. */ gboolean file_open_from_command_line (Gimp *gimp, GFile *file, gboolean as_new, GObject *screen, gint monitor) { GimpImage *image; GimpObject *display; GimpPDBStatusType status; gboolean success = FALSE; GError *error = NULL; g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE); g_return_val_if_fail (screen == NULL || G_IS_OBJECT (screen), FALSE); display = gimp_get_empty_display (gimp); /* show the progress in the last opened display, see bug #704896 */ if (! display) display = gimp_context_get_display (gimp_get_user_context (gimp)); if (display) g_object_add_weak_pointer (G_OBJECT (display), (gpointer) &display); image = file_open_with_display (gimp, gimp_get_user_context (gimp), GIMP_PROGRESS (display), file, as_new, screen, monitor, &status, &error); if (image) { success = TRUE; g_object_set_data_full (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_FILE_KEY, g_object_ref (file), (GDestroyNotify) g_object_unref); } else if (status != GIMP_PDB_CANCEL && display) { gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR, _("Opening '%s' failed: %s"), gimp_file_get_utf8_name (file), error->message); g_clear_error (&error); } if (display) g_object_remove_weak_pointer (G_OBJECT (display), (gpointer) &display); return success; }
void vectors_selection_to_vectors_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpImage *image; GtkWidget *widget; GimpProcedure *procedure; GimpValueArray *args; GimpDisplay *display; GError *error = NULL; return_if_no_image (image, data); return_if_no_widget (widget, data); if (value) procedure = gimp_pdb_lookup_procedure (image->gimp->pdb, "plug-in-sel2path-advanced"); else procedure = gimp_pdb_lookup_procedure (image->gimp->pdb, "plug-in-sel2path"); if (! procedure) { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR, "Selection to path procedure lookup failed."); return; } display = gimp_context_get_display (action_data_get_context (data)); args = gimp_procedure_get_arguments (procedure); gimp_value_array_truncate (args, 2); g_value_set_int (gimp_value_array_index (args, 0), GIMP_RUN_INTERACTIVE); gimp_value_set_image (gimp_value_array_index (args, 1), image); gimp_procedure_execute_async (procedure, image->gimp, action_data_get_context (data), GIMP_PROGRESS (display), args, GIMP_OBJECT (display), &error); gimp_value_array_unref (args); if (error) { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR, error->message); g_error_free (error); } }
static void gui_menu_hide_tooltip (GimpUIManager *manager, Gimp *gimp) { GimpContext *context = gimp_get_user_context (gimp); GimpDisplay *display = gimp_context_get_display (context); if (display) { GimpDisplayShell *shell = gimp_display_get_shell (display); GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell); gimp_statusbar_pop (statusbar, "menu-tooltip"); } }
static void gui_menu_show_tooltip (GimpUIManager *manager, const gchar *tooltip, Gimp *gimp) { GimpContext *context = gimp_get_user_context (gimp); GimpDisplay *display = gimp_context_get_display (context); if (display) { GimpDisplayShell *shell = gimp_display_get_shell (display); GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell); gimp_statusbar_push (statusbar, "menu-tooltip", NULL, "%s", tooltip); } }
static void buffers_paste (GimpBufferView *view, gboolean paste_into) { GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (view); GimpContainer *container; GimpContext *context; GimpBuffer *buffer; container = gimp_container_view_get_container (editor->view); context = gimp_container_view_get_context (editor->view); buffer = gimp_context_get_buffer (context); if (buffer && gimp_container_have (container, GIMP_OBJECT (buffer))) { GimpDisplay *display = gimp_context_get_display (context); GimpImage *image = NULL; gint x = -1; gint y = -1; gint width = -1; gint height = -1; if (display) { GimpDisplayShell *shell = gimp_display_get_shell (display); gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height); image = gimp_display_get_image (display); } else { image = gimp_context_get_image (context); } if (image) { gimp_edit_paste (image, gimp_image_get_active_drawable (image), buffer, paste_into, x, y, width, height); gimp_image_flush (image); } } }
void tools_select_cmd_callback (GtkAction *action, const gchar *value, gpointer data) { Gimp *gimp; GimpToolInfo *tool_info; GimpContext *context; GimpDisplay *display; gboolean rotate_layer = FALSE; return_if_no_gimp (gimp, data); /* special case gimp-rotate-tool being called from the Layer menu */ if (strcmp (value, "gimp-rotate-layer") == 0) { rotate_layer = TRUE; value = "gimp-rotate-tool"; } tool_info = gimp_get_tool_info (gimp, value); context = gimp_get_user_context (gimp); /* always allocate a new tool when selected from the image menu */ if (gimp_context_get_tool (context) != tool_info) { gimp_context_set_tool (context, tool_info); if (rotate_layer) g_object_set (tool_info->tool_options, "type", GIMP_TRANSFORM_TYPE_LAYER, NULL); } else { gimp_context_tool_changed (context); } display = gimp_context_get_display (context); if (display && gimp_display_get_image (display)) tool_manager_initialize_active (gimp, display); }
static GimpObject * gui_display_create (Gimp *gimp, GimpImage *image, GimpUnit unit, gdouble scale) { GimpContext *context = gimp_get_user_context (gimp); GimpDisplay *display = GIMP_DISPLAY (gui_get_empty_display (gimp)); if (display) { gimp_display_fill (display, image, unit, scale); } else { GList *image_managers = gimp_ui_managers_from_name ("<Image>"); g_return_val_if_fail (image_managers != NULL, NULL); display = gimp_display_new (gimp, image, unit, scale, global_menu_factory, image_managers->data, global_display_factory); } if (gimp_context_get_display (context) == display) { gimp_context_set_image (context, image); gimp_context_display_changed (context); } else { gimp_context_set_display (context, display); } gimp_ui_manager_update (GIMP_DISPLAY_SHELL (display->shell)->menubar_manager, display); return GIMP_OBJECT (display); }
void gimp_display_shell_set_action_active (GimpDisplayShell *shell, const gchar *action, gboolean active) { GimpImageWindow *window; GimpContext *context; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); g_return_if_fail (action != NULL); window = gimp_display_shell_get_window (shell); if (window && gimp_image_window_get_active_shell (window) == shell) { GimpUIManager *manager = gimp_image_window_get_ui_manager (window); GimpActionGroup *action_group; action_group = gimp_ui_manager_get_action_group (manager, "view"); if (action_group) gimp_action_group_set_action_active (action_group, action, active); } context = gimp_get_user_context (shell->display->gimp); if (shell->display == gimp_context_get_display (context)) { GimpActionGroup *action_group; action_group = gimp_ui_manager_get_action_group (shell->popup_manager, "view"); if (action_group) gimp_action_group_set_action_active (action_group, action, active); } }