gimp/app/widgets/gimptoolbox-indicator-area.c

208 lines
5.8 KiB
C
Raw Normal View History

/* 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.
*/
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include "config.h"
#include <stdlib.h>
#include <string.h>
1999-10-27 02:27:27 +08:00
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include <gtk/gtk.h>
#include "apptypes.h"
#include "appenv.h"
1999-10-27 02:27:27 +08:00
#include "brush_select.h"
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include "gimpcontext.h"
#include "gimpcontextpreview.h"
#include "gimpdnd.h"
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include "gimpui.h"
1999-10-28 23:05:49 +08:00
#include "gradient_select.h"
#include "indicator_area.h"
1999-10-27 02:27:27 +08:00
#include "pattern_select.h"
#include "libgimp/gimpintl.h"
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
1999-10-28 23:05:49 +08:00
#define CELL_SIZE 23 /* The size of the previews */
#define GRAD_CELL_WIDTH 48 /* The width of the gradient preview */
#define GRAD_CELL_HEIGHT 12 /* The height of the gradient preview */
1999-10-28 23:05:49 +08:00
#define CELL_PADDING 2 /* How much between brush and pattern cells */
1999-06-03 14:54:11 +08:00
/* Static variables */
static GtkWidget *brush_preview;
1999-06-03 14:54:11 +08:00
static GtkWidget *pattern_preview;
static GtkWidget *gradient_preview;
1999-06-03 12:16:37 +08:00
1999-10-27 02:27:27 +08:00
static void
brush_area_update (GimpContext *context,
GimpBrush *brush,
gpointer data)
{
if (brush)
gimp_context_preview_update (GIMP_CONTEXT_PREVIEW (brush_preview), brush);
1999-06-03 14:54:11 +08:00
}
1999-10-27 02:27:27 +08:00
static void
brush_preview_clicked (GtkWidget *widget,
gpointer data)
{
1999-10-27 02:27:27 +08:00
brush_dialog_create ();
}
static void
1999-10-28 23:05:49 +08:00
brush_preview_drop_brush (GtkWidget *widget,
GimpBrush *brush,
gpointer data)
{
1999-10-28 23:05:49 +08:00
if (brush)
gimp_context_set_brush (gimp_context_get_user (), brush);
}
1999-10-27 02:27:27 +08:00
static void
pattern_area_update (GimpContext *context,
GPattern *pattern,
gpointer data)
{
1999-10-27 02:27:27 +08:00
if (pattern)
gimp_context_preview_update (GIMP_CONTEXT_PREVIEW (pattern_preview),
pattern);
}
1999-10-27 02:27:27 +08:00
static void
pattern_preview_clicked (GtkWidget *widget,
gpointer data)
1999-06-03 14:54:11 +08:00
{
1999-10-27 02:27:27 +08:00
pattern_dialog_create ();
1999-06-03 14:54:11 +08:00
}
static void
1999-10-28 23:05:49 +08:00
pattern_preview_drop_pattern (GtkWidget *widget,
GPattern *pattern,
gpointer data)
{
1999-10-28 23:05:49 +08:00
if (pattern)
gimp_context_set_pattern (gimp_context_get_user (), pattern);
}
1999-10-27 02:27:27 +08:00
static void
gradient_area_update (GimpContext *context,
gradient_t *gradient,
gpointer data)
{
1999-10-27 02:27:27 +08:00
if (gradient)
gimp_context_preview_update (GIMP_CONTEXT_PREVIEW (gradient_preview),
gradient);
}
1999-10-27 02:27:27 +08:00
static void
gradient_preview_clicked (GtkWidget *widget,
gpointer data)
{
1999-10-28 23:05:49 +08:00
gradient_dialog_create ();
}
static void
gradient_preview_drop_gradient (GtkWidget *widget,
gradient_t *gradient,
gpointer data)
{
if (gradient)
gimp_context_set_gradient (gimp_context_get_user (), gradient);
}
1999-06-03 14:54:11 +08:00
GtkWidget *
indicator_area_create (void)
1999-06-03 14:54:11 +08:00
{
1999-10-27 02:27:27 +08:00
GimpContext *context;
GtkWidget *indicator_table;
1999-10-27 02:27:27 +08:00
context = gimp_context_get_user ();
indicator_table = gtk_table_new (2, 2, FALSE);
gtk_table_set_row_spacing (GTK_TABLE (indicator_table), 0, CELL_PADDING);
gtk_table_set_col_spacing (GTK_TABLE (indicator_table), 0, CELL_PADDING);
1999-10-28 23:05:49 +08:00
brush_preview =
gimp_context_preview_new (GCP_BRUSH,
CELL_SIZE, CELL_SIZE,
TRUE, FALSE,
1999-10-28 23:05:49 +08:00
(GimpDndDropBrushFunc) brush_preview_drop_brush,
NULL);
gimp_help_set_help_data (brush_preview,
_("The active brush.\n"
"Click to open the Brushes Dialog."), NULL);
gtk_signal_connect (GTK_OBJECT (brush_preview), "clicked",
1999-10-27 02:27:27 +08:00
GTK_SIGNAL_FUNC (brush_preview_clicked),
NULL);
gtk_signal_connect (GTK_OBJECT (context), "brush_changed",
GTK_SIGNAL_FUNC (brush_area_update),
NULL);
gtk_table_attach_defaults (GTK_TABLE (indicator_table), brush_preview,
0, 1, 0, 1);
1999-06-03 14:54:11 +08:00
1999-10-28 23:05:49 +08:00
pattern_preview =
gimp_context_preview_new (GCP_PATTERN,
CELL_SIZE, CELL_SIZE,
TRUE, FALSE,
1999-10-28 23:05:49 +08:00
(GimpDndDropPatternFunc) pattern_preview_drop_pattern,
NULL);
gimp_help_set_help_data (pattern_preview,
_("The active pattern.\n"
"Click to open the Patterns Dialog."), NULL);
gtk_signal_connect (GTK_OBJECT (pattern_preview), "clicked",
1999-10-27 02:27:27 +08:00
GTK_SIGNAL_FUNC (pattern_preview_clicked),
NULL);
gtk_signal_connect (GTK_OBJECT (context), "pattern_changed",
GTK_SIGNAL_FUNC (pattern_area_update),
NULL);
gtk_table_attach_defaults (GTK_TABLE (indicator_table), pattern_preview,
1, 2, 0, 1);
1999-06-03 14:54:11 +08:00
1999-10-28 23:05:49 +08:00
gradient_preview =
gimp_context_preview_new (GCP_GRADIENT,
GRAD_CELL_WIDTH,
GRAD_CELL_HEIGHT,
TRUE, FALSE,
1999-10-28 23:05:49 +08:00
(GimpDndDropGradientFunc) gradient_preview_drop_gradient,
NULL);
gimp_help_set_help_data (gradient_preview,
_("The active gradient.\n"
"Click to open the Gradients Dialog."), NULL);
gtk_signal_connect (GTK_OBJECT (gradient_preview), "clicked",
1999-10-27 02:27:27 +08:00
GTK_SIGNAL_FUNC (gradient_preview_clicked),
NULL);
gtk_signal_connect (GTK_OBJECT (context), "gradient_changed",
GTK_SIGNAL_FUNC (gradient_area_update),
NULL);
gtk_table_attach_defaults (GTK_TABLE (indicator_table), gradient_preview,
0, 2, 1, 2);
1999-10-27 02:27:27 +08:00
brush_area_update (NULL, gimp_context_get_brush (context), NULL);
pattern_area_update (NULL, gimp_context_get_pattern (context), NULL);
gradient_area_update (NULL, gimp_context_get_gradient (context), NULL);
gtk_widget_show (brush_preview);
gtk_widget_show (pattern_preview);
gtk_widget_show (gradient_preview);
gtk_widget_show (indicator_table);
return (indicator_table);
1999-06-03 14:54:11 +08:00
}