Files
gimp/app/gui/edit-commands.c
Michael Natterer d463a5efdf removed a useless g_return_if_fail().
2001-11-23  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpcontainer.c: removed a useless g_return_if_fail().

	* app/widgets/gimpcontainereditor.h: removed GimpViewType enum.

	* app/widgets/widgets-types.h: added it here.

	* app/widgets/gimpcontainerview-utils.[ch]: added a utility function
	which gets the GimpContainerView out of a GimpDockable.

	* app/widgets/gimpdialogfactory.[ch]: added support for saving and
	loading of each GimpDockable's preview size. Store the dialog's
	default preview size in the GimpDialogFactoryEntry.  Pass the
	preview_size to each created dialog.

	* app/gui/menus.c: added menu items for setting the preview_size
	and switching between list and grid view. Removed the item
	overkill in the "Add Tab" submenu.

	* app/gui/dialogs-commands.[ch]: added callbacks for the new items.

	* app/widgets/gimpdockbook.c: set the item's state before showing
	the menu.

	* app/errors.c
	* app/gui/dialogs-constructors.[ch]
	* app/gui/dialogs.c
	* app/gui/edit-commands.c
	* app/gui/gui.c
	* app/gui/indicator-area.c
	* app/gui/toolbox.c: changed accordingly.

	* app/tools/selection_options.[ch]: cleaned up the selection
	options and added some tooltips. Much more to do...
2001-11-23 16:25:01 +00:00

320 lines
7.0 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 "gui-types.h"
#include "core/gimp.h"
#include "core/gimpbuffer.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpedit.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "tools/tool_manager.h"
#include "widgets/gimpdialogfactory.h"
#include "dialogs.h"
#include "edit-commands.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
#define return_if_no_display(gdisp,data) \
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
if (! gdisp) \
return
#define return_if_no_image(gimage,data) \
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
if (! gimage) \
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)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
undo_pop (gimage);
}
void
edit_redo_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
undo_redo (gimage);
}
void
edit_cut_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, 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)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
gimp_edit_copy (gimage, gimp_image_active_drawable (gimage));
}
void
edit_paste_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_paste (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage),
gdisp->gimage->gimp->global_buffer,
FALSE))
{
gdisplays_flush ();
}
}
}
void
edit_paste_into_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
if (gimp_edit_paste (gdisp->gimage,
gimp_image_active_drawable (gdisp->gimage),
gdisp->gimage->gimp->global_buffer,
TRUE))
{
gdisplays_flush ();
}
}
}
void
edit_paste_as_new_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
if (gdisp->gimage->gimp->global_buffer)
{
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
gimp_edit_paste_as_new (gdisp->gimage->gimp,
gdisp->gimage,
gdisp->gimage->gimp->global_buffer);
}
}
void
edit_named_cut_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
GtkWidget *qbox;
return_if_no_display (gdisp, data);
/* stop any active tool */
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
qbox = gimp_query_string_box (_("Cut Named"),
gimp_standard_help_func,
"dialogs/cut_named.html",
_("Enter a name for this buffer"),
NULL,
G_OBJECT (gdisp->gimage), "disconnect",
cut_named_buffer_callback, gdisp->gimage);
gtk_widget_show (qbox);
}
void
edit_named_copy_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GtkWidget *qbox;
return_if_no_image (gimage, data);
qbox = gimp_query_string_box (_("Copy Named"),
gimp_standard_help_func,
"dialogs/copy_named.html",
_("Enter a name for this buffer"),
NULL,
G_OBJECT (gimage), "disconnect",
copy_named_buffer_callback, gimage);
gtk_widget_show (qbox);
}
void
edit_named_paste_cmd_callback (GtkWidget *widget,
gpointer data)
{
gimp_dialog_factory_dialog_raise (global_dock_factory, "gimp:buffer-list", -1);
}
void
edit_clear_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
gimp_edit_clear (gimage, gimp_image_active_drawable (gimage));
gdisplays_flush ();
}
void
edit_fill_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpImage *gimage;
GimpFillType fill_type;
return_if_no_image (gimage, data);
fill_type = (GimpFillType) action;
gimp_edit_fill (gimage,
gimp_image_active_drawable (gimage),
fill_type);
gdisplays_flush ();
}
void
edit_stroke_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
gimage_mask_stroke (gimage,
gimp_image_active_drawable (gimage),
gimp_get_current_context (gimage->gimp));
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 (gimage->gimp->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 (gimage->gimp->named_buffers, GIMP_OBJECT (buffer));
}
}