2001-02-05 23:22:20 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2001-04-22 08:38:56 +08:00
|
|
|
* gimppreview.c
|
2001-02-05 23:22:20 +08:00
|
|
|
* Copyright (C) 2001 Michael Natterer
|
|
|
|
*
|
|
|
|
* 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 <string.h>
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-05-03 20:26:05 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-02-05 23:22:20 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "widgets-types.h"
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpbrush.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "core/gimpbuffer.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpgradient.h"
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
#include "core/gimpmarshal.h"
|
|
|
|
#include "core/gimppalette.h"
|
|
|
|
#include "core/gimppattern.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-02-23 11:29:53 +08:00
|
|
|
|
2001-02-07 08:06:58 +08:00
|
|
|
#include "gimpbrushpreview.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "gimpbufferpreview.h"
|
2001-03-05 06:07:19 +08:00
|
|
|
#include "gimpdnd.h"
|
2001-02-07 08:06:58 +08:00
|
|
|
#include "gimpdrawablepreview.h"
|
2001-02-12 00:14:25 +08:00
|
|
|
#include "gimpgradientpreview.h"
|
2001-02-07 10:37:49 +08:00
|
|
|
#include "gimpimagepreview.h"
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "gimppalettepreview.h"
|
|
|
|
#include "gimppatternpreview.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "gimppreview.h"
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "gimptoolinfopreview.h"
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
#include "image_render.h"
|
|
|
|
|
|
|
|
|
2001-02-07 05:43:59 +08:00
|
|
|
#define PREVIEW_POPUP_DELAY 150
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
#define PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
|
|
|
|
GDK_BUTTON_RELEASE_MASK | \
|
|
|
|
GDK_ENTER_NOTIFY_MASK | \
|
|
|
|
GDK_LEAVE_NOTIFY_MASK)
|
|
|
|
|
2001-02-07 05:43:59 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
CLICKED,
|
2001-02-13 08:12:15 +08:00
|
|
|
DOUBLE_CLICKED,
|
2001-05-02 00:45:29 +08:00
|
|
|
EXTENDED_CLICKED,
|
2001-07-09 05:44:52 +08:00
|
|
|
CONTEXT,
|
2001-02-08 04:35:18 +08:00
|
|
|
RENDER,
|
2001-02-13 08:12:15 +08:00
|
|
|
GET_SIZE,
|
2001-02-07 23:01:52 +08:00
|
|
|
NEEDS_POPUP,
|
2001-02-13 08:12:15 +08:00
|
|
|
CREATE_POPUP,
|
2001-02-07 05:43:59 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-02-07 08:06:58 +08:00
|
|
|
static void gimp_preview_class_init (GimpPreviewClass *klass);
|
|
|
|
static void gimp_preview_init (GimpPreview *preview);
|
|
|
|
static void gimp_preview_destroy (GtkObject *object);
|
|
|
|
static void gimp_preview_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation);
|
|
|
|
static gint gimp_preview_button_press_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent);
|
|
|
|
static gint gimp_preview_button_release_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent);
|
|
|
|
static gint gimp_preview_enter_notify_event (GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event);
|
|
|
|
static gint gimp_preview_leave_notify_event (GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event);
|
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
static void gimp_preview_real_render (GimpPreview *preview);
|
2001-02-13 08:12:15 +08:00
|
|
|
static void gimp_preview_get_size (GimpPreview *preview,
|
|
|
|
gint size,
|
|
|
|
gint *width,
|
|
|
|
gint *height);
|
|
|
|
static void gimp_preview_real_get_size (GimpPreview *preview,
|
|
|
|
gint size,
|
|
|
|
gint *width,
|
|
|
|
gint *height);
|
2001-02-07 23:01:52 +08:00
|
|
|
static gboolean gimp_preview_needs_popup (GimpPreview *preview);
|
|
|
|
static gboolean gimp_preview_real_needs_popup (GimpPreview *preview);
|
2001-02-13 08:12:15 +08:00
|
|
|
static GtkWidget * gimp_preview_create_popup (GimpPreview *preview);
|
|
|
|
static GtkWidget * gimp_preview_real_create_popup (GimpPreview *preview);
|
2001-02-07 08:06:58 +08:00
|
|
|
|
|
|
|
static void gimp_preview_popup_show (GimpPreview *preview,
|
|
|
|
gint x,
|
|
|
|
gint y);
|
|
|
|
static void gimp_preview_popup_hide (GimpPreview *preview);
|
2001-06-18 21:10:03 +08:00
|
|
|
static void gimp_preview_size_changed (GimpPreview *preview,
|
|
|
|
GimpViewable *viewable);
|
2001-02-07 08:06:58 +08:00
|
|
|
static void gimp_preview_paint (GimpPreview *preview);
|
|
|
|
static gboolean gimp_preview_idle_paint (GimpPreview *preview);
|
2001-03-05 06:07:19 +08:00
|
|
|
static GimpViewable * gimp_preview_drag_viewable (GtkWidget *widget,
|
|
|
|
gpointer data);
|
2001-02-05 23:22:20 +08:00
|
|
|
|
|
|
|
|
2001-02-07 05:43:59 +08:00
|
|
|
static guint preview_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
static GtkPreviewClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
GtkType
|
|
|
|
gimp_preview_get_type (void)
|
|
|
|
{
|
|
|
|
static GtkType preview_type = 0;
|
|
|
|
|
|
|
|
if (! preview_type)
|
|
|
|
{
|
|
|
|
GtkTypeInfo preview_info =
|
|
|
|
{
|
|
|
|
"GimpPreview",
|
|
|
|
sizeof (GimpPreview),
|
|
|
|
sizeof (GimpPreviewClass),
|
|
|
|
(GtkClassInitFunc) gimp_preview_class_init,
|
|
|
|
(GtkObjectInitFunc) gimp_preview_init,
|
|
|
|
/* reserved_1 */ NULL,
|
|
|
|
/* reserved_2 */ NULL,
|
|
|
|
(GtkClassInitFunc) NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
preview_type = gtk_type_unique (GTK_TYPE_PREVIEW, &preview_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return preview_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_preview_class_init (GimpPreviewClass *klass)
|
|
|
|
{
|
|
|
|
GtkObjectClass *object_class;
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
object_class = (GtkObjectClass *) klass;
|
|
|
|
widget_class = (GtkWidgetClass *) 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-05 23:22:20 +08:00
|
|
|
|
2001-02-07 05:43:59 +08:00
|
|
|
preview_signals[CLICKED] =
|
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
|
|
|
g_signal_new ("clicked",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpPreviewClass, clicked),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2001-02-07 05:43:59 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
preview_signals[DOUBLE_CLICKED] =
|
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
|
|
|
g_signal_new ("double_clicked",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpPreviewClass, double_clicked),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-05-02 00:45:29 +08:00
|
|
|
preview_signals[EXTENDED_CLICKED] =
|
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
|
|
|
g_signal_new ("extended_clicked",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpPreviewClass, extended_clicked),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__UINT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_UINT);
|
2001-05-02 00:45:29 +08:00
|
|
|
|
2001-07-09 05:44:52 +08:00
|
|
|
preview_signals[CONTEXT] =
|
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
|
|
|
g_signal_new ("context",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpPreviewClass, context),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2001-07-09 05:44:52 +08:00
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
preview_signals[RENDER] =
|
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
|
|
|
g_signal_new ("render",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpPreviewClass, render),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2001-02-07 08:06:58 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
preview_signals[GET_SIZE] =
|
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
|
|
|
g_signal_new ("get_size",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpPreviewClass, get_size),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_cclosure_marshal_VOID__INT_POINTER_POINTER,
|
|
|
|
G_TYPE_NONE, 3,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_POINTER,
|
|
|
|
G_TYPE_POINTER);
|
2001-02-07 08:06:58 +08:00
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
preview_signals[NEEDS_POPUP] =
|
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
|
|
|
g_signal_new ("needs_popup",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpPreviewClass, needs_popup),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_cclosure_marshal_BOOLEAN__VOID,
|
|
|
|
G_TYPE_BOOLEAN, 0);
|
2001-02-07 23:01:52 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
preview_signals[CREATE_POPUP] =
|
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
|
|
|
g_signal_new ("create_popup",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpPreviewClass, create_popup),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_cclosure_marshal_POINTER__VOID,
|
|
|
|
G_TYPE_POINTER, 0);
|
2001-02-07 05:43:59 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
object_class->destroy = gimp_preview_destroy;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
|
|
|
widget_class->size_allocate = gimp_preview_size_allocate;
|
|
|
|
widget_class->button_press_event = gimp_preview_button_press_event;
|
|
|
|
widget_class->button_release_event = gimp_preview_button_release_event;
|
2001-02-07 05:43:59 +08:00
|
|
|
widget_class->enter_notify_event = gimp_preview_enter_notify_event;
|
|
|
|
widget_class->leave_notify_event = gimp_preview_leave_notify_event;
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
klass->clicked = NULL;
|
|
|
|
klass->double_clicked = NULL;
|
|
|
|
klass->extended_clicked = NULL;
|
2001-07-09 05:44:52 +08:00
|
|
|
klass->context = NULL;
|
2001-06-18 21:10:03 +08:00
|
|
|
klass->render = gimp_preview_real_render;
|
|
|
|
klass->get_size = gimp_preview_real_get_size;
|
|
|
|
klass->needs_popup = gimp_preview_real_needs_popup;
|
|
|
|
klass->create_popup = gimp_preview_real_create_popup;
|
2001-02-05 23:22:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_preview_init (GimpPreview *preview)
|
|
|
|
{
|
2001-02-09 23:12:01 +08:00
|
|
|
preview->viewable = NULL;
|
2001-02-08 02:01:54 +08:00
|
|
|
|
2001-02-09 23:12:01 +08:00
|
|
|
preview->width = 8;
|
|
|
|
preview->height = 8;
|
|
|
|
preview->border_width = 0;
|
2001-06-18 21:10:03 +08:00
|
|
|
preview->dot_for_dot = TRUE;
|
2001-02-08 07:14:14 +08:00
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
gimp_rgba_set (&preview->border_color, 0.0, 0.0, 0.0, 1.0);
|
2001-02-08 07:14:14 +08:00
|
|
|
|
2001-02-11 03:35:29 +08:00
|
|
|
preview->is_popup = FALSE;
|
2001-02-09 23:12:01 +08:00
|
|
|
preview->clickable = FALSE;
|
|
|
|
preview->show_popup = FALSE;
|
2001-02-07 05:43:59 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
preview->size = -1;
|
2001-02-09 23:12:01 +08:00
|
|
|
preview->in_button = FALSE;
|
|
|
|
preview->idle_id = 0;
|
|
|
|
preview->popup_id = 0;
|
|
|
|
preview->popup_x = 0;
|
|
|
|
preview->popup_y = 0;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
|
|
|
GTK_PREVIEW (preview)->type = GTK_PREVIEW_COLOR;
|
|
|
|
GTK_PREVIEW (preview)->bpp = 3;
|
|
|
|
GTK_PREVIEW (preview)->dither = GDK_RGB_DITHER_NORMAL;
|
|
|
|
|
|
|
|
gtk_widget_set_events (GTK_WIDGET (preview), PREVIEW_EVENT_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_preview_destroy (GtkObject *object)
|
|
|
|
{
|
2001-02-07 10:37:49 +08:00
|
|
|
GimpPreview *preview;
|
|
|
|
|
|
|
|
preview = GIMP_PREVIEW (object);
|
|
|
|
|
|
|
|
if (preview->idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (preview->idle_id);
|
2001-05-03 20:26:05 +08:00
|
|
|
preview->idle_id = 0;
|
2001-02-07 10:37:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_preview_popup_hide (preview);
|
|
|
|
|
2001-02-08 12:16:41 +08:00
|
|
|
gimp_preview_set_viewable (preview, NULL);
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static GimpPreview *
|
|
|
|
gimp_preview_new_by_type (GimpViewable *viewable)
|
2001-02-09 23:12:01 +08:00
|
|
|
{
|
2001-02-13 08:12:15 +08:00
|
|
|
GimpPreview *preview;
|
2001-02-09 23:12:01 +08:00
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
if (GIMP_IS_BRUSH (viewable))
|
|
|
|
{
|
|
|
|
preview = gtk_type_new (GIMP_TYPE_BRUSH_PREVIEW);
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_DRAWABLE (viewable))
|
|
|
|
{
|
|
|
|
preview = gtk_type_new (GIMP_TYPE_DRAWABLE_PREVIEW);
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_IMAGE (viewable))
|
|
|
|
{
|
|
|
|
preview = gtk_type_new (GIMP_TYPE_IMAGE_PREVIEW);
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_PATTERN (viewable))
|
|
|
|
{
|
|
|
|
preview = gtk_type_new (GIMP_TYPE_PATTERN_PREVIEW);
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_GRADIENT (viewable))
|
|
|
|
{
|
|
|
|
preview = gtk_type_new (GIMP_TYPE_GRADIENT_PREVIEW);
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_PALETTE (viewable))
|
|
|
|
{
|
|
|
|
preview = gtk_type_new (GIMP_TYPE_PALETTE_PREVIEW);
|
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
else if (GIMP_IS_BUFFER (viewable))
|
|
|
|
{
|
|
|
|
preview = gtk_type_new (GIMP_TYPE_BUFFER_PREVIEW);
|
|
|
|
}
|
2001-02-23 11:29:53 +08:00
|
|
|
else if (GIMP_IS_TOOL_INFO (viewable))
|
|
|
|
{
|
|
|
|
preview = gtk_type_new (GIMP_TYPE_TOOL_INFO_PREVIEW);
|
|
|
|
}
|
2001-02-13 08:12:15 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
preview = gtk_type_new (GIMP_TYPE_PREVIEW);
|
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
return preview;
|
|
|
|
}
|
2001-02-20 06:54:12 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_preview_new (GimpViewable *viewable,
|
|
|
|
gint size,
|
|
|
|
gint border_width,
|
|
|
|
gboolean is_popup)
|
|
|
|
{
|
|
|
|
GimpPreview *preview;
|
2001-02-20 06:54:12 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
g_return_val_if_fail (viewable != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
|
|
|
|
g_return_val_if_fail (size > 0 && size <= 256, NULL);
|
|
|
|
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
preview = gimp_preview_new_by_type (viewable);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
preview->is_popup = is_popup;
|
|
|
|
|
|
|
|
gimp_preview_set_viewable (preview, viewable);
|
|
|
|
|
|
|
|
gimp_preview_set_size (preview, size, border_width);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
|
|
|
return GTK_WIDGET (preview);
|
2001-02-09 23:12:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_preview_new_full (GimpViewable *viewable,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint border_width,
|
|
|
|
gboolean is_popup,
|
|
|
|
gboolean clickable,
|
|
|
|
gboolean show_popup)
|
2001-02-05 23:22:20 +08:00
|
|
|
{
|
|
|
|
GimpPreview *preview;
|
|
|
|
|
|
|
|
g_return_val_if_fail (viewable != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
|
2001-02-07 05:43:59 +08:00
|
|
|
g_return_val_if_fail (width > 0 && width <= 256, NULL);
|
|
|
|
g_return_val_if_fail (height > 0 && height <= 256, NULL);
|
2001-02-09 23:12:01 +08:00
|
|
|
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
preview = gimp_preview_new_by_type (viewable);
|
2001-02-08 07:14:14 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
preview->is_popup = is_popup;
|
2001-02-07 05:43:59 +08:00
|
|
|
preview->clickable = clickable;
|
|
|
|
preview->show_popup = show_popup;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-02-08 12:16:41 +08:00
|
|
|
gimp_preview_set_viewable (preview, viewable);
|
2001-02-06 23:57:07 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gimp_preview_set_size_full (preview, width, height, border_width);
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
return GTK_WIDGET (preview);
|
|
|
|
}
|
|
|
|
|
2001-02-08 12:16:41 +08:00
|
|
|
void
|
|
|
|
gimp_preview_set_viewable (GimpPreview *preview,
|
|
|
|
GimpViewable *viewable)
|
|
|
|
{
|
|
|
|
g_return_if_fail (preview != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
|
|
|
g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable));
|
|
|
|
|
|
|
|
if (preview->viewable)
|
|
|
|
{
|
2001-03-05 06:07:19 +08:00
|
|
|
if (! preview->is_popup)
|
|
|
|
{
|
|
|
|
gtk_drag_source_unset (GTK_WIDGET (preview));
|
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
|
|
|
gimp_dnd_viewable_source_unset (GTK_WIDGET (preview),
|
|
|
|
G_TYPE_FROM_INSTANCE (preview->viewable));
|
2001-03-05 06:07:19 +08:00
|
|
|
}
|
|
|
|
|
2001-02-08 12:16:41 +08:00
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
2001-06-18 21:10:03 +08:00
|
|
|
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
|
|
|
&preview->viewable);
|
|
|
|
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
|
|
|
GTK_SIGNAL_FUNC (gimp_preview_paint),
|
2001-02-08 12:16:41 +08:00
|
|
|
preview);
|
|
|
|
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
|
2001-06-18 21:10:03 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_preview_size_changed),
|
|
|
|
preview);
|
|
|
|
|
2001-02-08 12:16:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
preview->viewable = viewable;
|
|
|
|
|
|
|
|
if (preview->viewable)
|
|
|
|
{
|
2001-03-05 06:07:19 +08:00
|
|
|
if (! preview->is_popup)
|
|
|
|
{
|
|
|
|
gimp_gtk_drag_source_set_by_type (GTK_WIDGET (preview),
|
|
|
|
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
|
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
|
|
|
G_TYPE_FROM_INSTANCE (preview->viewable),
|
2001-03-05 06:07:19 +08:00
|
|
|
GDK_ACTION_COPY);
|
|
|
|
gimp_dnd_viewable_source_set (GTK_WIDGET (preview),
|
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
|
|
|
G_TYPE_FROM_INSTANCE (preview->viewable),
|
2001-03-05 06:07:19 +08:00
|
|
|
gimp_preview_drag_viewable,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (preview->viewable), "destroy",
|
|
|
|
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
|
|
|
&preview->viewable);
|
|
|
|
|
2001-02-08 12:16:41 +08:00
|
|
|
gtk_signal_connect_object (GTK_OBJECT (preview->viewable),
|
|
|
|
"invalidate_preview",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_preview_paint),
|
|
|
|
GTK_OBJECT (preview));
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gtk_signal_connect_object (GTK_OBJECT (preview->viewable),
|
|
|
|
"size_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_preview_size_changed),
|
|
|
|
GTK_OBJECT (preview));
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (preview->size != -1)
|
|
|
|
{
|
|
|
|
gimp_preview_set_size (preview,
|
|
|
|
preview->size,
|
|
|
|
preview->border_width);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_preview_paint (preview);
|
2001-02-08 12:16:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
void
|
|
|
|
gimp_preview_set_size (GimpPreview *preview,
|
|
|
|
gint preview_size,
|
|
|
|
gint border_width)
|
|
|
|
{
|
|
|
|
gint width, height;
|
|
|
|
|
|
|
|
g_return_if_fail (preview != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
|
|
|
g_return_if_fail (preview_size > 0 && preview_size <= 256);
|
|
|
|
g_return_if_fail (border_width >= 0 && border_width <= 16);
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
preview->size = preview_size;
|
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
gimp_preview_get_size (preview, preview_size, &width, &height);
|
|
|
|
|
|
|
|
gimp_preview_set_size_full (preview,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
border_width);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_preview_set_size_full (GimpPreview *preview,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint border_width)
|
|
|
|
{
|
|
|
|
g_return_if_fail (preview != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
|
|
|
g_return_if_fail (width > 0 && width <= 256);
|
|
|
|
g_return_if_fail (height > 0 && height <= 256);
|
|
|
|
g_return_if_fail (border_width >= 0 && border_width <= 16);
|
|
|
|
|
|
|
|
preview->width = width;
|
|
|
|
preview->height = height;
|
|
|
|
preview->border_width = border_width;
|
|
|
|
|
|
|
|
gtk_preview_size (GTK_PREVIEW (preview),
|
|
|
|
width + 2 * preview->border_width,
|
|
|
|
height + 2 * preview->border_width);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
gtk_widget_hide (GTK_WIDGET (preview));
|
|
|
|
gtk_widget_show (GTK_WIDGET (preview));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_preview_set_dot_for_dot (GimpPreview *preview,
|
|
|
|
gboolean dot_for_dot)
|
|
|
|
{
|
|
|
|
g_return_if_fail (preview != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
|
|
|
|
|
|
|
if (dot_for_dot != preview->dot_for_dot)
|
|
|
|
{
|
|
|
|
preview->dot_for_dot = dot_for_dot ? TRUE: FALSE;
|
|
|
|
|
|
|
|
if (preview->size != -1)
|
|
|
|
{
|
|
|
|
gimp_preview_set_size (preview,
|
|
|
|
preview->size,
|
|
|
|
preview->border_width);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_preview_paint (preview);
|
|
|
|
}
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_preview_set_border_color (GimpPreview *preview,
|
|
|
|
const GimpRGB *color)
|
|
|
|
{
|
|
|
|
g_return_if_fail (preview != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
|
|
|
|
if (gimp_rgb_distance (&preview->border_color, color))
|
|
|
|
{
|
|
|
|
preview->border_color = *color;
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gimp_preview_paint (preview);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-24 10:42:09 +08:00
|
|
|
void
|
|
|
|
gimp_preview_render (GimpPreview *preview)
|
|
|
|
{
|
|
|
|
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[RENDER]);
|
|
|
|
}
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
static gint
|
|
|
|
gimp_preview_button_press_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent)
|
|
|
|
{
|
2001-02-07 05:43:59 +08:00
|
|
|
GimpPreview *preview;
|
|
|
|
|
|
|
|
preview = GIMP_PREVIEW (widget);
|
|
|
|
|
2001-02-07 10:37:49 +08:00
|
|
|
if (! preview->clickable &&
|
|
|
|
! preview->show_popup)
|
|
|
|
return FALSE;
|
2001-02-07 05:43:59 +08:00
|
|
|
|
2001-02-07 10:37:49 +08:00
|
|
|
if (bevent->type == GDK_BUTTON_PRESS)
|
|
|
|
{
|
|
|
|
if (bevent->button == 1)
|
|
|
|
{
|
|
|
|
gtk_grab_add (widget);
|
|
|
|
|
2001-05-02 00:45:29 +08:00
|
|
|
preview->press_state = bevent->state;
|
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
2001-02-07 10:37:49 +08:00
|
|
|
{
|
|
|
|
gimp_preview_popup_show (preview,
|
|
|
|
bevent->x,
|
|
|
|
bevent->y);
|
|
|
|
}
|
|
|
|
}
|
2001-07-09 05:44:52 +08:00
|
|
|
else if (bevent->button == 3)
|
|
|
|
{
|
|
|
|
gtk_signal_emit (GTK_OBJECT (widget), preview_signals[CONTEXT]);
|
|
|
|
}
|
2001-02-10 05:49:47 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-02-07 05:43:59 +08:00
|
|
|
}
|
2001-02-13 08:12:15 +08:00
|
|
|
else if (bevent->type == GDK_2BUTTON_PRESS)
|
|
|
|
{
|
|
|
|
if (bevent->button == 1)
|
|
|
|
{
|
|
|
|
gtk_signal_emit (GTK_OBJECT (widget), preview_signals[DOUBLE_CLICKED]);
|
|
|
|
}
|
|
|
|
}
|
2001-02-07 05:43:59 +08:00
|
|
|
|
|
|
|
return TRUE;
|
2001-02-05 23:22:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gimp_preview_button_release_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent)
|
|
|
|
{
|
2001-02-07 05:43:59 +08:00
|
|
|
GimpPreview *preview;
|
2001-02-08 07:14:14 +08:00
|
|
|
gboolean click = TRUE;
|
2001-02-07 05:43:59 +08:00
|
|
|
|
|
|
|
preview = GIMP_PREVIEW (widget);
|
|
|
|
|
2001-02-07 10:37:49 +08:00
|
|
|
if (! preview->clickable &&
|
|
|
|
! preview->show_popup)
|
|
|
|
return FALSE;
|
|
|
|
|
2001-02-07 05:43:59 +08:00
|
|
|
if (bevent->button == 1)
|
|
|
|
{
|
2001-02-08 07:14:14 +08:00
|
|
|
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
|
|
|
{
|
|
|
|
click = (preview->popup_id != 0);
|
2001-02-07 05:43:59 +08:00
|
|
|
}
|
|
|
|
|
2001-02-07 10:37:49 +08:00
|
|
|
gimp_preview_popup_hide (preview);
|
|
|
|
|
|
|
|
/* remove the grab _after_ hiding the popup */
|
|
|
|
gtk_grab_remove (widget);
|
|
|
|
|
2001-02-08 07:14:14 +08:00
|
|
|
if (preview->clickable && click && preview->in_button)
|
2001-02-07 05:43:59 +08:00
|
|
|
{
|
2001-05-02 00:45:29 +08:00
|
|
|
if (preview->press_state &
|
|
|
|
(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK))
|
|
|
|
{
|
|
|
|
gtk_signal_emit (GTK_OBJECT (widget),
|
|
|
|
preview_signals[EXTENDED_CLICKED],
|
|
|
|
preview->press_state);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_signal_emit (GTK_OBJECT (widget), preview_signals[CLICKED]);
|
|
|
|
}
|
2001-02-07 05:43:59 +08:00
|
|
|
}
|
|
|
|
}
|
2001-02-10 05:49:47 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-02-07 05:43:59 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gimp_preview_enter_notify_event (GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event)
|
|
|
|
{
|
|
|
|
GimpPreview *preview;
|
|
|
|
GtkWidget *event_widget;
|
|
|
|
|
|
|
|
preview = GIMP_PREVIEW (widget);
|
|
|
|
event_widget = gtk_get_event_widget ((GdkEvent *) event);
|
|
|
|
|
|
|
|
if ((event_widget == widget) &&
|
|
|
|
(event->detail != GDK_NOTIFY_INFERIOR))
|
|
|
|
{
|
|
|
|
preview->in_button = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gimp_preview_leave_notify_event (GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event)
|
|
|
|
{
|
|
|
|
GimpPreview *preview;
|
|
|
|
GtkWidget *event_widget;
|
|
|
|
|
|
|
|
preview = GIMP_PREVIEW (widget);
|
|
|
|
event_widget = gtk_get_event_widget ((GdkEvent *) event);
|
|
|
|
|
|
|
|
if ((event_widget == widget) &&
|
|
|
|
(event->detail != GDK_NOTIFY_INFERIOR))
|
|
|
|
{
|
|
|
|
preview->in_button = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
static void
|
|
|
|
gimp_preview_real_render (GimpPreview *preview)
|
2001-02-07 08:06:58 +08:00
|
|
|
{
|
2001-02-08 04:35:18 +08:00
|
|
|
TempBuf *temp_buf;
|
|
|
|
|
2001-02-08 07:14:14 +08:00
|
|
|
temp_buf = gimp_viewable_get_new_preview (preview->viewable,
|
|
|
|
preview->width,
|
|
|
|
preview->height);
|
2001-02-08 04:35:18 +08:00
|
|
|
|
2001-02-21 20:18:09 +08:00
|
|
|
if (temp_buf)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
|
|
|
gimp_preview_render_and_flush (preview,
|
|
|
|
temp_buf,
|
|
|
|
-1);
|
|
|
|
temp_buf_free (temp_buf);
|
|
|
|
}
|
2001-02-07 08:06:58 +08:00
|
|
|
}
|
|
|
|
|
2001-02-13 08:12:15 +08:00
|
|
|
static void
|
|
|
|
gimp_preview_get_size (GimpPreview *preview,
|
|
|
|
gint size,
|
|
|
|
gint *width,
|
|
|
|
gint *height)
|
|
|
|
{
|
|
|
|
g_return_if_fail (preview != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
|
|
|
g_return_if_fail (width != NULL);
|
|
|
|
g_return_if_fail (height != NULL);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[GET_SIZE],
|
|
|
|
size, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_preview_real_get_size (GimpPreview *preview,
|
|
|
|
gint size,
|
|
|
|
gint *width,
|
|
|
|
gint *height)
|
|
|
|
{
|
|
|
|
*width = size;
|
|
|
|
*height = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_preview_needs_popup (GimpPreview *preview)
|
|
|
|
{
|
|
|
|
gboolean needs_popup = FALSE;
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[NEEDS_POPUP],
|
|
|
|
&needs_popup);
|
|
|
|
|
|
|
|
return needs_popup;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_preview_real_needs_popup (GimpPreview *preview)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-02-07 08:06:58 +08:00
|
|
|
static GtkWidget *
|
|
|
|
gimp_preview_create_popup (GimpPreview *preview)
|
|
|
|
{
|
|
|
|
GtkWidget *popup_preview = NULL;
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[CREATE_POPUP],
|
|
|
|
&popup_preview);
|
|
|
|
|
|
|
|
return popup_preview;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
gimp_preview_real_create_popup (GimpPreview *preview)
|
|
|
|
{
|
2001-02-08 02:01:54 +08:00
|
|
|
gint popup_width;
|
|
|
|
gint popup_height;
|
2001-02-07 08:06:58 +08:00
|
|
|
|
2001-02-08 07:14:14 +08:00
|
|
|
popup_width = MIN (preview->width * 2, 256);
|
|
|
|
popup_height = MIN (preview->height * 2, 256);
|
2001-02-07 08:06:58 +08:00
|
|
|
|
2001-02-09 23:12:01 +08:00
|
|
|
return gimp_preview_new_full (preview->viewable,
|
|
|
|
popup_width,
|
|
|
|
popup_height,
|
|
|
|
0,
|
|
|
|
TRUE, FALSE, FALSE);
|
2001-02-07 08:06:58 +08:00
|
|
|
}
|
|
|
|
|
2001-02-07 05:43:59 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_preview_popup_timeout (GimpPreview *preview)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *popup_preview;
|
|
|
|
gint orig_x;
|
|
|
|
gint orig_y;
|
|
|
|
gint scr_width;
|
|
|
|
gint scr_height;
|
|
|
|
gint x;
|
|
|
|
gint y;
|
|
|
|
gint popup_width;
|
|
|
|
gint popup_height;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (preview);
|
|
|
|
|
|
|
|
x = preview->popup_x;
|
|
|
|
y = preview->popup_y;
|
|
|
|
|
|
|
|
preview->popup_id = 0;
|
|
|
|
preview->popup_x = 0;
|
|
|
|
preview->popup_y = 0;
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_POPUP);
|
|
|
|
gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, TRUE);
|
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), frame);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2001-02-07 08:06:58 +08:00
|
|
|
popup_preview = gimp_preview_create_popup (preview);
|
|
|
|
|
|
|
|
popup_width = popup_preview->requisition.width;
|
|
|
|
popup_height = popup_preview->requisition.height;
|
|
|
|
|
2001-02-07 05:43:59 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), popup_preview);
|
|
|
|
gtk_widget_show (popup_preview);
|
|
|
|
|
|
|
|
gdk_window_get_origin (widget->window, &orig_x, &orig_y);
|
|
|
|
scr_width = gdk_screen_width ();
|
|
|
|
scr_height = gdk_screen_height ();
|
|
|
|
x = orig_x + x - (popup_width >> 1);
|
|
|
|
y = orig_y + y - (popup_height >> 1);
|
|
|
|
x = (x < 0) ? 0 : x;
|
|
|
|
y = (y < 0) ? 0 : y;
|
|
|
|
x = (x + popup_width > scr_width) ? scr_width - popup_width : x;
|
|
|
|
y = (y + popup_height > scr_height) ? scr_height - popup_height : y;
|
|
|
|
|
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
|
|
|
gtk_widget_set_uposition (window, x, y);
|
|
|
|
gtk_widget_show (window);
|
2001-02-07 05:43:59 +08:00
|
|
|
|
|
|
|
gtk_object_set_data_full (GTK_OBJECT (preview), "preview_popup_window", window,
|
|
|
|
(GtkDestroyNotify) gtk_widget_destroy);
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-02-07 05:43:59 +08:00
|
|
|
static void
|
|
|
|
gimp_preview_popup_show (GimpPreview *preview,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
|
|
|
{
|
|
|
|
preview->popup_x = x;
|
|
|
|
preview->popup_y = y;
|
|
|
|
|
|
|
|
preview->popup_id = g_timeout_add (PREVIEW_POPUP_DELAY,
|
|
|
|
(GSourceFunc) gimp_preview_popup_timeout,
|
|
|
|
preview);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_preview_popup_hide (GimpPreview *preview)
|
|
|
|
{
|
|
|
|
if (preview->popup_id)
|
|
|
|
{
|
|
|
|
g_source_remove (preview->popup_id);
|
|
|
|
|
|
|
|
preview->popup_id = 0;
|
|
|
|
preview->popup_x = 0;
|
|
|
|
preview->popup_y = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_object_set_data (GTK_OBJECT (preview), "preview_popup_window", NULL);
|
|
|
|
}
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
static void
|
|
|
|
gimp_preview_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
{
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
|
|
|
|
|
|
|
|
gimp_preview_paint (GIMP_PREVIEW (widget));
|
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static void
|
|
|
|
gimp_preview_size_changed (GimpPreview *preview,
|
|
|
|
GimpViewable *viewable)
|
|
|
|
{
|
|
|
|
if (preview->size != -1)
|
|
|
|
{
|
|
|
|
g_print ("size_changed (%d)\n", preview->size);
|
|
|
|
|
|
|
|
gimp_preview_set_size (preview,
|
|
|
|
preview->size,
|
|
|
|
preview->border_width);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
static void
|
|
|
|
gimp_preview_paint (GimpPreview *preview)
|
|
|
|
{
|
|
|
|
if (preview->idle_id)
|
2001-02-07 10:37:49 +08:00
|
|
|
{
|
|
|
|
g_source_remove (preview->idle_id);
|
|
|
|
}
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-02-07 10:37:49 +08:00
|
|
|
preview->idle_id =
|
|
|
|
g_idle_add_full (G_PRIORITY_LOW,
|
|
|
|
(GSourceFunc) gimp_preview_idle_paint, preview,
|
|
|
|
NULL);
|
2001-02-05 23:22:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_preview_idle_paint (GimpPreview *preview)
|
|
|
|
{
|
|
|
|
preview->idle_id = 0;
|
|
|
|
|
2001-02-06 23:57:07 +08:00
|
|
|
if (! preview->viewable)
|
|
|
|
return FALSE;
|
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
gimp_preview_render (preview);
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-05-03 20:26:05 +08:00
|
|
|
void
|
2001-06-18 21:10:03 +08:00
|
|
|
gimp_preview_calc_size (GimpPreview *preview,
|
|
|
|
gint aspect_width,
|
|
|
|
gint aspect_height,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gdouble xresolution,
|
|
|
|
gdouble yresolution,
|
|
|
|
gint *return_width,
|
|
|
|
gint *return_height,
|
|
|
|
gboolean *scaling_up)
|
2001-05-03 20:26:05 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
gdouble xratio;
|
|
|
|
gdouble yratio;
|
2001-05-03 20:26:05 +08:00
|
|
|
|
|
|
|
if (aspect_width > aspect_height)
|
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
xratio = yratio = (gdouble) width / (gdouble) aspect_width;
|
2001-05-03 20:26:05 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
xratio = yratio = (gdouble) height / (gdouble) aspect_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! preview->dot_for_dot && xresolution != yresolution)
|
|
|
|
{
|
|
|
|
if (xresolution < yresolution)
|
|
|
|
{
|
|
|
|
yratio *= xresolution / yresolution;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
yratio *= yresolution / xresolution;
|
|
|
|
}
|
2001-05-03 20:26:05 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
width = RINT (xratio * (gdouble) aspect_width);
|
|
|
|
height = RINT (yratio * (gdouble) aspect_height);
|
2001-05-03 20:26:05 +08:00
|
|
|
|
|
|
|
if (width < 1) width = 1;
|
|
|
|
if (height < 1) height = 1;
|
|
|
|
|
|
|
|
*return_width = width;
|
|
|
|
*return_height = height;
|
2001-06-18 21:10:03 +08:00
|
|
|
*scaling_up = (xratio > 1.0) || (yratio > 1.0);
|
2001-05-03 20:26:05 +08:00
|
|
|
}
|
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
void
|
|
|
|
gimp_preview_render_and_flush (GimpPreview *preview,
|
|
|
|
TempBuf *temp_buf,
|
|
|
|
gint channel)
|
|
|
|
{
|
2001-02-08 07:14:14 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
2001-02-08 04:35:18 +08:00
|
|
|
guchar *src, *s;
|
|
|
|
guchar *cb;
|
|
|
|
guchar *buf;
|
|
|
|
gint a;
|
|
|
|
gint i, j, b;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
gint rowstride;
|
|
|
|
gboolean color_buf;
|
|
|
|
gboolean color;
|
|
|
|
gint alpha;
|
|
|
|
gboolean has_alpha;
|
|
|
|
gint image_bytes;
|
|
|
|
gint offset;
|
2001-02-08 07:14:14 +08:00
|
|
|
gint border;
|
2001-03-12 01:24:47 +08:00
|
|
|
guchar border_color[3];
|
2001-02-08 07:14:14 +08:00
|
|
|
|
|
|
|
width = preview->width;
|
|
|
|
height = preview->height;
|
2001-02-09 23:12:01 +08:00
|
|
|
border = preview->border_width;
|
2001-02-08 04:35:18 +08:00
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
gimp_rgb_get_uchar (&preview->border_color,
|
|
|
|
&border_color[0],
|
|
|
|
&border_color[1],
|
|
|
|
&border_color[2]);
|
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
alpha = ALPHA_PIX;
|
|
|
|
|
|
|
|
/* Here are the different cases this functions handles correctly:
|
|
|
|
* 1) Offset temp_buf which does not necessarily cover full image area
|
|
|
|
* 2) Color conversion of temp_buf if it is gray and image is color
|
|
|
|
* 3) Background check buffer for transparent temp_bufs
|
|
|
|
* 4) Using the optional "channel" argument, one channel can be extracted
|
|
|
|
* from a multi-channel temp_buf and composited as a grayscale
|
|
|
|
* Prereqs:
|
|
|
|
* 1) Grayscale temp_bufs have bytes == {1, 2}
|
|
|
|
* 2) Color temp_bufs have bytes == {3, 4}
|
|
|
|
* 3) If image is gray, then temp_buf should have bytes == {1, 2}
|
|
|
|
*/
|
|
|
|
color_buf = (GTK_PREVIEW (preview)->type == GTK_PREVIEW_COLOR);
|
|
|
|
image_bytes = (color_buf) ? 3 : 1;
|
|
|
|
has_alpha = (temp_buf->bytes == 2 || temp_buf->bytes == 4);
|
|
|
|
rowstride = temp_buf->width * temp_buf->bytes;
|
|
|
|
|
|
|
|
/* Determine if the preview buf supplied is color
|
|
|
|
* Generally, if the bytes == {3, 4}, this is true.
|
|
|
|
* However, if the channel argument supplied is not -1, then
|
|
|
|
* the preview buf is assumed to be gray despite the number of
|
|
|
|
* channels it contains
|
|
|
|
*/
|
|
|
|
color = ((channel == -1) &&
|
|
|
|
(temp_buf->bytes == 3 || temp_buf->bytes == 4));
|
|
|
|
|
|
|
|
if (has_alpha)
|
|
|
|
{
|
|
|
|
buf = render_check_buf;
|
|
|
|
alpha = ((color) ? ALPHA_PIX :
|
|
|
|
((channel != -1) ? (temp_buf->bytes - 1) :
|
|
|
|
ALPHA_G_PIX));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buf = render_empty_buf;
|
|
|
|
}
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
x1 = CLAMP (temp_buf->x, 0, width);
|
|
|
|
y1 = CLAMP (temp_buf->y, 0, height);
|
2001-02-08 07:14:14 +08:00
|
|
|
x2 = CLAMP (temp_buf->x + temp_buf->width, 0, width);
|
2001-02-08 04:35:18 +08:00
|
|
|
y2 = CLAMP (temp_buf->y + temp_buf->height, 0, height);
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
src = temp_buf_data (temp_buf) + ((y1 - temp_buf->y) * rowstride +
|
|
|
|
(x1 - temp_buf->x) * temp_buf->bytes);
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
/* One last thing for efficiency's sake: */
|
|
|
|
if (channel == -1)
|
|
|
|
channel = 0;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-02-08 07:14:14 +08:00
|
|
|
/* Set the border color once before rendering */
|
|
|
|
for (j = 0; j < width + border * 2; j++)
|
2001-05-03 20:26:05 +08:00
|
|
|
for (b = 0; b < image_bytes; b++)
|
|
|
|
render_temp_buf[j * image_bytes + b] = border_color[b];
|
2001-02-08 07:14:14 +08:00
|
|
|
|
|
|
|
for (i = 0; i < border; i++)
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (preview),
|
|
|
|
render_temp_buf,
|
|
|
|
0, i,
|
|
|
|
width + 2 * border);
|
|
|
|
|
|
|
|
for (i = border + height; i < 2 * border + height; i++)
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (preview),
|
|
|
|
render_temp_buf,
|
|
|
|
0, i,
|
|
|
|
width + 2 * border);
|
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
{
|
|
|
|
if (i & 0x4)
|
|
|
|
{
|
|
|
|
offset = 4;
|
|
|
|
cb = buf + offset * 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
offset = 0;
|
|
|
|
cb = buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The interesting stuff between leading & trailing
|
|
|
|
* vertical transparency
|
|
|
|
*/
|
|
|
|
if (i >= y1 && i < y2)
|
|
|
|
{
|
|
|
|
/* Handle the leading transparency */
|
|
|
|
for (j = 0; j < x1; j++)
|
|
|
|
for (b = 0; b < image_bytes; b++)
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * image_bytes + b] = cb[j * 3 + b];
|
2001-02-08 04:35:18 +08:00
|
|
|
|
|
|
|
/* The stuff in the middle */
|
|
|
|
s = src;
|
|
|
|
for (j = x1; j < x2; j++)
|
|
|
|
{
|
|
|
|
if (color)
|
|
|
|
{
|
|
|
|
if (has_alpha)
|
|
|
|
{
|
|
|
|
a = s[alpha] << 8;
|
|
|
|
|
|
|
|
if ((j + offset) & 0x4)
|
|
|
|
{
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 0] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_dark_check [(a | s[RED_PIX])];
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 1] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_dark_check [(a | s[GREEN_PIX])];
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 2] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_dark_check [(a | s[BLUE_PIX])];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 0] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_light_check [(a | s[RED_PIX])];
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 1] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_light_check [(a | s[GREEN_PIX])];
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 2] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_light_check [(a | s[BLUE_PIX])];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 0] = s[RED_PIX];
|
|
|
|
render_temp_buf[(border + j) * 3 + 1] = s[GREEN_PIX];
|
|
|
|
render_temp_buf[(border + j) * 3 + 2] = s[BLUE_PIX];
|
2001-02-08 04:35:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (has_alpha)
|
|
|
|
{
|
|
|
|
a = s[alpha] << 8;
|
|
|
|
|
|
|
|
if ((j + offset) & 0x4)
|
|
|
|
{
|
|
|
|
if (color_buf)
|
|
|
|
{
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 0] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_dark_check [(a | s[GRAY_PIX])];
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 1] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_dark_check [(a | s[GRAY_PIX])];
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 2] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_dark_check [(a | s[GRAY_PIX])];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j)] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_dark_check [(a | s[GRAY_PIX + channel])];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (color_buf)
|
|
|
|
{
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 0] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_light_check [(a | s[GRAY_PIX])];
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 1] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_light_check [(a | s[GRAY_PIX])];
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 2] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_light_check [(a | s[GRAY_PIX])];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j)] =
|
2001-02-08 04:35:18 +08:00
|
|
|
render_blend_light_check [(a | s[GRAY_PIX + channel])];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (color_buf)
|
|
|
|
{
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * 3 + 0] = s[GRAY_PIX];
|
|
|
|
render_temp_buf[(border + j) * 3 + 1] = s[GRAY_PIX];
|
|
|
|
render_temp_buf[(border + j) * 3 + 2] = s[GRAY_PIX];
|
2001-02-08 04:35:18 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j)] = s[GRAY_PIX + channel];
|
2001-02-08 04:35:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s += temp_buf->bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle the trailing transparency */
|
|
|
|
for (j = x2; j < width; j++)
|
|
|
|
for (b = 0; b < image_bytes; b++)
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * image_bytes + b] = cb[j * 3 + b];
|
2001-02-08 04:35:18 +08:00
|
|
|
|
|
|
|
src += rowstride;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (j = 0; j < width; j++)
|
|
|
|
for (b = 0; b < image_bytes; b++)
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf[(border + j) * image_bytes + b] = cb[j * 3 + b];
|
2001-02-08 04:35:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (preview),
|
2001-02-08 07:14:14 +08:00
|
|
|
render_temp_buf,
|
|
|
|
0,
|
|
|
|
i + border,
|
|
|
|
width + 2 * border);
|
2001-02-08 04:35:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (preview));
|
2001-02-05 23:22:20 +08:00
|
|
|
}
|
2001-03-05 06:07:19 +08:00
|
|
|
|
|
|
|
static GimpViewable *
|
|
|
|
gimp_preview_drag_viewable (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
return GIMP_PREVIEW (widget)->viewable;
|
|
|
|
}
|