
2001-07-07 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/context_manager.[ch]: removed. * app/app_procs.c: call tool_mananger instead of context_manager functions, pass "the_gimp" to some more functions. * app/drawable.[ch]: pass a GimpContext to drawable_fill(). * app/errors.c: behave according to "stack_trace_mode" when using the debugging signal handler. * app/gimprc.[ch]: removed the core/ config variables. * app/selection.c: set the selection's state to INVISIBLE in selection_pause(). * app/core/Makefile.am * app/core/gimpcoreconfig.[ch]: new files (the configuration variables used by core/). * app/core/gimpcontext.[ch]: removed the global contexts (user, default, ...) and their functions. It's no longer possible to pass NULL to the context functions to manipulate the current context (gimpcontext.c doesn't know the current context any more). * app/core/gimp.[ch]: added them here. The functions are now called gimp_[set|get]_*_context(). Added gimp_create_context() which is the only function to create contexts now. * app/gui/dialogs.[ch] * app/gui/gui.[ch]: pass "gimp" to all functions. * app/tools/tool_manager.[ch] * app/tools/tools.[ch]: pass "gimp" to lots of functions. Added the "global_tool_context" logic and the global/non-global paint options switching from the context_manager. Pass "gimp" to all tools' "register" functions. * app/tools/*: changed accordingly. * app/devices.c * app/disp_callbacks.c * app/file-open.[ch] * app/file-save.c * app/gdisplay.c * app/gimage.c * app/libgimp_glue.c * app/module_db.c * app/nav_window.c * app/plug_in.c * app/qmask.c * app/undo.c * app/base/base-config.c * app/core/gimpbrushpipe.c * app/core/gimpdrawable-offset.c * app/core/gimpgradient.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimpimage-new.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimptoolinfo.[ch] * app/core/gimpundo.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.c * app/gui/test-commands.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdnd.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimpimagedock.c * app/widgets/gimplayerlistview.c * app/pdb/brushes_cmds.c * app/pdb/drawable_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/palette_cmds.c * app/pdb/patterns_cmds.c * app/pdb/procedural_db.c * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly: remove usage of gimp_context_[get|set]_*(NULL), create contexts with gimp_create_context(). Get the user/current context with gimp_get_[user|current]_context(). Added/removed access to the global "the_gimp" variable in some places. Get the core's config variables from "core_config".
1000 lines
24 KiB
C
1000 lines
24 KiB
C
/* The GIMP -- an image manipulation program
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
#include "apptypes.h"
|
|
#include "widgets/widgets-types.h"
|
|
|
|
#include "core/gimp.h"
|
|
#include "core/gimpbrushgenerated.h"
|
|
#include "core/gimpchannel.h"
|
|
#include "core/gimpcontext.h"
|
|
#include "core/gimpgradient.h"
|
|
#include "core/gimpimage.h"
|
|
#include "core/gimplayer.h"
|
|
#include "core/gimptoolinfo.h"
|
|
|
|
#include "widgets/gimpbrushfactoryview.h"
|
|
#include "widgets/gimpbufferview.h"
|
|
#include "widgets/gimpcontainerlistview.h"
|
|
#include "widgets/gimpcontainergridview.h"
|
|
#include "widgets/gimpdatafactoryview.h"
|
|
#include "widgets/gimpdialogfactory.h"
|
|
#include "widgets/gimpimagedock.h"
|
|
#include "widgets/gimpdockable.h"
|
|
#include "widgets/gimpdockbook.h"
|
|
#include "widgets/gimpdrawablelistview.h"
|
|
#include "widgets/gimplistitem.h"
|
|
#include "widgets/gimppreview.h"
|
|
|
|
#include "about-dialog.h"
|
|
#include "brush-editor.h"
|
|
#include "brush-select.h"
|
|
#include "channels-commands.h"
|
|
#include "color-area.h"
|
|
#include "colormap-dialog.h"
|
|
#include "devices.h"
|
|
#include "dialogs-constructors.h"
|
|
#include "docindex.h"
|
|
#include "errorconsole.h"
|
|
#include "gdisplay.h"
|
|
#include "gradient-editor.h"
|
|
#include "gradient-select.h"
|
|
#include "layers-commands.h"
|
|
#include "palette-editor.h"
|
|
#include "paths-dialog.h"
|
|
#include "pattern-select.h"
|
|
#include "preferences-dialog.h"
|
|
#include "tips-dialog.h"
|
|
#include "tool-options-dialog.h"
|
|
#include "toolbox.h"
|
|
|
|
#include "app_procs.h"
|
|
#include "gdisplay.h"
|
|
#include "gimprc.h"
|
|
#include "module_db.h"
|
|
#include "undo_history.h"
|
|
|
|
#ifdef DISPLAY_FILTERS
|
|
#include "gdisplay_color_ui.h"
|
|
#endif /* DISPLAY_FILTERS */
|
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
static void dialogs_indexed_palette_selected (GimpColormapDialog *dialog,
|
|
GimpContext *context);
|
|
|
|
static GtkWidget * dialogs_brush_tab_func (GimpDockable *dockable,
|
|
GimpDockbook *dockbook,
|
|
gint size);
|
|
static GtkWidget * dialogs_pattern_tab_func (GimpDockable *dockable,
|
|
GimpDockbook *dockbook,
|
|
gint size);
|
|
static GtkWidget * dialogs_gradient_tab_func (GimpDockable *dockable,
|
|
GimpDockbook *dockbook,
|
|
gint size);
|
|
static GtkWidget * dialogs_palette_tab_func (GimpDockable *dockable,
|
|
GimpDockbook *dockbook,
|
|
gint size);
|
|
static GtkWidget * dialogs_tool_tab_func (GimpDockable *dockable,
|
|
GimpDockbook *dockbook,
|
|
gint size);
|
|
|
|
static void dialogs_set_view_context_func (GimpDockable *dockable,
|
|
GimpContext *context);
|
|
static void dialogs_set_editor_context_func (GimpDockable *dockable,
|
|
GimpContext *context);
|
|
static void dialogs_set_drawable_context_func (GimpDockable *dockable,
|
|
GimpContext *context);
|
|
static void dialogs_set_path_context_func (GimpDockable *dockable,
|
|
GimpContext *context);
|
|
|
|
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
|
|
const gchar *name,
|
|
const gchar *short_name,
|
|
GimpDockableGetTabFunc get_tab_func,
|
|
GimpDockableSetContextFunc set_context_func);
|
|
|
|
static void dialogs_drawable_view_image_changed (GimpContext *context,
|
|
GimpImage *gimage,
|
|
GimpDrawableListView *view);
|
|
static void dialogs_path_view_image_changed (GimpContext *context,
|
|
GimpImage *gimage,
|
|
GtkWidget *view);
|
|
|
|
|
|
/* public functions */
|
|
|
|
GtkWidget *
|
|
dialogs_toolbox_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return toolbox_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_tool_options_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return tool_options_dialog_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_device_status_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return device_status_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_brush_select_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return brush_dialog_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_pattern_select_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return pattern_dialog_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_gradient_select_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return gradient_dialog_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_palette_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return palette_dialog_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_error_console_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return error_console_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_document_index_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return document_index_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_preferences_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return preferences_dialog_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_input_devices_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return input_dialog_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_module_browser_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return module_db_browser_new ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_indexed_palette_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GimpColormapDialog *cmap_dlg;
|
|
|
|
cmap_dlg = gimp_colormap_dialog_create (context->gimp->images);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (cmap_dlg), "selected",
|
|
GTK_SIGNAL_FUNC (dialogs_indexed_palette_selected),
|
|
factory->context);
|
|
|
|
return GTK_WIDGET (cmap_dlg);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_undo_history_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GDisplay *gdisp;
|
|
GimpImage *gimage;
|
|
|
|
gdisp = gimp_context_get_display (context);
|
|
|
|
if (! gdisp)
|
|
return NULL;
|
|
|
|
gimage = gdisp->gimage;
|
|
|
|
if (! gimage->undo_history)
|
|
gimage->undo_history = undo_history_new (gimage);
|
|
|
|
return gimage->undo_history;
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_display_filters_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
#ifdef DISPLAY_FILTERS
|
|
GDisplay *gdisp;
|
|
|
|
gdisp = gimp_context_get_display (context);
|
|
|
|
if (! gdisp)
|
|
gdisp = color_area_gdisp;
|
|
|
|
if (! gdisp->cd_ui)
|
|
gdisplay_color_ui_new (gdisp);
|
|
|
|
return gdisp->cd_ui;
|
|
#else
|
|
return NULL;
|
|
#endif /* DISPLAY_FILTERS */
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_tips_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return tips_dialog_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_about_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return about_dialog_create ();
|
|
}
|
|
|
|
|
|
GtkWidget *
|
|
dialogs_dock_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return gimp_image_dock_new (factory, context->gimp->images);
|
|
}
|
|
|
|
|
|
/* list views */
|
|
|
|
GtkWidget *
|
|
dialogs_image_list_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_container_list_view_new (context->gimp->images,
|
|
context,
|
|
32,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Image List", "Images",
|
|
NULL,
|
|
dialogs_set_view_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_brush_list_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_brush_factory_view_new (GIMP_VIEW_TYPE_LIST,
|
|
context->gimp->brush_factory,
|
|
dialogs_edit_brush_func,
|
|
context,
|
|
TRUE,
|
|
32,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Brush List", "Brushes",
|
|
dialogs_brush_tab_func,
|
|
dialogs_set_editor_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_pattern_list_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
|
|
context->gimp->pattern_factory,
|
|
NULL,
|
|
context,
|
|
32,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Pattern List", "Patterns",
|
|
dialogs_pattern_tab_func,
|
|
dialogs_set_editor_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_gradient_list_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
|
|
context->gimp->gradient_factory,
|
|
dialogs_edit_gradient_func,
|
|
context,
|
|
32 / 2,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Gradient List", "Gradients",
|
|
dialogs_gradient_tab_func,
|
|
dialogs_set_editor_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_palette_list_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
|
|
context->gimp->palette_factory,
|
|
dialogs_edit_palette_func,
|
|
context,
|
|
32,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Palette List", "Palettes",
|
|
dialogs_palette_tab_func,
|
|
dialogs_set_editor_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_tool_list_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_container_list_view_new (context->gimp->tool_info_list,
|
|
context,
|
|
22,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Tool List", "Tools",
|
|
dialogs_tool_tab_func,
|
|
dialogs_set_view_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_buffer_list_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_buffer_view_new (GIMP_VIEW_TYPE_LIST,
|
|
context->gimp->named_buffers,
|
|
context,
|
|
32,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Buffer List", "Buffers",
|
|
NULL,
|
|
dialogs_set_editor_context_func);
|
|
}
|
|
|
|
|
|
/* grid views */
|
|
|
|
GtkWidget *
|
|
dialogs_image_grid_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_container_grid_view_new (context->gimp->images,
|
|
context,
|
|
32,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Image Grid", "Images",
|
|
NULL,
|
|
dialogs_set_view_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_brush_grid_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_brush_factory_view_new (GIMP_VIEW_TYPE_GRID,
|
|
context->gimp->brush_factory,
|
|
dialogs_edit_brush_func,
|
|
context,
|
|
TRUE,
|
|
32,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Brush Grid", "Brushes",
|
|
dialogs_brush_tab_func,
|
|
dialogs_set_editor_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
|
|
context->gimp->pattern_factory,
|
|
NULL,
|
|
context,
|
|
32,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Pattern Grid", "Patterns",
|
|
dialogs_pattern_tab_func,
|
|
dialogs_set_editor_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
|
|
context->gimp->gradient_factory,
|
|
dialogs_edit_gradient_func,
|
|
context,
|
|
32,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Gradient Grid", "Gradients",
|
|
dialogs_gradient_tab_func,
|
|
dialogs_set_editor_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_palette_grid_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_GRID,
|
|
context->gimp->palette_factory,
|
|
dialogs_edit_palette_func,
|
|
context,
|
|
32,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Palette Grid", "Palettes",
|
|
dialogs_palette_tab_func,
|
|
dialogs_set_editor_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_tool_grid_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_container_grid_view_new (context->gimp->tool_info_list,
|
|
context,
|
|
22,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Tool Grid", "Tools",
|
|
dialogs_tool_tab_func,
|
|
dialogs_set_view_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_buffer_view_new (GIMP_VIEW_TYPE_GRID,
|
|
context->gimp->named_buffers,
|
|
context,
|
|
32,
|
|
5, 3);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Buffer Grid", "Buffers",
|
|
NULL,
|
|
dialogs_set_editor_context_func);
|
|
}
|
|
|
|
|
|
/* image related dialogs */
|
|
|
|
GtkWidget *
|
|
dialogs_layer_list_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GimpImage *gimage;
|
|
GtkWidget *view;
|
|
GtkWidget *dockable;
|
|
|
|
gimage = gimp_context_get_image (context);
|
|
|
|
view = gimp_drawable_list_view_new
|
|
(gimprc.preview_size,
|
|
gimage,
|
|
GIMP_TYPE_LAYER,
|
|
"active_layer_changed",
|
|
(GimpGetContainerFunc) gimp_image_get_layers,
|
|
(GimpGetDrawableFunc) gimp_image_get_active_layer,
|
|
(GimpSetDrawableFunc) gimp_image_set_active_layer,
|
|
(GimpReorderDrawableFunc) gimp_image_position_layer,
|
|
(GimpAddDrawableFunc) gimp_image_add_layer,
|
|
(GimpRemoveDrawableFunc) gimp_image_remove_layer,
|
|
(GimpCopyDrawableFunc) gimp_layer_copy,
|
|
(GimpNewDrawableFunc) layers_new_layer_query,
|
|
(GimpEditDrawableFunc) layers_edit_layer_query,
|
|
(GimpDrawableContextFunc) layers_show_context_menu);
|
|
|
|
dockable = dialogs_dockable_new (view,
|
|
"Layer List", "Layers",
|
|
NULL,
|
|
dialogs_set_drawable_context_func);
|
|
|
|
dialogs_set_drawable_context_func (GIMP_DOCKABLE (dockable), context);
|
|
|
|
return dockable;
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_channel_list_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GimpImage *gimage;
|
|
GtkWidget *view;
|
|
GtkWidget *dockable;
|
|
|
|
gimage = gimp_context_get_image (context);
|
|
|
|
view = gimp_drawable_list_view_new
|
|
(gimprc.preview_size,
|
|
gimage,
|
|
GIMP_TYPE_CHANNEL,
|
|
"active_channel_changed",
|
|
(GimpGetContainerFunc) gimp_image_get_channels,
|
|
(GimpGetDrawableFunc) gimp_image_get_active_channel,
|
|
(GimpSetDrawableFunc) gimp_image_set_active_channel,
|
|
(GimpReorderDrawableFunc) gimp_image_position_channel,
|
|
(GimpAddDrawableFunc) gimp_image_add_channel,
|
|
(GimpRemoveDrawableFunc) gimp_image_remove_channel,
|
|
(GimpCopyDrawableFunc) gimp_channel_copy,
|
|
(GimpNewDrawableFunc) channels_new_channel_query,
|
|
(GimpEditDrawableFunc) channels_edit_channel_query,
|
|
(GimpDrawableContextFunc) channels_show_context_menu);
|
|
|
|
dockable = dialogs_dockable_new (view,
|
|
"Channel List", "Channels",
|
|
NULL,
|
|
dialogs_set_drawable_context_func);
|
|
|
|
dialogs_set_drawable_context_func (GIMP_DOCKABLE (dockable), context);
|
|
|
|
return dockable;
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_path_list_view_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
static GtkWidget *view = NULL;
|
|
|
|
GtkWidget *dockable;
|
|
|
|
if (view)
|
|
return NULL;
|
|
|
|
view = paths_dialog_create ();
|
|
|
|
gtk_signal_connect (GTK_OBJECT (view), "destroy",
|
|
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
|
&view);
|
|
|
|
dockable = dialogs_dockable_new (view,
|
|
"Path List", "Paths",
|
|
NULL,
|
|
dialogs_set_path_context_func);
|
|
|
|
dialogs_set_path_context_func (GIMP_DOCKABLE (dockable), context);
|
|
|
|
return dockable;
|
|
}
|
|
|
|
|
|
/* editor dialogs */
|
|
|
|
void
|
|
dialogs_edit_brush_func (GimpData *data)
|
|
{
|
|
static BrushEditor *brush_editor_dialog = NULL;
|
|
|
|
GimpBrush *brush;
|
|
|
|
brush = GIMP_BRUSH (data);
|
|
|
|
if (GIMP_IS_BRUSH_GENERATED (brush))
|
|
{
|
|
if (! brush_editor_dialog)
|
|
{
|
|
brush_editor_dialog = brush_editor_new ();
|
|
}
|
|
|
|
brush_editor_set_brush (brush_editor_dialog, brush);
|
|
}
|
|
else
|
|
{
|
|
g_message (_("Sorry, this brush can't be edited."));
|
|
}
|
|
}
|
|
|
|
void
|
|
dialogs_edit_gradient_func (GimpData *data)
|
|
{
|
|
static GradientEditor *gradient_editor_dialog = NULL;
|
|
|
|
GimpGradient *gradient;
|
|
|
|
gradient = GIMP_GRADIENT (data);
|
|
|
|
if (! gradient_editor_dialog)
|
|
{
|
|
gradient_editor_dialog = gradient_editor_new ();
|
|
}
|
|
|
|
gradient_editor_set_gradient (gradient_editor_dialog, gradient);
|
|
}
|
|
|
|
void
|
|
dialogs_edit_palette_func (GimpData *data)
|
|
{
|
|
palette_dialog_edit_palette (data);
|
|
}
|
|
|
|
|
|
/* private functions */
|
|
|
|
static void
|
|
dialogs_indexed_palette_selected (GimpColormapDialog *dialog,
|
|
GimpContext *context)
|
|
{
|
|
GimpImage *gimage;
|
|
GimpRGB color;
|
|
gint index;
|
|
|
|
gimage = gimp_colormap_dialog_image (dialog);
|
|
index = gimp_colormap_dialog_col_index (dialog);
|
|
|
|
gimp_rgba_set_uchar (&color,
|
|
gimage->cmap[index * 3],
|
|
gimage->cmap[index * 3 + 1],
|
|
gimage->cmap[index * 3 + 2],
|
|
255);
|
|
|
|
if (active_color == FOREGROUND)
|
|
gimp_context_set_foreground (context, &color);
|
|
else if (active_color == BACKGROUND)
|
|
gimp_context_set_background (context, &color);
|
|
}
|
|
|
|
static GtkWidget *
|
|
dialogs_brush_tab_func (GimpDockable *dockable,
|
|
GimpDockbook *dockbook,
|
|
gint size)
|
|
{
|
|
GimpContext *context;
|
|
GtkWidget *preview;
|
|
|
|
context = dockbook->dock->context;
|
|
|
|
preview =
|
|
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_brush (context)),
|
|
size, size, 1,
|
|
FALSE, FALSE, FALSE);
|
|
|
|
gtk_signal_connect_object_while_alive
|
|
(GTK_OBJECT (context),
|
|
"brush_changed",
|
|
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
|
|
GTK_OBJECT (preview));
|
|
|
|
return preview;
|
|
}
|
|
|
|
static GtkWidget *
|
|
dialogs_pattern_tab_func (GimpDockable *dockable,
|
|
GimpDockbook *dockbook,
|
|
gint size)
|
|
{
|
|
GimpContext *context;
|
|
GtkWidget *preview;
|
|
|
|
context = dockbook->dock->context;
|
|
|
|
preview =
|
|
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_pattern (context)),
|
|
size, size, 1,
|
|
FALSE, FALSE, FALSE);
|
|
|
|
gtk_signal_connect_object_while_alive
|
|
(GTK_OBJECT (context),
|
|
"pattern_changed",
|
|
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
|
|
GTK_OBJECT (preview));
|
|
|
|
return preview;
|
|
}
|
|
|
|
static GtkWidget *
|
|
dialogs_gradient_tab_func (GimpDockable *dockable,
|
|
GimpDockbook *dockbook,
|
|
gint size)
|
|
{
|
|
GimpContext *context;
|
|
GtkWidget *preview;
|
|
|
|
context = dockbook->dock->context;
|
|
|
|
preview =
|
|
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_gradient (context)),
|
|
size, size, 1,
|
|
FALSE, FALSE, FALSE);
|
|
|
|
gtk_signal_connect_object_while_alive
|
|
(GTK_OBJECT (context),
|
|
"gradient_changed",
|
|
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
|
|
GTK_OBJECT (preview));
|
|
|
|
return preview;
|
|
}
|
|
|
|
static GtkWidget *
|
|
dialogs_palette_tab_func (GimpDockable *dockable,
|
|
GimpDockbook *dockbook,
|
|
gint size)
|
|
{
|
|
GimpContext *context;
|
|
GtkWidget *preview;
|
|
|
|
context = dockbook->dock->context;
|
|
|
|
preview =
|
|
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_palette (context)),
|
|
size, size, 1,
|
|
FALSE, FALSE, FALSE);
|
|
|
|
gtk_signal_connect_object_while_alive
|
|
(GTK_OBJECT (context),
|
|
"palette_changed",
|
|
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
|
|
GTK_OBJECT (preview));
|
|
|
|
return preview;
|
|
}
|
|
|
|
static GtkWidget *
|
|
dialogs_tool_tab_func (GimpDockable *dockable,
|
|
GimpDockbook *dockbook,
|
|
gint size)
|
|
{
|
|
GimpContext *context;
|
|
GtkWidget *preview;
|
|
|
|
context = dockbook->dock->context;
|
|
|
|
preview =
|
|
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_tool (context)),
|
|
size, size, 1,
|
|
FALSE, FALSE, FALSE);
|
|
|
|
gtk_signal_connect_object_while_alive
|
|
(GTK_OBJECT (context),
|
|
"tool_changed",
|
|
GTK_SIGNAL_FUNC (gimp_preview_set_viewable),
|
|
GTK_OBJECT (preview));
|
|
|
|
return preview;
|
|
}
|
|
|
|
static void
|
|
dialogs_set_view_context_func (GimpDockable *dockable,
|
|
GimpContext *context)
|
|
{
|
|
GimpContainerView *view;
|
|
|
|
view = (GimpContainerView *) gtk_object_get_data (GTK_OBJECT (dockable),
|
|
"gimp-dialogs-view");
|
|
|
|
if (view)
|
|
gimp_container_view_set_context (view, context);
|
|
}
|
|
|
|
static void
|
|
dialogs_set_editor_context_func (GimpDockable *dockable,
|
|
GimpContext *context)
|
|
{
|
|
GimpContainerEditor *editor;
|
|
|
|
editor = (GimpContainerEditor *) gtk_object_get_data (GTK_OBJECT (dockable),
|
|
"gimp-dialogs-view");
|
|
|
|
if (editor)
|
|
gimp_container_view_set_context (editor->view, context);
|
|
}
|
|
|
|
static void
|
|
dialogs_set_drawable_context_func (GimpDockable *dockable,
|
|
GimpContext *context)
|
|
{
|
|
GimpDrawableListView *view;
|
|
|
|
view = (GimpDrawableListView *) gtk_object_get_data (GTK_OBJECT (dockable),
|
|
"gimp-dialogs-view");
|
|
|
|
if (view)
|
|
{
|
|
GimpContext *old_context;
|
|
|
|
old_context = (GimpContext *) gtk_object_get_data (GTK_OBJECT (view),
|
|
"gimp-dialogs-context");
|
|
|
|
if (old_context)
|
|
{
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (old_context),
|
|
GTK_SIGNAL_FUNC (dialogs_drawable_view_image_changed),
|
|
view);
|
|
}
|
|
|
|
if (context)
|
|
{
|
|
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
|
|
GTK_SIGNAL_FUNC (dialogs_drawable_view_image_changed),
|
|
view);
|
|
|
|
dialogs_drawable_view_image_changed (context,
|
|
gimp_context_get_image (context),
|
|
view);
|
|
}
|
|
else
|
|
{
|
|
dialogs_drawable_view_image_changed (NULL, NULL, view);
|
|
}
|
|
|
|
gtk_object_set_data (GTK_OBJECT (view), "gimp-dialogs-context", context);
|
|
}
|
|
}
|
|
|
|
static void
|
|
dialogs_set_path_context_func (GimpDockable *dockable,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (dockable),
|
|
"gimp-dialogs-view");
|
|
|
|
if (view)
|
|
{
|
|
GimpContext *old_context;
|
|
|
|
old_context = (GimpContext *) gtk_object_get_data (GTK_OBJECT (view),
|
|
"gimp-dialogs-context");
|
|
|
|
if (old_context)
|
|
{
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (old_context),
|
|
GTK_SIGNAL_FUNC (dialogs_path_view_image_changed),
|
|
view);
|
|
}
|
|
|
|
if (context)
|
|
{
|
|
gtk_signal_connect (GTK_OBJECT (context), "image_changed",
|
|
GTK_SIGNAL_FUNC (dialogs_path_view_image_changed),
|
|
view);
|
|
|
|
dialogs_path_view_image_changed (context,
|
|
gimp_context_get_image (context),
|
|
view);
|
|
}
|
|
else
|
|
{
|
|
dialogs_path_view_image_changed (NULL, NULL, view);
|
|
}
|
|
|
|
gtk_object_set_data (GTK_OBJECT (view), "gimp-dialogs-context", context);
|
|
}
|
|
}
|
|
|
|
static GtkWidget *
|
|
dialogs_dockable_new (GtkWidget *widget,
|
|
const gchar *name,
|
|
const gchar *short_name,
|
|
GimpDockableGetTabFunc get_tab_func,
|
|
GimpDockableSetContextFunc set_context_func)
|
|
{
|
|
GtkWidget *dockable;
|
|
|
|
dockable = gimp_dockable_new (name,
|
|
short_name,
|
|
get_tab_func,
|
|
set_context_func);
|
|
gtk_container_add (GTK_CONTAINER (dockable), widget);
|
|
gtk_widget_show (widget);
|
|
|
|
gtk_object_set_data (GTK_OBJECT (dockable), "gimp-dialogs-view", widget);
|
|
|
|
return dockable;
|
|
}
|
|
|
|
static void
|
|
dialogs_drawable_view_image_changed (GimpContext *context,
|
|
GimpImage *gimage,
|
|
GimpDrawableListView *view)
|
|
{
|
|
gimp_drawable_list_view_set_image (view, gimage);
|
|
}
|
|
|
|
static void
|
|
dialogs_path_view_image_changed (GimpContext *context,
|
|
GimpImage *gimage,
|
|
GtkWidget *widget)
|
|
{
|
|
paths_dialog_update (gimage);
|
|
}
|