1999-06-02 13:55:02 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "appenv.h"
|
|
|
|
#include "gimpbrushlist.h"
|
1999-09-01 08:12:33 +08:00
|
|
|
#include "gimpcontextpreview.h"
|
|
|
|
#include "indicator_area.h"
|
|
|
|
#include "interface.h" /* for tool_tips */
|
|
|
|
#include "libgimp/gimpintl.h"
|
1999-06-02 13:55:02 +08:00
|
|
|
|
1999-06-03 14:54:11 +08:00
|
|
|
#define CELL_SIZE 23 /* The size of the previews */
|
1999-06-02 13:55:02 +08:00
|
|
|
#define CELL_PADDING 2 /* How much between brush and pattern cells */
|
1999-06-03 14:54:11 +08:00
|
|
|
|
1999-06-02 13:55:02 +08:00
|
|
|
/* Static variables */
|
|
|
|
static GtkWidget *indicator_table;
|
|
|
|
static GtkWidget *brush_preview;
|
1999-06-03 14:54:11 +08:00
|
|
|
static GtkWidget *pattern_preview;
|
1999-06-03 12:16:37 +08:00
|
|
|
|
|
|
|
|
1999-08-27 04:11:36 +08:00
|
|
|
/* The _area_update () functions should be called _preview_update(),
|
|
|
|
but I've left the old function names in for now since they are
|
|
|
|
called from devices.c
|
|
|
|
*/
|
1999-06-02 13:55:02 +08:00
|
|
|
|
1999-06-03 14:54:11 +08:00
|
|
|
void
|
|
|
|
brush_area_update ()
|
|
|
|
{
|
1999-08-27 04:11:36 +08:00
|
|
|
GimpBrush *brush;
|
1999-06-03 14:54:11 +08:00
|
|
|
|
1999-06-18 12:22:19 +08:00
|
|
|
if (no_data || no_interface) return;
|
1999-06-14 10:23:53 +08:00
|
|
|
|
1999-06-03 14:54:11 +08:00
|
|
|
brush = get_active_brush();
|
|
|
|
if (!brush)
|
|
|
|
{
|
1999-09-01 08:12:33 +08:00
|
|
|
g_warning ("No gimp brush found\n");
|
1999-08-13 01:53:51 +08:00
|
|
|
return;
|
1999-06-03 14:54:11 +08:00
|
|
|
}
|
1999-09-01 08:12:33 +08:00
|
|
|
gimp_context_preview_update (GIMP_CONTEXT_PREVIEW (brush_preview), brush);
|
1999-06-03 14:54:11 +08:00
|
|
|
}
|
|
|
|
|
1999-06-02 13:55:02 +08:00
|
|
|
static gint
|
1999-08-27 04:11:36 +08:00
|
|
|
brush_preview_clicked (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-06-02 13:55:02 +08:00
|
|
|
{
|
1999-09-01 08:12:33 +08:00
|
|
|
create_brush_dialog ();
|
1999-08-27 04:11:36 +08:00
|
|
|
return TRUE;
|
1999-06-02 13:55:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-08-13 01:53:51 +08:00
|
|
|
pattern_area_update ()
|
1999-06-02 13:55:02 +08:00
|
|
|
{
|
1999-08-27 04:11:36 +08:00
|
|
|
GPattern *pattern;
|
|
|
|
|
1999-06-18 12:22:19 +08:00
|
|
|
if (no_data || no_interface) return;
|
1999-06-02 13:55:02 +08:00
|
|
|
|
1999-06-18 12:22:19 +08:00
|
|
|
pattern = get_active_pattern();
|
1999-06-03 14:54:11 +08:00
|
|
|
|
1999-08-27 04:11:36 +08:00
|
|
|
if (!pattern)
|
1999-06-02 13:55:02 +08:00
|
|
|
{
|
1999-09-01 08:12:33 +08:00
|
|
|
g_warning ("No gimp pattern found\n");
|
1999-08-27 04:11:36 +08:00
|
|
|
return;
|
1999-06-03 14:54:11 +08:00
|
|
|
}
|
1999-09-01 08:12:33 +08:00
|
|
|
gimp_context_preview_update (GIMP_CONTEXT_PREVIEW (pattern_preview), pattern);
|
1999-06-02 13:55:02 +08:00
|
|
|
}
|
|
|
|
|
1999-06-03 14:54:11 +08:00
|
|
|
static gint
|
1999-08-27 04:11:36 +08:00
|
|
|
pattern_preview_clicked (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-06-03 14:54:11 +08:00
|
|
|
{
|
1999-08-27 04:11:36 +08:00
|
|
|
create_pattern_dialog();
|
|
|
|
return TRUE;
|
1999-06-03 14:54:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
1999-08-13 01:53:51 +08:00
|
|
|
indicator_area_create (int width,
|
|
|
|
int height)
|
1999-06-03 14:54:11 +08:00
|
|
|
{
|
1999-08-27 04:11:36 +08:00
|
|
|
indicator_table = gtk_table_new (1, 3, FALSE);
|
1999-06-03 14:54:11 +08:00
|
|
|
|
1999-09-01 08:12:33 +08:00
|
|
|
brush_preview = gimp_context_preview_new (GCP_BRUSH,
|
|
|
|
CELL_SIZE, CELL_SIZE,
|
|
|
|
FALSE);
|
|
|
|
gtk_tooltips_set_tip (tool_tips, brush_preview,
|
|
|
|
_("The active brush.\nClick to open the Brushes Dialog."),
|
|
|
|
NULL);
|
1999-08-27 04:11:36 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (brush_preview), "clicked",
|
|
|
|
(GtkSignalFunc) brush_preview_clicked, NULL);
|
1999-06-03 14:54:11 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE(indicator_table), brush_preview,
|
|
|
|
0, 1, 0, 1);
|
|
|
|
|
1999-09-01 08:12:33 +08:00
|
|
|
pattern_preview = gimp_context_preview_new (GCP_PATTERN,
|
|
|
|
CELL_SIZE, CELL_SIZE,
|
|
|
|
FALSE);
|
|
|
|
gtk_tooltips_set_tip (tool_tips, pattern_preview,
|
|
|
|
_("The active pattern.\nClick to open the Patterns Dialog."),
|
|
|
|
NULL);
|
1999-08-27 04:11:36 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (pattern_preview), "clicked",
|
|
|
|
(GtkSignalFunc) pattern_preview_clicked, NULL);
|
1999-06-03 14:54:11 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE(indicator_table), pattern_preview,
|
1999-08-13 01:53:51 +08:00
|
|
|
1, 2, 0, 1);
|
1999-06-03 14:54:11 +08:00
|
|
|
|
1999-08-27 04:11:36 +08:00
|
|
|
brush_area_update ();
|
|
|
|
pattern_area_update ();
|
|
|
|
|
|
|
|
gtk_widget_show (brush_preview);
|
|
|
|
gtk_widget_show (pattern_preview);
|
|
|
|
gtk_widget_show (indicator_table);
|
|
|
|
|
|
|
|
return (indicator_table);
|
1999-06-03 14:54:11 +08:00
|
|
|
}
|
1999-08-27 04:11:36 +08:00
|
|
|
|
|
|
|
|