1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display-types.h"
|
2003-01-13 22:08:10 +08:00
|
|
|
#include "tools/tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2002-05-11 07:30:09 +08:00
|
|
|
#ifdef __GNUC__
|
2002-05-03 20:45:22 +08:00
|
|
|
#warning FIXME #include "gui/gui-types.h"
|
2002-05-11 07:30:09 +08:00
|
|
|
#endif
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "gui/gui-types.h"
|
|
|
|
|
2003-10-22 22:46:05 +08:00
|
|
|
#include "config/gimpconfig.h"
|
2004-06-02 06:04:20 +08:00
|
|
|
#include "config/gimpconfig-params.h"
|
2003-10-22 22:46:05 +08:00
|
|
|
#include "config/gimpconfig-utils.h"
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpdisplayconfig.h"
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "core/gimp.h"
|
2001-07-03 04:57:58 +08:00
|
|
|
#include "core/gimpbuffer.h"
|
2001-11-28 03:27:55 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2003-06-24 03:34:48 +08:00
|
|
|
#include "core/gimpgrid.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2003-10-06 20:17:11 +08:00
|
|
|
#include "core/gimpimage-guides.h"
|
2003-06-24 03:34:48 +08:00
|
|
|
#include "core/gimpimage-snap.h"
|
2001-05-13 19:35:20 +08:00
|
|
|
#include "core/gimplayer.h"
|
|
|
|
#include "core/gimplayermask.h"
|
2003-09-12 06:24:30 +08:00
|
|
|
#include "core/gimplist.h"
|
2002-05-08 00:23:14 +08:00
|
|
|
#include "core/gimpmarshal.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimppattern.h"
|
|
|
|
|
2003-05-18 22:47:07 +08:00
|
|
|
#include "vectors/gimpvectors.h"
|
2003-09-12 06:24:30 +08:00
|
|
|
#include "vectors/gimpstroke.h"
|
2003-05-18 22:47:07 +08:00
|
|
|
|
2001-05-09 03:29:15 +08:00
|
|
|
#include "widgets/gimpdnd.h"
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "widgets/gimpmenufactory.h"
|
2004-04-22 00:33:17 +08:00
|
|
|
#include "widgets/gimpuimanager.h"
|
2003-05-29 19:34:30 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2001-05-09 03:29:15 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "gui/info-window.h"
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-29 01:51:06 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2003-11-10 07:24:40 +08:00
|
|
|
#include "gimpcanvas.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gimpdisplay.h"
|
2003-10-22 22:46:05 +08:00
|
|
|
#include "gimpdisplayoptions.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gimpdisplayshell.h"
|
2003-03-20 19:31:33 +08:00
|
|
|
#include "gimpdisplayshell-appearance.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "gimpdisplayshell-callbacks.h"
|
2004-07-14 08:15:57 +08:00
|
|
|
#include "gimpdisplayshell-close.h"
|
2003-01-04 02:01:30 +08:00
|
|
|
#include "gimpdisplayshell-cursor.h"
|
2001-11-09 03:14:51 +08:00
|
|
|
#include "gimpdisplayshell-dnd.h"
|
2004-02-07 08:16:52 +08:00
|
|
|
#include "gimpdisplayshell-draw.h"
|
2002-03-15 06:42:50 +08:00
|
|
|
#include "gimpdisplayshell-filter.h"
|
2001-11-11 03:10:28 +08:00
|
|
|
#include "gimpdisplayshell-handlers.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "gimpdisplayshell-render.h"
|
2003-06-04 21:06:59 +08:00
|
|
|
#include "gimpdisplayshell-scale.h"
|
2001-11-11 07:03:22 +08:00
|
|
|
#include "gimpdisplayshell-selection.h"
|
2003-01-04 02:01:30 +08:00
|
|
|
#include "gimpdisplayshell-title.h"
|
|
|
|
#include "gimpdisplayshell-transform.h"
|
2002-02-03 20:10:23 +08:00
|
|
|
#include "gimpstatusbar.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
1998-11-23 22:47:09 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_SCALE,
|
|
|
|
PROP_UNIT
|
|
|
|
};
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SCALED,
|
|
|
|
SCROLLED,
|
2002-09-28 00:17:31 +08:00
|
|
|
RECONNECT,
|
2002-05-08 00:23:14 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
|
|
|
|
/* local function prototypes */
|
2000-02-09 07:45:20 +08:00
|
|
|
|
2003-01-04 02:01:30 +08:00
|
|
|
static void gimp_display_shell_class_init (GimpDisplayShellClass *klass);
|
|
|
|
static void gimp_display_shell_init (GimpDisplayShell *shell);
|
|
|
|
|
2004-07-14 08:15:57 +08:00
|
|
|
static void gimp_display_shell_finalize (GObject *object);
|
|
|
|
static void gimp_display_shell_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_display_shell_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
static void gimp_display_shell_destroy (GtkObject *object);
|
|
|
|
static void gimp_display_shell_screen_changed (GtkWidget *widget,
|
|
|
|
GdkScreen *previous);
|
|
|
|
static gboolean gimp_display_shell_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *aevent);
|
|
|
|
|
|
|
|
static void gimp_display_shell_real_scaled (GimpDisplayShell *shell);
|
2001-10-13 20:52:30 +08:00
|
|
|
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
static guint display_shell_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2001-10-13 20:52:30 +08:00
|
|
|
static GtkWindowClass *parent_class = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-08-17 22:27:31 +08:00
|
|
|
|
2001-10-13 20:52:30 +08:00
|
|
|
GType
|
|
|
|
gimp_display_shell_get_type (void)
|
|
|
|
{
|
|
|
|
static GType shell_type = 0;
|
|
|
|
|
|
|
|
if (! shell_type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo shell_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpDisplayShellClass),
|
2004-06-23 00:31:27 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_display_shell_class_init,
|
2004-07-14 18:31:59 +08:00
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
2004-06-23 00:31:27 +08:00
|
|
|
sizeof (GimpDisplayShell),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_display_shell_init,
|
2001-10-13 20:52:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
shell_type = g_type_register_static (GTK_TYPE_WINDOW,
|
|
|
|
"GimpDisplayShell",
|
|
|
|
&shell_info, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return shell_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_class_init (GimpDisplayShellClass *klass)
|
|
|
|
{
|
2004-07-14 18:31:59 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2001-10-13 20:52:30 +08:00
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
display_shell_signals[SCALED] =
|
|
|
|
g_signal_new ("scaled",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDisplayShellClass, scaled),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
display_shell_signals[SCROLLED] =
|
|
|
|
g_signal_new ("scrolled",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDisplayShellClass, scrolled),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2002-09-28 00:17:31 +08:00
|
|
|
display_shell_signals[RECONNECT] =
|
|
|
|
g_signal_new ("reconnect",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDisplayShellClass, reconnect),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2004-07-14 18:31:59 +08:00
|
|
|
object_class->finalize = gimp_display_shell_finalize;
|
|
|
|
object_class->set_property = gimp_display_shell_set_property;
|
|
|
|
object_class->get_property = gimp_display_shell_get_property;
|
2003-10-22 22:46:05 +08:00
|
|
|
|
2004-07-14 18:31:59 +08:00
|
|
|
gtk_object_class->destroy = gimp_display_shell_destroy;
|
2001-10-13 20:52:30 +08:00
|
|
|
|
2003-10-06 04:34:48 +08:00
|
|
|
widget_class->screen_changed = gimp_display_shell_screen_changed;
|
|
|
|
widget_class->delete_event = gimp_display_shell_delete_event;
|
|
|
|
widget_class->popup_menu = gimp_display_shell_popup_menu;
|
2002-09-28 00:17:31 +08:00
|
|
|
|
2003-10-06 04:34:48 +08:00
|
|
|
klass->scaled = gimp_display_shell_real_scaled;
|
|
|
|
klass->scrolled = NULL;
|
|
|
|
klass->reconnect = NULL;
|
2004-06-02 06:04:20 +08:00
|
|
|
|
2004-07-14 18:31:59 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_SCALE,
|
2004-06-02 06:04:20 +08:00
|
|
|
g_param_spec_double ("scale", NULL, NULL,
|
|
|
|
1.0 / 256, 256, 1.0,
|
|
|
|
G_PARAM_READWRITE));
|
2004-07-14 18:31:59 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_UNIT,
|
2004-06-02 06:04:20 +08:00
|
|
|
gimp_param_spec_unit ("unit", NULL, NULL,
|
|
|
|
TRUE, FALSE,
|
|
|
|
GIMP_UNIT_PIXEL,
|
|
|
|
G_PARAM_READWRITE));
|
2001-10-13 20:52:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_init (GimpDisplayShell *shell)
|
|
|
|
{
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->gdisp = NULL;
|
2004-04-29 20:52:29 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->menubar_manager = NULL;
|
|
|
|
shell->popup_manager = NULL;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->unit = GIMP_UNIT_PIXEL;
|
2004-06-02 06:04:20 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->scale = 1.0;
|
|
|
|
shell->other_scale = 0.0;
|
|
|
|
shell->dot_for_dot = TRUE;
|
2002-06-27 06:16:59 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->offset_x = 0;
|
|
|
|
shell->offset_y = 0;
|
2001-11-02 17:31:21 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->disp_width = 0;
|
|
|
|
shell->disp_height = 0;
|
|
|
|
shell->disp_xoffset = 0;
|
|
|
|
shell->disp_yoffset = 0;
|
2001-11-02 17:31:21 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->proximity = FALSE;
|
|
|
|
shell->snap_to_guides = TRUE;
|
|
|
|
shell->snap_to_grid = FALSE;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->select = NULL;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->canvas = NULL;
|
|
|
|
shell->grid_gc = NULL;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2004-06-23 00:31:27 +08:00
|
|
|
shell->hsbdata = NULL;
|
|
|
|
shell->vsbdata = NULL;
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->hsb = NULL;
|
|
|
|
shell->vsb = NULL;
|
2004-06-23 00:31:27 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->hrule = NULL;
|
|
|
|
shell->vrule = NULL;
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2004-06-23 00:31:27 +08:00
|
|
|
shell->origin_button = NULL;
|
|
|
|
shell->qmask_button = NULL;
|
|
|
|
shell->zoom_button = NULL;
|
|
|
|
shell->nav_ebox = NULL;
|
|
|
|
|
|
|
|
shell->menubar = NULL;
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->statusbar = NULL;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->render_buf = g_malloc (GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH *
|
2001-12-01 02:23:49 +08:00
|
|
|
GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT *
|
|
|
|
3);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2004-06-23 00:31:27 +08:00
|
|
|
shell->title_idle_id = 0;
|
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->icon_size = 32;
|
|
|
|
shell->icon_idle_id = 0;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2004-06-14 18:19:39 +08:00
|
|
|
shell->cursor_format = GIMP_CURSOR_FORMAT_BITMAP;
|
|
|
|
shell->current_cursor = (GimpCursorType) -1;
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->tool_cursor = GIMP_TOOL_CURSOR_NONE;
|
|
|
|
shell->cursor_modifier = GIMP_CURSOR_MODIFIER_NONE;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2004-06-14 18:19:39 +08:00
|
|
|
shell->override_cursor = (GimpCursorType) -1;
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->using_override_cursor = FALSE;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->draw_cursor = FALSE;
|
|
|
|
shell->have_cursor = FALSE;
|
|
|
|
shell->cursor_x = 0;
|
|
|
|
shell->cursor_y = 0;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2004-07-14 18:31:59 +08:00
|
|
|
shell->close_dialog = NULL;
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->info_dialog = NULL;
|
|
|
|
shell->scale_dialog = NULL;
|
|
|
|
shell->nav_popup = NULL;
|
|
|
|
shell->grid_dialog = NULL;
|
2002-01-26 02:34:33 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->filter_stack = NULL;
|
|
|
|
shell->filter_idle_id = 0;
|
|
|
|
shell->filters_dialog = NULL;
|
2003-03-11 09:22:57 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->paused_count = 0;
|
|
|
|
|
2004-06-23 00:31:27 +08:00
|
|
|
shell->window_state = 0;
|
|
|
|
shell->zoom_on_resize = FALSE;
|
|
|
|
shell->show_transform_preview = FALSE;
|
|
|
|
|
|
|
|
shell->options = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS, NULL);
|
|
|
|
shell->fullscreen_options = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_FULLSCREEN, NULL);
|
2003-10-22 22:46:05 +08:00
|
|
|
|
2004-06-13 09:37:29 +08:00
|
|
|
shell->space_pressed = FALSE;
|
|
|
|
shell->space_release_pending = FALSE;
|
|
|
|
shell->scrolling = FALSE;
|
|
|
|
shell->scroll_start_x = 0;
|
|
|
|
shell->scroll_start_y = 0;
|
2003-10-14 19:14:28 +08:00
|
|
|
shell->button_press_before_focus = FALSE;
|
2003-09-12 06:24:30 +08:00
|
|
|
|
2003-11-08 01:29:02 +08:00
|
|
|
gtk_window_set_role (GTK_WINDOW (shell), "gimp-image-window");
|
2002-01-26 02:34:33 +08:00
|
|
|
gtk_window_set_resizable (GTK_WINDOW (shell), TRUE);
|
|
|
|
|
|
|
|
gtk_widget_set_events (GTK_WIDGET (shell), (GDK_POINTER_MOTION_MASK |
|
|
|
|
GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON_PRESS_MASK |
|
|
|
|
GDK_KEY_PRESS_MASK |
|
2003-11-21 01:13:02 +08:00
|
|
|
GDK_KEY_RELEASE_MASK |
|
|
|
|
GDK_FOCUS_CHANGE_MASK |
|
|
|
|
GDK_SCROLL_MASK));
|
2002-01-26 02:34:33 +08:00
|
|
|
|
|
|
|
/* active display callback */
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell, "button_press_event",
|
2004-06-13 02:31:49 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_events),
|
|
|
|
shell);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell, "button_release_event",
|
2004-06-13 02:31:49 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_events),
|
|
|
|
shell);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell, "key_press_event",
|
2004-06-13 02:31:49 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_events),
|
|
|
|
shell);
|
2003-03-11 09:22:57 +08:00
|
|
|
g_signal_connect (shell, "window_state_event",
|
2004-06-13 02:31:49 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_events),
|
|
|
|
shell);
|
2002-01-26 02:34:33 +08:00
|
|
|
|
|
|
|
/* dnd stuff */
|
2004-06-30 22:47:23 +08:00
|
|
|
gimp_dnd_uri_list_dest_add (GTK_WIDGET (shell),
|
|
|
|
gimp_display_shell_drop_uri_list,
|
2004-06-13 02:31:49 +08:00
|
|
|
shell);
|
2002-09-02 22:39:08 +08:00
|
|
|
gimp_dnd_viewable_dest_add (GTK_WIDGET (shell), GIMP_TYPE_LAYER,
|
2004-06-13 02:31:49 +08:00
|
|
|
gimp_display_shell_drop_drawable,
|
2002-01-26 02:34:33 +08:00
|
|
|
shell);
|
2002-09-02 22:39:08 +08:00
|
|
|
gimp_dnd_viewable_dest_add (GTK_WIDGET (shell), GIMP_TYPE_LAYER_MASK,
|
2004-06-13 02:31:49 +08:00
|
|
|
gimp_display_shell_drop_drawable,
|
2002-01-26 02:34:33 +08:00
|
|
|
shell);
|
2002-09-02 22:39:08 +08:00
|
|
|
gimp_dnd_viewable_dest_add (GTK_WIDGET (shell), GIMP_TYPE_CHANNEL,
|
2004-06-13 02:31:49 +08:00
|
|
|
gimp_display_shell_drop_drawable,
|
2002-01-26 02:34:33 +08:00
|
|
|
shell);
|
2003-05-18 22:47:07 +08:00
|
|
|
gimp_dnd_viewable_dest_add (GTK_WIDGET (shell), GIMP_TYPE_VECTORS,
|
2004-06-13 02:31:49 +08:00
|
|
|
gimp_display_shell_drop_vectors,
|
2003-05-18 22:47:07 +08:00
|
|
|
shell);
|
2002-09-02 22:39:08 +08:00
|
|
|
gimp_dnd_viewable_dest_add (GTK_WIDGET (shell), GIMP_TYPE_PATTERN,
|
2004-06-13 02:31:49 +08:00
|
|
|
gimp_display_shell_drop_pattern,
|
2002-01-26 02:34:33 +08:00
|
|
|
shell);
|
2002-09-02 22:39:08 +08:00
|
|
|
gimp_dnd_viewable_dest_add (GTK_WIDGET (shell), GIMP_TYPE_BUFFER,
|
2004-06-13 02:31:49 +08:00
|
|
|
gimp_display_shell_drop_buffer,
|
2002-01-26 02:34:33 +08:00
|
|
|
shell);
|
2002-09-02 22:39:08 +08:00
|
|
|
gimp_dnd_color_dest_add (GTK_WIDGET (shell),
|
2004-06-13 02:31:49 +08:00
|
|
|
gimp_display_shell_drop_color,
|
2004-06-02 07:14:28 +08:00
|
|
|
shell);
|
2004-06-29 21:34:16 +08:00
|
|
|
gimp_dnd_svg_dest_add (GTK_WIDGET (shell),
|
|
|
|
gimp_display_shell_drop_svg,
|
|
|
|
shell);
|
2002-01-26 02:34:33 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
gimp_help_connect (GTK_WIDGET (shell), gimp_standard_help_func,
|
2004-06-13 02:31:49 +08:00
|
|
|
GIMP_HELP_IMAGE_WINDOW, NULL);
|
2003-10-22 22:46:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
|
2002-01-26 02:34:33 +08:00
|
|
|
|
2003-10-22 22:46:05 +08:00
|
|
|
if (shell->options)
|
|
|
|
g_object_unref (shell->options);
|
|
|
|
|
|
|
|
if (shell->fullscreen_options)
|
|
|
|
g_object_unref (shell->fullscreen_options);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-10-13 20:52:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_destroy (GtkObject *object)
|
|
|
|
{
|
2003-10-22 22:46:05 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2001-11-11 03:10:28 +08:00
|
|
|
if (shell->gdisp)
|
2004-01-04 04:51:36 +08:00
|
|
|
gimp_display_shell_disconnect (shell);
|
2001-11-11 03:10:28 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
if (shell->menubar_manager)
|
|
|
|
{
|
|
|
|
g_object_unref (shell->menubar_manager);
|
|
|
|
shell->menubar_manager = NULL;
|
|
|
|
}
|
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
shell->popup_manager = NULL;
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
if (shell->select)
|
|
|
|
{
|
|
|
|
gimp_display_shell_selection_free (shell->select);
|
|
|
|
shell->select = NULL;
|
|
|
|
}
|
|
|
|
|
2003-11-22 06:52:36 +08:00
|
|
|
if (shell->filter_stack)
|
|
|
|
gimp_display_shell_filter_set (shell, NULL);
|
|
|
|
|
|
|
|
if (shell->filter_idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (shell->filter_idle_id);
|
2003-11-24 20:43:59 +08:00
|
|
|
shell->filter_idle_id = 0;
|
2003-11-22 06:52:36 +08:00
|
|
|
}
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2001-12-01 02:23:49 +08:00
|
|
|
if (shell->render_buf)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
2001-12-01 02:23:49 +08:00
|
|
|
g_free (shell->render_buf);
|
|
|
|
shell->render_buf = NULL;
|
|
|
|
}
|
|
|
|
|
2003-02-26 03:01:10 +08:00
|
|
|
if (shell->title_idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (shell->title_idle_id);
|
|
|
|
shell->title_idle_id = 0;
|
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
if (shell->info_dialog)
|
|
|
|
{
|
|
|
|
info_window_free (shell->info_dialog);
|
|
|
|
shell->info_dialog = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shell->nav_popup)
|
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
gtk_widget_destroy (shell->nav_popup);
|
2001-11-01 05:20:09 +08:00
|
|
|
shell->nav_popup = NULL;
|
|
|
|
}
|
|
|
|
|
2003-06-24 03:34:48 +08:00
|
|
|
if (shell->grid_dialog)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (shell->grid_dialog);
|
|
|
|
shell->grid_dialog = NULL;
|
|
|
|
}
|
|
|
|
|
2001-11-11 03:10:28 +08:00
|
|
|
shell->gdisp = NULL;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
2001-10-13 20:52:30 +08:00
|
|
|
}
|
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_SCALE:
|
|
|
|
gimp_display_shell_scale (shell,
|
|
|
|
GIMP_ZOOM_TO, g_value_get_double (value));
|
|
|
|
break;
|
|
|
|
case PROP_UNIT:
|
|
|
|
gimp_display_shell_set_unit (shell, g_value_get_int (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_SCALE:
|
|
|
|
g_value_set_double (value, shell->scale);
|
|
|
|
break;
|
|
|
|
case PROP_UNIT:
|
|
|
|
g_value_set_int (value, shell->unit);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-29 00:11:29 +08:00
|
|
|
static void
|
2003-10-06 04:34:48 +08:00
|
|
|
gimp_display_shell_screen_changed (GtkWidget *widget,
|
|
|
|
GdkScreen *previous)
|
2003-05-29 00:11:29 +08:00
|
|
|
{
|
2004-06-02 06:04:20 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (widget);
|
2003-05-29 00:11:29 +08:00
|
|
|
GimpDisplayConfig *config;
|
|
|
|
|
2003-11-08 23:29:47 +08:00
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->screen_changed)
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->screen_changed (widget, previous);
|
2003-05-29 00:11:29 +08:00
|
|
|
|
|
|
|
config = GIMP_DISPLAY_CONFIG (shell->gdisp->gimage->gimp->config);
|
|
|
|
|
|
|
|
if (GIMP_DISPLAY_CONFIG (config)->monitor_res_from_gdk)
|
|
|
|
{
|
2003-05-29 19:34:30 +08:00
|
|
|
gimp_get_screen_resolution (gtk_widget_get_screen (widget),
|
|
|
|
&shell->monitor_xres,
|
|
|
|
&shell->monitor_yres);
|
2003-05-29 00:11:29 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shell->monitor_xres = GIMP_DISPLAY_CONFIG (config)->monitor_xres;
|
|
|
|
shell->monitor_yres = GIMP_DISPLAY_CONFIG (config)->monitor_yres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-13 20:52:30 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_display_shell_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *aevent)
|
|
|
|
{
|
2003-11-08 23:29:47 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (widget);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_close (shell, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-03-15 11:15:35 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-02-26 03:01:10 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_real_scaled (GimpDisplayShell *shell)
|
|
|
|
{
|
2003-03-20 19:31:33 +08:00
|
|
|
GimpContext *user_context;
|
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
if (! shell->gdisp)
|
|
|
|
return;
|
|
|
|
|
2004-07-15 00:37:13 +08:00
|
|
|
gimp_display_shell_title_update (shell);
|
2003-03-13 01:18:25 +08:00
|
|
|
|
|
|
|
/* update the <Image>/View/Zoom menu */
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_ui_manager_update (shell->menubar_manager, shell);
|
2003-03-20 19:31:33 +08:00
|
|
|
|
|
|
|
user_context = gimp_get_user_context (shell->gdisp->gimage->gimp);
|
|
|
|
|
|
|
|
if (shell->gdisp == gimp_context_get_display (user_context))
|
2004-04-29 20:52:29 +08:00
|
|
|
gimp_ui_manager_update (shell->popup_manager, shell);
|
2003-02-26 03:01:10 +08:00
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
GtkWidget *
|
2003-01-11 01:55:53 +08:00
|
|
|
gimp_display_shell_new (GimpDisplay *gdisp,
|
2004-06-02 06:04:20 +08:00
|
|
|
GimpUnit unit,
|
2004-01-30 06:22:29 +08:00
|
|
|
gdouble scale,
|
2003-01-11 01:55:53 +08:00
|
|
|
GimpMenuFactory *menu_factory,
|
2004-04-29 20:52:29 +08:00
|
|
|
GimpUIManager *popup_manager)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-11-19 04:50:31 +08:00
|
|
|
GimpDisplayShell *shell;
|
2004-05-17 21:38:03 +08:00
|
|
|
GimpDisplayConfig *display_config;
|
2002-11-19 04:50:31 +08:00
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *disp_vbox;
|
|
|
|
GtkWidget *upper_hbox;
|
|
|
|
GtkWidget *right_vbox;
|
|
|
|
GtkWidget *lower_hbox;
|
|
|
|
GtkWidget *inner_table;
|
|
|
|
GtkWidget *image;
|
2003-09-09 19:35:27 +08:00
|
|
|
GdkScreen *screen;
|
2002-11-19 04:50:31 +08:00
|
|
|
gint image_width, image_height;
|
|
|
|
gint n_width, n_height;
|
|
|
|
gint s_width, s_height;
|
2004-01-30 06:22:29 +08:00
|
|
|
gdouble new_scale;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), NULL);
|
2003-01-11 01:55:53 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
|
2004-04-29 20:52:29 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_UI_MANAGER (popup_manager), NULL);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2002-06-27 06:16:59 +08:00
|
|
|
/* the toplevel shell */
|
2004-06-02 06:04:20 +08:00
|
|
|
shell = g_object_new (GIMP_TYPE_DISPLAY_SHELL,
|
|
|
|
"unit", unit,
|
|
|
|
"scale", scale,
|
|
|
|
NULL);
|
2002-06-27 06:16:59 +08:00
|
|
|
|
|
|
|
shell->gdisp = gdisp;
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
image_width = gdisp->gimage->width;
|
|
|
|
image_height = gdisp->gimage->height;
|
|
|
|
|
2004-05-17 21:38:03 +08:00
|
|
|
display_config = GIMP_DISPLAY_CONFIG (gdisp->gimage->gimp->config);
|
2002-11-19 04:50:31 +08:00
|
|
|
|
2004-05-17 21:38:03 +08:00
|
|
|
shell->dot_for_dot = display_config->default_dot_for_dot;
|
2002-11-19 04:50:31 +08:00
|
|
|
|
2004-05-17 21:38:03 +08:00
|
|
|
gimp_config_sync (GIMP_CONFIG (display_config->default_view),
|
2003-10-22 22:46:05 +08:00
|
|
|
GIMP_CONFIG (shell->options), 0);
|
2004-05-17 21:38:03 +08:00
|
|
|
gimp_config_sync (GIMP_CONFIG (display_config->default_fullscreen_view),
|
2003-10-22 22:46:05 +08:00
|
|
|
GIMP_CONFIG (shell->fullscreen_options), 0);
|
2003-03-12 00:49:36 +08:00
|
|
|
|
2002-09-28 00:17:31 +08:00
|
|
|
/* adjust the initial scale -- so that window fits on screen the 75%
|
|
|
|
* value is the same as in gimp_display_shell_shrink_wrap. It
|
|
|
|
* probably should be a user-configurable option.
|
2001-01-22 11:30:42 +08:00
|
|
|
*/
|
2003-09-09 19:35:27 +08:00
|
|
|
screen = gtk_widget_get_screen (GTK_WIDGET (shell));
|
|
|
|
|
2004-05-17 21:38:03 +08:00
|
|
|
if (display_config->monitor_res_from_gdk)
|
2003-10-06 04:34:48 +08:00
|
|
|
{
|
|
|
|
gimp_get_screen_resolution (screen,
|
|
|
|
&shell->monitor_xres, &shell->monitor_yres);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-05-17 21:38:03 +08:00
|
|
|
shell->monitor_xres = display_config->monitor_xres;
|
|
|
|
shell->monitor_yres = display_config->monitor_yres;
|
2003-10-06 04:34:48 +08:00
|
|
|
}
|
|
|
|
|
2003-09-09 19:35:27 +08:00
|
|
|
s_width = gdk_screen_get_width (screen) * 0.75;
|
|
|
|
s_height = gdk_screen_get_height (screen) * 0.75;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-06-27 06:16:59 +08:00
|
|
|
n_width = SCALEX (shell, image_width);
|
2004-01-30 06:22:29 +08:00
|
|
|
n_height = SCALEY (shell, image_height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-05-17 21:38:03 +08:00
|
|
|
if (display_config->initial_zoom_to_fit)
|
2000-04-02 23:34:30 +08:00
|
|
|
{
|
2003-02-26 00:30:53 +08:00
|
|
|
/* Limit to the size of the screen... */
|
2004-01-30 06:22:29 +08:00
|
|
|
if (n_width > s_width || n_height > s_height)
|
2003-02-26 00:30:53 +08:00
|
|
|
{
|
2004-01-30 06:22:29 +08:00
|
|
|
new_scale = shell->scale * MIN (((gdouble) s_height) / n_height,
|
|
|
|
((gdouble) s_width) / n_width);
|
2004-02-07 08:16:52 +08:00
|
|
|
|
2004-01-30 06:22:29 +08:00
|
|
|
new_scale = gimp_display_shell_scale_zoom_step (GIMP_ZOOM_OUT,
|
|
|
|
new_scale);
|
|
|
|
|
|
|
|
/* since zooming out might skip a zoom step we zoom in again
|
|
|
|
* and test if we are small enough. */
|
|
|
|
shell->scale = gimp_display_shell_scale_zoom_step (GIMP_ZOOM_IN,
|
|
|
|
new_scale);
|
|
|
|
|
|
|
|
if (SCALEX (shell, image_width) > s_width ||
|
|
|
|
SCALEY (shell, image_height) > s_height)
|
|
|
|
shell->scale = new_scale;
|
|
|
|
|
|
|
|
n_width = SCALEX (shell, image_width);
|
|
|
|
n_height = SCALEY (shell, image_height);
|
2003-02-26 00:30:53 +08:00
|
|
|
}
|
2003-07-18 06:30:13 +08:00
|
|
|
}
|
|
|
|
else
|
2003-02-26 00:30:53 +08:00
|
|
|
{
|
2003-07-18 06:30:13 +08:00
|
|
|
/* Set up size like above, but do not zoom to fit.
|
2004-07-14 18:31:59 +08:00
|
|
|
Useful when working on large images. */
|
2003-07-18 06:30:13 +08:00
|
|
|
|
2003-02-26 00:30:53 +08:00
|
|
|
if (n_width > s_width)
|
2004-07-14 18:31:59 +08:00
|
|
|
n_width = s_width;
|
2003-02-26 00:30:53 +08:00
|
|
|
|
|
|
|
if (n_height > s_height)
|
2004-07-14 18:31:59 +08:00
|
|
|
n_height = s_height;
|
2000-04-02 23:34:30 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
shell->menubar_manager = gimp_menu_factory_manager_new (menu_factory,
|
|
|
|
"<Image>",
|
|
|
|
gdisp,
|
|
|
|
FALSE);
|
2002-12-14 22:13:54 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
shell->popup_manager = popup_manager;
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2003-01-12 20:35:00 +08:00
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (shell),
|
2004-04-29 20:52:29 +08:00
|
|
|
gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (shell->menubar_manager)));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* GtkTable widgets are not able to shrink a row/column correctly if
|
|
|
|
* widgets are attached with GTK_EXPAND even if those widgets have
|
|
|
|
* other rows/columns in their rowspan/colspan where they could
|
|
|
|
* nicely expand without disturbing the row/column which is supposed
|
|
|
|
* to shrink. --Mitch
|
|
|
|
*
|
|
|
|
* Changed the packing to use hboxes and vboxes which behave nicer:
|
|
|
|
*
|
|
|
|
* main_vbox
|
|
|
|
* |
|
2002-12-18 23:42:45 +08:00
|
|
|
* +-- menubar
|
|
|
|
* |
|
2000-04-02 23:34:30 +08:00
|
|
|
* +-- disp_vbox
|
|
|
|
* | |
|
|
|
|
* | +-- upper_hbox
|
|
|
|
* | | |
|
|
|
|
* | | +-- inner_table
|
|
|
|
* | | | |
|
|
|
|
* | | | +-- origin
|
|
|
|
* | | | +-- hruler
|
|
|
|
* | | | +-- vruler
|
|
|
|
* | | | +-- canvas
|
2003-07-18 06:30:13 +08:00
|
|
|
* | | |
|
2001-11-16 23:08:59 +08:00
|
|
|
* | | +-- right_vbox
|
|
|
|
* | | |
|
2004-06-23 00:31:27 +08:00
|
|
|
* | | +-- zoom_on_resize_button
|
2001-11-16 23:08:59 +08:00
|
|
|
* | | +-- vscrollbar
|
2003-07-18 06:30:13 +08:00
|
|
|
* | |
|
2000-04-02 23:34:30 +08:00
|
|
|
* | +-- lower_hbox
|
|
|
|
* | |
|
2001-11-30 00:44:51 +08:00
|
|
|
* | +-- qmask
|
2000-04-02 23:34:30 +08:00
|
|
|
* | +-- hscrollbar
|
|
|
|
* | +-- navbutton
|
|
|
|
* |
|
2002-02-03 20:10:23 +08:00
|
|
|
* +-- statusbar
|
2000-04-02 23:34:30 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* first, set up the container hierarchy *********************************/
|
|
|
|
|
|
|
|
/* the vbox containing all widgets */
|
2002-12-11 00:38:16 +08:00
|
|
|
|
2002-12-14 22:13:54 +08:00
|
|
|
main_vbox = gtk_vbox_new (FALSE, 0);
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (shell), main_vbox);
|
2000-04-02 23:34:30 +08:00
|
|
|
|
2004-05-17 21:38:03 +08:00
|
|
|
shell->menubar = gimp_ui_manager_ui_get (shell->menubar_manager,
|
|
|
|
"/image-menubar");
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), shell->menubar, FALSE, FALSE, 0);
|
2004-04-23 01:14:22 +08:00
|
|
|
|
|
|
|
if (shell->options->show_menubar)
|
2004-05-17 21:38:03 +08:00
|
|
|
gtk_widget_show (shell->menubar);
|
2004-06-17 20:19:02 +08:00
|
|
|
else
|
|
|
|
gtk_widget_hide (shell->menubar);
|
2004-04-22 00:33:17 +08:00
|
|
|
|
2004-03-19 20:52:27 +08:00
|
|
|
/* make sure we can activate accels even if the menubar is invisible
|
|
|
|
* (see http://bugzilla.gnome.org/show_bug.cgi?id=137151)
|
|
|
|
*/
|
2004-05-17 21:38:03 +08:00
|
|
|
g_signal_connect (shell->menubar, "can-activate-accel",
|
2004-04-16 00:54:44 +08:00
|
|
|
G_CALLBACK (gtk_true),
|
|
|
|
NULL);
|
2004-03-19 20:52:27 +08:00
|
|
|
|
2002-12-14 22:13:54 +08:00
|
|
|
/* active display callback */
|
2004-05-17 21:38:03 +08:00
|
|
|
g_signal_connect (shell->menubar, "button_press_event",
|
2002-12-14 22:13:54 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_events),
|
|
|
|
shell);
|
2004-05-17 21:38:03 +08:00
|
|
|
g_signal_connect (shell->menubar, "button_release_event",
|
2002-12-14 22:13:54 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_events),
|
|
|
|
shell);
|
2004-05-17 21:38:03 +08:00
|
|
|
g_signal_connect (shell->menubar, "key_press_event",
|
2002-12-14 22:13:54 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_events),
|
|
|
|
shell);
|
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* another vbox for everything except the statusbar */
|
|
|
|
disp_vbox = gtk_vbox_new (FALSE, 1);
|
2002-12-14 22:13:54 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (disp_vbox), 2);
|
2000-04-02 23:34:30 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), disp_vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (disp_vbox);
|
|
|
|
|
|
|
|
/* a hbox for the inner_table and the vertical scrollbar */
|
|
|
|
upper_hbox = gtk_hbox_new (FALSE, 1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (disp_vbox), upper_hbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (upper_hbox);
|
|
|
|
|
|
|
|
/* the table containing origin, rulers and the canvas */
|
|
|
|
inner_table = gtk_table_new (2, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (inner_table), 0, 1);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (inner_table), 0, 1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (upper_hbox), inner_table, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (inner_table);
|
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
/* the vbox containing the color button and the vertical scrollbar */
|
|
|
|
right_vbox = gtk_vbox_new (FALSE, 1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (upper_hbox), right_vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (right_vbox);
|
|
|
|
|
2001-11-30 00:44:51 +08:00
|
|
|
/* the hbox containing qmask button, vertical scrollbar and nav button */
|
2000-04-02 23:34:30 +08:00
|
|
|
lower_hbox = gtk_hbox_new (FALSE, 1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (disp_vbox), lower_hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (lower_hbox);
|
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
/* create the scrollbars *************************************************/
|
1999-11-03 17:58:46 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* the horizontal scrollbar */
|
2001-11-01 05:20:09 +08:00
|
|
|
shell->hsbdata =
|
|
|
|
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, image_width, 1, 1, image_width));
|
|
|
|
shell->hsb = gtk_hscrollbar_new (shell->hsbdata);
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (shell->hsb, GTK_CAN_FOCUS);
|
1999-11-03 17:58:46 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* the vertical scrollbar */
|
2001-11-01 05:20:09 +08:00
|
|
|
shell->vsbdata =
|
|
|
|
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, image_height, 1, 1, image_height));
|
|
|
|
shell->vsb = gtk_vscrollbar_new (shell->vsbdata);
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (shell->vsb, GTK_CAN_FOCUS);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* create the contents of the inner_table ********************************/
|
1998-06-15 10:25:27 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* the menu popup button */
|
2004-06-23 00:31:27 +08:00
|
|
|
shell->origin_button = gtk_button_new ();
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (shell->origin_button, GTK_CAN_FOCUS);
|
2003-09-23 20:30:53 +08:00
|
|
|
|
|
|
|
image = gtk_image_new_from_stock (GIMP_STOCK_MENU_RIGHT, GTK_ICON_SIZE_MENU);
|
2004-06-23 00:31:27 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (shell->origin_button), image);
|
2003-09-23 20:30:53 +08:00
|
|
|
gtk_widget_show (image);
|
2001-07-31 01:17:36 +08:00
|
|
|
|
2004-06-23 00:31:27 +08:00
|
|
|
g_signal_connect (shell->origin_button, "button_press_event",
|
2002-12-11 00:38:16 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_origin_button_press),
|
|
|
|
shell);
|
1998-07-20 23:07:13 +08:00
|
|
|
|
2004-06-23 00:31:27 +08:00
|
|
|
gimp_help_set_help_data (shell->origin_button, NULL,
|
2003-11-12 21:35:06 +08:00
|
|
|
GIMP_HELP_IMAGE_WINDOW_ORIGIN_BUTTON);
|
1999-11-03 17:58:46 +08:00
|
|
|
|
2003-11-10 07:24:40 +08:00
|
|
|
shell->canvas = gimp_canvas_new ();
|
2002-12-11 00:38:16 +08:00
|
|
|
|
2003-11-11 22:50:07 +08:00
|
|
|
shell->select = gimp_display_shell_selection_new (shell);
|
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* the horizontal ruler */
|
2001-11-01 05:20:09 +08:00
|
|
|
shell->hrule = gtk_hruler_new ();
|
|
|
|
gtk_widget_set_events (GTK_WIDGET (shell->hrule),
|
2004-07-14 18:31:59 +08:00
|
|
|
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
|
2001-07-31 01:17:36 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_swapped (shell->canvas, "motion_notify_event",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_CALLBACK (GTK_WIDGET_GET_CLASS (shell->hrule)->motion_notify_event),
|
|
|
|
shell->hrule);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell->hrule, "button_press_event",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_hruler_button_press),
|
|
|
|
shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-12 21:35:06 +08:00
|
|
|
gimp_help_set_help_data (shell->hrule, NULL, GIMP_HELP_IMAGE_WINDOW_RULER);
|
1999-11-03 17:58:46 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* the vertical ruler */
|
2001-11-01 05:20:09 +08:00
|
|
|
shell->vrule = gtk_vruler_new ();
|
|
|
|
gtk_widget_set_events (GTK_WIDGET (shell->vrule),
|
2004-07-14 18:31:59 +08:00
|
|
|
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
|
2001-07-31 01:17:36 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_swapped (shell->canvas, "motion_notify_event",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_CALLBACK (GTK_WIDGET_GET_CLASS (shell->vrule)->motion_notify_event),
|
|
|
|
shell->vrule);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell->vrule, "button_press_event",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_vruler_button_press),
|
|
|
|
shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-12 21:35:06 +08:00
|
|
|
gimp_help_set_help_data (shell->vrule, NULL, GIMP_HELP_IMAGE_WINDOW_RULER);
|
1999-11-03 17:58:46 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* the canvas */
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_set_size_request (shell->canvas, n_width, n_height);
|
2001-11-02 17:31:21 +08:00
|
|
|
gtk_widget_set_events (shell->canvas, GIMP_DISPLAY_SHELL_CANVAS_EVENT_MASK);
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_widget_set_extension_events (shell->canvas, GDK_EXTENSION_EVENTS_ALL);
|
|
|
|
GTK_WIDGET_SET_FLAGS (shell->canvas, GTK_CAN_FOCUS);
|
2000-04-02 23:34:30 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell->canvas, "realize",
|
2001-11-10 00:54:56 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_canvas_realize),
|
2001-11-02 17:31:21 +08:00
|
|
|
shell);
|
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* set the active display before doing any other canvas event processing */
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell->canvas, "event",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_events),
|
|
|
|
shell);
|
2001-11-02 17:31:21 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell->canvas, "expose_event",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_canvas_expose),
|
|
|
|
shell);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell->canvas, "configure_event",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_canvas_configure),
|
|
|
|
shell);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell->canvas, "event",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
/* create the contents of the right_vbox *********************************/
|
2004-06-23 00:31:27 +08:00
|
|
|
shell->zoom_button = gtk_check_button_new ();
|
|
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (shell->zoom_button), FALSE);
|
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (shell->zoom_button), 16, 16);
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (shell->zoom_button, GTK_CAN_FOCUS);
|
|
|
|
|
|
|
|
image = gtk_image_new_from_stock (GIMP_STOCK_ZOOM_FOLLOW_WINDOW,
|
|
|
|
GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_container_add (GTK_CONTAINER (shell->zoom_button), image);
|
|
|
|
gtk_widget_show (image);
|
2001-11-16 23:08:59 +08:00
|
|
|
|
2004-06-23 00:31:27 +08:00
|
|
|
gimp_help_set_help_data (shell->zoom_button,
|
|
|
|
_("Zoom image when window size changes"),
|
|
|
|
GIMP_HELP_IMAGE_WINDOW_ZOOM_FOLLOW_BUTTON);
|
|
|
|
|
|
|
|
g_signal_connect (shell->zoom_button, "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&shell->zoom_on_resize);
|
2002-02-28 21:47:03 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* create the contents of the lower_hbox *********************************/
|
1999-11-03 17:58:46 +08:00
|
|
|
|
2001-11-30 00:44:51 +08:00
|
|
|
/* the qmask button */
|
2004-06-23 00:31:27 +08:00
|
|
|
shell->qmask_button = gtk_check_button_new ();
|
|
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (shell->qmask_button), FALSE);
|
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (shell->qmask_button), 16, 16);
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (shell->qmask_button, GTK_CAN_FOCUS);
|
2001-11-10 00:54:56 +08:00
|
|
|
|
2002-09-28 00:17:31 +08:00
|
|
|
image = gtk_image_new_from_stock (GIMP_STOCK_QMASK_OFF, GTK_ICON_SIZE_MENU);
|
2004-06-23 00:31:27 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (shell->qmask_button), image);
|
2001-11-30 00:44:51 +08:00
|
|
|
gtk_widget_show (image);
|
2001-11-10 00:54:56 +08:00
|
|
|
|
2004-06-23 00:31:27 +08:00
|
|
|
gimp_help_set_help_data (shell->qmask_button,
|
2003-11-12 21:35:06 +08:00
|
|
|
_("Toggle QuickMask"),
|
|
|
|
GIMP_HELP_IMAGE_WINDOW_QMASK_BUTTON);
|
2001-11-30 00:44:51 +08:00
|
|
|
|
2004-06-23 00:31:27 +08:00
|
|
|
g_signal_connect (shell->qmask_button, "toggled",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_qmask_toggled),
|
|
|
|
shell);
|
2004-06-23 00:31:27 +08:00
|
|
|
g_signal_connect (shell->qmask_button, "button_press_event",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_qmask_button_press),
|
|
|
|
shell);
|
1999-07-07 11:18:54 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* the navigation window button */
|
2002-11-23 06:10:40 +08:00
|
|
|
shell->nav_ebox = gtk_event_box_new ();
|
2001-07-31 01:17:36 +08:00
|
|
|
|
2001-11-10 00:54:56 +08:00
|
|
|
image = gtk_image_new_from_stock (GIMP_STOCK_NAVIGATION, GTK_ICON_SIZE_MENU);
|
2003-07-18 06:30:13 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (shell->nav_ebox), image);
|
2001-11-10 00:54:56 +08:00
|
|
|
gtk_widget_show (image);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (shell->nav_ebox, "button_press_event",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_nav_button_press),
|
|
|
|
shell);
|
2000-04-02 23:34:30 +08:00
|
|
|
|
2003-11-12 21:35:06 +08:00
|
|
|
gimp_help_set_help_data (shell->nav_ebox, NULL,
|
|
|
|
GIMP_HELP_IMAGE_WINDOW_NAV_BUTTON);
|
2000-04-02 23:34:30 +08:00
|
|
|
|
|
|
|
/* create the contents of the status area *********************************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* the statusbar */
|
2002-06-27 06:16:59 +08:00
|
|
|
shell->statusbar = gimp_statusbar_new (shell);
|
2003-11-12 21:35:06 +08:00
|
|
|
gimp_help_set_help_data (shell->statusbar, NULL,
|
|
|
|
GIMP_HELP_IMAGE_WINDOW_STATUS_BAR);
|
1998-07-15 20:15:24 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* pack all the widgets **************************************************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* fill the inner_table */
|
2004-06-23 00:31:27 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (inner_table), shell->origin_button, 0, 1, 0, 1,
|
2002-12-11 00:38:16 +08:00
|
|
|
GTK_FILL, GTK_FILL, 0, 0);
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (inner_table), shell->hrule, 1, 2, 0, 1,
|
2004-07-14 18:31:59 +08:00
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (inner_table), shell->vrule, 0, 1, 1, 2,
|
2004-07-14 18:31:59 +08:00
|
|
|
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (inner_table), shell->canvas, 1, 2, 1, 2,
|
2004-07-14 18:31:59 +08:00
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
|
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
/* fill the right_vbox */
|
2004-06-23 00:31:27 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (right_vbox), shell->zoom_button, FALSE, FALSE, 0);
|
2001-11-16 23:08:59 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (right_vbox), shell->vsb, TRUE, TRUE, 0);
|
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
/* fill the lower_hbox */
|
2004-06-23 00:31:27 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (lower_hbox), shell->qmask_button, FALSE, FALSE, 0);
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (lower_hbox), shell->hsb, TRUE, TRUE, 0);
|
2002-11-23 06:10:40 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (lower_hbox), shell->nav_ebox, FALSE, FALSE, 0);
|
1999-07-07 11:18:54 +08:00
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (main_vbox), shell->statusbar, FALSE, FALSE, 0);
|
2000-04-02 23:34:30 +08:00
|
|
|
|
|
|
|
/* show everything *******************************************************/
|
1998-10-07 16:59:11 +08:00
|
|
|
|
2003-10-22 22:46:05 +08:00
|
|
|
if (shell->options->show_rulers)
|
1998-08-05 20:38:11 +08:00
|
|
|
{
|
2004-06-23 00:31:27 +08:00
|
|
|
gtk_widget_show (shell->origin_button);
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_widget_show (shell->hrule);
|
|
|
|
gtk_widget_show (shell->vrule);
|
1998-08-05 20:38:11 +08:00
|
|
|
}
|
2000-04-02 23:34:30 +08:00
|
|
|
|
2003-11-11 03:35:56 +08:00
|
|
|
gtk_widget_show (GTK_WIDGET (shell->canvas));
|
2001-11-16 23:08:59 +08:00
|
|
|
|
2003-10-22 22:46:05 +08:00
|
|
|
if (shell->options->show_scrollbars)
|
2003-03-12 00:49:36 +08:00
|
|
|
{
|
|
|
|
gtk_widget_show (shell->vsb);
|
|
|
|
gtk_widget_show (shell->hsb);
|
2004-06-23 00:31:27 +08:00
|
|
|
gtk_widget_show (shell->zoom_button);
|
|
|
|
gtk_widget_show (shell->qmask_button);
|
2003-03-12 00:49:36 +08:00
|
|
|
gtk_widget_show (shell->nav_ebox);
|
|
|
|
}
|
2000-04-02 23:34:30 +08:00
|
|
|
|
2003-10-22 22:46:05 +08:00
|
|
|
if (shell->options->show_statusbar)
|
2002-12-14 22:13:54 +08:00
|
|
|
gtk_widget_show (shell->statusbar);
|
1999-12-26 15:54:39 +08:00
|
|
|
|
2000-04-02 23:34:30 +08:00
|
|
|
gtk_widget_show (main_vbox);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2001-11-11 03:10:28 +08:00
|
|
|
gimp_display_shell_connect (shell);
|
|
|
|
|
2004-07-15 00:37:13 +08:00
|
|
|
gimp_display_shell_title_init (shell);
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
return GTK_WIDGET (shell);
|
|
|
|
}
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_reconnect (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (shell->gdisp));
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (shell->gdisp->gimage));
|
|
|
|
|
|
|
|
gimp_display_shell_connect (shell);
|
|
|
|
|
2003-06-04 21:06:59 +08:00
|
|
|
gimp_display_shell_scale_setup (shell);
|
2004-03-22 21:12:07 +08:00
|
|
|
gimp_display_shell_expose_full (shell);
|
2004-05-10 18:33:21 +08:00
|
|
|
gimp_display_shell_scaled (shell);
|
2002-09-28 00:17:31 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_emit (shell, display_shell_signals[RECONNECT], 0);
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_scaled (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_emit (shell, display_shell_signals[SCALED], 0);
|
2002-05-08 00:23:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_display_shell_scrolled (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_emit (shell, display_shell_signals[SCROLLED], 0);
|
2002-05-08 00:23:14 +08:00
|
|
|
}
|
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_set_unit (GimpDisplayShell *shell,
|
|
|
|
GimpUnit unit)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
|
|
|
if (shell->unit != unit)
|
|
|
|
{
|
|
|
|
shell->unit = unit;
|
|
|
|
|
|
|
|
gimp_display_shell_scale_setup (shell);
|
|
|
|
gimp_display_shell_scaled (shell);
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (shell), "unit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-24 02:23:31 +08:00
|
|
|
gboolean
|
2003-04-17 10:57:33 +08:00
|
|
|
gimp_display_shell_snap_coords (GimpDisplayShell *shell,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GimpCoords *snapped_coords,
|
|
|
|
gint snap_offset_x,
|
|
|
|
gint snap_offset_y,
|
|
|
|
gint snap_width,
|
|
|
|
gint snap_height)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
2003-06-24 03:34:48 +08:00
|
|
|
gboolean snap_to_guides = FALSE;
|
2004-01-04 04:51:36 +08:00
|
|
|
gboolean snap_to_grid = FALSE;
|
2004-02-24 02:23:31 +08:00
|
|
|
gboolean snapped = FALSE;
|
2003-06-24 03:34:48 +08:00
|
|
|
|
2004-02-24 02:23:31 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
|
|
|
|
g_return_val_if_fail (coords != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (snapped_coords != NULL, FALSE);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2003-04-17 10:57:33 +08:00
|
|
|
*snapped_coords = *coords;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2004-01-04 04:51:36 +08:00
|
|
|
if (shell->snap_to_guides &&
|
2001-11-01 05:20:09 +08:00
|
|
|
shell->gdisp->gimage->guides)
|
2003-06-24 03:34:48 +08:00
|
|
|
{
|
|
|
|
snap_to_guides = TRUE;
|
|
|
|
}
|
2003-07-18 06:30:13 +08:00
|
|
|
|
2003-08-13 02:02:55 +08:00
|
|
|
if (gimp_display_shell_get_snap_to_grid (shell) &&
|
2003-06-24 03:34:48 +08:00
|
|
|
shell->gdisp->gimage->grid)
|
|
|
|
{
|
|
|
|
snap_to_grid = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (snap_to_guides || snap_to_grid)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
2004-02-24 02:23:31 +08:00
|
|
|
gdouble tx, ty;
|
|
|
|
gint snap_distance;
|
2004-02-19 04:31:11 +08:00
|
|
|
|
2004-02-24 02:23:31 +08:00
|
|
|
snap_distance =
|
2004-07-14 18:31:59 +08:00
|
|
|
GIMP_DISPLAY_CONFIG (shell->gdisp->gimage->gimp->config)->snap_distance;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2003-04-17 10:57:33 +08:00
|
|
|
if (snap_width > 0 && snap_height > 0)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
2003-05-05 19:26:01 +08:00
|
|
|
snapped = gimp_image_snap_rectangle (shell->gdisp->gimage,
|
|
|
|
coords->x + snap_offset_x,
|
|
|
|
coords->y + snap_offset_y,
|
|
|
|
coords->x + snap_offset_x +
|
|
|
|
snap_width,
|
|
|
|
coords->y + snap_offset_y +
|
|
|
|
snap_height,
|
|
|
|
&tx,
|
2003-06-24 03:34:48 +08:00
|
|
|
&ty,
|
2004-02-19 04:31:11 +08:00
|
|
|
FUNSCALEX (shell, snap_distance),
|
|
|
|
FUNSCALEY (shell, snap_distance),
|
2003-06-24 03:34:48 +08:00
|
|
|
snap_to_guides,
|
|
|
|
snap_to_grid);
|
2003-04-17 10:57:33 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-05-05 19:26:01 +08:00
|
|
|
snapped = gimp_image_snap_point (shell->gdisp->gimage,
|
|
|
|
coords->x + snap_offset_x,
|
|
|
|
coords->y + snap_offset_y,
|
|
|
|
&tx,
|
2003-06-24 03:34:48 +08:00
|
|
|
&ty,
|
2004-02-19 04:31:11 +08:00
|
|
|
FUNSCALEX (shell, snap_distance),
|
|
|
|
FUNSCALEY (shell, snap_distance),
|
2003-06-24 03:34:48 +08:00
|
|
|
snap_to_guides,
|
|
|
|
snap_to_grid);
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
2003-03-20 19:31:33 +08:00
|
|
|
|
2003-05-05 19:26:01 +08:00
|
|
|
if (snapped)
|
|
|
|
{
|
|
|
|
snapped_coords->x = tx - snap_offset_x;
|
|
|
|
snapped_coords->y = ty - snap_offset_y;
|
|
|
|
}
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
2004-02-24 02:23:31 +08:00
|
|
|
|
|
|
|
return snapped;
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_display_shell_mask_bounds (GimpDisplayShell *shell,
|
|
|
|
gint *x1,
|
|
|
|
gint *y1,
|
|
|
|
gint *x2,
|
|
|
|
gint *y2)
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
gint off_x;
|
|
|
|
gint off_y;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
|
|
|
|
g_return_val_if_fail (x1 != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (y1 != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (x2 != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (y2 != NULL, FALSE);
|
|
|
|
|
|
|
|
/* If there is a floating selection, handle things differently */
|
|
|
|
if ((layer = gimp_image_floating_sel (shell->gdisp->gimage)))
|
|
|
|
{
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (layer), &off_x, &off_y);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
|
|
|
if (! gimp_channel_bounds (gimp_image_get_mask (shell->gdisp->gimage),
|
2004-07-14 18:31:59 +08:00
|
|
|
x1, y1, x2, y2))
|
|
|
|
{
|
|
|
|
*x1 = off_x;
|
|
|
|
*y1 = off_y;
|
|
|
|
*x2 = off_x + gimp_item_width (GIMP_ITEM (layer));
|
|
|
|
*y2 = off_y + gimp_item_height (GIMP_ITEM (layer));
|
|
|
|
}
|
2001-11-01 05:20:09 +08:00
|
|
|
else
|
2004-07-14 18:31:59 +08:00
|
|
|
{
|
|
|
|
*x1 = MIN (off_x, *x1);
|
|
|
|
*y1 = MIN (off_y, *y1);
|
|
|
|
*x2 = MAX (off_x + gimp_item_width (GIMP_ITEM (layer)), *x2);
|
|
|
|
*y2 = MAX (off_y + gimp_item_height (GIMP_ITEM (layer)), *y2);
|
|
|
|
}
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
|
|
|
else if (! gimp_channel_bounds (gimp_image_get_mask (shell->gdisp->gimage),
|
2004-07-14 18:31:59 +08:00
|
|
|
x1, y1, x2, y2))
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-02-06 07:55:03 +08:00
|
|
|
gimp_display_shell_transform_xy (shell, *x1, *y1, x1, y1, FALSE);
|
|
|
|
gimp_display_shell_transform_xy (shell, *x2, *y2, x2, y2, FALSE);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
|
|
|
/* Make sure the extents are within bounds */
|
2001-11-02 17:31:21 +08:00
|
|
|
*x1 = CLAMP (*x1, 0, shell->disp_width);
|
|
|
|
*y1 = CLAMP (*y1, 0, shell->disp_height);
|
|
|
|
*x2 = CLAMP (*x2, 0, shell->disp_width);
|
|
|
|
*y2 = CLAMP (*y2, 0, shell->disp_height);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-02-21 20:16:43 +08:00
|
|
|
gimp_display_shell_expose_area (GimpDisplayShell *shell,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2003-02-21 20:16:43 +08:00
|
|
|
gtk_widget_queue_draw_area (shell->canvas, x, y, w, h);
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_display_shell_expose_guide (GimpDisplayShell *shell,
|
|
|
|
GimpGuide *guide)
|
|
|
|
{
|
|
|
|
gint x;
|
|
|
|
gint y;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
g_return_if_fail (guide != NULL);
|
|
|
|
|
|
|
|
if (guide->position < 0)
|
|
|
|
return;
|
|
|
|
|
2002-06-27 06:16:59 +08:00
|
|
|
gimp_display_shell_transform_xy (shell,
|
|
|
|
guide->position,
|
|
|
|
guide->position,
|
|
|
|
&x, &y,
|
|
|
|
FALSE);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
|
|
|
switch (guide->orientation)
|
|
|
|
{
|
2003-02-08 01:12:21 +08:00
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
2003-02-21 20:16:43 +08:00
|
|
|
gimp_display_shell_expose_area (shell, 0, y, shell->disp_width, 1);
|
2001-11-01 05:20:09 +08:00
|
|
|
break;
|
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
2003-02-21 20:16:43 +08:00
|
|
|
gimp_display_shell_expose_area (shell, x, 0, 1, shell->disp_height);
|
2001-11-01 05:20:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_display_shell_expose_full (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2003-02-21 20:16:43 +08:00
|
|
|
gtk_widget_queue_draw (shell->canvas);
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-10-08 22:50:26 +08:00
|
|
|
gimp_display_shell_flush (GimpDisplayShell *shell,
|
|
|
|
gboolean now)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
if (! shell->select)
|
|
|
|
{
|
|
|
|
g_warning ("%s: called unrealized", G_STRFUNC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-07-15 00:37:13 +08:00
|
|
|
gimp_display_shell_title_update (shell);
|
2003-10-08 22:50:26 +08:00
|
|
|
|
|
|
|
if (now)
|
2004-07-14 00:36:29 +08:00
|
|
|
{
|
|
|
|
gdk_window_process_updates (shell->canvas->window, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GimpContext *user_context;
|
|
|
|
|
|
|
|
gimp_ui_manager_update (shell->menubar_manager, shell);
|
|
|
|
|
|
|
|
user_context = gimp_get_user_context (shell->gdisp->gimage->gimp);
|
|
|
|
|
|
|
|
if (shell->gdisp == gimp_context_get_display (user_context))
|
|
|
|
gimp_ui_manager_update (shell->popup_manager, shell);
|
|
|
|
}
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
|
|
|
|
2004-07-16 07:02:52 +08:00
|
|
|
/**
|
|
|
|
* gimp_display_shell_pause:
|
|
|
|
* @shell: a display shell
|
|
|
|
*
|
|
|
|
* This function increments the pause count or the display shell.
|
2004-07-16 18:07:30 +08:00
|
|
|
* If it was zero coming in, then the function pauses the active tool,
|
|
|
|
* so that operations on the display can take place without corrupting
|
|
|
|
* anything that the tool has drawn. It "undraws" the current tool
|
|
|
|
* drawing, and must be followed by gimp_display_shell_resume() after
|
2004-07-16 07:02:52 +08:00
|
|
|
* the operation in question is completed.
|
|
|
|
**/
|
2003-09-12 06:24:30 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_pause (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
|
|
|
shell->paused_count++;
|
|
|
|
|
|
|
|
if (shell->paused_count == 1)
|
|
|
|
{
|
|
|
|
/* pause the currently active tool */
|
|
|
|
tool_manager_control_active (shell->gdisp->gimage->gimp, PAUSE,
|
|
|
|
shell->gdisp);
|
|
|
|
|
|
|
|
gimp_display_shell_draw_vectors (shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-16 07:02:52 +08:00
|
|
|
/**
|
2004-07-22 20:05:36 +08:00
|
|
|
* gimp_display_shell_resume:
|
2004-07-16 07:02:52 +08:00
|
|
|
* @shell: a display shell
|
|
|
|
*
|
|
|
|
* This function decrements the pause count for the display shell.
|
|
|
|
* If this brings it to zero, then the current tool is resumed.
|
|
|
|
* It is an error to call this function without having previously
|
|
|
|
* called gimp_display_shell_pause().
|
|
|
|
**/
|
2003-09-12 06:24:30 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_resume (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
g_return_if_fail (shell->paused_count > 0);
|
|
|
|
|
|
|
|
shell->paused_count--;
|
|
|
|
|
|
|
|
if (shell->paused_count == 0)
|
|
|
|
{
|
|
|
|
gimp_display_shell_draw_vectors (shell);
|
|
|
|
|
|
|
|
/* start the currently active tool */
|
|
|
|
tool_manager_control_active (shell->gdisp->gimage->gimp, RESUME,
|
|
|
|
shell->gdisp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-17 21:12:16 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_update_icon (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
gint width, height;
|
|
|
|
gdouble factor;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
|
|
|
factor = ((gdouble) gimp_image_get_height (shell->gdisp->gimage) /
|
|
|
|
(gdouble) gimp_image_get_width (shell->gdisp->gimage));
|
|
|
|
|
|
|
|
if (factor >= 1)
|
|
|
|
{
|
|
|
|
height = MAX (shell->icon_size, 1);
|
|
|
|
width = MAX (((gdouble) shell->icon_size) / factor, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
height = MAX (((gdouble) shell->icon_size) * factor, 1);
|
|
|
|
width = MAX (shell->icon_size, 1);
|
|
|
|
}
|
|
|
|
|
2004-07-14 08:15:57 +08:00
|
|
|
pixbuf = gimp_viewable_get_pixbuf (GIMP_VIEWABLE (shell->gdisp->gimage),
|
|
|
|
width, height);
|
2002-02-17 21:12:16 +08:00
|
|
|
|
|
|
|
gtk_window_set_icon (GTK_WINDOW (shell), pixbuf);
|
|
|
|
}
|
|
|
|
|
2003-03-11 09:22:57 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
|
|
|
|
{
|
2003-11-20 02:34:04 +08:00
|
|
|
GtkWidget *widget;
|
|
|
|
GdkScreen *screen;
|
|
|
|
GdkRectangle rect;
|
|
|
|
gint monitor;
|
|
|
|
gint disp_width, disp_height;
|
|
|
|
gint width, height;
|
|
|
|
gint max_auto_width, max_auto_height;
|
|
|
|
gint border_x, border_y;
|
|
|
|
gboolean resize = FALSE;
|
2003-09-09 19:35:27 +08:00
|
|
|
|
2003-11-20 02:34:04 +08:00
|
|
|
g_return_if_fail (GTK_WIDGET_REALIZED (shell));
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (shell);
|
|
|
|
screen = gtk_widget_get_screen (widget);
|
2003-09-09 19:35:27 +08:00
|
|
|
|
2003-11-20 02:34:04 +08:00
|
|
|
monitor = gdk_screen_get_monitor_at_window (screen, widget->window);
|
|
|
|
gdk_screen_get_monitor_geometry (screen, monitor, &rect);
|
2003-03-11 09:22:57 +08:00
|
|
|
|
|
|
|
width = SCALEX (shell, shell->gdisp->gimage->width);
|
|
|
|
height = SCALEY (shell, shell->gdisp->gimage->height);
|
|
|
|
|
|
|
|
disp_width = shell->disp_width;
|
|
|
|
disp_height = shell->disp_height;
|
|
|
|
|
2003-11-20 02:34:04 +08:00
|
|
|
border_x = widget->allocation.width - disp_width;
|
|
|
|
border_y = widget->allocation.height - disp_height;
|
2003-03-11 09:22:57 +08:00
|
|
|
|
2003-11-20 02:34:04 +08:00
|
|
|
max_auto_width = (rect.width - border_x) * 0.75;
|
|
|
|
max_auto_height = (rect.height - border_y) * 0.75;
|
2003-03-11 09:22:57 +08:00
|
|
|
|
|
|
|
/* If one of the display dimensions has changed and one of the
|
|
|
|
* dimensions fits inside the screen
|
|
|
|
*/
|
2003-11-20 02:34:04 +08:00
|
|
|
if (((width + border_x) < rect.width || (height + border_y) < rect.height) &&
|
2003-03-11 09:22:57 +08:00
|
|
|
(width != disp_width || height != disp_height))
|
|
|
|
{
|
2003-11-20 02:34:04 +08:00
|
|
|
width = ((width + border_x) < rect.width) ? width : max_auto_width;
|
|
|
|
height = ((height + border_y) < rect.height) ? height : max_auto_height;
|
2003-03-11 09:22:57 +08:00
|
|
|
|
|
|
|
resize = TRUE;
|
|
|
|
}
|
2003-11-20 02:34:04 +08:00
|
|
|
|
2003-03-11 09:22:57 +08:00
|
|
|
/* If the projected dimension is greater than current, but less than
|
|
|
|
* 3/4 of the screen size, expand automagically
|
|
|
|
*/
|
|
|
|
else if ((width > disp_width || height > disp_height) &&
|
2004-07-14 18:31:59 +08:00
|
|
|
(disp_width < max_auto_width || disp_height < max_auto_height))
|
2003-03-11 09:22:57 +08:00
|
|
|
{
|
|
|
|
width = MIN (max_auto_width, width);
|
|
|
|
height = MIN (max_auto_height, height);
|
|
|
|
|
|
|
|
resize = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (resize)
|
|
|
|
{
|
2003-07-18 06:30:13 +08:00
|
|
|
if (width < shell->statusbar->requisition.width)
|
|
|
|
width = shell->statusbar->requisition.width;
|
2003-03-11 09:22:57 +08:00
|
|
|
|
|
|
|
gtk_window_resize (GTK_WINDOW (shell),
|
|
|
|
width + border_x,
|
|
|
|
height + border_y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
|
|
|
|
GimpSelectionControl control)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
|
|
|
if (shell->select)
|
|
|
|
{
|
|
|
|
switch (control)
|
2004-07-14 18:31:59 +08:00
|
|
|
{
|
|
|
|
case GIMP_SELECTION_OFF:
|
|
|
|
gimp_display_shell_selection_invis (shell->select);
|
|
|
|
break;
|
|
|
|
case GIMP_SELECTION_LAYER_OFF:
|
|
|
|
gimp_display_shell_selection_layer_invis (shell->select);
|
|
|
|
break;
|
|
|
|
case GIMP_SELECTION_ON:
|
|
|
|
gimp_display_shell_selection_start (shell->select, TRUE);
|
|
|
|
break;
|
|
|
|
case GIMP_SELECTION_PAUSE:
|
|
|
|
gimp_display_shell_selection_pause (shell->select);
|
|
|
|
break;
|
|
|
|
case GIMP_SELECTION_RESUME:
|
|
|
|
gimp_display_shell_selection_resume (shell->select);
|
|
|
|
break;
|
|
|
|
}
|
2003-03-11 09:22:57 +08:00
|
|
|
}
|
|
|
|
}
|