2001-01-22 05:08:44 +00:00
|
|
|
/* 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>
|
|
|
|
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-22 05:08:44 +00:00
|
|
|
|
2001-05-25 01:24:12 +00:00
|
|
|
#include "tools/tools-types.h"
|
2001-01-22 05:08:44 +00:00
|
|
|
|
2001-07-07 12:17:23 +00:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimplist.h"
|
2001-05-09 22:34:59 +00:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
|
2001-05-08 19:29:15 +00:00
|
|
|
#include "widgets/gimpdnd.h"
|
2001-04-11 01:13:53 +00:00
|
|
|
#include "widgets/gimppreview.h"
|
2001-05-25 16:04:54 +00:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2001-04-11 01:13:53 +00:00
|
|
|
|
2001-05-25 01:24:12 +00:00
|
|
|
#include "tools/gimptool.h"
|
|
|
|
#include "tools/tool_options.h"
|
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
|
|
|
#include "tool-options-dialog.h"
|
|
|
|
|
2001-07-07 12:17:23 +00:00
|
|
|
#include "app_procs.h"
|
2001-01-22 05:08:44 +00:00
|
|
|
|
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
static void tool_options_dialog_tool_changed (GimpContext *context,
|
|
|
|
GimpToolInfo *tool_info,
|
|
|
|
gpointer data);
|
|
|
|
static GimpViewable * tool_options_dialog_drag_tool (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void tool_options_dialog_drop_tool (GtkWidget *widget,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data);
|
|
|
|
static void tool_options_dialog_reset_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void tool_options_dialog_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
2001-01-22 05:08:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* private variables */
|
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
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;
|
2001-01-22 05:08:44 +00:00
|
|
|
|
2001-07-17 20:50:01 +00:00
|
|
|
static GimpToolOptions *visible_tool_options = NULL;
|
2001-01-22 05:08:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2001-04-17 16:00:27 +00:00
|
|
|
GtkWidget *
|
|
|
|
tool_options_dialog_create (void)
|
2001-01-22 05:08:44 +00:00
|
|
|
{
|
2001-02-23 21:32:47 +00:00
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
|
2001-04-17 16:00:27 +00:00
|
|
|
if (options_shell)
|
|
|
|
return options_shell;
|
|
|
|
|
2001-07-07 12:17:23 +00:00
|
|
|
tool_info = gimp_context_get_tool (gimp_get_user_context (the_gimp));
|
2001-02-23 21:32:47 +00:00
|
|
|
|
|
|
|
if (! tool_info)
|
|
|
|
{
|
|
|
|
g_warning ("%s(): no tool info registered for active tool",
|
|
|
|
G_GNUC_FUNCTION);
|
|
|
|
}
|
2001-01-22 05:08:44 +00:00
|
|
|
|
|
|
|
/* The shell and main vbox */
|
|
|
|
options_shell =
|
|
|
|
gimp_dialog_new (_("Tool Options"), "tool_options",
|
2001-02-23 21:32:47 +00:00
|
|
|
tool_manager_help_func,
|
2001-01-22 05:08:44 +00:00
|
|
|
"dialogs/tool_options.html",
|
|
|
|
GTK_WIN_POS_NONE,
|
|
|
|
FALSE, TRUE, TRUE,
|
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
_("Reset"), tool_options_dialog_reset_callback,
|
2001-01-22 05:08:44 +00:00
|
|
|
NULL, NULL, &options_reset_button, FALSE, FALSE,
|
2001-02-23 21:32:47 +00:00
|
|
|
|
2001-07-30 17:17:36 +00:00
|
|
|
GTK_STOCK_CLOSE, tool_options_dialog_close_callback,
|
2001-01-22 05:08:44 +00:00
|
|
|
NULL, NULL, NULL, TRUE, TRUE,
|
|
|
|
|
|
|
|
NULL);
|
|
|
|
|
2001-07-31 16:55:59 +00:00
|
|
|
gtk_dialog_set_has_separator (GTK_DIALOG (options_shell), FALSE);
|
2001-02-23 21:32:47 +00:00
|
|
|
|
2001-01-22 05:08:44 +00:00
|
|
|
/* 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);
|
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
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);
|
2001-01-22 05:08:44 +00:00
|
|
|
|
|
|
|
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 */
|
2001-02-23 21:32:47 +00:00
|
|
|
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, NULL);
|
|
|
|
|
|
|
|
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, NULL);
|
|
|
|
|
2001-07-31 16:55:59 +00:00
|
|
|
g_signal_connect_object (G_OBJECT (gimp_get_user_context (the_gimp)),
|
|
|
|
"tool_changed",
|
|
|
|
G_CALLBACK (tool_options_dialog_tool_changed),
|
|
|
|
G_OBJECT (options_shell),
|
|
|
|
0);
|
2001-02-23 21:32:47 +00:00
|
|
|
|
2001-07-07 12:17:23 +00:00
|
|
|
tool_info = gimp_context_get_tool (gimp_get_user_context (the_gimp));
|
2001-02-23 21:32:47 +00:00
|
|
|
|
2001-07-07 12:17:23 +00:00
|
|
|
tool_options_dialog_tool_changed (gimp_get_user_context (the_gimp),
|
2001-02-23 21:32:47 +00:00
|
|
|
tool_info,
|
|
|
|
NULL);
|
2001-01-22 05:08:44 +00:00
|
|
|
|
2001-04-17 16:00:27 +00:00
|
|
|
return options_shell;
|
2001-01-22 05:08:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tool_options_dialog_free (void)
|
|
|
|
{
|
2001-04-17 16:00:27 +00:00
|
|
|
if (options_shell)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (options_shell);
|
|
|
|
options_shell = NULL;
|
|
|
|
}
|
2001-01-22 05:08:44 +00:00
|
|
|
}
|
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tool_options_dialog_tool_changed (GimpContext *context,
|
|
|
|
GimpToolInfo *tool_info,
|
|
|
|
gpointer data)
|
2001-01-22 05:08:44 +00:00
|
|
|
{
|
2001-02-23 21:32:47 +00:00
|
|
|
if (visible_tool_options &&
|
|
|
|
(! tool_info || tool_info->tool_options != visible_tool_options))
|
|
|
|
{
|
|
|
|
gtk_widget_hide (visible_tool_options->main_vbox);
|
2001-01-22 05:08:44 +00:00
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
visible_tool_options = NULL;
|
|
|
|
}
|
2001-01-22 05:08:44 +00:00
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
if (tool_info)
|
|
|
|
{
|
|
|
|
if (tool_info->tool_options)
|
|
|
|
{
|
2001-06-04 23:11:31 +00:00
|
|
|
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);
|
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
gtk_widget_show (tool_info->tool_options->main_vbox);
|
2001-01-22 05:08:44 +00:00
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
visible_tool_options = tool_info->tool_options;
|
2001-01-22 05:08:44 +00:00
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
gtk_label_set_text (GTK_LABEL (options_label),
|
|
|
|
tool_info->blurb);
|
2001-01-22 05:08:44 +00:00
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
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);
|
|
|
|
}
|
2001-01-22 05:08:44 +00:00
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
gimp_preview_set_viewable (GIMP_PREVIEW (options_preview),
|
|
|
|
GIMP_VIEWABLE (tool_info));
|
2001-01-22 05:08:44 +00:00
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
gimp_help_set_help_data (options_label->parent->parent,
|
|
|
|
tool_info->help,
|
|
|
|
tool_info->help_data);
|
2001-01-22 05:08:44 +00:00
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
}
|
|
|
|
}
|
2001-01-22 05:08:44 +00:00
|
|
|
|
|
|
|
static void
|
2001-02-23 21:32:47 +00:00
|
|
|
tool_options_dialog_drop_tool (GtkWidget *widget,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
2001-01-22 05:08:44 +00:00
|
|
|
{
|
2001-07-07 12:17:23 +00:00
|
|
|
gimp_context_set_tool (gimp_get_user_context (the_gimp),
|
|
|
|
GIMP_TOOL_INFO (viewable));
|
2001-01-22 05:08:44 +00:00
|
|
|
}
|
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
GimpViewable *
|
|
|
|
tool_options_dialog_drag_tool (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-01-22 05:08:44 +00:00
|
|
|
{
|
2001-07-07 12:17:23 +00:00
|
|
|
return (GimpViewable *) gimp_context_get_tool (gimp_get_user_context (the_gimp));
|
2001-01-22 05:08:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-02-23 21:32:47 +00:00
|
|
|
tool_options_dialog_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-01-22 05:08:44 +00:00
|
|
|
{
|
|
|
|
GtkWidget *shell;
|
|
|
|
|
|
|
|
shell = (GtkWidget *) data;
|
2001-02-23 21:32:47 +00:00
|
|
|
|
2001-01-22 05:08:44 +00:00
|
|
|
gimp_dialog_hide (shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-02-23 21:32:47 +00:00
|
|
|
tool_options_dialog_reset_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-01-22 05:08:44 +00:00
|
|
|
{
|
2001-02-23 21:32:47 +00:00
|
|
|
GimpToolInfo *tool_info;
|
2001-07-07 17:36:00 +00:00
|
|
|
GimpTool *active_tool;
|
2001-02-23 21:32:47 +00:00
|
|
|
GtkWidget *shell;
|
2001-01-22 05:08:44 +00:00
|
|
|
|
|
|
|
shell = (GtkWidget *) data;
|
|
|
|
|
2001-07-07 17:36:00 +00:00
|
|
|
active_tool = tool_manager_get_active (the_gimp);
|
|
|
|
|
2001-02-23 21:32:47 +00:00
|
|
|
if (! active_tool)
|
2001-01-22 05:08:44 +00:00
|
|
|
return;
|
|
|
|
|
2001-07-07 12:17:23 +00:00
|
|
|
tool_info = tool_manager_get_info_by_tool (the_gimp, active_tool);
|
2001-02-23 21:32:47 +00:00
|
|
|
|
|
|
|
if (! tool_info)
|
|
|
|
{
|
|
|
|
g_warning ("%s(): no tool info registered for %s",
|
|
|
|
G_GNUC_FUNCTION,
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-24 21:27:11 +00:00
|
|
|
g_type_name (G_TYPE_FROM_INSTANCE (active_tool)));
|
2001-02-23 21:32:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tool_info->tool_options->reset_func)
|
2001-03-31 20:41:39 +00:00
|
|
|
tool_info->tool_options->reset_func (tool_info->tool_options);
|
2001-01-22 05:08:44 +00:00
|
|
|
}
|