2001-02-21 20:18:09 +08: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"
|
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2001-02-21 20:18:09 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-05-26 05:17:07 +08:00
|
|
|
#include "core-types.h"
|
2001-05-15 19:25:25 +08:00
|
|
|
|
|
|
|
#include "base/temp-buf.h"
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "gimp.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "gimpcontext.h"
|
|
|
|
#include "gimptoolinfo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
/* GRMPF */
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "tools/tools-types.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "tools/gimprectselecttool.h"
|
2001-02-24 05:32:47 +08:00
|
|
|
|
2001-02-21 20:18:09 +08:00
|
|
|
|
|
|
|
static void gimp_tool_info_class_init (GimpToolInfoClass *klass);
|
|
|
|
static void gimp_tool_info_init (GimpToolInfo *tool_info);
|
|
|
|
|
|
|
|
static void gimp_tool_info_destroy (GtkObject *object);
|
|
|
|
static TempBuf * gimp_tool_info_get_new_preview (GimpViewable *viewable,
|
|
|
|
gint width,
|
|
|
|
gint height);
|
|
|
|
|
|
|
|
|
|
|
|
static GimpDataClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
GtkType
|
|
|
|
gimp_tool_info_get_type (void)
|
|
|
|
{
|
|
|
|
static GtkType tool_info_type = 0;
|
|
|
|
|
|
|
|
if (! tool_info_type)
|
|
|
|
{
|
|
|
|
GtkTypeInfo tool_info_info =
|
|
|
|
{
|
|
|
|
"GimpToolInfo",
|
|
|
|
sizeof (GimpToolInfo),
|
|
|
|
sizeof (GimpToolInfoClass),
|
|
|
|
(GtkClassInitFunc) gimp_tool_info_class_init,
|
|
|
|
(GtkObjectInitFunc) gimp_tool_info_init,
|
|
|
|
/* reserved_1 */ NULL,
|
|
|
|
/* reserved_2 */ NULL,
|
|
|
|
(GtkClassInitFunc) NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
tool_info_type = gtk_type_unique (GIMP_TYPE_DATA, &tool_info_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tool_info_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_tool_info_class_init (GimpToolInfoClass *klass)
|
|
|
|
{
|
|
|
|
GtkObjectClass *object_class;
|
|
|
|
GimpViewableClass *viewable_class;
|
|
|
|
|
|
|
|
object_class = (GtkObjectClass *) klass;
|
|
|
|
viewable_class = (GimpViewableClass *) klass;
|
|
|
|
|
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-25 05:27:11 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-02-21 20:18:09 +08:00
|
|
|
|
|
|
|
object_class->destroy = gimp_tool_info_destroy;
|
|
|
|
|
|
|
|
viewable_class->get_new_preview = gimp_tool_info_get_new_preview;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_tool_info_init (GimpToolInfo *tool_info)
|
|
|
|
{
|
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-25 05:27:11 +08:00
|
|
|
tool_info->tool_type = G_TYPE_NONE;
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
tool_info->blurb = NULL;
|
|
|
|
tool_info->help = NULL;
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
tool_info->menu_path = NULL;
|
|
|
|
tool_info->menu_accel = NULL;
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
tool_info->help_domain = NULL;
|
|
|
|
tool_info->help_data = NULL;
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
tool_info->stock_id = NULL;
|
|
|
|
tool_info->stock_pixbuf = NULL;
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
tool_info->context = NULL;
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
tool_info->tool_options = NULL;
|
2001-02-21 20:18:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_tool_info_destroy (GtkObject *object)
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
|
|
|
|
tool_info = (GimpToolInfo *) object;
|
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
g_free (tool_info->blurb);
|
|
|
|
g_free (tool_info->help);
|
2001-02-21 20:18:09 +08:00
|
|
|
|
|
|
|
g_free (tool_info->menu_path);
|
|
|
|
g_free (tool_info->menu_accel);
|
|
|
|
|
|
|
|
g_free (tool_info->help_domain);
|
|
|
|
g_free (tool_info->help_data);
|
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
if (tool_info->stock_pixbuf)
|
|
|
|
{
|
|
|
|
g_object_unref (G_OBJECT (tool_info->stock_pixbuf));
|
|
|
|
tool_info->stock_pixbuf = NULL;
|
|
|
|
}
|
|
|
|
|
2001-02-21 20:18:09 +08:00
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static TempBuf *
|
2001-08-06 00:07:02 +08:00
|
|
|
temp_buf_new_from_pixbuf (GdkPixbuf *pixbuf,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
2001-02-21 20:18:09 +08:00
|
|
|
{
|
2001-08-06 00:07:02 +08:00
|
|
|
TempBuf *temp_buf;
|
|
|
|
gint pixbuf_width;
|
|
|
|
gint pixbuf_height;
|
|
|
|
guchar transparent[4] = { 0, 0, 0, 0 };
|
|
|
|
guchar *p_data;
|
|
|
|
guchar *t_data;
|
|
|
|
guchar *p;
|
|
|
|
guchar *t;
|
|
|
|
gint x, y;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
|
|
|
|
|
|
|
|
pixbuf_width = gdk_pixbuf_get_width (pixbuf);
|
|
|
|
pixbuf_height = gdk_pixbuf_get_height (pixbuf);
|
|
|
|
|
|
|
|
if (pixbuf_width != width || pixbuf_height != height)
|
|
|
|
{
|
|
|
|
GdkPixbuf *scaled_pixbuf;
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
|
|
|
|
width, height,
|
|
|
|
GDK_INTERP_BILINEAR);
|
2001-02-23 11:29:53 +08:00
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
pixbuf = scaled_pixbuf;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_object_ref (G_OBJECT (pixbuf));
|
|
|
|
}
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
temp_buf = temp_buf_new (width, height, 4, 0, 0, transparent);
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
p_data = gdk_pixbuf_get_pixels (pixbuf);
|
|
|
|
t_data = temp_buf_data (temp_buf);
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
for (y = 0; y < height; y++)
|
2001-02-21 20:18:09 +08:00
|
|
|
{
|
2001-08-06 00:07:02 +08:00
|
|
|
p = p_data;
|
|
|
|
t = t_data;
|
|
|
|
|
|
|
|
for (x = 0; x < width; x++)
|
|
|
|
{
|
|
|
|
*t++ = *p++;
|
|
|
|
*t++ = *p++;
|
|
|
|
*t++ = *p++;
|
|
|
|
*t++ = *p++;
|
2001-02-21 20:18:09 +08:00
|
|
|
}
|
2001-08-06 00:07:02 +08:00
|
|
|
|
|
|
|
p_data += gdk_pixbuf_get_rowstride (pixbuf);
|
|
|
|
t_data += width * 4;
|
2001-02-21 20:18:09 +08:00
|
|
|
}
|
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
g_object_unref (G_OBJECT (pixbuf));
|
2001-02-24 10:42:09 +08:00
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
return temp_buf;
|
|
|
|
}
|
2001-02-24 10:42:09 +08:00
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
static TempBuf *
|
|
|
|
gimp_tool_info_get_new_preview (GimpViewable *viewable,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info;
|
2001-02-24 10:42:09 +08:00
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
tool_info = GIMP_TOOL_INFO (viewable);
|
2001-02-24 10:42:09 +08:00
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
return temp_buf_new_from_pixbuf (tool_info->stock_pixbuf, width, height);
|
2001-02-21 20:18:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GimpToolInfo *
|
2001-07-07 20:17:23 +08:00
|
|
|
gimp_tool_info_new (GimpContext *context,
|
2001-08-06 00:07:02 +08:00
|
|
|
GType tool_type,
|
2001-02-28 07:20:51 +08:00
|
|
|
gboolean tool_context,
|
2001-02-24 05:32:47 +08:00
|
|
|
const gchar *identifier,
|
|
|
|
const gchar *blurb,
|
|
|
|
const gchar *help,
|
2001-02-21 20:18:09 +08:00
|
|
|
const gchar *menu_path,
|
|
|
|
const gchar *menu_accel,
|
|
|
|
const gchar *help_domain,
|
|
|
|
const gchar *help_data,
|
2001-07-18 04:50:01 +08:00
|
|
|
const gchar *pdb_string,
|
2001-08-06 00:07:02 +08:00
|
|
|
const gchar *stock_id,
|
|
|
|
GdkPixbuf *stock_pixbuf)
|
2001-02-21 20:18:09 +08:00
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
g_return_val_if_fail (! context || GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
g_return_val_if_fail (identifier != NULL, NULL);
|
|
|
|
g_return_val_if_fail (blurb != NULL, NULL);
|
|
|
|
g_return_val_if_fail (help != NULL, NULL);
|
|
|
|
g_return_val_if_fail (menu_path != NULL, NULL);
|
|
|
|
g_return_val_if_fail (stock_id != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GDK_IS_PIXBUF (stock_pixbuf), NULL);
|
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
tool_info = g_object_new (GIMP_TYPE_TOOL_INFO, NULL);
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
gimp_object_set_name (GIMP_OBJECT (tool_info), identifier);
|
2001-02-21 20:18:09 +08:00
|
|
|
|
|
|
|
tool_info->tool_type = tool_type;
|
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
tool_info->blurb = g_strdup (blurb);
|
|
|
|
tool_info->help = g_strdup (help);
|
2001-02-21 20:18:09 +08:00
|
|
|
|
|
|
|
tool_info->menu_path = g_strdup (menu_path);
|
|
|
|
tool_info->menu_accel = g_strdup (menu_accel);
|
|
|
|
|
|
|
|
tool_info->help_domain = g_strdup (help_domain);
|
|
|
|
tool_info->help_data = g_strdup (help_data);
|
|
|
|
|
2001-07-18 04:50:01 +08:00
|
|
|
tool_info->pdb_string = (pdb_string ?
|
|
|
|
g_strdup (pdb_string) : "gimp_paintbrush_default");
|
|
|
|
|
2001-08-06 00:07:02 +08:00
|
|
|
tool_info->stock_id = stock_id;
|
|
|
|
tool_info->stock_pixbuf = stock_pixbuf;
|
|
|
|
|
|
|
|
g_object_ref (G_OBJECT (stock_pixbuf));
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
if (tool_context)
|
|
|
|
{
|
2001-07-07 20:17:23 +08:00
|
|
|
tool_info->context = gimp_create_context (context->gimp,
|
|
|
|
identifier,
|
|
|
|
context);
|
2001-02-28 07:20:51 +08:00
|
|
|
}
|
|
|
|
|
2001-02-21 20:18:09 +08:00
|
|
|
return tool_info;
|
|
|
|
}
|
2001-02-24 05:32:47 +08:00
|
|
|
|
|
|
|
GimpToolInfo *
|
|
|
|
gimp_tool_info_get_standard (void)
|
|
|
|
{
|
|
|
|
static GimpToolInfo *standard_tool_info = NULL;
|
|
|
|
|
|
|
|
if (! standard_tool_info)
|
|
|
|
{
|
2001-08-06 00:07:02 +08:00
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
|
|
|
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
|
|
|
|
TRUE,
|
|
|
|
8,
|
|
|
|
22,
|
|
|
|
22);
|
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
standard_tool_info =
|
2001-07-07 20:17:23 +08:00
|
|
|
gimp_tool_info_new (NULL,
|
|
|
|
GIMP_TYPE_RECT_SELECT_TOOL,
|
2001-02-28 07:20:51 +08:00
|
|
|
FALSE,
|
2001-02-24 05:32:47 +08:00
|
|
|
"gimp:standard_tool",
|
|
|
|
"Standard Tool",
|
|
|
|
"Well something must be broken",
|
2001-08-06 00:07:02 +08:00
|
|
|
"<Image>/Tools/Default Tool", NULL,
|
2001-02-24 05:32:47 +08:00
|
|
|
NULL, NULL,
|
2001-07-18 04:50:01 +08:00
|
|
|
NULL,
|
2001-08-06 00:07:02 +08:00
|
|
|
GTK_STOCK_STOP,
|
|
|
|
pixbuf);
|
|
|
|
|
|
|
|
g_object_unref (G_OBJECT (pixbuf));
|
2001-02-24 05:32:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return standard_tool_info;
|
|
|
|
}
|