gimp/app/display/gimpdisplayshell.c

581 lines
19 KiB
C
Raw Normal View History

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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-25 06:05:25 +08:00
*/
1999-03-07 20:56:03 +08:00
#include "config.h"
#include <gtk/gtk.h>
Makefile.am configure.in added the new library below. 2001-01-24 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added the new library below. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.[ch] * libgimpwidgets/gimpcolorbutton.[ch] * libgimpwidgets/gimpdialog.[ch] * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimphelpui.[ch] * libgimpwidgets/gimppatheditor.[ch] * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpquerybox.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch] * libgimpwidgets/gimpwidgets.[ch] * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgetstypes.h: new shared library. Currently there are some ugly dependencies into libgimp. These will be removed and go to a "libgimpglue" library which will be a library for functions which share a common interface between plug-ins and the app but have different implementations. Include "libgimp/gimpunit.h" from "libgimpwidgets/gimpwidgetstypes.h" to simulate this upcoming separation. * libgimp/Makefile.am * libgimp/gimpchainbutton.[ch] * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimppixmap.[ch] * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: removed from here. * libgimp/gimpui.h * libgimp/gimpuitypes.h * libgimp/makefile.mingw.in * libgimp/makefile.msc: changed accordingly. * app/[all ui files] * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: #include "libgimpwidgets/gimpwidgets.h" and removed useless includes. * app/apptypes.h: #include "libgimpwidgets/gimpwidgetstypes.h" * app/Makefile.am * plug-ins/[all makefiles which link against libgimpui]: link against libgimpwidgets.la * po-libgimp/POTFILES.in: changed file locations.
2001-01-25 06:36:18 +08:00
#include "libgimpwidgets/gimpwidgets.h"
#include "core/core-types.h"
#include "core/gimpbuffer.h"
#include "core/gimpimage.h"
removed some forgotten tools types. 2001-05-13 Michael Natterer <mitch@gimp.org> * app/apptypes.h: removed some forgotten tools types. * app/tools/tools-types.h: and added them here. * app/interface.c * app/disp_callbacks.[ch]: ported dropping of drawables to the new DND system. * app/app_procs.c * app/core/gimpdatafactory.c * app/core/gimpimage-duplicate.c * app/core/gimptoolinfo.h * app/gui/gui.c * app/tools/tool_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimplayerlistview.c: removed/fixed includes. * app/gui/brush-select.[ch] * app/gui/pattern-select.[ch]: removed the display of the current name (done by the grid view now). * app/gui/palette-select.c: fixed palette preview size. * app/gui/dialogs-constructors.c: added get_name() functions for brushes, patterns, images and palettes. * app/widgets/gimpcontainergridview.[ch]: added a label for the name of the active item. * app/widgets/gimpdnd.[ch]: removed the old drawable DND preview icon code. * tools/pdbgen/app.pl: braino: the $tool_eek hack has to be initialized to 0 at the beginning of each file, otherwise we end up including "tools/tools-types.h" everywhere. * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb: add "tools/tools-types.h" where needed. * app/pdb/color_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * app/pdb/plug_in_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/selection_cmds.c * app/pdb/undo_cmds.c * app/pdb/unit_cmds.c: regenerated.
2001-05-13 19:35:20 +08:00
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "core/gimppattern.h"
#include "widgets/gimpdnd.h"
#include "widgets/gimpwidgets-utils.h"
1997-11-25 06:05:25 +08:00
#include "disp_callbacks.h"
#include "gdisplay_ops.h"
app/Makefile.am app/gui/Makefile.am app/about_dialog.[ch] 2001-04-17 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gui/Makefile.am * app/about_dialog.[ch] * app/brush_edit.[ch] * app/brush_select.[ch] * app/channels_dialog.[ch] * app/color_area.[ch] * app/color_notebook.[ch] * app/color_select.[ch] * app/colormap_dialog.[ch] * app/commands.[ch] * app/file_new_dialog.[ch] * app/gradient_editor.[ch] * app/gradient_select.[ch] * app/indicator_area.[ch] * app/info_dialog.[ch] * app/info_window.[ch] * app/layer_select.[ch] * app/layers_dialog.[ch] * app/menus.[ch] * app/palette.[ch] * app/palette_import.[ch] * app/palette_select.[ch] * app/paths_dialog.[ch] * app/pattern_select.[ch] * app/preferences_dialog.[ch] * app/session.[ch] * app/test_commands.[ch] * app/tips_dialog.[ch] * app/toolbox.[ch]: moved to gui/ (s/_/-/ and some more useful filenames on the way). * app/app_procs.c * app/context_manager.c * app/convert.c * app/disp_callbacks.c * app/errorconsole.c * app/file-open.c * app/file-save.c * app/file-utils.c * app/gdisplay.c * app/gimage.c * app/gimprc.c * app/image_new.c * app/interface.c * app/nav_window.c * app/path.c * app/plug_in.c * app/gui/dialogs-constructors.c * app/pdb/brush_select_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/pattern_select_cmds.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpscaletool.c * app/tools/gimptransformtool.c * app/widgets/gimpcolorpanel.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/pattern_select.pdb * po/POTFILES.in: changed accordingly.
2001-04-18 05:43:29 +08:00
#include "interface.h"
#include "gui/menus.h"
#include "nav_window.h"
1997-11-25 06:05:25 +08:00
#include "gimprc.h"
#include "qmask.h"
1997-11-25 06:05:25 +08:00
#include "pixmaps/qmasksel.xpm"
#include "pixmaps/qmasknosel.xpm"
#include "pixmaps/navbutton.xpm"
1997-11-25 06:05:25 +08:00
#include "libgimp/gimpintl.h"
1997-11-25 06:05:25 +08:00
/* local functions */
static void gdisplay_destroy (GtkWidget *widget,
GDisplay *display);
static gint gdisplay_delete (GtkWidget *widget,
GdkEvent *event,
GDisplay *display);
1997-11-25 06:05:25 +08:00
static GtkTargetEntry display_target_table[] =
{
GIMP_TARGET_LAYER,
GIMP_TARGET_CHANNEL,
GIMP_TARGET_LAYER_MASK,
1999-10-10 04:33:53 +08:00
GIMP_TARGET_COLOR,
GIMP_TARGET_PATTERN,
GIMP_TARGET_BUFFER
};
static guint display_n_targets = (sizeof (display_target_table) /
sizeof (display_target_table[0]));
1997-11-25 06:05:25 +08:00
static void
new ui for the "Layer Offset" dialog. 1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de> * app/channel_ops.[ch]: new ui for the "Layer Offset" dialog. * app/channels_dialog.c * app/layers_dialog.c: major code cleanup: Folded some callbacks into common ones, "widget" instead of "w", indentation, ... * app/commands.c * app/interface.[ch] * app/global_edit.c: the query boxes must be shown by the caller now. There's no need to split up the string for the message box manually as the Gtk 1.2 label widget handles newlines corectly. Added the "edge_lock" toggle to the "Shrink Selection" dialog. Nicer spacings for the query and message boxes. * app/ink.c: tried to grab the pointer in the blob preview but failed. Left the code there as a reminder (commented out). * app/menus.c: reordered <Image>/Select. I was bored and grep-ed the sources for ancient or deprecated stuff: * app/about_dialog.[ch] * app/actionarea.[ch] * app/app_procs.c * app/brush_edit.c * app/brush_select.c * app/color_select.c * app/convert.c * app/devices.c * app/gdisplay.c * app/gdisplay_ops.c * app/histogram_tool.[ch] * app/info_window.c * app/install.c * app/ops_buttons.c * app/palette.c * app/palette_select.c * app/paths_dialog.c * app/pattern_select.c * app/resize.c * app/scale_toolc.c * app/text_tool.c: s/container_border_width/container_set_border_width/g, s/sprintf/g_snprintf/g, replaced some constant string lengths with strlen(x). * app/bezier_select.c * app/blend.c * app/boundary.c * app/errors.[ch] * app/free_select.c * app/gimpbrushlist.c * app/gimprc.c * app/iscissors.c * app/main.c * app/patterns.[ch] * app/text_tool.c: namespace fanaticism: prefixed all gimp error functions with "gimp_" and formated the messages more uniformly. * app/gradient.c * app/gradient_select.c: same stuff as above for the ui code. There are still some sub-dialogs which need cleanup. Did some cleanup in most of these files: prototypes, removed tons of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
gdisplay_destroy (GtkWidget *widget,
1997-11-25 06:05:25 +08:00
GDisplay *gdisp)
{
gdisplay_remove_and_delete (gdisp);
}
static gboolean
new ui for the "Layer Offset" dialog. 1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de> * app/channel_ops.[ch]: new ui for the "Layer Offset" dialog. * app/channels_dialog.c * app/layers_dialog.c: major code cleanup: Folded some callbacks into common ones, "widget" instead of "w", indentation, ... * app/commands.c * app/interface.[ch] * app/global_edit.c: the query boxes must be shown by the caller now. There's no need to split up the string for the message box manually as the Gtk 1.2 label widget handles newlines corectly. Added the "edge_lock" toggle to the "Shrink Selection" dialog. Nicer spacings for the query and message boxes. * app/ink.c: tried to grab the pointer in the blob preview but failed. Left the code there as a reminder (commented out). * app/menus.c: reordered <Image>/Select. I was bored and grep-ed the sources for ancient or deprecated stuff: * app/about_dialog.[ch] * app/actionarea.[ch] * app/app_procs.c * app/brush_edit.c * app/brush_select.c * app/color_select.c * app/convert.c * app/devices.c * app/gdisplay.c * app/gdisplay_ops.c * app/histogram_tool.[ch] * app/info_window.c * app/install.c * app/ops_buttons.c * app/palette.c * app/palette_select.c * app/paths_dialog.c * app/pattern_select.c * app/resize.c * app/scale_toolc.c * app/text_tool.c: s/container_border_width/container_set_border_width/g, s/sprintf/g_snprintf/g, replaced some constant string lengths with strlen(x). * app/bezier_select.c * app/blend.c * app/boundary.c * app/errors.[ch] * app/free_select.c * app/gimpbrushlist.c * app/gimprc.c * app/iscissors.c * app/main.c * app/patterns.[ch] * app/text_tool.c: namespace fanaticism: prefixed all gimp error functions with "gimp_" and formated the messages more uniformly. * app/gradient.c * app/gradient_select.c: same stuff as above for the ui code. There are still some sub-dialogs which need cleanup. Did some cleanup in most of these files: prototypes, removed tons of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
gdisplay_delete (GtkWidget *widget,
GdkEvent *event,
GDisplay *gdisp)
1997-11-25 06:05:25 +08:00
{
gdisplay_close_window (gdisp, FALSE);
return TRUE;
1997-11-25 06:05:25 +08:00
}
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
static gpointer
gdisplay_get_accel_context (gpointer data)
{
GDisplay *gdisp;
gdisp = (GDisplay *) data;
if (gdisp)
return gdisp->gimage;
return NULL;
}
1997-11-25 06:05:25 +08:00
void
create_display_shell (GDisplay *gdisp,
new ui for the "Layer Offset" dialog. 1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de> * app/channel_ops.[ch]: new ui for the "Layer Offset" dialog. * app/channels_dialog.c * app/layers_dialog.c: major code cleanup: Folded some callbacks into common ones, "widget" instead of "w", indentation, ... * app/commands.c * app/interface.[ch] * app/global_edit.c: the query boxes must be shown by the caller now. There's no need to split up the string for the message box manually as the Gtk 1.2 label widget handles newlines corectly. Added the "edge_lock" toggle to the "Shrink Selection" dialog. Nicer spacings for the query and message boxes. * app/ink.c: tried to grab the pointer in the blob preview but failed. Left the code there as a reminder (commented out). * app/menus.c: reordered <Image>/Select. I was bored and grep-ed the sources for ancient or deprecated stuff: * app/about_dialog.[ch] * app/actionarea.[ch] * app/app_procs.c * app/brush_edit.c * app/brush_select.c * app/color_select.c * app/convert.c * app/devices.c * app/gdisplay.c * app/gdisplay_ops.c * app/histogram_tool.[ch] * app/info_window.c * app/install.c * app/ops_buttons.c * app/palette.c * app/palette_select.c * app/paths_dialog.c * app/pattern_select.c * app/resize.c * app/scale_toolc.c * app/text_tool.c: s/container_border_width/container_set_border_width/g, s/sprintf/g_snprintf/g, replaced some constant string lengths with strlen(x). * app/bezier_select.c * app/blend.c * app/boundary.c * app/errors.[ch] * app/free_select.c * app/gimpbrushlist.c * app/gimprc.c * app/iscissors.c * app/main.c * app/patterns.[ch] * app/text_tool.c: namespace fanaticism: prefixed all gimp error functions with "gimp_" and formated the messages more uniformly. * app/gradient.c * app/gradient_select.c: same stuff as above for the ui code. There are still some sub-dialogs which need cleanup. Did some cleanup in most of these files: prototypes, removed tons of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
gint width,
gint height,
gchar *title,
gint type)
1997-11-25 06:05:25 +08:00
{
static GdkPixmap *qmasksel_pixmap = NULL;
static GdkBitmap *qmasksel_mask = NULL;
static GdkPixmap *qmasknosel_pixmap = NULL;
static GdkBitmap *qmasknosel_mask = NULL;
static GdkPixmap *navbutton_pixmap = NULL;
static GdkBitmap *navbutton_mask = NULL;
GtkWidget *main_vbox;
GtkWidget *disp_vbox;
GtkWidget *upper_hbox;
GtkWidget *lower_hbox;
GtkWidget *inner_table;
GtkWidget *status_hbox;
GtkWidget *arrow;
GtkWidget *pixmap;
GtkWidget *label_frame;
GtkWidget *nav_ebox;
GSList *group = NULL;
gint n_width, n_height;
gint s_width, s_height;
gint scalesrc, scaledest;
gint contextid;
1997-11-25 06:05:25 +08:00
/* adjust the initial scale -- so that window fits on screen
* the 75% value is the same as in gdisplay_shrink_wrap. It
* probably should be a user-configurable option.
*/
s_width = gdk_screen_width () * 0.75;
s_height = gdk_screen_height () * 0.75;
1997-11-25 06:05:25 +08:00
scalesrc = SCALESRC (gdisp);
scaledest = SCALEDEST (gdisp);
1997-11-25 06:05:25 +08:00
n_width = SCALEX (gdisp, width);
n_height = SCALEX (gdisp, height);
1997-11-25 06:05:25 +08:00
/* Limit to the size of the screen... */
while (n_width > s_width || n_height > s_height)
{
if (scaledest > 1)
scaledest--;
else
if (scalesrc < 0xff)
scalesrc++;
1997-11-25 06:05:25 +08:00
n_width = width *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
n_height = height *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
}
1997-11-25 06:05:25 +08:00
gdisp->scale = (scaledest << 8) + scalesrc;
1997-11-25 06:05:25 +08:00
/* the toplevel shell */
1997-11-25 06:05:25 +08:00
gdisp->shell = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_ref (gdisp->shell);
1997-11-25 06:05:25 +08:00
gtk_window_set_title (GTK_WINDOW (gdisp->shell), title);
gtk_window_set_wmclass (GTK_WINDOW (gdisp->shell), "image_window", "Gimp");
1997-11-25 06:05:25 +08:00
gtk_window_set_policy (GTK_WINDOW (gdisp->shell), TRUE, TRUE, TRUE);
gtk_object_set_user_data (GTK_OBJECT (gdisp->shell), (gpointer) gdisp);
gtk_widget_set_events (gdisp->shell, (GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK));
g_signal_connect (G_OBJECT (gdisp->shell), "delete_event",
G_CALLBACK (gdisplay_delete),
gdisp);
g_signal_connect (G_OBJECT (gdisp->shell), "destroy",
G_CALLBACK (gdisplay_destroy),
gdisp);
1997-11-25 06:05:25 +08:00
/* active display callback */
g_signal_connect (G_OBJECT (gdisp->shell), "button_press_event",
G_CALLBACK (gdisplay_shell_events),
gdisp);
g_signal_connect (G_OBJECT (gdisp->shell), "key_press_event",
G_CALLBACK (gdisplay_shell_events),
gdisp);
/* dnd stuff */
gtk_drag_dest_set (gdisp->shell,
GTK_DEST_DEFAULT_ALL,
display_target_table, display_n_targets,
GDK_ACTION_COPY);
removed some forgotten tools types. 2001-05-13 Michael Natterer <mitch@gimp.org> * app/apptypes.h: removed some forgotten tools types. * app/tools/tools-types.h: and added them here. * app/interface.c * app/disp_callbacks.[ch]: ported dropping of drawables to the new DND system. * app/app_procs.c * app/core/gimpdatafactory.c * app/core/gimpimage-duplicate.c * app/core/gimptoolinfo.h * app/gui/gui.c * app/tools/tool_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimplayerlistview.c: removed/fixed includes. * app/gui/brush-select.[ch] * app/gui/pattern-select.[ch]: removed the display of the current name (done by the grid view now). * app/gui/palette-select.c: fixed palette preview size. * app/gui/dialogs-constructors.c: added get_name() functions for brushes, patterns, images and palettes. * app/widgets/gimpcontainergridview.[ch]: added a label for the name of the active item. * app/widgets/gimpdnd.[ch]: removed the old drawable DND preview icon code. * tools/pdbgen/app.pl: braino: the $tool_eek hack has to be initialized to 0 at the beginning of each file, otherwise we end up including "tools/tools-types.h" everywhere. * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb: add "tools/tools-types.h" where needed. * app/pdb/color_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * app/pdb/plug_in_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/selection_cmds.c * app/pdb/undo_cmds.c * app/pdb/unit_cmds.c: regenerated.
2001-05-13 19:35:20 +08:00
gimp_dnd_viewable_dest_set (gdisp->shell, GIMP_TYPE_LAYER,
gdisplay_drop_drawable, gdisp);
gimp_dnd_viewable_dest_set (gdisp->shell, GIMP_TYPE_LAYER_MASK,
gdisplay_drop_drawable, gdisp);
gimp_dnd_viewable_dest_set (gdisp->shell, GIMP_TYPE_CHANNEL,
gdisplay_drop_drawable, gdisp);
gimp_dnd_viewable_dest_set (gdisp->shell, GIMP_TYPE_PATTERN,
gdisplay_drop_pattern, gdisp);
gimp_dnd_viewable_dest_set (gdisp->shell, GIMP_TYPE_BUFFER,
gdisplay_drop_buffer, gdisp);
removed some forgotten tools types. 2001-05-13 Michael Natterer <mitch@gimp.org> * app/apptypes.h: removed some forgotten tools types. * app/tools/tools-types.h: and added them here. * app/interface.c * app/disp_callbacks.[ch]: ported dropping of drawables to the new DND system. * app/app_procs.c * app/core/gimpdatafactory.c * app/core/gimpimage-duplicate.c * app/core/gimptoolinfo.h * app/gui/gui.c * app/tools/tool_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimplayerlistview.c: removed/fixed includes. * app/gui/brush-select.[ch] * app/gui/pattern-select.[ch]: removed the display of the current name (done by the grid view now). * app/gui/palette-select.c: fixed palette preview size. * app/gui/dialogs-constructors.c: added get_name() functions for brushes, patterns, images and palettes. * app/widgets/gimpcontainergridview.[ch]: added a label for the name of the active item. * app/widgets/gimpdnd.[ch]: removed the old drawable DND preview icon code. * tools/pdbgen/app.pl: braino: the $tool_eek hack has to be initialized to 0 at the beginning of each file, otherwise we end up including "tools/tools-types.h" everywhere. * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb: add "tools/tools-types.h" where needed. * app/pdb/color_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * app/pdb/plug_in_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/selection_cmds.c * app/pdb/undo_cmds.c * app/pdb/unit_cmds.c: regenerated.
2001-05-13 19:35:20 +08:00
gimp_dnd_color_dest_set (gdisp->shell,
gdisplay_drop_color, gdisp);
/* the popup menu */
gdisp->ifactory = menus_get_image_factory ();
/* The accelerator table for images */
gimp_window_add_accel_group (GTK_WINDOW (gdisp->shell),
gdisp->ifactory,
gdisplay_get_accel_context,
gdisp);
/* connect the "F1" help key */
gimp_help_connect (gdisp->shell,
gimp_standard_help_func,
"image/image_window.html");
/* 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
* |
* +-- disp_vbox
* | |
* | +-- upper_hbox
* | | |
* | | +-- inner_table
* | | | |
* | | | +-- origin
* | | | +-- hruler
* | | | +-- vruler
* | | | +-- canvas
* | | |
* | | +-- vscrollbar
* | |
* | +-- lower_hbox
* | |
* | +-- qmaskoff
* | +-- qmaskon
* | +-- hscrollbar
* | +-- navbutton
* |
* +-- statusarea
* |
* +-- cursorlabel
* +-- statusbar
* +-- progressbar
* +-- cancelbutton
*/
/* first, set up the container hierarchy *********************************/
/* the vbox containing all widgets */
main_vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 2);
gtk_container_add (GTK_CONTAINER (gdisp->shell), main_vbox);
/* another vbox for everything except the statusbar */
disp_vbox = gtk_vbox_new (FALSE, 1);
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);
/* the hbox containing qmask buttons, vertical scrollbar and nav button */
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);
/* eventbox and hbox for status area */
gdisp->statusarea = gtk_event_box_new ();
gtk_box_pack_start (GTK_BOX (main_vbox), gdisp->statusarea, FALSE, FALSE, 0);
gimp_help_set_help_data (gdisp->statusarea, NULL, "#status_area");
status_hbox = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (gdisp->statusarea), status_hbox);
gtk_widget_show (status_hbox);
gtk_container_set_resize_mode (GTK_CONTAINER (status_hbox),
GTK_RESIZE_QUEUE);
/* create the scrollbars *************************************************/
/* the horizontal scrollbar */
gdisp->hsbdata =
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, width, 1, 1, width));
gdisp->hsb = gtk_hscrollbar_new (gdisp->hsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->hsb, GTK_CAN_FOCUS);
/* the vertical scrollbar */
gdisp->vsbdata =
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, height, 1, 1, height));
gdisp->vsb = gtk_vscrollbar_new (gdisp->vsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->vsb, GTK_CAN_FOCUS);
1997-11-25 06:05:25 +08:00
/* create the contents of the inner_table ********************************/
/* the menu popup button */
gdisp->origin = gtk_button_new ();
GTK_WIDGET_UNSET_FLAGS (gdisp->origin, GTK_CAN_FOCUS);
gtk_widget_set_events (GTK_WIDGET (gdisp->origin),
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
g_signal_connect (G_OBJECT (gdisp->origin), "button_press_event",
G_CALLBACK (gdisplay_origin_button_press),
gdisp);
gimp_help_set_help_data (gdisp->origin, NULL, "#origin_button");
arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
gtk_container_set_border_width (GTK_CONTAINER (gdisp->origin), 0);
gtk_container_add (GTK_CONTAINER (gdisp->origin), arrow);
gtk_widget_show (arrow);
1997-11-25 06:05:25 +08:00
/* the horizontal ruler */
1997-11-25 06:05:25 +08:00
gdisp->hrule = gtk_hruler_new ();
gtk_widget_set_events (GTK_WIDGET (gdisp->hrule),
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
g_signal_connect_swapped (G_OBJECT (gdisp->shell), "motion_notify_event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (gdisp->hrule)->motion_notify_event),
gdisp->hrule);
g_signal_connect (G_OBJECT (gdisp->hrule), "button_press_event",
G_CALLBACK (gdisplay_hruler_button_press),
gdisp);
1997-11-25 06:05:25 +08:00
gimp_help_set_help_data (gdisp->hrule, NULL, "#ruler");
/* the vertical ruler */
1997-11-25 06:05:25 +08:00
gdisp->vrule = gtk_vruler_new ();
gtk_widget_set_events (GTK_WIDGET (gdisp->vrule),
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
g_signal_connect_swapped (G_OBJECT (gdisp->shell), "motion_notify_event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (gdisp->vrule)->motion_notify_event),
gdisp->vrule);
g_signal_connect (G_OBJECT (gdisp->vrule), "button_press_event",
G_CALLBACK (gdisplay_vruler_button_press),
gdisp);
1997-11-25 06:05:25 +08:00
gimp_help_set_help_data (gdisp->vrule, NULL, "#ruler");
/* the canvas */
gdisp->canvas = gtk_drawing_area_new ();
gtk_widget_set_name (gdisp->canvas, "gimp-canvas");
gtk_drawing_area_size (GTK_DRAWING_AREA (gdisp->canvas), n_width, n_height);
gtk_widget_set_events (gdisp->canvas, CANVAS_EVENT_MASK);
gtk_widget_set_extension_events (gdisp->canvas, GDK_EXTENSION_EVENTS_ALL);
GTK_WIDGET_SET_FLAGS (gdisp->canvas, GTK_CAN_FOCUS);
gtk_object_set_user_data (GTK_OBJECT (gdisp->canvas), (gpointer) gdisp);
/* set the active display before doing any other canvas event processing */
g_signal_connect (G_OBJECT (gdisp->canvas), "event",
G_CALLBACK (gdisplay_shell_events),
gdisp);
g_signal_connect (G_OBJECT (gdisp->canvas), "event",
G_CALLBACK (gdisplay_canvas_events),
gdisp);
/* create the contents of the lower_hbox *********************************/
/* the qmask buttons */
1999-10-27 02:27:27 +08:00
gdisp->qmaskoff = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (gdisp->qmaskoff));
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskoff), 15, 15);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (gdisp->qmaskoff), FALSE);
GTK_WIDGET_UNSET_FLAGS (gdisp->qmaskoff, GTK_CAN_FOCUS);
g_signal_connect (G_OBJECT (gdisp->qmaskoff), "toggled",
G_CALLBACK (qmask_deactivate_callback),
gdisp);
g_signal_connect (G_OBJECT (gdisp->qmaskoff), "button_press_event",
G_CALLBACK (qmask_button_press_callback),
gdisp);
gimp_help_set_help_data (gdisp->qmaskoff, NULL, "#qmask_off_button");
1999-10-27 02:27:27 +08:00
gdisp->qmaskon = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (gdisp->qmaskon));
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskon), 15, 15);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (gdisp->qmaskon), FALSE);
GTK_WIDGET_UNSET_FLAGS (gdisp->qmaskon, GTK_CAN_FOCUS);
g_signal_connect (G_OBJECT (gdisp->qmaskon), "toggled",
G_CALLBACK (qmask_activate_callback),
gdisp);
g_signal_connect (G_OBJECT (gdisp->qmaskon), "button_press_event",
G_CALLBACK (qmask_button_press_callback),
gdisp);
gimp_help_set_help_data (gdisp->qmaskon, NULL, "#qmask_on_button");
new ui for the "Layer Offset" dialog. 1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de> * app/channel_ops.[ch]: new ui for the "Layer Offset" dialog. * app/channels_dialog.c * app/layers_dialog.c: major code cleanup: Folded some callbacks into common ones, "widget" instead of "w", indentation, ... * app/commands.c * app/interface.[ch] * app/global_edit.c: the query boxes must be shown by the caller now. There's no need to split up the string for the message box manually as the Gtk 1.2 label widget handles newlines corectly. Added the "edge_lock" toggle to the "Shrink Selection" dialog. Nicer spacings for the query and message boxes. * app/ink.c: tried to grab the pointer in the blob preview but failed. Left the code there as a reminder (commented out). * app/menus.c: reordered <Image>/Select. I was bored and grep-ed the sources for ancient or deprecated stuff: * app/about_dialog.[ch] * app/actionarea.[ch] * app/app_procs.c * app/brush_edit.c * app/brush_select.c * app/color_select.c * app/convert.c * app/devices.c * app/gdisplay.c * app/gdisplay_ops.c * app/histogram_tool.[ch] * app/info_window.c * app/install.c * app/ops_buttons.c * app/palette.c * app/palette_select.c * app/paths_dialog.c * app/pattern_select.c * app/resize.c * app/scale_toolc.c * app/text_tool.c: s/container_border_width/container_set_border_width/g, s/sprintf/g_snprintf/g, replaced some constant string lengths with strlen(x). * app/bezier_select.c * app/blend.c * app/boundary.c * app/errors.[ch] * app/free_select.c * app/gimpbrushlist.c * app/gimprc.c * app/iscissors.c * app/main.c * app/patterns.[ch] * app/text_tool.c: namespace fanaticism: prefixed all gimp error functions with "gimp_" and formated the messages more uniformly. * app/gradient.c * app/gradient_select.c: same stuff as above for the ui code. There are still some sub-dialogs which need cleanup. Did some cleanup in most of these files: prototypes, removed tons of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gdisp->qmaskoff), TRUE);
/* the navigation window button */
nav_ebox = gtk_event_box_new ();
g_signal_connect (G_OBJECT (nav_ebox), "button_press_event",
G_CALLBACK (nav_popup_click_handler),
gdisp);
gimp_help_set_help_data (nav_ebox, NULL, "#nav_window_button");
/* We need to realize the shell so that we have a GdkWindow for
* the pixmap creation.
*/
gtk_widget_realize (gdisp->shell);
/* create the pixmaps ****************************************************/
if (!qmasksel_pixmap)
{
GtkStyle *style;
style = gtk_widget_get_style (gdisp->shell);
qmasksel_pixmap =
gdk_pixmap_create_from_xpm_d (gdisp->shell->window,
&qmasksel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasksel_xpm);
qmasknosel_pixmap =
gdk_pixmap_create_from_xpm_d (gdisp->shell->window,
&qmasknosel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasknosel_xpm);
navbutton_pixmap =
gdk_pixmap_create_from_xpm_d (gdisp->shell->window,
&navbutton_mask,
&style->bg[GTK_STATE_NORMAL],
navbutton_xpm);
}
/* Icon stuff */
gdisp->iconsize = 32;
gdisp->icon = NULL;
gdisp->iconmask = NULL;
gdisp->icon_needs_update = 0;
gdisp->icon_timeout_id = 0;
gdisp->icon_idle_id = 0;
g_signal_connect (G_OBJECT (gdisp->gimage), "invalidate_preview",
G_CALLBACK (gdisplay_update_icon_scheduler),
gdisp);
gdisplay_update_icon_scheduler (gdisp->gimage, gdisp);
/* create the GtkPixmaps */
pixmap = gtk_pixmap_new (qmasksel_pixmap, qmasksel_mask);
gtk_container_add (GTK_CONTAINER (gdisp->qmaskon), pixmap);
gtk_widget_show (pixmap);
pixmap = gtk_pixmap_new (qmasknosel_pixmap, qmasknosel_mask);
gtk_container_add (GTK_CONTAINER (gdisp->qmaskoff), pixmap);
gtk_widget_show (pixmap);
pixmap = gtk_pixmap_new (navbutton_pixmap, navbutton_mask);
gtk_container_add (GTK_CONTAINER (nav_ebox), pixmap);
gtk_widget_show (pixmap);
/* create the contents of the status area *********************************/
1997-11-25 06:05:25 +08:00
/* the cursor label */
label_frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (label_frame), GTK_SHADOW_IN);
gdisp->cursor_label = gtk_label_new (" ");
gtk_container_add (GTK_CONTAINER (label_frame), gdisp->cursor_label);
gtk_widget_show (gdisp->cursor_label);
/* the statusbar */
gdisp->statusbar = gtk_statusbar_new ();
gtk_widget_set_usize (gdisp->statusbar, 1, -1);
gtk_container_set_resize_mode (GTK_CONTAINER (gdisp->statusbar),
GTK_RESIZE_QUEUE);
contextid = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar),
"title");
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar),
contextid,
title);
/* the progress bar */
gdisp->progressbar = gtk_progress_bar_new ();
gtk_widget_set_usize (gdisp->progressbar, 80, -1);
/* the cancel button */
gdisp->cancelbutton = gtk_button_new_with_label (_("Cancel"));
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
/* pack all the widgets **************************************************/
1997-11-25 06:05:25 +08:00
/* fill the upper_hbox */
gtk_box_pack_start (GTK_BOX (upper_hbox), gdisp->vsb, FALSE, FALSE, 0);
1997-11-25 06:05:25 +08:00
/* fill the inner_table */
gtk_table_attach (GTK_TABLE (inner_table), gdisp->origin, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (inner_table), gdisp->hrule, 1, 2, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (inner_table), gdisp->vrule, 0, 1, 1, 2,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (inner_table), gdisp->canvas, 1, 2, 1, 2,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
/* fill the lower_hbox */
gtk_box_pack_start (GTK_BOX (lower_hbox), gdisp->qmaskoff, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), gdisp->qmaskon, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), gdisp->hsb, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), nav_ebox, FALSE, FALSE, 0);
/* fill the status area */
gtk_box_pack_start (GTK_BOX (status_hbox), label_frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), gdisp->statusbar, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), gdisp->progressbar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), gdisp->cancelbutton, FALSE, FALSE, 0);
/* show everything *******************************************************/
if (gimprc.show_rulers)
{
gtk_widget_show (gdisp->origin);
gtk_widget_show (gdisp->hrule);
gtk_widget_show (gdisp->vrule);
}
1997-11-25 06:05:25 +08:00
gtk_widget_show (gdisp->canvas);
gtk_widget_show (gdisp->vsb);
gtk_widget_show (gdisp->hsb);
gtk_widget_show (gdisp->qmaskoff);
gtk_widget_show (gdisp->qmaskon);
gtk_widget_show (nav_ebox);
gtk_widget_show (label_frame);
gtk_widget_show (gdisp->statusbar);
gtk_widget_show (gdisp->progressbar);
gtk_widget_show (gdisp->cancelbutton);
if (gimprc.show_statusbar)
{
gtk_widget_show (gdisp->statusarea);
}
gtk_widget_realize (gdisp->canvas);
gdk_window_set_back_pixmap (gdisp->canvas->window, NULL, FALSE);
/* we need to realize the cursor_label widget here, so the size gets
* computed correctly
*/
gtk_widget_realize (gdisp->cursor_label);
gdisplay_resize_cursor_label (gdisp);
gtk_widget_show (main_vbox);
gtk_widget_show (gdisp->shell);
1997-11-25 06:05:25 +08:00
/* set the focus to the canvas area */
gtk_widget_grab_focus (gdisp->canvas);
}