2001-02-05 07:22:20 -08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2001-04-21 17:38:56 -07:00
|
|
|
* gimppreview.c
|
2001-10-17 09:11:28 -07:00
|
|
|
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
2001-02-05 07:22:20 -08:00
|
|
|
*
|
|
|
|
|
* 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-11 09:24:47 -08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-05-03 05:26:05 -07:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-21 13:30:16 -07:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-02-05 07:22:20 -08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
2001-05-07 20:48:54 -07:00
|
|
|
#include "widgets-types.h"
|
2001-02-05 07:22:20 -08:00
|
|
|
|
2001-05-08 19:32:03 -07:00
|
|
|
#include "core/gimpmarshal.h"
|
2002-03-22 07:47:59 -08:00
|
|
|
#include "core/gimpviewable.h"
|
2001-02-22 19:29:53 -08:00
|
|
|
|
2001-03-04 14:07:19 -08:00
|
|
|
#include "gimpdnd.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
#include "gimppreview.h"
|
2003-02-27 05:59:41 -08:00
|
|
|
#include "gimppreview-popup.h"
|
2003-02-28 19:53:41 -08:00
|
|
|
#include "gimppreviewrenderer.h"
|
|
|
|
|
#include "gimppreviewrenderer-utils.h"
|
2001-05-07 20:48:54 -07:00
|
|
|
|
2001-02-05 07:22:20 -08:00
|
|
|
|
2003-02-27 05:59:41 -08:00
|
|
|
#define PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
|
|
|
|
|
GDK_BUTTON_RELEASE_MASK | \
|
|
|
|
|
GDK_ENTER_NOTIFY_MASK | \
|
|
|
|
|
GDK_LEAVE_NOTIFY_MASK)
|
2001-02-05 07:22:20 -08:00
|
|
|
|
2003-04-03 08:13:12 -08:00
|
|
|
|
2001-02-06 13:43:59 -08:00
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
CLICKED,
|
2001-02-12 16:12:15 -08:00
|
|
|
DOUBLE_CLICKED,
|
2001-07-08 14:44:52 -07:00
|
|
|
CONTEXT,
|
2001-02-06 13:43:59 -08:00
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
2001-02-05 07:22:20 -08:00
|
|
|
|
2001-02-06 16:06:58 -08:00
|
|
|
static void gimp_preview_class_init (GimpPreviewClass *klass);
|
|
|
|
|
static void gimp_preview_init (GimpPreview *preview);
|
2002-01-30 09:39:56 -08:00
|
|
|
|
2001-02-06 16:06:58 -08:00
|
|
|
static void gimp_preview_destroy (GtkObject *object);
|
2003-04-03 08:13:12 -08:00
|
|
|
static void gimp_preview_realize (GtkWidget *widget);
|
2003-04-11 01:37:26 -07:00
|
|
|
static void gimp_preview_unrealize (GtkWidget *widget);
|
|
|
|
|
static void gimp_preview_map (GtkWidget *widget);
|
|
|
|
|
static void gimp_preview_unmap (GtkWidget *widget);
|
2003-03-03 04:59:03 -08:00
|
|
|
static void gimp_preview_size_request (GtkWidget *widget,
|
|
|
|
|
GtkRequisition *requisition);
|
2001-02-06 16:06:58 -08:00
|
|
|
static void gimp_preview_size_allocate (GtkWidget *widget,
|
|
|
|
|
GtkAllocation *allocation);
|
2002-01-31 08:47:20 -08:00
|
|
|
static gboolean gimp_preview_expose_event (GtkWidget *widget,
|
2002-01-30 09:39:56 -08:00
|
|
|
GdkEventExpose *event);
|
|
|
|
|
static gboolean gimp_preview_button_press_event (GtkWidget *widget,
|
2001-02-06 16:06:58 -08:00
|
|
|
GdkEventButton *bevent);
|
2003-08-13 16:28:26 -07:00
|
|
|
static gboolean gimp_preview_button_release_event (GtkWidget *widget,
|
2001-02-06 16:06:58 -08:00
|
|
|
GdkEventButton *bevent);
|
2002-01-30 09:39:56 -08:00
|
|
|
static gboolean gimp_preview_enter_notify_event (GtkWidget *widget,
|
2001-02-06 16:06:58 -08:00
|
|
|
GdkEventCrossing *event);
|
2002-01-30 09:39:56 -08:00
|
|
|
static gboolean gimp_preview_leave_notify_event (GtkWidget *widget,
|
2001-02-06 16:06:58 -08:00
|
|
|
GdkEventCrossing *event);
|
|
|
|
|
|
2003-02-28 19:53:41 -08:00
|
|
|
static void gimp_preview_update_callback (GimpPreviewRenderer *renderer,
|
|
|
|
|
GimpPreview *preview);
|
2002-01-31 08:47:20 -08:00
|
|
|
|
2001-03-04 14:07:19 -08:00
|
|
|
static GimpViewable * gimp_preview_drag_viewable (GtkWidget *widget,
|
|
|
|
|
gpointer data);
|
2001-02-05 07:22:20 -08:00
|
|
|
|
2003-04-03 08:13:12 -08:00
|
|
|
|
2001-02-05 07:22:20 -08:00
|
|
|
|
2001-02-06 13:43:59 -08:00
|
|
|
static guint preview_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2003-04-11 01:37:26 -07:00
|
|
|
static GtkWidgetClass *parent_class = NULL;
|
2001-02-05 07:22:20 -08:00
|
|
|
|
|
|
|
|
|
2001-08-06 17:06:06 -07:00
|
|
|
GType
|
2001-02-05 07:22:20 -08:00
|
|
|
gimp_preview_get_type (void)
|
|
|
|
|
{
|
2001-08-06 17:06:06 -07:00
|
|
|
static GType preview_type = 0;
|
2001-02-05 07:22:20 -08:00
|
|
|
|
|
|
|
|
if (! preview_type)
|
|
|
|
|
{
|
2001-10-17 04:33:43 -07:00
|
|
|
static const GTypeInfo preview_info =
|
2001-02-05 07:22:20 -08:00
|
|
|
{
|
2001-10-17 04:33:43 -07:00
|
|
|
sizeof (GimpPreviewClass),
|
|
|
|
|
NULL, /* base_init */
|
|
|
|
|
NULL, /* base_finalize */
|
|
|
|
|
(GClassInitFunc) gimp_preview_class_init,
|
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
|
NULL, /* class_data */
|
|
|
|
|
sizeof (GimpPreview),
|
|
|
|
|
0, /* n_preallocs */
|
|
|
|
|
(GInstanceInitFunc) gimp_preview_init,
|
2001-02-05 07:22:20 -08:00
|
|
|
};
|
|
|
|
|
|
2003-04-11 01:37:26 -07:00
|
|
|
preview_type = g_type_register_static (GTK_TYPE_WIDGET,
|
2001-10-17 04:33:43 -07:00
|
|
|
"GimpPreview",
|
|
|
|
|
&preview_info, 0);
|
2001-02-05 07:22:20 -08:00
|
|
|
}
|
2003-02-27 05:59:41 -08:00
|
|
|
|
2001-02-05 07:22:20 -08:00
|
|
|
return preview_type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_preview_class_init (GimpPreviewClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GtkObjectClass *object_class;
|
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
2001-10-17 04:33:43 -07:00
|
|
|
object_class = GTK_OBJECT_CLASS (klass);
|
|
|
|
|
widget_class = GTK_WIDGET_CLASS (klass);
|
2001-02-05 07:22:20 -08:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-24 14:27:11 -07:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-02-05 07:22:20 -08:00
|
|
|
|
2003-08-13 16:28:26 -07: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-24 14:27:11 -07:00
|
|
|
g_signal_new ("clicked",
|
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (GimpPreviewClass, clicked),
|
|
|
|
|
NULL, NULL,
|
2003-03-20 07:49:48 -08:00
|
|
|
gimp_marshal_VOID__FLAGS,
|
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
GDK_TYPE_MODIFIER_TYPE);
|
2001-02-06 13:43:59 -08:00
|
|
|
|
2003-08-13 16:28:26 -07: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-24 14:27:11 -07:00
|
|
|
g_signal_new ("double_clicked",
|
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (GimpPreviewClass, double_clicked),
|
|
|
|
|
NULL, NULL,
|
2001-11-22 15:46:13 -08:00
|
|
|
gimp_marshal_VOID__VOID,
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-24 14:27:11 -07:00
|
|
|
G_TYPE_NONE, 0);
|
2001-02-12 16:12:15 -08:00
|
|
|
|
2003-08-13 16:28:26 -07: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-24 14:27:11 -07:00
|
|
|
g_signal_new ("context",
|
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (GimpPreviewClass, context),
|
|
|
|
|
NULL, NULL,
|
2001-11-22 15:46:13 -08:00
|
|
|
gimp_marshal_VOID__VOID,
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-24 14:27:11 -07:00
|
|
|
G_TYPE_NONE, 0);
|
2001-07-08 14:44:52 -07:00
|
|
|
|
2001-06-18 06:10:03 -07:00
|
|
|
object_class->destroy = gimp_preview_destroy;
|
2001-02-05 07:22:20 -08:00
|
|
|
|
2002-04-18 07:14:50 -07:00
|
|
|
widget_class->activate_signal = preview_signals[CLICKED];
|
2003-04-03 08:13:12 -08:00
|
|
|
widget_class->realize = gimp_preview_realize;
|
2003-04-11 01:37:26 -07:00
|
|
|
widget_class->unrealize = gimp_preview_unrealize;
|
|
|
|
|
widget_class->map = gimp_preview_map;
|
|
|
|
|
widget_class->unmap = gimp_preview_unmap;
|
2003-03-03 04:59:03 -08:00
|
|
|
widget_class->size_request = gimp_preview_size_request;
|
2001-02-05 07:22:20 -08:00
|
|
|
widget_class->size_allocate = gimp_preview_size_allocate;
|
2002-01-31 08:47:20 -08:00
|
|
|
widget_class->expose_event = gimp_preview_expose_event;
|
2001-02-05 07:22:20 -08:00
|
|
|
widget_class->button_press_event = gimp_preview_button_press_event;
|
|
|
|
|
widget_class->button_release_event = gimp_preview_button_release_event;
|
2001-02-06 13: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 06:10:03 -07:00
|
|
|
klass->clicked = NULL;
|
|
|
|
|
klass->double_clicked = NULL;
|
2001-07-08 14:44:52 -07:00
|
|
|
klass->context = NULL;
|
2001-02-05 07:22:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_preview_init (GimpPreview *preview)
|
|
|
|
|
{
|
2003-04-11 01:37:26 -07:00
|
|
|
GTK_WIDGET_SET_FLAGS (preview, GTK_NO_WINDOW);
|
|
|
|
|
|
2002-05-28 13:04:28 -07:00
|
|
|
preview->viewable = NULL;
|
2003-02-28 19:53:41 -08:00
|
|
|
preview->renderer = NULL;
|
2001-02-07 10:01:54 -08:00
|
|
|
|
2002-05-28 13:04:28 -07:00
|
|
|
preview->clickable = FALSE;
|
|
|
|
|
preview->eat_button_events = TRUE;
|
|
|
|
|
preview->show_popup = FALSE;
|
2003-03-10 06:07:22 -08:00
|
|
|
preview->expand = FALSE;
|
2001-02-06 13:43:59 -08:00
|
|
|
|
2002-05-28 13:04:28 -07:00
|
|
|
preview->in_button = FALSE;
|
2001-02-05 07:22:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_preview_destroy (GtkObject *object)
|
|
|
|
|
{
|
2001-02-06 18:37:49 -08:00
|
|
|
GimpPreview *preview;
|
|
|
|
|
|
|
|
|
|
preview = GIMP_PREVIEW (object);
|
|
|
|
|
|
2001-07-31 09:55:59 -07:00
|
|
|
if (preview->viewable)
|
|
|
|
|
gimp_preview_set_viewable (preview, NULL);
|
2001-02-07 20:16:41 -08:00
|
|
|
|
2003-02-28 19:53:41 -08:00
|
|
|
if (preview->renderer)
|
2003-02-26 08:17:10 -08:00
|
|
|
{
|
2003-02-28 19:53:41 -08:00
|
|
|
g_object_unref (preview->renderer);
|
|
|
|
|
preview->renderer = NULL;
|
2003-02-26 08:17:10 -08:00
|
|
|
}
|
|
|
|
|
|
2002-03-22 07:21:18 -08:00
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
2001-02-05 07:22:20 -08:00
|
|
|
}
|
|
|
|
|
|
2003-04-03 08:13:12 -08:00
|
|
|
static void
|
|
|
|
|
gimp_preview_realize (GtkWidget *widget)
|
|
|
|
|
{
|
2003-04-11 01:37:26 -07:00
|
|
|
GimpPreview *preview;
|
|
|
|
|
GdkWindowAttr attributes;
|
|
|
|
|
gint attributes_mask;
|
|
|
|
|
|
|
|
|
|
preview = GIMP_PREVIEW (widget);
|
|
|
|
|
|
2003-04-03 08:13:12 -08:00
|
|
|
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
2003-08-13 16:28:26 -07:00
|
|
|
|
2003-04-11 01:37:26 -07:00
|
|
|
attributes.window_type = GDK_WINDOW_CHILD;
|
|
|
|
|
attributes.x = widget->allocation.x;
|
|
|
|
|
attributes.y = widget->allocation.y;
|
|
|
|
|
attributes.width = widget->allocation.width;
|
|
|
|
|
attributes.height = widget->allocation.height;
|
2003-08-13 16:28:26 -07:00
|
|
|
|
2003-04-11 01:37:26 -07:00
|
|
|
attributes.wclass = GDK_INPUT_ONLY;
|
|
|
|
|
attributes.event_mask = gtk_widget_get_events (widget);
|
|
|
|
|
attributes.event_mask |= PREVIEW_EVENT_MASK;
|
2003-04-03 08:13:12 -08:00
|
|
|
|
2003-04-11 01:37:26 -07:00
|
|
|
attributes_mask = GDK_WA_X | GDK_WA_Y;
|
|
|
|
|
|
|
|
|
|
preview->event_window = gdk_window_new (widget->window,
|
|
|
|
|
&attributes, attributes_mask);
|
|
|
|
|
gdk_window_set_user_data (preview->event_window, preview);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_preview_unrealize (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GimpPreview *preview = GIMP_PREVIEW (widget);
|
|
|
|
|
|
|
|
|
|
if (preview->event_window)
|
|
|
|
|
{
|
|
|
|
|
gdk_window_set_user_data (preview->event_window, NULL);
|
|
|
|
|
gdk_window_destroy (preview->event_window);
|
|
|
|
|
preview->event_window = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_preview_map (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GimpPreview *preview = GIMP_PREVIEW (widget);
|
|
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->map (widget);
|
|
|
|
|
|
|
|
|
|
if (preview->event_window)
|
|
|
|
|
gdk_window_show (preview->event_window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_preview_unmap (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GimpPreview *preview = GIMP_PREVIEW (widget);
|
|
|
|
|
|
2003-08-13 16:28:26 -07:00
|
|
|
if (preview->has_grab)
|
|
|
|
|
gtk_grab_remove (widget);
|
|
|
|
|
|
2003-04-11 01:37:26 -07:00
|
|
|
if (preview->event_window)
|
|
|
|
|
gdk_window_hide (preview->event_window);
|
|
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
|
2003-04-03 08:13:12 -08:00
|
|
|
}
|
|
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
static void
|
|
|
|
|
gimp_preview_size_request (GtkWidget *widget,
|
|
|
|
|
GtkRequisition *requisition)
|
|
|
|
|
{
|
|
|
|
|
GimpPreview *preview;
|
|
|
|
|
|
|
|
|
|
preview = GIMP_PREVIEW (widget);
|
|
|
|
|
|
2003-03-10 06:07:22 -08:00
|
|
|
if (preview->expand)
|
|
|
|
|
{
|
|
|
|
|
requisition->width = 2 * preview->renderer->border_width + 1;
|
|
|
|
|
requisition->height = 2 * preview->renderer->border_width + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
requisition->width = (preview->renderer->width +
|
|
|
|
|
2 * preview->renderer->border_width);
|
|
|
|
|
requisition->height = (preview->renderer->height +
|
|
|
|
|
2 * preview->renderer->border_width);
|
|
|
|
|
}
|
2003-03-03 04:59:03 -08:00
|
|
|
|
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->size_request)
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-31 08:47:20 -08:00
|
|
|
static void
|
|
|
|
|
gimp_preview_size_allocate (GtkWidget *widget,
|
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
|
{
|
|
|
|
|
GimpPreview *preview;
|
2002-06-12 08:39:03 -07:00
|
|
|
gint width;
|
|
|
|
|
gint height;
|
2002-01-31 08:47:20 -08:00
|
|
|
|
|
|
|
|
preview = GIMP_PREVIEW (widget);
|
|
|
|
|
|
2003-03-10 06:07:22 -08:00
|
|
|
if (preview->expand)
|
|
|
|
|
{
|
2003-04-01 05:53:47 -08:00
|
|
|
width = MIN (GIMP_VIEWABLE_MAX_PREVIEW_SIZE,
|
2003-03-10 06:07:22 -08:00
|
|
|
allocation->width - 2 * preview->renderer->border_width);
|
2003-04-01 05:53:47 -08:00
|
|
|
height = MIN (GIMP_VIEWABLE_MAX_PREVIEW_SIZE,
|
2003-03-10 06:07:22 -08:00
|
|
|
allocation->height - 2 * preview->renderer->border_width);
|
|
|
|
|
|
|
|
|
|
if (preview->renderer->width != width ||
|
|
|
|
|
preview->renderer->height != height)
|
|
|
|
|
{
|
|
|
|
|
gint border_width = preview->renderer->border_width;
|
|
|
|
|
|
|
|
|
|
if (preview->renderer->size != -1 && preview->renderer->viewable)
|
|
|
|
|
{
|
|
|
|
|
gint preview_width;
|
|
|
|
|
gint preview_height;
|
|
|
|
|
gint scaled_width;
|
|
|
|
|
gint scaled_height;
|
|
|
|
|
|
|
|
|
|
gimp_viewable_get_preview_size (preview->renderer->viewable,
|
2003-04-01 05:53:47 -08:00
|
|
|
GIMP_VIEWABLE_MAX_PREVIEW_SIZE,
|
2003-03-10 06:07:22 -08:00
|
|
|
preview->renderer->is_popup,
|
|
|
|
|
preview->renderer->dot_for_dot,
|
|
|
|
|
&preview_width,
|
|
|
|
|
&preview_height);
|
|
|
|
|
|
|
|
|
|
gimp_viewable_calc_preview_size (preview->renderer->viewable,
|
|
|
|
|
preview_width,
|
|
|
|
|
preview_height,
|
|
|
|
|
width, height,
|
|
|
|
|
TRUE, 1.0, 1.0,
|
|
|
|
|
&scaled_width, &scaled_height,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
if (scaled_width > width)
|
|
|
|
|
{
|
|
|
|
|
scaled_height = scaled_height * width / scaled_width;
|
|
|
|
|
scaled_width = scaled_width * width / scaled_width;
|
|
|
|
|
}
|
|
|
|
|
else if (scaled_height > height)
|
|
|
|
|
{
|
|
|
|
|
scaled_width = scaled_width * height / scaled_height;
|
|
|
|
|
scaled_height = scaled_height * height / scaled_height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gimp_preview_renderer_set_size (preview->renderer,
|
|
|
|
|
MAX (scaled_width, scaled_height),
|
|
|
|
|
border_width);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gimp_preview_renderer_set_size_full (preview->renderer,
|
|
|
|
|
width, height,
|
|
|
|
|
border_width);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gimp_preview_renderer_remove_idle (preview->renderer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-28 19:53:41 -08:00
|
|
|
width = (preview->renderer->width +
|
|
|
|
|
2 * preview->renderer->border_width);
|
|
|
|
|
height = (preview->renderer->height +
|
|
|
|
|
2 * preview->renderer->border_width);
|
2002-06-12 08:39:03 -07:00
|
|
|
|
|
|
|
|
if (allocation->width > width)
|
|
|
|
|
allocation->x += (allocation->width - width) / 2;
|
|
|
|
|
|
|
|
|
|
if (allocation->height > height)
|
|
|
|
|
allocation->y += (allocation->height - height) / 2;
|
|
|
|
|
|
|
|
|
|
allocation->width = width;
|
|
|
|
|
allocation->height = height;
|
2002-01-31 08:47:20 -08:00
|
|
|
|
2003-04-11 01:37:26 -07:00
|
|
|
widget->allocation = *allocation;
|
|
|
|
|
|
|
|
|
|
if (GTK_WIDGET_REALIZED (widget))
|
|
|
|
|
gdk_window_move_resize (preview->event_window,
|
|
|
|
|
allocation->x,
|
|
|
|
|
allocation->y,
|
|
|
|
|
allocation->width,
|
|
|
|
|
allocation->height);
|
2002-01-31 08:47:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gimp_preview_expose_event (GtkWidget *widget,
|
|
|
|
|
GdkEventExpose *event)
|
|
|
|
|
{
|
2003-02-26 08:17:10 -08:00
|
|
|
if (! GTK_WIDGET_DRAWABLE (widget))
|
2002-01-31 08:47:20 -08:00
|
|
|
return FALSE;
|
|
|
|
|
|
2003-04-11 04:18:12 -07:00
|
|
|
gimp_preview_renderer_draw (GIMP_PREVIEW (widget)->renderer,
|
2003-02-28 19:53:41 -08:00
|
|
|
widget->window, widget,
|
2003-04-11 01:37:26 -07:00
|
|
|
&widget->allocation,
|
2003-02-28 19:53:41 -08:00
|
|
|
&event->area);
|
2003-02-26 08:17:10 -08:00
|
|
|
|
2002-01-31 08:47:20 -08:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-07 03:33:01 -08:00
|
|
|
|
|
|
|
|
#define DEBUG_MEMSIZE 1
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_MEMSIZE
|
|
|
|
|
extern gboolean gimp_debug_memsize;
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-03-22 07:47:59 -08:00
|
|
|
static gboolean
|
2002-01-31 08:47:20 -08:00
|
|
|
gimp_preview_button_press_event (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *bevent)
|
|
|
|
|
{
|
|
|
|
|
GimpPreview *preview;
|
|
|
|
|
|
|
|
|
|
preview = GIMP_PREVIEW (widget);
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_MEMSIZE
|
|
|
|
|
if (bevent->type == GDK_BUTTON_PRESS && bevent->button == 2)
|
|
|
|
|
{
|
2002-02-07 03:33:01 -08:00
|
|
|
gimp_debug_memsize = TRUE;
|
|
|
|
|
|
2003-08-25 03:49:33 -07:00
|
|
|
gimp_object_get_memsize (GIMP_OBJECT (preview->viewable), NULL);
|
2002-02-07 03:33:01 -08:00
|
|
|
|
|
|
|
|
gimp_debug_memsize = FALSE;
|
2002-01-31 08:47:20 -08:00
|
|
|
}
|
|
|
|
|
#endif /* DEBUG_MEMSIZE */
|
|
|
|
|
|
|
|
|
|
if (! preview->clickable &&
|
|
|
|
|
! preview->show_popup)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2003-08-13 16:28:26 -07:00
|
|
|
if (! GTK_WIDGET_REALIZED (widget))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2002-01-31 08:47:20 -08:00
|
|
|
if (bevent->type == GDK_BUTTON_PRESS)
|
|
|
|
|
{
|
|
|
|
|
if (bevent->button == 1)
|
|
|
|
|
{
|
|
|
|
|
gtk_grab_add (widget);
|
|
|
|
|
|
2003-08-13 16:28:26 -07:00
|
|
|
preview->has_grab = TRUE;
|
2002-01-31 08:47:20 -08:00
|
|
|
preview->press_state = bevent->state;
|
|
|
|
|
|
2003-02-27 05:59:41 -08:00
|
|
|
if (preview->show_popup)
|
|
|
|
|
{
|
2003-04-11 01:37:26 -07:00
|
|
|
bevent->x += widget->allocation.x;
|
|
|
|
|
bevent->y += widget->allocation.y;
|
|
|
|
|
|
2003-02-27 05:59:41 -08:00
|
|
|
gimp_preview_popup_show (widget, bevent,
|
|
|
|
|
preview->viewable,
|
2003-02-28 19:53:41 -08:00
|
|
|
preview->renderer->width,
|
|
|
|
|
preview->renderer->height,
|
|
|
|
|
preview->renderer->dot_for_dot);
|
2002-01-31 08:47:20 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
preview->press_state = 0;
|
|
|
|
|
|
2003-02-27 05:59:41 -08:00
|
|
|
if (bevent->button == 3)
|
2003-08-13 16:28:26 -07:00
|
|
|
g_signal_emit (widget, preview_signals[CONTEXT], 0);
|
2002-01-31 08:47:20 -08:00
|
|
|
else
|
2003-08-13 16:28:26 -07:00
|
|
|
return FALSE;
|
2002-01-31 08:47:20 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (bevent->type == GDK_2BUTTON_PRESS)
|
|
|
|
|
{
|
|
|
|
|
if (bevent->button == 1)
|
2003-08-13 16:28:26 -07:00
|
|
|
g_signal_emit (widget, preview_signals[DOUBLE_CLICKED], 0);
|
2002-01-31 08:47:20 -08:00
|
|
|
}
|
|
|
|
|
|
2002-05-28 13:04:28 -07:00
|
|
|
return preview->eat_button_events ? TRUE : FALSE;
|
2002-01-31 08:47:20 -08:00
|
|
|
}
|
2003-08-13 16:28:26 -07:00
|
|
|
|
2002-03-22 07:47:59 -08:00
|
|
|
static gboolean
|
2002-01-31 08:47:20 -08:00
|
|
|
gimp_preview_button_release_event (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *bevent)
|
|
|
|
|
{
|
|
|
|
|
GimpPreview *preview;
|
|
|
|
|
|
|
|
|
|
preview = GIMP_PREVIEW (widget);
|
|
|
|
|
|
|
|
|
|
if (! preview->clickable &&
|
|
|
|
|
! preview->show_popup)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (bevent->button == 1)
|
|
|
|
|
{
|
|
|
|
|
gtk_grab_remove (widget);
|
|
|
|
|
|
2003-08-13 16:28:26 -07:00
|
|
|
preview->has_grab = FALSE;
|
|
|
|
|
|
2003-02-27 05:59:41 -08:00
|
|
|
if (preview->clickable && preview->in_button)
|
2002-01-31 08:47:20 -08:00
|
|
|
{
|
2003-03-20 07:49:48 -08:00
|
|
|
g_signal_emit (widget, preview_signals[CLICKED], 0,
|
|
|
|
|
preview->press_state);
|
2002-01-31 08:47:20 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-28 13:04:28 -07:00
|
|
|
return preview->eat_button_events ? TRUE : FALSE;
|
2002-01-31 08:47:20 -08:00
|
|
|
}
|
|
|
|
|
|
2002-03-22 07:47:59 -08:00
|
|
|
static gboolean
|
2002-01-31 08:47:20 -08:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-22 07:47:59 -08:00
|
|
|
static gboolean
|
2002-01-31 08:47:20 -08:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
2001-06-18 06:10:03 -07:00
|
|
|
GtkWidget *
|
|
|
|
|
gimp_preview_new (GimpViewable *viewable,
|
|
|
|
|
gint size,
|
|
|
|
|
gint border_width,
|
|
|
|
|
gboolean is_popup)
|
|
|
|
|
{
|
2003-03-03 04:59:03 -08:00
|
|
|
GtkWidget *preview;
|
2001-02-19 14:54:12 -08:00
|
|
|
|
2001-06-18 06:10:03 -07:00
|
|
|
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
|
2002-08-22 05:49:01 -07:00
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
preview = gimp_preview_new_by_types (GIMP_TYPE_PREVIEW,
|
|
|
|
|
G_TYPE_FROM_INSTANCE (viewable),
|
|
|
|
|
size, border_width, is_popup);
|
2001-02-12 16:12:15 -08:00
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
if (preview)
|
|
|
|
|
gimp_preview_set_viewable (GIMP_PREVIEW (preview), viewable);
|
2001-06-18 06:10:03 -07:00
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
gimp_preview_renderer_remove_idle (GIMP_PREVIEW (preview)->renderer);
|
2003-02-28 19:53:41 -08:00
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
return preview;
|
2001-02-09 07: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)
|
2003-03-03 04:59:03 -08:00
|
|
|
{
|
|
|
|
|
GtkWidget *preview;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
|
|
|
|
|
|
|
|
|
|
preview = gimp_preview_new_full_by_types (GIMP_TYPE_PREVIEW,
|
|
|
|
|
G_TYPE_FROM_INSTANCE (viewable),
|
|
|
|
|
width, height, border_width,
|
|
|
|
|
is_popup, clickable, show_popup);
|
|
|
|
|
|
|
|
|
|
if (preview)
|
|
|
|
|
gimp_preview_set_viewable (GIMP_PREVIEW (preview), viewable);
|
|
|
|
|
|
|
|
|
|
gimp_preview_renderer_remove_idle (GIMP_PREVIEW (preview)->renderer);
|
|
|
|
|
|
|
|
|
|
return preview;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gimp_preview_new_by_types (GType preview_type,
|
|
|
|
|
GType viewable_type,
|
|
|
|
|
gint size,
|
|
|
|
|
gint border_width,
|
|
|
|
|
gboolean is_popup)
|
2001-02-05 07:22:20 -08:00
|
|
|
{
|
2003-02-28 19:53:41 -08:00
|
|
|
GimpPreviewRenderer *renderer;
|
|
|
|
|
GimpPreview *preview;
|
2001-02-05 07:22:20 -08:00
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
g_return_val_if_fail (g_type_is_a (preview_type, GIMP_TYPE_PREVIEW), NULL);
|
|
|
|
|
g_return_val_if_fail (g_type_is_a (viewable_type, GIMP_TYPE_VIEWABLE), NULL);
|
2003-04-01 05:53:47 -08:00
|
|
|
g_return_val_if_fail (size > 0 &&
|
|
|
|
|
size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
|
2002-08-27 08:31:24 -07:00
|
|
|
g_return_val_if_fail (border_width >= 0 &&
|
|
|
|
|
border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH, NULL);
|
2001-02-05 07:22:20 -08:00
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
renderer = gimp_preview_renderer_new (viewable_type, size,
|
|
|
|
|
border_width, is_popup);
|
2003-02-28 19:53:41 -08:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (renderer != NULL, NULL);
|
|
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
preview = g_object_new (preview_type, NULL);
|
2002-08-22 05:49:01 -07:00
|
|
|
|
2003-02-28 19:53:41 -08:00
|
|
|
g_signal_connect (renderer, "update",
|
|
|
|
|
G_CALLBACK (gimp_preview_update_callback),
|
|
|
|
|
preview);
|
2001-02-07 15:14:14 -08:00
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
preview->renderer = renderer;
|
2001-02-07 20:16:41 -08:00
|
|
|
|
2001-02-05 07:22:20 -08:00
|
|
|
return GTK_WIDGET (preview);
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-22 05:49:01 -07:00
|
|
|
GtkWidget *
|
2003-03-03 04:59:03 -08:00
|
|
|
gimp_preview_new_full_by_types (GType preview_type,
|
|
|
|
|
GType viewable_type,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height,
|
|
|
|
|
gint border_width,
|
|
|
|
|
gboolean is_popup,
|
|
|
|
|
gboolean clickable,
|
|
|
|
|
gboolean show_popup)
|
2003-02-28 19:53:41 -08:00
|
|
|
{
|
|
|
|
|
GimpPreviewRenderer *renderer;
|
|
|
|
|
GimpPreview *preview;
|
2002-08-22 05:49:01 -07:00
|
|
|
|
2003-02-28 19:53:41 -08:00
|
|
|
g_return_val_if_fail (g_type_is_a (preview_type, GIMP_TYPE_PREVIEW), NULL);
|
2002-08-22 05:49:01 -07:00
|
|
|
g_return_val_if_fail (g_type_is_a (viewable_type, GIMP_TYPE_VIEWABLE), NULL);
|
2003-04-01 05:53:47 -08:00
|
|
|
g_return_val_if_fail (width > 0 &&
|
|
|
|
|
width <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
|
|
|
|
|
g_return_val_if_fail (height > 0 &&
|
|
|
|
|
height <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
|
2002-08-27 08:31:24 -07:00
|
|
|
g_return_val_if_fail (border_width >= 0 &&
|
|
|
|
|
border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH, NULL);
|
2002-08-22 05:49:01 -07:00
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
renderer = gimp_preview_renderer_new_full (viewable_type, width, height,
|
|
|
|
|
border_width, is_popup);
|
2003-02-28 19:53:41 -08:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (renderer != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
preview = g_object_new (preview_type, NULL);
|
2002-08-22 05:49:01 -07:00
|
|
|
|
2003-02-28 19:53:41 -08:00
|
|
|
g_signal_connect (renderer, "update",
|
|
|
|
|
G_CALLBACK (gimp_preview_update_callback),
|
|
|
|
|
preview);
|
|
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
preview->renderer = renderer;
|
|
|
|
|
preview->clickable = clickable ? TRUE : FALSE;
|
|
|
|
|
preview->show_popup = show_popup ? TRUE : FALSE;
|
2002-08-22 05:49:01 -07:00
|
|
|
|
|
|
|
|
return GTK_WIDGET (preview);
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-07 20:16:41 -08:00
|
|
|
void
|
|
|
|
|
gimp_preview_set_viewable (GimpPreview *preview,
|
|
|
|
|
GimpViewable *viewable)
|
|
|
|
|
{
|
2002-08-27 08:31:24 -07:00
|
|
|
GType viewable_type = G_TYPE_NONE;
|
|
|
|
|
|
2001-02-07 20:16:41 -08:00
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
2003-04-01 05:53:47 -08:00
|
|
|
g_return_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable));
|
2002-08-22 05:49:01 -07:00
|
|
|
|
|
|
|
|
if (viewable)
|
|
|
|
|
{
|
|
|
|
|
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
|
|
|
|
|
|
2003-02-28 19:53:41 -08:00
|
|
|
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (preview->renderer),
|
|
|
|
|
gimp_preview_renderer_type_from_viewable_type (viewable_type)));
|
2002-08-22 05:49:01 -07:00
|
|
|
}
|
2001-02-07 20:16:41 -08:00
|
|
|
|
2002-05-10 05:47:42 -07:00
|
|
|
if (viewable == preview->viewable)
|
|
|
|
|
return;
|
|
|
|
|
|
2001-02-07 20:16:41 -08:00
|
|
|
if (preview->viewable)
|
|
|
|
|
{
|
2001-08-12 08:39:23 -07:00
|
|
|
g_object_remove_weak_pointer (G_OBJECT (preview->viewable),
|
|
|
|
|
(gpointer *) &preview->viewable);
|
2001-06-18 06:10:03 -07:00
|
|
|
|
2003-02-28 19:53:41 -08:00
|
|
|
if (! viewable && ! preview->renderer->is_popup)
|
2003-02-20 04:47:42 -08:00
|
|
|
{
|
|
|
|
|
if (gimp_dnd_viewable_source_unset (GTK_WIDGET (preview),
|
|
|
|
|
G_TYPE_FROM_INSTANCE (preview->viewable)))
|
|
|
|
|
{
|
|
|
|
|
gtk_drag_source_unset (GTK_WIDGET (preview));
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-02-07 20:16:41 -08:00
|
|
|
}
|
2003-02-28 19:53:41 -08:00
|
|
|
else if (viewable && ! preview->renderer->is_popup)
|
2002-03-22 07:47:59 -08:00
|
|
|
{
|
2003-02-20 04:47:42 -08:00
|
|
|
if (gimp_dnd_drag_source_set_by_type (GTK_WIDGET (preview),
|
|
|
|
|
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
|
|
|
|
|
viewable_type,
|
|
|
|
|
GDK_ACTION_COPY))
|
|
|
|
|
{
|
|
|
|
|
gimp_dnd_viewable_source_set (GTK_WIDGET (preview),
|
2002-08-27 08:31:24 -07:00
|
|
|
viewable_type,
|
2003-02-20 04:47:42 -08:00
|
|
|
gimp_preview_drag_viewable,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
2002-03-22 07:47:59 -08:00
|
|
|
}
|
2001-02-07 20:16:41 -08:00
|
|
|
|
2003-02-28 19:53:41 -08:00
|
|
|
gimp_preview_renderer_set_viewable (preview->renderer, viewable);
|
2001-02-07 20:16:41 -08:00
|
|
|
preview->viewable = viewable;
|
|
|
|
|
|
|
|
|
|
if (preview->viewable)
|
|
|
|
|
{
|
2001-08-12 08:39:23 -07:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (preview->viewable),
|
|
|
|
|
(gpointer *) &preview->viewable);
|
2001-02-07 20:16:41 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-10 06:07:22 -08:00
|
|
|
void
|
|
|
|
|
gimp_preview_set_expand (GimpPreview *preview,
|
|
|
|
|
gboolean expand)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW (preview));
|
|
|
|
|
|
|
|
|
|
if (preview->expand != expand)
|
|
|
|
|
{
|
|
|
|
|
preview->expand = expand ? TRUE : FALSE;
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (preview));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 08:14:26 -08:00
|
|
|
|
2002-01-31 08:47:20 -08:00
|
|
|
/* private functions */
|
2001-02-06 13:43:59 -08:00
|
|
|
|
2002-11-04 04:15:29 -08:00
|
|
|
static void
|
2003-02-28 19:53:41 -08:00
|
|
|
gimp_preview_update_callback (GimpPreviewRenderer *renderer,
|
|
|
|
|
GimpPreview *preview)
|
2002-11-04 04:15:29 -08:00
|
|
|
{
|
2003-02-28 19:53:41 -08:00
|
|
|
GtkWidget *widget;
|
|
|
|
|
gint width;
|
|
|
|
|
gint height;
|
2002-11-04 04:15:29 -08:00
|
|
|
|
2003-02-28 19:53:41 -08:00
|
|
|
widget = GTK_WIDGET (preview);
|
2003-02-26 08:17:10 -08:00
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
width = renderer->width + 2 * renderer->border_width;
|
|
|
|
|
height = renderer->height + 2 * renderer->border_width;
|
2001-02-06 16:06:58 -08:00
|
|
|
|
2003-03-03 04:59:03 -08:00
|
|
|
if (width != widget->requisition.width ||
|
|
|
|
|
height != widget->requisition.height)
|
2001-06-18 06:10:03 -07:00
|
|
|
{
|
2003-03-03 04:59:03 -08:00
|
|
|
widget->requisition.width = width;
|
|
|
|
|
widget->requisition.height = height;
|
2001-06-18 06:10:03 -07:00
|
|
|
|
2003-02-28 19:53:41 -08:00
|
|
|
gtk_widget_queue_resize (widget);
|
2001-06-18 06:10:03 -07:00
|
|
|
}
|
2002-11-04 04:15:29 -08:00
|
|
|
else
|
2001-02-06 18:37:49 -08:00
|
|
|
{
|
2003-02-28 19:53:41 -08:00
|
|
|
gtk_widget_queue_draw (widget);
|
2001-02-06 18:37:49 -08:00
|
|
|
}
|
2001-02-07 12:35:18 -08:00
|
|
|
}
|
2001-02-05 07:22:20 -08:00
|
|
|
|
2002-01-31 08:47:20 -08:00
|
|
|
static GimpViewable *
|
|
|
|
|
gimp_preview_drag_viewable (GtkWidget *widget,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
return GIMP_PREVIEW (widget)->viewable;
|
|
|
|
|
}
|