2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1999-06-02 13:55:02 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1999-06-02 13:55:02 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1999-06-02 13:55:02 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1999-06-02 13:55:02 +08:00
|
|
|
*/
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1999-06-02 13:55:02 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
#include "widgets-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpbrush.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpgradient.h"
|
|
|
|
#include "core/gimppattern.h"
|
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
#include "gimpdialogfactory.h"
|
|
|
|
#include "gimpdnd.h"
|
2004-08-25 01:16:46 +08:00
|
|
|
#include "gimpview.h"
|
2002-03-15 01:07:02 +08:00
|
|
|
#include "gimptoolbox.h"
|
|
|
|
#include "gimptoolbox-indicator-area.h"
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
1999-06-02 13:55:02 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2007-05-17 21:07:52 +08:00
|
|
|
#define CELL_SIZE 24 /* The size of the previews */
|
|
|
|
#define GRAD_CELL_WIDTH 52 /* The width of the gradient preview */
|
|
|
|
#define GRAD_CELL_HEIGHT 12 /* The height of the gradient preview */
|
2004-06-01 04:30:52 +08:00
|
|
|
#define CELL_SPACING 2 /* How much between brush and pattern cells */
|
1999-06-03 14:54:11 +08:00
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
2003-03-20 23:49:48 +08:00
|
|
|
brush_preview_clicked (GtkWidget *widget,
|
|
|
|
GdkModifierType state,
|
2004-08-25 01:16:46 +08:00
|
|
|
GimpToolbox *toolbox)
|
1999-06-02 13:55:02 +08:00
|
|
|
{
|
2009-12-06 04:20:18 +08:00
|
|
|
gimp_dialog_factory_dialog_raise (gimp_toolbox_get_dialog_factory (toolbox),
|
2003-11-08 23:32:38 +08:00
|
|
|
gtk_widget_get_screen (widget),
|
2004-08-25 01:16:46 +08:00
|
|
|
"gimp-brush-grid|gimp-brush-list", -1);
|
1999-06-02 13:55:02 +08:00
|
|
|
}
|
|
|
|
|
1999-09-05 18:45:07 +08:00
|
|
|
static void
|
2001-02-14 03:53:07 +08:00
|
|
|
brush_preview_drop_brush (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2004-08-25 01:16:46 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
1999-09-05 18:45:07 +08:00
|
|
|
{
|
2004-06-01 04:30:52 +08:00
|
|
|
GimpContext *context = GIMP_CONTEXT (data);
|
2001-02-24 10:42:09 +08:00
|
|
|
|
|
|
|
gimp_context_set_brush (context, GIMP_BRUSH (viewable));
|
1999-09-05 18:45:07 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
2003-03-20 23:49:48 +08:00
|
|
|
pattern_preview_clicked (GtkWidget *widget,
|
|
|
|
GdkModifierType state,
|
2004-08-25 01:16:46 +08:00
|
|
|
GimpToolbox *toolbox)
|
1999-06-03 14:54:11 +08:00
|
|
|
{
|
2009-12-06 04:20:18 +08:00
|
|
|
gimp_dialog_factory_dialog_raise (gimp_toolbox_get_dialog_factory (toolbox),
|
2003-11-08 23:32:38 +08:00
|
|
|
gtk_widget_get_screen (widget),
|
2004-08-25 01:16:46 +08:00
|
|
|
"gimp-pattern-grid|gimp-pattern-list", -1);
|
1999-06-03 14:54:11 +08:00
|
|
|
}
|
|
|
|
|
1999-09-05 18:45:07 +08:00
|
|
|
static void
|
2001-02-14 03:53:07 +08:00
|
|
|
pattern_preview_drop_pattern (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2004-08-25 01:16:46 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
1999-09-05 18:45:07 +08:00
|
|
|
{
|
2004-06-01 04:30:52 +08:00
|
|
|
GimpContext *context = GIMP_CONTEXT (data);
|
2001-02-24 10:42:09 +08:00
|
|
|
|
|
|
|
gimp_context_set_pattern (context, GIMP_PATTERN (viewable));
|
1999-09-05 18:45:07 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
2003-03-20 23:49:48 +08:00
|
|
|
gradient_preview_clicked (GtkWidget *widget,
|
|
|
|
GdkModifierType state,
|
2004-08-25 01:16:46 +08:00
|
|
|
GimpToolbox *toolbox)
|
1999-09-01 19:29:39 +08:00
|
|
|
{
|
2009-12-06 04:20:18 +08:00
|
|
|
gimp_dialog_factory_dialog_raise (gimp_toolbox_get_dialog_factory (toolbox),
|
2003-11-08 23:32:38 +08:00
|
|
|
gtk_widget_get_screen (widget),
|
2004-08-25 01:16:46 +08:00
|
|
|
"gimp-gradient-list|gimp-gradient-grid", -1);
|
1999-10-28 23:05:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-02-11 03:35:29 +08:00
|
|
|
gradient_preview_drop_gradient (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2004-08-25 01:16:46 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
1999-10-28 23:05:49 +08:00
|
|
|
{
|
2004-06-01 04:30:52 +08:00
|
|
|
GimpContext *context = GIMP_CONTEXT (data);
|
2001-02-24 10:42:09 +08:00
|
|
|
|
|
|
|
gimp_context_set_gradient (context, GIMP_GRADIENT (viewable));
|
1999-09-01 19:29:39 +08:00
|
|
|
}
|
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
1999-06-03 14:54:11 +08:00
|
|
|
GtkWidget *
|
2002-03-15 01:07:02 +08:00
|
|
|
gimp_toolbox_indicator_area_create (GimpToolbox *toolbox)
|
1999-06-03 14:54:11 +08:00
|
|
|
{
|
2002-03-15 01:07:02 +08:00
|
|
|
GimpContext *context;
|
|
|
|
GtkWidget *indicator_table;
|
2004-08-25 01:16:46 +08:00
|
|
|
GtkWidget *brush_view;
|
|
|
|
GtkWidget *pattern_view;
|
|
|
|
GtkWidget *gradient_view;
|
2002-03-15 01:07:02 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL);
|
1999-09-01 19:29:39 +08:00
|
|
|
|
2009-12-06 04:20:18 +08:00
|
|
|
context = gimp_toolbox_get_context (toolbox);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-09-01 19:29:39 +08:00
|
|
|
indicator_table = gtk_table_new (2, 2, FALSE);
|
2004-06-01 04:30:52 +08:00
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (indicator_table), CELL_SPACING);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (indicator_table), CELL_SPACING);
|
1999-10-28 23:05:49 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
/* brush view */
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
brush_view =
|
2006-08-30 05:44:51 +08:00
|
|
|
gimp_view_new_full_by_types (context,
|
|
|
|
GIMP_TYPE_VIEW, GIMP_TYPE_BRUSH,
|
2007-05-17 21:07:52 +08:00
|
|
|
CELL_SIZE, CELL_SIZE, 1,
|
2004-08-25 01:16:46 +08:00
|
|
|
FALSE, TRUE, TRUE);
|
|
|
|
gimp_view_set_viewable (GIMP_VIEW (brush_view),
|
|
|
|
GIMP_VIEWABLE (gimp_context_get_brush (context)));
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (indicator_table), brush_view,
|
2004-06-01 04:30:52 +08:00
|
|
|
0, 1, 0, 1);
|
2004-08-25 01:16:46 +08:00
|
|
|
gtk_widget_show (brush_view);
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
gimp_help_set_help_data (brush_view,
|
2004-06-01 04:30:52 +08:00
|
|
|
_("The active brush.\n"
|
|
|
|
"Click to open the Brush Dialog."), NULL);
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect_object (context, "brush-changed",
|
2004-08-25 01:16:46 +08:00
|
|
|
G_CALLBACK (gimp_view_set_viewable),
|
|
|
|
brush_view,
|
2004-06-01 04:30:52 +08:00
|
|
|
G_CONNECT_SWAPPED);
|
2001-08-10 00:39:08 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
g_signal_connect (brush_view, "clicked",
|
2004-06-01 04:30:52 +08:00
|
|
|
G_CALLBACK (brush_preview_clicked),
|
|
|
|
toolbox);
|
2001-08-10 00:39:08 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
gimp_dnd_viewable_dest_add (brush_view,
|
2001-02-12 11:27:28 +08:00
|
|
|
GIMP_TYPE_BRUSH,
|
|
|
|
brush_preview_drop_brush,
|
2001-02-24 10:42:09 +08:00
|
|
|
context);
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
/* pattern view */
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
pattern_view =
|
2006-08-30 05:44:51 +08:00
|
|
|
gimp_view_new_full_by_types (context,
|
|
|
|
GIMP_TYPE_VIEW, GIMP_TYPE_PATTERN,
|
2007-05-17 21:07:52 +08:00
|
|
|
CELL_SIZE, CELL_SIZE, 1,
|
2004-08-25 01:16:46 +08:00
|
|
|
FALSE, TRUE, TRUE);
|
|
|
|
gimp_view_set_viewable (GIMP_VIEW (pattern_view),
|
|
|
|
GIMP_VIEWABLE (gimp_context_get_pattern (context)));
|
2003-11-24 09:23:45 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (indicator_table), pattern_view,
|
2004-06-01 04:30:52 +08:00
|
|
|
1, 2, 0, 1);
|
2004-08-25 01:16:46 +08:00
|
|
|
gtk_widget_show (pattern_view);
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
gimp_help_set_help_data (pattern_view,
|
2004-06-01 04:30:52 +08:00
|
|
|
_("The active pattern.\n"
|
|
|
|
"Click to open the Pattern Dialog."), NULL);
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect_object (context, "pattern-changed",
|
2004-08-25 01:16:46 +08:00
|
|
|
G_CALLBACK (gimp_view_set_viewable),
|
|
|
|
pattern_view,
|
2004-06-01 04:30:52 +08:00
|
|
|
G_CONNECT_SWAPPED);
|
2001-08-10 00:39:08 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
g_signal_connect (pattern_view, "clicked",
|
2004-06-01 04:30:52 +08:00
|
|
|
G_CALLBACK (pattern_preview_clicked),
|
|
|
|
toolbox);
|
2001-08-10 00:39:08 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
gimp_dnd_viewable_dest_add (pattern_view,
|
2001-02-12 11:27:28 +08:00
|
|
|
GIMP_TYPE_PATTERN,
|
|
|
|
pattern_preview_drop_pattern,
|
2001-02-24 10:42:09 +08:00
|
|
|
context);
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
/* gradient view */
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
gradient_view =
|
2006-08-30 05:44:51 +08:00
|
|
|
gimp_view_new_full_by_types (context,
|
|
|
|
GIMP_TYPE_VIEW, GIMP_TYPE_GRADIENT,
|
2007-05-17 21:07:52 +08:00
|
|
|
GRAD_CELL_WIDTH, GRAD_CELL_HEIGHT, 1,
|
2004-08-25 01:16:46 +08:00
|
|
|
FALSE, TRUE, TRUE);
|
|
|
|
gimp_view_set_viewable (GIMP_VIEW (gradient_view),
|
|
|
|
GIMP_VIEWABLE (gimp_context_get_gradient (context)));
|
2003-11-24 09:23:45 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (indicator_table), gradient_view,
|
2004-06-01 04:30:52 +08:00
|
|
|
0, 2, 1, 2);
|
2004-08-25 01:16:46 +08:00
|
|
|
gtk_widget_show (gradient_view);
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
gimp_help_set_help_data (gradient_view,
|
2004-06-01 04:30:52 +08:00
|
|
|
_("The active gradient.\n"
|
|
|
|
"Click to open the Gradient Dialog."), NULL);
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect_object (context, "gradient-changed",
|
2004-08-25 01:16:46 +08:00
|
|
|
G_CALLBACK (gimp_view_set_viewable),
|
|
|
|
gradient_view,
|
2004-06-01 04:30:52 +08:00
|
|
|
G_CONNECT_SWAPPED);
|
2001-08-10 00:39:08 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
g_signal_connect (gradient_view, "clicked",
|
2004-06-01 04:30:52 +08:00
|
|
|
G_CALLBACK (gradient_preview_clicked),
|
|
|
|
toolbox);
|
2001-08-10 00:39:08 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
gimp_dnd_viewable_dest_add (gradient_view,
|
2001-02-12 11:27:28 +08:00
|
|
|
GIMP_TYPE_GRADIENT,
|
|
|
|
gradient_preview_drop_gradient,
|
2001-02-24 10:42:09 +08:00
|
|
|
context);
|
2001-02-12 11:27:28 +08:00
|
|
|
|
1999-08-27 04:11:36 +08:00
|
|
|
gtk_widget_show (indicator_table);
|
|
|
|
|
2001-02-24 10:42:09 +08:00
|
|
|
return indicator_table;
|
1999-06-03 14:54:11 +08:00
|
|
|
}
|