2001-04-22 08:38:56 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpimagedock.c
|
2005-05-12 04:26:12 +08:00
|
|
|
* Copyright (C) 2001-2005 Michael Natterer <mitch@gimp.org>
|
2001-04-22 08:38:56 +08:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "widgets-types.h"
|
2001-04-22 08:38:56 +08:00
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2001-07-07 20:19:21 +08:00
|
|
|
#include "core/gimp.h"
|
2005-05-12 04:26:12 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2002-05-10 21:09:19 +08:00
|
|
|
|
2001-04-22 08:38:56 +08:00
|
|
|
#include "gimpdialogfactory.h"
|
|
|
|
#include "gimpimagedock.h"
|
2005-05-12 04:26:12 +08:00
|
|
|
#include "gimpmenufactory.h"
|
|
|
|
#include "gimpuimanager.h"
|
|
|
|
|
|
|
|
|
|
|
|
static void gimp_image_dock_class_init (GimpImageDockClass *klass);
|
|
|
|
static void gimp_image_dock_init (GimpImageDock *dock);
|
|
|
|
|
|
|
|
static GObject * gimp_image_dock_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
|
|
|
|
|
|
|
static void gimp_image_dock_destroy (GtkObject *object);
|
|
|
|
|
|
|
|
static void gimp_image_dock_display_changed (GimpContext *context,
|
|
|
|
GimpObject *display,
|
|
|
|
GimpImageDock *dock);
|
|
|
|
static void gimp_image_dock_image_flush (GimpImage *image,
|
|
|
|
GimpImageDock *dock);
|
2001-04-22 08:38:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
static GimpDockClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
GType
|
2001-04-22 08:38:56 +08:00
|
|
|
gimp_image_dock_get_type (void)
|
|
|
|
{
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
static GType dock_type = 0;
|
2001-04-22 08:38:56 +08:00
|
|
|
|
|
|
|
if (! dock_type)
|
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
static const GTypeInfo dock_info =
|
2001-04-22 08:38:56 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
sizeof (GimpImageDockClass),
|
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
|
|
|
(GClassInitFunc) gimp_image_dock_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpImageDock),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_image_dock_init,
|
2001-04-22 08:38:56 +08:00
|
|
|
};
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
dock_type = g_type_register_static (GIMP_TYPE_DOCK,
|
|
|
|
"GimpImageDock",
|
|
|
|
&dock_info, 0);
|
2001-04-22 08:38:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return dock_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_dock_class_init (GimpImageDockClass *klass)
|
|
|
|
{
|
2005-02-01 00:09:52 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
|
2001-04-22 08:38:56 +08:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-04-22 08:38:56 +08:00
|
|
|
|
2004-02-01 04:23:53 +08:00
|
|
|
object_class->constructor = gimp_image_dock_constructor;
|
2003-05-03 19:59:44 +08:00
|
|
|
|
2004-02-01 04:23:53 +08:00
|
|
|
gtk_object_class->destroy = gimp_image_dock_destroy;
|
2002-03-19 03:34:06 +08:00
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
klass->ui_manager_name = "<Dock>";
|
2001-04-22 08:38:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_dock_init (GimpImageDock *dock)
|
|
|
|
{
|
2005-05-12 04:26:12 +08:00
|
|
|
dock->ui_manager = NULL;
|
|
|
|
dock->image_flush_handler_id = 0;
|
2001-04-22 08:38:56 +08:00
|
|
|
}
|
|
|
|
|
2004-02-01 04:23:53 +08:00
|
|
|
static GObject *
|
|
|
|
gimp_image_dock_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
2001-04-22 08:38:56 +08:00
|
|
|
{
|
2005-02-01 00:09:52 +08:00
|
|
|
GObject *object;
|
|
|
|
GimpImageDock *dock;
|
2005-05-12 04:26:12 +08:00
|
|
|
GimpGuiConfig *config;
|
|
|
|
GtkAccelGroup *accel_group;
|
2004-02-01 04:23:53 +08:00
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
2001-04-22 08:38:56 +08:00
|
|
|
|
|
|
|
dock = GIMP_IMAGE_DOCK (object);
|
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
config = GIMP_GUI_CONFIG (GIMP_DOCK (dock)->context->gimp->config);
|
2004-02-01 04:23:53 +08:00
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
dock->ui_manager =
|
|
|
|
gimp_menu_factory_manager_new (GIMP_DOCK (dock)->dialog_factory->menu_factory,
|
|
|
|
GIMP_IMAGE_DOCK_GET_CLASS (dock)->ui_manager_name,
|
|
|
|
dock,
|
|
|
|
config->tearoff_menus);
|
2004-02-01 04:23:53 +08:00
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
accel_group =
|
|
|
|
gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (dock->ui_manager));
|
2003-05-03 19:59:44 +08:00
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (object), accel_group);
|
2001-04-24 00:58:18 +08:00
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
dock->image_flush_handler_id =
|
|
|
|
gimp_container_add_handler (GIMP_DOCK (dock)->context->gimp->images, "flush",
|
|
|
|
G_CALLBACK (gimp_image_dock_image_flush),
|
|
|
|
dock);
|
2001-04-22 08:38:56 +08:00
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
g_signal_connect_object (GIMP_DOCK (dock)->context, "display-changed",
|
|
|
|
G_CALLBACK (gimp_image_dock_display_changed),
|
|
|
|
dock, 0);
|
2003-10-08 23:44:35 +08:00
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
return object;
|
2003-05-03 19:59:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-05-12 04:26:12 +08:00
|
|
|
gimp_image_dock_destroy (GtkObject *object)
|
2003-05-03 19:59:44 +08:00
|
|
|
{
|
2005-05-12 04:26:12 +08:00
|
|
|
GimpImageDock *dock = GIMP_IMAGE_DOCK (object);
|
2003-05-03 19:59:44 +08:00
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
if (dock->image_flush_handler_id)
|
2002-05-08 20:39:01 +08:00
|
|
|
{
|
2005-05-12 04:26:12 +08:00
|
|
|
gimp_container_remove_handler (GIMP_DOCK (dock)->context->gimp->images,
|
|
|
|
dock->image_flush_handler_id);
|
|
|
|
dock->image_flush_handler_id = 0;
|
2002-05-08 20:39:01 +08:00
|
|
|
}
|
2001-05-07 00:14:34 +08:00
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
if (dock->ui_manager)
|
2003-05-03 19:59:44 +08:00
|
|
|
{
|
2005-05-12 04:26:12 +08:00
|
|
|
g_object_unref (dock->ui_manager);
|
|
|
|
dock->ui_manager = NULL;
|
2003-05-03 19:59:44 +08:00
|
|
|
}
|
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
2002-05-08 00:23:14 +08:00
|
|
|
}
|
|
|
|
|
2001-04-24 00:58:18 +08:00
|
|
|
static void
|
2005-05-12 04:26:12 +08:00
|
|
|
gimp_image_dock_display_changed (GimpContext *context,
|
|
|
|
GimpObject *display,
|
|
|
|
GimpImageDock *dock)
|
2001-04-24 00:58:18 +08:00
|
|
|
{
|
2005-05-12 04:26:12 +08:00
|
|
|
gimp_ui_manager_update (dock->ui_manager, display);
|
2005-05-12 06:18:47 +08:00
|
|
|
|
|
|
|
if (GIMP_GUI_CONFIG (context->gimp->config)->transient_docks)
|
|
|
|
{
|
|
|
|
GtkWindow *parent = NULL;
|
|
|
|
|
|
|
|
if (display)
|
|
|
|
g_object_get (display, "shell", &parent, NULL);
|
|
|
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dock), parent);
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
g_object_unref (parent);
|
|
|
|
}
|
2001-04-24 00:58:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-05-12 04:26:12 +08:00
|
|
|
gimp_image_dock_image_flush (GimpImage *image,
|
|
|
|
GimpImageDock *dock)
|
2001-04-24 00:58:18 +08:00
|
|
|
{
|
2005-05-12 04:26:12 +08:00
|
|
|
if (image == gimp_context_get_image (GIMP_DOCK (dock)->context))
|
2001-04-24 00:58:18 +08:00
|
|
|
{
|
2005-05-12 04:26:12 +08:00
|
|
|
GimpObject *display = gimp_context_get_display (GIMP_DOCK (dock)->context);
|
2001-04-24 00:58:18 +08:00
|
|
|
|
2005-05-12 04:26:12 +08:00
|
|
|
if (display)
|
|
|
|
gimp_ui_manager_update (dock->ui_manager, display);
|
2001-04-24 00:58:18 +08:00
|
|
|
}
|
|
|
|
}
|