gimp/app/gui/tool-options-dialog.c
Michael Natterer 02fde14c95 build display/ before tools/.
2001-11-08  Michael Natterer  <mitch@gimp.org>

	* app/Makefile.am: build display/ before tools/.

	* app/devices.c: devices_check_change(): added all events
	which have a GdkDevice pointer.

	* app/gimpprogress.c: include "display-types.h" instead of
	"core-types.h".

	* app/core/Makefile.am
	* app/core/gimpdrawable-bucket-fill.[ch]: new files: the bucket_fill
	stuff taken from tools/gimpbucketfilltool.[ch].

	* app/core/core-types.h: added "BucketFillMode".

	* app/core/gimpimage-mask-select.[ch]: cleanup.

	* app/core/gimpmarshal.list: added more marshallers for GimpTool's
	new signal signatures.

	* app/core/gimpmarshal.[ch]: regenerated.

	* app/display/Makefile.am
	* app/display/gimpdisplayshell-dnd.[ch]
	* app/display/gimpdisplayshell-layer-select.[ch]: new files: the
	canvas drop callbacks from gimpdisplayshell-callbacks.[ch] and
	the stuff formerly knows as gui/layer-select.[ch].

	* app/display/gimpdisplay.h: don't include "gui/gui-types.h".

	* app/display/gximage.c: include "display-types.h".

	* app/display/gimpdisplay-foreach.c
	* app/display/gimpdisplayshell.[ch]: call gdsplay_delete(), don't
	destroy the shell widget.

	* app/gui/Makefile.am
	* app/gui/layer-select.[ch]: removed.

	* app/gui/gradients-commands.c: fixed "Save as POV" fprintf()s.

	* app/gui/preferences-dialog.c: removed the layer_select stuff
	because it is useless with the new preview system.

	* app/gui/tool-options-dialog.c: send the correct data to the
	close_callback.

	* app/gui/tools-commands.c: changed to follow the new
	gimp_tool_initialize() semantics (see below).

	Tool & canvas event handling chainsawing:

	* app/tools/tools-types.h: new struct GimpCoords which contains
	x, y, pressure, tilt etc.

	* app/display/gimpdisplayshell-callbacks.[ch]: added utility
	functions which transparently retreive the current event's
	GimpCoords or take it from the device directly if the event has
	none. Pass GimpCoords _in_image_coordinates_ to all tool
	functions.

	Most important: don't pass GdkEvents and display coordinates to
	tools any more.

	* app/tools/gimptool.[ch]: changed virtual functions to take
	GimpCoords, time and state separately instead of GdkEvents.

	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpblendtool.c
	* app/tools/gimpbucketfilltool.[ch]
	* app/tools/gimpbycolorselecttool.c
	* app/tools/gimpclonetool.c
	* app/tools/gimpcolorpickertool.c
	* app/tools/gimpconvolvetool.c
	* app/tools/gimpcroptool.[ch]
	* app/tools/gimpcurvestool.c
	* app/tools/gimpdodgeburntool.c
	* app/tools/gimpdrawtool.c
	* app/tools/gimpeditselectiontool.[ch]
	* app/tools/gimperasertool.c
	* app/tools/gimpfliptool.c
	* app/tools/gimpfreeselecttool.[ch]
	* app/tools/gimpfuzzyselecttool.c
	* app/tools/gimpinktool.c
	* app/tools/gimpiscissorstool.c
	* app/tools/gimpmagnifytool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimpmovetool.c
	* app/tools/gimppainttool.c
	* app/tools/gimppathtool.[ch]
	* app/tools/gimprectselecttool.c
	* app/tools/gimprotatetool.c
	* app/tools/gimpselectiontool.[ch]
	* app/tools/gimpsmudgetool.c
	* app/tools/gimptexttool.c
	* app/tools/gimptransformtool.[ch]
	* app/tools/path_tool.[ch]
	* app/tools/selection_options.c: tons and tons of changes:

	- changed to use the new virtual function parameters.
	- removed zillions of gdisplay_untransform_coords().
	- get the active drawable's offsets manually in many cases.
	  (questionable, but IMHO ok because it's obvious and not simply a
	  "TRUE" passed to some function)
	- reordered some functions to be consistent across tools.
	- some tools had to be changed to work on image coords, not
	  display ones (esp. crop).
	- fixed strange rotate tool behaviour which should be backported
	  to stable.
	- some stuff i came across.
	- indentation and other paranoia.
	- rounding of coordinated may be broken in some tools.
	- new bugs guaranteed.

	* app/tools/tool_manager.[ch]: new semantic of
	tool_manager_initialize_active() (looked at the places where it
	was used from and put common code together). Should be a bit
	better now :)

	* app/tools/gimpblendtool.c
	* app/tools/transform_options.c: use the new GTK+ feature that a
	widget (toggle button) can be a frame's title for this tools' tool
	options.

	* app/widgets/widgets-types.h: stuff.

	* themes/Default/gtkrc: s/GtkDialog/GimpDialog/.

	* tools/pdbgen/Makefile.am: don't scan tools/gimpbucketfilltool.h
	any more.

	* tools/pdbgen/enums.pl: regenerated.

	* tools/pdbgen/pdb/tools.pdb: changed bucket_fill wrapper.

	* app/pdb/tools_cmds.c: regenerated.
