1997-11-24 22:05:25 +00:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 05:44:11 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-12-16 21:37:03 +00: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-01 20:30:56 +00:00
|
|
|
#include "config.h"
|
2001-10-29 11:47:11 +00:00
|
|
|
|
2000-12-16 21:37:03 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "display-types.h"
|
2002-05-03 12:45:22 +00:00
|
|
|
#include "tools/tools-types.h"
|
|
|
|
|
2001-07-07 12:17:23 +00:00
|
|
|
#include "core/gimp.h"
|
2004-07-13 16:36:29 +00:00
|
|
|
#include "core/gimparea.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpimage.h"
|
2002-05-08 17:48:24 +00:00
|
|
|
#include "core/gimplist.h"
|
2004-08-10 18:47:21 +00:00
|
|
|
#include "core/gimpprogress.h"
|
2003-01-10 17:55:53 +00:00
|
|
|
|
2003-04-15 14:20:19 +00:00
|
|
|
#include "tools/gimptool.h"
|
2001-02-28 02:53:27 +00:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "gimpdisplay.h"
|
2001-10-31 21:20:09 +00:00
|
|
|
#include "gimpdisplay-handlers.h"
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "gimpdisplayshell.h"
|
2001-11-10 23:03:22 +00:00
|
|
|
#include "gimpdisplayshell-handlers.h"
|
2003-01-03 18:01:30 +00:00
|
|
|
#include "gimpdisplayshell-transform.h"
|
2001-04-17 21:43:29 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2000-04-27 17:27:28 +00:00
|
|
|
|
2001-07-31 11:33:13 +00:00
|
|
|
|
2002-05-10 13:09:19 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2004-07-12 11:43:00 +00:00
|
|
|
PROP_ID,
|
2005-05-11 20:41:51 +00:00
|
|
|
PROP_IMAGE,
|
|
|
|
PROP_SHELL
|
2002-05-10 13:09:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-10-31 21:20:09 +00:00
|
|
|
/* local function prototypes */
|
2001-07-31 11:33:13 +00:00
|
|
|
|
2005-12-10 19:24:36 +00:00
|
|
|
static void gimp_display_progress_iface_init (GimpProgressInterface *iface);
|
2004-08-11 10:29:56 +00:00
|
|
|
|
2005-09-09 18:07:31 +00:00
|
|
|
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-10 18:47:21 +00:00
|
|
|
|
|
|
|
static GimpProgress *
|
2005-09-09 18:07:31 +00: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);
|
|
|
|
static void gimp_display_progress_pulse (GimpProgress *progress);
|
|
|
|
static guint32 gimp_display_progress_get_window (GimpProgress *progress);
|
|
|
|
static void gimp_display_progress_canceled (GimpProgress *progress,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
static void gimp_display_flush_whenever (GimpDisplay *display,
|
2005-09-09 18:07:31 +00:00
|
|
|
gboolean now);
|
2006-03-28 17:55:52 +00:00
|
|
|
static void gimp_display_paint_area (GimpDisplay *display,
|
2005-09-09 18:07:31 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
2001-09-25 17:44:03 +00:00
|
|
|
|
|
|
|
|
2005-12-10 19:24:36 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpDisplay, gimp_display, GIMP_TYPE_OBJECT,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
|
2006-05-15 09:46:31 +00:00
|
|
|
gimp_display_progress_iface_init))
|
2001-09-25 17:44:03 +00:00
|
|
|
|
2005-12-10 19:24:36 +00:00
|
|
|
#define parent_class gimp_display_parent_class
|
2001-09-25 17:44:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_class_init (GimpDisplayClass *klass)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2004-06-01 22:04:20 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-05-10 13:09:19 +00:00
|
|
|
object_class->set_property = gimp_display_set_property;
|
|
|
|
object_class->get_property = gimp_display_get_property;
|
|
|
|
|
2004-07-12 11:43:00 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_ID,
|
|
|
|
g_param_spec_int ("id",
|
|
|
|
NULL, NULL,
|
|
|
|
0, G_MAXINT, 0,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_READWRITE |
|
2004-07-12 11:43:00 +00:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2002-05-10 13:09:19 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_IMAGE,
|
2004-07-12 11:43:00 +00:00
|
|
|
g_param_spec_object ("image",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_IMAGE,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_READABLE));
|
2005-05-11 20:41:51 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_SHELL,
|
|
|
|
g_param_spec_object ("shell",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_DISPLAY_SHELL,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_READABLE));
|
2001-09-25 17:44:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_init (GimpDisplay *display)
|
2001-09-25 17:44:03 +00:00
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
display->ID = 0;
|
2001-09-25 17:44:03 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
display->image = NULL;
|
|
|
|
display->instance = 0;
|
2001-09-25 17:44:03 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
display->shell = NULL;
|
1998-06-15 02:25:27 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
display->update_areas = NULL;
|
2001-09-25 17:44:03 +00:00
|
|
|
}
|
|
|
|
|
2004-08-10 18:47:21 +00:00
|
|
|
static void
|
2005-12-10 19:24:36 +00:00
|
|
|
gimp_display_progress_iface_init (GimpProgressInterface *iface)
|
2004-08-10 18:47:21 +00:00
|
|
|
{
|
2005-12-10 19:24:36 +00:00
|
|
|
iface->start = gimp_display_progress_start;
|
|
|
|
iface->end = gimp_display_progress_end;
|
|
|
|
iface->is_active = gimp_display_progress_is_active;
|
|
|
|
iface->set_text = gimp_display_progress_set_text;
|
|
|
|
iface->set_value = gimp_display_progress_set_value;
|
|
|
|
iface->get_value = gimp_display_progress_get_value;
|
|
|
|
iface->pulse = gimp_display_progress_pulse;
|
|
|
|
iface->get_window = gimp_display_progress_get_window;
|
2004-08-10 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
2002-05-10 13:09:19 +00:00
|
|
|
static void
|
|
|
|
gimp_display_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (object);
|
2004-07-12 11:43:00 +00:00
|
|
|
|
2002-05-10 13:09:19 +00:00
|
|
|
switch (property_id)
|
|
|
|
{
|
2004-07-12 11:43:00 +00:00
|
|
|
case PROP_ID:
|
2006-03-28 17:55:52 +00:00
|
|
|
display->ID = g_value_get_int (value);
|
2004-07-12 11:43:00 +00:00
|
|
|
break;
|
2002-05-10 13:09:19 +00:00
|
|
|
case PROP_IMAGE:
|
2005-05-11 20:41:51 +00:00
|
|
|
case PROP_SHELL:
|
2002-05-10 13:09:19 +00: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)
|
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (object);
|
2002-05-10 13:09:19 +00:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2004-07-12 11:43:00 +00:00
|
|
|
case PROP_ID:
|
2006-03-28 17:55:52 +00:00
|
|
|
g_value_set_int (value, display->ID);
|
2004-07-12 11:43:00 +00:00
|
|
|
break;
|
2002-05-10 13:09:19 +00:00
|
|
|
case PROP_IMAGE:
|
2006-03-28 17:55:52 +00:00
|
|
|
g_value_set_object (value, display->image);
|
2002-05-10 13:09:19 +00:00
|
|
|
break;
|
2005-05-11 20:41:51 +00:00
|
|
|
case PROP_SHELL:
|
2006-03-28 17:55:52 +00:00
|
|
|
g_value_set_object (value, display->shell);
|
2005-05-11 20:41:51 +00:00
|
|
|
break;
|
2002-05-10 13:09:19 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-10 18:47:21 +00:00
|
|
|
static GimpProgress *
|
|
|
|
gimp_display_progress_start (GimpProgress *progress,
|
|
|
|
const gchar *message,
|
|
|
|
gboolean cancelable)
|
|
|
|
{
|
2006-06-29 09:42:05 +00:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2004-09-01 15:26:48 +00:00
|
|
|
|
|
|
|
if (! display->shell)
|
|
|
|
return NULL;
|
|
|
|
|
2006-06-29 09:42:05 +00:00
|
|
|
return gimp_progress_start (GIMP_PROGRESS (display->shell),
|
2004-08-10 18:47:21 +00:00
|
|
|
message, cancelable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_progress_end (GimpProgress *progress)
|
|
|
|
{
|
2006-06-29 09:42:05 +00:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2004-08-10 18:47:21 +00:00
|
|
|
|
2006-06-29 09:42:05 +00:00
|
|
|
if (display->shell)
|
|
|
|
gimp_progress_end (GIMP_PROGRESS (display->shell));
|
2004-08-10 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
2004-08-11 10:29:56 +00:00
|
|
|
static gboolean
|
|
|
|
gimp_display_progress_is_active (GimpProgress *progress)
|
|
|
|
{
|
2006-06-29 09:42:05 +00:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2004-09-01 15:26:48 +00:00
|
|
|
|
|
|
|
if (! display->shell)
|
|
|
|
return FALSE;
|
|
|
|
|
2006-06-29 09:42:05 +00:00
|
|
|
return gimp_progress_is_active (GIMP_PROGRESS (display->shell));
|
2004-08-11 10:29:56 +00:00
|
|
|
}
|
|
|
|
|
2004-08-10 18:47:21 +00:00
|
|
|
static void
|
|
|
|
gimp_display_progress_set_text (GimpProgress *progress,
|
|
|
|
const gchar *message)
|
|
|
|
{
|
2006-06-29 09:42:05 +00:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2004-08-10 18:47:21 +00:00
|
|
|
|
2006-06-29 09:42:05 +00:00
|
|
|
if (display->shell)
|
|
|
|
gimp_progress_set_text (GIMP_PROGRESS (display->shell), message);
|
2004-08-10 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_progress_set_value (GimpProgress *progress,
|
|
|
|
gdouble percentage)
|
|
|
|
{
|
2006-06-29 09:42:05 +00:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2004-08-10 18:47:21 +00:00
|
|
|
|
2006-06-29 09:42:05 +00:00
|
|
|
if (display->shell)
|
|
|
|
gimp_progress_set_value (GIMP_PROGRESS (display->shell), percentage);
|
2004-08-10 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gdouble
|
|
|
|
gimp_display_progress_get_value (GimpProgress *progress)
|
|
|
|
{
|
2006-06-29 09:42:05 +00:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2004-09-01 15:26:48 +00:00
|
|
|
|
|
|
|
if (! display->shell)
|
|
|
|
return 0.0;
|
|
|
|
|
2006-06-29 09:42:05 +00:00
|
|
|
return gimp_progress_get_value (GIMP_PROGRESS (display->shell));
|
2004-08-10 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
2005-02-12 14:18:12 +00:00
|
|
|
static void
|
|
|
|
gimp_display_progress_pulse (GimpProgress *progress)
|
|
|
|
{
|
2006-06-29 09:42:05 +00:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2005-02-12 14:18:12 +00:00
|
|
|
|
2006-06-29 09:42:05 +00:00
|
|
|
if (display->shell)
|
|
|
|
gimp_progress_pulse (GIMP_PROGRESS (display->shell));
|
2005-02-12 14:18:12 +00:00
|
|
|
}
|
|
|
|
|
2005-09-09 18:07:31 +00:00
|
|
|
static guint32
|
|
|
|
gimp_display_progress_get_window (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
|
|
|
|
if (! display->shell)
|
|
|
|
return 0;
|
|
|
|
|
2006-06-29 09:42:05 +00:00
|
|
|
return gimp_progress_get_window (GIMP_PROGRESS (display->shell));
|
2005-09-09 18:07:31 +00:00
|
|
|
}
|
|
|
|
|
2004-08-10 18:47:21 +00:00
|
|
|
static void
|
|
|
|
gimp_display_progress_canceled (GimpProgress *progress,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
gimp_progress_cancel (GIMP_PROGRESS (display));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2001-09-25 17:44:03 +00:00
|
|
|
GimpDisplay *
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_display_new (GimpImage *image,
|
2004-06-01 22:04:20 +00:00
|
|
|
GimpUnit unit,
|
2004-01-29 22:22:29 +00:00
|
|
|
gdouble scale,
|
2003-01-10 17:55:53 +00:00
|
|
|
GimpMenuFactory *menu_factory,
|
2004-04-29 12:52:29 +00:00
|
|
|
GimpUIManager *popup_manager)
|
2001-09-25 17:44:03 +00:00
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
GimpDisplay *display;
|
2006-05-09 19:15:49 +00:00
|
|
|
gint ID;
|
2001-09-25 17:44:03 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
2001-10-29 11:47:11 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
/* If there isn't an interface, never create a displaylay */
|
2006-03-28 17:08:36 +00:00
|
|
|
if (image->gimp->no_interface)
|
2001-09-25 17:44:03 +00:00
|
|
|
return NULL;
|
|
|
|
|
2006-05-09 19:15:49 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
ID = image->gimp->next_display_ID++;
|
|
|
|
|
|
|
|
if (image->gimp->next_display_ID == G_MAXINT)
|
|
|
|
image->gimp->next_display_ID = 1;
|
|
|
|
}
|
|
|
|
while (gimp_display_get_by_ID (image->gimp, ID));
|
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
display = g_object_new (GIMP_TYPE_DISPLAY,
|
2006-05-09 19:15:49 +00:00
|
|
|
"id", ID,
|
2006-03-28 17:55:52 +00:00
|
|
|
NULL);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-05-08 12:39:01 +00:00
|
|
|
/* refs the image */
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_connect (display, image);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-10-31 21:20:09 +00:00
|
|
|
/* create the shell for the image */
|
2006-03-28 17:55:52 +00:00
|
|
|
display->shell = gimp_display_shell_new (display, unit, scale,
|
|
|
|
menu_factory, popup_manager);
|
|
|
|
gtk_widget_show (display->shell);
|
2001-11-09 16:54:56 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
g_signal_connect (GIMP_DISPLAY_SHELL (display->shell)->statusbar, "cancel",
|
2004-08-10 18:47:21 +00:00
|
|
|
G_CALLBACK (gimp_display_progress_canceled),
|
2006-03-28 17:55:52 +00:00
|
|
|
display);
|
2004-08-10 18:47:21 +00:00
|
|
|
|
2006-05-09 19:15:49 +00:00
|
|
|
/* add the display to the list */
|
|
|
|
gimp_container_add (image->gimp->displays, GIMP_OBJECT (display));
|
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
return display;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2001-10-31 21:20:09 +00:00
|
|
|
void
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_delete (GimpDisplay *display)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-07-07 17:36:00 +00:00
|
|
|
GimpTool *active_tool;
|
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2001-09-25 17:44:03 +00:00
|
|
|
|
2001-10-31 21:20:09 +00:00
|
|
|
/* remove the display from the list */
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_container_remove (display->image->gimp->displays,
|
|
|
|
GIMP_OBJECT (display));
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* stop any active tool */
|
2006-05-21 21:12:01 +00:00
|
|
|
tool_manager_control_active (display->image->gimp, GIMP_TOOL_ACTION_HALT,
|
|
|
|
display);
|
2001-07-07 17:36:00 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
active_tool = tool_manager_get_active (display->image->gimp);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2006-06-18 19:58:49 +00:00
|
|
|
if (active_tool && active_tool->focus_display == display)
|
|
|
|
tool_manager_focus_display_active (display->image->gimp, NULL);
|
1998-04-13 04:32:39 +00:00
|
|
|
|
2001-10-31 21:20:09 +00:00
|
|
|
/* free the update area lists */
|
2006-03-28 17:55:52 +00:00
|
|
|
display->update_areas = gimp_area_list_free (display->update_areas);
|
2001-02-20 15:15:30 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
if (display->shell)
|
2001-09-25 17:44:03 +00:00
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
GtkWidget *shell = display->shell;
|
2004-01-02 17:36:45 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
/* set display->shell to NULL *before* destroying the shell.
|
2004-01-02 17:36:45 +00:00
|
|
|
* all callbacks in gimpdisplayshell-callbacks.c will check
|
|
|
|
* this pointer and do nothing if the shell is in destruction.
|
|
|
|
*/
|
2006-03-28 17:55:52 +00:00
|
|
|
display->shell = NULL;
|
2004-01-02 17:36:45 +00:00
|
|
|
gtk_widget_destroy (shell);
|
2001-09-25 17:44:03 +00:00
|
|
|
}
|
1998-02-14 15:30:31 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
/* unrefs the image */
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_disconnect (display);
|
2001-10-31 21:20:09 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
g_object_unref (display);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2001-11-10 23:03:22 +00:00
|
|
|
gint
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_get_ID (GimpDisplay *display)
|
2001-11-10 23:03:22 +00:00
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (display), -1);
|
2001-11-10 23:03:22 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
return display->ID;
|
2001-11-10 23:03:22 +00:00
|
|
|
}
|
|
|
|
|
2001-10-31 21:20:09 +00:00
|
|
|
GimpDisplay *
|
2001-11-10 23:03:22 +00:00
|
|
|
gimp_display_get_by_ID (Gimp *gimp,
|
|
|
|
gint ID)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2004-07-12 11:43:00 +00:00
|
|
|
GList *list;
|
2001-10-31 21:20:09 +00:00
|
|
|
|
2002-05-08 12:39:01 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
2002-05-08 17:48:24 +00:00
|
|
|
for (list = GIMP_LIST (gimp->displays)->list;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
GimpDisplay *display = list->data;
|
2001-10-31 21:20:09 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
if (display->ID == ID)
|
|
|
|
return display;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-10-31 21:20:09 +00:00
|
|
|
void
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_reconnect (GimpDisplay *display,
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2006-03-06 17:35:40 +00:00
|
|
|
GimpImage *old_image;
|
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2006-03-28 17:08:36 +00:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (image));
|
2001-09-25 17:44:03 +00:00
|
|
|
|
2003-10-12 11:20:22 +00:00
|
|
|
/* stop any active tool */
|
2006-05-21 21:12:01 +00:00
|
|
|
tool_manager_control_active (display->image->gimp, GIMP_TOOL_ACTION_HALT,
|
|
|
|
display);
|
2003-10-12 11:20:22 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_shell_disconnect (GIMP_DISPLAY_SHELL (display->shell));
|
2001-11-10 23:03:22 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
old_image = g_object_ref (display->image);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_disconnect (display);
|
|
|
|
gimp_display_connect (display, image);
|
2001-10-31 21:20:09 +00:00
|
|
|
|
2006-03-06 17:35:40 +00:00
|
|
|
g_object_unref (old_image);
|
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_shell_reconnect (GIMP_DISPLAY_SHELL (display->shell));
|
2001-10-31 21:20:09 +00:00
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-10 23:03:22 +00:00
|
|
|
void
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_update_area (GimpDisplay *display,
|
2004-07-13 16:36:29 +00:00
|
|
|
gboolean now,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
1998-10-01 16:22:28 +00:00
|
|
|
|
2004-07-13 16:36:29 +00:00
|
|
|
if (now)
|
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_paint_area (display, x, y, w, h);
|
2004-07-13 16:36:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
GimpArea *area = gimp_area_new (CLAMP (x, 0, display->image->width),
|
|
|
|
CLAMP (y, 0, display->image->height),
|
|
|
|
CLAMP (x + w, 0, display->image->width),
|
|
|
|
CLAMP (y + h, 0, display->image->height));
|
1997-11-26 19:30:17 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
display->update_areas = gimp_area_list_process (display->update_areas,
|
|
|
|
area);
|
2004-07-13 16:36:29 +00:00
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
1998-10-01 16:22:28 +00:00
|
|
|
void
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_flush (GimpDisplay *display)
|
1998-10-01 16:22:28 +00:00
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2001-09-25 17:44:03 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_flush_whenever (display, FALSE);
|
1998-10-01 16:22:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_flush_now (GimpDisplay *display)
|
1998-10-01 16:22:28 +00:00
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2001-09-25 17:44:03 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_flush_whenever (display, TRUE);
|
1998-10-01 16:22:28 +00:00
|
|
|
}
|
|
|
|
|
2001-02-20 15:15:30 +00:00
|
|
|
|
2001-11-10 23:03:22 +00:00
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_flush_whenever (GimpDisplay *display,
|
2001-11-10 23:03:22 +00:00
|
|
|
gboolean now)
|
2001-06-18 13:10:03 +00:00
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
if (display->update_areas)
|
2001-06-18 13:10:03 +00:00
|
|
|
{
|
2004-07-13 16:36:29 +00:00
|
|
|
GSList *list;
|
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
for (list = display->update_areas; list; list = g_slist_next (list))
|
2003-07-29 16:36:56 +00:00
|
|
|
{
|
2004-07-13 16:36:29 +00:00
|
|
|
GimpArea *area = list->data;
|
2003-07-29 16:36:56 +00:00
|
|
|
|
2004-07-13 16:36:29 +00:00
|
|
|
if ((area->x1 != area->x2) && (area->y1 != area->y2))
|
2003-07-29 16:36:56 +00:00
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_paint_area (display,
|
2004-07-13 16:36:29 +00:00
|
|
|
area->x1,
|
|
|
|
area->y1,
|
|
|
|
(area->x2 - area->x1),
|
|
|
|
(area->y2 - area->y1));
|
2003-07-29 16:36:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
display->update_areas = gimp_area_list_free (display->update_areas);
|
2001-06-18 13:10:03 +00:00
|
|
|
}
|
2001-11-10 23:03:22 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_shell_flush (GIMP_DISPLAY_SHELL (display->shell), now);
|
2001-11-10 23:03:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_display_paint_area (GimpDisplay *display,
|
2001-11-10 23:03:22 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
|
|
|
{
|
2006-03-28 17:55:52 +00:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
2001-11-10 23:03:22 +00:00
|
|
|
gint x1, y1, x2, y2;
|
2003-11-20 18:08:01 +00:00
|
|
|
gdouble x1_f, y1_f, x2_f, y2_f;
|
2001-11-10 23:03:22 +00:00
|
|
|
|
|
|
|
/* Bounds check */
|
2006-03-28 17:55:52 +00:00
|
|
|
x1 = CLAMP (x, 0, display->image->width);
|
|
|
|
y1 = CLAMP (y, 0, display->image->height);
|
|
|
|
x2 = CLAMP (x + w, 0, display->image->width);
|
|
|
|
y2 = CLAMP (y + h, 0, display->image->height);
|
2001-11-10 23:03:22 +00:00
|
|
|
x = x1;
|
|
|
|
y = y1;
|
|
|
|
w = (x2 - x1);
|
|
|
|
h = (y2 - y1);
|
|
|
|
|
|
|
|
/* display the area */
|
2003-11-20 18:08:01 +00: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-10 23:03:22 +00:00
|
|
|
|
2003-11-20 18:08:01 +00: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 13:10:03 +00:00
|
|
|
}
|