2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 14:05:25 -08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 14:05:25 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 14:05:25 -08:00
|
|
|
* (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
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 14:05:25 -08:00
|
|
|
*/
|
2000-12-16 13: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-01 13:30:56 -07:00
|
|
|
#include "config.h"
|
2001-10-29 03:47:11 -08:00
|
|
|
|
2008-10-09 13:24:04 -07:00
|
|
|
#include <gegl.h>
|
2000-12-16 13:37:03 -08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
2007-03-09 05:00:01 -08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
|
2001-09-25 16:23:09 -07:00
|
|
|
#include "display-types.h"
|
2002-05-03 05:45:22 -07:00
|
|
|
#include "tools/tools-types.h"
|
|
|
|
|
|
2009-10-02 12:15:07 -07:00
|
|
|
#include "config/gimpguiconfig.h"
|
2008-03-18 14:22:21 -07:00
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
#include "core/gimp.h"
|
2008-11-02 13:34:14 -08:00
|
|
|
#include "core/gimpcontainer.h"
|
2009-10-02 12:50:02 -07:00
|
|
|
#include "core/gimpcontext.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
#include "core/gimpimage.h"
|
2004-08-10 11:47:21 -07:00
|
|
|
#include "core/gimpprogress.h"
|
2003-01-10 09:55:53 -08:00
|
|
|
|
2013-02-27 14:26:49 -08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
|
|
|
|
|
2003-04-15 07:20:19 -07:00
|
|
|
#include "tools/gimptool.h"
|
2001-02-27 18:53:27 -08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
|
2001-09-25 16:23:09 -07:00
|
|
|
#include "gimpdisplay.h"
|
2001-10-31 13:20:09 -08:00
|
|
|
#include "gimpdisplay-handlers.h"
|
2001-09-25 16:23:09 -07:00
|
|
|
#include "gimpdisplayshell.h"
|
2009-10-02 14:55:26 -07:00
|
|
|
#include "gimpdisplayshell-expose.h"
|
2001-11-10 15:03:22 -08:00
|
|
|
#include "gimpdisplayshell-handlers.h"
|
2008-03-25 09:33:37 -07:00
|
|
|
#include "gimpdisplayshell-icon.h"
|
2003-01-03 10:01:30 -08:00
|
|
|
#include "gimpdisplayshell-transform.h"
|
2009-09-29 11:56:14 -07:00
|
|
|
#include "gimpimagewindow.h"
|
2001-04-17 14:43:29 -07:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
2000-04-27 10:27:28 -07:00
|
|
|
|
2001-07-31 04:33:13 -07:00
|
|
|
|
2018-04-08 06:16:53 -07:00
|
|
|
#define FLUSH_NOW_INTERVAL 20000 /* 20 ms in microseconds */
|
|
|
|
|
|
|
|
|
|
#define PAINT_AREA_CHUNK_WIDTH 32
|
|
|
|
|
#define PAINT_AREA_CHUNK_HEIGHT 32
|
2010-10-11 13:49:10 -07:00
|
|
|
|
|
|
|
|
|
2002-05-10 06:09:19 -07:00
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
2004-07-12 04:43:00 -07:00
|
|
|
PROP_ID,
|
2008-03-18 14:22:21 -07:00
|
|
|
PROP_GIMP,
|
2005-05-11 13:41:51 -07:00
|
|
|
PROP_IMAGE,
|
|
|
|
|
PROP_SHELL
|
2002-05-10 06:09:19 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
typedef struct _GimpDisplayPrivate GimpDisplayPrivate;
|
|
|
|
|
|
|
|
|
|
struct _GimpDisplayPrivate
|
|
|
|
|
{
|
2014-05-30 16:22:54 -07:00
|
|
|
gint ID; /* unique identifier for this display */
|
2010-02-28 07:14:54 -08:00
|
|
|
|
2014-05-30 16:22:54 -07:00
|
|
|
GimpImage *image; /* pointer to the associated image */
|
|
|
|
|
gint instance; /* the instance # of this display as
|
|
|
|
|
* taken from the image at creation */
|
2010-02-28 07:14:54 -08:00
|
|
|
|
2014-05-30 16:22:54 -07:00
|
|
|
GtkWidget *shell;
|
|
|
|
|
cairo_region_t *update_region;
|
2010-10-11 13:49:10 -07:00
|
|
|
|
2014-05-30 16:22:54 -07:00
|
|
|
guint64 last_flush_now;
|
2009-10-05 11:06:13 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define GIMP_DISPLAY_GET_PRIVATE(display) \
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-18 09:09:39 -07:00
|
|
|
((GimpDisplayPrivate *) gimp_display_get_instance_private ((GimpDisplay *) (display)))
|
2009-10-05 11:06:13 -07:00
|
|
|
|
|
|
|
|
|
2001-10-31 13:20:09 -08:00
|
|
|
/* local function prototypes */
|
2001-07-31 04:33:13 -07:00
|
|
|
|
2011-02-06 03:07:55 -08:00
|
|
|
static void gimp_display_progress_iface_init (GimpProgressInterface *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);
|
|
|
|
|
|
|
|
|
|
static GimpProgress * gimp_display_progress_start (GimpProgress *progress,
|
2014-07-12 14:45:20 -07:00
|
|
|
gboolean cancellable,
|
|
|
|
|
const gchar *message);
|
2011-02-06 03:07:55 -08:00
|
|
|
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_id (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-25 10:44:03 -07:00
|
|
|
|
|
|
|
|
|
2005-12-10 11:24:36 -08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpDisplay, gimp_display, GIMP_TYPE_OBJECT,
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-18 09:09:39 -07:00
|
|
|
G_ADD_PRIVATE (GimpDisplay)
|
2005-12-10 11:24:36 -08:00
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
|
2006-05-15 02:46:31 -07:00
|
|
|
gimp_display_progress_iface_init))
|
2001-09-25 10:44:03 -07:00
|
|
|
|
2005-12-10 11:24:36 -08:00
|
|
|
#define parent_class gimp_display_parent_class
|
2001-09-25 10:44:03 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_display_class_init (GimpDisplayClass *klass)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2004-06-01 15:04:20 -07:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2002-05-10 06:09:19 -07:00
|
|
|
object_class->set_property = gimp_display_set_property;
|
|
|
|
|
object_class->get_property = gimp_display_get_property;
|
|
|
|
|
|
2004-07-12 04:43:00 -07:00
|
|
|
g_object_class_install_property (object_class, PROP_ID,
|
|
|
|
|
g_param_spec_int ("id",
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
0, G_MAXINT, 0,
|
2009-10-04 12:58:12 -07:00
|
|
|
GIMP_PARAM_READABLE));
|
2004-07-12 04:43:00 -07:00
|
|
|
|
2008-03-18 14:22:21 -07: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 06:09:19 -07:00
|
|
|
g_object_class_install_property (object_class, PROP_IMAGE,
|
2004-07-12 04:43:00 -07:00
|
|
|
g_param_spec_object ("image",
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
GIMP_TYPE_IMAGE,
|
2006-01-18 12:29:40 -08:00
|
|
|
GIMP_PARAM_READABLE));
|
2005-05-11 13:41:51 -07:00
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_SHELL,
|
|
|
|
|
g_param_spec_object ("shell",
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
GIMP_TYPE_DISPLAY_SHELL,
|
2006-01-18 12:29:40 -08:00
|
|
|
GIMP_PARAM_READABLE));
|
2001-09-25 10:44:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_display_init (GimpDisplay *display)
|
2001-09-25 10:44:03 -07:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-10 11:47:21 -07:00
|
|
|
static void
|
2005-12-10 11:24:36 -08:00
|
|
|
gimp_display_progress_iface_init (GimpProgressInterface *iface)
|
2004-08-10 11:47:21 -07:00
|
|
|
{
|
2011-02-06 03:07:55 -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_id = gimp_display_progress_get_window_id;
|
|
|
|
|
iface->message = gimp_display_progress_message;
|
2004-08-10 11:47:21 -07:00
|
|
|
}
|
|
|
|
|
|
2002-05-10 06:09:19 -07:00
|
|
|
static void
|
|
|
|
|
gimp_display_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2009-10-05 11:10:00 -07:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (object);
|
|
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
2004-07-12 04:43:00 -07:00
|
|
|
|
2002-05-10 06:09:19 -07:00
|
|
|
switch (property_id)
|
|
|
|
|
{
|
2008-03-18 14:22:21 -07:00
|
|
|
case PROP_GIMP:
|
2009-10-04 12:58:12 -07:00
|
|
|
{
|
|
|
|
|
gint ID;
|
|
|
|
|
|
|
|
|
|
display->gimp = g_value_get_object (value); /* don't ref the gimp */
|
|
|
|
|
display->config = GIMP_DISPLAY_CONFIG (display->gimp->config);
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
ID = display->gimp->next_display_ID++;
|
|
|
|
|
|
|
|
|
|
if (display->gimp->next_display_ID == G_MAXINT)
|
|
|
|
|
display->gimp->next_display_ID = 1;
|
|
|
|
|
}
|
|
|
|
|
while (gimp_display_get_by_ID (display->gimp, ID));
|
|
|
|
|
|
2009-10-05 11:10:00 -07:00
|
|
|
private->ID = ID;
|
2009-10-04 12:58:12 -07:00
|
|
|
}
|
2008-03-18 14:22:21 -07:00
|
|
|
break;
|
|
|
|
|
|
2002-05-10 06:09:19 -07: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)
|
|
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (object);
|
|
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
2002-05-10 06:09:19 -07:00
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
2004-07-12 04:43:00 -07:00
|
|
|
case PROP_ID:
|
2009-10-05 11:10:00 -07:00
|
|
|
g_value_set_int (value, private->ID);
|
2004-07-12 04:43:00 -07:00
|
|
|
break;
|
2008-03-18 14:22:21 -07:00
|
|
|
|
|
|
|
|
case PROP_GIMP:
|
|
|
|
|
g_value_set_object (value, display->gimp);
|
|
|
|
|
break;
|
|
|
|
|
|
2002-05-10 06:09:19 -07:00
|
|
|
case PROP_IMAGE:
|
2010-02-28 07:14:54 -08:00
|
|
|
g_value_set_object (value, private->image);
|
2002-05-10 06:09:19 -07:00
|
|
|
break;
|
2008-03-18 14:22:21 -07:00
|
|
|
|
2005-05-11 13:41:51 -07:00
|
|
|
case PROP_SHELL:
|
2009-10-05 11:06:13 -07:00
|
|
|
g_value_set_object (value, private->shell);
|
2005-05-11 13:41:51 -07:00
|
|
|
break;
|
2008-03-18 14:22:21 -07:00
|
|
|
|
2002-05-10 06:09:19 -07:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-10 11:47:21 -07:00
|
|
|
static GimpProgress *
|
|
|
|
|
gimp_display_progress_start (GimpProgress *progress,
|
2014-07-12 14:45:20 -07:00
|
|
|
gboolean cancellable,
|
|
|
|
|
const gchar *message)
|
2004-08-10 11:47:21 -07:00
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
2004-09-01 08:26:48 -07:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
if (private->shell)
|
2014-07-12 14:45:20 -07:00
|
|
|
return gimp_progress_start (GIMP_PROGRESS (private->shell), cancellable,
|
|
|
|
|
"%s", message);
|
2004-09-01 08:26:48 -07:00
|
|
|
|
2006-10-09 01:17:22 -07:00
|
|
|
return NULL;
|
2004-08-10 11:47:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_display_progress_end (GimpProgress *progress)
|
|
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
2004-08-10 11:47:21 -07:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
if (private->shell)
|
|
|
|
|
gimp_progress_end (GIMP_PROGRESS (private->shell));
|
2004-08-10 11:47:21 -07:00
|
|
|
}
|
|
|
|
|
|
2004-08-11 03:29:56 -07:00
|
|
|
static gboolean
|
|
|
|
|
gimp_display_progress_is_active (GimpProgress *progress)
|
|
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
2004-09-01 08:26:48 -07:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
if (private->shell)
|
|
|
|
|
return gimp_progress_is_active (GIMP_PROGRESS (private->shell));
|
2004-09-01 08:26:48 -07:00
|
|
|
|
2006-10-09 01:17:22 -07:00
|
|
|
return FALSE;
|
2004-08-11 03:29:56 -07:00
|
|
|
}
|
|
|
|
|
|
2004-08-10 11:47:21 -07:00
|
|
|
static void
|
|
|
|
|
gimp_display_progress_set_text (GimpProgress *progress,
|
|
|
|
|
const gchar *message)
|
|
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
2004-08-10 11:47:21 -07:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
if (private->shell)
|
2014-07-20 14:32:19 -07:00
|
|
|
gimp_progress_set_text_literal (GIMP_PROGRESS (private->shell), message);
|
2004-08-10 11:47:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_display_progress_set_value (GimpProgress *progress,
|
|
|
|
|
gdouble percentage)
|
|
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
2004-08-10 11:47:21 -07:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
if (private->shell)
|
|
|
|
|
gimp_progress_set_value (GIMP_PROGRESS (private->shell), percentage);
|
2004-08-10 11:47:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gdouble
|
|
|
|
|
gimp_display_progress_get_value (GimpProgress *progress)
|
|
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
2004-09-01 08:26:48 -07:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
if (private->shell)
|
|
|
|
|
return gimp_progress_get_value (GIMP_PROGRESS (private->shell));
|
2004-09-01 08:26:48 -07:00
|
|
|
|
2006-10-09 01:17:22 -07:00
|
|
|
return 0.0;
|
2004-08-10 11:47:21 -07:00
|
|
|
}
|
|
|
|
|
|
2005-02-12 06:18:12 -08:00
|
|
|
static void
|
|
|
|
|
gimp_display_progress_pulse (GimpProgress *progress)
|
|
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
2005-02-12 06:18:12 -08:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
if (private->shell)
|
|
|
|
|
gimp_progress_pulse (GIMP_PROGRESS (private->shell));
|
2005-02-12 06:18:12 -08:00
|
|
|
}
|
|
|
|
|
|
2005-09-09 11:07:31 -07:00
|
|
|
static guint32
|
2011-02-06 03:07:55 -08:00
|
|
|
gimp_display_progress_get_window_id (GimpProgress *progress)
|
2005-09-09 11:07:31 -07:00
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
2005-09-09 11:07:31 -07:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
if (private->shell)
|
2011-02-06 03:07:55 -08:00
|
|
|
return gimp_progress_get_window_id (GIMP_PROGRESS (private->shell));
|
2006-10-09 01:17:22 -07:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gimp_display_progress_message (GimpProgress *progress,
|
|
|
|
|
Gimp *gimp,
|
|
|
|
|
GimpMessageSeverity severity,
|
|
|
|
|
const gchar *domain,
|
|
|
|
|
const gchar *message)
|
|
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplay *display = GIMP_DISPLAY (progress);
|
|
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
2006-10-09 01:17:22 -07:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
if (private->shell)
|
|
|
|
|
return gimp_progress_message (GIMP_PROGRESS (private->shell), gimp,
|
2006-10-09 01:17:22 -07:00
|
|
|
severity, domain, message);
|
2005-09-09 11:07:31 -07:00
|
|
|
|
2006-10-09 01:17:22 -07:00
|
|
|
return FALSE;
|
2005-09-09 11:07:31 -07:00
|
|
|
}
|
|
|
|
|
|
2004-08-10 11:47:21 -07:00
|
|
|
static void
|
|
|
|
|
gimp_display_progress_canceled (GimpProgress *progress,
|
|
|
|
|
GimpDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
gimp_progress_cancel (GIMP_PROGRESS (display));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
2001-09-25 10:44:03 -07:00
|
|
|
GimpDisplay *
|
2008-03-23 06:40:39 -07:00
|
|
|
gimp_display_new (Gimp *gimp,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
GimpUnit unit,
|
|
|
|
|
gdouble scale,
|
|
|
|
|
GimpUIManager *popup_manager,
|
2014-05-02 11:20:46 -07:00
|
|
|
GimpDialogFactory *dialog_factory,
|
|
|
|
|
GdkScreen *screen,
|
|
|
|
|
gint monitor)
|
2001-09-25 10:44:03 -07:00
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplay *display;
|
|
|
|
|
GimpDisplayPrivate *private;
|
|
|
|
|
GimpImageWindow *window = NULL;
|
|
|
|
|
GimpDisplayShell *shell;
|
2001-09-25 10:44:03 -07:00
|
|
|
|
2008-03-18 14:22:21 -07:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
g_return_val_if_fail (image == NULL || GIMP_IS_IMAGE (image), NULL);
|
2014-05-02 11:20:46 -07:00
|
|
|
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
2001-10-29 03:47:11 -08:00
|
|
|
|
2006-12-11 12:57:44 -08:00
|
|
|
/* If there isn't an interface, never create a display */
|
2008-03-18 14:22:21 -07:00
|
|
|
if (gimp->no_interface)
|
2001-09-25 10:44:03 -07:00
|
|
|
return NULL;
|
|
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
display = g_object_new (GIMP_TYPE_DISPLAY,
|
2008-03-18 14:22:21 -07:00
|
|
|
"gimp", gimp,
|
2006-03-28 09:55:52 -08:00
|
|
|
NULL);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
private = GIMP_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
|
2002-05-08 05:39:01 -07:00
|
|
|
/* refs the image */
|
2008-03-18 14:22:21 -07:00
|
|
|
if (image)
|
2009-10-07 10:42:08 -07:00
|
|
|
gimp_display_set_image (display, image);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2009-10-02 12:15:07 -07:00
|
|
|
/* get an image window */
|
|
|
|
|
if (GIMP_GUI_CONFIG (display->config)->single_window_mode)
|
|
|
|
|
{
|
2009-10-02 12:50:02 -07:00
|
|
|
GimpDisplay *active_display;
|
2009-10-02 12:15:07 -07:00
|
|
|
|
2009-10-02 12:50:02 -07:00
|
|
|
active_display = gimp_context_get_display (gimp_get_user_context (gimp));
|
2009-10-02 12:15:07 -07:00
|
|
|
|
2009-10-02 12:50:02 -07:00
|
|
|
if (! active_display)
|
2009-10-02 12:15:07 -07:00
|
|
|
{
|
2009-10-02 12:50:02 -07:00
|
|
|
active_display =
|
|
|
|
|
GIMP_DISPLAY (gimp_container_get_first_child (gimp->displays));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (active_display)
|
|
|
|
|
{
|
2009-10-05 10:27:04 -07:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (active_display);
|
2009-10-02 12:15:07 -07:00
|
|
|
|
|
|
|
|
window = gimp_display_shell_get_window (shell);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-09-29 11:56:14 -07:00
|
|
|
|
2009-10-02 12:15:07 -07:00
|
|
|
if (! window)
|
2009-10-03 17:01:53 -07:00
|
|
|
{
|
2009-10-25 14:02:38 -07:00
|
|
|
window = gimp_image_window_new (gimp,
|
2010-02-28 07:14:54 -08:00
|
|
|
private->image,
|
2014-05-02 11:20:46 -07:00
|
|
|
dialog_factory,
|
|
|
|
|
screen,
|
|
|
|
|
monitor);
|
2009-10-03 17:01:53 -07:00
|
|
|
}
|
2009-10-02 12:15:07 -07:00
|
|
|
|
|
|
|
|
/* create the shell for the image */
|
2009-10-05 11:06:13 -07:00
|
|
|
private->shell = gimp_display_shell_new (display, unit, scale,
|
2014-05-02 15:54:20 -07:00
|
|
|
popup_manager,
|
|
|
|
|
screen,
|
|
|
|
|
monitor);
|
2001-11-09 08:54:56 -08:00
|
|
|
|
2009-10-05 10:27:04 -07:00
|
|
|
shell = gimp_display_get_shell (display);
|
2009-09-23 09:52:42 -07:00
|
|
|
|
2009-10-04 10:30:32 -07:00
|
|
|
gimp_image_window_add_shell (window, shell);
|
|
|
|
|
gimp_display_shell_present (shell);
|
|
|
|
|
|
2013-02-27 14:26:49 -08:00
|
|
|
/* make sure the docks are visible, in case all other image windows
|
|
|
|
|
* are iconified, see bug #686544.
|
|
|
|
|
*/
|
|
|
|
|
gimp_dialog_factory_show_with_display (dialog_factory);
|
|
|
|
|
|
2009-10-04 10:30:32 -07:00
|
|
|
g_signal_connect (gimp_display_shell_get_statusbar (shell), "cancel",
|
2004-08-10 11:47:21 -07:00
|
|
|
G_CALLBACK (gimp_display_progress_canceled),
|
2006-03-28 09:55:52 -08:00
|
|
|
display);
|
2004-08-10 11:47:21 -07:00
|
|
|
|
2006-05-09 12:15:49 -07:00
|
|
|
/* add the display to the list */
|
2008-03-18 14:22:21 -07:00
|
|
|
gimp_container_add (gimp->displays, GIMP_OBJECT (display));
|
2006-05-09 12:15:49 -07:00
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
return display;
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2008-04-05 13:32:24 -07: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-10-31 13:20:09 -08:00
|
|
|
void
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_display_delete (GimpDisplay *display)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplayPrivate *private;
|
|
|
|
|
GimpTool *active_tool;
|
2001-07-07 10:36:00 -07:00
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2001-09-25 10:44:03 -07:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
private = GIMP_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
|
2001-10-31 13:20:09 -08:00
|
|
|
/* remove the display from the list */
|
2008-04-05 13:32:24 -07:00
|
|
|
gimp_container_remove (display->gimp->displays, GIMP_OBJECT (display));
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2008-03-18 14:22:21 -07:00
|
|
|
/* unrefs the image */
|
|
|
|
|
gimp_display_set_image (display, NULL);
|
2001-07-07 10:36:00 -07:00
|
|
|
|
2008-03-18 14:22:21 -07:00
|
|
|
active_tool = tool_manager_get_active (display->gimp);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2006-06-18 12:58:49 -07:00
|
|
|
if (active_tool && active_tool->focus_display == display)
|
2008-03-18 14:22:21 -07:00
|
|
|
tool_manager_focus_display_active (display->gimp, NULL);
|
1998-04-12 21:32:39 -07:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
if (private->shell)
|
2001-09-25 10:44:03 -07:00
|
|
|
{
|
2009-10-05 10:27:04 -07:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
2009-09-29 11:32:26 -07:00
|
|
|
GimpImageWindow *window = gimp_display_shell_get_window (shell);
|
2004-01-02 09:36:45 -08:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
/* set private->shell to NULL *before* destroying the shell.
|
2004-01-02 09:36:45 -08:00
|
|
|
* all callbacks in gimpdisplayshell-callbacks.c will check
|
|
|
|
|
* this pointer and do nothing if the shell is in destruction.
|
|
|
|
|
*/
|
2009-10-05 11:06:13 -07:00
|
|
|
private->shell = NULL;
|
2009-09-25 13:06:19 -07:00
|
|
|
|
2009-09-29 14:01:33 -07:00
|
|
|
if (window)
|
2009-09-25 13:06:19 -07:00
|
|
|
{
|
2009-09-29 14:01:33 -07:00
|
|
|
if (gimp_image_window_get_n_shells (window) > 1)
|
|
|
|
|
{
|
2009-10-01 10:38:52 -07:00
|
|
|
g_object_ref (shell);
|
|
|
|
|
|
2009-09-29 14:01:33 -07:00
|
|
|
gimp_image_window_remove_shell (window, shell);
|
2009-10-01 10:38:52 -07:00
|
|
|
gtk_widget_destroy (GTK_WIDGET (shell));
|
|
|
|
|
|
|
|
|
|
g_object_unref (shell);
|
2009-09-29 14:01:33 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-10-25 14:02:38 -07:00
|
|
|
gimp_image_window_destroy (window);
|
2009-09-29 14:01:33 -07:00
|
|
|
}
|
2009-09-25 13:06:19 -07:00
|
|
|
}
|
2009-09-29 14:01:33 -07:00
|
|
|
else
|
2009-09-25 13:06:19 -07:00
|
|
|
{
|
2009-09-29 14:01:33 -07:00
|
|
|
g_object_unref (shell);
|
2009-09-25 13:06:19 -07:00
|
|
|
}
|
2001-09-25 10:44:03 -07:00
|
|
|
}
|
1998-02-14 07:30:31 -08:00
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
g_object_unref (display);
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2008-04-05 13:32:24 -07: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));
|
|
|
|
|
|
2008-11-20 14:45:19 -08:00
|
|
|
if (gimp_container_get_n_children (display->gimp->displays) > 1)
|
2008-04-05 13:32:24 -07:00
|
|
|
{
|
|
|
|
|
gimp_display_delete (display);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gimp_display_empty (display);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-10 15:03:22 -08:00
|
|
|
gint
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_display_get_ID (GimpDisplay *display)
|
2001-11-10 15:03:22 -08:00
|
|
|
{
|
2009-10-05 11:10:00 -07:00
|
|
|
GimpDisplayPrivate *private;
|
|
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (display), -1);
|
2001-11-10 15:03:22 -08:00
|
|
|
|
2009-10-05 11:10:00 -07:00
|
|
|
private = GIMP_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
|
|
|
|
|
return private->ID;
|
2001-11-10 15:03:22 -08:00
|
|
|
}
|
|
|
|
|
|
2001-10-31 13:20:09 -08:00
|
|
|
GimpDisplay *
|
2001-11-10 15:03:22 -08:00
|
|
|
gimp_display_get_by_ID (Gimp *gimp,
|
|
|
|
|
gint ID)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2004-07-12 04:43:00 -07:00
|
|
|
GList *list;
|
2001-10-31 13:20:09 -08:00
|
|
|
|
2002-05-08 05:39:01 -07:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
|
2008-11-02 13:34:14 -08:00
|
|
|
for (list = gimp_get_display_iter (gimp);
|
2002-05-08 10:48:24 -07:00
|
|
|
list;
|
|
|
|
|
list = g_list_next (list))
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2006-03-28 09:55:52 -08:00
|
|
|
GimpDisplay *display = list->data;
|
2001-10-31 13:20:09 -08:00
|
|
|
|
2009-10-05 11:10:00 -07:00
|
|
|
if (gimp_display_get_ID (display) == ID)
|
2006-03-28 09:55:52 -08:00
|
|
|
return display;
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-11 08:57:27 -08:00
|
|
|
/**
|
|
|
|
|
* gimp_display_get_action_name:
|
|
|
|
|
* @display:
|
|
|
|
|
*
|
|
|
|
|
* Returns: The action name for the given display. The action name
|
|
|
|
|
* depends on the display ID. The result must be freed with g_free().
|
|
|
|
|
**/
|
|
|
|
|
gchar *
|
|
|
|
|
gimp_display_get_action_name (GimpDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL);
|
|
|
|
|
|
|
|
|
|
return g_strdup_printf ("windows-display-%04d",
|
|
|
|
|
gimp_display_get_ID (display));
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-04 10:39:22 -07:00
|
|
|
Gimp *
|
|
|
|
|
gimp_display_get_gimp (GimpDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL);
|
|
|
|
|
|
|
|
|
|
return display->gimp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GimpImage *
|
|
|
|
|
gimp_display_get_image (GimpDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL);
|
|
|
|
|
|
2010-02-28 07:14:54 -08:00
|
|
|
return GIMP_DISPLAY_GET_PRIVATE (display)->image;
|
2009-10-04 10:39:22 -07:00
|
|
|
}
|
|
|
|
|
|
2001-10-31 13:20:09 -08:00
|
|
|
void
|
2008-03-18 14:22:21 -07:00
|
|
|
gimp_display_set_image (GimpDisplay *display,
|
2006-03-28 09:08:36 -08:00
|
|
|
GimpImage *image)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2009-10-06 00:16:46 -07:00
|
|
|
GimpDisplayPrivate *private;
|
|
|
|
|
GimpImage *old_image = NULL;
|
2009-10-07 10:42:08 -07:00
|
|
|
GimpDisplayShell *shell;
|
2006-03-06 09:35:40 -08:00
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2008-03-18 14:22:21 -07:00
|
|
|
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
|
2001-09-25 10:44:03 -07:00
|
|
|
|
2009-10-06 00:16:46 -07:00
|
|
|
private = GIMP_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
|
2009-10-07 10:59:54 -07:00
|
|
|
shell = gimp_display_get_shell (display);
|
|
|
|
|
|
2010-02-28 07:14:54 -08:00
|
|
|
if (private->image)
|
2008-03-18 14:22:21 -07:00
|
|
|
{
|
|
|
|
|
/* stop any active tool */
|
|
|
|
|
tool_manager_control_active (display->gimp, GIMP_TOOL_ACTION_HALT,
|
|
|
|
|
display);
|
2003-10-12 04:20:22 -07:00
|
|
|
|
2009-10-07 10:59:54 -07:00
|
|
|
gimp_display_shell_disconnect (shell);
|
2001-11-10 15:03:22 -08:00
|
|
|
|
2008-03-18 14:22:21 -07:00
|
|
|
gimp_display_disconnect (display);
|
2009-10-07 12:13:39 -07:00
|
|
|
|
2017-07-15 09:38:01 -07:00
|
|
|
g_clear_pointer (&private->update_region, cairo_region_destroy);
|
2014-05-30 16:22:54 -07:00
|
|
|
|
2010-02-28 07:14:54 -08:00
|
|
|
gimp_image_dec_display_count (private->image);
|
2009-10-07 12:13:39 -07:00
|
|
|
|
2010-02-28 07:14:54 -08:00
|
|
|
/* set private->image before unrefing because there may be code
|
2009-10-07 12:13:39 -07:00
|
|
|
* that listens for image removals and then iterates the
|
|
|
|
|
* display list to find a valid display.
|
|
|
|
|
*/
|
2010-02-28 07:14:54 -08:00
|
|
|
old_image = private->image;
|
2009-10-07 12:13:39 -07:00
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
g_print ("%s: image->ref_count before unrefing: %d\n",
|
|
|
|
|
G_STRFUNC, G_OBJECT (old_image)->ref_count);
|
|
|
|
|
#endif
|
2008-03-18 14:22:21 -07:00
|
|
|
}
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2010-02-28 07:14:54 -08:00
|
|
|
private->image = image;
|
2009-10-07 12:13:39 -07:00
|
|
|
|
2008-03-18 14:22:21 -07:00
|
|
|
if (image)
|
2009-10-06 00:16:46 -07:00
|
|
|
{
|
2009-10-07 12:13:39 -07:00
|
|
|
#if 0
|
|
|
|
|
g_print ("%s: image->ref_count before refing: %d\n",
|
|
|
|
|
G_STRFUNC, G_OBJECT (image)->ref_count);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
g_object_ref (image);
|
|
|
|
|
|
2010-02-03 12:20:29 -08:00
|
|
|
private->instance = gimp_image_get_instance_count (image);
|
|
|
|
|
gimp_image_inc_instance_count (image);
|
2009-10-06 00:16:46 -07:00
|
|
|
|
2010-02-03 13:59:50 -08:00
|
|
|
gimp_image_inc_display_count (image);
|
2009-10-07 12:13:39 -07:00
|
|
|
|
|
|
|
|
gimp_display_connect (display);
|
2009-10-07 11:11:48 -07:00
|
|
|
|
|
|
|
|
if (shell)
|
|
|
|
|
gimp_display_shell_connect (shell);
|
2009-10-06 00:16:46 -07:00
|
|
|
}
|
2001-10-31 13:20:09 -08:00
|
|
|
|
2008-03-18 14:22:21 -07:00
|
|
|
if (old_image)
|
|
|
|
|
g_object_unref (old_image);
|
2006-03-06 09:35:40 -08:00
|
|
|
|
2009-10-07 10:42:08 -07:00
|
|
|
if (shell)
|
|
|
|
|
{
|
|
|
|
|
if (image)
|
|
|
|
|
gimp_display_shell_reconnect (shell);
|
|
|
|
|
else
|
|
|
|
|
gimp_display_shell_icon_update (shell);
|
|
|
|
|
}
|
2008-05-10 08:22:17 -07:00
|
|
|
|
2009-09-24 16:55:39 -07:00
|
|
|
if (old_image != image)
|
|
|
|
|
g_object_notify (G_OBJECT (display), "image");
|
2001-10-31 13:20:09 -08:00
|
|
|
}
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2009-10-06 00:16:46 -07:00
|
|
|
gint
|
|
|
|
|
gimp_display_get_instance (GimpDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
GimpDisplayPrivate *private;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (display), 0);
|
|
|
|
|
|
|
|
|
|
private = GIMP_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
|
|
|
|
|
return private->instance;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-04 10:39:22 -07:00
|
|
|
GimpDisplayShell *
|
|
|
|
|
gimp_display_get_shell (GimpDisplay *display)
|
|
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplayPrivate *private;
|
|
|
|
|
|
2009-10-04 10:39:22 -07:00
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL);
|
|
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
private = GIMP_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
|
|
|
|
|
return GIMP_DISPLAY_SHELL (private->shell);
|
2009-10-04 10:39:22 -07:00
|
|
|
}
|
|
|
|
|
|
2008-03-19 09:15:50 -07:00
|
|
|
void
|
|
|
|
|
gimp_display_empty (GimpDisplay *display)
|
|
|
|
|
{
|
2010-02-28 07:14:54 -08:00
|
|
|
GimpDisplayPrivate *private;
|
2019-01-08 07:00:51 -08:00
|
|
|
GList *iter;
|
2010-02-28 07:14:54 -08:00
|
|
|
|
2008-03-19 09:15:50 -07:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2010-02-28 07:14:54 -08:00
|
|
|
|
|
|
|
|
private = GIMP_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (private->image));
|
2008-03-19 09:15:50 -07:00
|
|
|
|
2019-01-08 07:00:51 -08:00
|
|
|
for (iter = display->gimp->context_list; iter; iter = g_list_next (iter))
|
|
|
|
|
{
|
|
|
|
|
GimpContext *context = iter->data;
|
|
|
|
|
|
|
|
|
|
if (gimp_context_get_display (context) == display)
|
|
|
|
|
gimp_context_set_image (context, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-19 09:15:50 -07:00
|
|
|
gimp_display_set_image (display, NULL);
|
|
|
|
|
|
2009-10-05 10:27:04 -07:00
|
|
|
gimp_display_shell_empty (gimp_display_get_shell (display));
|
2008-03-19 09:15:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gimp_display_fill (GimpDisplay *display,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
GimpUnit unit,
|
|
|
|
|
gdouble scale)
|
|
|
|
|
{
|
2010-02-28 07:14:54 -08:00
|
|
|
GimpDisplayPrivate *private;
|
|
|
|
|
|
2008-03-19 09:15:50 -07:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (image));
|
|
|
|
|
|
2010-02-28 07:14:54 -08:00
|
|
|
private = GIMP_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (private->image == NULL);
|
|
|
|
|
|
2008-03-19 09:15:50 -07:00
|
|
|
gimp_display_set_image (display, image);
|
|
|
|
|
|
2009-10-05 10:27:04 -07:00
|
|
|
gimp_display_shell_fill (gimp_display_get_shell (display),
|
2008-03-19 09:15:50 -07:00
|
|
|
image, unit, scale);
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-10 15:03:22 -08:00
|
|
|
void
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_display_update_area (GimpDisplay *display,
|
2004-07-13 09:36:29 -07:00
|
|
|
gboolean now,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint w,
|
|
|
|
|
gint h)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplayPrivate *private;
|
|
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
1998-10-01 09:22:28 -07:00
|
|
|
|
2009-10-05 11:06:13 -07:00
|
|
|
private = GIMP_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
if (now)
|
|
|
|
|
{
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_display_paint_area (display, x, y, w, h);
|
2004-07-13 09:36:29 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-05-30 16:22:54 -07:00
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
|
gint image_width;
|
|
|
|
|
gint image_height;
|
|
|
|
|
|
|
|
|
|
image_width = gimp_image_get_width (private->image);
|
|
|
|
|
image_height = gimp_image_get_height (private->image);
|
2007-12-25 08:21:40 -08:00
|
|
|
|
2014-05-30 16:22:54 -07:00
|
|
|
rect.x = CLAMP (x, 0, image_width);
|
|
|
|
|
rect.y = CLAMP (y, 0, image_height);
|
|
|
|
|
rect.width = CLAMP (x + w, 0, image_width) - rect.x;
|
|
|
|
|
rect.height = CLAMP (y + h, 0, image_height) - rect.y;
|
1997-11-26 11:30:17 -08:00
|
|
|
|
2014-05-30 16:22:54 -07:00
|
|
|
if (private->update_region)
|
|
|
|
|
cairo_region_union_rectangle (private->update_region, &rect);
|
|
|
|
|
else
|
|
|
|
|
private->update_region = cairo_region_create_rectangle (&rect);
|
2004-07-13 09:36:29 -07:00
|
|
|
}
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
1998-10-01 09:22:28 -07:00
|
|
|
void
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_display_flush (GimpDisplay *display)
|
1998-10-01 09:22:28 -07:00
|
|
|
{
|
2006-03-28 09:55:52 -08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2001-09-25 10:44:03 -07:00
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_display_flush_whenever (display, FALSE);
|
1998-10-01 09:22:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_display_flush_now (GimpDisplay *display)
|
1998-10-01 09:22:28 -07:00
|
|
|
{
|
2006-03-28 09:55:52 -08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2001-09-25 10:44:03 -07:00
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_display_flush_whenever (display, TRUE);
|
1998-10-01 09:22:28 -07:00
|
|
|
}
|
|
|
|
|
|
2001-02-20 07:15:30 -08:00
|
|
|
|
2001-11-10 15:03:22 -08:00
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_display_flush_whenever (GimpDisplay *display,
|
2001-11-10 15:03:22 -08:00
|
|
|
gboolean now)
|
2001-06-18 06:10:03 -07:00
|
|
|
{
|
2009-10-05 11:06:13 -07:00
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
|
2014-05-30 16:22:54 -07:00
|
|
|
if (private->update_region)
|
2001-06-18 06:10:03 -07:00
|
|
|
{
|
2014-05-30 16:22:54 -07:00
|
|
|
gint n_rects = cairo_region_num_rectangles (private->update_region);
|
|
|
|
|
gint i;
|
2004-07-13 09:36:29 -07:00
|
|
|
|
2014-05-30 16:22:54 -07:00
|
|
|
for (i = 0; i < n_rects; i++)
|
2003-07-29 09:36:56 -07:00
|
|
|
{
|
2014-05-30 16:22:54 -07:00
|
|
|
cairo_rectangle_int_t rect;
|
2003-07-29 09:36:56 -07:00
|
|
|
|
2014-05-30 16:22:54 -07:00
|
|
|
cairo_region_get_rectangle (private->update_region,
|
|
|
|
|
i, &rect);
|
|
|
|
|
|
|
|
|
|
gimp_display_paint_area (display,
|
|
|
|
|
rect.x,
|
|
|
|
|
rect.y,
|
|
|
|
|
rect.width,
|
|
|
|
|
rect.height);
|
2003-07-29 09:36:56 -07:00
|
|
|
}
|
2007-08-13 12:36:18 -07:00
|
|
|
|
2017-07-15 09:38:01 -07:00
|
|
|
g_clear_pointer (&private->update_region, cairo_region_destroy);
|
2001-06-18 06:10:03 -07:00
|
|
|
}
|
2001-11-10 15:03:22 -08:00
|
|
|
|
2010-10-11 13:49:10 -07:00
|
|
|
if (now)
|
|
|
|
|
{
|
2012-10-06 09:01:41 -07:00
|
|
|
guint64 now = g_get_monotonic_time ();
|
2010-10-11 14:33:33 -07:00
|
|
|
|
2012-10-06 09:01:41 -07:00
|
|
|
if ((now - private->last_flush_now) > FLUSH_NOW_INTERVAL)
|
2010-10-11 14:33:33 -07:00
|
|
|
{
|
|
|
|
|
gimp_display_shell_flush (gimp_display_get_shell (display), now);
|
|
|
|
|
|
2012-10-06 09:01:41 -07:00
|
|
|
private->last_flush_now = now;
|
2010-10-11 14:33:33 -07:00
|
|
|
}
|
2010-10-11 13:49:10 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gimp_display_shell_flush (gimp_display_get_shell (display), now);
|
|
|
|
|
}
|
2001-11-10 15:03:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_display_paint_area (GimpDisplay *display,
|
2001-11-10 15:03:22 -08:00
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint w,
|
|
|
|
|
gint h)
|
|
|
|
|
{
|
2010-02-28 07:14:54 -08:00
|
|
|
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
|
|
|
|
gint image_width = gimp_image_get_width (private->image);
|
|
|
|
|
gint image_height = gimp_image_get_height (private->image);
|
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
|
gdouble x1_f, y1_f, x2_f, y2_f;
|
2001-11-10 15:03:22 -08:00
|
|
|
|
|
|
|
|
/* Bounds check */
|
2007-12-25 08: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-13 12:36:18 -07:00
|
|
|
|
2001-11-10 15:03:22 -08:00
|
|
|
x = x1;
|
|
|
|
|
y = y1;
|
|
|
|
|
w = (x2 - x1);
|
|
|
|
|
h = (y2 - y1);
|
|
|
|
|
|
|
|
|
|
/* display the area */
|
2013-04-19 07:22:19 -07:00
|
|
|
gimp_display_shell_transform_bounds (shell,
|
|
|
|
|
x, y, x + w, y + h,
|
|
|
|
|
&x1_f, &y1_f, &x2_f, &y2_f);
|
2001-11-10 15:03:22 -08:00
|
|
|
|
2003-11-20 10: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-23 11:21:08 -07:00
|
|
|
*
|
2013-01-27 07:52:38 -08:00
|
|
|
* also accommodate for spill introduced by potential box filtering.
|
2007-09-23 11:21:08 -07:00
|
|
|
* (bug #474509). --simon
|
2003-11-20 10:08:01 -08:00
|
|
|
*/
|
2007-09-23 11:21:08 -07: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-20 10:08:01 -08:00
|
|
|
|
2018-04-08 06:16:53 -07:00
|
|
|
/* align transformed area to a coarse grid, to simplify the
|
|
|
|
|
* invalidated area
|
|
|
|
|
*/
|
|
|
|
|
x1 = floor ((gdouble) x1 / PAINT_AREA_CHUNK_WIDTH) * PAINT_AREA_CHUNK_WIDTH;
|
|
|
|
|
y1 = floor ((gdouble) y1 / PAINT_AREA_CHUNK_HEIGHT) * PAINT_AREA_CHUNK_HEIGHT;
|
|
|
|
|
x2 = ceil ((gdouble) x2 / PAINT_AREA_CHUNK_WIDTH) * PAINT_AREA_CHUNK_WIDTH;
|
|
|
|
|
y2 = ceil ((gdouble) y2 / PAINT_AREA_CHUNK_HEIGHT) * PAINT_AREA_CHUNK_HEIGHT;
|
|
|
|
|
|
2003-11-20 10:08:01 -08:00
|
|
|
gimp_display_shell_expose_area (shell, x1, y1, x2 - x1, y2 - y1);
|
2001-06-18 06:10:03 -07:00
|
|
|
}
|