gimp/app/indicator_area.c

130 lines
3.5 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.
*/
#include <stdlib.h>
#include <string.h>
#include "appenv.h"
#include "gimpbrushlist.h"
#include "gimpcontextpreview.h"
#include "indicator_area.h"
#include "interface.h" /* for tool_tips */
#include "libgimp/gimpintl.h"
1999-06-03 14:54:11 +08:00
#define CELL_SIZE 23 /* The size of the previews */
#define CELL_PADDING 2 /* How much between brush and pattern cells */
1999-06-03 14:54:11 +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
/* 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-03 14:54:11 +08:00
void
brush_area_update ()
{
GimpBrush *brush;
1999-06-03 14:54:11 +08:00
if (no_data || no_interface) return;
1999-06-03 14:54:11 +08:00
brush = get_active_brush();
if (!brush)
{
g_warning ("No gimp brush found\n");
return;
1999-06-03 14:54:11 +08:00
}
gimp_context_preview_update (GIMP_CONTEXT_PREVIEW (brush_preview), brush);
1999-06-03 14:54:11 +08:00
}
static gint
brush_preview_clicked (GtkWidget *widget,
gpointer data)
{
create_brush_dialog ();
return TRUE;
}
void
pattern_area_update ()
{
GPattern *pattern;
if (no_data || no_interface) return;
pattern = get_active_pattern();
1999-06-03 14:54:11 +08:00
if (!pattern)
{
g_warning ("No gimp pattern found\n");
return;
1999-06-03 14:54:11 +08:00
}
gimp_context_preview_update (GIMP_CONTEXT_PREVIEW (pattern_preview), pattern);
}
1999-06-03 14:54:11 +08:00
static gint
pattern_preview_clicked (GtkWidget *widget,
gpointer data)
1999-06-03 14:54:11 +08:00
{
create_pattern_dialog();
return TRUE;
1999-06-03 14:54:11 +08:00
}
GtkWidget *
indicator_area_create (int width,
int height)
1999-06-03 14:54:11 +08:00
{
indicator_table = gtk_table_new (1, 3, FALSE);
1999-06-03 14:54:11 +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);
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);
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);
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,
1, 2, 0, 1);
1999-06-03 14:54:11 +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
}