
2001-10-29 Michael Natterer <mitch@gimp.org> Cleanup weekend... * app/app_procs.c: pass "no_interface" to gimp_new(). * app/core/gimp.[ch]: added "gboolean no_interface" and the load_procs and save_procs GSLists. * app/core/gimptoolinfo.[ch]: added a "Gimp" pointer to the GimpToolInfo object so more functions find their context without accessing the global "the_gimp" variable. * app/display/display-types.h: removed the GDisplay -> GimpDisplay typedef. * app/display/gimpdisplay.c: look at gimp->no_interface, don't include "appenv.h". * app/file/file-open.[ch] * app/file/file-save.[ch]: don't use "the_gimp" any more. Instead, pass around lots of "Gimp" pointers. Removed the global load_procs and save_procs variables here. Use access() to find out whether a file is readable/writable, removed the manual voodoo and it's Win32 wrappers. Added an optional (can be NULL) "PlunInProcDef" parameter to file_save(), removed file_save_with_proc(). * app/gui/menus.c: Use the unused "gpointer data" parameter of the GtkItemFactory callbacks to pass a "Gimp" pointer to all of them. This reduces the usage of the global "the_gimp" hack to zero in app/gui/... yeah. * app/gui/channels-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/select-commands.c * app/gui/test-commands.c * app/gui/tools-commands.c * app/gui/view-commands.c: use the passed "Gimp" pointer. * app/gui/color-area.[ch] * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.[ch] * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch] * app/gui/gui.c * app/gui/info-window.[ch] * app/gui/module-browser.[ch] * app/gui/palette-editor.c * app/gui/palette-import-dialog.[ch] * app/gui/paths-dialog.c * app/gui/preferences-dialog.[ch] * app/gui/resize-dialog.[ch] * app/gui/tool-options-dialog.[ch] * app/gui/toolbox.c: pass around lots more "Gimp" and "GimpContext" pointers and don't use "the_gimp" any more. * app/tools/gimptool.h: added a pointer to the corresponding GimpToolInfo object (which in turn has a pointer to a Gimp). * app/tools/tool_manager.[ch]: set the pointer after creating the tool object. Removed tool_manager_get_info_by_tool() as there is a tool->tool_info pointer now. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool.c * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimpperspectivetool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpsheartool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/path_tool.c * app/tools/xinput_airbrush.c: s/GDisplay/GimpDisplay/g. Use tool->tool_info and tool_info->gimp in some places to get rid of using "the_gimp". Removing the remaining ones involves changing the tool options system and is scheduled next... * app/widgets/gimpdnd.c * app/widgets/gimpdocumentview.c: pass a "Gimp" pointer to all file_open_*() functions. * app/gdisplay_color.[ch] * app/gdisplay_color_ui.[ch] * app/image_map.[ch] * app/nav_window.[ch] * app/path.c * app/path_bezier.c * app/path_transform.h * app/qmask.[ch]: s/GDisplay/GimpDisplay/g * tools/pdbgen/pdb/fileops.pdb: load_procs and save_procs are members of the "Gimp" object now. * tools/pdbgen/pdb/plug_in.pdb: use gimp->no_interface, don't include "appenv.h". * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
1156 lines
28 KiB
C
1156 lines
28 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 "gui-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/gimppalette.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/gimpdocumentview.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 "brushes-commands.h"
|
|
#include "buffers-commands.h"
|
|
#include "channels-commands.h"
|
|
#include "color-area.h"
|
|
#include "colormap-dialog.h"
|
|
#include "dialogs.h"
|
|
#include "dialogs-constructors.h"
|
|
#include "documents-commands.h"
|
|
#include "error-console-dialog.h"
|
|
#include "gradient-editor.h"
|
|
#include "gradient-select.h"
|
|
#include "gradients-commands.h"
|
|
#include "layers-commands.h"
|
|
#include "menus.h"
|
|
#include "module-browser.h"
|
|
#include "palette-editor.h"
|
|
#include "palette-select.h"
|
|
#include "palettes-commands.h"
|
|
#include "paths-dialog.h"
|
|
#include "pattern-select.h"
|
|
#include "patterns-commands.h"
|
|
#include "preferences-dialog.h"
|
|
#include "tips-dialog.h"
|
|
#include "tool-options-dialog.h"
|
|
#include "toolbox.h"
|
|
|
|
#include "devices.h"
|
|
#include "gimprc.h"
|
|
#include "undo_history.h"
|
|
|
|
#ifdef DISPLAY_FILTERS
|
|
#include "gdisplay_color_ui.h"
|
|
#endif /* DISPLAY_FILTERS */
|
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
/* FIXME: do something about this uglyness:
|
|
*/
|
|
|
|
typedef struct
|
|
{
|
|
GtkWidget *shell;
|
|
} EEKWrapper;
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
static void dialogs_indexed_palette_selected (GimpColormapDialog *dialog,
|
|
GimpDockable *dockable);
|
|
|
|
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 void dialogs_set_indexed_palette_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);
|
|
static void dialogs_indexed_palette_image_changed (GimpContext *context,
|
|
GimpImage *gimage,
|
|
GimpColormapDialog *ipal);
|
|
|
|
|
|
/* private variables */
|
|
|
|
static BrushEditor *brush_editor_dialog = NULL;
|
|
static GradientEditor *gradient_editor_dialog = NULL;
|
|
static PaletteEditor *palette_editor_dialog = NULL;
|
|
|
|
|
|
/* public functions */
|
|
|
|
GtkWidget *
|
|
dialogs_toolbox_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return toolbox_create (context->gimp);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_tool_options_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return tool_options_dialog_create (context->gimp);
|
|
}
|
|
|
|
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 (context->gimp);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_pattern_select_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return pattern_dialog_create (context->gimp);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_gradient_select_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return gradient_dialog_create (context->gimp);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_palette_select_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return palette_dialog_create (context->gimp);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_preferences_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return preferences_dialog_create (context->gimp);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_input_devices_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return input_dialog_create ();
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_module_browser_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
return module_browser_new (context->gimp);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_undo_history_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GimpImage *gimage;
|
|
GtkWidget *undo_history;
|
|
|
|
gimage = gimp_context_get_image (context);
|
|
|
|
if (! gimage)
|
|
return NULL;
|
|
|
|
undo_history = g_object_get_data (G_OBJECT (gimage), "undo-history");
|
|
|
|
if (! undo_history)
|
|
{
|
|
undo_history = undo_history_new (gimage);
|
|
|
|
g_object_set_data (G_OBJECT (gimage), "undo-history", undo_history);
|
|
}
|
|
|
|
return undo_history;
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_display_filters_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
#ifdef DISPLAY_FILTERS
|
|
GimpDisplay *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_brush_editor_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
if (! brush_editor_dialog)
|
|
{
|
|
brush_editor_dialog = brush_editor_new (context->gimp);
|
|
}
|
|
|
|
return ((EEKWrapper *) brush_editor_dialog)->shell;
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_gradient_editor_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
if (! gradient_editor_dialog)
|
|
{
|
|
gradient_editor_dialog = gradient_editor_new (context->gimp);
|
|
}
|
|
|
|
return ((EEKWrapper *) gradient_editor_dialog)->shell;
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_palette_editor_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
if (! palette_editor_dialog)
|
|
{
|
|
palette_editor_dialog = palette_editor_new (context->gimp);
|
|
}
|
|
|
|
return ((EEKWrapper *) palette_editor_dialog)->shell;
|
|
}
|
|
|
|
|
|
/* docks */
|
|
|
|
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,
|
|
FALSE,
|
|
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,
|
|
brushes_show_context_menu);
|
|
|
|
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,
|
|
patterns_show_context_menu);
|
|
|
|
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,
|
|
gradients_show_context_menu);
|
|
|
|
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,
|
|
palettes_show_context_menu);
|
|
|
|
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,
|
|
FALSE,
|
|
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,
|
|
buffers_show_context_menu);
|
|
|
|
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,
|
|
FALSE,
|
|
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,
|
|
brushes_show_context_menu);
|
|
|
|
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,
|
|
patterns_show_context_menu);
|
|
|
|
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,
|
|
gradients_show_context_menu);
|
|
|
|
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,
|
|
palettes_show_context_menu);
|
|
|
|
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,
|
|
FALSE,
|
|
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,
|
|
buffers_show_context_menu);
|
|
|
|
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);
|
|
|
|
gimp_dockable_set_context (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);
|
|
|
|
gimp_dockable_set_context (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 ();
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view);
|
|
|
|
dockable = dialogs_dockable_new (view,
|
|
"Path List", "Paths",
|
|
NULL,
|
|
dialogs_set_path_context_func);
|
|
|
|
gimp_dockable_set_context (GIMP_DOCKABLE (dockable), context);
|
|
|
|
return dockable;
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_indexed_palette_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GimpImage *gimage;
|
|
GtkWidget *view;
|
|
GtkWidget *dockable;
|
|
|
|
gimage = gimp_context_get_image (context);
|
|
|
|
view = gimp_colormap_dialog_new (gimage);
|
|
|
|
dockable = dialogs_dockable_new (view,
|
|
"Indexed Palette", "Colormap",
|
|
NULL,
|
|
dialogs_set_indexed_palette_context_func);
|
|
|
|
dialogs_set_indexed_palette_context_func (GIMP_DOCKABLE (dockable), context);
|
|
|
|
g_signal_connect (G_OBJECT (view), "selected",
|
|
G_CALLBACK (dialogs_indexed_palette_selected),
|
|
dockable);
|
|
|
|
return dockable;
|
|
}
|
|
|
|
|
|
/* misc dockables */
|
|
|
|
GtkWidget *
|
|
dialogs_document_history_new (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = gimp_document_view_new (GIMP_VIEW_TYPE_LIST,
|
|
context->gimp->documents,
|
|
context,
|
|
32,
|
|
5, 3,
|
|
documents_show_context_menu);
|
|
|
|
return dialogs_dockable_new (view,
|
|
"Document History", "History",
|
|
NULL,
|
|
dialogs_set_editor_context_func);
|
|
}
|
|
|
|
GtkWidget *
|
|
dialogs_error_console_get (GimpDialogFactory *factory,
|
|
GimpContext *context)
|
|
{
|
|
static GtkWidget *view = NULL;
|
|
|
|
GtkWidget *dockable;
|
|
|
|
if (view)
|
|
return NULL;
|
|
|
|
view = error_console_create ();
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view);
|
|
|
|
dockable = dialogs_dockable_new (view,
|
|
"Error Console", "Errors",
|
|
NULL,
|
|
NULL);
|
|
|
|
return dockable;
|
|
}
|
|
|
|
|
|
/* editor dialogs */
|
|
|
|
void
|
|
dialogs_edit_brush_func (GimpData *data)
|
|
{
|
|
GimpBrush *brush;
|
|
|
|
brush = GIMP_BRUSH (data);
|
|
|
|
if (GIMP_IS_BRUSH_GENERATED (brush))
|
|
{
|
|
gimp_dialog_factory_dialog_raise (global_dialog_factory,
|
|
"gimp:brush-editor");
|
|
|
|
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)
|
|
{
|
|
GimpGradient *gradient;
|
|
|
|
gradient = GIMP_GRADIENT (data);
|
|
|
|
gimp_dialog_factory_dialog_raise (global_dialog_factory,
|
|
"gimp:gradient-editor");
|
|
|
|
gradient_editor_set_gradient (gradient_editor_dialog, gradient);
|
|
}
|
|
|
|
void
|
|
dialogs_edit_palette_func (GimpData *data)
|
|
{
|
|
GimpPalette *palette;
|
|
|
|
palette = GIMP_PALETTE (data);
|
|
|
|
gimp_dialog_factory_dialog_raise (global_dialog_factory,
|
|
"gimp:palette-editor");
|
|
|
|
palette_editor_set_palette (palette_editor_dialog, palette);
|
|
}
|
|
|
|
|
|
/* private functions */
|
|
|
|
static void
|
|
dialogs_indexed_palette_selected (GimpColormapDialog *dialog,
|
|
GimpDockable *dockable)
|
|
{
|
|
GimpContext *context;
|
|
|
|
context = (GimpContext *) g_object_get_data (G_OBJECT (dialog),
|
|
"gimp-dialogs-context");
|
|
|
|
if (context)
|
|
{
|
|
GimpImage *gimage;
|
|
GimpRGB color;
|
|
gint index;
|
|
|
|
gimage = gimp_colormap_dialog_get_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);
|
|
|
|
g_signal_connect_object (G_OBJECT (context), "brush_changed",
|
|
G_CALLBACK (gimp_preview_set_viewable),
|
|
G_OBJECT (preview),
|
|
G_CONNECT_SWAPPED);
|
|
|
|
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);
|
|
|
|
g_signal_connect_object (G_OBJECT (context), "pattern_changed",
|
|
G_CALLBACK (gimp_preview_set_viewable),
|
|
G_OBJECT (preview),
|
|
G_CONNECT_SWAPPED);
|
|
|
|
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);
|
|
|
|
g_signal_connect_object (G_OBJECT (context), "gradient_changed",
|
|
G_CALLBACK (gimp_preview_set_viewable),
|
|
G_OBJECT (preview),
|
|
G_CONNECT_SWAPPED);
|
|
|
|
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);
|
|
|
|
g_signal_connect_object (G_OBJECT (context), "palette_changed",
|
|
G_CALLBACK (gimp_preview_set_viewable),
|
|
G_OBJECT (preview),
|
|
G_CONNECT_SWAPPED);
|
|
|
|
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);
|
|
|
|
g_signal_connect_object (G_OBJECT (context), "tool_changed",
|
|
G_CALLBACK (gimp_preview_set_viewable),
|
|
G_OBJECT (preview),
|
|
G_CONNECT_SWAPPED);
|
|
|
|
return preview;
|
|
}
|
|
|
|
static void
|
|
dialogs_set_view_context_func (GimpDockable *dockable,
|
|
GimpContext *context)
|
|
{
|
|
GimpContainerView *view;
|
|
|
|
view = (GimpContainerView *) g_object_get_data (G_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 *) g_object_get_data (G_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 *) g_object_get_data (G_OBJECT (dockable),
|
|
"gimp-dialogs-view");
|
|
|
|
if (view)
|
|
{
|
|
if (dockable->context)
|
|
{
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (dockable->context),
|
|
dialogs_drawable_view_image_changed,
|
|
view);
|
|
}
|
|
|
|
if (context)
|
|
{
|
|
g_signal_connect (G_OBJECT (context), "image_changed",
|
|
G_CALLBACK (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);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void
|
|
dialogs_set_path_context_func (GimpDockable *dockable,
|
|
GimpContext *context)
|
|
{
|
|
GtkWidget *view;
|
|
|
|
view = (GtkWidget *) g_object_get_data (G_OBJECT (dockable),
|
|
"gimp-dialogs-view");
|
|
|
|
if (view)
|
|
{
|
|
if (dockable->context)
|
|
{
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (dockable->context),
|
|
dialogs_path_view_image_changed,
|
|
view);
|
|
}
|
|
|
|
if (context)
|
|
{
|
|
g_signal_connect (G_OBJECT (context), "image_changed",
|
|
G_CALLBACK (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);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void
|
|
dialogs_set_indexed_palette_context_func (GimpDockable *dockable,
|
|
GimpContext *context)
|
|
{
|
|
GimpColormapDialog *view;
|
|
|
|
view = (GimpColormapDialog *) g_object_get_data (G_OBJECT (dockable),
|
|
"gimp-dialogs-view");
|
|
|
|
if (view)
|
|
{
|
|
if (dockable->context)
|
|
{
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (dockable->context),
|
|
dialogs_indexed_palette_image_changed,
|
|
view);
|
|
}
|
|
|
|
if (context)
|
|
{
|
|
g_signal_connect (G_OBJECT (context), "image_changed",
|
|
G_CALLBACK (dialogs_indexed_palette_image_changed),
|
|
view);
|
|
|
|
dialogs_indexed_palette_image_changed (context,
|
|
gimp_context_get_image (context),
|
|
view);
|
|
}
|
|
else
|
|
{
|
|
dialogs_indexed_palette_image_changed (NULL, NULL, view);
|
|
}
|
|
}
|
|
}
|
|
|
|
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);
|
|
|
|
g_object_set_data (G_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);
|
|
}
|
|
|
|
static void
|
|
dialogs_indexed_palette_image_changed (GimpContext *context,
|
|
GimpImage *gimage,
|
|
GimpColormapDialog *ipal)
|
|
{
|
|
gimp_colormap_dialog_set_image (ipal, gimage);
|
|
}
|