
2001-06-29 Michael Natterer <mitch@gimp.org> * app/appenums.h: removed GimpFillType. * app/gimprc.c: parse the session-info's new "aux-info" field. * app/global_edit.[ch]: removed the old "Paste Named" dialog and prefixed all functions with "gimp_". * app/core/core-types.h: added GimpFillType. * app/core/gimpbrush.[ch]: new signal "spacing_changed". * app/gui/Makefile.am * app/gui/tools-commands.[ch]: one more file cut out of commands.[ch]. * app/gui/commands.[ch]: removed the tools stuff here. * app/gui/brush-select.[ch] * app/gui/dialogs-constructors.c: use the new GimpBrushFactoryView (see below). * app/gui/dialogs-commands.[ch] * app/gui/menus.[ch]: - Made it 64bit safe again by passing the dialog factory's identifiers as GQuarks, not as guints created by GPOINTER_TO_UINT(). - Added a "gchar *quark_string" field to GimpItemFactoryEntry which gets transformed into a GQuark by menus_create_item(). - Added SEPARATOR() and BRANCH() macros which make the *_entries[] arrays more readable. - Added a menu item to show/hide GimpImageDock's image menu. - Removed file_last_opened_cmd_callback(). * app/gui/edit-commands.c: the global_edit functions are "gimp_" prefixed now. * app/gui/file-commands.[ch]: added file_last_opened_cmd_callback() here. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpbrushfactoryview.[ch]: new widget: a GimpDataFactory subclass with a "spacing" scale. * app/widgets/gimpcontainereditor.[ch]: - Connect to the GimpContainerView's "select_item", "activate_item" and "context_item" signals here once instead of in each subclass and dispatch them via new virtual functions. - Added a convenience function which makes DND to the buttons much less painful for subclasses. * app/widgets/gimpbufferview.c * app/widgets/gimpdatafactoryview.[ch]: changed accordingly. * app/widgets/gimpdialogfactory.[ch]: - Added gimp_dialog_factory_dialog_raise() which can raise toplevel dialogs _and_ dockables (and creates them if they are not open yet). - Keep track of all created dialogs (not only toplevels). - Added an "aux_info" field to GimpSessionInfo which is a GList of gchar* and is saved in sessionrc. - Remember if GimpImageDock's image menu is visible by using an aux_info string. - The code did not become nicer with all those new constraints. I have to add comments before I forget how it works. * app/widgets/gimpdockbook.c: set the state of the "Show Image Menu" menu item before popping up the item factory. * app/widgets/gimpimagedock.[ch]: added gimp_image_dock_set_show_image_meu(). * plug-ins/gdyntext/gdyntext.c * plug-ins/perl/examples/fit-text * plug-ins/perl/examples/terral_text * plug-ins/perl/examples/tex-to-float: register all text rendering plug-ins under <Image>/Filters/Text * app/pdb/brush_select_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/enums.pl * po/POTFILES.in: changed according to all the stuff above.
320 lines
6.6 KiB
C
320 lines
6.6 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 "libgimpwidgets/gimpwidgets.h"
|
|
|
|
#include "core/core-types.h"
|
|
#include "tools/tools-types.h"
|
|
|
|
#include "core/gimpbuffer.h"
|
|
#include "core/gimpcontainer.h"
|
|
#include "core/gimpcontext.h"
|
|
#include "core/gimpdrawable.h"
|
|
#include "core/gimpimage.h"
|
|
#include "core/gimpimage-mask.h"
|
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
#include "widgets/gimpdialogfactory.h"
|
|
|
|
#include "dialogs.h"
|
|
#include "edit-commands.h"
|
|
|
|
#include "context_manager.h"
|
|
#include "gdisplay.h"
|
|
#include "global_edit.h"
|
|
#include "undo.h"
|
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
#define return_if_no_display(gdisp) \
|
|
gdisp = gdisplay_active (); \
|
|
if (!gdisp) return
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
static void cut_named_buffer_callback (GtkWidget *widget,
|
|
gchar *name,
|
|
gpointer data);
|
|
static void copy_named_buffer_callback (GtkWidget *widget,
|
|
gchar *name,
|
|
gpointer data);
|
|
|
|
|
|
/* public functions */
|
|
|
|
void
|
|
edit_undo_cmd_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp;
|
|
return_if_no_display (gdisp);
|
|
|
|
undo_pop (gdisp->gimage);
|
|
}
|
|
|
|
void
|
|
edit_redo_cmd_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp;
|
|
return_if_no_display (gdisp);
|
|
|
|
undo_redo (gdisp->gimage);
|
|
}
|
|
|
|
void
|
|
edit_cut_cmd_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp;
|
|
return_if_no_display (gdisp);
|
|
|
|
/* stop any active tool */
|
|
tool_manager_control_active (HALT, gdisp);
|
|
|
|
if (gimp_edit_cut (gdisp->gimage,
|
|
gimp_image_active_drawable (gdisp->gimage)))
|
|
{
|
|
gdisplays_flush ();
|
|
}
|
|
}
|
|
|
|
void
|
|
edit_copy_cmd_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp;
|
|
return_if_no_display (gdisp);
|
|
|
|
gimp_edit_copy (gdisp->gimage,
|
|
gimp_image_active_drawable (gdisp->gimage));
|
|
}
|
|
|
|
void
|
|
edit_paste_cmd_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp;
|
|
return_if_no_display (gdisp);
|
|
|
|
if (global_buffer)
|
|
{
|
|
/* stop any active tool */
|
|
tool_manager_control_active (HALT, gdisp);
|
|
|
|
if (gimp_edit_paste (gdisp->gimage,
|
|
gimp_image_active_drawable (gdisp->gimage),
|
|
global_buffer,
|
|
FALSE))
|
|
{
|
|
gdisplays_update_title (gdisp->gimage);
|
|
gdisplays_flush ();
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
edit_paste_into_cmd_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp;
|
|
return_if_no_display (gdisp);
|
|
|
|
if (global_buffer)
|
|
{
|
|
/* stop any active tool */
|
|
tool_manager_control_active (HALT, gdisp);
|
|
|
|
if (gimp_edit_paste (gdisp->gimage,
|
|
gimp_image_active_drawable (gdisp->gimage),
|
|
global_buffer,
|
|
TRUE))
|
|
{
|
|
gdisplays_update_title (gdisp->gimage);
|
|
gdisplays_flush ();
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
edit_paste_as_new_cmd_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp;
|
|
return_if_no_display (gdisp);
|
|
|
|
if (global_buffer)
|
|
{
|
|
/* stop any active tool */
|
|
tool_manager_control_active (HALT, gdisp);
|
|
|
|
gimp_edit_paste_as_new (gdisp->gimage,
|
|
global_buffer);
|
|
}
|
|
}
|
|
|
|
void
|
|
edit_named_cut_cmd_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp;
|
|
GtkWidget *qbox;
|
|
|
|
return_if_no_display (gdisp);
|
|
|
|
/* stop any active tool */
|
|
tool_manager_control_active (HALT, gdisp);
|
|
|
|
qbox = gimp_query_string_box (_("Cut Named"),
|
|
gimp_standard_help_func,
|
|
"dialogs/cut_named.html",
|
|
_("Enter a name for this buffer"),
|
|
NULL,
|
|
GTK_OBJECT (gdisp->gimage), "destroy",
|
|
cut_named_buffer_callback, gdisp->gimage);
|
|
gtk_widget_show (qbox);
|
|
}
|
|
|
|
void
|
|
edit_named_copy_cmd_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp;
|
|
GtkWidget *qbox;
|
|
|
|
return_if_no_display (gdisp);
|
|
|
|
qbox = gimp_query_string_box (_("Copy Named"),
|
|
gimp_standard_help_func,
|
|
"dialogs/copy_named.html",
|
|
_("Enter a name for this buffer"),
|
|
NULL,
|
|
GTK_OBJECT (gdisp->gimage), "destroy",
|
|
copy_named_buffer_callback, gdisp->gimage);
|
|
gtk_widget_show (qbox);
|
|
}
|
|
|
|
void
|
|
edit_named_paste_cmd_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp;
|
|
return_if_no_display (gdisp);
|
|
|
|
gimp_dialog_factory_dialog_raise (global_dock_factory, "gimp:buffer-list");
|
|
}
|
|
|
|
void
|
|
edit_clear_cmd_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp;
|
|
return_if_no_display (gdisp);
|
|
|
|
gimp_edit_clear (gdisp->gimage, gimp_image_active_drawable (gdisp->gimage));
|
|
gdisplays_flush ();
|
|
}
|
|
|
|
void
|
|
edit_fill_cmd_callback (GtkWidget *widget,
|
|
gpointer data,
|
|
guint action)
|
|
{
|
|
GimpFillType fill_type;
|
|
GDisplay *gdisp;
|
|
|
|
return_if_no_display (gdisp);
|
|
|
|
fill_type = (GimpFillType) action;
|
|
|
|
gimp_edit_fill (gdisp->gimage,
|
|
gimp_image_active_drawable (gdisp->gimage),
|
|
fill_type);
|
|
|
|
gdisplays_flush ();
|
|
}
|
|
|
|
void
|
|
edit_stroke_cmd_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp;
|
|
return_if_no_display (gdisp);
|
|
|
|
gimage_mask_stroke (gdisp->gimage,
|
|
gimp_image_active_drawable (gdisp->gimage));
|
|
|
|
gdisplays_flush ();
|
|
}
|
|
|
|
|
|
/* private functions */
|
|
|
|
static void
|
|
cut_named_buffer_callback (GtkWidget *widget,
|
|
gchar *name,
|
|
gpointer data)
|
|
{
|
|
TileManager *new_tiles;
|
|
GimpImage *gimage;
|
|
|
|
gimage = (GimpImage *) data;
|
|
|
|
new_tiles = gimp_edit_cut (gimage,
|
|
gimp_image_active_drawable (gimage));
|
|
|
|
if (new_tiles)
|
|
{
|
|
GimpBuffer *buffer;
|
|
|
|
buffer = gimp_buffer_new (new_tiles, name);
|
|
gimp_container_add (named_buffers, GIMP_OBJECT (buffer));
|
|
}
|
|
|
|
gdisplays_flush ();
|
|
}
|
|
|
|
static void
|
|
copy_named_buffer_callback (GtkWidget *widget,
|
|
gchar *name,
|
|
gpointer data)
|
|
{
|
|
TileManager *new_tiles;
|
|
GimpImage *gimage;
|
|
|
|
gimage = (GimpImage *) data;
|
|
|
|
new_tiles = gimp_edit_copy (gimage,
|
|
gimp_image_active_drawable (gimage));
|
|
|
|
if (new_tiles)
|
|
{
|
|
GimpBuffer *buffer;
|
|
|
|
buffer = gimp_buffer_new (new_tiles, name);
|
|
gimp_container_add (named_buffers, GIMP_OBJECT (buffer));
|
|
}
|
|
}
|