1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
#include "config.h"
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display-types.h"
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools/tools-types.h"
|
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2004-07-14 00:36:29 +08:00
|
|
|
#include "core/gimparea.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2002-05-09 01:48:24 +08:00
|
|
|
#include "core/gimplist.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "core/gimpprogress.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2003-04-15 22:20:19 +08:00
|
|
|
#include "tools/gimptool.h"
|
2001-02-28 10:53:27 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gimpdisplay.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "gimpdisplay-handlers.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gimpdisplayshell.h"
|
2001-11-11 07:03:22 +08:00
|
|
|
#include "gimpdisplayshell-handlers.h"
|
2003-01-04 02:01:30 +08:00
|
|
|
#include "gimpdisplayshell-transform.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2001-07-31 19:33:13 +08:00
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2004-07-12 19:43:00 +08:00
|
|
|
PROP_ID,
|
2005-05-12 04:41:51 +08:00
|
|
|
PROP_IMAGE,
|
|
|
|
PROP_SHELL
|
2002-05-10 21:09:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* local function prototypes */
|
2001-07-31 19:33:13 +08:00
|
|
|
|
2004-08-11 18:29:56 +08:00
|
|
|
static void gimp_display_class_init (GimpDisplayClass *klass);
|
|
|
|
static void gimp_display_init (GimpDisplay *gdisp);
|
|
|
|
static void gimp_display_progress_iface_init (GimpProgressInterface *progress_iface);
|
|
|
|
|
|
|
|
static void gimp_display_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_display_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2004-08-11 02:47:21 +08:00
|
|
|
|
|
|
|
static GimpProgress *
|
2004-08-11 18:29:56 +08:00
|
|
|
gimp_display_progress_start (GimpProgress *progress,
|
|
|
|
const gchar *message,
|
|
|
|
gboolean cancelable);
|
|
|
|
static void gimp_display_progress_end (GimpProgress *progress);
|
|
|
|
static gboolean gimp_display_progress_is_active (GimpProgress *progress);
|
|
|
|
static void gimp_display_progress_set_text (GimpProgress *progress,
|
|
|
|
const gchar *message);
|
|
|
|
static void gimp_display_progress_set_value (GimpProgress *progress,
|
|
|
|
gdouble percentage);
|
|
|
|
static gdouble gimp_display_progress_get_value (GimpProgress *progress);
|
2005-02-12 22:18:12 +08:00
|
|
|
static void gimp_display_progress_pulse (GimpProgress *progress);
|
2004-08-11 18:29:56 +08:00
|
|
|
static void gimp_display_progress_canceled (GimpProgress *progress,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
|
|
static void gimp_display_flush_whenever (GimpDisplay *gdisp,
|
|
|
|
gboolean now);
|
|
|
|
static void gimp_display_paint_area (GimpDisplay *gdisp,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
2001-09-26 01:44:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
static GimpObjectClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
GType
|
|
|
|
gimp_display_get_type (void)
|
|
|
|
{
|
|
|
|
static GType display_type = 0;
|
|
|
|
|
|
|
|
if (! display_type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo display_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpDisplayClass),
|
2004-07-14 00:36:29 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_display_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpDisplay),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_display_init,
|
2001-09-26 01:44:03 +08:00
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
static const GInterfaceInfo progress_iface_info =
|
|
|
|
{
|
|
|
|
(GInterfaceInitFunc) gimp_display_progress_iface_init,
|
|
|
|
NULL, /* iface_finalize */
|
|
|
|
NULL /* iface_data */
|
|
|
|
};
|
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
display_type = g_type_register_static (GIMP_TYPE_OBJECT,
|
|
|
|
"GimpDisplay",
|
|
|
|
&display_info, 0);
|
2004-08-11 02:47:21 +08:00
|
|
|
|
|
|
|
g_type_add_interface_static (display_type, GIMP_TYPE_PROGRESS,
|
|
|
|
&progress_iface_info);
|
2001-09-26 01:44:03 +08:00
|
|
|
}
|
2001-02-02 02:44:22 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
return display_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_class_init (GimpDisplayClass *klass)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-06-02 06:04:20 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
object_class->set_property = gimp_display_set_property;
|
|
|
|
object_class->get_property = gimp_display_get_property;
|
|
|
|
|
2004-07-12 19:43:00 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_ID,
|
|
|
|
g_param_spec_int ("id",
|
|
|
|
NULL, NULL,
|
|
|
|
0, G_MAXINT, 0,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_IMAGE,
|
2004-07-12 19:43:00 +08:00
|
|
|
g_param_spec_object ("image",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_IMAGE,
|
|
|
|
G_PARAM_READABLE));
|
2005-05-12 04:41:51 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_SHELL,
|
|
|
|
g_param_spec_object ("shell",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_DISPLAY_SHELL,
|
|
|
|
G_PARAM_READABLE));
|
2001-09-26 01:44:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_init (GimpDisplay *gdisp)
|
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
gdisp->ID = 0;
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
gdisp->gimage = NULL;
|
|
|
|
gdisp->instance = 0;
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
gdisp->shell = NULL;
|
1998-06-15 10:25:27 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
gdisp->update_areas = NULL;
|
2001-09-26 01:44:03 +08:00
|
|
|
}
|
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
static void
|
|
|
|
gimp_display_progress_iface_init (GimpProgressInterface *progress_iface)
|
|
|
|
{
|
|
|
|
progress_iface->start = gimp_display_progress_start;
|
|
|
|
progress_iface->end = gimp_display_progress_end;
|
2004-08-11 18:29:56 +08:00
|
|
|
progress_iface->is_active = gimp_display_progress_is_active;
|
2004-08-11 02:47:21 +08:00
|
|
|
progress_iface->set_text = gimp_display_progress_set_text;
|
|
|
|
progress_iface->set_value = gimp_display_progress_set_value;
|
|
|
|
progress_iface->get_value = gimp_display_progress_get_value;
|
2005-02-12 22:18:12 +08:00
|
|
|
progress_iface->pulse = gimp_display_progress_pulse;
|
2004-08-11 02:47:21 +08:00
|
|
|
}
|
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
static void
|
|
|
|
gimp_display_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2004-07-12 19:43:00 +08:00
|
|
|
GimpDisplay *gdisp = GIMP_DISPLAY (object);
|
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
switch (property_id)
|
|
|
|
{
|
2004-07-12 19:43:00 +08:00
|
|
|
case PROP_ID:
|
|
|
|
gdisp->ID = g_value_get_int (value);
|
|
|
|
break;
|
2002-05-10 21:09:19 +08:00
|
|
|
case PROP_IMAGE:
|
2005-05-12 04:41:51 +08:00
|
|
|
case PROP_SHELL:
|
2002-05-10 21:09:19 +08:00
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2004-06-02 06:04:20 +08:00
|
|
|
GimpDisplay *gdisp = GIMP_DISPLAY (object);
|
2002-05-10 21:09:19 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2004-07-12 19:43:00 +08:00
|
|
|
case PROP_ID:
|
|
|
|
g_value_set_int (value, gdisp->ID);
|
|
|
|
break;
|
2002-05-10 21:09:19 +08:00
|
|
|
case PROP_IMAGE:
|
|
|
|
g_value_set_object (value, gdisp->gimage);
|
|
|
|
break;
|
2005-05-12 04:41:51 +08:00
|
|
|
case PROP_SHELL:
|
|
|
|
g_value_set_object (value, gdisp->shell);
|
|
|
|
break;
|
2002-05-10 21:09:19 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
static GimpProgress *
|
|
|
|
gimp_display_progress_start (GimpProgress *progress,
|
|
|
|
const gchar *message,
|
|
|
|
gboolean cancelable)
|
|
|
|
{
|
2004-09-01 23:26:48 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
|
|
|
if (! display->shell)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (display->shell);
|
2004-08-11 02:47:21 +08:00
|
|
|
|
|
|
|
return gimp_progress_start (GIMP_PROGRESS (shell->statusbar),
|
|
|
|
message, cancelable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_progress_end (GimpProgress *progress)
|
|
|
|
{
|
2004-09-01 23:26:48 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
|
|
|
if (! display->shell)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (display->shell);
|
2004-08-11 02:47:21 +08:00
|
|
|
|
|
|
|
gimp_progress_end (GIMP_PROGRESS (shell->statusbar));
|
|
|
|
}
|
|
|
|
|
2004-08-11 18:29:56 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_display_progress_is_active (GimpProgress *progress)
|
|
|
|
{
|
2004-09-01 23:26:48 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
|
|
|
if (! display->shell)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (display->shell);
|
2004-08-11 18:29:56 +08:00
|
|
|
|
|
|
|
return gimp_progress_is_active (GIMP_PROGRESS (shell->statusbar));
|
|
|
|
}
|
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
static void
|
|
|
|
gimp_display_progress_set_text (GimpProgress *progress,
|
|
|
|
const gchar *message)
|
|
|
|
{
|
2004-09-01 23:26:48 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
|
|
|
if (! display->shell)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (display->shell);
|
2004-08-11 02:47:21 +08:00
|
|
|
|
|
|
|
gimp_progress_set_text (GIMP_PROGRESS (shell->statusbar), message);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_progress_set_value (GimpProgress *progress,
|
|
|
|
gdouble percentage)
|
|
|
|
{
|
2004-09-01 23:26:48 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
|
|
|
if (! display->shell)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (display->shell);
|
2004-08-11 02:47:21 +08:00
|
|
|
|
|
|
|
gimp_progress_set_value (GIMP_PROGRESS (shell->statusbar), percentage);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gdouble
|
|
|
|
gimp_display_progress_get_value (GimpProgress *progress)
|
|
|
|
{
|
2004-09-01 23:26:48 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
|
|
|
if (! display->shell)
|
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (display->shell);
|
2004-08-11 02:47:21 +08:00
|
|
|
|
|
|
|
return gimp_progress_get_value (GIMP_PROGRESS (shell->statusbar));
|
|
|
|
}
|
|
|
|
|
2005-02-12 22:18:12 +08:00
|
|
|
static void
|
|
|
|
gimp_display_progress_pulse (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
|
|
|
if (! display->shell)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (display->shell);
|
|
|
|
|
|
|
|
gimp_progress_pulse (GIMP_PROGRESS (shell->statusbar));
|
|
|
|
}
|
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
static void
|
|
|
|
gimp_display_progress_canceled (GimpProgress *progress,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
gimp_progress_cancel (GIMP_PROGRESS (display));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
GimpDisplay *
|
2003-01-11 01:55:53 +08:00
|
|
|
gimp_display_new (GimpImage *gimage,
|
2004-06-02 06:04:20 +08:00
|
|
|
GimpUnit unit,
|
2004-01-30 06:22:29 +08:00
|
|
|
gdouble scale,
|
2003-01-11 01:55:53 +08:00
|
|
|
GimpMenuFactory *menu_factory,
|
2004-04-29 20:52:29 +08:00
|
|
|
GimpUIManager *popup_manager)
|
2001-09-26 01:44:03 +08:00
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
/* If there isn't an interface, never create a gdisplay */
|
2001-10-29 19:47:11 +08:00
|
|
|
if (gimage->gimp->no_interface)
|
2001-09-26 01:44:03 +08:00
|
|
|
return NULL;
|
|
|
|
|
2004-07-12 19:43:00 +08:00
|
|
|
gdisp = g_object_new (GIMP_TYPE_DISPLAY,
|
|
|
|
"id", gimage->gimp->next_display_ID++,
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-08 20:39:01 +08:00
|
|
|
/* refs the image */
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_connect (gdisp, gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* create the shell for the image */
|
2004-06-02 06:04:20 +08:00
|
|
|
gdisp->shell = gimp_display_shell_new (gdisp, unit, scale,
|
2004-04-29 20:52:29 +08:00
|
|
|
menu_factory, popup_manager);
|
2001-11-10 00:54:56 +08:00
|
|
|
gtk_widget_show (gdisp->shell);
|
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
g_signal_connect (GIMP_DISPLAY_SHELL (gdisp->shell)->statusbar, "cancel",
|
|
|
|
G_CALLBACK (gimp_display_progress_canceled),
|
|
|
|
gdisp);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return gdisp;
|
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
void
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_delete (GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-08 01:36:00 +08:00
|
|
|
GimpTool *active_tool;
|
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* remove the display from the list */
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_container_remove (gdisp->gimage->gimp->displays,
|
|
|
|
GIMP_OBJECT (gdisp));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* stop any active tool */
|
2001-07-08 01:36:00 +08:00
|
|
|
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
|
|
|
|
|
|
|
|
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-10-14 19:14:28 +08:00
|
|
|
if (active_tool)
|
1999-06-22 06:12:07 +08:00
|
|
|
{
|
2003-10-14 19:14:28 +08:00
|
|
|
if (active_tool->focus_display == gdisp)
|
|
|
|
tool_manager_focus_display_active (gdisp->gimage->gimp, NULL);
|
|
|
|
|
|
|
|
/* clear out the pointer to this gdisp from the active tool */
|
|
|
|
if (active_tool->gdisp == gdisp)
|
|
|
|
{
|
|
|
|
active_tool->drawable = NULL;
|
|
|
|
active_tool->gdisp = NULL;
|
|
|
|
}
|
1998-04-15 06:05:08 +08:00
|
|
|
}
|
1998-04-13 12:32:39 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* free the update area lists */
|
2004-07-14 00:36:29 +08:00
|
|
|
gdisp->update_areas = gimp_area_list_free (gdisp->update_areas);
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
if (gdisp->shell)
|
|
|
|
{
|
2004-01-03 01:36:45 +08:00
|
|
|
GtkWidget *shell = gdisp->shell;
|
|
|
|
|
|
|
|
/* set gdisp->shell to NULL *before* destroying the shell.
|
|
|
|
* all callbacks in gimpdisplayshell-callbacks.c will check
|
|
|
|
* this pointer and do nothing if the shell is in destruction.
|
|
|
|
*/
|
2001-09-26 01:44:03 +08:00
|
|
|
gdisp->shell = NULL;
|
2004-01-03 01:36:45 +08:00
|
|
|
gtk_widget_destroy (shell);
|
2001-09-26 01:44:03 +08:00
|
|
|
}
|
1998-02-14 23:30:31 +08:00
|
|
|
|
2002-05-08 20:39:01 +08:00
|
|
|
/* unrefs the gimage */
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_disconnect (gdisp);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
gint
|
|
|
|
gimp_display_get_ID (GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), -1);
|
|
|
|
|
|
|
|
return gdisp->ID;
|
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplay *
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_get_by_ID (Gimp *gimp,
|
|
|
|
gint ID)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-07-12 19:43:00 +08:00
|
|
|
GList *list;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2002-05-08 20:39:01 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
for (list = GIMP_LIST (gimp->displays)->list;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-07-12 19:43:00 +08:00
|
|
|
GimpDisplay *gdisp = list->data;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
|
|
|
if (gdisp->ID == ID)
|
2004-07-14 00:36:29 +08:00
|
|
|
return gdisp;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
void
|
2003-10-08 22:50:26 +08:00
|
|
|
gimp_display_reconnect (GimpDisplay *gdisp,
|
2001-11-11 07:03:22 +08:00
|
|
|
GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2003-10-12 19:20:22 +08:00
|
|
|
/* stop any active tool */
|
|
|
|
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_shell_disconnect (GIMP_DISPLAY_SHELL (gdisp->shell));
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_disconnect (gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_connect (gdisp, gimage);
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_shell_reconnect (GIMP_DISPLAY_SHELL (gdisp->shell));
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
void
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_display_update_area (GimpDisplay *gdisp,
|
|
|
|
gboolean now,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-11 07:03:22 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
1998-10-02 00:22:28 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
if (now)
|
|
|
|
{
|
|
|
|
gimp_display_paint_area (gdisp, x, y, w, h);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GimpArea *area = gimp_area_new (CLAMP (x, 0, gdisp->gimage->width),
|
|
|
|
CLAMP (y, 0, gdisp->gimage->height),
|
|
|
|
CLAMP (x + w, 0, gdisp->gimage->width),
|
|
|
|
CLAMP (y + h, 0, gdisp->gimage->height));
|
1997-11-27 03:30:17 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
gdisp->update_areas = gimp_area_list_process (gdisp->update_areas, area);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
void
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_flush (GimpDisplay *gdisp)
|
1998-10-02 00:22:28 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_flush_whenever (gdisp, FALSE);
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_flush_now (GimpDisplay *gdisp)
|
1998-10-02 00:22:28 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_flush_whenever (gdisp, TRUE);
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2003-10-08 22:50:26 +08:00
|
|
|
gimp_display_flush_whenever (GimpDisplay *gdisp,
|
2001-11-11 07:03:22 +08:00
|
|
|
gboolean now)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2003-07-30 00:36:56 +08:00
|
|
|
if (gdisp->update_areas)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
for (list = gdisp->update_areas; list; list = g_slist_next (list))
|
2003-07-30 00:36:56 +08:00
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
GimpArea *area = list->data;
|
2003-07-30 00:36:56 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
if ((area->x1 != area->x2) && (area->y1 != area->y2))
|
2003-07-30 00:36:56 +08:00
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_display_paint_area (gdisp,
|
|
|
|
area->x1,
|
|
|
|
area->y1,
|
|
|
|
(area->x2 - area->x1),
|
|
|
|
(area->y2 - area->y1));
|
2003-07-30 00:36:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
gdisp->update_areas = gimp_area_list_free (gdisp->update_areas);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_display_shell_flush (GIMP_DISPLAY_SHELL (gdisp->shell), now);
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_paint_area (GimpDisplay *gdisp,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
|
|
|
{
|
2004-06-02 06:04:20 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
2001-11-11 07:03:22 +08:00
|
|
|
gint x1, y1, x2, y2;
|
2003-11-21 02:08:01 +08:00
|
|
|
gdouble x1_f, y1_f, x2_f, y2_f;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
|
|
|
/* Bounds check */
|
|
|
|
x1 = CLAMP (x, 0, gdisp->gimage->width);
|
|
|
|
y1 = CLAMP (y, 0, gdisp->gimage->height);
|
|
|
|
x2 = CLAMP (x + w, 0, gdisp->gimage->width);
|
|
|
|
y2 = CLAMP (y + h, 0, gdisp->gimage->height);
|
|
|
|
x = x1;
|
|
|
|
y = y1;
|
|
|
|
w = (x2 - x1);
|
|
|
|
h = (y2 - y1);
|
|
|
|
|
|
|
|
/* display the area */
|
2003-11-21 02:08:01 +08:00
|
|
|
gimp_display_shell_transform_xy_f (shell, x, y, &x1_f, &y1_f, FALSE);
|
|
|
|
gimp_display_shell_transform_xy_f (shell, x + w, y + h, &x2_f, &y2_f, FALSE);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2003-11-21 02:08:01 +08:00
|
|
|
/* make sure to expose a superset of the transformed sub-pixel expose
|
|
|
|
* area, not a subset. bug #126942. --mitch
|
|
|
|
*/
|
|
|
|
x1 = floor (x1_f);
|
|
|
|
y1 = floor (y1_f);
|
|
|
|
x2 = ceil (x2_f);
|
|
|
|
y2 = ceil (y2_f);
|
|
|
|
|
|
|
|
gimp_display_shell_expose_area (shell, x1, y1, x2 - x1, y2 - y1);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|