void gimp_text_editor_set_direction (GimpTextEditor *editor, GimpTextDirection base_dir) { g_return_if_fail (GIMP_IS_TEXT_EDITOR (editor)); if (editor->base_dir == base_dir) return; editor->base_dir = base_dir; if (editor->view) { switch (editor->base_dir) { case GIMP_TEXT_DIRECTION_LTR: case GIMP_TEXT_DIRECTION_TTB_RTL: case GIMP_TEXT_DIRECTION_TTB_RTL_UPRIGHT: case GIMP_TEXT_DIRECTION_TTB_LTR: case GIMP_TEXT_DIRECTION_TTB_LTR_UPRIGHT: gtk_widget_set_direction (editor->view, GTK_TEXT_DIR_LTR); break; case GIMP_TEXT_DIRECTION_RTL: gtk_widget_set_direction (editor->view, GTK_TEXT_DIR_RTL); break; } } gimp_ui_manager_update (editor->ui_manager, editor); g_signal_emit (editor, text_editor_signals[DIR_CHANGED], 0); }
static void palette_editor_entry_selected (GimpPaletteView *view, GimpPaletteEntry *entry, GimpPaletteEditor *editor) { GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor); if (editor->color != entry) { editor->color = entry; g_signal_handlers_block_by_func (editor->color_name, palette_editor_color_name_changed, editor); gtk_entry_set_text (GTK_ENTRY (editor->color_name), entry ? entry->name : _("Undefined")); g_signal_handlers_unblock_by_func (editor->color_name, palette_editor_color_name_changed, editor); gtk_editable_set_editable (GTK_EDITABLE (editor->color_name), entry && data_editor->data_editable); gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)), gimp_editor_get_popup_data (GIMP_EDITOR (editor))); } }
static void gradient_editor_right_color_update (GimpColorDialog *dialog, const GimpRGB *color, GimpColorDialogState state, GimpGradientEditor *editor) { GimpGradient *gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data); switch (state) { case GIMP_COLOR_DIALOG_UPDATE: gimp_gradient_segment_range_blend (gradient, editor->control_sel_l, editor->control_sel_r, &editor->control_sel_l->left_color, color, TRUE, TRUE); break; case GIMP_COLOR_DIALOG_OK: gimp_gradient_segment_range_blend (gradient, editor->control_sel_l, editor->control_sel_r, &editor->control_sel_l->left_color, color, TRUE, TRUE); gimp_gradient_segments_free (editor->right_saved_segments); gtk_widget_destroy (editor->color_dialog); editor->color_dialog = NULL; gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE); gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager, GIMP_EDITOR (editor)->popup_data); break; case GIMP_COLOR_DIALOG_CANCEL: gradient_editor_replace_selection (editor, editor->right_saved_segments); if (! editor->right_saved_dirty) gimp_data_clean (GIMP_DATA (gradient)); gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gradient)); gtk_widget_destroy (editor->color_dialog); editor->color_dialog = NULL; gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE); gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager, GIMP_EDITOR (editor)->popup_data); break; } }
static void gimp_navigation_editor_set_shell (GimpNavigationEditor *editor, GimpDisplayShell *shell) { g_return_if_fail (GIMP_IS_NAVIGATION_EDITOR (editor)); g_return_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell)); if (shell == editor->shell) return; if (editor->shell) { g_signal_handlers_disconnect_by_func (editor->shell, gimp_navigation_editor_shell_scaled, editor); g_signal_handlers_disconnect_by_func (editor->shell, gimp_navigation_editor_shell_scrolled, editor); g_signal_handlers_disconnect_by_func (editor->shell, gimp_navigation_editor_shell_reconnect, editor); } else if (shell) { gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE); } editor->shell = shell; if (editor->shell) { GimpImage *image = gimp_display_get_image (shell->display); gimp_view_set_viewable (GIMP_VIEW (editor->view), GIMP_VIEWABLE (image)); g_signal_connect (editor->shell, "scaled", G_CALLBACK (gimp_navigation_editor_shell_scaled), editor); g_signal_connect (editor->shell, "scrolled", G_CALLBACK (gimp_navigation_editor_shell_scrolled), editor); g_signal_connect (editor->shell, "reconnect", G_CALLBACK (gimp_navigation_editor_shell_reconnect), editor); gimp_navigation_editor_shell_scaled (editor->shell, editor); } else { gimp_view_set_viewable (GIMP_VIEW (editor->view), NULL); gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE); } 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))); }
static void gimp_image_editor_image_flush (GimpImage *image, gboolean invalidate_preview, GimpImageEditor *editor) { 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))); }
static void gimp_navigation_editor_shell_scrolled (GimpDisplayShell *shell, GimpNavigationEditor *editor) { gimp_navigation_editor_update_marker (editor); 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))); }
static void gimp_navigation_editor_shell_reconnect (GimpDisplayShell *shell, GimpNavigationEditor *editor) { GimpImage *image = gimp_display_get_image (shell->display); gimp_view_set_viewable (GIMP_VIEW (editor->view), GIMP_VIEWABLE (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))); }
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))); } }
GtkWidget * gimp_font_view_new (GimpViewType view_type, GimpContainer *container, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory) { GimpFontView *font_view; GimpContainerEditor *editor; g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (view_size > 0 && view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL); g_return_val_if_fail (view_border_width >= 0 && view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH, NULL); g_return_val_if_fail (menu_factory == NULL || GIMP_IS_MENU_FACTORY (menu_factory), NULL); font_view = g_object_new (GIMP_TYPE_FONT_VIEW, "view-type", view_type, "container", container, "context", context, "view-size", view_size, "view-border-width", view_border_width, "menu-factory", menu_factory, "menu-identifier", "<Fonts>", "ui-path", "/fonts-popup", NULL); editor = GIMP_CONTAINER_EDITOR (font_view); gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (editor->view), FALSE); font_view->refresh_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "fonts", "fonts-refresh", NULL); gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor->view)), editor); return GTK_WIDGET (font_view); }
static gboolean gimp_container_editor_select_item (GtkWidget *widget, GimpViewable *viewable, gpointer insert_data, GimpContainerEditor *editor) { GimpContainerEditorClass *klass = GIMP_CONTAINER_EDITOR_GET_CLASS (editor); if (klass->select_item) klass->select_item (editor, viewable); if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor->view))) gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor->view)), gimp_editor_get_popup_data (GIMP_EDITOR (editor->view))); return TRUE; }
gboolean gimp_editor_popup_menu (GimpEditor *editor, GimpMenuPositionFunc position_func, gpointer position_data) { g_return_val_if_fail (GIMP_IS_EDITOR (editor), FALSE); if (editor->ui_manager && editor->ui_path) { gimp_ui_manager_update (editor->ui_manager, editor->popup_data); gimp_ui_manager_ui_popup (editor->ui_manager, editor->ui_path, GTK_WIDGET (editor), position_func, position_data, NULL, NULL); return TRUE; } return FALSE; }
void gimp_data_editor_set_data (GimpDataEditor *editor, GimpData *data) { g_return_if_fail (GIMP_IS_DATA_EDITOR (editor)); g_return_if_fail (data == NULL || GIMP_IS_DATA (data)); g_return_if_fail (data == NULL || g_type_is_a (G_TYPE_FROM_INSTANCE (data), gimp_data_factory_get_data_type (editor->data_factory))); if (editor->data != data) { GIMP_DATA_EDITOR_GET_CLASS (editor)->set_data (editor, data); g_object_notify (G_OBJECT (editor), "data"); 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))); } }
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); }
static void gradient_editor_replicate_response (GtkWidget *widget, gint response_id, GimpGradientEditor *editor) { gtk_widget_destroy (widget); gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE); gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager, GIMP_EDITOR (editor)->popup_data); if (response_id == GTK_RESPONSE_OK) { GimpGradient *gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data); gimp_gradient_segment_range_replicate (gradient, editor->control_sel_l, editor->control_sel_r, editor->replicate_times, &editor->control_sel_l, &editor->control_sel_r); } }
static void gimp_navigation_editor_shell_scaled (GimpDisplayShell *shell, GimpNavigationEditor *editor) { if (editor->zoom_label) { gchar *str; g_object_get (shell->zoom, "percentage", &str, NULL); gtk_label_set_text (GTK_LABEL (editor->zoom_label), str); g_free (str); } if (editor->zoom_adjustment) { gdouble val; val = log (gimp_zoom_model_get_factor (shell->zoom)) / G_LN2; g_signal_handlers_block_by_func (editor->zoom_adjustment, gimp_navigation_editor_zoom_adj_changed, editor); gtk_adjustment_set_value (editor->zoom_adjustment, val); g_signal_handlers_unblock_by_func (editor->zoom_adjustment, gimp_navigation_editor_zoom_adj_changed, editor); } gimp_navigation_editor_update_marker (editor); 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))); }
void gradient_editor_left_color_cmd_callback (GtkAction *action, gpointer data) { GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data); GimpGradient *gradient; gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data); editor->left_saved_dirty = gimp_data_is_dirty (GIMP_DATA (gradient)); editor->left_saved_segments = gradient_editor_save_selection (editor); editor->color_dialog = gimp_color_dialog_new (GIMP_VIEWABLE (gradient), GIMP_DATA_EDITOR (editor)->context, _("Left Endpoint Color"), GIMP_STOCK_GRADIENT, _("Gradient Segment's Left Endpoint Color"), GTK_WIDGET (editor), gimp_dialog_factory_get_singleton (), "gimp-gradient-editor-color-dialog", &editor->control_sel_l->left_color, TRUE, TRUE); g_signal_connect (editor->color_dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &editor->color_dialog); g_signal_connect (editor->color_dialog, "update", G_CALLBACK (gradient_editor_left_color_update), editor); gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE); gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager, GIMP_EDITOR (editor)->popup_data); gtk_window_present (GTK_WINDOW (editor->color_dialog)); }
static void gui_display_changed (GimpContext *context, GimpDisplay *display, Gimp *gimp) { if (! display) { GimpImage *image = gimp_context_get_image (context); if (image) { GList *list; for (list = gimp_get_display_iter (gimp); list; list = g_list_next (list)) { GimpDisplay *display2 = list->data; if (gimp_display_get_image (display2) == image) { gimp_context_set_display (context, display2); /* stop the emission of the original signal * (the emission of the recursive signal is finished) */ g_signal_stop_emission_by_name (context, "display-changed"); return; } } gimp_context_set_image (context, NULL); } } gimp_ui_manager_update (image_ui_manager, display); }
GtkWidget * gimp_document_view_new (GimpViewType view_type, GimpContainer *container, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory) { GimpDocumentView *document_view; GimpContainerEditor *editor; g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); 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), NULL); document_view = g_object_new (GIMP_TYPE_DOCUMENT_VIEW, "view-type", view_type, "container", container, "context", context, "view-size", view_size, "view-border-width", view_border_width, "menu-factory", menu_factory, "menu-identifier", "<Documents>", "ui-path", "/documents-popup", NULL); editor = GIMP_CONTAINER_EDITOR (document_view); document_view->open_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "documents", "documents-open", "documents-raise-or-open", GDK_SHIFT_MASK, "documents-file-open-dialog", gimp_get_toggle_behavior_mask (), NULL); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (document_view->open_button), GIMP_TYPE_IMAGEFILE); document_view->remove_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "documents", "documents-remove", NULL); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (document_view->remove_button), GIMP_TYPE_IMAGEFILE); gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "documents", "documents-clear", NULL); document_view->refresh_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "documents", "documents-recreate-preview", "documents-reload-previews", GDK_SHIFT_MASK, "documents-remove-dangling", gimp_get_toggle_behavior_mask (), NULL); if (view_type == GIMP_VIEW_TYPE_LIST) { GtkWidget *dnd_widget; dnd_widget = gimp_container_view_get_dnd_widget (editor->view); gimp_dnd_uri_list_source_add (dnd_widget, gimp_document_view_drag_uri_list, editor); } gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor->view)), editor); return GTK_WIDGET (document_view); }
GtkWidget * gimp_buffer_view_new (GimpViewType view_type, GimpContainer *container, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory) { GimpBufferView *buffer_view; GimpContainerEditor *editor; GtkWidget *frame; GtkWidget *hbox; buffer_view = g_object_new (GIMP_TYPE_BUFFER_VIEW, NULL); if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (buffer_view), view_type, container, context, view_size, view_border_width, menu_factory, "<Buffers>", "/buffers-popup")) { g_object_unref (buffer_view); return NULL; } editor = GIMP_CONTAINER_EDITOR (buffer_view); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (editor), frame, FALSE, FALSE, 0); gtk_box_reorder_child (GTK_BOX (editor), frame, 0); gtk_widget_show (frame); hbox = gtk_hbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (hbox), 2); gtk_container_add (GTK_CONTAINER (frame), hbox); gtk_widget_show (hbox); buffer_view->global_view = gimp_view_new_full_by_types (NULL, GIMP_TYPE_VIEW, GIMP_TYPE_BUFFER, view_size, view_size, view_border_width, FALSE, FALSE, TRUE); gtk_box_pack_start (GTK_BOX (hbox), buffer_view->global_view, FALSE, FALSE, 0); gtk_widget_show (buffer_view->global_view); g_signal_connect_object (editor->view, "notify::view-size", G_CALLBACK (gimp_buffer_view_view_notify), buffer_view, 0); g_signal_connect_object (editor->view, "notify::view-border-width", G_CALLBACK (gimp_buffer_view_view_notify), buffer_view, 0); buffer_view->global_label = gtk_label_new (_("(None)")); gtk_box_pack_start (GTK_BOX (hbox), buffer_view->global_label, FALSE, FALSE, 0); gtk_widget_show (buffer_view->global_label); g_signal_connect_object (context->gimp, "buffer-changed", G_CALLBACK (gimp_buffer_view_buffer_changed), G_OBJECT (buffer_view), 0); gimp_buffer_view_buffer_changed (context->gimp, buffer_view); buffer_view->paste_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "buffers", "buffers-paste", NULL); buffer_view->paste_into_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "buffers", "buffers-paste-into", NULL); buffer_view->paste_as_new_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "buffers", "buffers-paste-as-new", NULL); buffer_view->delete_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "buffers", "buffers-delete", NULL); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (buffer_view->paste_button), GIMP_TYPE_BUFFER); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (buffer_view->paste_into_button), GIMP_TYPE_BUFFER); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (buffer_view->paste_as_new_button), GIMP_TYPE_BUFFER); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (buffer_view->delete_button), GIMP_TYPE_BUFFER); gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor->view)), editor); return GTK_WIDGET (buffer_view); }
static void gui_restore_after_callback (Gimp *gimp, GimpInitStatusFunc status_callback) { GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config); GimpDisplay *display; if (gimp->be_verbose) g_print ("INIT: %s\n", G_STRFUNC); gimp->message_handler = GIMP_MESSAGE_BOX; if (gui_config->restore_accels) menus_restore (gimp); ui_configurer = g_object_new (GIMP_TYPE_UI_CONFIGURER, "gimp", gimp, NULL); image_ui_manager = gimp_menu_factory_manager_new (global_menu_factory, "<Image>", gimp, gui_config->tearoff_menus); gimp_ui_manager_update (image_ui_manager, gimp); #ifdef GDK_WINDOWING_QUARTZ { GtkosxApplication *osx_app; GtkWidget *menu; GtkWidget *item; osx_app = gtkosx_application_get (); menu = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager), "/image-menubar"); if (GTK_IS_MENU_ITEM (menu)) menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu)); gtkosx_application_set_menu_bar (osx_app, GTK_MENU_SHELL (menu)); gtkosx_application_set_use_quartz_accelerators (osx_app, FALSE); gui_add_to_app_menu (image_ui_manager, osx_app, "/image-menubar/Help/dialogs-about", 0); #define PREFERENCES "/image-menubar/Edit/Preferences/" gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-preferences", 2); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-input-devices", 3); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-keyboard-shortcuts", 4); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-module-dialog", 5); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "plug-in-unit-editor", 6); #undef PREFERENCES item = gtk_separator_menu_item_new (); gtkosx_application_insert_app_menu_item (osx_app, item, 7); item = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager), "/image-menubar/File/file-quit"); gtk_widget_hide (item); g_signal_connect (osx_app, "NSApplicationBlockTermination", G_CALLBACK (gui_quartz_quit_callback), image_ui_manager); gtkosx_application_ready (osx_app); } #endif /* GDK_WINDOWING_QUARTZ */ g_signal_connect_object (gui_config, "notify::single-window-mode", G_CALLBACK (gui_single_window_mode_notify), ui_configurer, 0); g_signal_connect_object (gui_config, "notify::tearoff-menus", G_CALLBACK (gui_tearoff_menus_notify), image_ui_manager, 0); g_signal_connect (image_ui_manager, "show-tooltip", G_CALLBACK (gui_menu_show_tooltip), gimp); g_signal_connect (image_ui_manager, "hide-tooltip", G_CALLBACK (gui_menu_hide_tooltip), gimp); gimp_devices_restore (gimp); gimp_controllers_restore (gimp, image_ui_manager); if (status_callback == splash_update) splash_destroy (); color_history_restore (gimp); if (gimp_get_show_gui (gimp)) { GimpDisplayShell *shell; /* create the empty display */ display = GIMP_DISPLAY (gimp_create_display (gimp, NULL, GIMP_UNIT_PIXEL, 1.0)); shell = gimp_display_get_shell (display); if (gui_config->restore_session) session_restore (gimp); /* move keyboard focus to the display */ gtk_window_present (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shell)))); } /* indicate that the application has finished loading */ gdk_notify_startup_complete (); }
GtkWidget * gimp_text_editor_new (const gchar *title, GtkWindow *parent, Gimp *gimp, GimpMenuFactory *menu_factory, GimpText *text, GimpTextBuffer *text_buffer, gdouble xres, gdouble yres) { GimpTextEditor *editor; GtkWidget *content_area; GtkWidget *toolbar; GtkWidget *style_editor; GtkWidget *scrolled_window; gboolean use_header_bar; g_return_val_if_fail (title != NULL, NULL); g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL); g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL); g_return_val_if_fail (GIMP_IS_TEXT (text), NULL); g_return_val_if_fail (GIMP_IS_TEXT_BUFFER (text_buffer), NULL); g_object_get (gtk_settings_get_default (), "gtk-dialogs-use-header", &use_header_bar, NULL); editor = g_object_new (GIMP_TYPE_TEXT_EDITOR, "title", title, "role", "gimp-text-editor", "transient-for", parent, "help-func", gimp_standard_help_func, "help-id", GIMP_HELP_TEXT_EDITOR_DIALOG, "use-header-bar", use_header_bar, NULL); gtk_dialog_add_button (GTK_DIALOG (editor), _("_Close"), GTK_RESPONSE_CLOSE); g_signal_connect (editor, "response", G_CALLBACK (gtk_widget_destroy), NULL); g_signal_connect_object (text_buffer, "changed", G_CALLBACK (gimp_text_editor_text_changed), editor, 0); editor->ui_manager = gimp_menu_factory_manager_new (menu_factory, "<TextEditor>", editor); content_area = gtk_dialog_get_content_area (GTK_DIALOG (editor)); toolbar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (editor->ui_manager), "/text-editor-toolbar"); if (toolbar) { gtk_box_pack_start (GTK_BOX (content_area), toolbar, FALSE, FALSE, 0); gtk_widget_show (toolbar); } style_editor = gimp_text_style_editor_new (gimp, text, text_buffer, gimp_data_factory_get_container (gimp->font_factory), xres, yres); gtk_box_pack_start (GTK_BOX (content_area), style_editor, FALSE, FALSE, 0); gtk_widget_show (style_editor); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 2); gtk_box_pack_start (GTK_BOX (content_area), scrolled_window, TRUE, TRUE, 0); gtk_widget_show (scrolled_window); editor->view = gtk_text_view_new_with_buffer (GTK_TEXT_BUFFER (text_buffer)); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (editor->view), GTK_WRAP_WORD_CHAR); gtk_container_add (GTK_CONTAINER (scrolled_window), editor->view); gtk_widget_show (editor->view); switch (editor->base_dir) { case GIMP_TEXT_DIRECTION_LTR: case GIMP_TEXT_DIRECTION_TTB_RTL: case GIMP_TEXT_DIRECTION_TTB_RTL_UPRIGHT: case GIMP_TEXT_DIRECTION_TTB_LTR: case GIMP_TEXT_DIRECTION_TTB_LTR_UPRIGHT: gtk_widget_set_direction (editor->view, GTK_TEXT_DIR_LTR); break; case GIMP_TEXT_DIRECTION_RTL: gtk_widget_set_direction (editor->view, GTK_TEXT_DIR_RTL); break; } gtk_widget_set_size_request (editor->view, 200, 64); editor->font_toggle = gtk_check_button_new_with_mnemonic (_("_Use selected font")); gtk_box_pack_start (GTK_BOX (content_area), editor->font_toggle, FALSE, FALSE, 0); gtk_widget_show (editor->font_toggle); g_signal_connect (editor->font_toggle, "toggled", G_CALLBACK (gimp_text_editor_font_toggled), editor); gtk_widget_grab_focus (editor->view); gimp_ui_manager_update (editor->ui_manager, editor); return GTK_WIDGET (editor); }
GtkWidget * gimp_image_view_new (GimpViewType view_type, GimpContainer *container, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory) { GimpImageView *image_view; GimpContainerEditor *editor; image_view = g_object_new (GIMP_TYPE_IMAGE_VIEW, NULL); if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (image_view), view_type, container, context, view_size, view_border_width, menu_factory, "<Images>", "/images-popup")) { g_object_unref (image_view); return NULL; } editor = GIMP_CONTAINER_EDITOR (image_view); image_view->raise_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "images", "images-raise-views", NULL); image_view->new_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "images", "images-new-view", NULL); image_view->delete_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "images", "images-delete", NULL); if (view_type == GIMP_VIEW_TYPE_LIST) { GtkWidget *dnd_widget; dnd_widget = gimp_container_view_get_dnd_widget (editor->view); gimp_dnd_xds_source_add (dnd_widget, (GimpDndDragViewableFunc) gimp_dnd_get_drag_data, NULL); } gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (image_view->raise_button), GIMP_TYPE_IMAGE); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (image_view->new_button), GIMP_TYPE_IMAGE); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (image_view->delete_button), GIMP_TYPE_IMAGE); gimp_ui_manager_update (GIMP_EDITOR (editor->view)->ui_manager, editor); return GTK_WIDGET (image_view); }
void gradient_editor_split_uniformly_cmd_callback (GtkAction *action, gpointer data) { GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data); GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data); GtkWidget *dialog; GtkWidget *vbox; GtkWidget *label; GtkWidget *scale; GtkObject *scale_data; const gchar *title; const gchar *desc; if (editor->control_sel_l == editor->control_sel_r) { title = _("Split Segment Uniformly"); desc = _("Split Gradient Segment Uniformly"); } else { title = _("Split Segments Uniformly"); desc = _("Split Gradient Segments Uniformly"); } dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (data_editor->data), data_editor->context, title, "gimp-gradient-segment-split-uniformly", GIMP_STOCK_GRADIENT, desc, GTK_WIDGET (editor), gimp_standard_help_func, GIMP_HELP_GRADIENT_EDITOR_SPLIT_UNIFORM, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("Split"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_signal_connect (dialog, "response", G_CALLBACK (gradient_editor_split_uniform_response), editor); /* The main vbox */ vbox = gtk_vbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); /* Instructions */ if (editor->control_sel_l == editor->control_sel_r) label = gtk_label_new (_("Select the number of uniform parts\n" "in which to split the selected segment.")); else label = gtk_label_new (_("Select the number of uniform parts\n" "in which to split the segments in the selection.")); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); /* Scale */ editor->split_parts = 2; scale_data = gtk_adjustment_new (2.0, 2.0, 21.0, 1.0, 1.0, 1.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_scale_set_digits (GTK_SCALE (scale), 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 4); gtk_widget_show (scale); g_signal_connect (scale_data, "value-changed", G_CALLBACK (gimp_int_adjustment_update), &editor->split_parts); gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE); gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager, GIMP_EDITOR (editor)->popup_data); gtk_widget_show (dialog); }
GtkWidget * gimp_tool_view_new (GimpViewType view_type, GimpContainer *container, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory) { GimpToolView *tool_view; GimpContainerEditor *editor; tool_view = g_object_new (GIMP_TYPE_TOOL_VIEW, NULL); if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (tool_view), view_type, container, context, view_size, view_border_width, menu_factory, "<Tools>", "/tools-popup")) { g_object_unref (tool_view); return NULL; } editor = GIMP_CONTAINER_EDITOR (tool_view); tool_view->raise_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "tools", "tools-raise", "tools-raise-to-top", GDK_SHIFT_MASK, NULL); tool_view->lower_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "tools", "tools-lower", "tools-lower-to-bottom", GDK_SHIFT_MASK, NULL); tool_view->reset_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "tools", "tools-reset", NULL); if (view_type == GIMP_VIEW_TYPE_LIST) { GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (editor->view); GtkWidget *tree_widget = GTK_WIDGET (tree_view); GtkTreeViewColumn *column; GtkCellRenderer *eye_cell; GtkIconSize icon_size; column = gtk_tree_view_column_new (); gtk_tree_view_insert_column (tree_view->view, column, 0); eye_cell = gimp_cell_renderer_toggle_new (GIMP_STOCK_VISIBLE); icon_size = gimp_get_icon_size (GTK_WIDGET (tree_view), GIMP_STOCK_VISIBLE, GTK_ICON_SIZE_BUTTON, view_size - 2 * tree_widget->style->xthickness, view_size - 2 * tree_widget->style->ythickness); g_object_set (eye_cell, "stock-size", icon_size, NULL); gtk_tree_view_column_pack_start (column, eye_cell, FALSE); gtk_tree_view_column_set_cell_data_func (column, eye_cell, gimp_tool_view_eye_data_func, tree_view, NULL); tree_view->toggle_cells = g_list_prepend (tree_view->toggle_cells, eye_cell); g_signal_connect (eye_cell, "clicked", G_CALLBACK (gimp_tool_view_eye_clicked), tree_view); tool_view->visible_handler_id = gimp_container_add_handler (container, "notify::visible", G_CALLBACK (gimp_tool_view_visible_notify), tree_view); } gimp_ui_manager_update (GIMP_EDITOR (editor->view)->ui_manager, editor); return GTK_WIDGET (tool_view); }
static void gui_restore_after_callback (Gimp *gimp, GimpInitStatusFunc status_callback) { GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config); GimpDisplay *display; if (gimp->be_verbose) g_print ("INIT: %s\n", G_STRFUNC); gimp->message_handler = GIMP_MESSAGE_BOX; /* load the recent documents after gimp_real_restore() because we * need the mime-types implemented by plug-ins */ status_callback (NULL, _("Documents"), 0.9); gimp_recent_list_load (gimp); /* enable this to always have icons everywhere */ if (g_getenv ("GIMP_ICONS_LIKE_A_BOSS")) { GdkScreen *screen = gdk_screen_get_default (); g_object_set (G_OBJECT (gtk_settings_get_for_screen (screen)), "gtk-button-images", TRUE, "gtk-menu-images", TRUE, NULL); } if (gui_config->restore_accels) menus_restore (gimp); ui_configurer = g_object_new (GIMP_TYPE_UI_CONFIGURER, "gimp", gimp, NULL); image_ui_manager = gimp_menu_factory_manager_new (global_menu_factory, "<Image>", gimp, gui_config->tearoff_menus); gimp_ui_manager_update (image_ui_manager, gimp); gimp_action_history_init (gimp); #ifdef GDK_WINDOWING_QUARTZ { GtkosxApplication *osx_app; GtkWidget *menu; GtkWidget *item; osx_app = gtkosx_application_get (); menu = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager), "/image-menubar"); if (GTK_IS_MENU_ITEM (menu)) menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu)); gtkosx_application_set_menu_bar (osx_app, GTK_MENU_SHELL (menu)); gtkosx_application_set_use_quartz_accelerators (osx_app, FALSE); gui_add_to_app_menu (image_ui_manager, osx_app, "/image-menubar/Help/dialogs-about", 0); gui_add_to_app_menu (image_ui_manager, osx_app, "/image-menubar/Help/dialogs-search-action", 1); #define PREFERENCES "/image-menubar/Edit/Preferences/" gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-preferences", 3); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-input-devices", 4); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-keyboard-shortcuts", 5); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "dialogs-module-dialog", 6); gui_add_to_app_menu (image_ui_manager, osx_app, PREFERENCES "plug-in-unit-editor", 7); #undef PREFERENCES item = gtk_separator_menu_item_new (); gtkosx_application_insert_app_menu_item (osx_app, item, 8); item = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager), "/image-menubar/File/file-quit"); gtk_widget_hide (item); g_signal_connect (osx_app, "NSApplicationBlockTermination", G_CALLBACK (gui_quartz_quit_callback), image_ui_manager); gtkosx_application_ready (osx_app); } #endif /* GDK_WINDOWING_QUARTZ */ g_signal_connect_object (gui_config, "notify::single-window-mode", G_CALLBACK (gui_single_window_mode_notify), ui_configurer, 0); g_signal_connect_object (gui_config, "notify::tearoff-menus", G_CALLBACK (gui_tearoff_menus_notify), image_ui_manager, 0); g_signal_connect (image_ui_manager, "show-tooltip", G_CALLBACK (gui_menu_show_tooltip), gimp); g_signal_connect (image_ui_manager, "hide-tooltip", G_CALLBACK (gui_menu_hide_tooltip), gimp); gimp_devices_restore (gimp); gimp_controllers_restore (gimp, image_ui_manager); if (status_callback == splash_update) splash_destroy (); color_history_restore (gimp); if (gimp_get_show_gui (gimp)) { GimpDisplayShell *shell; GtkWidget *toplevel; /* create the empty display */ display = GIMP_DISPLAY (gimp_create_display (gimp, NULL, GIMP_UNIT_PIXEL, 1.0, G_OBJECT (initial_screen), initial_monitor)); shell = gimp_display_get_shell (display); if (gui_config->restore_session) session_restore (gimp, initial_screen, initial_monitor); /* move keyboard focus to the display */ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell)); gtk_window_present (GTK_WINDOW (toplevel)); } /* indicate that the application has finished loading */ gdk_notify_startup_complete (); /* clear startup monitor variables */ initial_screen = NULL; initial_monitor = -1; }
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; }
GtkWidget * gimp_document_view_new (GimpViewType view_type, GimpContainer *container, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory) { GimpDocumentView *document_view; GimpContainerEditor *editor; document_view = g_object_new (GIMP_TYPE_DOCUMENT_VIEW, NULL); if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (document_view), view_type, container, context, view_size, view_border_width, menu_factory, "<Documents>", "/documents-popup")) { g_object_unref (document_view); return NULL; } editor = GIMP_CONTAINER_EDITOR (document_view); document_view->open_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "documents", "documents-open", "documents-raise-or-open", GDK_SHIFT_MASK, "documents-file-open-dialog", GDK_CONTROL_MASK, NULL); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (document_view->open_button), GIMP_TYPE_IMAGEFILE); document_view->remove_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "documents", "documents-remove", NULL); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (document_view->remove_button), GIMP_TYPE_IMAGEFILE); gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "documents", "documents-clear", NULL); document_view->refresh_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "documents", "documents-recreate-preview", "documents-reload-previews", GDK_SHIFT_MASK, "documents-remove-dangling", GDK_CONTROL_MASK, NULL); if (view_type == GIMP_VIEW_TYPE_LIST) { GtkWidget *dnd_widget; dnd_widget = gimp_container_view_get_dnd_widget (editor->view); gimp_dnd_uri_list_source_add (dnd_widget, gimp_document_view_drag_uri_list, editor); } gimp_ui_manager_update (GIMP_EDITOR (editor->view)->ui_manager, editor); return GTK_WIDGET (document_view); }
GtkWidget * gimp_template_view_new (GimpViewType view_type, GimpContainer *container, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory) { GimpTemplateView *template_view; GimpContainerEditor *editor; template_view = g_object_new (GIMP_TYPE_TEMPLATE_VIEW, NULL); if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (template_view), view_type, container, context, view_size, view_border_width, menu_factory, "<Templates>", "/templates-popup")) { g_object_unref (template_view); return NULL; } editor = GIMP_CONTAINER_EDITOR (template_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_template_view_tree_name_edited), template_view); } template_view->create_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates", "templates-create-image", NULL); template_view->new_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates", "templates-new", NULL); template_view->duplicate_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates", "templates-duplicate", NULL); template_view->edit_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates", "templates-edit", NULL); template_view->delete_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates", "templates-delete", NULL); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (template_view->create_button), GIMP_TYPE_TEMPLATE); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (template_view->duplicate_button), GIMP_TYPE_TEMPLATE); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (template_view->edit_button), GIMP_TYPE_TEMPLATE); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (template_view->delete_button), GIMP_TYPE_TEMPLATE); gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor->view)), editor); return GTK_WIDGET (template_view); }