1998-07-09 13:31:06 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2001-05-01 21:16:59 +08:00
|
|
|
* brush-editor.c
|
|
|
|
* Copyright 1998 Jay Cox <jaycox@earthlink.net>
|
1998-07-09 13:31:06 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2000-09-29 20:00:00 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1998-09-24 20:05:49 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core/core-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpbrushgenerated.h"
|
|
|
|
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "brush-editor.h"
|
|
|
|
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
1998-07-09 13:31:06 +08:00
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
struct _BrushEditor
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
GtkWidget *shell;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *preview;
|
|
|
|
GtkWidget *scale_label;
|
|
|
|
GtkWidget *options_box;
|
|
|
|
GtkWidget *name;
|
|
|
|
GtkAdjustment *radius_data;
|
|
|
|
GtkAdjustment *hardness_data;
|
|
|
|
GtkAdjustment *angle_data;
|
|
|
|
GtkAdjustment *aspect_ratio_data;
|
|
|
|
|
|
|
|
/* Brush preview */
|
|
|
|
GtkWidget *brush_preview;
|
|
|
|
GimpBrushGenerated *brush;
|
|
|
|
gint scale;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
static void brush_editor_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void brush_editor_name_activate (GtkWidget *widget,
|
|
|
|
BrushEditor *brush_editor);
|
|
|
|
static gboolean brush_editor_name_focus_out (GtkWidget *widget,
|
|
|
|
GdkEventFocus *fevent,
|
|
|
|
BrushEditor *brush_editor);
|
|
|
|
static void brush_editor_update_brush (GtkAdjustment *adjustment,
|
|
|
|
BrushEditor *brush_editor);
|
|
|
|
static void brush_editor_preview_resize (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
BrushEditor *brush_editor);
|
2001-02-18 05:20:10 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
static void brush_editor_clear_preview (BrushEditor *brush_editor);
|
|
|
|
static void brush_editor_brush_dirty (GimpBrush *brush,
|
|
|
|
BrushEditor *brush_editor);
|
|
|
|
static void brush_editor_brush_name_changed (GtkWidget *widget,
|
|
|
|
BrushEditor *brush_editor);
|
2001-02-18 05:20:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
1999-08-30 18:51:01 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
BrushEditor *
|
2001-07-15 22:32:44 +08:00
|
|
|
brush_editor_new (Gimp *gimp)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
2001-05-01 21:16:59 +08:00
|
|
|
BrushEditor *brush_editor;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *slider;
|
|
|
|
GtkWidget *table;
|
1998-07-09 13:31:06 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor = g_new0 (BrushEditor, 1);
|
1998-07-15 20:15:24 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor->shell =
|
|
|
|
gimp_dialog_new (_("Brush Editor"), "generated_brush_editor",
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"dialogs/brush_editor.html",
|
|
|
|
GTK_WIN_POS_NONE,
|
|
|
|
FALSE, TRUE, FALSE,
|
1998-07-09 13:31:06 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
"_delete_event_", brush_editor_close_callback,
|
|
|
|
brush_editor, NULL, NULL, TRUE, TRUE,
|
1998-07-09 13:31:06 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
NULL);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
gtk_widget_hide (GTK_WIDGET (g_list_nth_data (gtk_container_children (GTK_CONTAINER (GTK_DIALOG (brush_editor->shell)->vbox)), 0)));
|
2001-02-18 05:20:10 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
gtk_widget_hide (GTK_DIALOG (brush_editor->shell)->action_area);
|
2001-02-18 05:20:10 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 1);
|
2001-02-19 08:05:03 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
2001-05-01 21:16:59 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (brush_editor->shell)->vbox),
|
|
|
|
vbox);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Brush's name */
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor->name = gtk_entry_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), brush_editor->name, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (brush_editor->name);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2001-07-28 03:41:54 +08:00
|
|
|
g_signal_connect (G_OBJECT (brush_editor->name), "activate",
|
|
|
|
G_CALLBACK (brush_editor_name_activate),
|
|
|
|
brush_editor);
|
|
|
|
g_signal_connect (G_OBJECT (brush_editor->name), "focus_out_event",
|
|
|
|
G_CALLBACK (brush_editor_name_focus_out),
|
|
|
|
brush_editor);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* brush's preview widget w/frame */
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor->frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (brush_editor->frame), GTK_SHADOW_IN);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), brush_editor->frame, TRUE, TRUE, 0);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor->preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (brush_editor->preview), 125, 100);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
/* Enable auto-resizing of the preview but ensure a minimal size */
|
|
|
|
gtk_widget_set_usize (brush_editor->preview, 125, 100);
|
|
|
|
gtk_preview_set_expand (GTK_PREVIEW (brush_editor->preview), TRUE);
|
|
|
|
|
|
|
|
gtk_signal_connect_after (GTK_OBJECT (brush_editor->frame), "size_allocate",
|
2001-07-28 03:41:54 +08:00
|
|
|
G_CALLBACK (brush_editor_preview_resize),
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor);
|
|
|
|
gtk_container_add (GTK_CONTAINER (brush_editor->frame), brush_editor->preview);
|
|
|
|
|
|
|
|
gtk_widget_show (brush_editor->preview);
|
|
|
|
gtk_widget_show (brush_editor->frame);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
1998-07-16 19:44:56 +08:00
|
|
|
/* table for sliders/labels */
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor->scale_label = gtk_label_new ("-1:1");
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), brush_editor->scale_label,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (brush_editor->scale_label);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor->scale = -1;
|
2000-09-29 20:00:00 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
/* table for sliders/labels */
|
2000-09-29 20:00:00 +08:00
|
|
|
table = gtk_table_new (4, 2, FALSE);
|
1998-07-09 13:31:06 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* brush radius scale */
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor->radius_data =
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_ADJUSTMENT (gtk_adjustment_new (10.0, 0.0, 100.0, 0.1, 1.0, 0.0));
|
2001-05-01 21:16:59 +08:00
|
|
|
slider = gtk_hscale_new (brush_editor->radius_data);
|
1998-07-09 13:31:06 +08:00
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
|
2001-07-28 03:41:54 +08:00
|
|
|
g_signal_connect (G_OBJECT (brush_editor->radius_data), "value_changed",
|
|
|
|
G_CALLBACK (brush_editor_update_brush),
|
|
|
|
brush_editor);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
1999-10-27 02:27:27 +08:00
|
|
|
_("Radius:"), 1.0, 1.0,
|
2000-01-31 11:13:02 +08:00
|
|
|
slider, 1, FALSE);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* brush hardness scale */
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor->hardness_data =
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.01, 0.0));
|
2001-05-01 21:16:59 +08:00
|
|
|
slider = gtk_hscale_new (brush_editor->hardness_data);
|
1998-07-09 13:31:06 +08:00
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
|
2001-07-28 03:41:54 +08:00
|
|
|
g_signal_connect (G_OBJECT (brush_editor->hardness_data), "value_changed",
|
|
|
|
G_CALLBACK (brush_editor_update_brush),
|
|
|
|
brush_editor);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
1999-10-27 02:27:27 +08:00
|
|
|
_("Hardness:"), 1.0, 1.0,
|
2000-01-31 11:13:02 +08:00
|
|
|
slider, 1, FALSE);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* brush aspect ratio scale */
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor->aspect_ratio_data =
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_ADJUSTMENT (gtk_adjustment_new (1.0, 1.0, 20.0, 0.1, 1.0, 0.0));
|
2001-05-01 21:16:59 +08:00
|
|
|
slider = gtk_hscale_new (brush_editor->aspect_ratio_data);
|
1998-07-09 13:31:06 +08:00
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
|
2001-07-28 03:41:54 +08:00
|
|
|
g_signal_connect (G_OBJECT (brush_editor->aspect_ratio_data),"value_changed",
|
|
|
|
G_CALLBACK (brush_editor_update_brush),
|
|
|
|
brush_editor);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
|
1999-10-27 02:27:27 +08:00
|
|
|
_("Aspect Ratio:"), 1.0, 1.0,
|
2000-01-31 11:13:02 +08:00
|
|
|
slider, 1, FALSE);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* brush angle scale */
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor->angle_data =
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_ADJUSTMENT (gtk_adjustment_new (00.0, 0.0, 180.0, 0.1, 1.0, 0.0));
|
2001-05-01 21:16:59 +08:00
|
|
|
slider = gtk_hscale_new (brush_editor->angle_data);
|
1998-07-09 13:31:06 +08:00
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
|
2001-07-28 03:41:54 +08:00
|
|
|
g_signal_connect (G_OBJECT (brush_editor->angle_data), "value_changed",
|
|
|
|
G_CALLBACK (brush_editor_update_brush),
|
|
|
|
brush_editor);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
|
1999-10-27 02:27:27 +08:00
|
|
|
_("Angle:"), 1.0, 1.0,
|
2000-01-31 11:13:02 +08:00
|
|
|
slider, 1, FALSE);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 3);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
1998-07-09 13:31:06 +08:00
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
gtk_widget_show (vbox);
|
2001-05-01 21:16:59 +08:00
|
|
|
gtk_widget_show (brush_editor->shell);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
return brush_editor;
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
1998-07-15 20:15:24 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
void
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor_set_brush (BrushEditor *brush_editor,
|
|
|
|
GimpBrush *gbrush)
|
2001-02-18 05:20:10 +08:00
|
|
|
{
|
|
|
|
GimpBrushGenerated *brush = NULL;
|
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
g_return_if_fail (brush_editor != NULL);
|
2001-07-31 01:17:36 +08:00
|
|
|
g_return_if_fail (GIMP_IS_BRUSH_GENERATED (gbrush));
|
2001-02-18 05:20:10 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
if (brush_editor->brush)
|
2001-02-18 05:20:10 +08:00
|
|
|
{
|
2001-07-28 03:41:54 +08:00
|
|
|
g_signal_handlers_disconnect_by_data (G_OBJECT (brush_editor->brush),
|
|
|
|
brush_editor);
|
|
|
|
g_object_unref (G_OBJECT (brush_editor->brush));
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor->brush = NULL;
|
2001-02-18 05:20:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
brush = GIMP_BRUSH_GENERATED (gbrush);
|
|
|
|
|
2001-07-28 03:41:54 +08:00
|
|
|
g_signal_connect (G_OBJECT (brush), "invalidate_preview",
|
|
|
|
G_CALLBACK (brush_editor_brush_dirty),
|
|
|
|
brush_editor);
|
|
|
|
g_signal_connect (G_OBJECT (brush), "name_changed",
|
|
|
|
G_CALLBACK (brush_editor_brush_name_changed),
|
|
|
|
brush_editor);
|
2001-02-18 05:20:10 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (brush_editor->radius_data),
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_brush_generated_get_radius (brush));
|
2001-05-01 21:16:59 +08:00
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (brush_editor->hardness_data),
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_brush_generated_get_hardness (brush));
|
2001-05-01 21:16:59 +08:00
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (brush_editor->angle_data),
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_brush_generated_get_angle (brush));
|
2001-05-01 21:16:59 +08:00
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (brush_editor->aspect_ratio_data),
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_brush_generated_get_aspect_ratio (brush));
|
2001-05-01 21:16:59 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (brush_editor->name),
|
2001-02-18 05:20:10 +08:00
|
|
|
gimp_object_get_name (GIMP_OBJECT (gbrush)));
|
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor->brush = brush;
|
2001-07-28 03:41:54 +08:00
|
|
|
g_object_ref (G_OBJECT (brush_editor->brush));
|
2001-02-18 05:20:10 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor_brush_dirty (GIMP_BRUSH (brush), brush_editor);
|
2001-02-18 05:20:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-02-18 05:20:10 +08:00
|
|
|
{
|
2001-05-01 21:16:59 +08:00
|
|
|
BrushEditor *brush_editor = (BrushEditor *) data;
|
2001-02-18 05:20:10 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
if (GTK_WIDGET_VISIBLE (brush_editor->shell))
|
|
|
|
gtk_widget_hide (brush_editor->shell);
|
2001-02-18 05:20:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor_name_activate (GtkWidget *widget,
|
|
|
|
BrushEditor *brush_editor)
|
2001-02-18 05:20:10 +08:00
|
|
|
{
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
const gchar *entry_text;
|
2001-02-18 05:20:10 +08:00
|
|
|
|
|
|
|
entry_text = gtk_entry_get_text (GTK_ENTRY (widget));
|
2001-05-01 21:16:59 +08:00
|
|
|
gimp_object_set_name (GIMP_OBJECT (brush_editor->brush), entry_text);
|
2001-02-18 05:20:10 +08:00
|
|
|
}
|
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
static gboolean
|
|
|
|
brush_editor_name_focus_out (GtkWidget *widget,
|
|
|
|
GdkEventFocus *fevent,
|
|
|
|
BrushEditor *brush_editor)
|
2001-02-18 05:20:10 +08:00
|
|
|
{
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor_name_activate (widget, brush_editor);
|
|
|
|
|
|
|
|
return FALSE;
|
2001-02-18 05:20:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor_update_brush (GtkAdjustment *adjustment,
|
|
|
|
BrushEditor *brush_editor)
|
2001-02-18 05:20:10 +08:00
|
|
|
{
|
2001-05-01 21:16:59 +08:00
|
|
|
if (brush_editor->brush &&
|
|
|
|
((brush_editor->radius_data->value
|
|
|
|
!= gimp_brush_generated_get_radius (brush_editor->brush))
|
|
|
|
|| (brush_editor->hardness_data->value
|
|
|
|
!= gimp_brush_generated_get_hardness (brush_editor->brush))
|
|
|
|
|| (brush_editor->aspect_ratio_data->value
|
|
|
|
!= gimp_brush_generated_get_aspect_ratio (brush_editor->brush))
|
|
|
|
|| (brush_editor->angle_data->value
|
|
|
|
!= gimp_brush_generated_get_angle (brush_editor->brush))))
|
2001-02-18 05:20:10 +08:00
|
|
|
{
|
2001-05-01 21:16:59 +08:00
|
|
|
gimp_brush_generated_freeze (brush_editor->brush);
|
|
|
|
gimp_brush_generated_set_radius (brush_editor->brush,
|
|
|
|
brush_editor->radius_data->value);
|
|
|
|
gimp_brush_generated_set_hardness (brush_editor->brush,
|
|
|
|
brush_editor->hardness_data->value);
|
|
|
|
gimp_brush_generated_set_aspect_ratio (brush_editor->brush,
|
|
|
|
brush_editor->aspect_ratio_data->value);
|
|
|
|
gimp_brush_generated_set_angle (brush_editor->brush,
|
|
|
|
brush_editor->angle_data->value);
|
|
|
|
gimp_brush_generated_thaw (brush_editor->brush);
|
2001-02-18 05:20:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
static void
|
|
|
|
brush_editor_preview_resize (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
BrushEditor *brush_editor)
|
1998-07-16 19:44:56 +08:00
|
|
|
{
|
2001-05-01 21:16:59 +08:00
|
|
|
if (brush_editor->brush)
|
|
|
|
brush_editor_brush_dirty (GIMP_BRUSH (brush_editor->brush), brush_editor);
|
1998-07-16 19:44:56 +08:00
|
|
|
}
|
2001-02-14 22:57:14 +08:00
|
|
|
|
1998-07-15 20:15:24 +08:00
|
|
|
static void
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor_clear_preview (BrushEditor *brush_editor)
|
1998-07-15 20:15:24 +08:00
|
|
|
{
|
2001-02-18 05:20:10 +08:00
|
|
|
guchar *buf;
|
|
|
|
gint i;
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
buf = g_new (guchar, brush_editor->preview->allocation.width);
|
2001-02-18 05:20:10 +08:00
|
|
|
|
|
|
|
/* Set the buffer to white */
|
2001-05-01 21:16:59 +08:00
|
|
|
memset (buf, 255, brush_editor->preview->allocation.width);
|
2001-02-18 05:20:10 +08:00
|
|
|
|
|
|
|
/* Set the image buffer to white */
|
2001-05-01 21:16:59 +08:00
|
|
|
for (i = 0; i < brush_editor->preview->allocation.height; i++)
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (brush_editor->preview), buf, 0, i,
|
|
|
|
brush_editor->preview->allocation.width);
|
2001-02-18 05:20:10 +08:00
|
|
|
|
|
|
|
g_free (buf);
|
|
|
|
}
|
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
static void
|
|
|
|
brush_editor_brush_dirty (GimpBrush *brush,
|
|
|
|
BrushEditor *brush_editor)
|
2001-02-18 05:20:10 +08:00
|
|
|
{
|
2001-05-01 21:16:59 +08:00
|
|
|
gint x, y, width, yend, ystart, xo;
|
|
|
|
gint scale;
|
|
|
|
guchar *src, *buf;
|
|
|
|
|
|
|
|
brush_editor_clear_preview (brush_editor);
|
2001-02-18 05:20:10 +08:00
|
|
|
|
|
|
|
if (brush == NULL || brush->mask == NULL)
|
2001-05-01 21:16:59 +08:00
|
|
|
return;
|
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
scale = MAX (ceil (brush->mask->width/
|
2001-05-01 21:16:59 +08:00
|
|
|
(float) brush_editor->preview->allocation.width),
|
2001-02-18 05:20:10 +08:00
|
|
|
ceil (brush->mask->height/
|
2001-05-01 21:16:59 +08:00
|
|
|
(float) brush_editor->preview->allocation.height));
|
2001-02-18 05:20:10 +08:00
|
|
|
|
|
|
|
ystart = 0;
|
2001-05-01 21:16:59 +08:00
|
|
|
xo = brush_editor->preview->allocation.width / 2 - brush->mask->width / (2 * scale);
|
|
|
|
ystart = brush_editor->preview->allocation.height / 2 - brush->mask->height / (2 * scale);
|
|
|
|
yend = ystart + brush->mask->height / scale;
|
|
|
|
width = CLAMP (brush->mask->width/scale, 0, brush_editor->preview->allocation.width);
|
2001-02-18 05:20:10 +08:00
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
buf = g_new (guchar, width);
|
|
|
|
src = (guchar *) temp_buf_data (brush->mask);
|
2001-02-18 05:20:10 +08:00
|
|
|
|
|
|
|
for (y = ystart; y < yend; y++)
|
|
|
|
{
|
|
|
|
/* Invert the mask for display.
|
|
|
|
*/
|
|
|
|
for (x = 0; x < width; x++)
|
2001-05-01 21:16:59 +08:00
|
|
|
buf[x] = 255 - src[x * scale];
|
|
|
|
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (brush_editor->preview), buf,
|
|
|
|
xo, y, width);
|
|
|
|
|
|
|
|
src += brush->mask->width * scale;
|
2001-02-18 05:20:10 +08:00
|
|
|
}
|
2001-05-01 21:16:59 +08:00
|
|
|
|
2001-02-18 05:20:10 +08:00
|
|
|
g_free (buf);
|
2001-05-01 21:16:59 +08:00
|
|
|
|
|
|
|
if (brush_editor->scale != scale)
|
2001-02-18 05:20:10 +08:00
|
|
|
{
|
|
|
|
gchar str[255];
|
2001-05-01 21:16:59 +08:00
|
|
|
|
|
|
|
brush_editor->scale = scale;
|
2001-02-18 05:20:10 +08:00
|
|
|
g_snprintf (str, sizeof (str), "%d:1", scale);
|
2001-05-01 21:16:59 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (brush_editor->scale_label), str);
|
2001-02-18 05:20:10 +08:00
|
|
|
}
|
2001-05-01 21:16:59 +08:00
|
|
|
|
|
|
|
gtk_widget_queue_draw (brush_editor->preview);
|
2001-02-18 05:20:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-05-01 21:16:59 +08:00
|
|
|
brush_editor_brush_name_changed (GtkWidget *widget,
|
|
|
|
BrushEditor *brush_editor)
|
2001-02-18 05:20:10 +08:00
|
|
|
{
|
2001-05-01 21:16:59 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (brush_editor->name),
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (brush_editor->brush)));
|
1998-07-15 20:15:24 +08:00
|
|
|
}
|