gimp/app/widgets/gimpdock.c

814 lines
25 KiB
C
Raw Normal View History

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdock.c
* Copyright (C) 2001-2005 Michael Natterer <mitch@gimp.org>
*
* 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>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
g_strdup() the stock_id passed to gimp_tool_info_new() because the 2002-03-14 Michael Natterer <mitch@gimp.org> * app/core/gimptoolinfo.c: g_strdup() the stock_id passed to gimp_tool_info_new() because the caller's memory may disappear after registering the tool (tool modules). Made a GimpDock out of the toolbox: * app/gui/Makefile.am * app/gui/color-area.[ch] * app/gui/indicator-area.[ch] * app/gui/toolbox.[ch]: removed... * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimptoolbox-color-area.[ch] * app/widgets/gimptoolbox-indicator-area.[ch] * app/widgets/gimptoolbox.[ch]: ...and added here. * app/widgets/gimpdock.[ch]: don't set a minimal width. Added a "destroy_if_empty" boolean so we can prevent destruction of the toolbox if it's last dockable is removed. Added gimp_dock_construct() which is called from GimpImageDock and GimpToolbox. * app/widgets/gimpimagedock.[ch]: Default to not showing the image menu, set a minimal width here, misc. minor cleanup. * app/widgets/gimpdockbook.c: some more GIMP_IS_IMAGE_DOCK() checks, fixed dnd widget creation. * app/widgets/gimpdialogfactory.[ch]: changed gimp_dialog_factories_toggle() to take just the toolbox_factory as parameter. When restoring the session use the created dock's dialog factory to create dockables, not the the factory we created the dock from (for the toolbox). * app/display/gimpdisplayshell-callbacks.c: changed accordingly. * app/gui/dialogs.[ch]: create an own dialog factory for the toolbox and set dialogs_toolbox_new() as it's new_dock_func. * app/gui/dialogs-constructors.[ch]: changed dialogs_toolbox_get() accordingly. * app/gui/dialogs-commands.[ch]: added dialogs_show_toolbox(), ckeck if a dock is really a GimpImageDock before casting. * app/gui/gui.c * app/gui/menus.c * app/widgets/gimppaletteeditor.c: changed accordingly. * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/palette-editor-commands.c: removed useless inclusion of "gui/color-area.h". * themes/Default/gtkrc: set "gimp-dock-style" for GimpToolbox widgets.
2002-03-15 01:07:02 +08:00
#include "core/gimpcontext.h"
#include "core/gimpmarshal.h"
g_strdup() the stock_id passed to gimp_tool_info_new() because the 2002-03-14 Michael Natterer <mitch@gimp.org> * app/core/gimptoolinfo.c: g_strdup() the stock_id passed to gimp_tool_info_new() because the caller's memory may disappear after registering the tool (tool modules). Made a GimpDock out of the toolbox: * app/gui/Makefile.am * app/gui/color-area.[ch] * app/gui/indicator-area.[ch] * app/gui/toolbox.[ch]: removed... * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimptoolbox-color-area.[ch] * app/widgets/gimptoolbox-indicator-area.[ch] * app/widgets/gimptoolbox.[ch]: ...and added here. * app/widgets/gimpdock.[ch]: don't set a minimal width. Added a "destroy_if_empty" boolean so we can prevent destruction of the toolbox if it's last dockable is removed. Added gimp_dock_construct() which is called from GimpImageDock and GimpToolbox. * app/widgets/gimpimagedock.[ch]: Default to not showing the image menu, set a minimal width here, misc. minor cleanup. * app/widgets/gimpdockbook.c: some more GIMP_IS_IMAGE_DOCK() checks, fixed dnd widget creation. * app/widgets/gimpdialogfactory.[ch]: changed gimp_dialog_factories_toggle() to take just the toolbox_factory as parameter. When restoring the session use the created dock's dialog factory to create dockables, not the the factory we created the dock from (for the toolbox). * app/display/gimpdisplayshell-callbacks.c: changed accordingly. * app/gui/dialogs.[ch]: create an own dialog factory for the toolbox and set dialogs_toolbox_new() as it's new_dock_func. * app/gui/dialogs-constructors.[ch]: changed dialogs_toolbox_get() accordingly. * app/gui/dialogs-commands.[ch]: added dialogs_show_toolbox(), ckeck if a dock is really a GimpImageDock before casting. * app/gui/gui.c * app/gui/menus.c * app/widgets/gimppaletteeditor.c: changed accordingly. * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/palette-editor-commands.c: removed useless inclusion of "gui/color-area.h". * themes/Default/gtkrc: set "gimp-dock-style" for GimpToolbox widgets.
2002-03-15 01:07:02 +08:00
#include "gimpdialogfactory.h"
#include "gimpdnd.h"
#include "gimpdock.h"
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimphelp-ids.h"
#include "gimpmessagebox.h"
#include "gimpmessagedialog.h"
#include "gimpwidgets-utils.h"
#include "gimp-intl.h"
#define DEFAULT_DOCK_HEIGHT 300
#define DEFAULT_SEPARATOR_HEIGHT 6
enum
{
PROP_0,
PROP_CONTEXT,
PROP_DIALOG_FACTORY
};
enum
{
BOOK_ADDED,
BOOK_REMOVED,
LAST_SIGNAL
};
static void gimp_dock_class_init (GimpDockClass *klass);
static void gimp_dock_init (GimpDock *dock);
static GObject * gimp_dock_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_dock_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_dock_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_dock_destroy (GtkObject *object);
static gboolean gimp_dock_delete_event (GtkWidget *widget,
GdkEventAny *event);
static gboolean gimp_dock_key_press_event (GtkWidget *widget,
GdkEventKey *kevent);
static void gimp_dock_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gimp_dock_real_book_added (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_dock_real_book_removed (GimpDock *dock,
GimpDockbook *dockbook);
static GtkWidget * gimp_dock_separator_new (GimpDock *dock);
static void gimp_dock_separator_drag_leave (GtkWidget *widget,
GdkDragContext *context,
guint time,
gpointer data);
static gboolean gimp_dock_separator_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data);
static gboolean gimp_dock_separator_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
GimpDock *dock);
static GtkWindowClass *parent_class = NULL;
static guint dock_signals[LAST_SIGNAL] = { 0 };
static GtkTargetEntry dialog_target_table[] = { GIMP_TARGET_DIALOG };
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
gimp_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;
if (! dock_type)
{
app/gimpprogress.[ch] s/GDisplay/GimpDisplay/ 2001-10-16 Michael Natterer <mitch@gimp.org> * app/gimpprogress.[ch] * app/undo.c: s/GDisplay/GimpDisplay/ * app/plug_in.[ch]: removed unused boolean "destroy" field of the PlugIn struct. * app/core/gimpedit.c: don't include "app_procs.h" * app/display/gimpdisplay-callbacks.c: moved the "grab_abd_scroll" stuff from gimpdisplay-scroll.* here (less complicated and easier to cleanup...) * app/display/gimpdisplay-scroll.[ch]: removed here. * app/display/gimpdisplay-render.[ch] * app/display/gimpdisplay-selection.[ch] * app/display/gimpdisplayshell.c: s/GDisplay/GimpDisplay/g * app/display/gimpdisplay.[ch]: ditto, removed gdisplay_active() which was just a wrapper around "gimp_context_get_display (gimp_get_user_context (the_gimp))" (which is more to type but makes the use of the global "the_gimp" variable more obvious). * app/gui/color-area.h * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/file-dialog-utils.c * app/gui/image-commands.c * app/gui/info-window.h * app/gui/paths-dialog.h * app/gui/select-commands.c * app/gui/tool-options-dialog.c * app/gui/tools-commands.c * app/gui/view-commands.c: s/GDisplay/GimpDisplay/, gdisplay_active() removal, include "app_procs.h" for "the_gimp". * app/tools/gimpbezierselecttool.h * app/tools/gimpbrightnesscontrasttool.[ch] * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.[ch] * app/tools/gimpcurvestool.[ch] * app/tools/gimpeditselectiontool.h * app/tools/gimphistogramtool.[ch] * app/tools/gimphuesaturationtool.[ch] * app/tools/gimplevelstool.[ch] * app/tools/gimpmovetool.h * app/tools/gimpperspectivetool.h * app/tools/gimpposterizetool.[ch] * app/tools/gimprotatetool.h * app/tools/gimpscaletool.h * app/tools/gimpsheartool.h * app/tools/gimptexttool.h * app/tools/gimpthresholdtool.[ch] * app/tools/gimptool.[ch] * app/tools/gimptransformtool.h * app/tools/tool_manager.[ch]: lots of s/GDisplay/GimpDisplay/, made all *_dialog_hide() functions private, cleanup. * app/widgets/*: removed GtkType and gtk_type_* stuff entirely and use GObject functions, removed lots of empty "destroy" methods and use more type checking class cast macros instead of casting directly. * app/widgets/gimpcontainermenu.c: fixed item insert order. * app/widgets/gimphistogramview.[ch]: cleaned up and renamed all functions. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_dialog_hide() as Gtk+ does the right thing (TM) now. * tools/pdbgen/pdb/color.pdb: implemented "histogram" without digging into tools/ and widgets/ (needs to be done for all color PDB functions). * tools/pdbgen/pdb/gimprc.pdb: no need to use "the_gimp" in a PDB function as a "Gimp" pointer is passed to them all. * tools/pdbgen/pdb/image.pdb: don't include "app_procs.h" * app/pdb/color_cmds.c * app/pdb/gimprc_cmds.c * app/pdb/image_cmds.c: regenerated. * app/pdb/procedural_db.c: don't include "app_procs.h"
2001-10-17 19:33:43 +08:00
static const GTypeInfo dock_info =
{
app/gimpprogress.[ch] s/GDisplay/GimpDisplay/ 2001-10-16 Michael Natterer <mitch@gimp.org> * app/gimpprogress.[ch] * app/undo.c: s/GDisplay/GimpDisplay/ * app/plug_in.[ch]: removed unused boolean "destroy" field of the PlugIn struct. * app/core/gimpedit.c: don't include "app_procs.h" * app/display/gimpdisplay-callbacks.c: moved the "grab_abd_scroll" stuff from gimpdisplay-scroll.* here (less complicated and easier to cleanup...) * app/display/gimpdisplay-scroll.[ch]: removed here. * app/display/gimpdisplay-render.[ch] * app/display/gimpdisplay-selection.[ch] * app/display/gimpdisplayshell.c: s/GDisplay/GimpDisplay/g * app/display/gimpdisplay.[ch]: ditto, removed gdisplay_active() which was just a wrapper around "gimp_context_get_display (gimp_get_user_context (the_gimp))" (which is more to type but makes the use of the global "the_gimp" variable more obvious). * app/gui/color-area.h * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/file-dialog-utils.c * app/gui/image-commands.c * app/gui/info-window.h * app/gui/paths-dialog.h * app/gui/select-commands.c * app/gui/tool-options-dialog.c * app/gui/tools-commands.c * app/gui/view-commands.c: s/GDisplay/GimpDisplay/, gdisplay_active() removal, include "app_procs.h" for "the_gimp". * app/tools/gimpbezierselecttool.h * app/tools/gimpbrightnesscontrasttool.[ch] * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.[ch] * app/tools/gimpcurvestool.[ch] * app/tools/gimpeditselectiontool.h * app/tools/gimphistogramtool.[ch] * app/tools/gimphuesaturationtool.[ch] * app/tools/gimplevelstool.[ch] * app/tools/gimpmovetool.h * app/tools/gimpperspectivetool.h * app/tools/gimpposterizetool.[ch] * app/tools/gimprotatetool.h * app/tools/gimpscaletool.h * app/tools/gimpsheartool.h * app/tools/gimptexttool.h * app/tools/gimpthresholdtool.[ch] * app/tools/gimptool.[ch] * app/tools/gimptransformtool.h * app/tools/tool_manager.[ch]: lots of s/GDisplay/GimpDisplay/, made all *_dialog_hide() functions private, cleanup. * app/widgets/*: removed GtkType and gtk_type_* stuff entirely and use GObject functions, removed lots of empty "destroy" methods and use more type checking class cast macros instead of casting directly. * app/widgets/gimpcontainermenu.c: fixed item insert order. * app/widgets/gimphistogramview.[ch]: cleaned up and renamed all functions. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_dialog_hide() as Gtk+ does the right thing (TM) now. * tools/pdbgen/pdb/color.pdb: implemented "histogram" without digging into tools/ and widgets/ (needs to be done for all color PDB functions). * tools/pdbgen/pdb/gimprc.pdb: no need to use "the_gimp" in a PDB function as a "Gimp" pointer is passed to them all. * tools/pdbgen/pdb/image.pdb: don't include "app_procs.h" * app/pdb/color_cmds.c * app/pdb/gimprc_cmds.c * app/pdb/image_cmds.c: regenerated. * app/pdb/procedural_db.c: don't include "app_procs.h"
2001-10-17 19:33:43 +08:00
sizeof (GimpDockClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_dock_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpDock),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_dock_init,
};
app/gimpprogress.[ch] s/GDisplay/GimpDisplay/ 2001-10-16 Michael Natterer <mitch@gimp.org> * app/gimpprogress.[ch] * app/undo.c: s/GDisplay/GimpDisplay/ * app/plug_in.[ch]: removed unused boolean "destroy" field of the PlugIn struct. * app/core/gimpedit.c: don't include "app_procs.h" * app/display/gimpdisplay-callbacks.c: moved the "grab_abd_scroll" stuff from gimpdisplay-scroll.* here (less complicated and easier to cleanup...) * app/display/gimpdisplay-scroll.[ch]: removed here. * app/display/gimpdisplay-render.[ch] * app/display/gimpdisplay-selection.[ch] * app/display/gimpdisplayshell.c: s/GDisplay/GimpDisplay/g * app/display/gimpdisplay.[ch]: ditto, removed gdisplay_active() which was just a wrapper around "gimp_context_get_display (gimp_get_user_context (the_gimp))" (which is more to type but makes the use of the global "the_gimp" variable more obvious). * app/gui/color-area.h * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/file-dialog-utils.c * app/gui/image-commands.c * app/gui/info-window.h * app/gui/paths-dialog.h * app/gui/select-commands.c * app/gui/tool-options-dialog.c * app/gui/tools-commands.c * app/gui/view-commands.c: s/GDisplay/GimpDisplay/, gdisplay_active() removal, include "app_procs.h" for "the_gimp". * app/tools/gimpbezierselecttool.h * app/tools/gimpbrightnesscontrasttool.[ch] * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.[ch] * app/tools/gimpcurvestool.[ch] * app/tools/gimpeditselectiontool.h * app/tools/gimphistogramtool.[ch] * app/tools/gimphuesaturationtool.[ch] * app/tools/gimplevelstool.[ch] * app/tools/gimpmovetool.h * app/tools/gimpperspectivetool.h * app/tools/gimpposterizetool.[ch] * app/tools/gimprotatetool.h * app/tools/gimpscaletool.h * app/tools/gimpsheartool.h * app/tools/gimptexttool.h * app/tools/gimpthresholdtool.[ch] * app/tools/gimptool.[ch] * app/tools/gimptransformtool.h * app/tools/tool_manager.[ch]: lots of s/GDisplay/GimpDisplay/, made all *_dialog_hide() functions private, cleanup. * app/widgets/*: removed GtkType and gtk_type_* stuff entirely and use GObject functions, removed lots of empty "destroy" methods and use more type checking class cast macros instead of casting directly. * app/widgets/gimpcontainermenu.c: fixed item insert order. * app/widgets/gimphistogramview.[ch]: cleaned up and renamed all functions. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_dialog_hide() as Gtk+ does the right thing (TM) now. * tools/pdbgen/pdb/color.pdb: implemented "histogram" without digging into tools/ and widgets/ (needs to be done for all color PDB functions). * tools/pdbgen/pdb/gimprc.pdb: no need to use "the_gimp" in a PDB function as a "Gimp" pointer is passed to them all. * tools/pdbgen/pdb/image.pdb: don't include "app_procs.h" * app/pdb/color_cmds.c * app/pdb/gimprc_cmds.c * app/pdb/image_cmds.c: regenerated. * app/pdb/procedural_db.c: don't include "app_procs.h"
2001-10-17 19:33:43 +08:00
dock_type = g_type_register_static (GTK_TYPE_WINDOW,
"GimpDock",
&dock_info, 0);
}
return dock_type;
}
static void
gimp_dock_class_init (GimpDockClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
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);
dock_signals[BOOK_ADDED] =
g_signal_new ("book-added",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpDockClass, book_added),
NULL, NULL,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GIMP_TYPE_DOCKBOOK);
dock_signals[BOOK_REMOVED] =
g_signal_new ("book-removed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpDockClass, book_removed),
NULL, NULL,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GIMP_TYPE_DOCKBOOK);
object_class->constructor = gimp_dock_constructor;
object_class->set_property = gimp_dock_set_property;
object_class->get_property = gimp_dock_get_property;
gtk_object_class->destroy = gimp_dock_destroy;
widget_class->delete_event = gimp_dock_delete_event;
widget_class->key_press_event = gimp_dock_key_press_event;
widget_class->style_set = gimp_dock_style_set;
klass->setup = NULL;
klass->book_added = gimp_dock_real_book_added;
klass->book_removed = gimp_dock_real_book_removed;
g_object_class_install_property (object_class, PROP_CONTEXT,
g_param_spec_object ("context", NULL, NULL,
GIMP_TYPE_CONTEXT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_DIALOG_FACTORY,
g_param_spec_object ("dialog-factory", NULL, NULL,
GIMP_TYPE_DIALOG_FACTORY,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("default-height",
NULL, NULL,
-1,
G_MAXINT,
DEFAULT_DOCK_HEIGHT,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("separator-height",
NULL, NULL,
0,
G_MAXINT,
DEFAULT_SEPARATOR_HEIGHT,
G_PARAM_READABLE));
}
static void
gimp_dock_init (GimpDock *dock)
{
GtkWidget *separator;
dock->context = NULL;
dock->dialog_factory = NULL;
added "wm_name", "wm_class", "display_name" and "monitor_number" to the 2003-11-07 Michael Natterer <mitch@gimp.org> * libgimpbase/gimpprotocol.[ch]: added "wm_name", "wm_class", "display_name" and "monitor_number" to the GPConfig message. Increased protocol version number. * libgimp/gimp.[ch] (gimp_config): read them from the GPConfig message and remember them. Added public accessors for the new config values. * libgimp/gimpui.c (gimp_ui_init): pass wm_name and wm_class to gtk_init() and export the display/screen to use to the environment. * app/core/gimp.[ch]: added vtable entries to get the values from the GUI. * app/gui/gui-vtable.c: implement the vtable entries. * app/plug-in/plug-in-run.c: fill in the GPConfig values using the new Gimp vtable functions. * app/display/gimpdisplayshell-layer-select.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-dialog-utils.[ch] * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor-commands.c * app/gui/gradients-commands.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-dialog.[ch] * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/splash.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/tips-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcurvestool.c * app/tools/gimplevelstool.c * app/widgets/gimpdock.c * app/widgets/gimperrorconsole.c * app/widgets/gimptexteditor.c * app/widgets/gimptoolbox.c * app/widgets/gimpviewabledialog.[ch] * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c * plug-ins/helpbrowser/dialog.c * plug-ins/ifscompose/ifscompose.c: replaced all calls to gtk_window_set_wmclass() by gtk_window_set_role() and all "const gchar *wmclass_name" parameters by "const gchar *role". Cleaned up the window role strings.
2003-11-08 01:29:02 +08:00
gtk_window_set_role (GTK_WINDOW (dock), "gimp-dock");
CPPFLAGS: added -DGTK_DISABLE_DEPRECATED 2002-01-25 Michael Natterer <mitch@gimp.org> * configure.in: CPPFLAGS: added -DGTK_DISABLE_DEPRECATED * libgimpwidgets/gimpdialog.c: still use the deprecated gtk_window_set_policy() but spit out a #warning. * app/widgets/widgets-types.h * app/widgets/gimpitemfactory.[ch]: made it a GtkItemFactory subclass. This way we can reproduce the effect of gtk_item_factory_get_from_path() which is deprectated for good reasons. For GIMP, using it its perfectly OK since we only have one item factory per "<prefix>". * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdatafactoryview.[ch] * app/widgets/gimpdialogfactory.[ch] * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdocumentview.[ch] * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimppreview.c * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell.[ch]: pass around GimpItemFactory pointers instead of "const gchar *" item factory identifiers. Replaced gtk_window_set_policy() by gtk_window_set_resizable() and other recommended stuff. * app/gui/about-dialog.c * app/gui/dialogs-constructors.c * app/gui/dialogs.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/menus.c * app/gui/offset-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c: lots of s/gtk_item_factory_from_path/gimp_item_factory_from_path/, gtk_window_set_policy() replacements, misc fixes. * plug-ins/gdyntext/charmap_window.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_main.c: replaced gtk_window_set_policy().
2002-01-26 02:34:33 +08:00
gtk_window_set_resizable (GTK_WINDOW (dock), TRUE);
cleanup. 2001-04-22 Michael Natterer <mitch@gimp.org> * app/Makefile.am: cleanup. * app/interface.c: #include "gimpui.h" * app/gui/dialogs-constructors.[ch] * app/gui/dialogs.c * app/gui/menus.c * app/gui/test-commands.[ch]: changes for the image menu below. * app/apptypes.h * app/widgets/Makefile.am * app/widgets/gimpcontainermenu.[ch] * app/widgets/gimpcontainermenuimpl.[ch]: new widgets. The actual implemtation lives in a separate file because gimpcontainermenu.c's code is identical to gimpcontainerview.c's except for the base class. This will become an interface with Gtk 2.0. * app/widgets/gimpimagedock.[ch]: a dock with an image menu. The pages still don't follow the context correctly. * app/widgets/gimpmenuitem.[ch]: a menu item with a preview. * app/widgets/gimpdialogfactory.[ch]: pass a dock constructor to the constructor and provide a method to create a new dock within this factory's context. * app/widgets/gimpdock.[ch]: removed the constructor because we create only image docks now. Put the vbox into a main_vbox (which also contains the image menu). * app/widgets/gimpdockbook.[ch]: create new docks with the dialog factory. * app/gimpcontainer.[ch] * app/gimpdata.[ch] * app/gimpdatafactory.[ch] * app/gimpdatalist.[ch] * app/gimplist.[ch] * app/gimpviewable.[ch] * app/widgets/gimpbrushpreview.[ch] * app/widgets/gimpcontainergridview.[ch] * app/widgets/gimpcontainerlistview.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdatafactoryview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistitem.[ch] * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimpdrawablepreview.[ch] * app/widgets/gimplayerlistitem.[ch] * app/widgets/gimplayerlistview.[ch] * app/widgets/gimplistitem.[ch] * app/widgets/gimppalettepreview.[ch] * app/widgets/gimppatternpreview.[ch] * app/widgets/gimppreview.[ch]: ass-sign some copyrights.
2001-04-22 08:38:56 +08:00
dock->main_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (dock), dock->main_vbox);
gtk_widget_show (dock->main_vbox);
dock->vbox = gtk_vbox_new (FALSE, 0);
cleanup. 2001-04-22 Michael Natterer <mitch@gimp.org> * app/Makefile.am: cleanup. * app/interface.c: #include "gimpui.h" * app/gui/dialogs-constructors.[ch] * app/gui/dialogs.c * app/gui/menus.c * app/gui/test-commands.[ch]: changes for the image menu below. * app/apptypes.h * app/widgets/Makefile.am * app/widgets/gimpcontainermenu.[ch] * app/widgets/gimpcontainermenuimpl.[ch]: new widgets. The actual implemtation lives in a separate file because gimpcontainermenu.c's code is identical to gimpcontainerview.c's except for the base class. This will become an interface with Gtk 2.0. * app/widgets/gimpimagedock.[ch]: a dock with an image menu. The pages still don't follow the context correctly. * app/widgets/gimpmenuitem.[ch]: a menu item with a preview. * app/widgets/gimpdialogfactory.[ch]: pass a dock constructor to the constructor and provide a method to create a new dock within this factory's context. * app/widgets/gimpdock.[ch]: removed the constructor because we create only image docks now. Put the vbox into a main_vbox (which also contains the image menu). * app/widgets/gimpdockbook.[ch]: create new docks with the dialog factory. * app/gimpcontainer.[ch] * app/gimpdata.[ch] * app/gimpdatafactory.[ch] * app/gimpdatalist.[ch] * app/gimplist.[ch] * app/gimpviewable.[ch] * app/widgets/gimpbrushpreview.[ch] * app/widgets/gimpcontainergridview.[ch] * app/widgets/gimpcontainerlistview.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdatafactoryview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistitem.[ch] * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimpdrawablepreview.[ch] * app/widgets/gimplayerlistitem.[ch] * app/widgets/gimplayerlistview.[ch] * app/widgets/gimplistitem.[ch] * app/widgets/gimppalettepreview.[ch] * app/widgets/gimppatternpreview.[ch] * app/widgets/gimppreview.[ch]: ass-sign some copyrights.
2001-04-22 08:38:56 +08:00
gtk_container_add (GTK_CONTAINER (dock->main_vbox), dock->vbox);
gtk_widget_show (dock->vbox);
separator = gimp_dock_separator_new (dock);
gtk_box_pack_start (GTK_BOX (dock->vbox), separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
}
static GObject *
gimp_dock_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpDock *dock;
GimpGuiConfig *config;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
dock = GIMP_DOCK (object);
g_assert (GIMP_IS_CONTEXT (dock->context));
g_assert (GIMP_IS_DIALOG_FACTORY (dock->dialog_factory));
config = GIMP_GUI_CONFIG (dock->context->gimp->config);
gimp_window_set_hint (GTK_WINDOW (dock), config->dock_window_hint);
return object;
}
static void
gimp_dock_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpDock *dock = GIMP_DOCK (object);
switch (property_id)
{
case PROP_CONTEXT:
dock->context = GIMP_CONTEXT (g_value_dup_object (value));
break;
case PROP_DIALOG_FACTORY:
dock->dialog_factory = GIMP_DIALOG_FACTORY (g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_dock_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpDock *dock = GIMP_DOCK (object);
switch (property_id)
{
case PROP_CONTEXT:
g_value_set_object (value, dock->context);
break;
case PROP_DIALOG_FACTORY:
g_value_set_object (value, dock->dialog_factory);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_dock_destroy (GtkObject *object)
{
GimpDock *dock = GIMP_DOCK (object);
while (dock->dockbooks)
gimp_dock_remove_book (dock, GIMP_DOCKBOOK (dock->dockbooks->data));
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
if (dock->context)
{
g_object_unref (dock->context);
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
dock->context = NULL;
}
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static gboolean
gimp_dock_delete_event (GtkWidget *widget,
GdkEventAny *event)
{
GimpDock *dock = GIMP_DOCK (widget);
gboolean retval = FALSE;
GList *list;
gint n;
for (list = dock->dockbooks, n = 0; list; list = list->next)
n += gtk_notebook_get_n_pages (GTK_NOTEBOOK (list->data));
if (n > 1)
{
GtkWidget *dialog =
gimp_message_dialog_new (_("Close all Tabs?"),
GIMP_STOCK_WARNING,
widget, GTK_DIALOG_MODAL,
NULL, NULL,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("Close all Tabs"), GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
_("Close all tabs?"));
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
_("This window has %d tabs open. Closing the "
"window will also close all its tabs."), n);
retval = (gimp_dialog_run (GIMP_DIALOG (dialog)) != GTK_RESPONSE_OK);
gtk_widget_destroy (dialog);
}
return retval;
}
static gboolean
gimp_dock_key_press_event (GtkWidget *widget,
GdkEventKey *event)
{
GtkWindow *window = GTK_WINDOW (widget);
gboolean handled = FALSE;
/* we're overriding the GtkWindow implementation here to give
* the focus widget precedence over unmodified accelerators
* before the accelerator activation scheme.
*/
/* invoke control/alt accelerators */
if (! handled && event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
handled = gtk_window_activate_key (window, event);
/* invoke focus widget handlers */
if (! handled)
handled = gtk_window_propagate_key_event (window, event);
/* invoke non-(control/alt) accelerators */
if (! handled && ! (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
handled = gtk_window_activate_key (window, event);
/* chain up, bypassing gtk_window_key_press(), to invoke binding set */
if (! handled)
handled = GTK_WIDGET_CLASS (g_type_class_peek (g_type_parent (GTK_TYPE_WINDOW)))->key_press_event (widget, event);
return handled;
}
static void
gimp_dock_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
GimpDock *dock = GIMP_DOCK (widget);
GList *children;
GList *list;
gint default_height;
gint separator_height;
if (GTK_WIDGET_CLASS (parent_class)->style_set)
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
gtk_widget_style_get (widget,
"default-height", &default_height,
"separator-height", &separator_height,
NULL);
gtk_window_set_default_size (GTK_WINDOW (widget), -1, default_height);
children = gtk_container_get_children (GTK_CONTAINER (dock->vbox));
for (list = children; list; list = g_list_next (list))
{
if (GTK_IS_EVENT_BOX (list->data))
gtk_widget_set_size_request (GTK_WIDGET (list->data),
-1, separator_height);
}
g_list_free (children);
}
static void
gimp_dock_real_book_added (GimpDock *dock,
GimpDockbook *dockbook)
{
}
static void
gimp_dock_real_book_removed (GimpDock *dock,
GimpDockbook *dockbook)
{
if (dock->dockbooks == NULL)
gtk_widget_destroy (GTK_WIDGET (dock));
}
/* public functions */
void
gimp_dock_setup (GimpDock *dock,
const GimpDock *template)
{
g_return_if_fail (GIMP_IS_DOCK (dock));
g_return_if_fail (GIMP_IS_DOCK (template));
if (GIMP_DOCK_GET_CLASS (dock)->setup)
GIMP_DOCK_GET_CLASS (dock)->setup (dock, template);
}
void
gimp_dock_set_aux_info (GimpDock *dock,
GList *aux_info)
{
g_return_if_fail (GIMP_IS_DOCK (dock));
if (GIMP_DOCK_GET_CLASS (dock)->set_aux_info)
GIMP_DOCK_GET_CLASS (dock)->set_aux_info (dock, aux_info);
}
GList *
gimp_dock_get_aux_info (GimpDock *dock)
{
g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL);
if (GIMP_DOCK_GET_CLASS (dock)->get_aux_info)
return GIMP_DOCK_GET_CLASS (dock)->get_aux_info (dock);
return NULL;
}
void
gimp_dock_add (GimpDock *dock,
GimpDockable *dockable,
gint section,
gint position)
{
GimpDockbook *dockbook;
g_return_if_fail (GIMP_IS_DOCK (dock));
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
g_return_if_fail (dockable->dockbook == NULL);
dockbook = GIMP_DOCKBOOK (dock->dockbooks->data);
gimp_dockbook_add (dockbook, dockable, position);
}
void
gimp_dock_remove (GimpDock *dock,
GimpDockable *dockable)
{
g_return_if_fail (GIMP_IS_DOCK (dock));
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
g_return_if_fail (dockable->dockbook != NULL);
g_return_if_fail (dockable->dockbook->dock == dock);
gimp_dockbook_remove (dockable->dockbook, dockable);
}
void
gimp_dock_add_book (GimpDock *dock,
GimpDockbook *dockbook,
gint index)
{
gint old_length;
g_return_if_fail (GIMP_IS_DOCK (dock));
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
g_return_if_fail (dockbook->dock == NULL);
old_length = g_list_length (dock->dockbooks);
if (index >= old_length || index < 0)
index = old_length;
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
dockbook->dock = dock;
dock->dockbooks = g_list_insert (dock->dockbooks, dockbook, index);
if (old_length == 0)
{
GtkWidget *separator;
gtk_box_pack_start (GTK_BOX (dock->vbox), GTK_WIDGET (dockbook),
TRUE, TRUE, 0);
separator = gimp_dock_separator_new (dock);
gtk_box_pack_end (GTK_BOX (dock->vbox), separator, FALSE, FALSE, 0);
gtk_widget_show (separator);
}
else
{
GtkWidget *old_book;
GtkWidget *parent;
GtkWidget *paned;
if (index == 0)
old_book = g_list_nth_data (dock->dockbooks, index + 1);
else
old_book = g_list_nth_data (dock->dockbooks, index - 1);
parent = old_book->parent;
if ((old_length > 1) && (index > 0))
{
GtkWidget *grandparent;
grandparent = parent->parent;
old_book = parent;
parent = grandparent;
}
g_object_ref (old_book);
gtk_container_remove (GTK_CONTAINER (parent), old_book);
paned = gtk_vpaned_new ();
if (GTK_IS_VPANED (parent))
gtk_paned_pack1 (GTK_PANED (parent), paned, TRUE, FALSE);
else
gtk_box_pack_start (GTK_BOX (parent), paned, TRUE, TRUE, 0);
gtk_widget_show (paned);
if (index == 0)
{
gtk_paned_pack1 (GTK_PANED (paned), GTK_WIDGET (dockbook),
TRUE, FALSE);
gtk_paned_pack2 (GTK_PANED (paned), old_book,
TRUE, FALSE);
}
else
{
gtk_paned_pack1 (GTK_PANED (paned), old_book,
TRUE, FALSE);
gtk_paned_pack2 (GTK_PANED (paned), GTK_WIDGET (dockbook),
TRUE, FALSE);
}
g_object_unref (old_book);
}
gtk_widget_show (GTK_WIDGET (dockbook));
g_signal_emit (dock, dock_signals[BOOK_ADDED], 0, dockbook);
}
void
gimp_dock_remove_book (GimpDock *dock,
GimpDockbook *dockbook)
{
gint old_length;
gint index;
g_return_if_fail (GIMP_IS_DOCK (dock));
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
g_return_if_fail (dockbook->dock == dock);
old_length = g_list_length (dock->dockbooks);
index = g_list_index (dock->dockbooks, dockbook);
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
dockbook->dock = NULL;
dock->dockbooks = g_list_remove (dock->dockbooks, dockbook);
g_object_ref (dockbook);
if (old_length == 1)
{
GtkWidget *separator;
GList *children;
children = gtk_container_get_children (GTK_CONTAINER (dock->vbox));
separator = g_list_nth_data (children, 2);
gtk_container_remove (GTK_CONTAINER (dock->vbox), separator);
gtk_container_remove (GTK_CONTAINER (dock->vbox), GTK_WIDGET (dockbook));
g_list_free (children);
}
g_strdup() the stock_id passed to gimp_tool_info_new() because the 2002-03-14 Michael Natterer <mitch@gimp.org> * app/core/gimptoolinfo.c: g_strdup() the stock_id passed to gimp_tool_info_new() because the caller's memory may disappear after registering the tool (tool modules). Made a GimpDock out of the toolbox: * app/gui/Makefile.am * app/gui/color-area.[ch] * app/gui/indicator-area.[ch] * app/gui/toolbox.[ch]: removed... * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimptoolbox-color-area.[ch] * app/widgets/gimptoolbox-indicator-area.[ch] * app/widgets/gimptoolbox.[ch]: ...and added here. * app/widgets/gimpdock.[ch]: don't set a minimal width. Added a "destroy_if_empty" boolean so we can prevent destruction of the toolbox if it's last dockable is removed. Added gimp_dock_construct() which is called from GimpImageDock and GimpToolbox. * app/widgets/gimpimagedock.[ch]: Default to not showing the image menu, set a minimal width here, misc. minor cleanup. * app/widgets/gimpdockbook.c: some more GIMP_IS_IMAGE_DOCK() checks, fixed dnd widget creation. * app/widgets/gimpdialogfactory.[ch]: changed gimp_dialog_factories_toggle() to take just the toolbox_factory as parameter. When restoring the session use the created dock's dialog factory to create dockables, not the the factory we created the dock from (for the toolbox). * app/display/gimpdisplayshell-callbacks.c: changed accordingly. * app/gui/dialogs.[ch]: create an own dialog factory for the toolbox and set dialogs_toolbox_new() as it's new_dock_func. * app/gui/dialogs-constructors.[ch]: changed dialogs_toolbox_get() accordingly. * app/gui/dialogs-commands.[ch]: added dialogs_show_toolbox(), ckeck if a dock is really a GimpImageDock before casting. * app/gui/gui.c * app/gui/menus.c * app/widgets/gimppaletteeditor.c: changed accordingly. * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/palette-editor-commands.c: removed useless inclusion of "gui/color-area.h". * themes/Default/gtkrc: set "gimp-dock-style" for GimpToolbox widgets.
2002-03-15 01:07:02 +08:00
else
{
GtkWidget *other_book;
GtkWidget *parent;
GtkWidget *grandparent;
parent = GTK_WIDGET (dockbook)->parent;
grandparent = parent->parent;
if (index == 0)
other_book = GTK_PANED (parent)->child2;
else
other_book = GTK_PANED (parent)->child1;
g_object_ref (other_book);
gtk_container_remove (GTK_CONTAINER (parent), other_book);
gtk_container_remove (GTK_CONTAINER (parent), GTK_WIDGET (dockbook));
gtk_container_remove (GTK_CONTAINER (grandparent), parent);
if (GTK_IS_VPANED (grandparent))
gtk_paned_pack1 (GTK_PANED (grandparent), other_book, TRUE, FALSE);
else
gtk_box_pack_start (GTK_BOX (dock->vbox), other_book, TRUE, TRUE, 0);
g_object_unref (other_book);
}
g_signal_emit (dock, dock_signals[BOOK_REMOVED], 0, dockbook);
g_object_unref (dockbook);
}
/* private functions */
static GtkWidget *
gimp_dock_separator_new (GimpDock *dock)
{
GtkWidget *event_box;
GtkWidget *frame;
gint separator_height;
event_box = gtk_event_box_new ();
gtk_widget_set_name (event_box, "gimp-dock-separator");
gtk_widget_style_get (GTK_WIDGET (dock),
"separator-height", &separator_height,
NULL);
gtk_widget_set_size_request (event_box, -1, separator_height);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_container_add (GTK_CONTAINER (event_box), frame);
gtk_widget_show (frame);
gimp_help_set_help_data (event_box,
_("You can drop dockable dialogs here."),
GIMP_HELP_DOCK_SEPARATOR);
gtk_drag_dest_set (GTK_WIDGET (event_box),
GTK_DEST_DEFAULT_ALL,
dialog_target_table, G_N_ELEMENTS (dialog_target_table),
GDK_ACTION_MOVE);
g_signal_connect (event_box, "drag-leave",
G_CALLBACK (gimp_dock_separator_drag_leave),
NULL);
g_signal_connect (event_box, "drag-motion",
G_CALLBACK (gimp_dock_separator_drag_motion),
NULL);
g_signal_connect (event_box, "drag-drop",
G_CALLBACK (gimp_dock_separator_drag_drop),
dock);
return event_box;
}
static void
gimp_dock_separator_drag_leave (GtkWidget *widget,
GdkDragContext *context,
guint time,
gpointer data)
{
gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, NULL);
}
static gboolean
gimp_dock_separator_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
{
GdkColor *color = gtk_widget_get_style (widget)->bg + GTK_STATE_SELECTED;
gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, color);
return FALSE;
}
static gboolean
gimp_dock_separator_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
GimpDock *dock)
{
GtkWidget *source = gtk_drag_get_source_widget (context);
if (source)
{
GimpDockable *dockable;
if (GIMP_IS_DOCKABLE (source))
dockable = GIMP_DOCKABLE (source);
else
dockable = (GimpDockable *) g_object_get_data (G_OBJECT (source),
"gimp-dockable");
if (dockable)
{
GtkWidget *dockbook;
GList *children;
gint index;
g_object_set_data (G_OBJECT (dockable),
"gimp-dock-drag-widget", NULL);
children = gtk_container_get_children (GTK_CONTAINER (widget->parent));
index = g_list_index (children, widget);
g_list_free (children);
if (index == 0)
index = 0;
else if (index == 2)
index = -1;
/* if dropping to the same dock, take care that we don't try
* to reorder the *only* dockable in the dock
*/
if (dockable->dockbook->dock == dock)
{
gint n_books;
gint n_dockables;
n_books = g_list_length (dock->dockbooks);
children =
gtk_container_get_children (GTK_CONTAINER (dockable->dockbook));
n_dockables = g_list_length (children);
g_list_free (children);
if (n_books == 1 && n_dockables == 1)
return TRUE; /* successfully do nothing */
}
g_object_ref (dockable);
gimp_dockbook_remove (dockable->dockbook, dockable);
dockbook = gimp_dockbook_new (dock->dialog_factory->menu_factory);
gimp_dock_add_book (dock, GIMP_DOCKBOOK (dockbook), index);
gimp_dockbook_add (GIMP_DOCKBOOK (dockbook), dockable, -1);
g_object_unref (dockable);
return TRUE;
}
}
return FALSE;
}