2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* 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>
|
|
|
|
|
2007-03-09 21:00:01 +08:00
|
|
|
#include "libgimpmath/gimpmath.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"
|
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
#include "config/gimpdisplayconfig.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"
|
2008-03-26 00:33:37 +08:00
|
|
|
#include "gimpdisplayshell-icon.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,
|
2008-03-19 05:22:21 +08:00
|
|
|
PROP_GIMP,
|
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
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
static void gimp_display_progress_iface_init (GimpProgressInterface *iface);
|
2004-08-11 18:29:56 +08:00
|
|
|
|
2006-10-09 16:17:22 +08: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-11 02:47:21 +08:00
|
|
|
|
|
|
|
static GimpProgress *
|
2006-10-09 16:17:22 +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);
|
|
|
|
static void gimp_display_progress_pulse (GimpProgress *progress);
|
|
|
|
static guint32 gimp_display_progress_get_window (GimpProgress *progress);
|
|
|
|
static gboolean gimp_display_progress_message (GimpProgress *progress,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpMessageSeverity severity,
|
|
|
|
const gchar *domain,
|
|
|
|
const gchar *message);
|
|
|
|
static void gimp_display_progress_canceled (GimpProgress *progress,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
|
|
static void gimp_display_flush_whenever (GimpDisplay *display,
|
|
|
|
gboolean now);
|
|
|
|
static void gimp_display_paint_area (GimpDisplay *display,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
2001-09-26 01:44:03 +08:00
|
|
|
|
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpDisplay, gimp_display, GIMP_TYPE_OBJECT,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
|
2006-05-15 17:46:31 +08:00
|
|
|
gimp_display_progress_iface_init))
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
#define parent_class gimp_display_parent_class
|
2001-09-26 01:44:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
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,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
2004-07-12 19:43:00 +08:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_GIMP,
|
|
|
|
g_param_spec_object ("gimp",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_GIMP,
|
|
|
|
GIMP_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,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_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,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READABLE));
|
2001-09-26 01:44:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_init (GimpDisplay *display)
|
2001-09-26 01:44:03 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
display->ID = 0;
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
display->gimp = NULL;
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
display->image = NULL;
|
|
|
|
display->instance = 0;
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
display->shell = NULL;
|
1998-06-15 10:25:27 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
display->update_areas = NULL;
|
2001-09-26 01:44:03 +08:00
|
|
|
}
|
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
static void
|
2005-12-11 03:24:36 +08:00
|
|
|
gimp_display_progress_iface_init (GimpProgressInterface *iface)
|
2004-08-11 02:47:21 +08:00
|
|
|
{
|
2005-12-11 03:24:36 +08: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;
|
2006-10-09 16:17:22 +08:00
|
|
|
iface->message = gimp_display_progress_message;
|
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)
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (object);
|
2004-07-12 19:43:00 +08:00
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
switch (property_id)
|
|
|
|
{
|
2004-07-12 19:43:00 +08:00
|
|
|
case PROP_ID:
|
2006-03-29 01:55:52 +08:00
|
|
|
display->ID = g_value_get_int (value);
|
2004-07-12 19:43:00 +08:00
|
|
|
break;
|
2008-03-19 05:22:21 +08:00
|
|
|
|
|
|
|
case PROP_GIMP:
|
|
|
|
display->gimp = g_value_get_object (value); /* don't ref the gimp */
|
|
|
|
display->config = GIMP_DISPLAY_CONFIG (display->gimp->config);
|
|
|
|
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;
|
2008-03-19 05:22:21 +08:00
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
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-29 01:55:52 +08:00
|
|
|
GimpDisplay *display = 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:
|
2006-03-29 01:55:52 +08:00
|
|
|
g_value_set_int (value, display->ID);
|
2004-07-12 19:43:00 +08:00
|
|
|
break;
|
2008-03-19 05:22:21 +08:00
|
|
|
|
|
|
|
case PROP_GIMP:
|
|
|
|
g_value_set_object (value, display->gimp);
|
|
|
|
break;
|
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
case PROP_IMAGE:
|
2006-03-29 01:55:52 +08:00
|
|
|
g_value_set_object (value, display->image);
|
2002-05-10 21:09:19 +08:00
|
|
|
break;
|
2008-03-19 05:22:21 +08:00
|
|
|
|
2005-05-12 04:41:51 +08:00
|
|
|
case PROP_SHELL:
|
2006-03-29 01:55:52 +08:00
|
|
|
g_value_set_object (value, display->shell);
|
2005-05-12 04:41:51 +08:00
|
|
|
break;
|
2008-03-19 05:22:21 +08:00
|
|
|
|
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)
|
|
|
|
{
|
2006-06-29 17:42:05 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2004-09-01 23:26:48 +08:00
|
|
|
|
2006-10-09 16:17:22 +08:00
|
|
|
if (display->shell)
|
|
|
|
return gimp_progress_start (GIMP_PROGRESS (display->shell),
|
|
|
|
message, cancelable);
|
2004-09-01 23:26:48 +08:00
|
|
|
|
2006-10-09 16:17:22 +08:00
|
|
|
return NULL;
|
2004-08-11 02:47:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_progress_end (GimpProgress *progress)
|
|
|
|
{
|
2006-06-29 17:42:05 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2004-08-11 02:47:21 +08:00
|
|
|
|
2006-06-29 17:42:05 +08:00
|
|
|
if (display->shell)
|
|
|
|
gimp_progress_end (GIMP_PROGRESS (display->shell));
|
2004-08-11 02:47:21 +08:00
|
|
|
}
|
|
|
|
|
2004-08-11 18:29:56 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_display_progress_is_active (GimpProgress *progress)
|
|
|
|
{
|
2006-06-29 17:42:05 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2004-09-01 23:26:48 +08:00
|
|
|
|
2006-10-09 16:17:22 +08:00
|
|
|
if (display->shell)
|
|
|
|
return gimp_progress_is_active (GIMP_PROGRESS (display->shell));
|
2004-09-01 23:26:48 +08:00
|
|
|
|
2006-10-09 16:17:22 +08:00
|
|
|
return FALSE;
|
2004-08-11 18:29:56 +08:00
|
|
|
}
|
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
static void
|
|
|
|
gimp_display_progress_set_text (GimpProgress *progress,
|
|
|
|
const gchar *message)
|
|
|
|
{
|
2006-06-29 17:42:05 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2004-08-11 02:47:21 +08:00
|
|
|
|
2006-06-29 17:42:05 +08:00
|
|
|
if (display->shell)
|
|
|
|
gimp_progress_set_text (GIMP_PROGRESS (display->shell), message);
|
2004-08-11 02:47:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_progress_set_value (GimpProgress *progress,
|
|
|
|
gdouble percentage)
|
|
|
|
{
|
2006-06-29 17:42:05 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2004-08-11 02:47:21 +08:00
|
|
|
|
2006-06-29 17:42:05 +08:00
|
|
|
if (display->shell)
|
|
|
|
gimp_progress_set_value (GIMP_PROGRESS (display->shell), percentage);
|
2004-08-11 02:47:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gdouble
|
|
|
|
gimp_display_progress_get_value (GimpProgress *progress)
|
|
|
|
{
|
2006-06-29 17:42:05 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2004-09-01 23:26:48 +08:00
|
|
|
|
2006-10-09 16:17:22 +08:00
|
|
|
if (display->shell)
|
|
|
|
return gimp_progress_get_value (GIMP_PROGRESS (display->shell));
|
2004-09-01 23:26:48 +08:00
|
|
|
|
2006-10-09 16:17:22 +08:00
|
|
|
return 0.0;
|
2004-08-11 02:47:21 +08:00
|
|
|
}
|
|
|
|
|
2005-02-12 22:18:12 +08:00
|
|
|
static void
|
|
|
|
gimp_display_progress_pulse (GimpProgress *progress)
|
|
|
|
{
|
2006-06-29 17:42:05 +08:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
2005-02-12 22:18:12 +08:00
|
|
|
|
2006-06-29 17:42:05 +08:00
|
|
|
if (display->shell)
|
|
|
|
gimp_progress_pulse (GIMP_PROGRESS (display->shell));
|
2005-02-12 22:18:12 +08:00
|
|
|
}
|
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
static guint32
|
|
|
|
gimp_display_progress_get_window (GimpProgress *progress)
|
|
|
|
{
|
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
|
2006-10-09 16:17:22 +08:00
|
|
|
if (display->shell)
|
|
|
|
return gimp_progress_get_window (GIMP_PROGRESS (display->shell));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_display_progress_message (GimpProgress *progress,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpMessageSeverity severity,
|
|
|
|
const gchar *domain,
|
|
|
|
const gchar *message)
|
|
|
|
{
|
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
|
|
|
|
if (display->shell)
|
|
|
|
return gimp_progress_message (GIMP_PROGRESS (display->shell), gimp,
|
|
|
|
severity, domain, message);
|
2005-09-10 02:07:31 +08:00
|
|
|
|
2006-10-09 16:17:22 +08:00
|
|
|
return FALSE;
|
2005-09-10 02:07:31 +08:00
|
|
|
}
|
|
|
|
|
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 *
|
2008-03-23 21:40:39 +08:00
|
|
|
gimp_display_new (Gimp *gimp,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpUnit unit,
|
|
|
|
gdouble scale,
|
|
|
|
GimpMenuFactory *menu_factory,
|
|
|
|
GimpUIManager *popup_manager,
|
|
|
|
GimpDialogFactory *display_factory)
|
2001-09-26 01:44:03 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display;
|
2006-05-10 03:15:49 +08:00
|
|
|
gint ID;
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
g_return_val_if_fail (image == NULL || GIMP_IS_IMAGE (image), NULL);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2006-12-12 04:57:44 +08:00
|
|
|
/* If there isn't an interface, never create a display */
|
2008-03-19 05:22:21 +08:00
|
|
|
if (gimp->no_interface)
|
2001-09-26 01:44:03 +08:00
|
|
|
return NULL;
|
|
|
|
|
2006-05-10 03:15:49 +08:00
|
|
|
do
|
|
|
|
{
|
2008-03-19 05:22:21 +08:00
|
|
|
ID = gimp->next_display_ID++;
|
2006-05-10 03:15:49 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
if (gimp->next_display_ID == G_MAXINT)
|
|
|
|
gimp->next_display_ID = 1;
|
2006-05-10 03:15:49 +08:00
|
|
|
}
|
2008-03-19 05:22:21 +08:00
|
|
|
while (gimp_display_get_by_ID (gimp, ID));
|
2006-05-10 03:15:49 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
display = g_object_new (GIMP_TYPE_DISPLAY,
|
2008-03-19 05:22:21 +08:00
|
|
|
"id", ID,
|
|
|
|
"gimp", gimp,
|
2006-03-29 01:55:52 +08:00
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-08 20:39:01 +08:00
|
|
|
/* refs the image */
|
2008-03-19 05:22:21 +08:00
|
|
|
if (image)
|
|
|
|
gimp_display_connect (display, image);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* create the shell for the image */
|
2006-03-29 01:55:52 +08:00
|
|
|
display->shell = gimp_display_shell_new (display, unit, scale,
|
2008-03-23 21:40:39 +08:00
|
|
|
menu_factory, popup_manager,
|
|
|
|
display_factory);
|
2006-03-29 01:55:52 +08:00
|
|
|
gtk_widget_show (display->shell);
|
2001-11-10 00:54:56 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
g_signal_connect (GIMP_DISPLAY_SHELL (display->shell)->statusbar, "cancel",
|
2004-08-11 02:47:21 +08:00
|
|
|
G_CALLBACK (gimp_display_progress_canceled),
|
2006-03-29 01:55:52 +08:00
|
|
|
display);
|
2004-08-11 02:47:21 +08:00
|
|
|
|
2006-05-10 03:15:49 +08:00
|
|
|
/* add the display to the list */
|
2008-03-19 05:22:21 +08:00
|
|
|
gimp_container_add (gimp->displays, GIMP_OBJECT (display));
|
2006-05-10 03:15:49 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
return display;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2008-04-06 04:32:24 +08:00
|
|
|
/**
|
|
|
|
* gimp_display_delete:
|
|
|
|
* @display:
|
|
|
|
*
|
|
|
|
* Closes the display and removes it from the display list. You should
|
|
|
|
* not call this function directly, use gimp_display_close() instead.
|
|
|
|
*/
|
2001-11-01 05:20:09 +08:00
|
|
|
void
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_delete (GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-08 01:36:00 +08:00
|
|
|
GimpTool *active_tool;
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* remove the display from the list */
|
2008-04-06 04:32:24 +08:00
|
|
|
gimp_container_remove (display->gimp->displays, GIMP_OBJECT (display));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
/* unrefs the image */
|
|
|
|
gimp_display_set_image (display, NULL);
|
2001-07-08 01:36:00 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
active_tool = tool_manager_get_active (display->gimp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-06-19 03:58:49 +08:00
|
|
|
if (active_tool && active_tool->focus_display == display)
|
2008-03-19 05:22:21 +08:00
|
|
|
tool_manager_focus_display_active (display->gimp, NULL);
|
1998-04-13 12:32:39 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* free the update area lists */
|
2007-05-23 02:52:11 +08:00
|
|
|
gimp_area_list_free (display->update_areas);
|
|
|
|
display->update_areas = NULL;
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
if (display->shell)
|
2001-09-26 01:44:03 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
GtkWidget *shell = display->shell;
|
2004-01-03 01:36:45 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
/* set display->shell to NULL *before* destroying the shell.
|
2004-01-03 01:36:45 +08:00
|
|
|
* all callbacks in gimpdisplayshell-callbacks.c will check
|
|
|
|
* this pointer and do nothing if the shell is in destruction.
|
|
|
|
*/
|
2006-03-29 01:55:52 +08:00
|
|
|
display->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
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
g_object_unref (display);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2008-04-06 04:32:24 +08:00
|
|
|
/**
|
|
|
|
* gimp_display_close:
|
|
|
|
* @display:
|
|
|
|
*
|
|
|
|
* Closes the display. If this is the last display, it will remain
|
|
|
|
* open, but without an image.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gimp_display_close (GimpDisplay *display)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
|
|
|
|
|
|
|
if (gimp_container_num_children (display->gimp->displays) > 1)
|
|
|
|
{
|
|
|
|
gimp_display_delete (display);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_display_empty (display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
gint
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_get_ID (GimpDisplay *display)
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (display), -1);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
return display->ID;
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display = list->data;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
if (display->ID == ID)
|
|
|
|
return display;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
void
|
2008-03-19 05:22:21 +08:00
|
|
|
gimp_display_set_image (GimpDisplay *display,
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-03-19 05:22:21 +08:00
|
|
|
GimpImage *old_image = NULL;
|
2006-03-07 01:35:40 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2008-03-19 05:22:21 +08:00
|
|
|
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
if (display->image)
|
|
|
|
{
|
|
|
|
/* stop any active tool */
|
|
|
|
tool_manager_control_active (display->gimp, GIMP_TOOL_ACTION_HALT,
|
|
|
|
display);
|
2003-10-12 19:20:22 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
gimp_display_shell_disconnect (GIMP_DISPLAY_SHELL (display->shell));
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
old_image = g_object_ref (display->image);
|
|
|
|
|
|
|
|
gimp_display_disconnect (display);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
if (image)
|
|
|
|
gimp_display_connect (display, image);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
if (old_image)
|
|
|
|
g_object_unref (old_image);
|
2006-03-07 01:35:40 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
if (image)
|
|
|
|
gimp_display_shell_reconnect (GIMP_DISPLAY_SHELL (display->shell));
|
2008-03-19 17:11:04 +08:00
|
|
|
else
|
2008-03-26 00:33:37 +08:00
|
|
|
gimp_display_shell_icon_update (GIMP_DISPLAY_SHELL (display->shell));
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2008-03-20 00:15:50 +08:00
|
|
|
void
|
|
|
|
gimp_display_empty (GimpDisplay *display)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (display->image));
|
|
|
|
|
|
|
|
gimp_display_set_image (display, NULL);
|
|
|
|
|
|
|
|
gimp_display_shell_empty (GIMP_DISPLAY_SHELL (display->shell));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_display_fill (GimpDisplay *display,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpUnit unit,
|
|
|
|
gdouble scale)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (image));
|
|
|
|
|
|
|
|
gimp_display_set_image (display, image);
|
|
|
|
|
|
|
|
gimp_display_shell_fill (GIMP_DISPLAY_SHELL (display->shell),
|
|
|
|
image, unit, scale);
|
|
|
|
}
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
void
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_update_area (GimpDisplay *display,
|
2004-07-14 00:36:29 +08:00
|
|
|
gboolean now,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
1998-10-02 00:22:28 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
if (now)
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_paint_area (display, x, y, w, h);
|
2004-07-14 00:36:29 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-26 00:21:40 +08:00
|
|
|
GimpArea *area;
|
|
|
|
gint image_width = gimp_image_get_width (display->image);
|
|
|
|
gint image_height = gimp_image_get_height (display->image);
|
|
|
|
|
|
|
|
area = gimp_area_new (CLAMP (x, 0, image_width),
|
|
|
|
CLAMP (y, 0, image_height),
|
|
|
|
CLAMP (x + w, 0, image_width),
|
|
|
|
CLAMP (y + h, 0, image_height));
|
1997-11-27 03:30:17 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
display->update_areas = gimp_area_list_process (display->update_areas,
|
|
|
|
area);
|
2004-07-14 00:36:29 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
void
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_flush (GimpDisplay *display)
|
1998-10-02 00:22:28 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_flush_whenever (display, FALSE);
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_flush_now (GimpDisplay *display)
|
1998-10-02 00:22:28 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_flush_whenever (display, 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
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_flush_whenever (GimpDisplay *display,
|
2001-11-11 07:03:22 +08:00
|
|
|
gboolean now)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
if (display->update_areas)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
GSList *list;
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
for (list = display->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
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_paint_area (display,
|
2004-07-14 00:36:29 +08:00
|
|
|
area->x1,
|
|
|
|
area->y1,
|
|
|
|
(area->x2 - area->x1),
|
|
|
|
(area->y2 - area->y1));
|
2003-07-30 00:36:56 +08:00
|
|
|
}
|
|
|
|
}
|
2007-08-14 03:36:18 +08:00
|
|
|
|
2007-05-23 02:52:11 +08:00
|
|
|
gimp_area_list_free (display->update_areas);
|
|
|
|
display->update_areas = NULL;
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_shell_flush (GIMP_DISPLAY_SHELL (display->shell), now);
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_paint_area (GimpDisplay *display,
|
2001-11-11 07:03:22 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
|
|
|
{
|
2007-12-26 00:21:40 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
|
|
|
gint image_width = gimp_image_get_width (display->image);
|
|
|
|
gint image_height = gimp_image_get_height (display->image);
|
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 */
|
2007-12-26 00:21:40 +08:00
|
|
|
x1 = CLAMP (x, 0, image_width);
|
|
|
|
y1 = CLAMP (y, 0, image_height);
|
|
|
|
x2 = CLAMP (x + w, 0, image_width);
|
|
|
|
y2 = CLAMP (y + h, 0, image_height);
|
2007-08-14 03:36:18 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
x = x1;
|
|
|
|
y = y1;
|
|
|
|
w = (x2 - x1);
|
|
|
|
h = (y2 - y1);
|
|
|
|
|
|
|
|
/* display the area */
|
2007-08-14 03:36:18 +08:00
|
|
|
gimp_display_shell_transform_xy_f (shell, x, y, &x1_f, &y1_f, FALSE);
|
2003-11-21 02:08:01 +08:00
|
|
|
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
|
2007-09-24 02:21:08 +08:00
|
|
|
*
|
|
|
|
* also acommodate for spill introduced by potential box filtering.
|
|
|
|
* (bug #474509). --simon
|
2003-11-21 02:08:01 +08:00
|
|
|
*/
|
2007-09-24 02:21:08 +08:00
|
|
|
x1 = floor (x1_f - 0.5);
|
|
|
|
y1 = floor (y1_f - 0.5);
|
|
|
|
x2 = ceil (x2_f + 0.5);
|
|
|
|
y2 = ceil (y2_f + 0.5);
|
2003-11-21 02:08:01 +08:00
|
|
|
|
|
|
|
gimp_display_shell_expose_area (shell, x1, y1, x2 - x1, y2 - y1);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|