2001-11-08 19:14:51 +00:00

315 lines
8.4 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 "tools/tools-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpdnd.h"
#include "widgets/gimppreview.h"
#include "widgets/gimpwidgets-utils.h"
#include "tools/gimptool.h"
#include "tools/tool_options.h"
#include "tools/tool_manager.h"
#include "tool-options-dialog.h"
#include "libgimp/gimpintl.h"
/* local function prototypes */
static void tool_options_dialog_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
gpointer data);
static void tool_options_dialog_drop_tool (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static GimpViewable * tool_options_dialog_drag_tool (GtkWidget *widget,
gpointer data);
static void tool_options_dialog_close_callback (GtkWidget *widget,
gpointer data);
static void tool_options_dialog_reset_callback (GtkWidget *widget,
gpointer data);
/* private variables */
static GtkWidget *options_shell = NULL;
static GtkWidget *options_vbox = NULL;
static GtkWidget *options_label = NULL;
static GtkWidget *options_preview = NULL;
static GtkWidget *options_eventbox = NULL;
static GtkWidget *options_reset_button = NULL;
static GimpToolOptions *visible_tool_options = NULL;
/* public functions */
GtkWidget *
tool_options_dialog_create (Gimp *gimp)
{
GimpToolInfo *tool_info;
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *vbox;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
if (options_shell)
return options_shell;
tool_info = gimp_context_get_tool (gimp_get_user_context (gimp));
if (! tool_info)
{
g_warning ("%s(): no tool info registered for active tool",
G_GNUC_FUNCTION);
}
/* The shell and main vbox */
options_shell =
gimp_dialog_new (_("Tool Options"), "tool_options",
tool_manager_help_func,
"dialogs/tool_options.html",
GTK_WIN_POS_NONE,
FALSE, TRUE, TRUE,
GIMP_STOCK_RESET, tool_options_dialog_reset_callback,
gimp, NULL, &options_reset_button, FALSE, FALSE,
GTK_STOCK_CLOSE, tool_options_dialog_close_callback,
NULL, NULL, NULL, TRUE, TRUE,
NULL);
gtk_dialog_set_has_separator (GTK_DIALOG (options_shell), FALSE);
/* The outer frame */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options_shell)->vbox), frame);
gtk_widget_show (frame);
/* The vbox containing the title frame and the options vbox */
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
/* The title frame */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
options_eventbox = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (frame), options_eventbox);
gtk_widget_show (options_eventbox);
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_add (GTK_CONTAINER (options_eventbox), hbox);
gtk_widget_show (hbox);
options_preview = gimp_preview_new (GIMP_VIEWABLE (tool_info), 22, 0, FALSE);
gtk_box_pack_start (GTK_BOX (hbox), options_preview, FALSE, FALSE, 0);
gtk_widget_show (options_preview);
options_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), options_label, FALSE, FALSE, 1);
gtk_widget_show (options_label);
options_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (options_vbox), 2);
gtk_box_pack_start (GTK_BOX (vbox), options_vbox, FALSE, FALSE, 0);
gtk_widget_show (options_vbox);
/* dnd stuff */
gimp_gtk_drag_dest_set_by_type (options_shell,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
GIMP_TYPE_TOOL_INFO,
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (options_shell,
GIMP_TYPE_TOOL_INFO,
tool_options_dialog_drop_tool,
gimp);
gimp_gtk_drag_source_set_by_type (options_eventbox,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
GIMP_TYPE_TOOL_INFO,
GDK_ACTION_COPY);
gimp_dnd_viewable_source_set (options_eventbox,
GIMP_TYPE_TOOL_INFO,
tool_options_dialog_drag_tool,
gimp);
g_signal_connect_object (G_OBJECT (gimp_get_user_context (gimp)),
"tool_changed",
G_CALLBACK (tool_options_dialog_tool_changed),
G_OBJECT (options_shell),
0);
tool_info = gimp_context_get_tool (gimp_get_user_context (gimp));
tool_options_dialog_tool_changed (gimp_get_user_context (gimp),
tool_info,
options_shell);
return options_shell;
}
void
tool_options_dialog_free (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (options_shell)
{
gtk_widget_destroy (options_shell);
options_shell = NULL;
}
}
/* private functions */
static void
tool_options_dialog_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
gpointer data)
{
if (visible_tool_options &&
(! tool_info || tool_info->tool_options != visible_tool_options))
{
gtk_widget_hide (visible_tool_options->main_vbox);
visible_tool_options = NULL;
}
if (tool_info)
{
if (tool_info->tool_options)
{
if (! tool_info->tool_options->main_vbox->parent)
gtk_box_pack_start (GTK_BOX (options_vbox),
tool_info->tool_options->main_vbox,
FALSE, FALSE, 0);
gtk_widget_show (tool_info->tool_options->main_vbox);
visible_tool_options = tool_info->tool_options;
gtk_label_set_text (GTK_LABEL (options_label),
tool_info->blurb);
if (tool_info->tool_options->reset_func)
gtk_widget_set_sensitive (options_reset_button, TRUE);
else
gtk_widget_set_sensitive (options_reset_button, FALSE);
}
else
{
gtk_widget_set_sensitive (options_reset_button, FALSE);
}
gimp_preview_set_viewable (GIMP_PREVIEW (options_preview),
GIMP_VIEWABLE (tool_info));
gimp_help_set_help_data (options_label->parent->parent,
tool_info->help,
tool_info->help_data);
}
}
static void
tool_options_dialog_drop_tool (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
Gimp *gimp;
gimp = GIMP (data);
gimp_context_set_tool (gimp_get_user_context (gimp),
GIMP_TOOL_INFO (viewable));
}
GimpViewable *
tool_options_dialog_drag_tool (GtkWidget *widget,
gpointer data)
{
Gimp *gimp;
gimp = GIMP (data);
return (GimpViewable *) gimp_context_get_tool (gimp_get_user_context (gimp));
}
static void
tool_options_dialog_close_callback (GtkWidget *widget,
gpointer data)
{
GtkWidget *shell;
shell = (GtkWidget *) data;
gtk_widget_hide (shell);
}
static void
tool_options_dialog_reset_callback (GtkWidget *widget,
gpointer data)
{
GimpToolInfo *tool_info;
GimpTool *active_tool;
Gimp *gimp;
gimp = GIMP (data);
active_tool = tool_manager_get_active (gimp);
if (! active_tool)
return;
tool_info = active_tool->tool_info;
if (! tool_info)
{
g_warning ("%s(): no tool info registered for %s",
G_GNUC_FUNCTION,
g_type_name (G_TYPE_FROM_INSTANCE (active_tool)));
}
if (tool_info->tool_options->reset_func)
tool_info->tool_options->reset_func (tool_info->tool_options);
}