diff --git a/ChangeLog b/ChangeLog index 36878e2aa78bc57b784c8e5aea3e32e6ce7443f0..c925011691347fc4db28c5091076a636f62b0fd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,49 @@ +2000-01-14 Michael Natterer + + * app/Makefile.am + * app/tool_options_ui.h: removed. + + * app/tool_options.c + * libgimp/gimpwidgets.[ch]: moved some more ui utility functions + to libgimp. + + * app/airbrush.c + * app/blend.c + * app/bucket_fill.c + * app/channel_ops.c + * app/clone.c + * app/color_picker.c + * app/convolve.c + * app/crop.c + * app/dodgeburn.c + * app/eraser.c + * app/file_new_dialog.[ch] + * app/flip_tool.c + * app/image_new.[ch] + * app/ink.c + * app/layers_dialog.c + * app/magnify.c + * app/measure.c + * app/paintbrush.c + * app/pencil.c + * app/smudge.c + * app/text_tool.c + * app/tool_options.c + * app/transform_tool.c + * app/xinput_airbrush.c: use the libgimp functions (esp. the radio + button group constructor), some code cleanup. + + * plug-ins/common/csource.c + * plug-ins/common/despeckle.c + * plug-ins/common/diffraction.c + * plug-ins/common/jpeg.c + * plug-ins/common/png.c + * plug-ins/unsharp/unsharp.c: more plugin ui tuning. + + * plug-ins/unsharp/Makefile.am + * plug-ins/unsharp/dialog_f.[ch] + * plug-ins/unsharp/dialog_i.[ch]: removed. + Thu Jan 13 16:35:44 PST 2000 Manish Singh * Made 1.1.15 release diff --git a/app/Makefile.am b/app/Makefile.am index c2a42a0fafe98baf48533434abab7123844870d1..b3124ead8784e75f9dff241c35ceea22db06d53a 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -419,7 +419,6 @@ gimp_SOURCES = \ tips_dialog.h \ tool_options.c \ tool_options.h \ - tool_options_ui.h \ tools.c \ tools.h \ toolsF.h \ diff --git a/app/airbrush.c b/app/airbrush.c index 20ea00d7a788162c723e6342582e4b86e2704897..6ff505297215237146abd7daa306ff526cba7c46 100644 --- a/app/airbrush.c +++ b/app/airbrush.c @@ -30,7 +30,6 @@ #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpintl.h" @@ -114,7 +113,7 @@ airbrush_options_new (void) GtkWidget *scale; /* the new airbrush tool options structure */ - options = (AirbrushOptions *) g_malloc (sizeof (AirbrushOptions)); + options = g_new (AirbrushOptions, 1); paint_options_init ((PaintOptions *) options, AIRBRUSH, airbrush_options_reset); @@ -136,7 +135,7 @@ airbrush_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->rate); gimp_table_attach_aligned (GTK_TABLE (table), 0, _("Rate:"), 1.0, 1.0, @@ -149,7 +148,7 @@ airbrush_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->pressure_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->pressure); gimp_table_attach_aligned (GTK_TABLE (table), 1, _("Pressure:"), 1.0, 1.0, @@ -200,10 +199,10 @@ airbrush_paint_func (PaintCore *paint_core, case INIT_PAINT : /* timer_state = OFF; */ if (timer_state == ON) - { - g_warning ("killing stray timer, please report to lewing@gimp.org"); - gtk_timeout_remove (timer); - } + { + g_warning ("killing stray timer, please report to lewing@gimp.org"); + gtk_timeout_remove (timer); + } timer_state = OFF; break; diff --git a/app/blend.c b/app/blend.c index a864a060a046fd98aef139b9972aa732d4c016da..9dd16ef55188f64047ac23529710cfd67a0d2d24 100644 --- a/app/blend.c +++ b/app/blend.c @@ -34,7 +34,6 @@ #include "interface.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" @@ -46,35 +45,37 @@ /* target size */ -#define TARGET_HEIGHT 15 -#define TARGET_WIDTH 15 +#define TARGET_HEIGHT 15 +#define TARGET_WIDTH 15 #define STATUSBAR_SIZE 128 /* the blend structures */ -typedef double (*RepeatFunc)(double); +typedef gdouble (* RepeatFunc) (gdouble); typedef struct _BlendTool BlendTool; + struct _BlendTool { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - int startx; /* starting x coord */ - int starty; /* starting y coord */ + gint startx; /* starting x coord */ + gint starty; /* starting y coord */ - int endx; /* ending x coord */ - int endy; /* ending y coord */ - guint context_id; /* for the statusbar */ + gint endx; /* ending x coord */ + gint endy; /* ending y coord */ + guint context_id; /* for the statusbar */ }; typedef struct _BlendOptions BlendOptions; + struct _BlendOptions { PaintOptions paint_options; - double offset; - double offset_d; + gdouble offset; + gdouble offset_d; GtkObject *offset_w; BlendMode blend_mode; @@ -89,37 +90,37 @@ struct _BlendOptions RepeatMode repeat_d; GtkWidget *repeat_w; - int supersample; - int supersample_d; + gint supersample; + gint supersample_d; GtkWidget *supersample_w; - int max_depth; - int max_depth_d; + gint max_depth; + gint max_depth_d; GtkObject *max_depth_w; - double threshold; - double threshold_d; + gdouble threshold; + gdouble threshold_d; GtkObject *threshold_w; }; typedef struct { - double offset; - double sx, sy; + gdouble offset; + gdouble sx, sy; BlendMode blend_mode; GradientType gradient_type; color_t fg, bg; - double dist; - double vec[2]; + gdouble dist; + gdouble vec[2]; RepeatFunc repeat_func; } RenderBlendData; typedef struct { - PixelRegion *PR; - unsigned char *row_data; - int bytes; - int width; + PixelRegion *PR; + guchar *row_data; + gint bytes; + gint width; } PutPixelData; @@ -302,7 +303,7 @@ blend_options_new () }; /* the new blend tool options structure */ - options = (BlendOptions *) g_malloc (sizeof (BlendOptions)); + options = g_new (BlendOptions, 1); paint_options_init ((PaintOptions *) options, BLEND, blend_options_reset); @@ -333,7 +334,7 @@ blend_options_new () _("Offset:"), 1.0, 1.0, scale, FALSE); gtk_signal_connect (GTK_OBJECT (options->offset_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->offset); /* the blend mode menu */ @@ -380,7 +381,7 @@ blend_options_new () gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->supersample_w), options->supersample_d); gtk_signal_connect (GTK_OBJECT (options->supersample_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->supersample); gtk_box_pack_start (GTK_BOX (vbox), options->supersample_w, FALSE, FALSE, 0); gtk_widget_show (options->supersample_w); @@ -407,7 +408,7 @@ blend_options_new () _("Max Depth:"), 1.0, 1.0, scale, FALSE); gtk_signal_connect (GTK_OBJECT(options->max_depth_w), "value_changed", - (GtkSignalFunc) tool_options_int_adjustment_update, + GTK_SIGNAL_FUNC (gimp_int_adjustment_update), &options->max_depth); /* threshold scale */ @@ -420,7 +421,7 @@ blend_options_new () _("Threshold:"), 1.0, 1.0, scale, FALSE); gtk_signal_connect (GTK_OBJECT(options->threshold_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->threshold); /* show the table */ diff --git a/app/bucket_fill.c b/app/bucket_fill.c index 3a46140b960f4a4d549e7df0bff8c1067c4f0846..44e035a29efae23b20382db2bcc26a6cadc498c3 100644 --- a/app/bucket_fill.c +++ b/app/bucket_fill.c @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include "gdk/gdkkeysyms.h" + +#include + #include "appenv.h" #include "bucket_fill.h" #include "cursorutil.h" @@ -24,11 +26,11 @@ #include "fuzzy_select.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "interface.h" #include "paint_funcs.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" @@ -104,12 +106,6 @@ bucket_options_new (void) GtkWidget *label; GtkWidget *scale; GtkWidget *frame; - gchar* fill_mode_label[3] = { N_("FG Color Fill"), - N_("BG Color Fill"), - N_("Pattern Fill") }; - gint fill_mode_value[3] = { FG_BUCKET_FILL, - BG_BUCKET_FILL, - PATTERN_BUCKET_FILL }; /* the new bucket fill tool options structure */ options = (BucketOptions *) g_malloc (sizeof (BucketOptions)); @@ -139,7 +135,7 @@ bucket_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->threshold_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->threshold); gtk_widget_show (scale); @@ -149,19 +145,29 @@ bucket_options_new (void) options->sample_merged_w = gtk_check_button_new_with_label (_("Sample Merged")); gtk_signal_connect (GTK_OBJECT (options->sample_merged_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->sample_merged); gtk_box_pack_start (GTK_BOX (vbox), options->sample_merged_w, FALSE, FALSE, 0); gtk_widget_show (options->sample_merged_w); /* fill type */ - frame = tool_options_radio_buttons_new (_("Fill Type"), - &options->fill_mode, - options->fill_mode_w, - fill_mode_label, - fill_mode_value, - 3); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->fill_mode_w[options->fill_mode_d]), TRUE); + frame = + gimp_radio_group_new2 (TRUE, _("Fill Type"), + gimp_radio_button_update, + &options->fill_mode, (gpointer) options->fill_mode, + + _("FG Color Fill"), + (gpointer) FG_BUCKET_FILL, + &options->fill_mode_w[0], + _("BG Color Fill"), + (gpointer) BG_BUCKET_FILL, + &options->fill_mode_w[1], + _("Pattern Fill"), + (gpointer) PATTERN_BUCKET_FILL, + &options->fill_mode_w[2], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/channel_ops.c b/app/channel_ops.c index 29d888c276a5c99fd92f18ffeb61972c5f593a37..dd60bd921322d40161ec82895194cf68c284bc37 100644 --- a/app/channel_ops.c +++ b/app/channel_ops.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include + #include "appenv.h" #include "channel_ops.h" #include "cursorutil.h" @@ -28,6 +28,7 @@ #include "interface.h" #include "libgimp/gimpsizeentry.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimpintl.h" #include "channel_pvt.h" @@ -43,8 +44,6 @@ struct _OffsetDialog GtkWidget *off_se; gboolean wrap_around; - - GtkWidget *fill_options; ChannelOffsetType fill_type; GimpImage *gimage; @@ -54,8 +53,6 @@ struct _OffsetDialog static void offset_ok_callback (GtkWidget *, gpointer); static void offset_cancel_callback (GtkWidget *, gpointer); -static void offset_wraparound_update (GtkWidget *, gpointer); -static void offset_fill_type_update (GtkWidget *, gpointer); static void offset_halfheight_callback (GtkWidget *, gpointer); @@ -70,9 +67,8 @@ channel_ops_offset (GimpImage* gimage) GtkWidget *table; GtkObject *adjustment; GtkWidget *spinbutton; - GtkWidget *radio_box; + GtkWidget *frame; GtkWidget *radio_button; - GSList *group = NULL; GimpDrawable *drawable; @@ -167,39 +163,22 @@ channel_ops_offset (GimpImage* gimage) gtk_widget_show (check); /* The fill options */ - off_d->fill_options = gtk_frame_new (_("Fill Options")); - gtk_box_pack_start (GTK_BOX (vbox), off_d->fill_options, FALSE, FALSE, 0); - - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (off_d->fill_options), radio_box); - - radio_button = gtk_radio_button_new_with_label (group, _("Background")); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "fill_type", - (gpointer) OFFSET_BACKGROUND); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) offset_fill_type_update, - off_d); - gtk_widget_show (radio_button); - - radio_button = gtk_radio_button_new_with_label (group, _("Transparent")); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "fill_type", - (gpointer) OFFSET_TRANSPARENT); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) offset_fill_type_update, - off_d); - gtk_widget_show (radio_button); - if (drawable_has_alpha (drawable)) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button), TRUE); - else - gtk_widget_set_sensitive (radio_button, FALSE); + frame = + gimp_radio_group_new2 (TRUE, _("Fill Options"), + gimp_radio_button_update, + &off_d->fill_type, (gpointer) off_d->fill_type, + + _("Background"), (gpointer) OFFSET_BACKGROUND, NULL, + _("Transparent"), (gpointer) OFFSET_TRANSPARENT, + &radio_button, - gtk_widget_show (radio_box); - gtk_widget_show (off_d->fill_options); + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + if (!drawable_has_alpha (drawable)) + gtk_widget_set_sensitive (radio_button, FALSE); /* The by half height and half width option */ push = gtk_button_new_with_label (_("Offset by (x/2),(y/2)")); @@ -209,8 +188,9 @@ channel_ops_offset (GimpImage* gimage) /* Hook up the wrap around */ gtk_signal_connect (GTK_OBJECT (check), "toggled", - (GtkSignalFunc) offset_wraparound_update, - off_d); + GTK_SIGNAL_FUNC (gimp_toggle_button_update), + &off_d->wrap_around); + gtk_object_set_data (GTK_OBJECT (check), "inverse_sensitive", frame); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), off_d->wrap_around); /* Hook up the by half */ @@ -505,32 +485,6 @@ offset_cancel_callback (GtkWidget *widget, g_free (off_d); } -static void -offset_wraparound_update (GtkWidget *widget, - gpointer data) -{ - OffsetDialog *off_d; - - off_d = (OffsetDialog *) data; - - off_d->wrap_around = GTK_TOGGLE_BUTTON (widget)->active ? TRUE : FALSE; - - gtk_widget_set_sensitive (off_d->fill_options, !off_d->wrap_around); -} - -static void -offset_fill_type_update (GtkWidget *widget, - gpointer data) -{ - OffsetDialog *off_d; - - off_d = (OffsetDialog *) data; - - if (GTK_TOGGLE_BUTTON (widget)->active) - off_d->fill_type = - (ChannelOffsetType) gtk_object_get_data (GTK_OBJECT (widget), "fill_type"); -} - static void offset_halfheight_callback (GtkWidget *widget, gpointer data) diff --git a/app/clone.c b/app/clone.c index 4e2c4b1246c66d4077ef492a0b179f67fda2a73d..10d23f90fa53ac6c2d6f874a08170c7025a8ad80 100644 --- a/app/clone.c +++ b/app/clone.c @@ -1,4 +1,4 @@ - /* The GIMP -- an image manipulation program +/* 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 @@ -15,13 +15,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include + #include "appenv.h" #include "drawable.h" #include "errors.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "interface.h" #include "paint_funcs.h" #include "paint_core.h" @@ -50,6 +54,7 @@ typedef enum } AlignType; typedef struct _CloneOptions CloneOptions; + struct _CloneOptions { PaintOptions paint_options; @@ -98,20 +103,6 @@ static void clone_line_pattern (GImage *, GimpDrawable *, GPattern *, /* functions */ -static void -clone_type_callback (GtkWidget *widget, - gpointer data) -{ - clone_options->type = (CloneType) data; -} - -static void -align_type_callback (GtkWidget *widget, - gpointer data) -{ - clone_options->aligned = (AlignType) data; -} - static void clone_options_reset (void) { @@ -127,31 +118,11 @@ static CloneOptions * clone_options_new (void) { CloneOptions *options; - GtkWidget *vbox; - GSList *group = NULL; - GtkWidget *radio_frame; - GtkWidget *radio_box; - GtkWidget *radio_button; - int i; - - static gchar *source_names[] = - { - N_("Image Source"), - N_("Pattern Source") - }; - static gint n_source_names = sizeof (source_names) / sizeof (source_names[0]); - - static gchar *align_names[] = - { - N_("Non Aligned"), - N_("Aligned"), - N_("Registered") - }; - static gint n_align_names = sizeof (align_names) / sizeof (align_names[0]); + GtkWidget *frame; /* the new clone tool options structure */ - options = (CloneOptions *) g_malloc (sizeof (CloneOptions)); + options = g_new (CloneOptions, 1); paint_options_init ((PaintOptions *) options, CLONE, clone_options_reset); @@ -161,56 +132,35 @@ clone_options_new (void) /* the main vbox */ vbox = ((ToolOptions *) options)->main_vbox; - /* the radio frame and box */ - radio_frame = gtk_frame_new (_("Source")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + frame = gimp_radio_group_new2 (TRUE, _("Source"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + _("Image Source"), (gpointer) IMAGE_CLONE, + &options->type_w[0], + _("Pattern Source"), (gpointer) PATTERN_CLONE, + &options->type_w[1], - /* the radio buttons */ - for (i = 0; i < n_source_names; i++) - { - radio_button = gtk_radio_button_new_with_label (group, - gettext(source_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) clone_type_callback, - (void *)((long) i)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_widget_show (radio_button); - - options->type_w[i] = radio_button; - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + NULL); - /* the radio frame and box */ - radio_frame = gtk_frame_new (_("Alignment")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + frame = gimp_radio_group_new2 (TRUE, _("Alignment"), + gimp_radio_button_update, + &options->aligned, (gpointer) options->aligned, - /* the radio buttons */ - group = NULL; - for (i = 0; i < n_align_names; i++) - { - radio_button = gtk_radio_button_new_with_label (group, - gettext(align_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) align_type_callback, - (void *)((long) i)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_widget_show (radio_button); - - options->aligned_w[i] = radio_button; - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + _("Non Aligned"), (gpointer) ALIGN_NO, + &options->aligned_w[0], + _("Aligned"), (gpointer) ALIGN_YES, + &options->aligned_w[1], + _("Registered"), (gpointer) ALIGN_REGISTERED, + &options->aligned_w[2], + + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); return options; } @@ -227,27 +177,25 @@ clone_src_drawable_destroyed_cb (GimpDrawable *drawable, } static void -clone_set_src_drawable(GimpDrawable *drawable) +clone_set_src_drawable (GimpDrawable *drawable) { if (src_drawable_ == drawable) return; if (src_drawable_) - gtk_signal_disconnect_by_data(GTK_OBJECT (src_drawable_), &src_drawable_); + gtk_signal_disconnect_by_data (GTK_OBJECT (src_drawable_), &src_drawable_); src_drawable_ = drawable; if (drawable) - { - gtk_signal_connect (GTK_OBJECT (drawable), - "destroy", - GTK_SIGNAL_FUNC (clone_src_drawable_destroyed_cb), - &src_drawable_); - } + { + gtk_signal_connect (GTK_OBJECT (drawable), "destroy", + GTK_SIGNAL_FUNC (clone_src_drawable_destroyed_cb), + &src_drawable_); + } } - void * clone_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + gint state) { GDisplay * gdisp; GDisplay * src_gdisp; @@ -258,10 +206,10 @@ clone_paint_func (PaintCore *paint_core, switch (state) { - case PRETRACE_PAINT : + case PRETRACE_PAINT: draw_core_pause (paint_core->core, active_tool); break; - case MOTION_PAINT : + case MOTION_PAINT: x1 = paint_core->curx; y1 = paint_core->cury; x2 = paint_core->lastx; @@ -302,7 +250,7 @@ clone_paint_func (PaintCore *paint_core, break; - case INIT_PAINT : + case INIT_PAINT: if (paint_core->state & GDK_CONTROL_MASK) { the_src_gdisp = gdisp; @@ -312,27 +260,27 @@ clone_paint_func (PaintCore *paint_core, first = TRUE; } else if (clone_options->aligned == ALIGN_NO) - { - first = TRUE; - orig_src_x = src_x; - orig_src_y = src_y; - } + { + first = TRUE; + orig_src_x = src_x; + orig_src_y = src_y; + } if (clone_options->type == PATTERN_CLONE) if (! gimp_context_get_pattern (NULL)) g_message (_("No patterns available for this operation.")); break; - case FINISH_PAINT : + case FINISH_PAINT: draw_core_stop (paint_core->core, active_tool); if (clone_options->aligned == ALIGN_NO && !first) - { - src_x = orig_src_x; - src_y = orig_src_y; - } + { + src_x = orig_src_x; + src_y = orig_src_y; + } return NULL; break; - default : + default: break; } @@ -350,11 +298,12 @@ clone_paint_func (PaintCore *paint_core, src_gdisp->canvas->window, active_tool); else if (state == POSTTRACE_PAINT) - { - /* Find the target cursor's location onscreen */ - gdisplay_transform_coords (src_gdisp, src_x, src_y, &trans_tx, &trans_ty, 1); - draw_core_resume (paint_core->core, active_tool); - } + { + /* Find the target cursor's location onscreen */ + gdisplay_transform_coords (src_gdisp, src_x, src_y, + &trans_tx, &trans_ty, 1); + draw_core_resume (paint_core->core, active_tool); + } return NULL; } @@ -393,19 +342,18 @@ clone_cursor_update (Tool *tool, } if (clone_options->type == IMAGE_CLONE) - { - if (mevent->state & GDK_CONTROL_MASK) - ctype = GDK_CROSSHAIR; - else if (!src_drawable_) - ctype = GIMP_BAD_CURSOR; - } + { + if (mevent->state & GDK_CONTROL_MASK) + ctype = GDK_CROSSHAIR; + else if (!src_drawable_) + ctype = GIMP_BAD_CURSOR; + } gdisplay_install_tool_cursor (gdisp, ctype); } - Tool * -tools_new_clone () +tools_new_clone (void) { Tool * tool; PaintCore * private; diff --git a/app/color_picker.c b/app/color_picker.c index 01e25804a79e2294ec682405235a7c1e3add0409..60216c1b2c3410e92c68a6d34bbe1af653c58ea3 100644 --- a/app/color_picker.c +++ b/app/color_picker.c @@ -25,7 +25,6 @@ #include "cursorutil.h" #include "info_dialog.h" #include "palette.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimprc.h" @@ -158,7 +157,7 @@ color_picker_options_new (void) options->sample_merged_d); gtk_box_pack_start (GTK_BOX (vbox), options->sample_merged_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->sample_merged_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->sample_merged); gtk_widget_show (options->sample_merged_w); @@ -174,7 +173,7 @@ color_picker_options_new (void) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->sample_average_w), options->sample_average_d); gtk_signal_connect (GTK_OBJECT (options->sample_average_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->sample_average); gtk_widget_show (options->sample_average_w); @@ -204,7 +203,7 @@ color_picker_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->average_radius_w), "value_changed", - GTK_SIGNAL_FUNC (tool_options_double_adjustment_update), + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->average_radius); gtk_widget_show (scale); gtk_widget_show (table); @@ -216,7 +215,7 @@ color_picker_options_new (void) options->update_active_d); gtk_box_pack_start (GTK_BOX (vbox), options->update_active_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->update_active_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->update_active); gtk_widget_show (options->update_active_w); diff --git a/app/convolve.c b/app/convolve.c index fdab91ae78c960b8833d5f01937286bcb740b75a..56c6bfd343920c03fbe6a35e30ba3f74c1b866f5 100644 --- a/app/convolve.c +++ b/app/convolve.c @@ -16,18 +16,19 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include -#include "gdk/gdkkeysyms.h" + +#include + #include "appenv.h" #include "drawable.h" #include "errors.h" #include "convolve.h" #include "gdisplay.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimage.h" @@ -46,6 +47,7 @@ /* the convolve structures */ typedef struct _ConvolveOptions ConvolveOptions; + struct _ConvolveOptions { PaintOptions paint_options; @@ -54,8 +56,8 @@ struct _ConvolveOptions ConvolveType type_d; GtkWidget *type_w[2]; - double rate; - double rate_d; + gdouble rate; + gdouble rate_d; GtkObject *rate_w; }; @@ -64,14 +66,14 @@ struct _ConvolveOptions static ConvolveOptions * convolve_options = NULL; /* local variables */ -static int matrix [25]; -static int matrix_size; -static int matrix_divisor; +static gint matrix [25]; +static gint matrix_size; +static gint matrix_divisor; static ConvolveType non_gui_type; -static double non_gui_rate; +static gdouble non_gui_rate; -static float custom_matrix [25] = +static gfloat custom_matrix [25] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -80,7 +82,7 @@ static float custom_matrix [25] = 0, 0, 0, 0, 0, }; -static float blur_matrix [25] = +static gfloat blur_matrix [25] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, @@ -89,7 +91,7 @@ static float blur_matrix [25] = 0, 0 ,0, 0, 0, }; -static float sharpen_matrix [25] = +static gfloat sharpen_matrix [25] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, @@ -133,11 +135,9 @@ convolve_options_new (void) GtkWidget *label; GtkWidget *scale; GtkWidget *frame; - gchar* type_label[2] = { N_("Blur"), N_("Sharpen") }; - gint type_value[2] = { BLUR_CONVOLVE, SHARPEN_CONVOLVE }; /* the new convolve tool options structure */ - options = (ConvolveOptions *) g_malloc (sizeof (ConvolveOptions)); + options = g_new (ConvolveOptions, 1); paint_options_init ((PaintOptions *) options, CONVOLVE, convolve_options_reset); @@ -163,18 +163,22 @@ convolve_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->rate); gtk_widget_show (scale); gtk_widget_show (hbox); - frame = tool_options_radio_buttons_new (_("Convolve Type"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); + frame = gimp_radio_group_new2 (TRUE, _("Convolve Type"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Blur"), (gpointer) BLUR_CONVOLVE, + &options->type_w[0], + _("Sharpen"), (gpointer) SHARPEN_CONVOLVE, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c index a864a060a046fd98aef139b9972aa732d4c016da..9dd16ef55188f64047ac23529710cfd67a0d2d24 100644 --- a/app/core/gimpdrawable-blend.c +++ b/app/core/gimpdrawable-blend.c @@ -34,7 +34,6 @@ #include "interface.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" @@ -46,35 +45,37 @@ /* target size */ -#define TARGET_HEIGHT 15 -#define TARGET_WIDTH 15 +#define TARGET_HEIGHT 15 +#define TARGET_WIDTH 15 #define STATUSBAR_SIZE 128 /* the blend structures */ -typedef double (*RepeatFunc)(double); +typedef gdouble (* RepeatFunc) (gdouble); typedef struct _BlendTool BlendTool; + struct _BlendTool { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - int startx; /* starting x coord */ - int starty; /* starting y coord */ + gint startx; /* starting x coord */ + gint starty; /* starting y coord */ - int endx; /* ending x coord */ - int endy; /* ending y coord */ - guint context_id; /* for the statusbar */ + gint endx; /* ending x coord */ + gint endy; /* ending y coord */ + guint context_id; /* for the statusbar */ }; typedef struct _BlendOptions BlendOptions; + struct _BlendOptions { PaintOptions paint_options; - double offset; - double offset_d; + gdouble offset; + gdouble offset_d; GtkObject *offset_w; BlendMode blend_mode; @@ -89,37 +90,37 @@ struct _BlendOptions RepeatMode repeat_d; GtkWidget *repeat_w; - int supersample; - int supersample_d; + gint supersample; + gint supersample_d; GtkWidget *supersample_w; - int max_depth; - int max_depth_d; + gint max_depth; + gint max_depth_d; GtkObject *max_depth_w; - double threshold; - double threshold_d; + gdouble threshold; + gdouble threshold_d; GtkObject *threshold_w; }; typedef struct { - double offset; - double sx, sy; + gdouble offset; + gdouble sx, sy; BlendMode blend_mode; GradientType gradient_type; color_t fg, bg; - double dist; - double vec[2]; + gdouble dist; + gdouble vec[2]; RepeatFunc repeat_func; } RenderBlendData; typedef struct { - PixelRegion *PR; - unsigned char *row_data; - int bytes; - int width; + PixelRegion *PR; + guchar *row_data; + gint bytes; + gint width; } PutPixelData; @@ -302,7 +303,7 @@ blend_options_new () }; /* the new blend tool options structure */ - options = (BlendOptions *) g_malloc (sizeof (BlendOptions)); + options = g_new (BlendOptions, 1); paint_options_init ((PaintOptions *) options, BLEND, blend_options_reset); @@ -333,7 +334,7 @@ blend_options_new () _("Offset:"), 1.0, 1.0, scale, FALSE); gtk_signal_connect (GTK_OBJECT (options->offset_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->offset); /* the blend mode menu */ @@ -380,7 +381,7 @@ blend_options_new () gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->supersample_w), options->supersample_d); gtk_signal_connect (GTK_OBJECT (options->supersample_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->supersample); gtk_box_pack_start (GTK_BOX (vbox), options->supersample_w, FALSE, FALSE, 0); gtk_widget_show (options->supersample_w); @@ -407,7 +408,7 @@ blend_options_new () _("Max Depth:"), 1.0, 1.0, scale, FALSE); gtk_signal_connect (GTK_OBJECT(options->max_depth_w), "value_changed", - (GtkSignalFunc) tool_options_int_adjustment_update, + GTK_SIGNAL_FUNC (gimp_int_adjustment_update), &options->max_depth); /* threshold scale */ @@ -420,7 +421,7 @@ blend_options_new () _("Threshold:"), 1.0, 1.0, scale, FALSE); gtk_signal_connect (GTK_OBJECT(options->threshold_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->threshold); /* show the table */ diff --git a/app/core/gimpdrawable-offset.c b/app/core/gimpdrawable-offset.c index 29d888c276a5c99fd92f18ffeb61972c5f593a37..dd60bd921322d40161ec82895194cf68c284bc37 100644 --- a/app/core/gimpdrawable-offset.c +++ b/app/core/gimpdrawable-offset.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include + #include "appenv.h" #include "channel_ops.h" #include "cursorutil.h" @@ -28,6 +28,7 @@ #include "interface.h" #include "libgimp/gimpsizeentry.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimpintl.h" #include "channel_pvt.h" @@ -43,8 +44,6 @@ struct _OffsetDialog GtkWidget *off_se; gboolean wrap_around; - - GtkWidget *fill_options; ChannelOffsetType fill_type; GimpImage *gimage; @@ -54,8 +53,6 @@ struct _OffsetDialog static void offset_ok_callback (GtkWidget *, gpointer); static void offset_cancel_callback (GtkWidget *, gpointer); -static void offset_wraparound_update (GtkWidget *, gpointer); -static void offset_fill_type_update (GtkWidget *, gpointer); static void offset_halfheight_callback (GtkWidget *, gpointer); @@ -70,9 +67,8 @@ channel_ops_offset (GimpImage* gimage) GtkWidget *table; GtkObject *adjustment; GtkWidget *spinbutton; - GtkWidget *radio_box; + GtkWidget *frame; GtkWidget *radio_button; - GSList *group = NULL; GimpDrawable *drawable; @@ -167,39 +163,22 @@ channel_ops_offset (GimpImage* gimage) gtk_widget_show (check); /* The fill options */ - off_d->fill_options = gtk_frame_new (_("Fill Options")); - gtk_box_pack_start (GTK_BOX (vbox), off_d->fill_options, FALSE, FALSE, 0); - - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (off_d->fill_options), radio_box); - - radio_button = gtk_radio_button_new_with_label (group, _("Background")); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "fill_type", - (gpointer) OFFSET_BACKGROUND); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) offset_fill_type_update, - off_d); - gtk_widget_show (radio_button); - - radio_button = gtk_radio_button_new_with_label (group, _("Transparent")); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "fill_type", - (gpointer) OFFSET_TRANSPARENT); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) offset_fill_type_update, - off_d); - gtk_widget_show (radio_button); - if (drawable_has_alpha (drawable)) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button), TRUE); - else - gtk_widget_set_sensitive (radio_button, FALSE); + frame = + gimp_radio_group_new2 (TRUE, _("Fill Options"), + gimp_radio_button_update, + &off_d->fill_type, (gpointer) off_d->fill_type, + + _("Background"), (gpointer) OFFSET_BACKGROUND, NULL, + _("Transparent"), (gpointer) OFFSET_TRANSPARENT, + &radio_button, - gtk_widget_show (radio_box); - gtk_widget_show (off_d->fill_options); + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + if (!drawable_has_alpha (drawable)) + gtk_widget_set_sensitive (radio_button, FALSE); /* The by half height and half width option */ push = gtk_button_new_with_label (_("Offset by (x/2),(y/2)")); @@ -209,8 +188,9 @@ channel_ops_offset (GimpImage* gimage) /* Hook up the wrap around */ gtk_signal_connect (GTK_OBJECT (check), "toggled", - (GtkSignalFunc) offset_wraparound_update, - off_d); + GTK_SIGNAL_FUNC (gimp_toggle_button_update), + &off_d->wrap_around); + gtk_object_set_data (GTK_OBJECT (check), "inverse_sensitive", frame); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), off_d->wrap_around); /* Hook up the by half */ @@ -505,32 +485,6 @@ offset_cancel_callback (GtkWidget *widget, g_free (off_d); } -static void -offset_wraparound_update (GtkWidget *widget, - gpointer data) -{ - OffsetDialog *off_d; - - off_d = (OffsetDialog *) data; - - off_d->wrap_around = GTK_TOGGLE_BUTTON (widget)->active ? TRUE : FALSE; - - gtk_widget_set_sensitive (off_d->fill_options, !off_d->wrap_around); -} - -static void -offset_fill_type_update (GtkWidget *widget, - gpointer data) -{ - OffsetDialog *off_d; - - off_d = (OffsetDialog *) data; - - if (GTK_TOGGLE_BUTTON (widget)->active) - off_d->fill_type = - (ChannelOffsetType) gtk_object_get_data (GTK_OBJECT (widget), "fill_type"); -} - static void offset_halfheight_callback (GtkWidget *widget, gpointer data) diff --git a/app/core/gimpimage-duplicate.c b/app/core/gimpimage-duplicate.c index 29d888c276a5c99fd92f18ffeb61972c5f593a37..dd60bd921322d40161ec82895194cf68c284bc37 100644 --- a/app/core/gimpimage-duplicate.c +++ b/app/core/gimpimage-duplicate.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include + #include "appenv.h" #include "channel_ops.h" #include "cursorutil.h" @@ -28,6 +28,7 @@ #include "interface.h" #include "libgimp/gimpsizeentry.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimpintl.h" #include "channel_pvt.h" @@ -43,8 +44,6 @@ struct _OffsetDialog GtkWidget *off_se; gboolean wrap_around; - - GtkWidget *fill_options; ChannelOffsetType fill_type; GimpImage *gimage; @@ -54,8 +53,6 @@ struct _OffsetDialog static void offset_ok_callback (GtkWidget *, gpointer); static void offset_cancel_callback (GtkWidget *, gpointer); -static void offset_wraparound_update (GtkWidget *, gpointer); -static void offset_fill_type_update (GtkWidget *, gpointer); static void offset_halfheight_callback (GtkWidget *, gpointer); @@ -70,9 +67,8 @@ channel_ops_offset (GimpImage* gimage) GtkWidget *table; GtkObject *adjustment; GtkWidget *spinbutton; - GtkWidget *radio_box; + GtkWidget *frame; GtkWidget *radio_button; - GSList *group = NULL; GimpDrawable *drawable; @@ -167,39 +163,22 @@ channel_ops_offset (GimpImage* gimage) gtk_widget_show (check); /* The fill options */ - off_d->fill_options = gtk_frame_new (_("Fill Options")); - gtk_box_pack_start (GTK_BOX (vbox), off_d->fill_options, FALSE, FALSE, 0); - - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (off_d->fill_options), radio_box); - - radio_button = gtk_radio_button_new_with_label (group, _("Background")); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "fill_type", - (gpointer) OFFSET_BACKGROUND); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) offset_fill_type_update, - off_d); - gtk_widget_show (radio_button); - - radio_button = gtk_radio_button_new_with_label (group, _("Transparent")); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "fill_type", - (gpointer) OFFSET_TRANSPARENT); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) offset_fill_type_update, - off_d); - gtk_widget_show (radio_button); - if (drawable_has_alpha (drawable)) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button), TRUE); - else - gtk_widget_set_sensitive (radio_button, FALSE); + frame = + gimp_radio_group_new2 (TRUE, _("Fill Options"), + gimp_radio_button_update, + &off_d->fill_type, (gpointer) off_d->fill_type, + + _("Background"), (gpointer) OFFSET_BACKGROUND, NULL, + _("Transparent"), (gpointer) OFFSET_TRANSPARENT, + &radio_button, - gtk_widget_show (radio_box); - gtk_widget_show (off_d->fill_options); + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + if (!drawable_has_alpha (drawable)) + gtk_widget_set_sensitive (radio_button, FALSE); /* The by half height and half width option */ push = gtk_button_new_with_label (_("Offset by (x/2),(y/2)")); @@ -209,8 +188,9 @@ channel_ops_offset (GimpImage* gimage) /* Hook up the wrap around */ gtk_signal_connect (GTK_OBJECT (check), "toggled", - (GtkSignalFunc) offset_wraparound_update, - off_d); + GTK_SIGNAL_FUNC (gimp_toggle_button_update), + &off_d->wrap_around); + gtk_object_set_data (GTK_OBJECT (check), "inverse_sensitive", frame); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), off_d->wrap_around); /* Hook up the by half */ @@ -505,32 +485,6 @@ offset_cancel_callback (GtkWidget *widget, g_free (off_d); } -static void -offset_wraparound_update (GtkWidget *widget, - gpointer data) -{ - OffsetDialog *off_d; - - off_d = (OffsetDialog *) data; - - off_d->wrap_around = GTK_TOGGLE_BUTTON (widget)->active ? TRUE : FALSE; - - gtk_widget_set_sensitive (off_d->fill_options, !off_d->wrap_around); -} - -static void -offset_fill_type_update (GtkWidget *widget, - gpointer data) -{ - OffsetDialog *off_d; - - off_d = (OffsetDialog *) data; - - if (GTK_TOGGLE_BUTTON (widget)->active) - off_d->fill_type = - (ChannelOffsetType) gtk_object_get_data (GTK_OBJECT (widget), "fill_type"); -} - static void offset_halfheight_callback (GtkWidget *widget, gpointer data) diff --git a/app/core/gimptooloptions.c b/app/core/gimptooloptions.c index d9b967715660f09983a675bccabcff82c0deaab5..03d819a1d76c90b370de286492572a9ee41ed68d 100644 --- a/app/core/gimptooloptions.c +++ b/app/core/gimptooloptions.c @@ -16,13 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" + #include "brush_select.h" #include "gimprc.h" #include "gimpui.h" #include "paint_funcs.h" #include "paint_options.h" #include "selection_options.h" -#include "tool_options_ui.h" #include "libgimp/gimpunitmenu.h" #include "libgimp/gimpintl.h" @@ -49,60 +49,7 @@ static void paint_pressure_options_reset (PaintPressureOptions /* ui helper functions ******************************************************/ -void -tool_options_toggle_update (GtkWidget *widget, - gpointer data) -{ - GtkWidget *set_sensitive; - gboolean *toggle_val; - - toggle_val = (gboolean *) data; - *toggle_val = (GTK_TOGGLE_BUTTON (widget)->active) ? TRUE : FALSE; - - /* a tool options toggle button can set the sensitive state of - * an arbitrary list of widgets - */ - - set_sensitive = - gtk_object_get_data (GTK_OBJECT (widget), "set_sensitive"); - while (set_sensitive) - { - gtk_widget_set_sensitive (GTK_WIDGET (set_sensitive), *toggle_val); - set_sensitive = - gtk_object_get_data (GTK_OBJECT (set_sensitive), "set_sensitive"); - } - - set_sensitive = - gtk_object_get_data (GTK_OBJECT (widget), "inverse_sensitive"); - while (set_sensitive) - { - gtk_widget_set_sensitive (GTK_WIDGET (set_sensitive), ! *toggle_val); - set_sensitive = - gtk_object_get_data (GTK_OBJECT (set_sensitive), "inverse_sensitive"); - } -} - -void -tool_options_int_adjustment_update (GtkWidget *widget, - gpointer data) -{ - gint *val; - - val = (gint *) data; - *val = GTK_ADJUSTMENT (widget)->value; -} - -void -tool_options_double_adjustment_update (GtkWidget *widget, - gpointer data) -{ - gdouble *val; - - val = (gdouble *) data; - *val = GTK_ADJUSTMENT (widget)->value; -} - -void +static void tool_options_opacity_adjustment_update (GtkWidget *widget, gpointer data) { @@ -122,82 +69,6 @@ tool_options_paint_mode_update (GtkWidget *widget, (LayerModeEffects) data); } -void -tool_options_unitmenu_update (GtkWidget *widget, - gpointer data) -{ - GUnit *val; - GtkWidget *spinbutton; - gint digits; - - val = (GUnit *) data; - *val = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget)); - - digits = ((*val == UNIT_PIXEL) ? 0 : - ((*val == UNIT_PERCENT) ? 2 : - (MIN (6, MAX (3, gimp_unit_get_digits (*val)))))); - - spinbutton = - gtk_object_get_data (GTK_OBJECT (widget), "set_digits"); - while (spinbutton) - { - gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits); - spinbutton = gtk_object_get_data (GTK_OBJECT (spinbutton), "set_digits"); - } -} - -static void -tool_options_radio_buttons_update (GtkWidget *widget, - gpointer data) -{ - gint *toggle_val; - - toggle_val = (gint *) data; - if (GTK_TOGGLE_BUTTON (widget)->active) - *toggle_val = (gint) gtk_object_get_data (GTK_OBJECT (widget), - "toggle_value"); -} - -GtkWidget * -tool_options_radio_buttons_new (gchar* label, - gpointer toggle_val, - GtkWidget* button_widget[], - gchar* button_label[], - gint button_value[], - gint num) -{ - GtkWidget *frame; - GtkWidget *vbox; - GSList *group = NULL; - gint i; - - frame = gtk_frame_new (label); - - g_return_val_if_fail (toggle_val != NULL, frame); - - vbox = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - for (i=0; ifeather_w), options->feather_d); gtk_signal_connect (GTK_OBJECT (options->feather_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->feather); gtk_widget_show (options->feather_w); @@ -316,7 +187,7 @@ selection_options_init (SelectionOptions *options, gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->feather_radius_w), "value_changed", - GTK_SIGNAL_FUNC (tool_options_double_adjustment_update), + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->feather_radius); gtk_widget_show (scale); @@ -336,7 +207,7 @@ selection_options_init (SelectionOptions *options, gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w), options->antialias_d); gtk_signal_connect (GTK_OBJECT (options->antialias_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->antialias); gtk_widget_show (options->antialias_w); } @@ -376,7 +247,7 @@ selection_options_init (SelectionOptions *options, gtk_box_pack_start (GTK_BOX (vbox), options->sample_merged_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->sample_merged_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->sample_merged); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->sample_merged_w), options->sample_merged_d); @@ -399,7 +270,7 @@ selection_options_init (SelectionOptions *options, gtk_box_pack_start (GTK_BOX (vbox), options->fixed_size_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->fixed_size_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->fixed_size); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->fixed_size_w), options->fixed_size_d); @@ -429,7 +300,7 @@ selection_options_init (SelectionOptions *options, gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (width_spinbutton), TRUE); gtk_widget_set_usize (width_spinbutton, 75, 0); gtk_signal_connect (GTK_OBJECT (options->fixed_width_w), "value_changed", - GTK_SIGNAL_FUNC (tool_options_double_adjustment_update), + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->fixed_width); gimp_table_attach_aligned (GTK_TABLE (table), 0, _("Width:"), 1.0, 0.5, @@ -445,7 +316,7 @@ selection_options_init (SelectionOptions *options, gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(height_spinbutton), TRUE); gtk_widget_set_usize (height_spinbutton, 75, 0); gtk_signal_connect (GTK_OBJECT (options->fixed_height_w), "value_changed", - GTK_SIGNAL_FUNC (tool_options_double_adjustment_update), + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->fixed_height); gimp_table_attach_aligned (GTK_TABLE (table), 1, _("Height:"), 1.0, 0.5, @@ -454,7 +325,7 @@ selection_options_init (SelectionOptions *options, options->fixed_unit_w = gimp_unit_menu_new ("%a", options->fixed_unit_d, TRUE, TRUE, TRUE); gtk_signal_connect (GTK_OBJECT (options->fixed_unit_w), "unit_changed", - GTK_SIGNAL_FUNC (tool_options_unitmenu_update), + GTK_SIGNAL_FUNC (gimp_unit_menu_update), &options->fixed_unit); gtk_object_set_data (GTK_OBJECT (options->fixed_unit_w), "set_digits", width_spinbutton); @@ -685,7 +556,7 @@ paint_options_init (PaintOptions *options, gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), options->incremental_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->incremental); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w), options->incremental_d); @@ -813,7 +684,7 @@ paint_pressure_options_new (ToolType tool_type) gtk_check_button_new_with_label (_("Opacity")); gtk_container_add (GTK_CONTAINER (hbox), pressure->opacity_w); gtk_signal_connect (GTK_OBJECT (pressure->opacity_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->opacity); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->opacity_w), pressure->opacity_d); @@ -836,7 +707,7 @@ paint_pressure_options_new (ToolType tool_type) pressure->pressure_w = gtk_check_button_new_with_label (_("Pressure")); gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w); gtk_signal_connect (GTK_OBJECT (pressure->pressure_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->pressure); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->pressure_w), pressure->pressure_d); @@ -856,7 +727,7 @@ paint_pressure_options_new (ToolType tool_type) gtk_check_button_new_with_label (_("Rate")); gtk_container_add (GTK_CONTAINER (hbox), pressure->rate_w); gtk_signal_connect (GTK_OBJECT (pressure->rate_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->rate); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->rate_w), pressure->rate_d); @@ -880,7 +751,7 @@ paint_pressure_options_new (ToolType tool_type) gtk_check_button_new_with_label (_("Size")); gtk_container_add (GTK_CONTAINER (hbox), pressure->size_w); gtk_signal_connect (GTK_OBJECT (pressure->size_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->size); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->size_w), pressure->size_d); @@ -900,7 +771,7 @@ paint_pressure_options_new (ToolType tool_type) gtk_check_button_new_with_label (_("Color")); gtk_container_add (GTK_CONTAINER (hbox), pressure->color_w); gtk_signal_connect (GTK_OBJECT (pressure->color_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->color); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->color_w), pressure->color_d); diff --git a/app/crop.c b/app/crop.c index 349e03cb1abf2fa8423bf4cd0771eb4a43a8876f..22c763e68541a9d411753284aeaa3ab7e18437c7 100644 --- a/app/crop.c +++ b/app/crop.c @@ -17,7 +17,8 @@ */ #include -#include "gdk/gdkkeysyms.h" +#include + #include "appenv.h" #include "crop.h" #include "cursorutil.h" @@ -29,7 +30,6 @@ #include "gimphelp.h" #include "gimpui.h" #include "info_dialog.h" -#include "tool_options_ui.h" #include "undo.h" #include "libgimp/gimpsizeentry.h" @@ -50,29 +50,31 @@ /* the crop structures */ typedef struct _Crop Crop; + struct _Crop { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - int startx; /* starting x coord */ - int starty; /* starting y coord */ + gint startx; /* starting x coord */ + gint starty; /* starting y coord */ - int lastx; /* previous x coord */ - int lasty; /* previous y coord */ + gint lastx; /* previous x coord */ + gint lasty; /* previous y coord */ - int x1, y1; /* upper left hand coordinate */ - int x2, y2; /* lower right hand coords */ + gint x1, y1; /* upper left hand coordinate */ + gint x2, y2; /* lower right hand coords */ - int srw, srh; /* width and height of corners */ + gint srw, srh; /* width and height of corners */ - int tx1, ty1; /* transformed coords */ - int tx2, ty2; /* */ + gint tx1, ty1; /* transformed coords */ + gint tx2, ty2; /* */ - int function; /* moving or resizing */ - guint context_id; /* for the statusbar */ + gint function; /* moving or resizing */ + guint context_id; /* for the statusbar */ }; typedef struct _CropOptions CropOptions; + struct _CropOptions { ToolOptions tool_options; @@ -168,11 +170,9 @@ crop_options_new (void) CropOptions *options; GtkWidget *vbox; GtkWidget *frame; - gchar* type_label[2] = { N_("Crop"), N_("Resize") }; - gint type_value[2] = { CROP_CROP, RESIZE_CROP }; /* the new crop tool options structure */ - options = (CropOptions *) g_malloc (sizeof (CropOptions)); + options = g_new (CropOptions, 1); tool_options_init ((ToolOptions *) options, _("Crop & Resize Options"), crop_options_reset); @@ -189,7 +189,7 @@ crop_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), options->layer_only_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->layer_only_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->layer_only); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->layer_only_w), options->layer_only_d); @@ -200,20 +200,24 @@ crop_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), options->allow_enlarge_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->allow_enlarge_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->allow_enlarge); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_enlarge_w), options->allow_enlarge_d); gtk_widget_show (options->allow_enlarge_w); /* tool toggle */ - frame = tool_options_radio_buttons_new (_("Tool Toggle"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); + frame = gimp_radio_group_new2 (TRUE, _("Tool Toggle"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Crop"), (gpointer) CROP_CROP, + &options->type_w[0], + _("Resize"), (gpointer) RESIZE_CROP, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/dialogs/image-new-dialog.c b/app/dialogs/image-new-dialog.c index ea9ba575dc292bd33ac1064ddce0db560c0f42be..a94f150dbde1ea9c738073e7b6f2a01fac3141f9 100644 --- a/app/dialogs/image-new-dialog.c +++ b/app/dialogs/image-new-dialog.c @@ -45,12 +45,11 @@ typedef struct } NewImageInfo; /* new image local functions */ -static void file_new_confirm_dialog (NewImageInfo *); +static void file_new_confirm_dialog (NewImageInfo *); -static void file_new_ok_callback (GtkWidget *, gpointer); -static void file_new_reset_callback (GtkWidget *, gpointer); -static void file_new_cancel_callback (GtkWidget *, gpointer); -static void file_new_toggle_callback (GtkWidget *, gpointer); +static void file_new_ok_callback (GtkWidget *, gpointer); +static void file_new_reset_callback (GtkWidget *, gpointer); +static void file_new_cancel_callback (GtkWidget *, gpointer); static void file_new_resolution_callback (GtkWidget *, gpointer); static void file_new_image_size_callback (GtkWidget *, gpointer); @@ -229,19 +228,6 @@ file_new_confirm_dialog (NewImageInfo *info) gtk_widget_show (info->confirm_dlg); } -static void -file_new_toggle_callback (GtkWidget *widget, - gpointer data) -{ - gint *val; - - if (GTK_TOGGLE_BUTTON (widget)->active) - { - val = data; - *val = (long) gtk_object_get_user_data (GTK_OBJECT (widget)); - } -} - static void file_new_resolution_callback (GtkWidget *widget, gpointer data) @@ -537,9 +523,11 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se), 1, values->height); gtk_signal_connect (GTK_OBJECT (info->size_se), "refval_changed", - (GtkSignalFunc) file_new_image_size_callback, info); + GTK_SIGNAL_FUNC (file_new_image_size_callback), + info); gtk_signal_connect (GTK_OBJECT (info->size_se), "value_changed", - (GtkSignalFunc) file_new_image_size_callback, info); + GTK_SIGNAL_FUNC (file_new_image_size_callback), + info); /* initialize the size label */ file_new_image_size_callback (info->size_se, info); @@ -593,7 +581,8 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) 1, values->yresolution); gtk_signal_connect (GTK_OBJECT (info->resolution_se), "value_changed", - (GtkSignalFunc) file_new_resolution_callback, info); + GTK_SIGNAL_FUNC (file_new_resolution_callback), + info); /* the resolution chainbutton */ info->couple_resolutions = gimp_chain_button_new (GIMP_CHAIN_RIGHT); @@ -633,10 +622,11 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) gtk_box_pack_start (GTK_BOX (radio_box), button, FALSE, TRUE, 0); gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) name_info->type); gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) file_new_toggle_callback, + GTK_SIGNAL_FUNC (gimp_radio_button_update), &values->type); gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) file_new_image_size_callback, info); + GTK_SIGNAL_FUNC (file_new_image_size_callback), + info); if (values->type == name_info->type) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); gtk_widget_show (button); @@ -670,10 +660,11 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) gtk_box_pack_start (GTK_BOX (radio_box), button, TRUE, TRUE, 0); gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) name_info->type); gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) file_new_toggle_callback, + GTK_SIGNAL_FUNC (gimp_radio_button_update), &values->fill_type); gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) file_new_image_size_callback, info); + GTK_SIGNAL_FUNC (file_new_image_size_callback), + info); if (values->fill_type == name_info->type) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); gtk_widget_show (button); diff --git a/app/dialogs/image-new-dialog.h b/app/dialogs/image-new-dialog.h index cc79bea337f537a4db9fd72a89bd87c7bc78f80c..f0441b1ac00339e8f8dd05e46f8333300164448b 100644 --- a/app/dialogs/image-new-dialog.h +++ b/app/dialogs/image-new-dialog.h @@ -1,3 +1,20 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-1999 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. + */ #ifndef __FILE_NEW_DIALOG_H__ #define __FILE_NEW_DIALOG_H__ diff --git a/app/dodgeburn.c b/app/dodgeburn.c index 8050b5fb9bf6bac64d176b81560da7a35a368a58..53fc443de24f4e207cb67f455426292054437f20 100644 --- a/app/dodgeburn.c +++ b/app/dodgeburn.c @@ -20,7 +20,7 @@ #include #include -#include "gdk/gdkkeysyms.h" +#include #include "appenv.h" #include "drawable.h" @@ -28,11 +28,11 @@ #include "dodgeburn.h" #include "gdisplay.h" #include "gimplut.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimage.h" @@ -42,6 +42,7 @@ /* the dodgeburn structures */ typedef struct _DodgeBurnOptions DodgeBurnOptions; + struct _DodgeBurnOptions { PaintOptions paint_options; @@ -54,8 +55,8 @@ struct _DodgeBurnOptions DodgeBurnMode mode_d; GtkWidget *mode_w[3]; - double exposure; - double exposure_d; + gdouble exposure; + gdouble exposure_d; GtkObject *exposure_w; GimpLut *lut; @@ -120,19 +121,8 @@ dodgeburn_options_new (void) GtkWidget *scale; GtkWidget *frame; - gchar* type_label[2] = { N_("Dodge"), N_("Burn") }; - gint type_value[2] = { DODGE, BURN }; - - gchar* mode_label[3] = { N_("Highlights"), - N_("Midtones"), - N_("Shadows") }; - - gint mode_value[3] = { DODGEBURN_HIGHLIGHTS, - DODGEBURN_MIDTONES, - DODGEBURN_SHADOWS }; - /* the new dodgeburn tool options structure */ - options = (DodgeBurnOptions *) g_malloc (sizeof (DodgeBurnOptions)); + options = g_new (DodgeBurnOptions, 1); paint_options_init ((PaintOptions *) options, DODGEBURN, dodgeburn_options_reset); @@ -161,31 +151,42 @@ dodgeburn_options_new (void) gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->exposure_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->exposure); gtk_widget_show (scale); gtk_widget_show (hbox); /* the type (dodge or burn) */ - frame = tool_options_radio_buttons_new (_("Type"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); + frame = gimp_radio_group_new2 (TRUE, _("Type"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Dodge"), (gpointer) DODGE, + &options->type_w[0], + _("Burn"), (gpointer) BURN, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* mode (highlights, midtones, or shadows) */ - frame = tool_options_radio_buttons_new (_("Mode"), - &options->mode, - options->mode_w, - mode_label, - mode_value, - 3); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->mode_w[options->mode_d]), TRUE); + frame = + gimp_radio_group_new2 (TRUE, _("Mode"), + gimp_radio_button_update, + &options->mode, (gpointer) options->mode, + + _("Highlights"), (gpointer) DODGEBURN_HIGHLIGHTS, + &options->mode_w[0], + _("Midtones"), (gpointer) DODGEBURN_MIDTONES, + &options->mode_w[1], + _("Shadows"), (gpointer) DODGEBURN_SHADOWS, + &options->mode_w[2], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/eraser.c b/app/eraser.c index cbcf52dcc86a88dc66e58d3627e268609c92fa73..a7fbb6b900c0d50ef1f001a97d4e2c5874794e54 100644 --- a/app/eraser.c +++ b/app/eraser.c @@ -17,19 +17,20 @@ */ #include -#include "gdk/gdkkeysyms.h" +#include + #include "appenv.h" #include "cursorutil.h" #include "drawable.h" #include "errors.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "eraser.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpintl.h" @@ -93,7 +94,7 @@ eraser_options_new (void) GtkWidget *vbox; /* the new eraser tool options structure */ - options = (EraserOptions *) g_malloc (sizeof (EraserOptions)); + options = g_new (EraserOptions, 1); paint_options_init ((PaintOptions *) options, ERASER, eraser_options_reset); @@ -107,7 +108,7 @@ eraser_options_new (void) options->hard_w = gtk_check_button_new_with_label (_("Hard Edge")); gtk_box_pack_start (GTK_BOX (vbox), options->hard_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->hard_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->hard); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w), options->hard_d); @@ -117,7 +118,7 @@ eraser_options_new (void) options->anti_erase_w = gtk_check_button_new_with_label (_("Anti Erase")); gtk_box_pack_start (GTK_BOX (vbox), options->anti_erase_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->anti_erase_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->anti_erase); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w), options->anti_erase_d); diff --git a/app/file_new_dialog.c b/app/file_new_dialog.c index ea9ba575dc292bd33ac1064ddce0db560c0f42be..a94f150dbde1ea9c738073e7b6f2a01fac3141f9 100644 --- a/app/file_new_dialog.c +++ b/app/file_new_dialog.c @@ -45,12 +45,11 @@ typedef struct } NewImageInfo; /* new image local functions */ -static void file_new_confirm_dialog (NewImageInfo *); +static void file_new_confirm_dialog (NewImageInfo *); -static void file_new_ok_callback (GtkWidget *, gpointer); -static void file_new_reset_callback (GtkWidget *, gpointer); -static void file_new_cancel_callback (GtkWidget *, gpointer); -static void file_new_toggle_callback (GtkWidget *, gpointer); +static void file_new_ok_callback (GtkWidget *, gpointer); +static void file_new_reset_callback (GtkWidget *, gpointer); +static void file_new_cancel_callback (GtkWidget *, gpointer); static void file_new_resolution_callback (GtkWidget *, gpointer); static void file_new_image_size_callback (GtkWidget *, gpointer); @@ -229,19 +228,6 @@ file_new_confirm_dialog (NewImageInfo *info) gtk_widget_show (info->confirm_dlg); } -static void -file_new_toggle_callback (GtkWidget *widget, - gpointer data) -{ - gint *val; - - if (GTK_TOGGLE_BUTTON (widget)->active) - { - val = data; - *val = (long) gtk_object_get_user_data (GTK_OBJECT (widget)); - } -} - static void file_new_resolution_callback (GtkWidget *widget, gpointer data) @@ -537,9 +523,11 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se), 1, values->height); gtk_signal_connect (GTK_OBJECT (info->size_se), "refval_changed", - (GtkSignalFunc) file_new_image_size_callback, info); + GTK_SIGNAL_FUNC (file_new_image_size_callback), + info); gtk_signal_connect (GTK_OBJECT (info->size_se), "value_changed", - (GtkSignalFunc) file_new_image_size_callback, info); + GTK_SIGNAL_FUNC (file_new_image_size_callback), + info); /* initialize the size label */ file_new_image_size_callback (info->size_se, info); @@ -593,7 +581,8 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) 1, values->yresolution); gtk_signal_connect (GTK_OBJECT (info->resolution_se), "value_changed", - (GtkSignalFunc) file_new_resolution_callback, info); + GTK_SIGNAL_FUNC (file_new_resolution_callback), + info); /* the resolution chainbutton */ info->couple_resolutions = gimp_chain_button_new (GIMP_CHAIN_RIGHT); @@ -633,10 +622,11 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) gtk_box_pack_start (GTK_BOX (radio_box), button, FALSE, TRUE, 0); gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) name_info->type); gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) file_new_toggle_callback, + GTK_SIGNAL_FUNC (gimp_radio_button_update), &values->type); gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) file_new_image_size_callback, info); + GTK_SIGNAL_FUNC (file_new_image_size_callback), + info); if (values->type == name_info->type) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); gtk_widget_show (button); @@ -670,10 +660,11 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) gtk_box_pack_start (GTK_BOX (radio_box), button, TRUE, TRUE, 0); gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) name_info->type); gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) file_new_toggle_callback, + GTK_SIGNAL_FUNC (gimp_radio_button_update), &values->fill_type); gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) file_new_image_size_callback, info); + GTK_SIGNAL_FUNC (file_new_image_size_callback), + info); if (values->fill_type == name_info->type) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); gtk_widget_show (button); diff --git a/app/file_new_dialog.h b/app/file_new_dialog.h index cc79bea337f537a4db9fd72a89bd87c7bc78f80c..f0441b1ac00339e8f8dd05e46f8333300164448b 100644 --- a/app/file_new_dialog.h +++ b/app/file_new_dialog.h @@ -1,3 +1,20 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-1999 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. + */ #ifndef __FILE_NEW_DIALOG_H__ #define __FILE_NEW_DIALOG_H__ diff --git a/app/flip_tool.c b/app/flip_tool.c index ec73f71fc461a278d39b5143c7df54079101e13a..9ed4dc02e260596e1d292ce70ffd55f1bc59972f 100644 --- a/app/flip_tool.c +++ b/app/flip_tool.c @@ -16,15 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include "gdk/gdkkeysyms.h" + +#include + #include "appenv.h" #include "cursorutil.h" #include "drawable.h" #include "flip_tool.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "temp_buf.h" -#include "tool_options_ui.h" #include "paths_dialogP.h" #include "undo.h" @@ -72,8 +74,6 @@ flip_options_new (void) GtkWidget *vbox; GtkWidget *frame; - gchar* type_label[2] = { N_("Horizontal"), N_("Vertical") }; - gint type_value[2] = { ORIENTATION_HORIZONTAL, ORIENTATION_VERTICAL }; /* the new flip tool options structure */ options = g_new (FlipOptions, 1); @@ -86,13 +86,18 @@ flip_options_new (void) vbox = options->tool_options.main_vbox; /* tool toggle */ - frame = tool_options_radio_buttons_new (_("Tool Toggle"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d - 1]), TRUE); + frame = + gimp_radio_group_new2 (TRUE, _("Tool Toggle"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Horizontal"), (gpointer) ORIENTATION_HORIZONTAL, + &options->type_w[0], + _("Vertical"), (gpointer) ORIENTATION_VERTICAL, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/gimpdrawable-offset.c b/app/gimpdrawable-offset.c index 29d888c276a5c99fd92f18ffeb61972c5f593a37..dd60bd921322d40161ec82895194cf68c284bc37 100644 --- a/app/gimpdrawable-offset.c +++ b/app/gimpdrawable-offset.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include + #include "appenv.h" #include "channel_ops.h" #include "cursorutil.h" @@ -28,6 +28,7 @@ #include "interface.h" #include "libgimp/gimpsizeentry.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimpintl.h" #include "channel_pvt.h" @@ -43,8 +44,6 @@ struct _OffsetDialog GtkWidget *off_se; gboolean wrap_around; - - GtkWidget *fill_options; ChannelOffsetType fill_type; GimpImage *gimage; @@ -54,8 +53,6 @@ struct _OffsetDialog static void offset_ok_callback (GtkWidget *, gpointer); static void offset_cancel_callback (GtkWidget *, gpointer); -static void offset_wraparound_update (GtkWidget *, gpointer); -static void offset_fill_type_update (GtkWidget *, gpointer); static void offset_halfheight_callback (GtkWidget *, gpointer); @@ -70,9 +67,8 @@ channel_ops_offset (GimpImage* gimage) GtkWidget *table; GtkObject *adjustment; GtkWidget *spinbutton; - GtkWidget *radio_box; + GtkWidget *frame; GtkWidget *radio_button; - GSList *group = NULL; GimpDrawable *drawable; @@ -167,39 +163,22 @@ channel_ops_offset (GimpImage* gimage) gtk_widget_show (check); /* The fill options */ - off_d->fill_options = gtk_frame_new (_("Fill Options")); - gtk_box_pack_start (GTK_BOX (vbox), off_d->fill_options, FALSE, FALSE, 0); - - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (off_d->fill_options), radio_box); - - radio_button = gtk_radio_button_new_with_label (group, _("Background")); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "fill_type", - (gpointer) OFFSET_BACKGROUND); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) offset_fill_type_update, - off_d); - gtk_widget_show (radio_button); - - radio_button = gtk_radio_button_new_with_label (group, _("Transparent")); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "fill_type", - (gpointer) OFFSET_TRANSPARENT); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) offset_fill_type_update, - off_d); - gtk_widget_show (radio_button); - if (drawable_has_alpha (drawable)) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button), TRUE); - else - gtk_widget_set_sensitive (radio_button, FALSE); + frame = + gimp_radio_group_new2 (TRUE, _("Fill Options"), + gimp_radio_button_update, + &off_d->fill_type, (gpointer) off_d->fill_type, + + _("Background"), (gpointer) OFFSET_BACKGROUND, NULL, + _("Transparent"), (gpointer) OFFSET_TRANSPARENT, + &radio_button, - gtk_widget_show (radio_box); - gtk_widget_show (off_d->fill_options); + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + if (!drawable_has_alpha (drawable)) + gtk_widget_set_sensitive (radio_button, FALSE); /* The by half height and half width option */ push = gtk_button_new_with_label (_("Offset by (x/2),(y/2)")); @@ -209,8 +188,9 @@ channel_ops_offset (GimpImage* gimage) /* Hook up the wrap around */ gtk_signal_connect (GTK_OBJECT (check), "toggled", - (GtkSignalFunc) offset_wraparound_update, - off_d); + GTK_SIGNAL_FUNC (gimp_toggle_button_update), + &off_d->wrap_around); + gtk_object_set_data (GTK_OBJECT (check), "inverse_sensitive", frame); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), off_d->wrap_around); /* Hook up the by half */ @@ -505,32 +485,6 @@ offset_cancel_callback (GtkWidget *widget, g_free (off_d); } -static void -offset_wraparound_update (GtkWidget *widget, - gpointer data) -{ - OffsetDialog *off_d; - - off_d = (OffsetDialog *) data; - - off_d->wrap_around = GTK_TOGGLE_BUTTON (widget)->active ? TRUE : FALSE; - - gtk_widget_set_sensitive (off_d->fill_options, !off_d->wrap_around); -} - -static void -offset_fill_type_update (GtkWidget *widget, - gpointer data) -{ - OffsetDialog *off_d; - - off_d = (OffsetDialog *) data; - - if (GTK_TOGGLE_BUTTON (widget)->active) - off_d->fill_type = - (ChannelOffsetType) gtk_object_get_data (GTK_OBJECT (widget), "fill_type"); -} - static void offset_halfheight_callback (GtkWidget *widget, gpointer data) diff --git a/app/gimpimage-duplicate.c b/app/gimpimage-duplicate.c index 29d888c276a5c99fd92f18ffeb61972c5f593a37..dd60bd921322d40161ec82895194cf68c284bc37 100644 --- a/app/gimpimage-duplicate.c +++ b/app/gimpimage-duplicate.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include + #include "appenv.h" #include "channel_ops.h" #include "cursorutil.h" @@ -28,6 +28,7 @@ #include "interface.h" #include "libgimp/gimpsizeentry.h" +#include "libgimp/gimpmath.h" #include "libgimp/gimpintl.h" #include "channel_pvt.h" @@ -43,8 +44,6 @@ struct _OffsetDialog GtkWidget *off_se; gboolean wrap_around; - - GtkWidget *fill_options; ChannelOffsetType fill_type; GimpImage *gimage; @@ -54,8 +53,6 @@ struct _OffsetDialog static void offset_ok_callback (GtkWidget *, gpointer); static void offset_cancel_callback (GtkWidget *, gpointer); -static void offset_wraparound_update (GtkWidget *, gpointer); -static void offset_fill_type_update (GtkWidget *, gpointer); static void offset_halfheight_callback (GtkWidget *, gpointer); @@ -70,9 +67,8 @@ channel_ops_offset (GimpImage* gimage) GtkWidget *table; GtkObject *adjustment; GtkWidget *spinbutton; - GtkWidget *radio_box; + GtkWidget *frame; GtkWidget *radio_button; - GSList *group = NULL; GimpDrawable *drawable; @@ -167,39 +163,22 @@ channel_ops_offset (GimpImage* gimage) gtk_widget_show (check); /* The fill options */ - off_d->fill_options = gtk_frame_new (_("Fill Options")); - gtk_box_pack_start (GTK_BOX (vbox), off_d->fill_options, FALSE, FALSE, 0); - - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (off_d->fill_options), radio_box); - - radio_button = gtk_radio_button_new_with_label (group, _("Background")); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "fill_type", - (gpointer) OFFSET_BACKGROUND); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) offset_fill_type_update, - off_d); - gtk_widget_show (radio_button); - - radio_button = gtk_radio_button_new_with_label (group, _("Transparent")); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "fill_type", - (gpointer) OFFSET_TRANSPARENT); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) offset_fill_type_update, - off_d); - gtk_widget_show (radio_button); - if (drawable_has_alpha (drawable)) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button), TRUE); - else - gtk_widget_set_sensitive (radio_button, FALSE); + frame = + gimp_radio_group_new2 (TRUE, _("Fill Options"), + gimp_radio_button_update, + &off_d->fill_type, (gpointer) off_d->fill_type, + + _("Background"), (gpointer) OFFSET_BACKGROUND, NULL, + _("Transparent"), (gpointer) OFFSET_TRANSPARENT, + &radio_button, - gtk_widget_show (radio_box); - gtk_widget_show (off_d->fill_options); + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + if (!drawable_has_alpha (drawable)) + gtk_widget_set_sensitive (radio_button, FALSE); /* The by half height and half width option */ push = gtk_button_new_with_label (_("Offset by (x/2),(y/2)")); @@ -209,8 +188,9 @@ channel_ops_offset (GimpImage* gimage) /* Hook up the wrap around */ gtk_signal_connect (GTK_OBJECT (check), "toggled", - (GtkSignalFunc) offset_wraparound_update, - off_d); + GTK_SIGNAL_FUNC (gimp_toggle_button_update), + &off_d->wrap_around); + gtk_object_set_data (GTK_OBJECT (check), "inverse_sensitive", frame); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), off_d->wrap_around); /* Hook up the by half */ @@ -505,32 +485,6 @@ offset_cancel_callback (GtkWidget *widget, g_free (off_d); } -static void -offset_wraparound_update (GtkWidget *widget, - gpointer data) -{ - OffsetDialog *off_d; - - off_d = (OffsetDialog *) data; - - off_d->wrap_around = GTK_TOGGLE_BUTTON (widget)->active ? TRUE : FALSE; - - gtk_widget_set_sensitive (off_d->fill_options, !off_d->wrap_around); -} - -static void -offset_fill_type_update (GtkWidget *widget, - gpointer data) -{ - OffsetDialog *off_d; - - off_d = (OffsetDialog *) data; - - if (GTK_TOGGLE_BUTTON (widget)->active) - off_d->fill_type = - (ChannelOffsetType) gtk_object_get_data (GTK_OBJECT (widget), "fill_type"); -} - static void offset_halfheight_callback (GtkWidget *widget, gpointer data) diff --git a/app/gui/file-new-dialog.c b/app/gui/file-new-dialog.c index ea9ba575dc292bd33ac1064ddce0db560c0f42be..a94f150dbde1ea9c738073e7b6f2a01fac3141f9 100644 --- a/app/gui/file-new-dialog.c +++ b/app/gui/file-new-dialog.c @@ -45,12 +45,11 @@ typedef struct } NewImageInfo; /* new image local functions */ -static void file_new_confirm_dialog (NewImageInfo *); +static void file_new_confirm_dialog (NewImageInfo *); -static void file_new_ok_callback (GtkWidget *, gpointer); -static void file_new_reset_callback (GtkWidget *, gpointer); -static void file_new_cancel_callback (GtkWidget *, gpointer); -static void file_new_toggle_callback (GtkWidget *, gpointer); +static void file_new_ok_callback (GtkWidget *, gpointer); +static void file_new_reset_callback (GtkWidget *, gpointer); +static void file_new_cancel_callback (GtkWidget *, gpointer); static void file_new_resolution_callback (GtkWidget *, gpointer); static void file_new_image_size_callback (GtkWidget *, gpointer); @@ -229,19 +228,6 @@ file_new_confirm_dialog (NewImageInfo *info) gtk_widget_show (info->confirm_dlg); } -static void -file_new_toggle_callback (GtkWidget *widget, - gpointer data) -{ - gint *val; - - if (GTK_TOGGLE_BUTTON (widget)->active) - { - val = data; - *val = (long) gtk_object_get_user_data (GTK_OBJECT (widget)); - } -} - static void file_new_resolution_callback (GtkWidget *widget, gpointer data) @@ -537,9 +523,11 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se), 1, values->height); gtk_signal_connect (GTK_OBJECT (info->size_se), "refval_changed", - (GtkSignalFunc) file_new_image_size_callback, info); + GTK_SIGNAL_FUNC (file_new_image_size_callback), + info); gtk_signal_connect (GTK_OBJECT (info->size_se), "value_changed", - (GtkSignalFunc) file_new_image_size_callback, info); + GTK_SIGNAL_FUNC (file_new_image_size_callback), + info); /* initialize the size label */ file_new_image_size_callback (info->size_se, info); @@ -593,7 +581,8 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) 1, values->yresolution); gtk_signal_connect (GTK_OBJECT (info->resolution_se), "value_changed", - (GtkSignalFunc) file_new_resolution_callback, info); + GTK_SIGNAL_FUNC (file_new_resolution_callback), + info); /* the resolution chainbutton */ info->couple_resolutions = gimp_chain_button_new (GIMP_CHAIN_RIGHT); @@ -633,10 +622,11 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) gtk_box_pack_start (GTK_BOX (radio_box), button, FALSE, TRUE, 0); gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) name_info->type); gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) file_new_toggle_callback, + GTK_SIGNAL_FUNC (gimp_radio_button_update), &values->type); gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) file_new_image_size_callback, info); + GTK_SIGNAL_FUNC (file_new_image_size_callback), + info); if (values->type == name_info->type) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); gtk_widget_show (button); @@ -670,10 +660,11 @@ ui_new_image_window_create (const GimpImageNewValues *values_orig) gtk_box_pack_start (GTK_BOX (radio_box), button, TRUE, TRUE, 0); gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) name_info->type); gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) file_new_toggle_callback, + GTK_SIGNAL_FUNC (gimp_radio_button_update), &values->fill_type); gtk_signal_connect (GTK_OBJECT (button), "toggled", - (GtkSignalFunc) file_new_image_size_callback, info); + GTK_SIGNAL_FUNC (file_new_image_size_callback), + info); if (values->fill_type == name_info->type) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); gtk_widget_show (button); diff --git a/app/gui/file-new-dialog.h b/app/gui/file-new-dialog.h index cc79bea337f537a4db9fd72a89bd87c7bc78f80c..f0441b1ac00339e8f8dd05e46f8333300164448b 100644 --- a/app/gui/file-new-dialog.h +++ b/app/gui/file-new-dialog.h @@ -1,3 +1,20 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-1999 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. + */ #ifndef __FILE_NEW_DIALOG_H__ #define __FILE_NEW_DIALOG_H__ diff --git a/app/gui/layers-dialog.c b/app/gui/layers-dialog.c index 20b6a6a653e645553fdc0d3c3d07b6c023b2ac09..cc20b24456703ec110d1d57061ba5c053ee312e2 100644 --- a/app/gui/layers-dialog.c +++ b/app/gui/layers-dialog.c @@ -3266,7 +3266,7 @@ new_layer_query_ok_callback (GtkWidget *widget, layer_name, OPAQUE_OPACITY, NORMAL_MODE); if (layer) { - drawable_fill (GIMP_DRAWABLE(layer), fill_type); + drawable_fill (GIMP_DRAWABLE (layer), fill_type); gimage_add_layer (gimage, layer, -1); /* End the group undo */ @@ -3297,18 +3297,6 @@ new_layer_query_cancel_callback (GtkWidget *widget, g_free (options); } -static void -new_layer_query_fill_type_callback (GtkWidget *widget, - gpointer data) -{ - NewLayerOptions *options; - - options = (NewLayerOptions *) data; - - options->fill_type = - (GimpFillType) gtk_object_get_data (GTK_OBJECT (widget), "fill_type"); -} - static void layers_dialog_new_layer_query (GimpImage* gimage) { @@ -3318,20 +3306,7 @@ layers_dialog_new_layer_query (GimpImage* gimage) GtkWidget *label; GtkObject *adjustment; GtkWidget *spinbutton; - GtkWidget *radio_frame; - GtkWidget *radio_box; - GtkWidget *radio_button; - GSList *group; - gint i; - - static gchar *button_names[] = - { - N_("Foreground"), - N_("Background"), - N_("White"), - N_("Transparent") - }; - static gint n_buttons = sizeof (button_names) / sizeof (button_names[0]); + GtkWidget *frame; /* The new options structure */ options = g_new (NewLayerOptions, 1); @@ -3437,36 +3412,21 @@ layers_dialog_new_layer_query (GimpImage* gimage) gtk_widget_show (table); - /* The radio frame and box */ - radio_frame = gtk_frame_new (_("Layer Fill Type")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + /* The radio frame */ + frame = + gimp_radio_group_new2 (TRUE, _("Layer Fill Type"), + gimp_radio_button_update, + &options->fill_type, (gpointer) options->fill_type, - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + _("Foreground"), (gpointer) FOREGROUND_FILL, NULL, + _("Background"), (gpointer) BACKGROUND_FILL, NULL, + _("White"), (gpointer) WHITE_FILL, NULL, + _("Transparent"), (gpointer) TRANSPARENT_FILL, NULL, - /* The radio buttons */ - group = NULL; - for (i = 0; i < n_buttons; i++) - { - radio_button = - gtk_radio_button_new_with_label (group, gettext(button_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "fill_type", - (gpointer) i); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) new_layer_query_fill_type_callback, - options); - - /* Set the correct radio button */ - if (i == options->fill_type) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button), TRUE); - - gtk_widget_show (radio_button); - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); gtk_widget_show (vbox); gtk_widget_show (options->query_box); @@ -3633,36 +3593,12 @@ add_mask_query_cancel_callback (GtkWidget *widget, g_free (options); } -static void -add_mask_query_fill_type_callback (GtkWidget *widget, - gpointer data) -{ - AddMaskOptions *options; - - options = (AddMaskOptions *) data; - - options->add_mask_type = - (AddMaskType) gtk_object_get_data (GTK_OBJECT (widget), "add_mask_type"); -} - static void layers_dialog_add_mask_query (Layer *layer) { AddMaskOptions *options; GtkWidget *vbox; - GtkWidget *radio_frame; - GtkWidget *radio_box; - GtkWidget *radio_button; - GSList *group = NULL; - gint i; - - static gchar *button_names[] = - { - N_("White (Full Opacity)"), - N_("Black (Full Transparency)"), - N_("Layer's Alpha Channel") - }; - static gint n_buttons = sizeof (button_names) / sizeof (button_names[0]); + GtkWidget *frame; /* The new options structure */ options = g_new (AddMaskOptions, 1); @@ -3691,29 +3627,22 @@ layers_dialog_add_mask_query (Layer *layer) vbox); /* The radio frame and box */ - radio_frame = gtk_frame_new (_("Initialize Layer Mask to:")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + frame = gimp_radio_group_new2 (TRUE, _("Initialize Layer Mask to:"), + gimp_radio_button_update, + &options->add_mask_type, + (gpointer) options->add_mask_type, - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + _("White (Full Opacity)"), + (gpointer) ADD_WHITE_MASK, NULL, + _("Black (Full Transparency)"), + (gpointer) ADD_BLACK_MASK, NULL, + _("Layer's Alpha Channel"), + (gpointer) ADD_ALPHA_MASK, NULL, - /* The radio buttons */ - for (i = 0; i < n_buttons; i++) - { - radio_button = - gtk_radio_button_new_with_label (group, gettext (button_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "add_mask_type", - (gpointer) i); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) add_mask_query_fill_type_callback, - options); - gtk_widget_show (radio_button); - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); gtk_widget_show (vbox); gtk_widget_show (options->query_box); @@ -4031,18 +3960,6 @@ layer_merge_query_cancel_callback (GtkWidget *widget, g_free (options); } -static void -layer_merge_query_type_callback (GtkWidget *widget, - gpointer data) -{ - LayerMergeOptions *options; - - options = (LayerMergeOptions *) data; - - options->merge_type = - (MergeType) gtk_object_get_data (GTK_OBJECT (widget), "merge_type"); -} - void layers_dialog_layer_merge_query (GImage *gimage, /* if FALSE, anchor active layer */ @@ -4050,19 +3967,7 @@ layers_dialog_layer_merge_query (GImage *gimage, { LayerMergeOptions *options; GtkWidget *vbox; - GtkWidget *radio_frame; - GtkWidget *radio_box; - GtkWidget *radio_button; - GSList *group = NULL; - gint i; - - static gchar *button_names[] = - { - N_("Expanded as necessary"), - N_("Clipped to image"), - N_("Clipped to bottom layer") - }; - static gint n_buttons = sizeof (button_names) / sizeof (button_names[0]); + GtkWidget *frame; /* The new options structure */ options = g_new (LayerMergeOptions, 1); @@ -4091,33 +3996,25 @@ layers_dialog_layer_merge_query (GImage *gimage, gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox), vbox); - /* The radio frame and box */ - if (merge_visible) - radio_frame = gtk_frame_new (_("Final, Merged Layer should be:")); - else - radio_frame = gtk_frame_new (_("Final, Anchored Layer should be:")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); - - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); - - /* The radio buttons */ - for (i = 0; i < n_buttons; i++) - { - radio_button = - gtk_radio_button_new_with_label (group, gettext (button_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "merge_type", - (gpointer) i); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) layer_merge_query_type_callback, - options); - gtk_widget_show (radio_button); - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + frame = gimp_radio_group_new2 (TRUE, + merge_visible ? + _("Final, Merged Layer should be:") : + _("Final, Anchored Layer should be:"), + gimp_radio_button_update, + &options->merge_type, + (gpointer) options->merge_type, + + _("Expanded as necessary"), + (gpointer) EXPAND_AS_NECESSARY, NULL, + _("Clipped to image"), + (gpointer) CLIP_TO_IMAGE, NULL, + _("Clipped to bottom layer"), + (gpointer) CLIP_TO_BOTTOM_LAYER, NULL, + + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); gtk_widget_show (vbox); gtk_widget_show (options->query_box); diff --git a/app/image_new.c b/app/image_new.c index dad4d67363e40f1febc89032d6cf5b117161ff76..c5ca368dcee992b29ec335f9c71a5020f4a3e12a 100644 --- a/app/image_new.c +++ b/app/image_new.c @@ -15,9 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - - #include "config.h" + #include "image_new.h" #include "gimprc.h" @@ -29,24 +28,24 @@ #include "libgimp/gimpintl.h" -static GList *image_base_type_names = NULL; -static GList *fill_type_names = NULL; -static GimpImageNewValues last_values; -static gboolean current_cut_buffer = FALSE; +static GList *image_base_type_names = NULL; +static GList *fill_type_names = NULL; +static GimpImageNewValues last_values; +static gboolean current_cut_buffer = FALSE; -extern TileManager *global_buf; +extern TileManager *global_buf; static void -image_new_init () +image_new_init (void) { - static gboolean image_new_inited = 0; + static gboolean image_new_inited = FALSE; GimpImageBaseTypeName *new_type; GimpFillTypeName *new_fill_type; if (image_new_inited) return; else - image_new_inited = 1; + image_new_inited = TRUE; /* Available Image Base Types */ new_type = g_new (GimpImageBaseTypeName, 1); @@ -92,7 +91,7 @@ image_new_init () } GList* -image_new_get_image_base_type_names () +image_new_get_image_base_type_names (void) { image_new_init (); @@ -100,7 +99,7 @@ image_new_get_image_base_type_names () } GList* -image_new_get_fill_type_names () +image_new_get_fill_type_names (void) { image_new_init (); @@ -109,7 +108,7 @@ image_new_get_fill_type_names () void image_new_create_window (const GimpImageNewValues *create_values, - const GimpImage *image) + const GimpImage *image) { GimpImageNewValues *values; @@ -123,9 +122,9 @@ image_new_create_window (const GimpImageNewValues *create_values, values->height = gimp_image_get_height (image); values->unit = gimp_image_get_unit (image); - gimp_image_get_resolution(image, - &values->xresolution, - &values->yresolution); + gimp_image_get_resolution (image, + &values->xresolution, + &values->yresolution); values->type = gimp_image_base_type (image); @@ -256,7 +255,7 @@ image_new_calculate_size (GimpImageNewValues *values) return size; } -gchar* +gchar * image_new_get_size_string (gdouble size) { if (size < 4096) @@ -274,7 +273,7 @@ image_new_get_size_string (gdouble size) } void -image_new_reset_current_cut_buffer () +image_new_reset_current_cut_buffer (void) { /* This function just changes the status of current_cut_buffer if there hass been a cut/copy since the last file new */ diff --git a/app/image_new.h b/app/image_new.h index 80d0e0fc96a63d3b09081ee6bf8b293fa1243ac8..ee9d2c4b88e252500cf9718f53853431e6041d97 100644 --- a/app/image_new.h +++ b/app/image_new.h @@ -26,45 +26,48 @@ extern "C" { #endif -typedef struct { - GimpImageBaseType type; - gchar *name; +typedef struct +{ + GimpImageBaseType type; + gchar *name; } GimpImageBaseTypeName; -typedef struct { - GimpFillType type; - gchar *name; +typedef struct +{ + GimpFillType type; + gchar *name; } GimpFillTypeName; -typedef struct { - gint width; - gint height; - GUnit unit; +typedef struct +{ + gint width; + gint height; + GUnit unit; - gdouble xresolution; - gdouble yresolution; - GUnit res_unit; + gdouble xresolution; + gdouble yresolution; + GUnit res_unit; - GimpImageBaseType type; - GimpFillType fill_type; + GimpImageBaseType type; + GimpFillType fill_type; } GimpImageNewValues; -GList* image_new_get_fill_type_names (); -GList* image_new_get_image_base_type_names (); +GList* image_new_get_fill_type_names (void); +GList* image_new_get_image_base_type_names (void); -void image_new_create_window (const GimpImageNewValues *values, - const GimpImage *image); -void image_new_set_default_values (const GimpImageNewValues *values); +void image_new_create_window (const GimpImageNewValues *values, + const GimpImage *image); +void image_new_set_default_values (const GimpImageNewValues *values); -GimpImageNewValues* image_new_values_new (const GimpImageNewValues *src_vals); -void image_new_values_free (GimpImageNewValues *values); +GimpImageNewValues * image_new_values_new (const GimpImageNewValues *src_vals); +void image_new_values_free (GimpImageNewValues *values); -void image_new_create_image (const GimpImageNewValues *values); +void image_new_create_image (const GimpImageNewValues *values); -gdouble image_new_calculate_size (GimpImageNewValues *values); -gchar* image_new_get_size_string (gdouble size); +gdouble image_new_calculate_size (GimpImageNewValues *values); +gchar * image_new_get_size_string (gdouble size); -void image_new_reset_current_cut_buffer (); +void image_new_reset_current_cut_buffer (void); #ifdef __cplusplus } diff --git a/app/ink.c b/app/ink.c index c9c34b273117cbc0a22877fb64ec469eb938a317..aca0f894b56ea1083bba31bb392e5c4a60c395c4 100644 --- a/app/ink.c +++ b/app/ink.c @@ -25,9 +25,9 @@ #include "draw_core.h" #include "gimage_mask.h" #include "gimprc.h" +#include "gimpui.h" #include "ink.h" #include "paint_options.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" #include "blob.h" @@ -45,33 +45,35 @@ /* the Ink structures */ -typedef Blob *(*BlobFunc) (double, double, double, double, double, double); +typedef Blob *(*BlobFunc) (gdouble, gdouble, gdouble, gdouble, gdouble, gdouble); typedef struct _InkTool InkTool; + struct _InkTool { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - Blob * last_blob; /* blob for last cursor position */ + Blob *last_blob; /* blob for last cursor position */ - int x1, y1; /* image space coordinate */ - int x2, y2; /* image space coords */ + gint x1, y1; /* image space coordinate */ + gint x2, y2; /* image space coords */ /* circular distance history buffer */ - gdouble dt_buffer[DIST_SMOOTHER_BUFFER]; - gint dt_index; + gdouble dt_buffer[DIST_SMOOTHER_BUFFER]; + gint dt_index; /* circular timing history buffer */ - guint32 ts_buffer[TIME_SMOOTHER_BUFFER]; - gint ts_index; + guint32 ts_buffer[TIME_SMOOTHER_BUFFER]; + gint ts_index; - gdouble last_time; /* previous time of a motion event */ - gdouble lastx, lasty; /* previous position of a motion event */ + gdouble last_time; /* previous time of a motion event */ + gdouble lastx, lasty; /* previous position of a motion event */ - gboolean init_velocity; + gboolean init_velocity; }; typedef struct _BrushWidget BrushWidget; + struct _BrushWidget { GtkWidget *widget; @@ -79,44 +81,45 @@ struct _BrushWidget }; typedef struct _InkOptions InkOptions; + struct _InkOptions { PaintOptions paint_options; - double size; - double size_d; + gdouble size; + gdouble size_d; GtkObject *size_w; - double sensitivity; - double sensitivity_d; + gdouble sensitivity; + gdouble sensitivity_d; GtkObject *sensitivity_w; - double vel_sensitivity; - double vel_sensitivity_d; + gdouble vel_sensitivity; + gdouble vel_sensitivity_d; GtkObject *vel_sensitivity_w; - double tilt_sensitivity; - double tilt_sensitivity_d; + gdouble tilt_sensitivity; + gdouble tilt_sensitivity_d; GtkObject *tilt_sensitivity_w; - double tilt_angle; - double tilt_angle_d; + gdouble tilt_angle; + gdouble tilt_angle_d; GtkObject *tilt_angle_w; BlobFunc function; BlobFunc function_d; GtkWidget *function_w[3]; /* 3 radio buttons */ - double aspect; - double aspect_d; - double angle; - double angle_d; + gdouble aspect; + gdouble aspect_d; + gdouble angle; + gdouble angle_d; BrushWidget *brush_w; }; /* the ink tool options */ -static InkOptions *ink_options = NULL; +static InkOptions * ink_options = NULL; /* local variables */ @@ -265,7 +268,7 @@ ink_options_new (void) GdkPixmap *pixmap; /* the new ink tool options structure */ - options = (InkOptions *) g_malloc (sizeof (InkOptions)); + options = g_new (InkOptions, 1); paint_options_init ((PaintOptions *) options, INK, ink_options_reset); @@ -303,7 +306,7 @@ ink_options_new (void) gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 0, 1); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->size_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->size); gtk_widget_show (slider); @@ -321,7 +324,7 @@ ink_options_new (void) gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 1, 2); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->sensitivity); gtk_widget_show (slider); @@ -350,7 +353,7 @@ ink_options_new (void) gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->tilt_sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->tilt_sensitivity); gtk_widget_show (slider); @@ -380,7 +383,7 @@ ink_options_new (void) gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->vel_sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->vel_sensitivity); gtk_widget_show (slider); @@ -410,7 +413,7 @@ ink_options_new (void) gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->tilt_angle_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->tilt_angle); /* Brush type radiobuttons */ diff --git a/app/layers_dialog.c b/app/layers_dialog.c index 20b6a6a653e645553fdc0d3c3d07b6c023b2ac09..cc20b24456703ec110d1d57061ba5c053ee312e2 100644 --- a/app/layers_dialog.c +++ b/app/layers_dialog.c @@ -3266,7 +3266,7 @@ new_layer_query_ok_callback (GtkWidget *widget, layer_name, OPAQUE_OPACITY, NORMAL_MODE); if (layer) { - drawable_fill (GIMP_DRAWABLE(layer), fill_type); + drawable_fill (GIMP_DRAWABLE (layer), fill_type); gimage_add_layer (gimage, layer, -1); /* End the group undo */ @@ -3297,18 +3297,6 @@ new_layer_query_cancel_callback (GtkWidget *widget, g_free (options); } -static void -new_layer_query_fill_type_callback (GtkWidget *widget, - gpointer data) -{ - NewLayerOptions *options; - - options = (NewLayerOptions *) data; - - options->fill_type = - (GimpFillType) gtk_object_get_data (GTK_OBJECT (widget), "fill_type"); -} - static void layers_dialog_new_layer_query (GimpImage* gimage) { @@ -3318,20 +3306,7 @@ layers_dialog_new_layer_query (GimpImage* gimage) GtkWidget *label; GtkObject *adjustment; GtkWidget *spinbutton; - GtkWidget *radio_frame; - GtkWidget *radio_box; - GtkWidget *radio_button; - GSList *group; - gint i; - - static gchar *button_names[] = - { - N_("Foreground"), - N_("Background"), - N_("White"), - N_("Transparent") - }; - static gint n_buttons = sizeof (button_names) / sizeof (button_names[0]); + GtkWidget *frame; /* The new options structure */ options = g_new (NewLayerOptions, 1); @@ -3437,36 +3412,21 @@ layers_dialog_new_layer_query (GimpImage* gimage) gtk_widget_show (table); - /* The radio frame and box */ - radio_frame = gtk_frame_new (_("Layer Fill Type")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + /* The radio frame */ + frame = + gimp_radio_group_new2 (TRUE, _("Layer Fill Type"), + gimp_radio_button_update, + &options->fill_type, (gpointer) options->fill_type, - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + _("Foreground"), (gpointer) FOREGROUND_FILL, NULL, + _("Background"), (gpointer) BACKGROUND_FILL, NULL, + _("White"), (gpointer) WHITE_FILL, NULL, + _("Transparent"), (gpointer) TRANSPARENT_FILL, NULL, - /* The radio buttons */ - group = NULL; - for (i = 0; i < n_buttons; i++) - { - radio_button = - gtk_radio_button_new_with_label (group, gettext(button_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "fill_type", - (gpointer) i); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) new_layer_query_fill_type_callback, - options); - - /* Set the correct radio button */ - if (i == options->fill_type) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button), TRUE); - - gtk_widget_show (radio_button); - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); gtk_widget_show (vbox); gtk_widget_show (options->query_box); @@ -3633,36 +3593,12 @@ add_mask_query_cancel_callback (GtkWidget *widget, g_free (options); } -static void -add_mask_query_fill_type_callback (GtkWidget *widget, - gpointer data) -{ - AddMaskOptions *options; - - options = (AddMaskOptions *) data; - - options->add_mask_type = - (AddMaskType) gtk_object_get_data (GTK_OBJECT (widget), "add_mask_type"); -} - static void layers_dialog_add_mask_query (Layer *layer) { AddMaskOptions *options; GtkWidget *vbox; - GtkWidget *radio_frame; - GtkWidget *radio_box; - GtkWidget *radio_button; - GSList *group = NULL; - gint i; - - static gchar *button_names[] = - { - N_("White (Full Opacity)"), - N_("Black (Full Transparency)"), - N_("Layer's Alpha Channel") - }; - static gint n_buttons = sizeof (button_names) / sizeof (button_names[0]); + GtkWidget *frame; /* The new options structure */ options = g_new (AddMaskOptions, 1); @@ -3691,29 +3627,22 @@ layers_dialog_add_mask_query (Layer *layer) vbox); /* The radio frame and box */ - radio_frame = gtk_frame_new (_("Initialize Layer Mask to:")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + frame = gimp_radio_group_new2 (TRUE, _("Initialize Layer Mask to:"), + gimp_radio_button_update, + &options->add_mask_type, + (gpointer) options->add_mask_type, - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + _("White (Full Opacity)"), + (gpointer) ADD_WHITE_MASK, NULL, + _("Black (Full Transparency)"), + (gpointer) ADD_BLACK_MASK, NULL, + _("Layer's Alpha Channel"), + (gpointer) ADD_ALPHA_MASK, NULL, - /* The radio buttons */ - for (i = 0; i < n_buttons; i++) - { - radio_button = - gtk_radio_button_new_with_label (group, gettext (button_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "add_mask_type", - (gpointer) i); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) add_mask_query_fill_type_callback, - options); - gtk_widget_show (radio_button); - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); gtk_widget_show (vbox); gtk_widget_show (options->query_box); @@ -4031,18 +3960,6 @@ layer_merge_query_cancel_callback (GtkWidget *widget, g_free (options); } -static void -layer_merge_query_type_callback (GtkWidget *widget, - gpointer data) -{ - LayerMergeOptions *options; - - options = (LayerMergeOptions *) data; - - options->merge_type = - (MergeType) gtk_object_get_data (GTK_OBJECT (widget), "merge_type"); -} - void layers_dialog_layer_merge_query (GImage *gimage, /* if FALSE, anchor active layer */ @@ -4050,19 +3967,7 @@ layers_dialog_layer_merge_query (GImage *gimage, { LayerMergeOptions *options; GtkWidget *vbox; - GtkWidget *radio_frame; - GtkWidget *radio_box; - GtkWidget *radio_button; - GSList *group = NULL; - gint i; - - static gchar *button_names[] = - { - N_("Expanded as necessary"), - N_("Clipped to image"), - N_("Clipped to bottom layer") - }; - static gint n_buttons = sizeof (button_names) / sizeof (button_names[0]); + GtkWidget *frame; /* The new options structure */ options = g_new (LayerMergeOptions, 1); @@ -4091,33 +3996,25 @@ layers_dialog_layer_merge_query (GImage *gimage, gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox), vbox); - /* The radio frame and box */ - if (merge_visible) - radio_frame = gtk_frame_new (_("Final, Merged Layer should be:")); - else - radio_frame = gtk_frame_new (_("Final, Anchored Layer should be:")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); - - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); - - /* The radio buttons */ - for (i = 0; i < n_buttons; i++) - { - radio_button = - gtk_radio_button_new_with_label (group, gettext (button_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (radio_button), "merge_type", - (gpointer) i); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) layer_merge_query_type_callback, - options); - gtk_widget_show (radio_button); - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + frame = gimp_radio_group_new2 (TRUE, + merge_visible ? + _("Final, Merged Layer should be:") : + _("Final, Anchored Layer should be:"), + gimp_radio_button_update, + &options->merge_type, + (gpointer) options->merge_type, + + _("Expanded as necessary"), + (gpointer) EXPAND_AS_NECESSARY, NULL, + _("Clipped to image"), + (gpointer) CLIP_TO_IMAGE, NULL, + _("Clipped to bottom layer"), + (gpointer) CLIP_TO_BOTTOM_LAYER, NULL, + + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); gtk_widget_show (vbox); gtk_widget_show (options->query_box); diff --git a/app/magnify.c b/app/magnify.c index 14c27af762cf5162a7df6aee5b62bafa4cd658f4..f009a25ab441eb4a24b88ab27c9d99bb0df260db 100644 --- a/app/magnify.c +++ b/app/magnify.c @@ -16,14 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include + #include "appenv.h" #include "draw_core.h" #include "gdisplay.h" #include "gimprc.h" +#include "gimpui.h" #include "info_window.h" #include "magnify.h" #include "scale.h" -#include "tool_options_ui.h" #include "libgimp/gimpintl.h" @@ -34,23 +35,25 @@ /* the magnify structures */ typedef struct _Magnify Magnify; + struct _Magnify { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - int x, y; /* upper left hand coordinate */ - int w, h; /* width and height */ + gint x, y; /* upper left hand coordinate */ + gint w, h; /* width and height */ - int op; /* magnify operation */ + gint op; /* magnify operation */ }; typedef struct _MagnifyOptions MagnifyOptions; + struct _MagnifyOptions { ToolOptions tool_options; - /* int allow_resize_windows; (from gimprc) */ - int allow_resize_d; + /* gint allow_resize_windows; (from gimprc) */ + gint allow_resize_d; GtkWidget *allow_resize_w; }; @@ -90,7 +93,7 @@ magnify_options_new (void) GtkWidget *vbox; /* the new magnify tool options structure */ - options = (MagnifyOptions *) g_malloc (sizeof (MagnifyOptions)); + options = g_new (MagnifyOptions, 1); tool_options_init ((ToolOptions *) options, _("Magnify Options"), magnify_options_reset); @@ -103,7 +106,7 @@ magnify_options_new (void) options->allow_resize_w = gtk_check_button_new_with_label (_("Allow Window Resizing")); gtk_signal_connect (GTK_OBJECT (options->allow_resize_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &allow_resize_windows); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_resize_w), allow_resize_windows); @@ -117,9 +120,9 @@ magnify_options_new (void) /* magnify utility functions */ static void -zoom_in (int *src, - int *dest, - int scale) +zoom_in (gint *src, + gint *dest, + gint scale) { while (scale--) { @@ -133,9 +136,9 @@ zoom_in (int *src, static void -zoom_out (int *src, - int *dest, - int scale) +zoom_out (gint *src, + gint *dest, + gint scale) { while (scale--) { @@ -155,9 +158,9 @@ magnify_button_press (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr) { - GDisplay * gdisp; - Magnify * magnify; - int x, y; + GDisplay *gdisp; + Magnify *magnify; + gint x, y; gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; @@ -170,7 +173,9 @@ magnify_button_press (Tool *tool, magnify->h = 0; gdk_pointer_grab (gdisp->canvas->window, FALSE, - GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, + GDK_POINTER_MOTION_HINT_MASK | + GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); tool->state = ACTIVE; @@ -192,13 +197,13 @@ magnify_button_release (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr) { - Magnify * magnify; - GDisplay * gdisp; - int win_width, win_height; - int width, height; - int scalesrc, scaledest; - int scale; - int x1, y1, x2, y2, w, h; + Magnify *magnify; + GDisplay *gdisp; + gint win_width, win_height; + gint width, height; + gint scalesrc, scaledest; + gint scale; + gint x1, y1, x2, y2, w, h; gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; @@ -252,7 +257,6 @@ magnify_button_release (Tool *tool, /* resize the image */ resize_display (gdisp, allow_resize_windows, TRUE); - } } @@ -261,9 +265,9 @@ magnify_motion (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr) { - Magnify * magnify; - GDisplay * gdisp; - int x, y; + Magnify *magnify; + GDisplay *gdisp; + gint x, y; if (tool->state != ACTIVE) return; @@ -286,7 +290,7 @@ magnify_cursor_update (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr) { - GDisplay * gdisp; + GDisplay *gdisp; gdisp = (GDisplay *) gdisp_ptr; @@ -297,17 +301,17 @@ magnify_cursor_update (Tool *tool, void magnify_draw (Tool *tool) { - GDisplay * gdisp; - Magnify * magnify; - int x1, y1, x2, y2; + GDisplay *gdisp; + Magnify *magnify; + gint x1, y1, x2, y2; gdisp = (GDisplay *) tool->gdisp_ptr; magnify = (Magnify *) tool->private; - x1 = MINIMUM (magnify->x, magnify->x + magnify->w); - y1 = MINIMUM (magnify->y, magnify->y + magnify->h); - x2 = MAXIMUM (magnify->x, magnify->x + magnify->w); - y2 = MAXIMUM (magnify->y, magnify->y + magnify->h); + x1 = MIN (magnify->x, magnify->x + magnify->w); + y1 = MIN (magnify->y, magnify->y + magnify->h); + x2 = MAX (magnify->x, magnify->x + magnify->w); + y2 = MAX (magnify->y, magnify->y + magnify->h); gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0); gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0); @@ -322,7 +326,7 @@ magnify_control (Tool *tool, ToolAction action, gpointer gdisp_ptr) { - Magnify * magnify; + Magnify *magnify; magnify = (Magnify *) tool->private; @@ -349,8 +353,8 @@ magnify_control (Tool *tool, Tool * tools_new_magnify (void) { - Tool * tool; - Magnify * private; + Tool *tool; + Magnify *private; /* The tool options */ if (! magnify_options) @@ -384,7 +388,7 @@ tools_new_magnify (void) void tools_free_magnify (Tool *tool) { - Magnify * magnify; + Magnify *magnify; magnify = (Magnify *) tool->private; diff --git a/app/measure.c b/app/measure.c index 2cee1723e45d7c43b6a8cd54a20edbea91d9ba99..a945985ac46c43e52d82932f2a63a5a7ceab9776 100644 --- a/app/measure.c +++ b/app/measure.c @@ -25,7 +25,6 @@ #include "gimpui.h" #include "info_dialog.h" #include "measure.h" -#include "tool_options_ui.h" #include "undo.h" #include "libgimp/gimpintl.h" @@ -49,21 +48,23 @@ typedef enum /* the measure structure */ typedef struct _MeasureTool MeasureTool; + struct _MeasureTool { DrawCore *core; /* draw core */ MeasureFunction function; /* what are we doing? */ - int point; /* what are we manipulating? */ - int num_points; /* how many points? */ - int x[3]; /* three x coordinates */ - int y[3]; /* three y coordinates */ - double angle1; /* first angle */ - double angle2; /* second angle */ + gint point; /* what are we manipulating? */ + gint num_points; /* how many points? */ + gint x[3]; /* three x coordinates */ + gint y[3]; /* three y coordinates */ + gdouble angle1; /* first angle */ + gdouble angle2; /* second angle */ guint context_id; /* for the statusbar */ }; /* the measure tool options */ typedef struct _MeasureOptions MeasureOptions; + struct _MeasureOptions { ToolOptions tool_options; @@ -128,7 +129,7 @@ measure_tool_options_new (void) options->use_info_window_d); gtk_box_pack_start (GTK_BOX (vbox), options->use_info_window_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->use_info_window_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->use_info_window); gtk_widget_show (options->use_info_window_w); @@ -181,7 +182,8 @@ measure_tool_button_press (Tool *tool, if (tool->state == ACTIVE && gdisp_ptr != tool->gdisp_ptr) { GDisplay *old_gdisp = tool->gdisp_ptr; - gtk_statusbar_pop (GTK_STATUSBAR (old_gdisp->statusbar), measure_tool->context_id); + gtk_statusbar_pop (GTK_STATUSBAR (old_gdisp->statusbar), + measure_tool->context_id); gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), measure_tool->context_id, ("")); } @@ -196,15 +198,15 @@ measure_tool_button_press (Tool *tool, { gdisplay_transform_coords (gdisp, measure_tool->x[i], measure_tool->y[i], &x[i], &y[i], FALSE); - if (bevent->x == BOUNDS (bevent->x, x[i] - TARGET, x[i] + TARGET) && - bevent->y == BOUNDS (bevent->y, y[i] - TARGET, y[i] + TARGET)) + if (bevent->x == CLAMP (bevent->x, x[i] - TARGET, x[i] + TARGET) && + bevent->y == CLAMP (bevent->y, y[i] - TARGET, y[i] + TARGET)) { if (bevent->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)) { Guide *guide; if (bevent->state & GDK_CONTROL_MASK && - (measure_tool->y[i] == BOUNDS (measure_tool->y[i], 0, gdisp->gimage->height))) + (measure_tool->y[i] == CLAMP (measure_tool->y[i], 0, gdisp->gimage->height))) { guide = gimp_image_add_hguide (gdisp->gimage); undo_push_guide (gdisp->gimage, guide); @@ -212,7 +214,7 @@ measure_tool_button_press (Tool *tool, gdisplays_expose_guide (gdisp->gimage, guide); } if (bevent->state & GDK_MOD1_MASK && - (measure_tool->x[i] == BOUNDS (measure_tool->x[i], 0, gdisp->gimage->width))) + (measure_tool->x[i] == CLAMP (measure_tool->x[i], 0, gdisp->gimage->width))) { guide = gimp_image_add_vguide (gdisp->gimage); undo_push_guide (gdisp->gimage, guide); @@ -258,7 +260,8 @@ measure_tool_button_press (Tool *tool, /* create the info window if necessary */ if (!measure_tool_info && - (measure_tool_options->use_info_window || !GTK_WIDGET_VISIBLE (gdisp->statusarea))) + (measure_tool_options->use_info_window || + !GTK_WIDGET_VISIBLE (gdisp->statusarea))) { measure_tool_info = info_dialog_new (_("Measure Tool"), tools_help_func, NULL); @@ -274,11 +277,15 @@ measure_tool_button_press (Tool *tool, } gdk_pointer_grab (gdisp->canvas->window, FALSE, - GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, + GDK_POINTER_MOTION_HINT_MASK | + GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); tool->state = ACTIVE; - /* set the pointer to the crosshair, so one actually sees the cursor position */ + /* set the pointer to the crosshair, + * so one actually sees the cursor position + */ gdisplay_install_tool_cursor (gdisp, GDK_TCROSS); } diff --git a/app/paint/gimpairbrush.c b/app/paint/gimpairbrush.c index 20ea00d7a788162c723e6342582e4b86e2704897..6ff505297215237146abd7daa306ff526cba7c46 100644 --- a/app/paint/gimpairbrush.c +++ b/app/paint/gimpairbrush.c @@ -30,7 +30,6 @@ #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpintl.h" @@ -114,7 +113,7 @@ airbrush_options_new (void) GtkWidget *scale; /* the new airbrush tool options structure */ - options = (AirbrushOptions *) g_malloc (sizeof (AirbrushOptions)); + options = g_new (AirbrushOptions, 1); paint_options_init ((PaintOptions *) options, AIRBRUSH, airbrush_options_reset); @@ -136,7 +135,7 @@ airbrush_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->rate); gimp_table_attach_aligned (GTK_TABLE (table), 0, _("Rate:"), 1.0, 1.0, @@ -149,7 +148,7 @@ airbrush_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->pressure_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->pressure); gimp_table_attach_aligned (GTK_TABLE (table), 1, _("Pressure:"), 1.0, 1.0, @@ -200,10 +199,10 @@ airbrush_paint_func (PaintCore *paint_core, case INIT_PAINT : /* timer_state = OFF; */ if (timer_state == ON) - { - g_warning ("killing stray timer, please report to lewing@gimp.org"); - gtk_timeout_remove (timer); - } + { + g_warning ("killing stray timer, please report to lewing@gimp.org"); + gtk_timeout_remove (timer); + } timer_state = OFF; break; diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c index 4e2c4b1246c66d4077ef492a0b179f67fda2a73d..10d23f90fa53ac6c2d6f874a08170c7025a8ad80 100644 --- a/app/paint/gimpclone.c +++ b/app/paint/gimpclone.c @@ -1,4 +1,4 @@ - /* The GIMP -- an image manipulation program +/* 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 @@ -15,13 +15,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include + #include "appenv.h" #include "drawable.h" #include "errors.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "interface.h" #include "paint_funcs.h" #include "paint_core.h" @@ -50,6 +54,7 @@ typedef enum } AlignType; typedef struct _CloneOptions CloneOptions; + struct _CloneOptions { PaintOptions paint_options; @@ -98,20 +103,6 @@ static void clone_line_pattern (GImage *, GimpDrawable *, GPattern *, /* functions */ -static void -clone_type_callback (GtkWidget *widget, - gpointer data) -{ - clone_options->type = (CloneType) data; -} - -static void -align_type_callback (GtkWidget *widget, - gpointer data) -{ - clone_options->aligned = (AlignType) data; -} - static void clone_options_reset (void) { @@ -127,31 +118,11 @@ static CloneOptions * clone_options_new (void) { CloneOptions *options; - GtkWidget *vbox; - GSList *group = NULL; - GtkWidget *radio_frame; - GtkWidget *radio_box; - GtkWidget *radio_button; - int i; - - static gchar *source_names[] = - { - N_("Image Source"), - N_("Pattern Source") - }; - static gint n_source_names = sizeof (source_names) / sizeof (source_names[0]); - - static gchar *align_names[] = - { - N_("Non Aligned"), - N_("Aligned"), - N_("Registered") - }; - static gint n_align_names = sizeof (align_names) / sizeof (align_names[0]); + GtkWidget *frame; /* the new clone tool options structure */ - options = (CloneOptions *) g_malloc (sizeof (CloneOptions)); + options = g_new (CloneOptions, 1); paint_options_init ((PaintOptions *) options, CLONE, clone_options_reset); @@ -161,56 +132,35 @@ clone_options_new (void) /* the main vbox */ vbox = ((ToolOptions *) options)->main_vbox; - /* the radio frame and box */ - radio_frame = gtk_frame_new (_("Source")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + frame = gimp_radio_group_new2 (TRUE, _("Source"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + _("Image Source"), (gpointer) IMAGE_CLONE, + &options->type_w[0], + _("Pattern Source"), (gpointer) PATTERN_CLONE, + &options->type_w[1], - /* the radio buttons */ - for (i = 0; i < n_source_names; i++) - { - radio_button = gtk_radio_button_new_with_label (group, - gettext(source_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) clone_type_callback, - (void *)((long) i)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_widget_show (radio_button); - - options->type_w[i] = radio_button; - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + NULL); - /* the radio frame and box */ - radio_frame = gtk_frame_new (_("Alignment")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + frame = gimp_radio_group_new2 (TRUE, _("Alignment"), + gimp_radio_button_update, + &options->aligned, (gpointer) options->aligned, - /* the radio buttons */ - group = NULL; - for (i = 0; i < n_align_names; i++) - { - radio_button = gtk_radio_button_new_with_label (group, - gettext(align_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) align_type_callback, - (void *)((long) i)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_widget_show (radio_button); - - options->aligned_w[i] = radio_button; - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + _("Non Aligned"), (gpointer) ALIGN_NO, + &options->aligned_w[0], + _("Aligned"), (gpointer) ALIGN_YES, + &options->aligned_w[1], + _("Registered"), (gpointer) ALIGN_REGISTERED, + &options->aligned_w[2], + + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); return options; } @@ -227,27 +177,25 @@ clone_src_drawable_destroyed_cb (GimpDrawable *drawable, } static void -clone_set_src_drawable(GimpDrawable *drawable) +clone_set_src_drawable (GimpDrawable *drawable) { if (src_drawable_ == drawable) return; if (src_drawable_) - gtk_signal_disconnect_by_data(GTK_OBJECT (src_drawable_), &src_drawable_); + gtk_signal_disconnect_by_data (GTK_OBJECT (src_drawable_), &src_drawable_); src_drawable_ = drawable; if (drawable) - { - gtk_signal_connect (GTK_OBJECT (drawable), - "destroy", - GTK_SIGNAL_FUNC (clone_src_drawable_destroyed_cb), - &src_drawable_); - } + { + gtk_signal_connect (GTK_OBJECT (drawable), "destroy", + GTK_SIGNAL_FUNC (clone_src_drawable_destroyed_cb), + &src_drawable_); + } } - void * clone_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + gint state) { GDisplay * gdisp; GDisplay * src_gdisp; @@ -258,10 +206,10 @@ clone_paint_func (PaintCore *paint_core, switch (state) { - case PRETRACE_PAINT : + case PRETRACE_PAINT: draw_core_pause (paint_core->core, active_tool); break; - case MOTION_PAINT : + case MOTION_PAINT: x1 = paint_core->curx; y1 = paint_core->cury; x2 = paint_core->lastx; @@ -302,7 +250,7 @@ clone_paint_func (PaintCore *paint_core, break; - case INIT_PAINT : + case INIT_PAINT: if (paint_core->state & GDK_CONTROL_MASK) { the_src_gdisp = gdisp; @@ -312,27 +260,27 @@ clone_paint_func (PaintCore *paint_core, first = TRUE; } else if (clone_options->aligned == ALIGN_NO) - { - first = TRUE; - orig_src_x = src_x; - orig_src_y = src_y; - } + { + first = TRUE; + orig_src_x = src_x; + orig_src_y = src_y; + } if (clone_options->type == PATTERN_CLONE) if (! gimp_context_get_pattern (NULL)) g_message (_("No patterns available for this operation.")); break; - case FINISH_PAINT : + case FINISH_PAINT: draw_core_stop (paint_core->core, active_tool); if (clone_options->aligned == ALIGN_NO && !first) - { - src_x = orig_src_x; - src_y = orig_src_y; - } + { + src_x = orig_src_x; + src_y = orig_src_y; + } return NULL; break; - default : + default: break; } @@ -350,11 +298,12 @@ clone_paint_func (PaintCore *paint_core, src_gdisp->canvas->window, active_tool); else if (state == POSTTRACE_PAINT) - { - /* Find the target cursor's location onscreen */ - gdisplay_transform_coords (src_gdisp, src_x, src_y, &trans_tx, &trans_ty, 1); - draw_core_resume (paint_core->core, active_tool); - } + { + /* Find the target cursor's location onscreen */ + gdisplay_transform_coords (src_gdisp, src_x, src_y, + &trans_tx, &trans_ty, 1); + draw_core_resume (paint_core->core, active_tool); + } return NULL; } @@ -393,19 +342,18 @@ clone_cursor_update (Tool *tool, } if (clone_options->type == IMAGE_CLONE) - { - if (mevent->state & GDK_CONTROL_MASK) - ctype = GDK_CROSSHAIR; - else if (!src_drawable_) - ctype = GIMP_BAD_CURSOR; - } + { + if (mevent->state & GDK_CONTROL_MASK) + ctype = GDK_CROSSHAIR; + else if (!src_drawable_) + ctype = GIMP_BAD_CURSOR; + } gdisplay_install_tool_cursor (gdisp, ctype); } - Tool * -tools_new_clone () +tools_new_clone (void) { Tool * tool; PaintCore * private; diff --git a/app/paint/gimpconvolve.c b/app/paint/gimpconvolve.c index fdab91ae78c960b8833d5f01937286bcb740b75a..56c6bfd343920c03fbe6a35e30ba3f74c1b866f5 100644 --- a/app/paint/gimpconvolve.c +++ b/app/paint/gimpconvolve.c @@ -16,18 +16,19 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include -#include "gdk/gdkkeysyms.h" + +#include + #include "appenv.h" #include "drawable.h" #include "errors.h" #include "convolve.h" #include "gdisplay.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimage.h" @@ -46,6 +47,7 @@ /* the convolve structures */ typedef struct _ConvolveOptions ConvolveOptions; + struct _ConvolveOptions { PaintOptions paint_options; @@ -54,8 +56,8 @@ struct _ConvolveOptions ConvolveType type_d; GtkWidget *type_w[2]; - double rate; - double rate_d; + gdouble rate; + gdouble rate_d; GtkObject *rate_w; }; @@ -64,14 +66,14 @@ struct _ConvolveOptions static ConvolveOptions * convolve_options = NULL; /* local variables */ -static int matrix [25]; -static int matrix_size; -static int matrix_divisor; +static gint matrix [25]; +static gint matrix_size; +static gint matrix_divisor; static ConvolveType non_gui_type; -static double non_gui_rate; +static gdouble non_gui_rate; -static float custom_matrix [25] = +static gfloat custom_matrix [25] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -80,7 +82,7 @@ static float custom_matrix [25] = 0, 0, 0, 0, 0, }; -static float blur_matrix [25] = +static gfloat blur_matrix [25] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, @@ -89,7 +91,7 @@ static float blur_matrix [25] = 0, 0 ,0, 0, 0, }; -static float sharpen_matrix [25] = +static gfloat sharpen_matrix [25] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, @@ -133,11 +135,9 @@ convolve_options_new (void) GtkWidget *label; GtkWidget *scale; GtkWidget *frame; - gchar* type_label[2] = { N_("Blur"), N_("Sharpen") }; - gint type_value[2] = { BLUR_CONVOLVE, SHARPEN_CONVOLVE }; /* the new convolve tool options structure */ - options = (ConvolveOptions *) g_malloc (sizeof (ConvolveOptions)); + options = g_new (ConvolveOptions, 1); paint_options_init ((PaintOptions *) options, CONVOLVE, convolve_options_reset); @@ -163,18 +163,22 @@ convolve_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->rate); gtk_widget_show (scale); gtk_widget_show (hbox); - frame = tool_options_radio_buttons_new (_("Convolve Type"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); + frame = gimp_radio_group_new2 (TRUE, _("Convolve Type"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Blur"), (gpointer) BLUR_CONVOLVE, + &options->type_w[0], + _("Sharpen"), (gpointer) SHARPEN_CONVOLVE, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/paint/gimpdodgeburn.c b/app/paint/gimpdodgeburn.c index 8050b5fb9bf6bac64d176b81560da7a35a368a58..53fc443de24f4e207cb67f455426292054437f20 100644 --- a/app/paint/gimpdodgeburn.c +++ b/app/paint/gimpdodgeburn.c @@ -20,7 +20,7 @@ #include #include -#include "gdk/gdkkeysyms.h" +#include #include "appenv.h" #include "drawable.h" @@ -28,11 +28,11 @@ #include "dodgeburn.h" #include "gdisplay.h" #include "gimplut.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimage.h" @@ -42,6 +42,7 @@ /* the dodgeburn structures */ typedef struct _DodgeBurnOptions DodgeBurnOptions; + struct _DodgeBurnOptions { PaintOptions paint_options; @@ -54,8 +55,8 @@ struct _DodgeBurnOptions DodgeBurnMode mode_d; GtkWidget *mode_w[3]; - double exposure; - double exposure_d; + gdouble exposure; + gdouble exposure_d; GtkObject *exposure_w; GimpLut *lut; @@ -120,19 +121,8 @@ dodgeburn_options_new (void) GtkWidget *scale; GtkWidget *frame; - gchar* type_label[2] = { N_("Dodge"), N_("Burn") }; - gint type_value[2] = { DODGE, BURN }; - - gchar* mode_label[3] = { N_("Highlights"), - N_("Midtones"), - N_("Shadows") }; - - gint mode_value[3] = { DODGEBURN_HIGHLIGHTS, - DODGEBURN_MIDTONES, - DODGEBURN_SHADOWS }; - /* the new dodgeburn tool options structure */ - options = (DodgeBurnOptions *) g_malloc (sizeof (DodgeBurnOptions)); + options = g_new (DodgeBurnOptions, 1); paint_options_init ((PaintOptions *) options, DODGEBURN, dodgeburn_options_reset); @@ -161,31 +151,42 @@ dodgeburn_options_new (void) gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->exposure_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->exposure); gtk_widget_show (scale); gtk_widget_show (hbox); /* the type (dodge or burn) */ - frame = tool_options_radio_buttons_new (_("Type"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); + frame = gimp_radio_group_new2 (TRUE, _("Type"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Dodge"), (gpointer) DODGE, + &options->type_w[0], + _("Burn"), (gpointer) BURN, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* mode (highlights, midtones, or shadows) */ - frame = tool_options_radio_buttons_new (_("Mode"), - &options->mode, - options->mode_w, - mode_label, - mode_value, - 3); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->mode_w[options->mode_d]), TRUE); + frame = + gimp_radio_group_new2 (TRUE, _("Mode"), + gimp_radio_button_update, + &options->mode, (gpointer) options->mode, + + _("Highlights"), (gpointer) DODGEBURN_HIGHLIGHTS, + &options->mode_w[0], + _("Midtones"), (gpointer) DODGEBURN_MIDTONES, + &options->mode_w[1], + _("Shadows"), (gpointer) DODGEBURN_SHADOWS, + &options->mode_w[2], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/paint/gimperaser.c b/app/paint/gimperaser.c index cbcf52dcc86a88dc66e58d3627e268609c92fa73..a7fbb6b900c0d50ef1f001a97d4e2c5874794e54 100644 --- a/app/paint/gimperaser.c +++ b/app/paint/gimperaser.c @@ -17,19 +17,20 @@ */ #include -#include "gdk/gdkkeysyms.h" +#include + #include "appenv.h" #include "cursorutil.h" #include "drawable.h" #include "errors.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "eraser.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpintl.h" @@ -93,7 +94,7 @@ eraser_options_new (void) GtkWidget *vbox; /* the new eraser tool options structure */ - options = (EraserOptions *) g_malloc (sizeof (EraserOptions)); + options = g_new (EraserOptions, 1); paint_options_init ((PaintOptions *) options, ERASER, eraser_options_reset); @@ -107,7 +108,7 @@ eraser_options_new (void) options->hard_w = gtk_check_button_new_with_label (_("Hard Edge")); gtk_box_pack_start (GTK_BOX (vbox), options->hard_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->hard_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->hard); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w), options->hard_d); @@ -117,7 +118,7 @@ eraser_options_new (void) options->anti_erase_w = gtk_check_button_new_with_label (_("Anti Erase")); gtk_box_pack_start (GTK_BOX (vbox), options->anti_erase_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->anti_erase_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->anti_erase); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w), options->anti_erase_d); diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c index c9c34b273117cbc0a22877fb64ec469eb938a317..aca0f894b56ea1083bba31bb392e5c4a60c395c4 100644 --- a/app/paint/gimpink.c +++ b/app/paint/gimpink.c @@ -25,9 +25,9 @@ #include "draw_core.h" #include "gimage_mask.h" #include "gimprc.h" +#include "gimpui.h" #include "ink.h" #include "paint_options.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" #include "blob.h" @@ -45,33 +45,35 @@ /* the Ink structures */ -typedef Blob *(*BlobFunc) (double, double, double, double, double, double); +typedef Blob *(*BlobFunc) (gdouble, gdouble, gdouble, gdouble, gdouble, gdouble); typedef struct _InkTool InkTool; + struct _InkTool { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - Blob * last_blob; /* blob for last cursor position */ + Blob *last_blob; /* blob for last cursor position */ - int x1, y1; /* image space coordinate */ - int x2, y2; /* image space coords */ + gint x1, y1; /* image space coordinate */ + gint x2, y2; /* image space coords */ /* circular distance history buffer */ - gdouble dt_buffer[DIST_SMOOTHER_BUFFER]; - gint dt_index; + gdouble dt_buffer[DIST_SMOOTHER_BUFFER]; + gint dt_index; /* circular timing history buffer */ - guint32 ts_buffer[TIME_SMOOTHER_BUFFER]; - gint ts_index; + guint32 ts_buffer[TIME_SMOOTHER_BUFFER]; + gint ts_index; - gdouble last_time; /* previous time of a motion event */ - gdouble lastx, lasty; /* previous position of a motion event */ + gdouble last_time; /* previous time of a motion event */ + gdouble lastx, lasty; /* previous position of a motion event */ - gboolean init_velocity; + gboolean init_velocity; }; typedef struct _BrushWidget BrushWidget; + struct _BrushWidget { GtkWidget *widget; @@ -79,44 +81,45 @@ struct _BrushWidget }; typedef struct _InkOptions InkOptions; + struct _InkOptions { PaintOptions paint_options; - double size; - double size_d; + gdouble size; + gdouble size_d; GtkObject *size_w; - double sensitivity; - double sensitivity_d; + gdouble sensitivity; + gdouble sensitivity_d; GtkObject *sensitivity_w; - double vel_sensitivity; - double vel_sensitivity_d; + gdouble vel_sensitivity; + gdouble vel_sensitivity_d; GtkObject *vel_sensitivity_w; - double tilt_sensitivity; - double tilt_sensitivity_d; + gdouble tilt_sensitivity; + gdouble tilt_sensitivity_d; GtkObject *tilt_sensitivity_w; - double tilt_angle; - double tilt_angle_d; + gdouble tilt_angle; + gdouble tilt_angle_d; GtkObject *tilt_angle_w; BlobFunc function; BlobFunc function_d; GtkWidget *function_w[3]; /* 3 radio buttons */ - double aspect; - double aspect_d; - double angle; - double angle_d; + gdouble aspect; + gdouble aspect_d; + gdouble angle; + gdouble angle_d; BrushWidget *brush_w; }; /* the ink tool options */ -static InkOptions *ink_options = NULL; +static InkOptions * ink_options = NULL; /* local variables */ @@ -265,7 +268,7 @@ ink_options_new (void) GdkPixmap *pixmap; /* the new ink tool options structure */ - options = (InkOptions *) g_malloc (sizeof (InkOptions)); + options = g_new (InkOptions, 1); paint_options_init ((PaintOptions *) options, INK, ink_options_reset); @@ -303,7 +306,7 @@ ink_options_new (void) gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 0, 1); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->size_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->size); gtk_widget_show (slider); @@ -321,7 +324,7 @@ ink_options_new (void) gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 1, 2); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->sensitivity); gtk_widget_show (slider); @@ -350,7 +353,7 @@ ink_options_new (void) gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->tilt_sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->tilt_sensitivity); gtk_widget_show (slider); @@ -380,7 +383,7 @@ ink_options_new (void) gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->vel_sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->vel_sensitivity); gtk_widget_show (slider); @@ -410,7 +413,7 @@ ink_options_new (void) gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->tilt_angle_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->tilt_angle); /* Brush type radiobuttons */ diff --git a/app/paint/gimppencil.c b/app/paint/gimppencil.c index 61cdab425557f76d0e08b0e099cee7eb834e3512..c9b431788fae14cb9f1c1d7d4ee6e418332170e7 100644 --- a/app/paint/gimppencil.c +++ b/app/paint/gimppencil.c @@ -29,13 +29,13 @@ #include "paintbrush.h" #include "pencil.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpintl.h" /* the pencil tool options */ typedef struct _PencilOptions PencilOptions; + struct _PencilOptions { PaintOptions paint_options; @@ -61,19 +61,19 @@ pencil_paint_func (PaintCore *paint_core, { switch (state) { - case INIT_PAINT : + case INIT_PAINT: break; - case MOTION_PAINT : + case MOTION_PAINT: pencil_motion (paint_core, drawable, pencil_options->paint_options.pressure_options, pencil_options->paint_options.incremental); break; - case FINISH_PAINT : + case FINISH_PAINT: break; - default : + default: break; } @@ -85,10 +85,11 @@ pencil_options_new (void) { PencilOptions *options; - options = (PencilOptions *) g_malloc (sizeof (PencilOptions)); + options = g_new (PencilOptions, 1); paint_options_init ((PaintOptions *) options, PENCIL, pencil_options_reset); + return options; } diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c index d8445da818eb627773536e8449fade90bfca723e..6c2154028c383b6d8dd5697bf64aa75a4ac74a3b 100644 --- a/app/paint/gimpsmudge.c +++ b/app/paint/gimpsmudge.c @@ -28,11 +28,11 @@ #include "smudge.h" #include "gdisplay.h" #include "gimplut.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimage.h" @@ -47,37 +47,41 @@ /* the smudge structures */ typedef struct _SmudgeOptions SmudgeOptions; + struct _SmudgeOptions { PaintOptions paint_options; - double rate; - double rate_d; + gdouble rate; + gdouble rate_d; GtkObject *rate_w; }; -static PixelRegion accumPR; -static unsigned char *accum_data; +static PixelRegion accumPR; +static guchar *accum_data; /* the smudge tool options */ -static SmudgeOptions *smudge_options = NULL; +static SmudgeOptions * smudge_options = NULL; /* local variables */ -static gdouble non_gui_rate; +static gdouble non_gui_rate; /* function prototypes */ -static void smudge_motion (PaintCore *, PaintPressureOptions *, - gdouble, GimpDrawable *); -static void smudge_init (PaintCore *, GimpDrawable *); -static void smudge_finish (PaintCore *, GimpDrawable *); - -static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, - gint * x, gint* y, - gint* w, gint *h); -static void smudge_allocate_accum_buffer (gint w, gint h, - gint bytes, guchar *do_fill); - +static void smudge_motion (PaintCore *, PaintPressureOptions *, + gdouble, GimpDrawable *); +static void smudge_init (PaintCore *, GimpDrawable *); +static void smudge_finish (PaintCore *, GimpDrawable *); + +static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, + gint *x, + gint *y, + gint *w, + gint *h); +static void smudge_allocate_accum_buffer (gint w, + gint h, + gint bytes, + guchar *do_fill); static void smudge_options_reset (void) @@ -100,7 +104,7 @@ smudge_options_new (void) GtkWidget *scale; /* the new smudge tool options structure */ - options = (SmudgeOptions *) g_malloc (sizeof (SmudgeOptions)); + options = g_new (SmudgeOptions, 1); paint_options_init ((PaintOptions *) options, SMUDGE, smudge_options_reset); @@ -126,7 +130,7 @@ smudge_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->rate); gtk_widget_show (scale); gtk_widget_show (hbox); @@ -224,7 +228,9 @@ smudge_init (PaintCore *paint_core, that may enter into the blend */ if (was_clipped) - do_fill = gimp_drawable_get_color_at (drawable, (gint)paint_core->curx, (gint) paint_core->cury); + do_fill = gimp_drawable_get_color_at (drawable, + (gint)paint_core->curx, + (gint) paint_core->cury); smudge_allocate_accum_buffer (w, h, drawable_bytes(drawable), do_fill); @@ -279,7 +285,7 @@ smudge_allocate_accum_buffer (gint w, } Tool * -tools_new_smudge () +tools_new_smudge (void) { Tool * tool; PaintCore * private; @@ -341,7 +347,7 @@ smudge_motion (PaintCore *paint_core, the drawable*/ pixel_region_init (&srcPR, drawable_data (drawable), - area->x, area->y, area->width, area->height, FALSE); + area->x, area->y, area->width, area->height, FALSE); /* Enable pressure sensitive rate */ if (pressure_options->rate) @@ -356,9 +362,8 @@ smudge_motion (PaintCore *paint_core, tempPR.y = area->y - y; tempPR.w = area->width; tempPR.h = area->height; - tempPR.data = accum_data - + tempPR.rowstride * tempPR.y - + tempPR.x * tempPR.bytes; + tempPR.data = accum_data + + tempPR.rowstride * tempPR.y + tempPR.x * tempPR.bytes; /* The dest will be the paint area we got above (= canvas_buf) */ @@ -439,7 +444,7 @@ smudge_non_gui (GimpDrawable *drawable, int num_strokes, double *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c index 4e2c4b1246c66d4077ef492a0b179f67fda2a73d..10d23f90fa53ac6c2d6f874a08170c7025a8ad80 100644 --- a/app/paint/gimpsourcecore.c +++ b/app/paint/gimpsourcecore.c @@ -1,4 +1,4 @@ - /* The GIMP -- an image manipulation program +/* 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 @@ -15,13 +15,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include + #include "appenv.h" #include "drawable.h" #include "errors.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "interface.h" #include "paint_funcs.h" #include "paint_core.h" @@ -50,6 +54,7 @@ typedef enum } AlignType; typedef struct _CloneOptions CloneOptions; + struct _CloneOptions { PaintOptions paint_options; @@ -98,20 +103,6 @@ static void clone_line_pattern (GImage *, GimpDrawable *, GPattern *, /* functions */ -static void -clone_type_callback (GtkWidget *widget, - gpointer data) -{ - clone_options->type = (CloneType) data; -} - -static void -align_type_callback (GtkWidget *widget, - gpointer data) -{ - clone_options->aligned = (AlignType) data; -} - static void clone_options_reset (void) { @@ -127,31 +118,11 @@ static CloneOptions * clone_options_new (void) { CloneOptions *options; - GtkWidget *vbox; - GSList *group = NULL; - GtkWidget *radio_frame; - GtkWidget *radio_box; - GtkWidget *radio_button; - int i; - - static gchar *source_names[] = - { - N_("Image Source"), - N_("Pattern Source") - }; - static gint n_source_names = sizeof (source_names) / sizeof (source_names[0]); - - static gchar *align_names[] = - { - N_("Non Aligned"), - N_("Aligned"), - N_("Registered") - }; - static gint n_align_names = sizeof (align_names) / sizeof (align_names[0]); + GtkWidget *frame; /* the new clone tool options structure */ - options = (CloneOptions *) g_malloc (sizeof (CloneOptions)); + options = g_new (CloneOptions, 1); paint_options_init ((PaintOptions *) options, CLONE, clone_options_reset); @@ -161,56 +132,35 @@ clone_options_new (void) /* the main vbox */ vbox = ((ToolOptions *) options)->main_vbox; - /* the radio frame and box */ - radio_frame = gtk_frame_new (_("Source")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + frame = gimp_radio_group_new2 (TRUE, _("Source"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + _("Image Source"), (gpointer) IMAGE_CLONE, + &options->type_w[0], + _("Pattern Source"), (gpointer) PATTERN_CLONE, + &options->type_w[1], - /* the radio buttons */ - for (i = 0; i < n_source_names; i++) - { - radio_button = gtk_radio_button_new_with_label (group, - gettext(source_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) clone_type_callback, - (void *)((long) i)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_widget_show (radio_button); - - options->type_w[i] = radio_button; - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + NULL); - /* the radio frame and box */ - radio_frame = gtk_frame_new (_("Alignment")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + frame = gimp_radio_group_new2 (TRUE, _("Alignment"), + gimp_radio_button_update, + &options->aligned, (gpointer) options->aligned, - /* the radio buttons */ - group = NULL; - for (i = 0; i < n_align_names; i++) - { - radio_button = gtk_radio_button_new_with_label (group, - gettext(align_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) align_type_callback, - (void *)((long) i)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_widget_show (radio_button); - - options->aligned_w[i] = radio_button; - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + _("Non Aligned"), (gpointer) ALIGN_NO, + &options->aligned_w[0], + _("Aligned"), (gpointer) ALIGN_YES, + &options->aligned_w[1], + _("Registered"), (gpointer) ALIGN_REGISTERED, + &options->aligned_w[2], + + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); return options; } @@ -227,27 +177,25 @@ clone_src_drawable_destroyed_cb (GimpDrawable *drawable, } static void -clone_set_src_drawable(GimpDrawable *drawable) +clone_set_src_drawable (GimpDrawable *drawable) { if (src_drawable_ == drawable) return; if (src_drawable_) - gtk_signal_disconnect_by_data(GTK_OBJECT (src_drawable_), &src_drawable_); + gtk_signal_disconnect_by_data (GTK_OBJECT (src_drawable_), &src_drawable_); src_drawable_ = drawable; if (drawable) - { - gtk_signal_connect (GTK_OBJECT (drawable), - "destroy", - GTK_SIGNAL_FUNC (clone_src_drawable_destroyed_cb), - &src_drawable_); - } + { + gtk_signal_connect (GTK_OBJECT (drawable), "destroy", + GTK_SIGNAL_FUNC (clone_src_drawable_destroyed_cb), + &src_drawable_); + } } - void * clone_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + gint state) { GDisplay * gdisp; GDisplay * src_gdisp; @@ -258,10 +206,10 @@ clone_paint_func (PaintCore *paint_core, switch (state) { - case PRETRACE_PAINT : + case PRETRACE_PAINT: draw_core_pause (paint_core->core, active_tool); break; - case MOTION_PAINT : + case MOTION_PAINT: x1 = paint_core->curx; y1 = paint_core->cury; x2 = paint_core->lastx; @@ -302,7 +250,7 @@ clone_paint_func (PaintCore *paint_core, break; - case INIT_PAINT : + case INIT_PAINT: if (paint_core->state & GDK_CONTROL_MASK) { the_src_gdisp = gdisp; @@ -312,27 +260,27 @@ clone_paint_func (PaintCore *paint_core, first = TRUE; } else if (clone_options->aligned == ALIGN_NO) - { - first = TRUE; - orig_src_x = src_x; - orig_src_y = src_y; - } + { + first = TRUE; + orig_src_x = src_x; + orig_src_y = src_y; + } if (clone_options->type == PATTERN_CLONE) if (! gimp_context_get_pattern (NULL)) g_message (_("No patterns available for this operation.")); break; - case FINISH_PAINT : + case FINISH_PAINT: draw_core_stop (paint_core->core, active_tool); if (clone_options->aligned == ALIGN_NO && !first) - { - src_x = orig_src_x; - src_y = orig_src_y; - } + { + src_x = orig_src_x; + src_y = orig_src_y; + } return NULL; break; - default : + default: break; } @@ -350,11 +298,12 @@ clone_paint_func (PaintCore *paint_core, src_gdisp->canvas->window, active_tool); else if (state == POSTTRACE_PAINT) - { - /* Find the target cursor's location onscreen */ - gdisplay_transform_coords (src_gdisp, src_x, src_y, &trans_tx, &trans_ty, 1); - draw_core_resume (paint_core->core, active_tool); - } + { + /* Find the target cursor's location onscreen */ + gdisplay_transform_coords (src_gdisp, src_x, src_y, + &trans_tx, &trans_ty, 1); + draw_core_resume (paint_core->core, active_tool); + } return NULL; } @@ -393,19 +342,18 @@ clone_cursor_update (Tool *tool, } if (clone_options->type == IMAGE_CLONE) - { - if (mevent->state & GDK_CONTROL_MASK) - ctype = GDK_CROSSHAIR; - else if (!src_drawable_) - ctype = GIMP_BAD_CURSOR; - } + { + if (mevent->state & GDK_CONTROL_MASK) + ctype = GDK_CROSSHAIR; + else if (!src_drawable_) + ctype = GIMP_BAD_CURSOR; + } gdisplay_install_tool_cursor (gdisp, ctype); } - Tool * -tools_new_clone () +tools_new_clone (void) { Tool * tool; PaintCore * private; diff --git a/app/paintbrush.c b/app/paintbrush.c index 1fd95fcbfb281877290a2f971575127e993139bc..0843171a54911cb377b9871f18b1e2924e1933d1 100644 --- a/app/paintbrush.c +++ b/app/paintbrush.c @@ -26,13 +26,13 @@ #include "gdisplay.h" #include "gimpbrushlist.h" #include "gimpbrushpipe.h" +#include "gimpui.h" #include "gradient.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "paintbrush.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpunitmenu.h" @@ -91,18 +91,19 @@ struct _PaintbrushOptions static PaintbrushOptions * paintbrush_options = NULL; /* local variables */ -static double non_gui_fade_out; -static double non_gui_gradient_length; -static int non_gui_gradient_type; -static double non_gui_incremental; -static GUnit non_gui_fade_unit; -static GUnit non_gui_gradient_unit; +static gdouble non_gui_fade_out; +static gdouble non_gui_gradient_length; +static gint non_gui_gradient_type; +static gdouble non_gui_incremental; +static GUnit non_gui_fade_unit; +static GUnit non_gui_gradient_unit; /* forward function declarations */ -static void paintbrush_motion (PaintCore *, GimpDrawable *, PaintPressureOptions *, - double, double, PaintApplicationMode, GradientPaintMode); - +static void paintbrush_motion (PaintCore *, GimpDrawable *, + PaintPressureOptions *, + double, double, PaintApplicationMode, + GradientPaintMode); /* functions */ @@ -114,7 +115,7 @@ paintbrush_gradient_toggle_callback (GtkWidget *widget, static int incremental_save = FALSE; - tool_options_toggle_update (widget, data); + gimp_toggle_button_update (widget, data); if (paintbrush_options->use_gradient) { @@ -240,7 +241,7 @@ paintbrush_options_new (void) gtk_check_button_new_with_label (_("Fade Out")); gtk_container_add (GTK_CONTAINER (abox), options->use_fade_w); gtk_signal_connect (GTK_OBJECT (options->use_fade_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->use_fade); gtk_widget_show (options->use_fade_w); @@ -252,7 +253,7 @@ paintbrush_options_new (void) gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); gtk_widget_set_usize (spinbutton, 75, 0); gtk_signal_connect (GTK_OBJECT (options->fade_out_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->fade_out); gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 0, 1); gtk_widget_show (spinbutton); @@ -261,7 +262,7 @@ paintbrush_options_new (void) options->fade_unit_w = gimp_unit_menu_new ("%a", options->fade_unit_d, TRUE, TRUE, TRUE); gtk_signal_connect (GTK_OBJECT (options->fade_unit_w), "unit_changed", - (GtkSignalFunc) tool_options_unitmenu_update, + GTK_SIGNAL_FUNC (gimp_unit_menu_update), &options->fade_unit); gtk_object_set_data (GTK_OBJECT (options->fade_unit_w), "set_digits", spinbutton); gtk_table_attach (GTK_TABLE (table), options->fade_unit_w, 2, 3, 0, 1, @@ -298,7 +299,7 @@ paintbrush_options_new (void) gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); gtk_widget_set_usize (spinbutton, 75, 0); gtk_signal_connect (GTK_OBJECT (options->gradient_length_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->gradient_length); gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 1, 2); gtk_widget_show (spinbutton); @@ -307,9 +308,10 @@ paintbrush_options_new (void) options->gradient_unit_w = gimp_unit_menu_new ("%a", options->gradient_unit_d, TRUE, TRUE, TRUE); gtk_signal_connect (GTK_OBJECT (options->gradient_unit_w), "unit_changed", - (GtkSignalFunc) tool_options_unitmenu_update, + GTK_SIGNAL_FUNC (gimp_unit_menu_update), &options->gradient_unit); - gtk_object_set_data (GTK_OBJECT (options->gradient_unit_w), "set_digits", spinbutton); + gtk_object_set_data (GTK_OBJECT (options->gradient_unit_w), "set_digits", + spinbutton); gtk_table_attach (GTK_TABLE (table), options->gradient_unit_w, 2, 3, 1, 2, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (options->gradient_unit_w); diff --git a/app/pencil.c b/app/pencil.c index 61cdab425557f76d0e08b0e099cee7eb834e3512..c9b431788fae14cb9f1c1d7d4ee6e418332170e7 100644 --- a/app/pencil.c +++ b/app/pencil.c @@ -29,13 +29,13 @@ #include "paintbrush.h" #include "pencil.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpintl.h" /* the pencil tool options */ typedef struct _PencilOptions PencilOptions; + struct _PencilOptions { PaintOptions paint_options; @@ -61,19 +61,19 @@ pencil_paint_func (PaintCore *paint_core, { switch (state) { - case INIT_PAINT : + case INIT_PAINT: break; - case MOTION_PAINT : + case MOTION_PAINT: pencil_motion (paint_core, drawable, pencil_options->paint_options.pressure_options, pencil_options->paint_options.incremental); break; - case FINISH_PAINT : + case FINISH_PAINT: break; - default : + default: break; } @@ -85,10 +85,11 @@ pencil_options_new (void) { PencilOptions *options; - options = (PencilOptions *) g_malloc (sizeof (PencilOptions)); + options = g_new (PencilOptions, 1); paint_options_init ((PaintOptions *) options, PENCIL, pencil_options_reset); + return options; } diff --git a/app/smudge.c b/app/smudge.c index d8445da818eb627773536e8449fade90bfca723e..6c2154028c383b6d8dd5697bf64aa75a4ac74a3b 100644 --- a/app/smudge.c +++ b/app/smudge.c @@ -28,11 +28,11 @@ #include "smudge.h" #include "gdisplay.h" #include "gimplut.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimage.h" @@ -47,37 +47,41 @@ /* the smudge structures */ typedef struct _SmudgeOptions SmudgeOptions; + struct _SmudgeOptions { PaintOptions paint_options; - double rate; - double rate_d; + gdouble rate; + gdouble rate_d; GtkObject *rate_w; }; -static PixelRegion accumPR; -static unsigned char *accum_data; +static PixelRegion accumPR; +static guchar *accum_data; /* the smudge tool options */ -static SmudgeOptions *smudge_options = NULL; +static SmudgeOptions * smudge_options = NULL; /* local variables */ -static gdouble non_gui_rate; +static gdouble non_gui_rate; /* function prototypes */ -static void smudge_motion (PaintCore *, PaintPressureOptions *, - gdouble, GimpDrawable *); -static void smudge_init (PaintCore *, GimpDrawable *); -static void smudge_finish (PaintCore *, GimpDrawable *); - -static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, - gint * x, gint* y, - gint* w, gint *h); -static void smudge_allocate_accum_buffer (gint w, gint h, - gint bytes, guchar *do_fill); - +static void smudge_motion (PaintCore *, PaintPressureOptions *, + gdouble, GimpDrawable *); +static void smudge_init (PaintCore *, GimpDrawable *); +static void smudge_finish (PaintCore *, GimpDrawable *); + +static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, + gint *x, + gint *y, + gint *w, + gint *h); +static void smudge_allocate_accum_buffer (gint w, + gint h, + gint bytes, + guchar *do_fill); static void smudge_options_reset (void) @@ -100,7 +104,7 @@ smudge_options_new (void) GtkWidget *scale; /* the new smudge tool options structure */ - options = (SmudgeOptions *) g_malloc (sizeof (SmudgeOptions)); + options = g_new (SmudgeOptions, 1); paint_options_init ((PaintOptions *) options, SMUDGE, smudge_options_reset); @@ -126,7 +130,7 @@ smudge_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->rate); gtk_widget_show (scale); gtk_widget_show (hbox); @@ -224,7 +228,9 @@ smudge_init (PaintCore *paint_core, that may enter into the blend */ if (was_clipped) - do_fill = gimp_drawable_get_color_at (drawable, (gint)paint_core->curx, (gint) paint_core->cury); + do_fill = gimp_drawable_get_color_at (drawable, + (gint)paint_core->curx, + (gint) paint_core->cury); smudge_allocate_accum_buffer (w, h, drawable_bytes(drawable), do_fill); @@ -279,7 +285,7 @@ smudge_allocate_accum_buffer (gint w, } Tool * -tools_new_smudge () +tools_new_smudge (void) { Tool * tool; PaintCore * private; @@ -341,7 +347,7 @@ smudge_motion (PaintCore *paint_core, the drawable*/ pixel_region_init (&srcPR, drawable_data (drawable), - area->x, area->y, area->width, area->height, FALSE); + area->x, area->y, area->width, area->height, FALSE); /* Enable pressure sensitive rate */ if (pressure_options->rate) @@ -356,9 +362,8 @@ smudge_motion (PaintCore *paint_core, tempPR.y = area->y - y; tempPR.w = area->width; tempPR.h = area->height; - tempPR.data = accum_data - + tempPR.rowstride * tempPR.y - + tempPR.x * tempPR.bytes; + tempPR.data = accum_data + + tempPR.rowstride * tempPR.y + tempPR.x * tempPR.bytes; /* The dest will be the paint area we got above (= canvas_buf) */ @@ -439,7 +444,7 @@ smudge_non_gui (GimpDrawable *drawable, int num_strokes, double *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) diff --git a/app/text_tool.c b/app/text_tool.c index b2b1716f2b500ffe89e752a1728b0e16c3107798..fc04848a08c25c0099ded0c53ff7c7456cd70f25 100644 --- a/app/text_tool.c +++ b/app/text_tool.c @@ -29,11 +29,11 @@ #include "errors.h" #include "floating_sel.h" #include "gimage_mask.h" +#include "gimpui.h" #include "global_edit.h" #include "procedural_db.h" #include "selection.h" #include "text_tool.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" @@ -141,7 +141,7 @@ text_options_new (void) GtkWidget *sep; /* the new text tool options structure */ - options = (TextOptions *) g_malloc (sizeof (TextOptions)); + options = g_new (TextOptions, 1); tool_options_init ((ToolOptions *) options, _("Text Tool Options"), text_options_reset); @@ -156,7 +156,7 @@ text_options_new (void) options->antialias_w = gtk_check_button_new_with_label (_("Antialiasing")); gtk_signal_connect (GTK_OBJECT (options->antialias_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->antialias); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w), options->antialias_d); @@ -175,7 +175,7 @@ text_options_new (void) options->border_w = gtk_adjustment_new (options->border_d, 0.0, 32767.0, 1.0, 50.0, 0.0); gtk_signal_connect (GTK_OBJECT (options->border_w), "value_changed", - (GtkSignalFunc) tool_options_int_adjustment_update, + GTK_SIGNAL_FUNC (gimp_int_adjustment_update), &options->border); spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (options->border_w), 1.0, 0.0); @@ -196,7 +196,7 @@ text_options_new (void) options->use_dyntext_w = gtk_check_button_new_with_label (_("Use Dynamic Text")); gtk_signal_connect (GTK_OBJECT (options->use_dyntext_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->use_dyntext); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_dyntext_w), options->use_dyntext_d); diff --git a/app/tool_options.c b/app/tool_options.c index d9b967715660f09983a675bccabcff82c0deaab5..03d819a1d76c90b370de286492572a9ee41ed68d 100644 --- a/app/tool_options.c +++ b/app/tool_options.c @@ -16,13 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" + #include "brush_select.h" #include "gimprc.h" #include "gimpui.h" #include "paint_funcs.h" #include "paint_options.h" #include "selection_options.h" -#include "tool_options_ui.h" #include "libgimp/gimpunitmenu.h" #include "libgimp/gimpintl.h" @@ -49,60 +49,7 @@ static void paint_pressure_options_reset (PaintPressureOptions /* ui helper functions ******************************************************/ -void -tool_options_toggle_update (GtkWidget *widget, - gpointer data) -{ - GtkWidget *set_sensitive; - gboolean *toggle_val; - - toggle_val = (gboolean *) data; - *toggle_val = (GTK_TOGGLE_BUTTON (widget)->active) ? TRUE : FALSE; - - /* a tool options toggle button can set the sensitive state of - * an arbitrary list of widgets - */ - - set_sensitive = - gtk_object_get_data (GTK_OBJECT (widget), "set_sensitive"); - while (set_sensitive) - { - gtk_widget_set_sensitive (GTK_WIDGET (set_sensitive), *toggle_val); - set_sensitive = - gtk_object_get_data (GTK_OBJECT (set_sensitive), "set_sensitive"); - } - - set_sensitive = - gtk_object_get_data (GTK_OBJECT (widget), "inverse_sensitive"); - while (set_sensitive) - { - gtk_widget_set_sensitive (GTK_WIDGET (set_sensitive), ! *toggle_val); - set_sensitive = - gtk_object_get_data (GTK_OBJECT (set_sensitive), "inverse_sensitive"); - } -} - -void -tool_options_int_adjustment_update (GtkWidget *widget, - gpointer data) -{ - gint *val; - - val = (gint *) data; - *val = GTK_ADJUSTMENT (widget)->value; -} - -void -tool_options_double_adjustment_update (GtkWidget *widget, - gpointer data) -{ - gdouble *val; - - val = (gdouble *) data; - *val = GTK_ADJUSTMENT (widget)->value; -} - -void +static void tool_options_opacity_adjustment_update (GtkWidget *widget, gpointer data) { @@ -122,82 +69,6 @@ tool_options_paint_mode_update (GtkWidget *widget, (LayerModeEffects) data); } -void -tool_options_unitmenu_update (GtkWidget *widget, - gpointer data) -{ - GUnit *val; - GtkWidget *spinbutton; - gint digits; - - val = (GUnit *) data; - *val = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget)); - - digits = ((*val == UNIT_PIXEL) ? 0 : - ((*val == UNIT_PERCENT) ? 2 : - (MIN (6, MAX (3, gimp_unit_get_digits (*val)))))); - - spinbutton = - gtk_object_get_data (GTK_OBJECT (widget), "set_digits"); - while (spinbutton) - { - gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits); - spinbutton = gtk_object_get_data (GTK_OBJECT (spinbutton), "set_digits"); - } -} - -static void -tool_options_radio_buttons_update (GtkWidget *widget, - gpointer data) -{ - gint *toggle_val; - - toggle_val = (gint *) data; - if (GTK_TOGGLE_BUTTON (widget)->active) - *toggle_val = (gint) gtk_object_get_data (GTK_OBJECT (widget), - "toggle_value"); -} - -GtkWidget * -tool_options_radio_buttons_new (gchar* label, - gpointer toggle_val, - GtkWidget* button_widget[], - gchar* button_label[], - gint button_value[], - gint num) -{ - GtkWidget *frame; - GtkWidget *vbox; - GSList *group = NULL; - gint i; - - frame = gtk_frame_new (label); - - g_return_val_if_fail (toggle_val != NULL, frame); - - vbox = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - for (i=0; ifeather_w), options->feather_d); gtk_signal_connect (GTK_OBJECT (options->feather_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->feather); gtk_widget_show (options->feather_w); @@ -316,7 +187,7 @@ selection_options_init (SelectionOptions *options, gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->feather_radius_w), "value_changed", - GTK_SIGNAL_FUNC (tool_options_double_adjustment_update), + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->feather_radius); gtk_widget_show (scale); @@ -336,7 +207,7 @@ selection_options_init (SelectionOptions *options, gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w), options->antialias_d); gtk_signal_connect (GTK_OBJECT (options->antialias_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->antialias); gtk_widget_show (options->antialias_w); } @@ -376,7 +247,7 @@ selection_options_init (SelectionOptions *options, gtk_box_pack_start (GTK_BOX (vbox), options->sample_merged_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->sample_merged_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->sample_merged); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->sample_merged_w), options->sample_merged_d); @@ -399,7 +270,7 @@ selection_options_init (SelectionOptions *options, gtk_box_pack_start (GTK_BOX (vbox), options->fixed_size_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->fixed_size_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->fixed_size); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->fixed_size_w), options->fixed_size_d); @@ -429,7 +300,7 @@ selection_options_init (SelectionOptions *options, gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (width_spinbutton), TRUE); gtk_widget_set_usize (width_spinbutton, 75, 0); gtk_signal_connect (GTK_OBJECT (options->fixed_width_w), "value_changed", - GTK_SIGNAL_FUNC (tool_options_double_adjustment_update), + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->fixed_width); gimp_table_attach_aligned (GTK_TABLE (table), 0, _("Width:"), 1.0, 0.5, @@ -445,7 +316,7 @@ selection_options_init (SelectionOptions *options, gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(height_spinbutton), TRUE); gtk_widget_set_usize (height_spinbutton, 75, 0); gtk_signal_connect (GTK_OBJECT (options->fixed_height_w), "value_changed", - GTK_SIGNAL_FUNC (tool_options_double_adjustment_update), + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->fixed_height); gimp_table_attach_aligned (GTK_TABLE (table), 1, _("Height:"), 1.0, 0.5, @@ -454,7 +325,7 @@ selection_options_init (SelectionOptions *options, options->fixed_unit_w = gimp_unit_menu_new ("%a", options->fixed_unit_d, TRUE, TRUE, TRUE); gtk_signal_connect (GTK_OBJECT (options->fixed_unit_w), "unit_changed", - GTK_SIGNAL_FUNC (tool_options_unitmenu_update), + GTK_SIGNAL_FUNC (gimp_unit_menu_update), &options->fixed_unit); gtk_object_set_data (GTK_OBJECT (options->fixed_unit_w), "set_digits", width_spinbutton); @@ -685,7 +556,7 @@ paint_options_init (PaintOptions *options, gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), options->incremental_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->incremental); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w), options->incremental_d); @@ -813,7 +684,7 @@ paint_pressure_options_new (ToolType tool_type) gtk_check_button_new_with_label (_("Opacity")); gtk_container_add (GTK_CONTAINER (hbox), pressure->opacity_w); gtk_signal_connect (GTK_OBJECT (pressure->opacity_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->opacity); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->opacity_w), pressure->opacity_d); @@ -836,7 +707,7 @@ paint_pressure_options_new (ToolType tool_type) pressure->pressure_w = gtk_check_button_new_with_label (_("Pressure")); gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w); gtk_signal_connect (GTK_OBJECT (pressure->pressure_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->pressure); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->pressure_w), pressure->pressure_d); @@ -856,7 +727,7 @@ paint_pressure_options_new (ToolType tool_type) gtk_check_button_new_with_label (_("Rate")); gtk_container_add (GTK_CONTAINER (hbox), pressure->rate_w); gtk_signal_connect (GTK_OBJECT (pressure->rate_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->rate); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->rate_w), pressure->rate_d); @@ -880,7 +751,7 @@ paint_pressure_options_new (ToolType tool_type) gtk_check_button_new_with_label (_("Size")); gtk_container_add (GTK_CONTAINER (hbox), pressure->size_w); gtk_signal_connect (GTK_OBJECT (pressure->size_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->size); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->size_w), pressure->size_d); @@ -900,7 +771,7 @@ paint_pressure_options_new (ToolType tool_type) gtk_check_button_new_with_label (_("Color")); gtk_container_add (GTK_CONTAINER (hbox), pressure->color_w); gtk_signal_connect (GTK_OBJECT (pressure->color_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->color); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->color_w), pressure->color_d); diff --git a/app/tool_options_ui.h b/app/tool_options_ui.h deleted file mode 100644 index 58832cedfa99820139d137828158b7927d18c6b5..0000000000000000000000000000000000000000 --- a/app/tool_options_ui.h +++ /dev/null @@ -1,53 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995-1999 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. - */ -#ifndef __TOOL_OPTIONS_UI_H__ -#define __TOOL_OPTIONS_UI_H__ - -#include - -/* a toggle button callback which sets the sensitive state of an attached - * list of widgets - */ -void tool_options_toggle_update (GtkWidget *widget, - gpointer data); - -/* a unit menu callback which sets the digits of an attached - * list of spinbuttons - */ -void tool_options_unitmenu_update (GtkWidget *widget, - gpointer data); - -/* integer and float adjustment callbacks - */ -void tool_options_int_adjustment_update (GtkWidget *widget, - gpointer data); -void tool_options_double_adjustment_update (GtkWidget *widget, - gpointer data); - -/* a group of radio buttons with a frame around them */ -GtkWidget* tool_options_radio_buttons_new (gchar* label, - gpointer toggle_val, - GtkWidget* button_widget[], - gchar* button_label[], - gint button_value[], - gint num); - -#endif /* __TOOL_OPTIONS_UI_H__ */ - - - diff --git a/app/tools/airbrush.c b/app/tools/airbrush.c index 20ea00d7a788162c723e6342582e4b86e2704897..6ff505297215237146abd7daa306ff526cba7c46 100644 --- a/app/tools/airbrush.c +++ b/app/tools/airbrush.c @@ -30,7 +30,6 @@ #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpintl.h" @@ -114,7 +113,7 @@ airbrush_options_new (void) GtkWidget *scale; /* the new airbrush tool options structure */ - options = (AirbrushOptions *) g_malloc (sizeof (AirbrushOptions)); + options = g_new (AirbrushOptions, 1); paint_options_init ((PaintOptions *) options, AIRBRUSH, airbrush_options_reset); @@ -136,7 +135,7 @@ airbrush_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->rate); gimp_table_attach_aligned (GTK_TABLE (table), 0, _("Rate:"), 1.0, 1.0, @@ -149,7 +148,7 @@ airbrush_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->pressure_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->pressure); gimp_table_attach_aligned (GTK_TABLE (table), 1, _("Pressure:"), 1.0, 1.0, @@ -200,10 +199,10 @@ airbrush_paint_func (PaintCore *paint_core, case INIT_PAINT : /* timer_state = OFF; */ if (timer_state == ON) - { - g_warning ("killing stray timer, please report to lewing@gimp.org"); - gtk_timeout_remove (timer); - } + { + g_warning ("killing stray timer, please report to lewing@gimp.org"); + gtk_timeout_remove (timer); + } timer_state = OFF; break; diff --git a/app/tools/blend.c b/app/tools/blend.c index a864a060a046fd98aef139b9972aa732d4c016da..9dd16ef55188f64047ac23529710cfd67a0d2d24 100644 --- a/app/tools/blend.c +++ b/app/tools/blend.c @@ -34,7 +34,6 @@ #include "interface.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" @@ -46,35 +45,37 @@ /* target size */ -#define TARGET_HEIGHT 15 -#define TARGET_WIDTH 15 +#define TARGET_HEIGHT 15 +#define TARGET_WIDTH 15 #define STATUSBAR_SIZE 128 /* the blend structures */ -typedef double (*RepeatFunc)(double); +typedef gdouble (* RepeatFunc) (gdouble); typedef struct _BlendTool BlendTool; + struct _BlendTool { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - int startx; /* starting x coord */ - int starty; /* starting y coord */ + gint startx; /* starting x coord */ + gint starty; /* starting y coord */ - int endx; /* ending x coord */ - int endy; /* ending y coord */ - guint context_id; /* for the statusbar */ + gint endx; /* ending x coord */ + gint endy; /* ending y coord */ + guint context_id; /* for the statusbar */ }; typedef struct _BlendOptions BlendOptions; + struct _BlendOptions { PaintOptions paint_options; - double offset; - double offset_d; + gdouble offset; + gdouble offset_d; GtkObject *offset_w; BlendMode blend_mode; @@ -89,37 +90,37 @@ struct _BlendOptions RepeatMode repeat_d; GtkWidget *repeat_w; - int supersample; - int supersample_d; + gint supersample; + gint supersample_d; GtkWidget *supersample_w; - int max_depth; - int max_depth_d; + gint max_depth; + gint max_depth_d; GtkObject *max_depth_w; - double threshold; - double threshold_d; + gdouble threshold; + gdouble threshold_d; GtkObject *threshold_w; }; typedef struct { - double offset; - double sx, sy; + gdouble offset; + gdouble sx, sy; BlendMode blend_mode; GradientType gradient_type; color_t fg, bg; - double dist; - double vec[2]; + gdouble dist; + gdouble vec[2]; RepeatFunc repeat_func; } RenderBlendData; typedef struct { - PixelRegion *PR; - unsigned char *row_data; - int bytes; - int width; + PixelRegion *PR; + guchar *row_data; + gint bytes; + gint width; } PutPixelData; @@ -302,7 +303,7 @@ blend_options_new () }; /* the new blend tool options structure */ - options = (BlendOptions *) g_malloc (sizeof (BlendOptions)); + options = g_new (BlendOptions, 1); paint_options_init ((PaintOptions *) options, BLEND, blend_options_reset); @@ -333,7 +334,7 @@ blend_options_new () _("Offset:"), 1.0, 1.0, scale, FALSE); gtk_signal_connect (GTK_OBJECT (options->offset_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->offset); /* the blend mode menu */ @@ -380,7 +381,7 @@ blend_options_new () gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->supersample_w), options->supersample_d); gtk_signal_connect (GTK_OBJECT (options->supersample_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->supersample); gtk_box_pack_start (GTK_BOX (vbox), options->supersample_w, FALSE, FALSE, 0); gtk_widget_show (options->supersample_w); @@ -407,7 +408,7 @@ blend_options_new () _("Max Depth:"), 1.0, 1.0, scale, FALSE); gtk_signal_connect (GTK_OBJECT(options->max_depth_w), "value_changed", - (GtkSignalFunc) tool_options_int_adjustment_update, + GTK_SIGNAL_FUNC (gimp_int_adjustment_update), &options->max_depth); /* threshold scale */ @@ -420,7 +421,7 @@ blend_options_new () _("Threshold:"), 1.0, 1.0, scale, FALSE); gtk_signal_connect (GTK_OBJECT(options->threshold_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->threshold); /* show the table */ diff --git a/app/tools/bucket_fill.c b/app/tools/bucket_fill.c index 3a46140b960f4a4d549e7df0bff8c1067c4f0846..44e035a29efae23b20382db2bcc26a6cadc498c3 100644 --- a/app/tools/bucket_fill.c +++ b/app/tools/bucket_fill.c @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include "gdk/gdkkeysyms.h" + +#include + #include "appenv.h" #include "bucket_fill.h" #include "cursorutil.h" @@ -24,11 +26,11 @@ #include "fuzzy_select.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "interface.h" #include "paint_funcs.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" @@ -104,12 +106,6 @@ bucket_options_new (void) GtkWidget *label; GtkWidget *scale; GtkWidget *frame; - gchar* fill_mode_label[3] = { N_("FG Color Fill"), - N_("BG Color Fill"), - N_("Pattern Fill") }; - gint fill_mode_value[3] = { FG_BUCKET_FILL, - BG_BUCKET_FILL, - PATTERN_BUCKET_FILL }; /* the new bucket fill tool options structure */ options = (BucketOptions *) g_malloc (sizeof (BucketOptions)); @@ -139,7 +135,7 @@ bucket_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->threshold_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->threshold); gtk_widget_show (scale); @@ -149,19 +145,29 @@ bucket_options_new (void) options->sample_merged_w = gtk_check_button_new_with_label (_("Sample Merged")); gtk_signal_connect (GTK_OBJECT (options->sample_merged_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->sample_merged); gtk_box_pack_start (GTK_BOX (vbox), options->sample_merged_w, FALSE, FALSE, 0); gtk_widget_show (options->sample_merged_w); /* fill type */ - frame = tool_options_radio_buttons_new (_("Fill Type"), - &options->fill_mode, - options->fill_mode_w, - fill_mode_label, - fill_mode_value, - 3); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->fill_mode_w[options->fill_mode_d]), TRUE); + frame = + gimp_radio_group_new2 (TRUE, _("Fill Type"), + gimp_radio_button_update, + &options->fill_mode, (gpointer) options->fill_mode, + + _("FG Color Fill"), + (gpointer) FG_BUCKET_FILL, + &options->fill_mode_w[0], + _("BG Color Fill"), + (gpointer) BG_BUCKET_FILL, + &options->fill_mode_w[1], + _("Pattern Fill"), + (gpointer) PATTERN_BUCKET_FILL, + &options->fill_mode_w[2], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/tools/clone.c b/app/tools/clone.c index 4e2c4b1246c66d4077ef492a0b179f67fda2a73d..10d23f90fa53ac6c2d6f874a08170c7025a8ad80 100644 --- a/app/tools/clone.c +++ b/app/tools/clone.c @@ -1,4 +1,4 @@ - /* The GIMP -- an image manipulation program +/* 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 @@ -15,13 +15,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include + #include "appenv.h" #include "drawable.h" #include "errors.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "interface.h" #include "paint_funcs.h" #include "paint_core.h" @@ -50,6 +54,7 @@ typedef enum } AlignType; typedef struct _CloneOptions CloneOptions; + struct _CloneOptions { PaintOptions paint_options; @@ -98,20 +103,6 @@ static void clone_line_pattern (GImage *, GimpDrawable *, GPattern *, /* functions */ -static void -clone_type_callback (GtkWidget *widget, - gpointer data) -{ - clone_options->type = (CloneType) data; -} - -static void -align_type_callback (GtkWidget *widget, - gpointer data) -{ - clone_options->aligned = (AlignType) data; -} - static void clone_options_reset (void) { @@ -127,31 +118,11 @@ static CloneOptions * clone_options_new (void) { CloneOptions *options; - GtkWidget *vbox; - GSList *group = NULL; - GtkWidget *radio_frame; - GtkWidget *radio_box; - GtkWidget *radio_button; - int i; - - static gchar *source_names[] = - { - N_("Image Source"), - N_("Pattern Source") - }; - static gint n_source_names = sizeof (source_names) / sizeof (source_names[0]); - - static gchar *align_names[] = - { - N_("Non Aligned"), - N_("Aligned"), - N_("Registered") - }; - static gint n_align_names = sizeof (align_names) / sizeof (align_names[0]); + GtkWidget *frame; /* the new clone tool options structure */ - options = (CloneOptions *) g_malloc (sizeof (CloneOptions)); + options = g_new (CloneOptions, 1); paint_options_init ((PaintOptions *) options, CLONE, clone_options_reset); @@ -161,56 +132,35 @@ clone_options_new (void) /* the main vbox */ vbox = ((ToolOptions *) options)->main_vbox; - /* the radio frame and box */ - radio_frame = gtk_frame_new (_("Source")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + frame = gimp_radio_group_new2 (TRUE, _("Source"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + _("Image Source"), (gpointer) IMAGE_CLONE, + &options->type_w[0], + _("Pattern Source"), (gpointer) PATTERN_CLONE, + &options->type_w[1], - /* the radio buttons */ - for (i = 0; i < n_source_names; i++) - { - radio_button = gtk_radio_button_new_with_label (group, - gettext(source_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) clone_type_callback, - (void *)((long) i)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_widget_show (radio_button); - - options->type_w[i] = radio_button; - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + NULL); - /* the radio frame and box */ - radio_frame = gtk_frame_new (_("Alignment")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + frame = gimp_radio_group_new2 (TRUE, _("Alignment"), + gimp_radio_button_update, + &options->aligned, (gpointer) options->aligned, - /* the radio buttons */ - group = NULL; - for (i = 0; i < n_align_names; i++) - { - radio_button = gtk_radio_button_new_with_label (group, - gettext(align_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) align_type_callback, - (void *)((long) i)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_widget_show (radio_button); - - options->aligned_w[i] = radio_button; - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + _("Non Aligned"), (gpointer) ALIGN_NO, + &options->aligned_w[0], + _("Aligned"), (gpointer) ALIGN_YES, + &options->aligned_w[1], + _("Registered"), (gpointer) ALIGN_REGISTERED, + &options->aligned_w[2], + + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); return options; } @@ -227,27 +177,25 @@ clone_src_drawable_destroyed_cb (GimpDrawable *drawable, } static void -clone_set_src_drawable(GimpDrawable *drawable) +clone_set_src_drawable (GimpDrawable *drawable) { if (src_drawable_ == drawable) return; if (src_drawable_) - gtk_signal_disconnect_by_data(GTK_OBJECT (src_drawable_), &src_drawable_); + gtk_signal_disconnect_by_data (GTK_OBJECT (src_drawable_), &src_drawable_); src_drawable_ = drawable; if (drawable) - { - gtk_signal_connect (GTK_OBJECT (drawable), - "destroy", - GTK_SIGNAL_FUNC (clone_src_drawable_destroyed_cb), - &src_drawable_); - } + { + gtk_signal_connect (GTK_OBJECT (drawable), "destroy", + GTK_SIGNAL_FUNC (clone_src_drawable_destroyed_cb), + &src_drawable_); + } } - void * clone_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + gint state) { GDisplay * gdisp; GDisplay * src_gdisp; @@ -258,10 +206,10 @@ clone_paint_func (PaintCore *paint_core, switch (state) { - case PRETRACE_PAINT : + case PRETRACE_PAINT: draw_core_pause (paint_core->core, active_tool); break; - case MOTION_PAINT : + case MOTION_PAINT: x1 = paint_core->curx; y1 = paint_core->cury; x2 = paint_core->lastx; @@ -302,7 +250,7 @@ clone_paint_func (PaintCore *paint_core, break; - case INIT_PAINT : + case INIT_PAINT: if (paint_core->state & GDK_CONTROL_MASK) { the_src_gdisp = gdisp; @@ -312,27 +260,27 @@ clone_paint_func (PaintCore *paint_core, first = TRUE; } else if (clone_options->aligned == ALIGN_NO) - { - first = TRUE; - orig_src_x = src_x; - orig_src_y = src_y; - } + { + first = TRUE; + orig_src_x = src_x; + orig_src_y = src_y; + } if (clone_options->type == PATTERN_CLONE) if (! gimp_context_get_pattern (NULL)) g_message (_("No patterns available for this operation.")); break; - case FINISH_PAINT : + case FINISH_PAINT: draw_core_stop (paint_core->core, active_tool); if (clone_options->aligned == ALIGN_NO && !first) - { - src_x = orig_src_x; - src_y = orig_src_y; - } + { + src_x = orig_src_x; + src_y = orig_src_y; + } return NULL; break; - default : + default: break; } @@ -350,11 +298,12 @@ clone_paint_func (PaintCore *paint_core, src_gdisp->canvas->window, active_tool); else if (state == POSTTRACE_PAINT) - { - /* Find the target cursor's location onscreen */ - gdisplay_transform_coords (src_gdisp, src_x, src_y, &trans_tx, &trans_ty, 1); - draw_core_resume (paint_core->core, active_tool); - } + { + /* Find the target cursor's location onscreen */ + gdisplay_transform_coords (src_gdisp, src_x, src_y, + &trans_tx, &trans_ty, 1); + draw_core_resume (paint_core->core, active_tool); + } return NULL; } @@ -393,19 +342,18 @@ clone_cursor_update (Tool *tool, } if (clone_options->type == IMAGE_CLONE) - { - if (mevent->state & GDK_CONTROL_MASK) - ctype = GDK_CROSSHAIR; - else if (!src_drawable_) - ctype = GIMP_BAD_CURSOR; - } + { + if (mevent->state & GDK_CONTROL_MASK) + ctype = GDK_CROSSHAIR; + else if (!src_drawable_) + ctype = GIMP_BAD_CURSOR; + } gdisplay_install_tool_cursor (gdisp, ctype); } - Tool * -tools_new_clone () +tools_new_clone (void) { Tool * tool; PaintCore * private; diff --git a/app/tools/color_picker.c b/app/tools/color_picker.c index 01e25804a79e2294ec682405235a7c1e3add0409..60216c1b2c3410e92c68a6d34bbe1af653c58ea3 100644 --- a/app/tools/color_picker.c +++ b/app/tools/color_picker.c @@ -25,7 +25,6 @@ #include "cursorutil.h" #include "info_dialog.h" #include "palette.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimprc.h" @@ -158,7 +157,7 @@ color_picker_options_new (void) options->sample_merged_d); gtk_box_pack_start (GTK_BOX (vbox), options->sample_merged_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->sample_merged_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->sample_merged); gtk_widget_show (options->sample_merged_w); @@ -174,7 +173,7 @@ color_picker_options_new (void) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->sample_average_w), options->sample_average_d); gtk_signal_connect (GTK_OBJECT (options->sample_average_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->sample_average); gtk_widget_show (options->sample_average_w); @@ -204,7 +203,7 @@ color_picker_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->average_radius_w), "value_changed", - GTK_SIGNAL_FUNC (tool_options_double_adjustment_update), + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->average_radius); gtk_widget_show (scale); gtk_widget_show (table); @@ -216,7 +215,7 @@ color_picker_options_new (void) options->update_active_d); gtk_box_pack_start (GTK_BOX (vbox), options->update_active_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->update_active_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->update_active); gtk_widget_show (options->update_active_w); diff --git a/app/tools/convolve.c b/app/tools/convolve.c index fdab91ae78c960b8833d5f01937286bcb740b75a..56c6bfd343920c03fbe6a35e30ba3f74c1b866f5 100644 --- a/app/tools/convolve.c +++ b/app/tools/convolve.c @@ -16,18 +16,19 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include -#include "gdk/gdkkeysyms.h" + +#include + #include "appenv.h" #include "drawable.h" #include "errors.h" #include "convolve.h" #include "gdisplay.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimage.h" @@ -46,6 +47,7 @@ /* the convolve structures */ typedef struct _ConvolveOptions ConvolveOptions; + struct _ConvolveOptions { PaintOptions paint_options; @@ -54,8 +56,8 @@ struct _ConvolveOptions ConvolveType type_d; GtkWidget *type_w[2]; - double rate; - double rate_d; + gdouble rate; + gdouble rate_d; GtkObject *rate_w; }; @@ -64,14 +66,14 @@ struct _ConvolveOptions static ConvolveOptions * convolve_options = NULL; /* local variables */ -static int matrix [25]; -static int matrix_size; -static int matrix_divisor; +static gint matrix [25]; +static gint matrix_size; +static gint matrix_divisor; static ConvolveType non_gui_type; -static double non_gui_rate; +static gdouble non_gui_rate; -static float custom_matrix [25] = +static gfloat custom_matrix [25] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -80,7 +82,7 @@ static float custom_matrix [25] = 0, 0, 0, 0, 0, }; -static float blur_matrix [25] = +static gfloat blur_matrix [25] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, @@ -89,7 +91,7 @@ static float blur_matrix [25] = 0, 0 ,0, 0, 0, }; -static float sharpen_matrix [25] = +static gfloat sharpen_matrix [25] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, @@ -133,11 +135,9 @@ convolve_options_new (void) GtkWidget *label; GtkWidget *scale; GtkWidget *frame; - gchar* type_label[2] = { N_("Blur"), N_("Sharpen") }; - gint type_value[2] = { BLUR_CONVOLVE, SHARPEN_CONVOLVE }; /* the new convolve tool options structure */ - options = (ConvolveOptions *) g_malloc (sizeof (ConvolveOptions)); + options = g_new (ConvolveOptions, 1); paint_options_init ((PaintOptions *) options, CONVOLVE, convolve_options_reset); @@ -163,18 +163,22 @@ convolve_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->rate); gtk_widget_show (scale); gtk_widget_show (hbox); - frame = tool_options_radio_buttons_new (_("Convolve Type"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); + frame = gimp_radio_group_new2 (TRUE, _("Convolve Type"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Blur"), (gpointer) BLUR_CONVOLVE, + &options->type_w[0], + _("Sharpen"), (gpointer) SHARPEN_CONVOLVE, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/tools/crop.c b/app/tools/crop.c index 349e03cb1abf2fa8423bf4cd0771eb4a43a8876f..22c763e68541a9d411753284aeaa3ab7e18437c7 100644 --- a/app/tools/crop.c +++ b/app/tools/crop.c @@ -17,7 +17,8 @@ */ #include -#include "gdk/gdkkeysyms.h" +#include + #include "appenv.h" #include "crop.h" #include "cursorutil.h" @@ -29,7 +30,6 @@ #include "gimphelp.h" #include "gimpui.h" #include "info_dialog.h" -#include "tool_options_ui.h" #include "undo.h" #include "libgimp/gimpsizeentry.h" @@ -50,29 +50,31 @@ /* the crop structures */ typedef struct _Crop Crop; + struct _Crop { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - int startx; /* starting x coord */ - int starty; /* starting y coord */ + gint startx; /* starting x coord */ + gint starty; /* starting y coord */ - int lastx; /* previous x coord */ - int lasty; /* previous y coord */ + gint lastx; /* previous x coord */ + gint lasty; /* previous y coord */ - int x1, y1; /* upper left hand coordinate */ - int x2, y2; /* lower right hand coords */ + gint x1, y1; /* upper left hand coordinate */ + gint x2, y2; /* lower right hand coords */ - int srw, srh; /* width and height of corners */ + gint srw, srh; /* width and height of corners */ - int tx1, ty1; /* transformed coords */ - int tx2, ty2; /* */ + gint tx1, ty1; /* transformed coords */ + gint tx2, ty2; /* */ - int function; /* moving or resizing */ - guint context_id; /* for the statusbar */ + gint function; /* moving or resizing */ + guint context_id; /* for the statusbar */ }; typedef struct _CropOptions CropOptions; + struct _CropOptions { ToolOptions tool_options; @@ -168,11 +170,9 @@ crop_options_new (void) CropOptions *options; GtkWidget *vbox; GtkWidget *frame; - gchar* type_label[2] = { N_("Crop"), N_("Resize") }; - gint type_value[2] = { CROP_CROP, RESIZE_CROP }; /* the new crop tool options structure */ - options = (CropOptions *) g_malloc (sizeof (CropOptions)); + options = g_new (CropOptions, 1); tool_options_init ((ToolOptions *) options, _("Crop & Resize Options"), crop_options_reset); @@ -189,7 +189,7 @@ crop_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), options->layer_only_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->layer_only_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->layer_only); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->layer_only_w), options->layer_only_d); @@ -200,20 +200,24 @@ crop_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), options->allow_enlarge_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->allow_enlarge_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->allow_enlarge); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_enlarge_w), options->allow_enlarge_d); gtk_widget_show (options->allow_enlarge_w); /* tool toggle */ - frame = tool_options_radio_buttons_new (_("Tool Toggle"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); + frame = gimp_radio_group_new2 (TRUE, _("Tool Toggle"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Crop"), (gpointer) CROP_CROP, + &options->type_w[0], + _("Resize"), (gpointer) RESIZE_CROP, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/tools/dodgeburn.c b/app/tools/dodgeburn.c index 8050b5fb9bf6bac64d176b81560da7a35a368a58..53fc443de24f4e207cb67f455426292054437f20 100644 --- a/app/tools/dodgeburn.c +++ b/app/tools/dodgeburn.c @@ -20,7 +20,7 @@ #include #include -#include "gdk/gdkkeysyms.h" +#include #include "appenv.h" #include "drawable.h" @@ -28,11 +28,11 @@ #include "dodgeburn.h" #include "gdisplay.h" #include "gimplut.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimage.h" @@ -42,6 +42,7 @@ /* the dodgeburn structures */ typedef struct _DodgeBurnOptions DodgeBurnOptions; + struct _DodgeBurnOptions { PaintOptions paint_options; @@ -54,8 +55,8 @@ struct _DodgeBurnOptions DodgeBurnMode mode_d; GtkWidget *mode_w[3]; - double exposure; - double exposure_d; + gdouble exposure; + gdouble exposure_d; GtkObject *exposure_w; GimpLut *lut; @@ -120,19 +121,8 @@ dodgeburn_options_new (void) GtkWidget *scale; GtkWidget *frame; - gchar* type_label[2] = { N_("Dodge"), N_("Burn") }; - gint type_value[2] = { DODGE, BURN }; - - gchar* mode_label[3] = { N_("Highlights"), - N_("Midtones"), - N_("Shadows") }; - - gint mode_value[3] = { DODGEBURN_HIGHLIGHTS, - DODGEBURN_MIDTONES, - DODGEBURN_SHADOWS }; - /* the new dodgeburn tool options structure */ - options = (DodgeBurnOptions *) g_malloc (sizeof (DodgeBurnOptions)); + options = g_new (DodgeBurnOptions, 1); paint_options_init ((PaintOptions *) options, DODGEBURN, dodgeburn_options_reset); @@ -161,31 +151,42 @@ dodgeburn_options_new (void) gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->exposure_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->exposure); gtk_widget_show (scale); gtk_widget_show (hbox); /* the type (dodge or burn) */ - frame = tool_options_radio_buttons_new (_("Type"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); + frame = gimp_radio_group_new2 (TRUE, _("Type"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Dodge"), (gpointer) DODGE, + &options->type_w[0], + _("Burn"), (gpointer) BURN, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* mode (highlights, midtones, or shadows) */ - frame = tool_options_radio_buttons_new (_("Mode"), - &options->mode, - options->mode_w, - mode_label, - mode_value, - 3); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->mode_w[options->mode_d]), TRUE); + frame = + gimp_radio_group_new2 (TRUE, _("Mode"), + gimp_radio_button_update, + &options->mode, (gpointer) options->mode, + + _("Highlights"), (gpointer) DODGEBURN_HIGHLIGHTS, + &options->mode_w[0], + _("Midtones"), (gpointer) DODGEBURN_MIDTONES, + &options->mode_w[1], + _("Shadows"), (gpointer) DODGEBURN_SHADOWS, + &options->mode_w[2], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/tools/eraser.c b/app/tools/eraser.c index cbcf52dcc86a88dc66e58d3627e268609c92fa73..a7fbb6b900c0d50ef1f001a97d4e2c5874794e54 100644 --- a/app/tools/eraser.c +++ b/app/tools/eraser.c @@ -17,19 +17,20 @@ */ #include -#include "gdk/gdkkeysyms.h" +#include + #include "appenv.h" #include "cursorutil.h" #include "drawable.h" #include "errors.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "eraser.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpintl.h" @@ -93,7 +94,7 @@ eraser_options_new (void) GtkWidget *vbox; /* the new eraser tool options structure */ - options = (EraserOptions *) g_malloc (sizeof (EraserOptions)); + options = g_new (EraserOptions, 1); paint_options_init ((PaintOptions *) options, ERASER, eraser_options_reset); @@ -107,7 +108,7 @@ eraser_options_new (void) options->hard_w = gtk_check_button_new_with_label (_("Hard Edge")); gtk_box_pack_start (GTK_BOX (vbox), options->hard_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->hard_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->hard); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w), options->hard_d); @@ -117,7 +118,7 @@ eraser_options_new (void) options->anti_erase_w = gtk_check_button_new_with_label (_("Anti Erase")); gtk_box_pack_start (GTK_BOX (vbox), options->anti_erase_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->anti_erase_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->anti_erase); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w), options->anti_erase_d); diff --git a/app/tools/flip_tool.c b/app/tools/flip_tool.c index ec73f71fc461a278d39b5143c7df54079101e13a..9ed4dc02e260596e1d292ce70ffd55f1bc59972f 100644 --- a/app/tools/flip_tool.c +++ b/app/tools/flip_tool.c @@ -16,15 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include "gdk/gdkkeysyms.h" + +#include + #include "appenv.h" #include "cursorutil.h" #include "drawable.h" #include "flip_tool.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "temp_buf.h" -#include "tool_options_ui.h" #include "paths_dialogP.h" #include "undo.h" @@ -72,8 +74,6 @@ flip_options_new (void) GtkWidget *vbox; GtkWidget *frame; - gchar* type_label[2] = { N_("Horizontal"), N_("Vertical") }; - gint type_value[2] = { ORIENTATION_HORIZONTAL, ORIENTATION_VERTICAL }; /* the new flip tool options structure */ options = g_new (FlipOptions, 1); @@ -86,13 +86,18 @@ flip_options_new (void) vbox = options->tool_options.main_vbox; /* tool toggle */ - frame = tool_options_radio_buttons_new (_("Tool Toggle"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d - 1]), TRUE); + frame = + gimp_radio_group_new2 (TRUE, _("Tool Toggle"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Horizontal"), (gpointer) ORIENTATION_HORIZONTAL, + &options->type_w[0], + _("Vertical"), (gpointer) ORIENTATION_VERTICAL, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/tools/gimpairbrushtool.c b/app/tools/gimpairbrushtool.c index 20ea00d7a788162c723e6342582e4b86e2704897..6ff505297215237146abd7daa306ff526cba7c46 100644 --- a/app/tools/gimpairbrushtool.c +++ b/app/tools/gimpairbrushtool.c @@ -30,7 +30,6 @@ #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpintl.h" @@ -114,7 +113,7 @@ airbrush_options_new (void) GtkWidget *scale; /* the new airbrush tool options structure */ - options = (AirbrushOptions *) g_malloc (sizeof (AirbrushOptions)); + options = g_new (AirbrushOptions, 1); paint_options_init ((PaintOptions *) options, AIRBRUSH, airbrush_options_reset); @@ -136,7 +135,7 @@ airbrush_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->rate); gimp_table_attach_aligned (GTK_TABLE (table), 0, _("Rate:"), 1.0, 1.0, @@ -149,7 +148,7 @@ airbrush_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->pressure_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->pressure); gimp_table_attach_aligned (GTK_TABLE (table), 1, _("Pressure:"), 1.0, 1.0, @@ -200,10 +199,10 @@ airbrush_paint_func (PaintCore *paint_core, case INIT_PAINT : /* timer_state = OFF; */ if (timer_state == ON) - { - g_warning ("killing stray timer, please report to lewing@gimp.org"); - gtk_timeout_remove (timer); - } + { + g_warning ("killing stray timer, please report to lewing@gimp.org"); + gtk_timeout_remove (timer); + } timer_state = OFF; break; diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c index a864a060a046fd98aef139b9972aa732d4c016da..9dd16ef55188f64047ac23529710cfd67a0d2d24 100644 --- a/app/tools/gimpblendtool.c +++ b/app/tools/gimpblendtool.c @@ -34,7 +34,6 @@ #include "interface.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" @@ -46,35 +45,37 @@ /* target size */ -#define TARGET_HEIGHT 15 -#define TARGET_WIDTH 15 +#define TARGET_HEIGHT 15 +#define TARGET_WIDTH 15 #define STATUSBAR_SIZE 128 /* the blend structures */ -typedef double (*RepeatFunc)(double); +typedef gdouble (* RepeatFunc) (gdouble); typedef struct _BlendTool BlendTool; + struct _BlendTool { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - int startx; /* starting x coord */ - int starty; /* starting y coord */ + gint startx; /* starting x coord */ + gint starty; /* starting y coord */ - int endx; /* ending x coord */ - int endy; /* ending y coord */ - guint context_id; /* for the statusbar */ + gint endx; /* ending x coord */ + gint endy; /* ending y coord */ + guint context_id; /* for the statusbar */ }; typedef struct _BlendOptions BlendOptions; + struct _BlendOptions { PaintOptions paint_options; - double offset; - double offset_d; + gdouble offset; + gdouble offset_d; GtkObject *offset_w; BlendMode blend_mode; @@ -89,37 +90,37 @@ struct _BlendOptions RepeatMode repeat_d; GtkWidget *repeat_w; - int supersample; - int supersample_d; + gint supersample; + gint supersample_d; GtkWidget *supersample_w; - int max_depth; - int max_depth_d; + gint max_depth; + gint max_depth_d; GtkObject *max_depth_w; - double threshold; - double threshold_d; + gdouble threshold; + gdouble threshold_d; GtkObject *threshold_w; }; typedef struct { - double offset; - double sx, sy; + gdouble offset; + gdouble sx, sy; BlendMode blend_mode; GradientType gradient_type; color_t fg, bg; - double dist; - double vec[2]; + gdouble dist; + gdouble vec[2]; RepeatFunc repeat_func; } RenderBlendData; typedef struct { - PixelRegion *PR; - unsigned char *row_data; - int bytes; - int width; + PixelRegion *PR; + guchar *row_data; + gint bytes; + gint width; } PutPixelData; @@ -302,7 +303,7 @@ blend_options_new () }; /* the new blend tool options structure */ - options = (BlendOptions *) g_malloc (sizeof (BlendOptions)); + options = g_new (BlendOptions, 1); paint_options_init ((PaintOptions *) options, BLEND, blend_options_reset); @@ -333,7 +334,7 @@ blend_options_new () _("Offset:"), 1.0, 1.0, scale, FALSE); gtk_signal_connect (GTK_OBJECT (options->offset_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->offset); /* the blend mode menu */ @@ -380,7 +381,7 @@ blend_options_new () gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->supersample_w), options->supersample_d); gtk_signal_connect (GTK_OBJECT (options->supersample_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->supersample); gtk_box_pack_start (GTK_BOX (vbox), options->supersample_w, FALSE, FALSE, 0); gtk_widget_show (options->supersample_w); @@ -407,7 +408,7 @@ blend_options_new () _("Max Depth:"), 1.0, 1.0, scale, FALSE); gtk_signal_connect (GTK_OBJECT(options->max_depth_w), "value_changed", - (GtkSignalFunc) tool_options_int_adjustment_update, + GTK_SIGNAL_FUNC (gimp_int_adjustment_update), &options->max_depth); /* threshold scale */ @@ -420,7 +421,7 @@ blend_options_new () _("Threshold:"), 1.0, 1.0, scale, FALSE); gtk_signal_connect (GTK_OBJECT(options->threshold_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->threshold); /* show the table */ diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c index 3a46140b960f4a4d549e7df0bff8c1067c4f0846..44e035a29efae23b20382db2bcc26a6cadc498c3 100644 --- a/app/tools/gimpbucketfilltool.c +++ b/app/tools/gimpbucketfilltool.c @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include "gdk/gdkkeysyms.h" + +#include + #include "appenv.h" #include "bucket_fill.h" #include "cursorutil.h" @@ -24,11 +26,11 @@ #include "fuzzy_select.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "interface.h" #include "paint_funcs.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" @@ -104,12 +106,6 @@ bucket_options_new (void) GtkWidget *label; GtkWidget *scale; GtkWidget *frame; - gchar* fill_mode_label[3] = { N_("FG Color Fill"), - N_("BG Color Fill"), - N_("Pattern Fill") }; - gint fill_mode_value[3] = { FG_BUCKET_FILL, - BG_BUCKET_FILL, - PATTERN_BUCKET_FILL }; /* the new bucket fill tool options structure */ options = (BucketOptions *) g_malloc (sizeof (BucketOptions)); @@ -139,7 +135,7 @@ bucket_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->threshold_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->threshold); gtk_widget_show (scale); @@ -149,19 +145,29 @@ bucket_options_new (void) options->sample_merged_w = gtk_check_button_new_with_label (_("Sample Merged")); gtk_signal_connect (GTK_OBJECT (options->sample_merged_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->sample_merged); gtk_box_pack_start (GTK_BOX (vbox), options->sample_merged_w, FALSE, FALSE, 0); gtk_widget_show (options->sample_merged_w); /* fill type */ - frame = tool_options_radio_buttons_new (_("Fill Type"), - &options->fill_mode, - options->fill_mode_w, - fill_mode_label, - fill_mode_value, - 3); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->fill_mode_w[options->fill_mode_d]), TRUE); + frame = + gimp_radio_group_new2 (TRUE, _("Fill Type"), + gimp_radio_button_update, + &options->fill_mode, (gpointer) options->fill_mode, + + _("FG Color Fill"), + (gpointer) FG_BUCKET_FILL, + &options->fill_mode_w[0], + _("BG Color Fill"), + (gpointer) BG_BUCKET_FILL, + &options->fill_mode_w[1], + _("Pattern Fill"), + (gpointer) PATTERN_BUCKET_FILL, + &options->fill_mode_w[2], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/tools/gimpclonetool.c b/app/tools/gimpclonetool.c index 4e2c4b1246c66d4077ef492a0b179f67fda2a73d..10d23f90fa53ac6c2d6f874a08170c7025a8ad80 100644 --- a/app/tools/gimpclonetool.c +++ b/app/tools/gimpclonetool.c @@ -1,4 +1,4 @@ - /* The GIMP -- an image manipulation program +/* 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 @@ -15,13 +15,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include + #include "appenv.h" #include "drawable.h" #include "errors.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "interface.h" #include "paint_funcs.h" #include "paint_core.h" @@ -50,6 +54,7 @@ typedef enum } AlignType; typedef struct _CloneOptions CloneOptions; + struct _CloneOptions { PaintOptions paint_options; @@ -98,20 +103,6 @@ static void clone_line_pattern (GImage *, GimpDrawable *, GPattern *, /* functions */ -static void -clone_type_callback (GtkWidget *widget, - gpointer data) -{ - clone_options->type = (CloneType) data; -} - -static void -align_type_callback (GtkWidget *widget, - gpointer data) -{ - clone_options->aligned = (AlignType) data; -} - static void clone_options_reset (void) { @@ -127,31 +118,11 @@ static CloneOptions * clone_options_new (void) { CloneOptions *options; - GtkWidget *vbox; - GSList *group = NULL; - GtkWidget *radio_frame; - GtkWidget *radio_box; - GtkWidget *radio_button; - int i; - - static gchar *source_names[] = - { - N_("Image Source"), - N_("Pattern Source") - }; - static gint n_source_names = sizeof (source_names) / sizeof (source_names[0]); - - static gchar *align_names[] = - { - N_("Non Aligned"), - N_("Aligned"), - N_("Registered") - }; - static gint n_align_names = sizeof (align_names) / sizeof (align_names[0]); + GtkWidget *frame; /* the new clone tool options structure */ - options = (CloneOptions *) g_malloc (sizeof (CloneOptions)); + options = g_new (CloneOptions, 1); paint_options_init ((PaintOptions *) options, CLONE, clone_options_reset); @@ -161,56 +132,35 @@ clone_options_new (void) /* the main vbox */ vbox = ((ToolOptions *) options)->main_vbox; - /* the radio frame and box */ - radio_frame = gtk_frame_new (_("Source")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + frame = gimp_radio_group_new2 (TRUE, _("Source"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + _("Image Source"), (gpointer) IMAGE_CLONE, + &options->type_w[0], + _("Pattern Source"), (gpointer) PATTERN_CLONE, + &options->type_w[1], - /* the radio buttons */ - for (i = 0; i < n_source_names; i++) - { - radio_button = gtk_radio_button_new_with_label (group, - gettext(source_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) clone_type_callback, - (void *)((long) i)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_widget_show (radio_button); - - options->type_w[i] = radio_button; - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + NULL); - /* the radio frame and box */ - radio_frame = gtk_frame_new (_("Alignment")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + frame = gimp_radio_group_new2 (TRUE, _("Alignment"), + gimp_radio_button_update, + &options->aligned, (gpointer) options->aligned, - /* the radio buttons */ - group = NULL; - for (i = 0; i < n_align_names; i++) - { - radio_button = gtk_radio_button_new_with_label (group, - gettext(align_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) align_type_callback, - (void *)((long) i)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_widget_show (radio_button); - - options->aligned_w[i] = radio_button; - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + _("Non Aligned"), (gpointer) ALIGN_NO, + &options->aligned_w[0], + _("Aligned"), (gpointer) ALIGN_YES, + &options->aligned_w[1], + _("Registered"), (gpointer) ALIGN_REGISTERED, + &options->aligned_w[2], + + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); return options; } @@ -227,27 +177,25 @@ clone_src_drawable_destroyed_cb (GimpDrawable *drawable, } static void -clone_set_src_drawable(GimpDrawable *drawable) +clone_set_src_drawable (GimpDrawable *drawable) { if (src_drawable_ == drawable) return; if (src_drawable_) - gtk_signal_disconnect_by_data(GTK_OBJECT (src_drawable_), &src_drawable_); + gtk_signal_disconnect_by_data (GTK_OBJECT (src_drawable_), &src_drawable_); src_drawable_ = drawable; if (drawable) - { - gtk_signal_connect (GTK_OBJECT (drawable), - "destroy", - GTK_SIGNAL_FUNC (clone_src_drawable_destroyed_cb), - &src_drawable_); - } + { + gtk_signal_connect (GTK_OBJECT (drawable), "destroy", + GTK_SIGNAL_FUNC (clone_src_drawable_destroyed_cb), + &src_drawable_); + } } - void * clone_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + gint state) { GDisplay * gdisp; GDisplay * src_gdisp; @@ -258,10 +206,10 @@ clone_paint_func (PaintCore *paint_core, switch (state) { - case PRETRACE_PAINT : + case PRETRACE_PAINT: draw_core_pause (paint_core->core, active_tool); break; - case MOTION_PAINT : + case MOTION_PAINT: x1 = paint_core->curx; y1 = paint_core->cury; x2 = paint_core->lastx; @@ -302,7 +250,7 @@ clone_paint_func (PaintCore *paint_core, break; - case INIT_PAINT : + case INIT_PAINT: if (paint_core->state & GDK_CONTROL_MASK) { the_src_gdisp = gdisp; @@ -312,27 +260,27 @@ clone_paint_func (PaintCore *paint_core, first = TRUE; } else if (clone_options->aligned == ALIGN_NO) - { - first = TRUE; - orig_src_x = src_x; - orig_src_y = src_y; - } + { + first = TRUE; + orig_src_x = src_x; + orig_src_y = src_y; + } if (clone_options->type == PATTERN_CLONE) if (! gimp_context_get_pattern (NULL)) g_message (_("No patterns available for this operation.")); break; - case FINISH_PAINT : + case FINISH_PAINT: draw_core_stop (paint_core->core, active_tool); if (clone_options->aligned == ALIGN_NO && !first) - { - src_x = orig_src_x; - src_y = orig_src_y; - } + { + src_x = orig_src_x; + src_y = orig_src_y; + } return NULL; break; - default : + default: break; } @@ -350,11 +298,12 @@ clone_paint_func (PaintCore *paint_core, src_gdisp->canvas->window, active_tool); else if (state == POSTTRACE_PAINT) - { - /* Find the target cursor's location onscreen */ - gdisplay_transform_coords (src_gdisp, src_x, src_y, &trans_tx, &trans_ty, 1); - draw_core_resume (paint_core->core, active_tool); - } + { + /* Find the target cursor's location onscreen */ + gdisplay_transform_coords (src_gdisp, src_x, src_y, + &trans_tx, &trans_ty, 1); + draw_core_resume (paint_core->core, active_tool); + } return NULL; } @@ -393,19 +342,18 @@ clone_cursor_update (Tool *tool, } if (clone_options->type == IMAGE_CLONE) - { - if (mevent->state & GDK_CONTROL_MASK) - ctype = GDK_CROSSHAIR; - else if (!src_drawable_) - ctype = GIMP_BAD_CURSOR; - } + { + if (mevent->state & GDK_CONTROL_MASK) + ctype = GDK_CROSSHAIR; + else if (!src_drawable_) + ctype = GIMP_BAD_CURSOR; + } gdisplay_install_tool_cursor (gdisp, ctype); } - Tool * -tools_new_clone () +tools_new_clone (void) { Tool * tool; PaintCore * private; diff --git a/app/tools/gimpconvolvetool.c b/app/tools/gimpconvolvetool.c index fdab91ae78c960b8833d5f01937286bcb740b75a..56c6bfd343920c03fbe6a35e30ba3f74c1b866f5 100644 --- a/app/tools/gimpconvolvetool.c +++ b/app/tools/gimpconvolvetool.c @@ -16,18 +16,19 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include -#include "gdk/gdkkeysyms.h" + +#include + #include "appenv.h" #include "drawable.h" #include "errors.h" #include "convolve.h" #include "gdisplay.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimage.h" @@ -46,6 +47,7 @@ /* the convolve structures */ typedef struct _ConvolveOptions ConvolveOptions; + struct _ConvolveOptions { PaintOptions paint_options; @@ -54,8 +56,8 @@ struct _ConvolveOptions ConvolveType type_d; GtkWidget *type_w[2]; - double rate; - double rate_d; + gdouble rate; + gdouble rate_d; GtkObject *rate_w; }; @@ -64,14 +66,14 @@ struct _ConvolveOptions static ConvolveOptions * convolve_options = NULL; /* local variables */ -static int matrix [25]; -static int matrix_size; -static int matrix_divisor; +static gint matrix [25]; +static gint matrix_size; +static gint matrix_divisor; static ConvolveType non_gui_type; -static double non_gui_rate; +static gdouble non_gui_rate; -static float custom_matrix [25] = +static gfloat custom_matrix [25] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -80,7 +82,7 @@ static float custom_matrix [25] = 0, 0, 0, 0, 0, }; -static float blur_matrix [25] = +static gfloat blur_matrix [25] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, @@ -89,7 +91,7 @@ static float blur_matrix [25] = 0, 0 ,0, 0, 0, }; -static float sharpen_matrix [25] = +static gfloat sharpen_matrix [25] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, @@ -133,11 +135,9 @@ convolve_options_new (void) GtkWidget *label; GtkWidget *scale; GtkWidget *frame; - gchar* type_label[2] = { N_("Blur"), N_("Sharpen") }; - gint type_value[2] = { BLUR_CONVOLVE, SHARPEN_CONVOLVE }; /* the new convolve tool options structure */ - options = (ConvolveOptions *) g_malloc (sizeof (ConvolveOptions)); + options = g_new (ConvolveOptions, 1); paint_options_init ((PaintOptions *) options, CONVOLVE, convolve_options_reset); @@ -163,18 +163,22 @@ convolve_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->rate); gtk_widget_show (scale); gtk_widget_show (hbox); - frame = tool_options_radio_buttons_new (_("Convolve Type"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); + frame = gimp_radio_group_new2 (TRUE, _("Convolve Type"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Blur"), (gpointer) BLUR_CONVOLVE, + &options->type_w[0], + _("Sharpen"), (gpointer) SHARPEN_CONVOLVE, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c index 349e03cb1abf2fa8423bf4cd0771eb4a43a8876f..22c763e68541a9d411753284aeaa3ab7e18437c7 100644 --- a/app/tools/gimpcroptool.c +++ b/app/tools/gimpcroptool.c @@ -17,7 +17,8 @@ */ #include -#include "gdk/gdkkeysyms.h" +#include + #include "appenv.h" #include "crop.h" #include "cursorutil.h" @@ -29,7 +30,6 @@ #include "gimphelp.h" #include "gimpui.h" #include "info_dialog.h" -#include "tool_options_ui.h" #include "undo.h" #include "libgimp/gimpsizeentry.h" @@ -50,29 +50,31 @@ /* the crop structures */ typedef struct _Crop Crop; + struct _Crop { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - int startx; /* starting x coord */ - int starty; /* starting y coord */ + gint startx; /* starting x coord */ + gint starty; /* starting y coord */ - int lastx; /* previous x coord */ - int lasty; /* previous y coord */ + gint lastx; /* previous x coord */ + gint lasty; /* previous y coord */ - int x1, y1; /* upper left hand coordinate */ - int x2, y2; /* lower right hand coords */ + gint x1, y1; /* upper left hand coordinate */ + gint x2, y2; /* lower right hand coords */ - int srw, srh; /* width and height of corners */ + gint srw, srh; /* width and height of corners */ - int tx1, ty1; /* transformed coords */ - int tx2, ty2; /* */ + gint tx1, ty1; /* transformed coords */ + gint tx2, ty2; /* */ - int function; /* moving or resizing */ - guint context_id; /* for the statusbar */ + gint function; /* moving or resizing */ + guint context_id; /* for the statusbar */ }; typedef struct _CropOptions CropOptions; + struct _CropOptions { ToolOptions tool_options; @@ -168,11 +170,9 @@ crop_options_new (void) CropOptions *options; GtkWidget *vbox; GtkWidget *frame; - gchar* type_label[2] = { N_("Crop"), N_("Resize") }; - gint type_value[2] = { CROP_CROP, RESIZE_CROP }; /* the new crop tool options structure */ - options = (CropOptions *) g_malloc (sizeof (CropOptions)); + options = g_new (CropOptions, 1); tool_options_init ((ToolOptions *) options, _("Crop & Resize Options"), crop_options_reset); @@ -189,7 +189,7 @@ crop_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), options->layer_only_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->layer_only_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->layer_only); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->layer_only_w), options->layer_only_d); @@ -200,20 +200,24 @@ crop_options_new (void) gtk_box_pack_start (GTK_BOX (vbox), options->allow_enlarge_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->allow_enlarge_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->allow_enlarge); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_enlarge_w), options->allow_enlarge_d); gtk_widget_show (options->allow_enlarge_w); /* tool toggle */ - frame = tool_options_radio_buttons_new (_("Tool Toggle"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); + frame = gimp_radio_group_new2 (TRUE, _("Tool Toggle"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Crop"), (gpointer) CROP_CROP, + &options->type_w[0], + _("Resize"), (gpointer) RESIZE_CROP, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/tools/gimpdodgeburntool.c b/app/tools/gimpdodgeburntool.c index 8050b5fb9bf6bac64d176b81560da7a35a368a58..53fc443de24f4e207cb67f455426292054437f20 100644 --- a/app/tools/gimpdodgeburntool.c +++ b/app/tools/gimpdodgeburntool.c @@ -20,7 +20,7 @@ #include #include -#include "gdk/gdkkeysyms.h" +#include #include "appenv.h" #include "drawable.h" @@ -28,11 +28,11 @@ #include "dodgeburn.h" #include "gdisplay.h" #include "gimplut.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimage.h" @@ -42,6 +42,7 @@ /* the dodgeburn structures */ typedef struct _DodgeBurnOptions DodgeBurnOptions; + struct _DodgeBurnOptions { PaintOptions paint_options; @@ -54,8 +55,8 @@ struct _DodgeBurnOptions DodgeBurnMode mode_d; GtkWidget *mode_w[3]; - double exposure; - double exposure_d; + gdouble exposure; + gdouble exposure_d; GtkObject *exposure_w; GimpLut *lut; @@ -120,19 +121,8 @@ dodgeburn_options_new (void) GtkWidget *scale; GtkWidget *frame; - gchar* type_label[2] = { N_("Dodge"), N_("Burn") }; - gint type_value[2] = { DODGE, BURN }; - - gchar* mode_label[3] = { N_("Highlights"), - N_("Midtones"), - N_("Shadows") }; - - gint mode_value[3] = { DODGEBURN_HIGHLIGHTS, - DODGEBURN_MIDTONES, - DODGEBURN_SHADOWS }; - /* the new dodgeburn tool options structure */ - options = (DodgeBurnOptions *) g_malloc (sizeof (DodgeBurnOptions)); + options = g_new (DodgeBurnOptions, 1); paint_options_init ((PaintOptions *) options, DODGEBURN, dodgeburn_options_reset); @@ -161,31 +151,42 @@ dodgeburn_options_new (void) gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->exposure_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->exposure); gtk_widget_show (scale); gtk_widget_show (hbox); /* the type (dodge or burn) */ - frame = tool_options_radio_buttons_new (_("Type"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); + frame = gimp_radio_group_new2 (TRUE, _("Type"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Dodge"), (gpointer) DODGE, + &options->type_w[0], + _("Burn"), (gpointer) BURN, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* mode (highlights, midtones, or shadows) */ - frame = tool_options_radio_buttons_new (_("Mode"), - &options->mode, - options->mode_w, - mode_label, - mode_value, - 3); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->mode_w[options->mode_d]), TRUE); + frame = + gimp_radio_group_new2 (TRUE, _("Mode"), + gimp_radio_button_update, + &options->mode, (gpointer) options->mode, + + _("Highlights"), (gpointer) DODGEBURN_HIGHLIGHTS, + &options->mode_w[0], + _("Midtones"), (gpointer) DODGEBURN_MIDTONES, + &options->mode_w[1], + _("Shadows"), (gpointer) DODGEBURN_SHADOWS, + &options->mode_w[2], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/tools/gimperasertool.c b/app/tools/gimperasertool.c index cbcf52dcc86a88dc66e58d3627e268609c92fa73..a7fbb6b900c0d50ef1f001a97d4e2c5874794e54 100644 --- a/app/tools/gimperasertool.c +++ b/app/tools/gimperasertool.c @@ -17,19 +17,20 @@ */ #include -#include "gdk/gdkkeysyms.h" +#include + #include "appenv.h" #include "cursorutil.h" #include "drawable.h" #include "errors.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "eraser.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpintl.h" @@ -93,7 +94,7 @@ eraser_options_new (void) GtkWidget *vbox; /* the new eraser tool options structure */ - options = (EraserOptions *) g_malloc (sizeof (EraserOptions)); + options = g_new (EraserOptions, 1); paint_options_init ((PaintOptions *) options, ERASER, eraser_options_reset); @@ -107,7 +108,7 @@ eraser_options_new (void) options->hard_w = gtk_check_button_new_with_label (_("Hard Edge")); gtk_box_pack_start (GTK_BOX (vbox), options->hard_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->hard_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->hard); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w), options->hard_d); @@ -117,7 +118,7 @@ eraser_options_new (void) options->anti_erase_w = gtk_check_button_new_with_label (_("Anti Erase")); gtk_box_pack_start (GTK_BOX (vbox), options->anti_erase_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->anti_erase_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->anti_erase); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w), options->anti_erase_d); diff --git a/app/tools/gimpfliptool.c b/app/tools/gimpfliptool.c index ec73f71fc461a278d39b5143c7df54079101e13a..9ed4dc02e260596e1d292ce70ffd55f1bc59972f 100644 --- a/app/tools/gimpfliptool.c +++ b/app/tools/gimpfliptool.c @@ -16,15 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -#include "gdk/gdkkeysyms.h" + +#include + #include "appenv.h" #include "cursorutil.h" #include "drawable.h" #include "flip_tool.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "temp_buf.h" -#include "tool_options_ui.h" #include "paths_dialogP.h" #include "undo.h" @@ -72,8 +74,6 @@ flip_options_new (void) GtkWidget *vbox; GtkWidget *frame; - gchar* type_label[2] = { N_("Horizontal"), N_("Vertical") }; - gint type_value[2] = { ORIENTATION_HORIZONTAL, ORIENTATION_VERTICAL }; /* the new flip tool options structure */ options = g_new (FlipOptions, 1); @@ -86,13 +86,18 @@ flip_options_new (void) vbox = options->tool_options.main_vbox; /* tool toggle */ - frame = tool_options_radio_buttons_new (_("Tool Toggle"), - &options->type, - options->type_w, - type_label, - type_value, - 2); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->type_w[options->type_d - 1]), TRUE); + frame = + gimp_radio_group_new2 (TRUE, _("Tool Toggle"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, + + _("Horizontal"), (gpointer) ORIENTATION_HORIZONTAL, + &options->type_w[0], + _("Vertical"), (gpointer) ORIENTATION_VERTICAL, + &options->type_w[1], + + NULL); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); diff --git a/app/tools/gimpinktool.c b/app/tools/gimpinktool.c index c9c34b273117cbc0a22877fb64ec469eb938a317..aca0f894b56ea1083bba31bb392e5c4a60c395c4 100644 --- a/app/tools/gimpinktool.c +++ b/app/tools/gimpinktool.c @@ -25,9 +25,9 @@ #include "draw_core.h" #include "gimage_mask.h" #include "gimprc.h" +#include "gimpui.h" #include "ink.h" #include "paint_options.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" #include "blob.h" @@ -45,33 +45,35 @@ /* the Ink structures */ -typedef Blob *(*BlobFunc) (double, double, double, double, double, double); +typedef Blob *(*BlobFunc) (gdouble, gdouble, gdouble, gdouble, gdouble, gdouble); typedef struct _InkTool InkTool; + struct _InkTool { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - Blob * last_blob; /* blob for last cursor position */ + Blob *last_blob; /* blob for last cursor position */ - int x1, y1; /* image space coordinate */ - int x2, y2; /* image space coords */ + gint x1, y1; /* image space coordinate */ + gint x2, y2; /* image space coords */ /* circular distance history buffer */ - gdouble dt_buffer[DIST_SMOOTHER_BUFFER]; - gint dt_index; + gdouble dt_buffer[DIST_SMOOTHER_BUFFER]; + gint dt_index; /* circular timing history buffer */ - guint32 ts_buffer[TIME_SMOOTHER_BUFFER]; - gint ts_index; + guint32 ts_buffer[TIME_SMOOTHER_BUFFER]; + gint ts_index; - gdouble last_time; /* previous time of a motion event */ - gdouble lastx, lasty; /* previous position of a motion event */ + gdouble last_time; /* previous time of a motion event */ + gdouble lastx, lasty; /* previous position of a motion event */ - gboolean init_velocity; + gboolean init_velocity; }; typedef struct _BrushWidget BrushWidget; + struct _BrushWidget { GtkWidget *widget; @@ -79,44 +81,45 @@ struct _BrushWidget }; typedef struct _InkOptions InkOptions; + struct _InkOptions { PaintOptions paint_options; - double size; - double size_d; + gdouble size; + gdouble size_d; GtkObject *size_w; - double sensitivity; - double sensitivity_d; + gdouble sensitivity; + gdouble sensitivity_d; GtkObject *sensitivity_w; - double vel_sensitivity; - double vel_sensitivity_d; + gdouble vel_sensitivity; + gdouble vel_sensitivity_d; GtkObject *vel_sensitivity_w; - double tilt_sensitivity; - double tilt_sensitivity_d; + gdouble tilt_sensitivity; + gdouble tilt_sensitivity_d; GtkObject *tilt_sensitivity_w; - double tilt_angle; - double tilt_angle_d; + gdouble tilt_angle; + gdouble tilt_angle_d; GtkObject *tilt_angle_w; BlobFunc function; BlobFunc function_d; GtkWidget *function_w[3]; /* 3 radio buttons */ - double aspect; - double aspect_d; - double angle; - double angle_d; + gdouble aspect; + gdouble aspect_d; + gdouble angle; + gdouble angle_d; BrushWidget *brush_w; }; /* the ink tool options */ -static InkOptions *ink_options = NULL; +static InkOptions * ink_options = NULL; /* local variables */ @@ -265,7 +268,7 @@ ink_options_new (void) GdkPixmap *pixmap; /* the new ink tool options structure */ - options = (InkOptions *) g_malloc (sizeof (InkOptions)); + options = g_new (InkOptions, 1); paint_options_init ((PaintOptions *) options, INK, ink_options_reset); @@ -303,7 +306,7 @@ ink_options_new (void) gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 0, 1); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->size_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->size); gtk_widget_show (slider); @@ -321,7 +324,7 @@ ink_options_new (void) gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 1, 2); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->sensitivity); gtk_widget_show (slider); @@ -350,7 +353,7 @@ ink_options_new (void) gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->tilt_sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->tilt_sensitivity); gtk_widget_show (slider); @@ -380,7 +383,7 @@ ink_options_new (void) gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->vel_sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->vel_sensitivity); gtk_widget_show (slider); @@ -410,7 +413,7 @@ ink_options_new (void) gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->tilt_angle_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->tilt_angle); /* Brush type radiobuttons */ diff --git a/app/tools/gimpmagnifytool.c b/app/tools/gimpmagnifytool.c index 14c27af762cf5162a7df6aee5b62bafa4cd658f4..f009a25ab441eb4a24b88ab27c9d99bb0df260db 100644 --- a/app/tools/gimpmagnifytool.c +++ b/app/tools/gimpmagnifytool.c @@ -16,14 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include + #include "appenv.h" #include "draw_core.h" #include "gdisplay.h" #include "gimprc.h" +#include "gimpui.h" #include "info_window.h" #include "magnify.h" #include "scale.h" -#include "tool_options_ui.h" #include "libgimp/gimpintl.h" @@ -34,23 +35,25 @@ /* the magnify structures */ typedef struct _Magnify Magnify; + struct _Magnify { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - int x, y; /* upper left hand coordinate */ - int w, h; /* width and height */ + gint x, y; /* upper left hand coordinate */ + gint w, h; /* width and height */ - int op; /* magnify operation */ + gint op; /* magnify operation */ }; typedef struct _MagnifyOptions MagnifyOptions; + struct _MagnifyOptions { ToolOptions tool_options; - /* int allow_resize_windows; (from gimprc) */ - int allow_resize_d; + /* gint allow_resize_windows; (from gimprc) */ + gint allow_resize_d; GtkWidget *allow_resize_w; }; @@ -90,7 +93,7 @@ magnify_options_new (void) GtkWidget *vbox; /* the new magnify tool options structure */ - options = (MagnifyOptions *) g_malloc (sizeof (MagnifyOptions)); + options = g_new (MagnifyOptions, 1); tool_options_init ((ToolOptions *) options, _("Magnify Options"), magnify_options_reset); @@ -103,7 +106,7 @@ magnify_options_new (void) options->allow_resize_w = gtk_check_button_new_with_label (_("Allow Window Resizing")); gtk_signal_connect (GTK_OBJECT (options->allow_resize_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &allow_resize_windows); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_resize_w), allow_resize_windows); @@ -117,9 +120,9 @@ magnify_options_new (void) /* magnify utility functions */ static void -zoom_in (int *src, - int *dest, - int scale) +zoom_in (gint *src, + gint *dest, + gint scale) { while (scale--) { @@ -133,9 +136,9 @@ zoom_in (int *src, static void -zoom_out (int *src, - int *dest, - int scale) +zoom_out (gint *src, + gint *dest, + gint scale) { while (scale--) { @@ -155,9 +158,9 @@ magnify_button_press (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr) { - GDisplay * gdisp; - Magnify * magnify; - int x, y; + GDisplay *gdisp; + Magnify *magnify; + gint x, y; gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; @@ -170,7 +173,9 @@ magnify_button_press (Tool *tool, magnify->h = 0; gdk_pointer_grab (gdisp->canvas->window, FALSE, - GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, + GDK_POINTER_MOTION_HINT_MASK | + GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); tool->state = ACTIVE; @@ -192,13 +197,13 @@ magnify_button_release (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr) { - Magnify * magnify; - GDisplay * gdisp; - int win_width, win_height; - int width, height; - int scalesrc, scaledest; - int scale; - int x1, y1, x2, y2, w, h; + Magnify *magnify; + GDisplay *gdisp; + gint win_width, win_height; + gint width, height; + gint scalesrc, scaledest; + gint scale; + gint x1, y1, x2, y2, w, h; gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; @@ -252,7 +257,6 @@ magnify_button_release (Tool *tool, /* resize the image */ resize_display (gdisp, allow_resize_windows, TRUE); - } } @@ -261,9 +265,9 @@ magnify_motion (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr) { - Magnify * magnify; - GDisplay * gdisp; - int x, y; + Magnify *magnify; + GDisplay *gdisp; + gint x, y; if (tool->state != ACTIVE) return; @@ -286,7 +290,7 @@ magnify_cursor_update (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr) { - GDisplay * gdisp; + GDisplay *gdisp; gdisp = (GDisplay *) gdisp_ptr; @@ -297,17 +301,17 @@ magnify_cursor_update (Tool *tool, void magnify_draw (Tool *tool) { - GDisplay * gdisp; - Magnify * magnify; - int x1, y1, x2, y2; + GDisplay *gdisp; + Magnify *magnify; + gint x1, y1, x2, y2; gdisp = (GDisplay *) tool->gdisp_ptr; magnify = (Magnify *) tool->private; - x1 = MINIMUM (magnify->x, magnify->x + magnify->w); - y1 = MINIMUM (magnify->y, magnify->y + magnify->h); - x2 = MAXIMUM (magnify->x, magnify->x + magnify->w); - y2 = MAXIMUM (magnify->y, magnify->y + magnify->h); + x1 = MIN (magnify->x, magnify->x + magnify->w); + y1 = MIN (magnify->y, magnify->y + magnify->h); + x2 = MAX (magnify->x, magnify->x + magnify->w); + y2 = MAX (magnify->y, magnify->y + magnify->h); gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0); gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0); @@ -322,7 +326,7 @@ magnify_control (Tool *tool, ToolAction action, gpointer gdisp_ptr) { - Magnify * magnify; + Magnify *magnify; magnify = (Magnify *) tool->private; @@ -349,8 +353,8 @@ magnify_control (Tool *tool, Tool * tools_new_magnify (void) { - Tool * tool; - Magnify * private; + Tool *tool; + Magnify *private; /* The tool options */ if (! magnify_options) @@ -384,7 +388,7 @@ tools_new_magnify (void) void tools_free_magnify (Tool *tool) { - Magnify * magnify; + Magnify *magnify; magnify = (Magnify *) tool->private; diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c index 2cee1723e45d7c43b6a8cd54a20edbea91d9ba99..a945985ac46c43e52d82932f2a63a5a7ceab9776 100644 --- a/app/tools/gimpmeasuretool.c +++ b/app/tools/gimpmeasuretool.c @@ -25,7 +25,6 @@ #include "gimpui.h" #include "info_dialog.h" #include "measure.h" -#include "tool_options_ui.h" #include "undo.h" #include "libgimp/gimpintl.h" @@ -49,21 +48,23 @@ typedef enum /* the measure structure */ typedef struct _MeasureTool MeasureTool; + struct _MeasureTool { DrawCore *core; /* draw core */ MeasureFunction function; /* what are we doing? */ - int point; /* what are we manipulating? */ - int num_points; /* how many points? */ - int x[3]; /* three x coordinates */ - int y[3]; /* three y coordinates */ - double angle1; /* first angle */ - double angle2; /* second angle */ + gint point; /* what are we manipulating? */ + gint num_points; /* how many points? */ + gint x[3]; /* three x coordinates */ + gint y[3]; /* three y coordinates */ + gdouble angle1; /* first angle */ + gdouble angle2; /* second angle */ guint context_id; /* for the statusbar */ }; /* the measure tool options */ typedef struct _MeasureOptions MeasureOptions; + struct _MeasureOptions { ToolOptions tool_options; @@ -128,7 +129,7 @@ measure_tool_options_new (void) options->use_info_window_d); gtk_box_pack_start (GTK_BOX (vbox), options->use_info_window_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->use_info_window_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->use_info_window); gtk_widget_show (options->use_info_window_w); @@ -181,7 +182,8 @@ measure_tool_button_press (Tool *tool, if (tool->state == ACTIVE && gdisp_ptr != tool->gdisp_ptr) { GDisplay *old_gdisp = tool->gdisp_ptr; - gtk_statusbar_pop (GTK_STATUSBAR (old_gdisp->statusbar), measure_tool->context_id); + gtk_statusbar_pop (GTK_STATUSBAR (old_gdisp->statusbar), + measure_tool->context_id); gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), measure_tool->context_id, ("")); } @@ -196,15 +198,15 @@ measure_tool_button_press (Tool *tool, { gdisplay_transform_coords (gdisp, measure_tool->x[i], measure_tool->y[i], &x[i], &y[i], FALSE); - if (bevent->x == BOUNDS (bevent->x, x[i] - TARGET, x[i] + TARGET) && - bevent->y == BOUNDS (bevent->y, y[i] - TARGET, y[i] + TARGET)) + if (bevent->x == CLAMP (bevent->x, x[i] - TARGET, x[i] + TARGET) && + bevent->y == CLAMP (bevent->y, y[i] - TARGET, y[i] + TARGET)) { if (bevent->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)) { Guide *guide; if (bevent->state & GDK_CONTROL_MASK && - (measure_tool->y[i] == BOUNDS (measure_tool->y[i], 0, gdisp->gimage->height))) + (measure_tool->y[i] == CLAMP (measure_tool->y[i], 0, gdisp->gimage->height))) { guide = gimp_image_add_hguide (gdisp->gimage); undo_push_guide (gdisp->gimage, guide); @@ -212,7 +214,7 @@ measure_tool_button_press (Tool *tool, gdisplays_expose_guide (gdisp->gimage, guide); } if (bevent->state & GDK_MOD1_MASK && - (measure_tool->x[i] == BOUNDS (measure_tool->x[i], 0, gdisp->gimage->width))) + (measure_tool->x[i] == CLAMP (measure_tool->x[i], 0, gdisp->gimage->width))) { guide = gimp_image_add_vguide (gdisp->gimage); undo_push_guide (gdisp->gimage, guide); @@ -258,7 +260,8 @@ measure_tool_button_press (Tool *tool, /* create the info window if necessary */ if (!measure_tool_info && - (measure_tool_options->use_info_window || !GTK_WIDGET_VISIBLE (gdisp->statusarea))) + (measure_tool_options->use_info_window || + !GTK_WIDGET_VISIBLE (gdisp->statusarea))) { measure_tool_info = info_dialog_new (_("Measure Tool"), tools_help_func, NULL); @@ -274,11 +277,15 @@ measure_tool_button_press (Tool *tool, } gdk_pointer_grab (gdisp->canvas->window, FALSE, - GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, + GDK_POINTER_MOTION_HINT_MASK | + GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); tool->state = ACTIVE; - /* set the pointer to the crosshair, so one actually sees the cursor position */ + /* set the pointer to the crosshair, + * so one actually sees the cursor position + */ gdisplay_install_tool_cursor (gdisp, GDK_TCROSS); } diff --git a/app/tools/gimppenciltool.c b/app/tools/gimppenciltool.c index 61cdab425557f76d0e08b0e099cee7eb834e3512..c9b431788fae14cb9f1c1d7d4ee6e418332170e7 100644 --- a/app/tools/gimppenciltool.c +++ b/app/tools/gimppenciltool.c @@ -29,13 +29,13 @@ #include "paintbrush.h" #include "pencil.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpintl.h" /* the pencil tool options */ typedef struct _PencilOptions PencilOptions; + struct _PencilOptions { PaintOptions paint_options; @@ -61,19 +61,19 @@ pencil_paint_func (PaintCore *paint_core, { switch (state) { - case INIT_PAINT : + case INIT_PAINT: break; - case MOTION_PAINT : + case MOTION_PAINT: pencil_motion (paint_core, drawable, pencil_options->paint_options.pressure_options, pencil_options->paint_options.incremental); break; - case FINISH_PAINT : + case FINISH_PAINT: break; - default : + default: break; } @@ -85,10 +85,11 @@ pencil_options_new (void) { PencilOptions *options; - options = (PencilOptions *) g_malloc (sizeof (PencilOptions)); + options = g_new (PencilOptions, 1); paint_options_init ((PaintOptions *) options, PENCIL, pencil_options_reset); + return options; } diff --git a/app/tools/gimpsmudgetool.c b/app/tools/gimpsmudgetool.c index d8445da818eb627773536e8449fade90bfca723e..6c2154028c383b6d8dd5697bf64aa75a4ac74a3b 100644 --- a/app/tools/gimpsmudgetool.c +++ b/app/tools/gimpsmudgetool.c @@ -28,11 +28,11 @@ #include "smudge.h" #include "gdisplay.h" #include "gimplut.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimage.h" @@ -47,37 +47,41 @@ /* the smudge structures */ typedef struct _SmudgeOptions SmudgeOptions; + struct _SmudgeOptions { PaintOptions paint_options; - double rate; - double rate_d; + gdouble rate; + gdouble rate_d; GtkObject *rate_w; }; -static PixelRegion accumPR; -static unsigned char *accum_data; +static PixelRegion accumPR; +static guchar *accum_data; /* the smudge tool options */ -static SmudgeOptions *smudge_options = NULL; +static SmudgeOptions * smudge_options = NULL; /* local variables */ -static gdouble non_gui_rate; +static gdouble non_gui_rate; /* function prototypes */ -static void smudge_motion (PaintCore *, PaintPressureOptions *, - gdouble, GimpDrawable *); -static void smudge_init (PaintCore *, GimpDrawable *); -static void smudge_finish (PaintCore *, GimpDrawable *); - -static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, - gint * x, gint* y, - gint* w, gint *h); -static void smudge_allocate_accum_buffer (gint w, gint h, - gint bytes, guchar *do_fill); - +static void smudge_motion (PaintCore *, PaintPressureOptions *, + gdouble, GimpDrawable *); +static void smudge_init (PaintCore *, GimpDrawable *); +static void smudge_finish (PaintCore *, GimpDrawable *); + +static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, + gint *x, + gint *y, + gint *w, + gint *h); +static void smudge_allocate_accum_buffer (gint w, + gint h, + gint bytes, + guchar *do_fill); static void smudge_options_reset (void) @@ -100,7 +104,7 @@ smudge_options_new (void) GtkWidget *scale; /* the new smudge tool options structure */ - options = (SmudgeOptions *) g_malloc (sizeof (SmudgeOptions)); + options = g_new (SmudgeOptions, 1); paint_options_init ((PaintOptions *) options, SMUDGE, smudge_options_reset); @@ -126,7 +130,7 @@ smudge_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->rate); gtk_widget_show (scale); gtk_widget_show (hbox); @@ -224,7 +228,9 @@ smudge_init (PaintCore *paint_core, that may enter into the blend */ if (was_clipped) - do_fill = gimp_drawable_get_color_at (drawable, (gint)paint_core->curx, (gint) paint_core->cury); + do_fill = gimp_drawable_get_color_at (drawable, + (gint)paint_core->curx, + (gint) paint_core->cury); smudge_allocate_accum_buffer (w, h, drawable_bytes(drawable), do_fill); @@ -279,7 +285,7 @@ smudge_allocate_accum_buffer (gint w, } Tool * -tools_new_smudge () +tools_new_smudge (void) { Tool * tool; PaintCore * private; @@ -341,7 +347,7 @@ smudge_motion (PaintCore *paint_core, the drawable*/ pixel_region_init (&srcPR, drawable_data (drawable), - area->x, area->y, area->width, area->height, FALSE); + area->x, area->y, area->width, area->height, FALSE); /* Enable pressure sensitive rate */ if (pressure_options->rate) @@ -356,9 +362,8 @@ smudge_motion (PaintCore *paint_core, tempPR.y = area->y - y; tempPR.w = area->width; tempPR.h = area->height; - tempPR.data = accum_data - + tempPR.rowstride * tempPR.y - + tempPR.x * tempPR.bytes; + tempPR.data = accum_data + + tempPR.rowstride * tempPR.y + tempPR.x * tempPR.bytes; /* The dest will be the paint area we got above (= canvas_buf) */ @@ -439,7 +444,7 @@ smudge_non_gui (GimpDrawable *drawable, int num_strokes, double *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) diff --git a/app/tools/gimpsourcetool.c b/app/tools/gimpsourcetool.c index 4e2c4b1246c66d4077ef492a0b179f67fda2a73d..10d23f90fa53ac6c2d6f874a08170c7025a8ad80 100644 --- a/app/tools/gimpsourcetool.c +++ b/app/tools/gimpsourcetool.c @@ -1,4 +1,4 @@ - /* The GIMP -- an image manipulation program +/* 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 @@ -15,13 +15,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include + #include "appenv.h" #include "drawable.h" #include "errors.h" #include "gdisplay.h" #include "gimage_mask.h" +#include "gimpui.h" #include "interface.h" #include "paint_funcs.h" #include "paint_core.h" @@ -50,6 +54,7 @@ typedef enum } AlignType; typedef struct _CloneOptions CloneOptions; + struct _CloneOptions { PaintOptions paint_options; @@ -98,20 +103,6 @@ static void clone_line_pattern (GImage *, GimpDrawable *, GPattern *, /* functions */ -static void -clone_type_callback (GtkWidget *widget, - gpointer data) -{ - clone_options->type = (CloneType) data; -} - -static void -align_type_callback (GtkWidget *widget, - gpointer data) -{ - clone_options->aligned = (AlignType) data; -} - static void clone_options_reset (void) { @@ -127,31 +118,11 @@ static CloneOptions * clone_options_new (void) { CloneOptions *options; - GtkWidget *vbox; - GSList *group = NULL; - GtkWidget *radio_frame; - GtkWidget *radio_box; - GtkWidget *radio_button; - int i; - - static gchar *source_names[] = - { - N_("Image Source"), - N_("Pattern Source") - }; - static gint n_source_names = sizeof (source_names) / sizeof (source_names[0]); - - static gchar *align_names[] = - { - N_("Non Aligned"), - N_("Aligned"), - N_("Registered") - }; - static gint n_align_names = sizeof (align_names) / sizeof (align_names[0]); + GtkWidget *frame; /* the new clone tool options structure */ - options = (CloneOptions *) g_malloc (sizeof (CloneOptions)); + options = g_new (CloneOptions, 1); paint_options_init ((PaintOptions *) options, CLONE, clone_options_reset); @@ -161,56 +132,35 @@ clone_options_new (void) /* the main vbox */ vbox = ((ToolOptions *) options)->main_vbox; - /* the radio frame and box */ - radio_frame = gtk_frame_new (_("Source")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + frame = gimp_radio_group_new2 (TRUE, _("Source"), + gimp_radio_button_update, + &options->type, (gpointer) options->type, - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + _("Image Source"), (gpointer) IMAGE_CLONE, + &options->type_w[0], + _("Pattern Source"), (gpointer) PATTERN_CLONE, + &options->type_w[1], - /* the radio buttons */ - for (i = 0; i < n_source_names; i++) - { - radio_button = gtk_radio_button_new_with_label (group, - gettext(source_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) clone_type_callback, - (void *)((long) i)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_widget_show (radio_button); - - options->type_w[i] = radio_button; - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + NULL); - /* the radio frame and box */ - radio_frame = gtk_frame_new (_("Alignment")); - gtk_box_pack_start (GTK_BOX (vbox), radio_frame, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - radio_box = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2); - gtk_container_add (GTK_CONTAINER (radio_frame), radio_box); + frame = gimp_radio_group_new2 (TRUE, _("Alignment"), + gimp_radio_button_update, + &options->aligned, (gpointer) options->aligned, - /* the radio buttons */ - group = NULL; - for (i = 0; i < n_align_names; i++) - { - radio_button = gtk_radio_button_new_with_label (group, - gettext(align_names[i])); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button)); - gtk_signal_connect (GTK_OBJECT (radio_button), "toggled", - (GtkSignalFunc) align_type_callback, - (void *)((long) i)); - gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0); - gtk_widget_show (radio_button); - - options->aligned_w[i] = radio_button; - } - gtk_widget_show (radio_box); - gtk_widget_show (radio_frame); + _("Non Aligned"), (gpointer) ALIGN_NO, + &options->aligned_w[0], + _("Aligned"), (gpointer) ALIGN_YES, + &options->aligned_w[1], + _("Registered"), (gpointer) ALIGN_REGISTERED, + &options->aligned_w[2], + + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); return options; } @@ -227,27 +177,25 @@ clone_src_drawable_destroyed_cb (GimpDrawable *drawable, } static void -clone_set_src_drawable(GimpDrawable *drawable) +clone_set_src_drawable (GimpDrawable *drawable) { if (src_drawable_ == drawable) return; if (src_drawable_) - gtk_signal_disconnect_by_data(GTK_OBJECT (src_drawable_), &src_drawable_); + gtk_signal_disconnect_by_data (GTK_OBJECT (src_drawable_), &src_drawable_); src_drawable_ = drawable; if (drawable) - { - gtk_signal_connect (GTK_OBJECT (drawable), - "destroy", - GTK_SIGNAL_FUNC (clone_src_drawable_destroyed_cb), - &src_drawable_); - } + { + gtk_signal_connect (GTK_OBJECT (drawable), "destroy", + GTK_SIGNAL_FUNC (clone_src_drawable_destroyed_cb), + &src_drawable_); + } } - void * clone_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + gint state) { GDisplay * gdisp; GDisplay * src_gdisp; @@ -258,10 +206,10 @@ clone_paint_func (PaintCore *paint_core, switch (state) { - case PRETRACE_PAINT : + case PRETRACE_PAINT: draw_core_pause (paint_core->core, active_tool); break; - case MOTION_PAINT : + case MOTION_PAINT: x1 = paint_core->curx; y1 = paint_core->cury; x2 = paint_core->lastx; @@ -302,7 +250,7 @@ clone_paint_func (PaintCore *paint_core, break; - case INIT_PAINT : + case INIT_PAINT: if (paint_core->state & GDK_CONTROL_MASK) { the_src_gdisp = gdisp; @@ -312,27 +260,27 @@ clone_paint_func (PaintCore *paint_core, first = TRUE; } else if (clone_options->aligned == ALIGN_NO) - { - first = TRUE; - orig_src_x = src_x; - orig_src_y = src_y; - } + { + first = TRUE; + orig_src_x = src_x; + orig_src_y = src_y; + } if (clone_options->type == PATTERN_CLONE) if (! gimp_context_get_pattern (NULL)) g_message (_("No patterns available for this operation.")); break; - case FINISH_PAINT : + case FINISH_PAINT: draw_core_stop (paint_core->core, active_tool); if (clone_options->aligned == ALIGN_NO && !first) - { - src_x = orig_src_x; - src_y = orig_src_y; - } + { + src_x = orig_src_x; + src_y = orig_src_y; + } return NULL; break; - default : + default: break; } @@ -350,11 +298,12 @@ clone_paint_func (PaintCore *paint_core, src_gdisp->canvas->window, active_tool); else if (state == POSTTRACE_PAINT) - { - /* Find the target cursor's location onscreen */ - gdisplay_transform_coords (src_gdisp, src_x, src_y, &trans_tx, &trans_ty, 1); - draw_core_resume (paint_core->core, active_tool); - } + { + /* Find the target cursor's location onscreen */ + gdisplay_transform_coords (src_gdisp, src_x, src_y, + &trans_tx, &trans_ty, 1); + draw_core_resume (paint_core->core, active_tool); + } return NULL; } @@ -393,19 +342,18 @@ clone_cursor_update (Tool *tool, } if (clone_options->type == IMAGE_CLONE) - { - if (mevent->state & GDK_CONTROL_MASK) - ctype = GDK_CROSSHAIR; - else if (!src_drawable_) - ctype = GIMP_BAD_CURSOR; - } + { + if (mevent->state & GDK_CONTROL_MASK) + ctype = GDK_CROSSHAIR; + else if (!src_drawable_) + ctype = GIMP_BAD_CURSOR; + } gdisplay_install_tool_cursor (gdisp, ctype); } - Tool * -tools_new_clone () +tools_new_clone (void) { Tool * tool; PaintCore * private; diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c index b2b1716f2b500ffe89e752a1728b0e16c3107798..fc04848a08c25c0099ded0c53ff7c7456cd70f25 100644 --- a/app/tools/gimptexttool.c +++ b/app/tools/gimptexttool.c @@ -29,11 +29,11 @@ #include "errors.h" #include "floating_sel.h" #include "gimage_mask.h" +#include "gimpui.h" #include "global_edit.h" #include "procedural_db.h" #include "selection.h" #include "text_tool.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" @@ -141,7 +141,7 @@ text_options_new (void) GtkWidget *sep; /* the new text tool options structure */ - options = (TextOptions *) g_malloc (sizeof (TextOptions)); + options = g_new (TextOptions, 1); tool_options_init ((ToolOptions *) options, _("Text Tool Options"), text_options_reset); @@ -156,7 +156,7 @@ text_options_new (void) options->antialias_w = gtk_check_button_new_with_label (_("Antialiasing")); gtk_signal_connect (GTK_OBJECT (options->antialias_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->antialias); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w), options->antialias_d); @@ -175,7 +175,7 @@ text_options_new (void) options->border_w = gtk_adjustment_new (options->border_d, 0.0, 32767.0, 1.0, 50.0, 0.0); gtk_signal_connect (GTK_OBJECT (options->border_w), "value_changed", - (GtkSignalFunc) tool_options_int_adjustment_update, + GTK_SIGNAL_FUNC (gimp_int_adjustment_update), &options->border); spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (options->border_w), 1.0, 0.0); @@ -196,7 +196,7 @@ text_options_new (void) options->use_dyntext_w = gtk_check_button_new_with_label (_("Use Dynamic Text")); gtk_signal_connect (GTK_OBJECT (options->use_dyntext_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->use_dyntext); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_dyntext_w), options->use_dyntext_d); diff --git a/app/tools/ink.c b/app/tools/ink.c index c9c34b273117cbc0a22877fb64ec469eb938a317..aca0f894b56ea1083bba31bb392e5c4a60c395c4 100644 --- a/app/tools/ink.c +++ b/app/tools/ink.c @@ -25,9 +25,9 @@ #include "draw_core.h" #include "gimage_mask.h" #include "gimprc.h" +#include "gimpui.h" #include "ink.h" #include "paint_options.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" #include "blob.h" @@ -45,33 +45,35 @@ /* the Ink structures */ -typedef Blob *(*BlobFunc) (double, double, double, double, double, double); +typedef Blob *(*BlobFunc) (gdouble, gdouble, gdouble, gdouble, gdouble, gdouble); typedef struct _InkTool InkTool; + struct _InkTool { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - Blob * last_blob; /* blob for last cursor position */ + Blob *last_blob; /* blob for last cursor position */ - int x1, y1; /* image space coordinate */ - int x2, y2; /* image space coords */ + gint x1, y1; /* image space coordinate */ + gint x2, y2; /* image space coords */ /* circular distance history buffer */ - gdouble dt_buffer[DIST_SMOOTHER_BUFFER]; - gint dt_index; + gdouble dt_buffer[DIST_SMOOTHER_BUFFER]; + gint dt_index; /* circular timing history buffer */ - guint32 ts_buffer[TIME_SMOOTHER_BUFFER]; - gint ts_index; + guint32 ts_buffer[TIME_SMOOTHER_BUFFER]; + gint ts_index; - gdouble last_time; /* previous time of a motion event */ - gdouble lastx, lasty; /* previous position of a motion event */ + gdouble last_time; /* previous time of a motion event */ + gdouble lastx, lasty; /* previous position of a motion event */ - gboolean init_velocity; + gboolean init_velocity; }; typedef struct _BrushWidget BrushWidget; + struct _BrushWidget { GtkWidget *widget; @@ -79,44 +81,45 @@ struct _BrushWidget }; typedef struct _InkOptions InkOptions; + struct _InkOptions { PaintOptions paint_options; - double size; - double size_d; + gdouble size; + gdouble size_d; GtkObject *size_w; - double sensitivity; - double sensitivity_d; + gdouble sensitivity; + gdouble sensitivity_d; GtkObject *sensitivity_w; - double vel_sensitivity; - double vel_sensitivity_d; + gdouble vel_sensitivity; + gdouble vel_sensitivity_d; GtkObject *vel_sensitivity_w; - double tilt_sensitivity; - double tilt_sensitivity_d; + gdouble tilt_sensitivity; + gdouble tilt_sensitivity_d; GtkObject *tilt_sensitivity_w; - double tilt_angle; - double tilt_angle_d; + gdouble tilt_angle; + gdouble tilt_angle_d; GtkObject *tilt_angle_w; BlobFunc function; BlobFunc function_d; GtkWidget *function_w[3]; /* 3 radio buttons */ - double aspect; - double aspect_d; - double angle; - double angle_d; + gdouble aspect; + gdouble aspect_d; + gdouble angle; + gdouble angle_d; BrushWidget *brush_w; }; /* the ink tool options */ -static InkOptions *ink_options = NULL; +static InkOptions * ink_options = NULL; /* local variables */ @@ -265,7 +268,7 @@ ink_options_new (void) GdkPixmap *pixmap; /* the new ink tool options structure */ - options = (InkOptions *) g_malloc (sizeof (InkOptions)); + options = g_new (InkOptions, 1); paint_options_init ((PaintOptions *) options, INK, ink_options_reset); @@ -303,7 +306,7 @@ ink_options_new (void) gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 0, 1); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->size_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->size); gtk_widget_show (slider); @@ -321,7 +324,7 @@ ink_options_new (void) gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 1, 2); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->sensitivity); gtk_widget_show (slider); @@ -350,7 +353,7 @@ ink_options_new (void) gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->tilt_sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->tilt_sensitivity); gtk_widget_show (slider); @@ -380,7 +383,7 @@ ink_options_new (void) gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->vel_sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->vel_sensitivity); gtk_widget_show (slider); @@ -410,7 +413,7 @@ ink_options_new (void) gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->tilt_angle_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->tilt_angle); /* Brush type radiobuttons */ diff --git a/app/tools/magnify.c b/app/tools/magnify.c index 14c27af762cf5162a7df6aee5b62bafa4cd658f4..f009a25ab441eb4a24b88ab27c9d99bb0df260db 100644 --- a/app/tools/magnify.c +++ b/app/tools/magnify.c @@ -16,14 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include + #include "appenv.h" #include "draw_core.h" #include "gdisplay.h" #include "gimprc.h" +#include "gimpui.h" #include "info_window.h" #include "magnify.h" #include "scale.h" -#include "tool_options_ui.h" #include "libgimp/gimpintl.h" @@ -34,23 +35,25 @@ /* the magnify structures */ typedef struct _Magnify Magnify; + struct _Magnify { - DrawCore * core; /* Core select object */ + DrawCore *core; /* Core select object */ - int x, y; /* upper left hand coordinate */ - int w, h; /* width and height */ + gint x, y; /* upper left hand coordinate */ + gint w, h; /* width and height */ - int op; /* magnify operation */ + gint op; /* magnify operation */ }; typedef struct _MagnifyOptions MagnifyOptions; + struct _MagnifyOptions { ToolOptions tool_options; - /* int allow_resize_windows; (from gimprc) */ - int allow_resize_d; + /* gint allow_resize_windows; (from gimprc) */ + gint allow_resize_d; GtkWidget *allow_resize_w; }; @@ -90,7 +93,7 @@ magnify_options_new (void) GtkWidget *vbox; /* the new magnify tool options structure */ - options = (MagnifyOptions *) g_malloc (sizeof (MagnifyOptions)); + options = g_new (MagnifyOptions, 1); tool_options_init ((ToolOptions *) options, _("Magnify Options"), magnify_options_reset); @@ -103,7 +106,7 @@ magnify_options_new (void) options->allow_resize_w = gtk_check_button_new_with_label (_("Allow Window Resizing")); gtk_signal_connect (GTK_OBJECT (options->allow_resize_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &allow_resize_windows); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_resize_w), allow_resize_windows); @@ -117,9 +120,9 @@ magnify_options_new (void) /* magnify utility functions */ static void -zoom_in (int *src, - int *dest, - int scale) +zoom_in (gint *src, + gint *dest, + gint scale) { while (scale--) { @@ -133,9 +136,9 @@ zoom_in (int *src, static void -zoom_out (int *src, - int *dest, - int scale) +zoom_out (gint *src, + gint *dest, + gint scale) { while (scale--) { @@ -155,9 +158,9 @@ magnify_button_press (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr) { - GDisplay * gdisp; - Magnify * magnify; - int x, y; + GDisplay *gdisp; + Magnify *magnify; + gint x, y; gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; @@ -170,7 +173,9 @@ magnify_button_press (Tool *tool, magnify->h = 0; gdk_pointer_grab (gdisp->canvas->window, FALSE, - GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, + GDK_POINTER_MOTION_HINT_MASK | + GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); tool->state = ACTIVE; @@ -192,13 +197,13 @@ magnify_button_release (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr) { - Magnify * magnify; - GDisplay * gdisp; - int win_width, win_height; - int width, height; - int scalesrc, scaledest; - int scale; - int x1, y1, x2, y2, w, h; + Magnify *magnify; + GDisplay *gdisp; + gint win_width, win_height; + gint width, height; + gint scalesrc, scaledest; + gint scale; + gint x1, y1, x2, y2, w, h; gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; @@ -252,7 +257,6 @@ magnify_button_release (Tool *tool, /* resize the image */ resize_display (gdisp, allow_resize_windows, TRUE); - } } @@ -261,9 +265,9 @@ magnify_motion (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr) { - Magnify * magnify; - GDisplay * gdisp; - int x, y; + Magnify *magnify; + GDisplay *gdisp; + gint x, y; if (tool->state != ACTIVE) return; @@ -286,7 +290,7 @@ magnify_cursor_update (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr) { - GDisplay * gdisp; + GDisplay *gdisp; gdisp = (GDisplay *) gdisp_ptr; @@ -297,17 +301,17 @@ magnify_cursor_update (Tool *tool, void magnify_draw (Tool *tool) { - GDisplay * gdisp; - Magnify * magnify; - int x1, y1, x2, y2; + GDisplay *gdisp; + Magnify *magnify; + gint x1, y1, x2, y2; gdisp = (GDisplay *) tool->gdisp_ptr; magnify = (Magnify *) tool->private; - x1 = MINIMUM (magnify->x, magnify->x + magnify->w); - y1 = MINIMUM (magnify->y, magnify->y + magnify->h); - x2 = MAXIMUM (magnify->x, magnify->x + magnify->w); - y2 = MAXIMUM (magnify->y, magnify->y + magnify->h); + x1 = MIN (magnify->x, magnify->x + magnify->w); + y1 = MIN (magnify->y, magnify->y + magnify->h); + x2 = MAX (magnify->x, magnify->x + magnify->w); + y2 = MAX (magnify->y, magnify->y + magnify->h); gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0); gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0); @@ -322,7 +326,7 @@ magnify_control (Tool *tool, ToolAction action, gpointer gdisp_ptr) { - Magnify * magnify; + Magnify *magnify; magnify = (Magnify *) tool->private; @@ -349,8 +353,8 @@ magnify_control (Tool *tool, Tool * tools_new_magnify (void) { - Tool * tool; - Magnify * private; + Tool *tool; + Magnify *private; /* The tool options */ if (! magnify_options) @@ -384,7 +388,7 @@ tools_new_magnify (void) void tools_free_magnify (Tool *tool) { - Magnify * magnify; + Magnify *magnify; magnify = (Magnify *) tool->private; diff --git a/app/tools/measure.c b/app/tools/measure.c index 2cee1723e45d7c43b6a8cd54a20edbea91d9ba99..a945985ac46c43e52d82932f2a63a5a7ceab9776 100644 --- a/app/tools/measure.c +++ b/app/tools/measure.c @@ -25,7 +25,6 @@ #include "gimpui.h" #include "info_dialog.h" #include "measure.h" -#include "tool_options_ui.h" #include "undo.h" #include "libgimp/gimpintl.h" @@ -49,21 +48,23 @@ typedef enum /* the measure structure */ typedef struct _MeasureTool MeasureTool; + struct _MeasureTool { DrawCore *core; /* draw core */ MeasureFunction function; /* what are we doing? */ - int point; /* what are we manipulating? */ - int num_points; /* how many points? */ - int x[3]; /* three x coordinates */ - int y[3]; /* three y coordinates */ - double angle1; /* first angle */ - double angle2; /* second angle */ + gint point; /* what are we manipulating? */ + gint num_points; /* how many points? */ + gint x[3]; /* three x coordinates */ + gint y[3]; /* three y coordinates */ + gdouble angle1; /* first angle */ + gdouble angle2; /* second angle */ guint context_id; /* for the statusbar */ }; /* the measure tool options */ typedef struct _MeasureOptions MeasureOptions; + struct _MeasureOptions { ToolOptions tool_options; @@ -128,7 +129,7 @@ measure_tool_options_new (void) options->use_info_window_d); gtk_box_pack_start (GTK_BOX (vbox), options->use_info_window_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->use_info_window_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->use_info_window); gtk_widget_show (options->use_info_window_w); @@ -181,7 +182,8 @@ measure_tool_button_press (Tool *tool, if (tool->state == ACTIVE && gdisp_ptr != tool->gdisp_ptr) { GDisplay *old_gdisp = tool->gdisp_ptr; - gtk_statusbar_pop (GTK_STATUSBAR (old_gdisp->statusbar), measure_tool->context_id); + gtk_statusbar_pop (GTK_STATUSBAR (old_gdisp->statusbar), + measure_tool->context_id); gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), measure_tool->context_id, ("")); } @@ -196,15 +198,15 @@ measure_tool_button_press (Tool *tool, { gdisplay_transform_coords (gdisp, measure_tool->x[i], measure_tool->y[i], &x[i], &y[i], FALSE); - if (bevent->x == BOUNDS (bevent->x, x[i] - TARGET, x[i] + TARGET) && - bevent->y == BOUNDS (bevent->y, y[i] - TARGET, y[i] + TARGET)) + if (bevent->x == CLAMP (bevent->x, x[i] - TARGET, x[i] + TARGET) && + bevent->y == CLAMP (bevent->y, y[i] - TARGET, y[i] + TARGET)) { if (bevent->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)) { Guide *guide; if (bevent->state & GDK_CONTROL_MASK && - (measure_tool->y[i] == BOUNDS (measure_tool->y[i], 0, gdisp->gimage->height))) + (measure_tool->y[i] == CLAMP (measure_tool->y[i], 0, gdisp->gimage->height))) { guide = gimp_image_add_hguide (gdisp->gimage); undo_push_guide (gdisp->gimage, guide); @@ -212,7 +214,7 @@ measure_tool_button_press (Tool *tool, gdisplays_expose_guide (gdisp->gimage, guide); } if (bevent->state & GDK_MOD1_MASK && - (measure_tool->x[i] == BOUNDS (measure_tool->x[i], 0, gdisp->gimage->width))) + (measure_tool->x[i] == CLAMP (measure_tool->x[i], 0, gdisp->gimage->width))) { guide = gimp_image_add_vguide (gdisp->gimage); undo_push_guide (gdisp->gimage, guide); @@ -258,7 +260,8 @@ measure_tool_button_press (Tool *tool, /* create the info window if necessary */ if (!measure_tool_info && - (measure_tool_options->use_info_window || !GTK_WIDGET_VISIBLE (gdisp->statusarea))) + (measure_tool_options->use_info_window || + !GTK_WIDGET_VISIBLE (gdisp->statusarea))) { measure_tool_info = info_dialog_new (_("Measure Tool"), tools_help_func, NULL); @@ -274,11 +277,15 @@ measure_tool_button_press (Tool *tool, } gdk_pointer_grab (gdisp->canvas->window, FALSE, - GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, + GDK_POINTER_MOTION_HINT_MASK | + GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); tool->state = ACTIVE; - /* set the pointer to the crosshair, so one actually sees the cursor position */ + /* set the pointer to the crosshair, + * so one actually sees the cursor position + */ gdisplay_install_tool_cursor (gdisp, GDK_TCROSS); } diff --git a/app/tools/paintbrush.c b/app/tools/paintbrush.c index 1fd95fcbfb281877290a2f971575127e993139bc..0843171a54911cb377b9871f18b1e2924e1933d1 100644 --- a/app/tools/paintbrush.c +++ b/app/tools/paintbrush.c @@ -26,13 +26,13 @@ #include "gdisplay.h" #include "gimpbrushlist.h" #include "gimpbrushpipe.h" +#include "gimpui.h" #include "gradient.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "paintbrush.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpunitmenu.h" @@ -91,18 +91,19 @@ struct _PaintbrushOptions static PaintbrushOptions * paintbrush_options = NULL; /* local variables */ -static double non_gui_fade_out; -static double non_gui_gradient_length; -static int non_gui_gradient_type; -static double non_gui_incremental; -static GUnit non_gui_fade_unit; -static GUnit non_gui_gradient_unit; +static gdouble non_gui_fade_out; +static gdouble non_gui_gradient_length; +static gint non_gui_gradient_type; +static gdouble non_gui_incremental; +static GUnit non_gui_fade_unit; +static GUnit non_gui_gradient_unit; /* forward function declarations */ -static void paintbrush_motion (PaintCore *, GimpDrawable *, PaintPressureOptions *, - double, double, PaintApplicationMode, GradientPaintMode); - +static void paintbrush_motion (PaintCore *, GimpDrawable *, + PaintPressureOptions *, + double, double, PaintApplicationMode, + GradientPaintMode); /* functions */ @@ -114,7 +115,7 @@ paintbrush_gradient_toggle_callback (GtkWidget *widget, static int incremental_save = FALSE; - tool_options_toggle_update (widget, data); + gimp_toggle_button_update (widget, data); if (paintbrush_options->use_gradient) { @@ -240,7 +241,7 @@ paintbrush_options_new (void) gtk_check_button_new_with_label (_("Fade Out")); gtk_container_add (GTK_CONTAINER (abox), options->use_fade_w); gtk_signal_connect (GTK_OBJECT (options->use_fade_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->use_fade); gtk_widget_show (options->use_fade_w); @@ -252,7 +253,7 @@ paintbrush_options_new (void) gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); gtk_widget_set_usize (spinbutton, 75, 0); gtk_signal_connect (GTK_OBJECT (options->fade_out_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->fade_out); gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 0, 1); gtk_widget_show (spinbutton); @@ -261,7 +262,7 @@ paintbrush_options_new (void) options->fade_unit_w = gimp_unit_menu_new ("%a", options->fade_unit_d, TRUE, TRUE, TRUE); gtk_signal_connect (GTK_OBJECT (options->fade_unit_w), "unit_changed", - (GtkSignalFunc) tool_options_unitmenu_update, + GTK_SIGNAL_FUNC (gimp_unit_menu_update), &options->fade_unit); gtk_object_set_data (GTK_OBJECT (options->fade_unit_w), "set_digits", spinbutton); gtk_table_attach (GTK_TABLE (table), options->fade_unit_w, 2, 3, 0, 1, @@ -298,7 +299,7 @@ paintbrush_options_new (void) gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); gtk_widget_set_usize (spinbutton, 75, 0); gtk_signal_connect (GTK_OBJECT (options->gradient_length_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->gradient_length); gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 1, 2); gtk_widget_show (spinbutton); @@ -307,9 +308,10 @@ paintbrush_options_new (void) options->gradient_unit_w = gimp_unit_menu_new ("%a", options->gradient_unit_d, TRUE, TRUE, TRUE); gtk_signal_connect (GTK_OBJECT (options->gradient_unit_w), "unit_changed", - (GtkSignalFunc) tool_options_unitmenu_update, + GTK_SIGNAL_FUNC (gimp_unit_menu_update), &options->gradient_unit); - gtk_object_set_data (GTK_OBJECT (options->gradient_unit_w), "set_digits", spinbutton); + gtk_object_set_data (GTK_OBJECT (options->gradient_unit_w), "set_digits", + spinbutton); gtk_table_attach (GTK_TABLE (table), options->gradient_unit_w, 2, 3, 1, 2, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (options->gradient_unit_w); diff --git a/app/tools/pencil.c b/app/tools/pencil.c index 61cdab425557f76d0e08b0e099cee7eb834e3512..c9b431788fae14cb9f1c1d7d4ee6e418332170e7 100644 --- a/app/tools/pencil.c +++ b/app/tools/pencil.c @@ -29,13 +29,13 @@ #include "paintbrush.h" #include "pencil.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "libgimp/gimpintl.h" /* the pencil tool options */ typedef struct _PencilOptions PencilOptions; + struct _PencilOptions { PaintOptions paint_options; @@ -61,19 +61,19 @@ pencil_paint_func (PaintCore *paint_core, { switch (state) { - case INIT_PAINT : + case INIT_PAINT: break; - case MOTION_PAINT : + case MOTION_PAINT: pencil_motion (paint_core, drawable, pencil_options->paint_options.pressure_options, pencil_options->paint_options.incremental); break; - case FINISH_PAINT : + case FINISH_PAINT: break; - default : + default: break; } @@ -85,10 +85,11 @@ pencil_options_new (void) { PencilOptions *options; - options = (PencilOptions *) g_malloc (sizeof (PencilOptions)); + options = g_new (PencilOptions, 1); paint_options_init ((PaintOptions *) options, PENCIL, pencil_options_reset); + return options; } diff --git a/app/tools/smudge.c b/app/tools/smudge.c index d8445da818eb627773536e8449fade90bfca723e..6c2154028c383b6d8dd5697bf64aa75a4ac74a3b 100644 --- a/app/tools/smudge.c +++ b/app/tools/smudge.c @@ -28,11 +28,11 @@ #include "smudge.h" #include "gdisplay.h" #include "gimplut.h" +#include "gimpui.h" #include "paint_funcs.h" #include "paint_core.h" #include "paint_options.h" #include "selection.h" -#include "tool_options_ui.h" #include "tools.h" #include "gimage.h" @@ -47,37 +47,41 @@ /* the smudge structures */ typedef struct _SmudgeOptions SmudgeOptions; + struct _SmudgeOptions { PaintOptions paint_options; - double rate; - double rate_d; + gdouble rate; + gdouble rate_d; GtkObject *rate_w; }; -static PixelRegion accumPR; -static unsigned char *accum_data; +static PixelRegion accumPR; +static guchar *accum_data; /* the smudge tool options */ -static SmudgeOptions *smudge_options = NULL; +static SmudgeOptions * smudge_options = NULL; /* local variables */ -static gdouble non_gui_rate; +static gdouble non_gui_rate; /* function prototypes */ -static void smudge_motion (PaintCore *, PaintPressureOptions *, - gdouble, GimpDrawable *); -static void smudge_init (PaintCore *, GimpDrawable *); -static void smudge_finish (PaintCore *, GimpDrawable *); - -static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, - gint * x, gint* y, - gint* w, gint *h); -static void smudge_allocate_accum_buffer (gint w, gint h, - gint bytes, guchar *do_fill); - +static void smudge_motion (PaintCore *, PaintPressureOptions *, + gdouble, GimpDrawable *); +static void smudge_init (PaintCore *, GimpDrawable *); +static void smudge_finish (PaintCore *, GimpDrawable *); + +static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, + gint *x, + gint *y, + gint *w, + gint *h); +static void smudge_allocate_accum_buffer (gint w, + gint h, + gint bytes, + guchar *do_fill); static void smudge_options_reset (void) @@ -100,7 +104,7 @@ smudge_options_new (void) GtkWidget *scale; /* the new smudge tool options structure */ - options = (SmudgeOptions *) g_malloc (sizeof (SmudgeOptions)); + options = g_new (SmudgeOptions, 1); paint_options_init ((PaintOptions *) options, SMUDGE, smudge_options_reset); @@ -126,7 +130,7 @@ smudge_options_new (void) gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->rate); gtk_widget_show (scale); gtk_widget_show (hbox); @@ -224,7 +228,9 @@ smudge_init (PaintCore *paint_core, that may enter into the blend */ if (was_clipped) - do_fill = gimp_drawable_get_color_at (drawable, (gint)paint_core->curx, (gint) paint_core->cury); + do_fill = gimp_drawable_get_color_at (drawable, + (gint)paint_core->curx, + (gint) paint_core->cury); smudge_allocate_accum_buffer (w, h, drawable_bytes(drawable), do_fill); @@ -279,7 +285,7 @@ smudge_allocate_accum_buffer (gint w, } Tool * -tools_new_smudge () +tools_new_smudge (void) { Tool * tool; PaintCore * private; @@ -341,7 +347,7 @@ smudge_motion (PaintCore *paint_core, the drawable*/ pixel_region_init (&srcPR, drawable_data (drawable), - area->x, area->y, area->width, area->height, FALSE); + area->x, area->y, area->width, area->height, FALSE); /* Enable pressure sensitive rate */ if (pressure_options->rate) @@ -356,9 +362,8 @@ smudge_motion (PaintCore *paint_core, tempPR.y = area->y - y; tempPR.w = area->width; tempPR.h = area->height; - tempPR.data = accum_data - + tempPR.rowstride * tempPR.y - + tempPR.x * tempPR.bytes; + tempPR.data = accum_data + + tempPR.rowstride * tempPR.y + tempPR.x * tempPR.bytes; /* The dest will be the paint area we got above (= canvas_buf) */ @@ -439,7 +444,7 @@ smudge_non_gui (GimpDrawable *drawable, int num_strokes, double *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) diff --git a/app/tools/text_tool.c b/app/tools/text_tool.c index b2b1716f2b500ffe89e752a1728b0e16c3107798..fc04848a08c25c0099ded0c53ff7c7456cd70f25 100644 --- a/app/tools/text_tool.c +++ b/app/tools/text_tool.c @@ -29,11 +29,11 @@ #include "errors.h" #include "floating_sel.h" #include "gimage_mask.h" +#include "gimpui.h" #include "global_edit.h" #include "procedural_db.h" #include "selection.h" #include "text_tool.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" @@ -141,7 +141,7 @@ text_options_new (void) GtkWidget *sep; /* the new text tool options structure */ - options = (TextOptions *) g_malloc (sizeof (TextOptions)); + options = g_new (TextOptions, 1); tool_options_init ((ToolOptions *) options, _("Text Tool Options"), text_options_reset); @@ -156,7 +156,7 @@ text_options_new (void) options->antialias_w = gtk_check_button_new_with_label (_("Antialiasing")); gtk_signal_connect (GTK_OBJECT (options->antialias_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->antialias); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w), options->antialias_d); @@ -175,7 +175,7 @@ text_options_new (void) options->border_w = gtk_adjustment_new (options->border_d, 0.0, 32767.0, 1.0, 50.0, 0.0); gtk_signal_connect (GTK_OBJECT (options->border_w), "value_changed", - (GtkSignalFunc) tool_options_int_adjustment_update, + GTK_SIGNAL_FUNC (gimp_int_adjustment_update), &options->border); spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (options->border_w), 1.0, 0.0); @@ -196,7 +196,7 @@ text_options_new (void) options->use_dyntext_w = gtk_check_button_new_with_label (_("Use Dynamic Text")); gtk_signal_connect (GTK_OBJECT (options->use_dyntext_w), "toggled", - (GtkSignalFunc) tool_options_toggle_update, + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->use_dyntext); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_dyntext_w), options->use_dyntext_d); diff --git a/app/tools/tool_options.c b/app/tools/tool_options.c index d9b967715660f09983a675bccabcff82c0deaab5..03d819a1d76c90b370de286492572a9ee41ed68d 100644 --- a/app/tools/tool_options.c +++ b/app/tools/tool_options.c @@ -16,13 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" + #include "brush_select.h" #include "gimprc.h" #include "gimpui.h" #include "paint_funcs.h" #include "paint_options.h" #include "selection_options.h" -#include "tool_options_ui.h" #include "libgimp/gimpunitmenu.h" #include "libgimp/gimpintl.h" @@ -49,60 +49,7 @@ static void paint_pressure_options_reset (PaintPressureOptions /* ui helper functions ******************************************************/ -void -tool_options_toggle_update (GtkWidget *widget, - gpointer data) -{ - GtkWidget *set_sensitive; - gboolean *toggle_val; - - toggle_val = (gboolean *) data; - *toggle_val = (GTK_TOGGLE_BUTTON (widget)->active) ? TRUE : FALSE; - - /* a tool options toggle button can set the sensitive state of - * an arbitrary list of widgets - */ - - set_sensitive = - gtk_object_get_data (GTK_OBJECT (widget), "set_sensitive"); - while (set_sensitive) - { - gtk_widget_set_sensitive (GTK_WIDGET (set_sensitive), *toggle_val); - set_sensitive = - gtk_object_get_data (GTK_OBJECT (set_sensitive), "set_sensitive"); - } - - set_sensitive = - gtk_object_get_data (GTK_OBJECT (widget), "inverse_sensitive"); - while (set_sensitive) - { - gtk_widget_set_sensitive (GTK_WIDGET (set_sensitive), ! *toggle_val); - set_sensitive = - gtk_object_get_data (GTK_OBJECT (set_sensitive), "inverse_sensitive"); - } -} - -void -tool_options_int_adjustment_update (GtkWidget *widget, - gpointer data) -{ - gint *val; - - val = (gint *) data; - *val = GTK_ADJUSTMENT (widget)->value; -} - -void -tool_options_double_adjustment_update (GtkWidget *widget, - gpointer data) -{ - gdouble *val; - - val = (gdouble *) data; - *val = GTK_ADJUSTMENT (widget)->value; -} - -void +static void tool_options_opacity_adjustment_update (GtkWidget *widget, gpointer data) { @@ -122,82 +69,6 @@ tool_options_paint_mode_update (GtkWidget *widget, (LayerModeEffects) data); } -void -tool_options_unitmenu_update (GtkWidget *widget, - gpointer data) -{ - GUnit *val; - GtkWidget *spinbutton; - gint digits; - - val = (GUnit *) data; - *val = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget)); - - digits = ((*val == UNIT_PIXEL) ? 0 : - ((*val == UNIT_PERCENT) ? 2 : - (MIN (6, MAX (3, gimp_unit_get_digits (*val)))))); - - spinbutton = - gtk_object_get_data (GTK_OBJECT (widget), "set_digits"); - while (spinbutton) - { - gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits); - spinbutton = gtk_object_get_data (GTK_OBJECT (spinbutton), "set_digits"); - } -} - -static void -tool_options_radio_buttons_update (GtkWidget *widget, - gpointer data) -{ - gint *toggle_val; - - toggle_val = (gint *) data; - if (GTK_TOGGLE_BUTTON (widget)->active) - *toggle_val = (gint) gtk_object_get_data (GTK_OBJECT (widget), - "toggle_value"); -} - -GtkWidget * -tool_options_radio_buttons_new (gchar* label, - gpointer toggle_val, - GtkWidget* button_widget[], - gchar* button_label[], - gint button_value[], - gint num) -{ - GtkWidget *frame; - GtkWidget *vbox; - GSList *group = NULL; - gint i; - - frame = gtk_frame_new (label); - - g_return_val_if_fail (toggle_val != NULL, frame); - - vbox = gtk_vbox_new (FALSE, 1); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - for (i=0; ifeather_w), options->feather_d); gtk_signal_connect (GTK_OBJECT (options->feather_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->feather); gtk_widget_show (options->feather_w); @@ -316,7 +187,7 @@ selection_options_init (SelectionOptions *options, gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->feather_radius_w), "value_changed", - GTK_SIGNAL_FUNC (tool_options_double_adjustment_update), + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->feather_radius); gtk_widget_show (scale); @@ -336,7 +207,7 @@ selection_options_init (SelectionOptions *options, gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->antialias_w), options->antialias_d); gtk_signal_connect (GTK_OBJECT (options->antialias_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->antialias); gtk_widget_show (options->antialias_w); } @@ -376,7 +247,7 @@ selection_options_init (SelectionOptions *options, gtk_box_pack_start (GTK_BOX (vbox), options->sample_merged_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->sample_merged_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->sample_merged); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->sample_merged_w), options->sample_merged_d); @@ -399,7 +270,7 @@ selection_options_init (SelectionOptions *options, gtk_box_pack_start (GTK_BOX (vbox), options->fixed_size_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->fixed_size_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->fixed_size); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->fixed_size_w), options->fixed_size_d); @@ -429,7 +300,7 @@ selection_options_init (SelectionOptions *options, gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (width_spinbutton), TRUE); gtk_widget_set_usize (width_spinbutton, 75, 0); gtk_signal_connect (GTK_OBJECT (options->fixed_width_w), "value_changed", - GTK_SIGNAL_FUNC (tool_options_double_adjustment_update), + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->fixed_width); gimp_table_attach_aligned (GTK_TABLE (table), 0, _("Width:"), 1.0, 0.5, @@ -445,7 +316,7 @@ selection_options_init (SelectionOptions *options, gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(height_spinbutton), TRUE); gtk_widget_set_usize (height_spinbutton, 75, 0); gtk_signal_connect (GTK_OBJECT (options->fixed_height_w), "value_changed", - GTK_SIGNAL_FUNC (tool_options_double_adjustment_update), + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->fixed_height); gimp_table_attach_aligned (GTK_TABLE (table), 1, _("Height:"), 1.0, 0.5, @@ -454,7 +325,7 @@ selection_options_init (SelectionOptions *options, options->fixed_unit_w = gimp_unit_menu_new ("%a", options->fixed_unit_d, TRUE, TRUE, TRUE); gtk_signal_connect (GTK_OBJECT (options->fixed_unit_w), "unit_changed", - GTK_SIGNAL_FUNC (tool_options_unitmenu_update), + GTK_SIGNAL_FUNC (gimp_unit_menu_update), &options->fixed_unit); gtk_object_set_data (GTK_OBJECT (options->fixed_unit_w), "set_digits", width_spinbutton); @@ -685,7 +556,7 @@ paint_options_init (PaintOptions *options, gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), options->incremental_w, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (options->incremental_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->incremental); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->incremental_w), options->incremental_d); @@ -813,7 +684,7 @@ paint_pressure_options_new (ToolType tool_type) gtk_check_button_new_with_label (_("Opacity")); gtk_container_add (GTK_CONTAINER (hbox), pressure->opacity_w); gtk_signal_connect (GTK_OBJECT (pressure->opacity_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->opacity); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->opacity_w), pressure->opacity_d); @@ -836,7 +707,7 @@ paint_pressure_options_new (ToolType tool_type) pressure->pressure_w = gtk_check_button_new_with_label (_("Pressure")); gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w); gtk_signal_connect (GTK_OBJECT (pressure->pressure_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->pressure); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->pressure_w), pressure->pressure_d); @@ -856,7 +727,7 @@ paint_pressure_options_new (ToolType tool_type) gtk_check_button_new_with_label (_("Rate")); gtk_container_add (GTK_CONTAINER (hbox), pressure->rate_w); gtk_signal_connect (GTK_OBJECT (pressure->rate_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->rate); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->rate_w), pressure->rate_d); @@ -880,7 +751,7 @@ paint_pressure_options_new (ToolType tool_type) gtk_check_button_new_with_label (_("Size")); gtk_container_add (GTK_CONTAINER (hbox), pressure->size_w); gtk_signal_connect (GTK_OBJECT (pressure->size_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->size); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->size_w), pressure->size_d); @@ -900,7 +771,7 @@ paint_pressure_options_new (ToolType tool_type) gtk_check_button_new_with_label (_("Color")); gtk_container_add (GTK_CONTAINER (hbox), pressure->color_w); gtk_signal_connect (GTK_OBJECT (pressure->color_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &pressure->color); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pressure->color_w), pressure->color_d); diff --git a/app/tools/transform_tool.c b/app/tools/transform_tool.c index e23799d4bf6675aaf49d57c192dc6363f52faa4b..5cdeac46b7cc75a9cc7e54aec6c98c45f43f0f12 100644 --- a/app/tools/transform_tool.c +++ b/app/tools/transform_tool.c @@ -15,10 +15,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include "appenv.h" #include "gdisplay.h" #include "gimpui.h" -#include "tool_options_ui.h" #include "tools.h" #include "perspective_tool.h" #include "rotate_tool.h" @@ -27,7 +28,6 @@ #include "transform_core.h" #include "transform_tool.h" -#include "config.h" #include "libgimp/gimpmath.h" #include "libgimp/gimpintl.h" @@ -83,7 +83,7 @@ static void transform_show_grid_update (GtkWidget *widget, gpointer data) { - static gboolean first_call = TRUE; /* eek, this hack avoids a segfult */ + static gboolean first_call = TRUE; /* eek, this hack avoids a segfault */ if (first_call) { @@ -91,7 +91,8 @@ transform_show_grid_update (GtkWidget *widget, return; } - tool_options_toggle_update (widget, data); + gimp_toggle_button_update (widget, data); + transform_core_grid_density_changed (); } @@ -99,7 +100,7 @@ static void transform_show_path_update (GtkWidget *widget, gpointer data) { - static gboolean first_call = TRUE; /* eek, this hack avoids a segfult */ + static gboolean first_call = TRUE; /* eek, this hack avoids a segfault */ if (first_call) { @@ -108,7 +109,7 @@ transform_show_path_update (GtkWidget *widget, } transform_core_showpath_changed (1); /* pause */ - tool_options_toggle_update (widget, data); + gimp_toggle_button_update (widget, data); transform_core_showpath_changed (0); /* resume */ } @@ -184,7 +185,7 @@ transform_options_new (void) GtkWidget *grid_density; /* the new transform tool options structure */ - options = (TransformOptions *) g_malloc (sizeof (TransformOptions)); + options = g_new (TransformOptions, 1); tool_options_init ((ToolOptions *) options, _("Transform Tool Options"), transform_options_reset); @@ -293,7 +294,7 @@ transform_options_new (void) /* the smoothing toggle button */ options->smoothing_w = gtk_check_button_new_with_label (_("Smoothing")); gtk_signal_connect (GTK_OBJECT (options->smoothing_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->smoothing); gtk_table_attach_defaults (GTK_TABLE (table), options->smoothing_w, 0, 1, 1, 2); @@ -313,7 +314,7 @@ transform_options_new (void) /* the clip resulting image toggle button */ options->clip_w = gtk_check_button_new_with_label (_("Clip Result")); gtk_signal_connect (GTK_OBJECT (options->clip_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->clip); gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), options->clip_w, FALSE, FALSE, 0); diff --git a/app/tools/xinput_airbrush.c b/app/tools/xinput_airbrush.c index 998e4129899254780205f5a0bfcb762e689f4b19..937f1737923bae28a16d723c20d7e74fbd1943bc 100644 --- a/app/tools/xinput_airbrush.c +++ b/app/tools/xinput_airbrush.c @@ -17,23 +17,23 @@ */ #include "config.h" -#include #include #include #include #include "appenv.h" + +#include "airbrush_blob.h" #include "drawable.h" #include "draw_core.h" +#include "gdisplay.h" #include "gimage_mask.h" #include "gimprc.h" -#include "xinput_airbrush.h" +#include "gimpui.h" #include "paint_options.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" -#include "airbrush_blob.h" -#include "gdisplay.h" +#include "xinput_airbrush.h" #include "libgimp/gimpintl.h" #include "libgimp/gimpmath.h" @@ -332,7 +332,7 @@ static XinputAirbrushOptions * gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 0, 1); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->flow_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->flow); gtk_widget_show (slider); gtk_scale_set_digits (GTK_SCALE (slider), 0); @@ -351,7 +351,7 @@ static XinputAirbrushOptions * gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 1, 2); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->sensitivity); gtk_widget_show (slider); @@ -371,7 +371,7 @@ static XinputAirbrushOptions * gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 2, 3); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->starttilt_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->starttilt); gtk_widget_show (slider); gtk_scale_set_digits (GTK_SCALE (slider), 0); @@ -399,7 +399,7 @@ static XinputAirbrushOptions * gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->tilt_sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->tilt_sensitivity); gtk_widget_show (slider); @@ -425,7 +425,7 @@ static XinputAirbrushOptions * gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->vel_sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->vel_sensitivity); gtk_widget_show (slider); @@ -447,7 +447,7 @@ static XinputAirbrushOptions * gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 7, 8); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->minheight_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->minheight); gtk_widget_show (slider); gtk_scale_set_digits (GTK_SCALE (slider), 0); @@ -468,7 +468,7 @@ static XinputAirbrushOptions * gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 9, 10); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->maxheight_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->maxheight); gtk_widget_show (slider); gtk_scale_set_digits (GTK_SCALE (slider), 0); @@ -489,7 +489,7 @@ static XinputAirbrushOptions * gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 7, 8); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->height_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->height); gtk_widget_show (slider); gtk_scale_set_digits (GTK_SCALE (slider), 0); diff --git a/app/transform_tool.c b/app/transform_tool.c index e23799d4bf6675aaf49d57c192dc6363f52faa4b..5cdeac46b7cc75a9cc7e54aec6c98c45f43f0f12 100644 --- a/app/transform_tool.c +++ b/app/transform_tool.c @@ -15,10 +15,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include "appenv.h" #include "gdisplay.h" #include "gimpui.h" -#include "tool_options_ui.h" #include "tools.h" #include "perspective_tool.h" #include "rotate_tool.h" @@ -27,7 +28,6 @@ #include "transform_core.h" #include "transform_tool.h" -#include "config.h" #include "libgimp/gimpmath.h" #include "libgimp/gimpintl.h" @@ -83,7 +83,7 @@ static void transform_show_grid_update (GtkWidget *widget, gpointer data) { - static gboolean first_call = TRUE; /* eek, this hack avoids a segfult */ + static gboolean first_call = TRUE; /* eek, this hack avoids a segfault */ if (first_call) { @@ -91,7 +91,8 @@ transform_show_grid_update (GtkWidget *widget, return; } - tool_options_toggle_update (widget, data); + gimp_toggle_button_update (widget, data); + transform_core_grid_density_changed (); } @@ -99,7 +100,7 @@ static void transform_show_path_update (GtkWidget *widget, gpointer data) { - static gboolean first_call = TRUE; /* eek, this hack avoids a segfult */ + static gboolean first_call = TRUE; /* eek, this hack avoids a segfault */ if (first_call) { @@ -108,7 +109,7 @@ transform_show_path_update (GtkWidget *widget, } transform_core_showpath_changed (1); /* pause */ - tool_options_toggle_update (widget, data); + gimp_toggle_button_update (widget, data); transform_core_showpath_changed (0); /* resume */ } @@ -184,7 +185,7 @@ transform_options_new (void) GtkWidget *grid_density; /* the new transform tool options structure */ - options = (TransformOptions *) g_malloc (sizeof (TransformOptions)); + options = g_new (TransformOptions, 1); tool_options_init ((ToolOptions *) options, _("Transform Tool Options"), transform_options_reset); @@ -293,7 +294,7 @@ transform_options_new (void) /* the smoothing toggle button */ options->smoothing_w = gtk_check_button_new_with_label (_("Smoothing")); gtk_signal_connect (GTK_OBJECT (options->smoothing_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->smoothing); gtk_table_attach_defaults (GTK_TABLE (table), options->smoothing_w, 0, 1, 1, 2); @@ -313,7 +314,7 @@ transform_options_new (void) /* the clip resulting image toggle button */ options->clip_w = gtk_check_button_new_with_label (_("Clip Result")); gtk_signal_connect (GTK_OBJECT (options->clip_w), "toggled", - GTK_SIGNAL_FUNC (tool_options_toggle_update), + GTK_SIGNAL_FUNC (gimp_toggle_button_update), &options->clip); gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), options->clip_w, FALSE, FALSE, 0); diff --git a/app/xinput_airbrush.c b/app/xinput_airbrush.c index 998e4129899254780205f5a0bfcb762e689f4b19..937f1737923bae28a16d723c20d7e74fbd1943bc 100644 --- a/app/xinput_airbrush.c +++ b/app/xinput_airbrush.c @@ -17,23 +17,23 @@ */ #include "config.h" -#include #include #include #include #include "appenv.h" + +#include "airbrush_blob.h" #include "drawable.h" #include "draw_core.h" +#include "gdisplay.h" #include "gimage_mask.h" #include "gimprc.h" -#include "xinput_airbrush.h" +#include "gimpui.h" #include "paint_options.h" -#include "tool_options_ui.h" #include "tools.h" #include "undo.h" -#include "airbrush_blob.h" -#include "gdisplay.h" +#include "xinput_airbrush.h" #include "libgimp/gimpintl.h" #include "libgimp/gimpmath.h" @@ -332,7 +332,7 @@ static XinputAirbrushOptions * gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 0, 1); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->flow_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->flow); gtk_widget_show (slider); gtk_scale_set_digits (GTK_SCALE (slider), 0); @@ -351,7 +351,7 @@ static XinputAirbrushOptions * gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 1, 2); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->sensitivity); gtk_widget_show (slider); @@ -371,7 +371,7 @@ static XinputAirbrushOptions * gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 2, 3); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->starttilt_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->starttilt); gtk_widget_show (slider); gtk_scale_set_digits (GTK_SCALE (slider), 0); @@ -399,7 +399,7 @@ static XinputAirbrushOptions * gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->tilt_sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->tilt_sensitivity); gtk_widget_show (slider); @@ -425,7 +425,7 @@ static XinputAirbrushOptions * gtk_container_add (GTK_CONTAINER (abox), slider); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->vel_sensitivity_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->vel_sensitivity); gtk_widget_show (slider); @@ -447,7 +447,7 @@ static XinputAirbrushOptions * gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 7, 8); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->minheight_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->minheight); gtk_widget_show (slider); gtk_scale_set_digits (GTK_SCALE (slider), 0); @@ -468,7 +468,7 @@ static XinputAirbrushOptions * gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 9, 10); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->maxheight_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->maxheight); gtk_widget_show (slider); gtk_scale_set_digits (GTK_SCALE (slider), 0); @@ -489,7 +489,7 @@ static XinputAirbrushOptions * gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, 7, 8); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (options->height_w), "value_changed", - (GtkSignalFunc) tool_options_double_adjustment_update, + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &options->height); gtk_widget_show (slider); gtk_scale_set_digits (GTK_SCALE (slider), 0); diff --git a/libgimp/gimpwidgets.c b/libgimp/gimpwidgets.c index 50c661ca82c15a07a569765f5acfc4f4e1499636..265a477241ed709a7bd442bedf2181e0b4ea970f 100644 --- a/libgimp/gimpwidgets.c +++ b/libgimp/gimpwidgets.c @@ -21,6 +21,7 @@ */ #include "gimphelpui.h" +#include "gimpunitmenu.h" #include "gimpwidgets.h" /* @@ -419,6 +420,30 @@ gimp_double_adjustment_update (GtkAdjustment *adjustment, *val = adjustment->value; } +void +gimp_unit_menu_update (GtkWidget *widget, + gpointer data) +{ + GUnit *val; + GtkWidget *spinbutton; + gint digits; + + val = (GUnit *) data; + *val = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget)); + + digits = ((*val == UNIT_PIXEL) ? 0 : + ((*val == UNIT_PERCENT) ? 2 : + (MIN (6, MAX (3, gimp_unit_get_digits (*val)))))); + + spinbutton = + gtk_object_get_data (GTK_OBJECT (widget), "set_digits"); + while (spinbutton) + { + gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits); + spinbutton = gtk_object_get_data (GTK_OBJECT (spinbutton), "set_digits"); + } +} + /* * Helper Functions... */ diff --git a/libgimp/gimpwidgets.h b/libgimp/gimpwidgets.h index ea262302ef6b7b3e76962e94aa5014f2896cfd32..63f765b1da440a3bc57fa55793333ff9f63ebcfc 100644 --- a/libgimp/gimpwidgets.h +++ b/libgimp/gimpwidgets.h @@ -118,6 +118,9 @@ void gimp_int_adjustment_update (GtkAdjustment *adjustment, void gimp_double_adjustment_update (GtkAdjustment *adjustment, gpointer data); +void gimp_unit_menu_update (GtkWidget *widget, + gpointer data); + /* * Helper Functions */ diff --git a/libgimpwidgets/gimpwidgets.c b/libgimpwidgets/gimpwidgets.c index 50c661ca82c15a07a569765f5acfc4f4e1499636..265a477241ed709a7bd442bedf2181e0b4ea970f 100644 --- a/libgimpwidgets/gimpwidgets.c +++ b/libgimpwidgets/gimpwidgets.c @@ -21,6 +21,7 @@ */ #include "gimphelpui.h" +#include "gimpunitmenu.h" #include "gimpwidgets.h" /* @@ -419,6 +420,30 @@ gimp_double_adjustment_update (GtkAdjustment *adjustment, *val = adjustment->value; } +void +gimp_unit_menu_update (GtkWidget *widget, + gpointer data) +{ + GUnit *val; + GtkWidget *spinbutton; + gint digits; + + val = (GUnit *) data; + *val = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget)); + + digits = ((*val == UNIT_PIXEL) ? 0 : + ((*val == UNIT_PERCENT) ? 2 : + (MIN (6, MAX (3, gimp_unit_get_digits (*val)))))); + + spinbutton = + gtk_object_get_data (GTK_OBJECT (widget), "set_digits"); + while (spinbutton) + { + gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits); + spinbutton = gtk_object_get_data (GTK_OBJECT (spinbutton), "set_digits"); + } +} + /* * Helper Functions... */ diff --git a/libgimpwidgets/gimpwidgets.h b/libgimpwidgets/gimpwidgets.h index ea262302ef6b7b3e76962e94aa5014f2896cfd32..63f765b1da440a3bc57fa55793333ff9f63ebcfc 100644 --- a/libgimpwidgets/gimpwidgets.h +++ b/libgimpwidgets/gimpwidgets.h @@ -118,6 +118,9 @@ void gimp_int_adjustment_update (GtkAdjustment *adjustment, void gimp_double_adjustment_update (GtkAdjustment *adjustment, gpointer data); +void gimp_unit_menu_update (GtkWidget *widget, + gpointer data); + /* * Helper Functions */ diff --git a/plug-ins/common/csource.c b/plug-ins/common/csource.c index d49f1d64292a64633cdaa2c5f765af7bae0c99e2..f4d141791212c990c9a8c7b6f7e80a651caec209 100644 --- a/plug-ins/common/csource.c +++ b/plug-ins/common/csource.c @@ -26,16 +26,17 @@ #include -typedef struct { - gchar *file_name; - gchar *prefixed_name; - gchar *comment; - gboolean use_comment; - gboolean glib_types; - gboolean alpha; - gboolean use_macros; - gboolean use_rle; - gdouble opacity; +typedef struct +{ + gchar *file_name; + gchar *prefixed_name; + gchar *comment; + gboolean use_comment; + gboolean glib_types; + gboolean alpha; + gboolean use_macros; + gboolean use_rle; + gdouble opacity; } Config; @@ -46,6 +47,7 @@ static void run (gchar *name, GParam *param, gint *nreturn_vals, GParam **return_vals); + static gint save_image (Config *config, gint32 image_ID, gint32 drawable_ID); @@ -55,10 +57,10 @@ static gboolean run_save_dialog (Config *config); /* --- variables --- */ GPlugInInfo PLUG_IN_INFO = { - NULL, /* init_proc */ - NULL, /* quit_proc */ - query, /* query_proc */ - run, /* run_proc */ + NULL, /* init */ + NULL, /* quit */ + query, /* query */ + run, /* run */ }; /* --- implement main (), provided by libgimp --- */ @@ -165,8 +167,6 @@ run (gchar *name, *nreturn_vals = 1; - - export = gimp_export_image (&image_ID, &drawable_ID, "C Source", (CAN_HANDLE_RGB | CAN_HANDLE_ALPHA)); @@ -591,13 +591,28 @@ cb_set_true (gboolean *bool_p) static gboolean run_save_dialog (Config *config) { - GtkWidget *dialog, *vbox, *hbox, *button; - GtkWidget *prefixed_name, *centry, *alpha, *use_macros, *use_rle, *gtype, *use_comment, *any; + GtkWidget *dialog; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *button; + GtkWidget *prefixed_name; + GtkWidget *centry; + GtkWidget *alpha; + GtkWidget *use_macros; + GtkWidget *use_rle; + GtkWidget *gtype; + GtkWidget *use_comment; + GtkWidget *any; GtkObject *opacity; gboolean do_save = FALSE; - - gtk_init (NULL, NULL); - g_set_prgname ("Save"); + gchar **argv; + gint argc; + + argc = 1; + argv = g_new (gchar *, 1); + argv[0] = g_strdup ("csource"); + + gtk_init (&argc, &argv); gtk_rc_parse (gimp_gtkrc ()); dialog = gimp_dialog_new ("Save as C-Source", "csource", @@ -620,11 +635,10 @@ run_save_dialog (Config *config) GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (dialog)); - vbox = GTK_DIALOG (dialog)->vbox; - gtk_widget_set (vbox, - "border_width", 5, - "spacing", 5, - NULL); + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox); + gtk_widget_show (vbox); /* Prefixed Name */ diff --git a/plug-ins/common/despeckle.c b/plug-ins/common/despeckle.c index a0cae78d1d1445f0a535d35415ee29826e40e89e..16ce32efb4d96172f3b57292b68760ee3e6e4509 100644 --- a/plug-ins/common/despeckle.c +++ b/plug-ins/common/despeckle.c @@ -41,6 +41,53 @@ * Revision History: * * $Log$ + * Revision 1.24 2000/01/14 12:40:59 mitch + * 2000-01-14 Michael Natterer + * + * * app/Makefile.am + * * app/tool_options_ui.h: removed. + * + * * app/tool_options.c + * * libgimp/gimpwidgets.[ch]: moved some more ui utility functions + * to libgimp. + * + * * app/airbrush.c + * * app/blend.c + * * app/bucket_fill.c + * * app/channel_ops.c + * * app/clone.c + * * app/color_picker.c + * * app/convolve.c + * * app/crop.c + * * app/dodgeburn.c + * * app/eraser.c + * * app/file_new_dialog.[ch] + * * app/flip_tool.c + * * app/image_new.[ch] + * * app/ink.c + * * app/layers_dialog.c + * * app/magnify.c + * * app/measure.c + * * app/paintbrush.c + * * app/pencil.c + * * app/smudge.c + * * app/text_tool.c + * * app/tool_options.c + * * app/transform_tool.c + * * app/xinput_airbrush.c: use the libgimp functions (esp. the radio + * button group constructor), some code cleanup. + * + * * plug-ins/common/csource.c + * * plug-ins/common/despeckle.c + * * plug-ins/common/diffraction.c + * * plug-ins/common/jpeg.c + * * plug-ins/common/png.c + * * plug-ins/unsharp/unsharp.c: more plugin ui tuning. + * + * * plug-ins/unsharp/Makefile.am + * * plug-ins/unsharp/dialog_f.[ch] + * * plug-ins/unsharp/dialog_i.[ch]: removed. + * * Revision 1.23 2000/01/13 15:39:24 mitch * 2000-01-13 Michael Natterer * @@ -304,19 +351,17 @@ */ static void query (void); -static void run (gchar *, - gint, - GParam *, - gint *, - GParam **); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); static void despeckle (void); static gint despeckle_dialog (void); -static void dialog_create_ivalue (gchar *, GtkTable *, - gint, gint *, gint, gint); + static void dialog_iscale_update (GtkAdjustment *, gint *); -static void dialog_ientry_update (GtkWidget *, gint *); static void dialog_adaptive_callback (GtkWidget *, gpointer); static void dialog_recursive_callback (GtkWidget *, gpointer); static void dialog_ok_callback (GtkWidget *, gpointer); @@ -333,10 +378,10 @@ static void preview_scroll_callback (void); GPlugInInfo PLUG_IN_INFO = { - NULL, /* init_proc */ - NULL, /* quit_proc */ - query, /* query_proc */ - run /* run_proc */ + NULL, /* init */ + NULL, /* quit */ + query, /* query */ + run /* run */ }; GtkWidget *preview; /* Preview widget */ @@ -826,21 +871,20 @@ despeckle (void) static gint despeckle_dialog (void) { - GtkWidget *dialog, /* Dialog window */ - *table, /* Table "container" for controls */ - *ptable, /* Preview table */ - *ftable, /* Filter table */ - *frame, /* Frame for preview */ - *scrollbar, /* Horizontal + vertical scroller */ - *button; /* Check Button */ - gint argc; /* Fake argc for GUI */ - gchar **argv; /* Fake argv for GUI */ - guchar *color_cube; /* Preview color cube... */ - gchar *plugin_name; - - /* - * Initialize the program's display... - */ + GtkWidget *dialog; + GtkWidget *main_vbox; + GtkWidget *hbox; + GtkWidget *vbox; + GtkWidget *table; + GtkWidget *ptable; + GtkWidget *frame; + GtkWidget *scrollbar; + GtkWidget *button; + GtkObject *adj; + gint argc; + gchar **argv; + guchar *color_cube; + gchar *plugin_name; argc = 1; argv = g_new (gchar *, 1); @@ -859,10 +903,6 @@ despeckle_dialog (void) gtk_widget_set_default_visual (gtk_preview_get_visual ()); gtk_widget_set_default_colormap (gtk_preview_get_cmap ()); - /* - * Dialog window... - */ - plugin_name = g_strdup_printf ("%s%s", _("Despeckle "), PLUG_IN_VERSION); dialog = gimp_dialog_new (plugin_name, "despeckle", @@ -883,25 +923,22 @@ despeckle_dialog (void) GTK_SIGNAL_FUNC (gtk_main_quit), NULL); - /* - * Top-level table for dialog... - */ + main_vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_vbox, + TRUE, TRUE, 0); + gtk_widget_show (main_vbox); - table = gtk_table_new (5, 3, FALSE); - gtk_table_set_col_spacings (GTK_TABLE (table), 4); - gtk_table_set_row_spacings (GTK_TABLE (table), 2); - gtk_container_set_border_width (GTK_CONTAINER (table), 6); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table, - FALSE, FALSE, 0); - gtk_widget_show (table); + hbox = gtk_hbox_new (FALSE, 4); + gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); /* * Preview window... */ ptable = gtk_table_new (2, 2, FALSE); - gtk_table_attach (GTK_TABLE (table), ptable, 0, 2, 0, 1, 0, 0, 0, 0); + gtk_box_pack_start (GTK_BOX (hbox), ptable, FALSE, FALSE, 0); gtk_widget_show(ptable); frame = gtk_frame_new (NULL); @@ -955,14 +992,17 @@ despeckle_dialog (void) * Filter type controls... */ - ftable = gtk_table_new (6, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (ftable), 4); - gtk_table_attach(GTK_TABLE(table), ftable, 2, 3, 0, 1, 0, 0, 0, 0); - gtk_widget_show(ftable); + frame = gtk_frame_new (_("Type")); + gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); + gtk_widget_show (frame); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); button = gtk_check_button_new_with_label (_("Adaptive")); - gtk_table_attach (GTK_TABLE (ftable), button, 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), (filter_type & FILTER_ADAPTIVE) ? TRUE : FALSE); gtk_signal_connect (GTK_OBJECT (button), "toggled", @@ -971,8 +1011,7 @@ despeckle_dialog (void) gtk_widget_show (button); button = gtk_check_button_new_with_label (_("Recursive")); - gtk_table_attach (GTK_TABLE (ftable), button, 0, 1, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), (filter_type & FILTER_RECURSIVE) ? TRUE : FALSE); gtk_signal_connect (GTK_OBJECT (button), "toggled", @@ -980,26 +1019,47 @@ despeckle_dialog (void) NULL); gtk_widget_show (button); + table = gtk_table_new (3, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0); + gtk_widget_show (table); + /* * Box size (radius) control... */ - dialog_create_ivalue (_("Radius:"), GTK_TABLE (table), 2, - &despeckle_radius, 1, MAX_RADIUS); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("Radius:"), 100, 0, + despeckle_radius, 1, MAX_RADIUS, 1, 5, 0, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (dialog_iscale_update), + &despeckle_radius); /* * Black level control... */ - dialog_create_ivalue (_("Black Level:"), GTK_TABLE (table), 3, - &black_level, 0, 256); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, + _("Black Level:"), 100, 0, + black_level, 0, 256, 1, 8, 0, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (dialog_iscale_update), + &black_level); /* * White level control... */ - dialog_create_ivalue (_("White Level:"), GTK_TABLE (table), 4, - &white_level, 0, 256); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, + _("White Level:"), 100, 0, + white_level, 0, 256, 1, 8, 0, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (dialog_iscale_update), + &white_level); /* * Show it and wait for the user to do something... @@ -1301,11 +1361,6 @@ preview_update (void) gdk_flush (); } - -/* - * 'preview_exit()' - Free all memory used by the preview window... - */ - static void preview_exit (void) { @@ -1314,144 +1369,21 @@ preview_exit (void) g_free (preview_sort); } - -/* - * 'dialog_create_ivalue()' - Create an integer value control... - */ - -static void -dialog_create_ivalue (char *title, /* I - Label for control */ - GtkTable *table, /* I - Table container to use */ - int row, /* I - Row # for container */ - gint *value, /* I - Value holder */ - int left, /* I - Minimum value for slider */ - int right) /* I - Maximum value for slider */ -{ - GtkWidget *label, /* Control label */ - *scale, /* Scale widget */ - *entry; /* Text widget */ - GtkObject *scale_data; /* Scale data */ - gchar buf[256]; /* String buffer */ - - /* - * Label... - */ - - label = gtk_label_new (title); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_table_attach (table, label, 0, 1, row, row + 1, - GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - /* - * Scale... - */ - - scale_data = gtk_adjustment_new (*value, left, right, 1.0, 1.0, 1.0); - - gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) dialog_iscale_update, - value); - - scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); - gtk_widget_set_usize (scale, SCALE_WIDTH, -1); - gtk_table_attach (table, scale, 1, 2, row, row + 1, - GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE); - gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_CONTINUOUS); - gtk_widget_show (scale); - - /* - * Text entry... - */ - - entry = gtk_entry_new (); - gtk_object_set_user_data (GTK_OBJECT (entry), scale_data); - gtk_object_set_user_data (scale_data, entry); - gtk_widget_set_usize (entry, ENTRY_WIDTH, -1); - g_snprintf (buf, sizeof (buf), "%d", *value); - gtk_entry_set_text (GTK_ENTRY (entry), buf); - gtk_signal_connect (GTK_OBJECT (entry), "changed", - (GtkSignalFunc) dialog_ientry_update, - value); - gtk_table_attach (GTK_TABLE (table), entry, 2, 3, row, row + 1, - GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (entry); -} - - -/* - * 'dialog_iscale_update()' - Update the value field using the scale. - */ - static void -dialog_iscale_update (GtkAdjustment *adjustment, /* I - New value */ - gint *value) /* I - Current value */ +dialog_iscale_update (GtkAdjustment *adjustment, + gint *value) { - GtkWidget *entry; /* Text entry widget */ - gchar buf[256]; /* Text buffer */ - - - if (*value != adjustment->value) - { - *value = adjustment->value; - - entry = gtk_object_get_user_data(GTK_OBJECT(adjustment)); - g_snprintf (buf, sizeof (buf), "%d", *value); - - gtk_signal_handler_block_by_data (GTK_OBJECT (entry), value); - gtk_entry_set_text (GTK_ENTRY (entry), buf); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (entry), value); - - if (value == &despeckle_radius) - preview_init (); - - preview_update (); - }; -} - + *value = adjustment->value; -/* - * 'dialog_ientry_update()' - Update the value field using the text entry. - */ + if (value == &despeckle_radius) + preview_init (); -static void -dialog_ientry_update (GtkWidget *widget, /* I - Entry widget */ - gint *value) /* I - Current value */ -{ - GtkAdjustment *adjustment; - gint new_value; - - new_value = atoi (gtk_entry_get_text (GTK_ENTRY (widget))); - - if (*value != new_value) - { - adjustment = gtk_object_get_user_data (GTK_OBJECT (widget)); - - if ((new_value >= adjustment->lower) && - (new_value <= adjustment->upper)) - { - *value = new_value; - adjustment->value = new_value; - - gtk_signal_emit_by_name (GTK_OBJECT (adjustment), "value_changed"); - - if (value == &despeckle_radius) - preview_init (); - - preview_update (); - }; - }; + preview_update (); } - -/* - * 'dialog_adaptive_callback()' - Update the filter type... - */ - static void -dialog_adaptive_callback (GtkWidget *widget, /* I - Toggle button */ - gpointer data) /* I - Data */ +dialog_adaptive_callback (GtkWidget *widget, + gpointer data) { if (GTK_TOGGLE_BUTTON (widget)->active) filter_type |= FILTER_ADAPTIVE; @@ -1461,14 +1393,9 @@ dialog_adaptive_callback (GtkWidget *widget, /* I - Toggle button */ preview_update (); } - -/* - * 'dialog_recursive_callback()' - Update the filter type... - */ - static void -dialog_recursive_callback (GtkWidget *widget, /* I - Toggle button */ - gpointer data) /* I - Data */ +dialog_recursive_callback (GtkWidget *widget, + gpointer data) { if (GTK_TOGGLE_BUTTON (widget)->active) filter_type |= FILTER_RECURSIVE; @@ -1478,14 +1405,9 @@ dialog_recursive_callback (GtkWidget *widget, /* I - Toggle button */ preview_update (); } - -/* - * 'dialog_ok_callback()' - Start the filter... - */ - static void -dialog_ok_callback (GtkWidget *widget, /* I - OK button widget */ - gpointer data) /* I - Dialog window */ +dialog_ok_callback (GtkWidget *widget, + gpointer data) { run_filter = TRUE; diff --git a/plug-ins/common/diffraction.c b/plug-ins/common/diffraction.c index d1b556000bdc5494a0747f3953cda270291b2be3..c3ce3ccc1314040d3b2408b90828d4fc5e7eab3a 100644 --- a/plug-ins/common/diffraction.c +++ b/plug-ins/common/diffraction.c @@ -33,500 +33,506 @@ #include -#include "libgimp/gimp.h" -#include "libgimp/gimpui.h" +#include +#include #include "libgimp/stdplugins-intl.h" /***** Magic numbers *****/ -#define ITERATIONS 100 /* 100 */ -#define WEIRD_FACTOR 0.04 /* 0.04 */ +#define ITERATIONS 100 +#define WEIRD_FACTOR 0.04 -#define PREVIEW_WIDTH 64 -#define PREVIEW_HEIGHT 64 -#define PROGRESS_WIDTH 32 -#define PROGRESS_HEIGHT 16 +#define PREVIEW_WIDTH 64 +#define PREVIEW_HEIGHT 64 +#define PROGRESS_WIDTH 32 +#define PROGRESS_HEIGHT 16 #define SCALE_WIDTH 150 /***** Types *****/ -typedef struct { - gdouble lam_r; - gdouble lam_g; - gdouble lam_b; - gdouble contour_r; - gdouble contour_g; - gdouble contour_b; - gdouble edges_r; - gdouble edges_g; - gdouble edges_b; - gdouble brightness; - gdouble scattering; - gdouble polarization; +typedef struct +{ + gdouble lam_r; + gdouble lam_g; + gdouble lam_b; + gdouble contour_r; + gdouble contour_g; + gdouble contour_b; + gdouble edges_r; + gdouble edges_g; + gdouble edges_b; + gdouble brightness; + gdouble scattering; + gdouble polarization; } diffraction_vals_t; -typedef struct { - GtkWidget *preview; - GtkWidget *progress; - guchar preview_row[PREVIEW_WIDTH * 3]; +typedef struct +{ + GtkWidget *preview; + GtkWidget *progress; + guchar preview_row[PREVIEW_WIDTH * 3]; - gint run; + gint run; } diffraction_interface_t; /***** Prototypes *****/ -static void query(void); -static void run(char *name, - int nparams, - GParam *param, - int *nreturn_vals, - GParam **return_vals); - -static void diffraction(GDrawable *drawable); +static void query (void); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); + +static void diffraction (GDrawable *drawable); + +static void diff_init_luts (void); +static void diff_diffract (gdouble x, + gdouble y, + gdouble *r, + gdouble *g, + gdouble *b); +static double diff_point (gdouble x, + gdouble y, + gdouble edges, + gdouble contours, + gdouble lam); +static double diff_intensity (gdouble x, + gdouble y, + gdouble lam); + +static gint diffraction_dialog (void); +static void dialog_update_preview (void); +static void dialog_update_callback (GtkWidget *widget, + gpointer data); +static void dialog_ok_callback (GtkWidget *widget, + gpointer data); -static void diff_init_luts(void); -static void diff_diffract(double x, double y, double *r, double *g, double *b); -static double diff_point(double x, double y, double edges, double contours, double lam); -static double diff_intensity(double x, double y, double lam); - -static gint diffraction_dialog(void); -static void dialog_update_preview(void); -static void dialog_create_value(char *title, GtkTable *table, int row, gdouble *value, double left, double right); -static void dialog_update_callback(GtkWidget *widget, gpointer data); -static void dialog_scale_update(GtkAdjustment *adjustment, gdouble *value); -static void dialog_close_callback(GtkWidget *widget, gpointer data); -static void dialog_ok_callback(GtkWidget *widget, gpointer data); -static void dialog_cancel_callback(GtkWidget *widget, gpointer data); +/***** Variables *****/ +GPlugInInfo PLUG_IN_INFO = +{ + NULL, /* init */ + NULL, /* quit */ + query, /* query */ + run /* run */ +}; -/***** Variables *****/ +static diffraction_vals_t dvals = +{ + 0.815, /* lam_r */ + 1.221, /* lam_g */ + 1.123, /* lam_b */ + 0.821, /* contour_r */ + 0.821, /* contour_g */ + 0.974, /* contour_b */ + 0.610, /* edges_r */ + 0.677, /* edges_g */ + 0.636, /* edges_b */ + 0.066, /* brightness */ + 37.126, /* scattering */ + -0.473 /* polarization */ +}; + +static diffraction_interface_t dint = +{ + NULL, /* preview */ + NULL, /* progress */ + { 0 }, /* preview_row */ + FALSE /* run */ +}; -GPlugInInfo PLUG_IN_INFO = { - NULL, /* init_proc */ - NULL, /* quit_proc */ - query, /* query_proc */ - run /* run_proc */ -}; /* PLUG_IN_INFO */ - -static diffraction_vals_t dvals = { - 0.815, /* lam_r */ - 1.221, /* lam_g */ - 1.123, /* lam_b */ - 0.821, /* contour_r */ - 0.821, /* contour_g */ - 0.974, /* contour_b */ - 0.610, /* edges_r */ - 0.677, /* edges_g */ - 0.636, /* edges_b */ - 0.066, /* brightness */ - 37.126, /* scattering */ - -0.473 /* polarization */ -}; /* dvals */ - -static diffraction_interface_t dint = { - NULL, /* preview */ - NULL, /* progress */ - { 0 }, /* preview_row */ - FALSE /* run */ -}; /* dint */ - -static double cos_lut[ITERATIONS + 1]; -static double param_lut1[ITERATIONS + 1]; -static double param_lut2[ITERATIONS + 1]; +static gdouble cos_lut[ITERATIONS + 1]; +static gdouble param_lut1[ITERATIONS + 1]; +static gdouble param_lut2[ITERATIONS + 1]; /***** Functions *****/ -/*****/ - MAIN() - -/*****/ - static void -query(void) +query (void) { - static GParamDef args[] = { - { PARAM_INT32, "run_mode", "Interactive, non-interactive" }, - { PARAM_IMAGE, "image", "Input image" }, - { PARAM_DRAWABLE, "drawable", "Input drawable" }, - { PARAM_FLOAT, "lam_r", "Light frequency (red)" }, - { PARAM_FLOAT, "lam_g", "Light frequency (green)" }, - { PARAM_FLOAT, "lam_b", "Light frequency (blue)" }, - { PARAM_FLOAT, "contour_r", "Number of contours (red)" }, - { PARAM_FLOAT, "contour_g", "Number of contours (green)" }, - { PARAM_FLOAT, "contour_b", "Number of contours (blue)" }, - { PARAM_FLOAT, "edges_r", "Number of sharp edges (red)" }, - { PARAM_FLOAT, "edges_g", "Number of sharp edges (green)" }, - { PARAM_FLOAT, "edges_b", "Number of sharp edges (blue)" }, - { PARAM_FLOAT, "brightness", "Brightness and shifting/fattening of contours" }, - { PARAM_FLOAT, "scattering", "Scattering (Speed vs. quality)" }, - { PARAM_FLOAT, "polarization", "Polarization" } - }; /* args */ - - static GParamDef *return_vals = NULL; - static int nargs = sizeof(args) / sizeof(args[0]); - static int nreturn_vals = 0; - - INIT_I18N(); - - gimp_install_procedure("plug_in_diffraction", - _("Generate diffraction patterns"), - _("Help? What help? Real men do not need help :-)"), /* FIXME */ - "Federico Mena Quintero", - "Federico Mena Quintero & David Bleecker", - "April 1997, 0.5", - N_("/Filters/Render/Pattern/Diffraction Patterns..."), - "RGB*", - PROC_PLUG_IN, - nargs, - nreturn_vals, - args, - return_vals); -} /* query */ - - -/*****/ + static GParamDef args[] = + { + { PARAM_INT32, "run_mode", "Interactive, non-interactive" }, + { PARAM_IMAGE, "image", "Input image" }, + { PARAM_DRAWABLE, "drawable", "Input drawable" }, + { PARAM_FLOAT, "lam_r", "Light frequency (red)" }, + { PARAM_FLOAT, "lam_g", "Light frequency (green)" }, + { PARAM_FLOAT, "lam_b", "Light frequency (blue)" }, + { PARAM_FLOAT, "contour_r", "Number of contours (red)" }, + { PARAM_FLOAT, "contour_g", "Number of contours (green)" }, + { PARAM_FLOAT, "contour_b", "Number of contours (blue)" }, + { PARAM_FLOAT, "edges_r", "Number of sharp edges (red)" }, + { PARAM_FLOAT, "edges_g", "Number of sharp edges (green)" }, + { PARAM_FLOAT, "edges_b", "Number of sharp edges (blue)" }, + { PARAM_FLOAT, "brightness", "Brightness and shifting/fattening of contours" }, + { PARAM_FLOAT, "scattering", "Scattering (Speed vs. quality)" }, + { PARAM_FLOAT, "polarization", "Polarization" } + }; + + static GParamDef *return_vals = NULL; + static gint nargs = sizeof(args) / sizeof(args[0]); + static gint nreturn_vals = 0; + + INIT_I18N(); + + gimp_install_procedure ("plug_in_diffraction", + _("Generate diffraction patterns"), + _("Help? What help? Real men do not need help :-)"), /* FIXME */ + "Federico Mena Quintero", + "Federico Mena Quintero & David Bleecker", + "April 1997, 0.5", + N_("/Filters/Render/Pattern/Diffraction Patterns..."), + "RGB*", + PROC_PLUG_IN, + nargs, + nreturn_vals, + args, + return_vals); +} static void -run(char *name, - int nparams, - GParam *param, - int *nreturn_vals, - GParam **return_vals) +run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals) { - static GParam values[1]; - - GDrawable *active_drawable; - GRunModeType run_mode; - GStatusType status; - - /* Initialize */ - - diff_init_luts(); - - status = STATUS_SUCCESS; - run_mode = param[0].data.d_int32; - - values[0].type = PARAM_STATUS; - values[0].data.d_status = status; - - *nreturn_vals = 1; - *return_vals = values; - - switch (run_mode) { - case RUN_INTERACTIVE: - /* Possibly retrieve data */ - - - INIT_I18N_UI(); - gimp_get_data("plug_in_diffraction", &dvals); + static GParam values[1]; - /* Get information from the dialog */ + GDrawable *active_drawable; + GRunModeType run_mode; + GStatusType status; - if (!diffraction_dialog()) - return; + /* Initialize */ - break; + diff_init_luts (); - case RUN_NONINTERACTIVE: - /* Make sure all the arguments are present */ + status = STATUS_SUCCESS; + run_mode = param[0].data.d_int32; - if (nparams != 15) - status = STATUS_CALLING_ERROR; + values[0].type = PARAM_STATUS; + values[0].data.d_status = status; - INIT_I18N(); - if (status == STATUS_SUCCESS) { - dvals.lam_r = param[3].data.d_float; - dvals.lam_g = param[4].data.d_float; - dvals.lam_b = param[5].data.d_float; - dvals.contour_r = param[6].data.d_float; - dvals.contour_g = param[7].data.d_float; - dvals.contour_b = param[8].data.d_float; - dvals.edges_r = param[9].data.d_float; - dvals.edges_g = param[10].data.d_float; - dvals.edges_b = param[11].data.d_float; - dvals.brightness = param[12].data.d_float; - dvals.scattering = param[13].data.d_float; - dvals.polarization = param[14].data.d_float; - } /* if */ + *nreturn_vals = 1; + *return_vals = values; - break; + switch (run_mode) + { + case RUN_INTERACTIVE: + INIT_I18N_UI(); - case RUN_WITH_LAST_VALS: - /* Possibly retrieve data */ + /* Possibly retrieve data */ + gimp_get_data ("plug_in_diffraction", &dvals); - INIT_I18N(); - gimp_get_data("plug_in_diffraction", &dvals); - break; + /* Get information from the dialog */ + if (!diffraction_dialog ()) + return; - default: - break; - } /* switch */ + break; - /* Get the active drawable */ + case RUN_NONINTERACTIVE: + INIT_I18N(); - active_drawable = gimp_drawable_get(param[2].data.d_drawable); + /* Make sure all the arguments are present */ + if (nparams != 15) + status = STATUS_CALLING_ERROR; - /* Create the diffraction pattern */ + if (status == STATUS_SUCCESS) + { + dvals.lam_r = param[3].data.d_float; + dvals.lam_g = param[4].data.d_float; + dvals.lam_b = param[5].data.d_float; + dvals.contour_r = param[6].data.d_float; + dvals.contour_g = param[7].data.d_float; + dvals.contour_b = param[8].data.d_float; + dvals.edges_r = param[9].data.d_float; + dvals.edges_g = param[10].data.d_float; + dvals.edges_b = param[11].data.d_float; + dvals.brightness = param[12].data.d_float; + dvals.scattering = param[13].data.d_float; + dvals.polarization = param[14].data.d_float; + } - if ((status == STATUS_SUCCESS) && gimp_drawable_is_rgb(active_drawable->id)) { - /* Set the tile cache size */ + break; - gimp_tile_cache_ntiles((active_drawable->width + gimp_tile_width() - 1) / gimp_tile_width()); + case RUN_WITH_LAST_VALS: + INIT_I18N(); - /* Run! */ + /* Possibly retrieve data */ + gimp_get_data ("plug_in_diffraction", &dvals); + break; - diffraction(active_drawable); + default: + break; + } - /* If run mode is interactive, flush displays */ + /* Get the active drawable */ + active_drawable = gimp_drawable_get (param[2].data.d_drawable); - if (run_mode != RUN_NONINTERACTIVE) - gimp_displays_flush(); + /* Create the diffraction pattern */ + if ((status == STATUS_SUCCESS) && gimp_drawable_is_rgb(active_drawable->id)) + { + /* Set the tile cache size */ + gimp_tile_cache_ntiles ((active_drawable->width + gimp_tile_width() - 1) / + gimp_tile_width()); - /* Store data */ + /* Run! */ + diffraction (active_drawable); - if (run_mode == RUN_INTERACTIVE) - gimp_set_data("plug_in_diffraction", &dvals, sizeof(diffraction_vals_t)); - } else if (status == STATUS_SUCCESS) - status = STATUS_EXECUTION_ERROR; + /* If run mode is interactive, flush displays */ + if (run_mode != RUN_NONINTERACTIVE) + gimp_displays_flush (); - values[0].data.d_status = status; + /* Store data */ + if (run_mode == RUN_INTERACTIVE) + gimp_set_data ("plug_in_diffraction", + &dvals, sizeof(diffraction_vals_t)); + } + else if (status == STATUS_SUCCESS) + status = STATUS_EXECUTION_ERROR; - gimp_drawable_detach(active_drawable); -} /* run */ + values[0].data.d_status = status; - -/*****/ + gimp_drawable_detach (active_drawable); +} static void -diffraction(GDrawable *drawable) +diffraction (GDrawable *drawable) { - GPixelRgn dest_rgn; - gpointer pr; - gint x1, y1, x2, y2; - gint width, height; - gint has_alpha; - gint row, col; - guchar *dest_row; - guchar *dest; - gint progress, max_progress; - double left, right, bottom, top; - double dhoriz, dvert; - double px, py; - double r, g, b; - - /* Get the mask bounds and image size */ + GPixelRgn dest_rgn; + gpointer pr; + gint x1, y1, x2, y2; + gint width, height; + gint has_alpha; + gint row, col; + guchar *dest_row; + guchar *dest; + gint progress, max_progress; + double left, right, bottom, top; + double dhoriz, dvert; + double px, py; + double r, g, b; - gimp_drawable_mask_bounds(drawable->id, &x1, &y1, &x2, &y2); + /* Get the mask bounds and image size */ - width = x2 - x1; - height = y2 - y1; + gimp_drawable_mask_bounds (drawable->id, &x1, &y1, &x2, &y2); - has_alpha = gimp_drawable_has_alpha(drawable->id); + width = x2 - x1; + height = y2 - y1; - /* Initialize pixel regions */ + has_alpha = gimp_drawable_has_alpha (drawable->id); - gimp_pixel_rgn_init(&dest_rgn, drawable, x1, y1, width, height, TRUE, TRUE); + /* Initialize pixel regions */ - progress = 0; - max_progress = width * height; + gimp_pixel_rgn_init (&dest_rgn, drawable, x1, y1, width, height, TRUE, TRUE); - gimp_progress_init( _("Creating diffraction pattern...")); + progress = 0; + max_progress = width * height; - /* Create diffraction pattern */ + gimp_progress_init (_("Creating diffraction pattern...")); - left = -5.0; - right = 5.0; - bottom = -5.0; - top = 5.0; + /* Create diffraction pattern */ - dhoriz = (right - left) / (width - 1); - dvert = (bottom - top) / (height - 1); + left = -5.0; + right = 5.0; + bottom = -5.0; + top = 5.0; - for (pr = gimp_pixel_rgns_register(1, &dest_rgn); - pr != NULL; pr = gimp_pixel_rgns_process(pr)) { - dest_row = dest_rgn.data; + dhoriz = (right - left) / (width - 1); + dvert = (bottom - top) / (height - 1); - py = top + dvert * (dest_rgn.y - y1); + for (pr = gimp_pixel_rgns_register (1, &dest_rgn); + pr != NULL; + pr = gimp_pixel_rgns_process (pr)) + { + dest_row = dest_rgn.data; - for (row = 0; row < dest_rgn.h; row++) { - dest = dest_row; + py = top + dvert * (dest_rgn.y - y1); - px = left + dhoriz * (dest_rgn.x - x1); + for (row = 0; row < dest_rgn.h; row++) + { + dest = dest_row; - for (col = 0; col < dest_rgn.w; col++) { - diff_diffract(px, py, &r, &g, &b); + px = left + dhoriz * (dest_rgn.x - x1); - *dest++ = 255.0 * r; - *dest++ = 255.0 * g; - *dest++ = 255.0 * b; + for (col = 0; col < dest_rgn.w; col++) + { + diff_diffract (px, py, &r, &g, &b); - if (has_alpha) - *dest++ = 255; + *dest++ = 255.0 * r; + *dest++ = 255.0 * g; + *dest++ = 255.0 * b; - px += dhoriz; - } /* for */ + if (has_alpha) + *dest++ = 255; - /* Update progress */ + px += dhoriz; + } - progress += dest_rgn.w; - gimp_progress_update((double) progress / max_progress); + /* Update progress */ - py += dvert; - dest_row += dest_rgn.rowstride; - } /* for */ - } /* for */ + progress += dest_rgn.w; + gimp_progress_update ((double) progress / max_progress); - gimp_drawable_flush(drawable); - gimp_drawable_merge_shadow(drawable->id, TRUE); - gimp_drawable_update(drawable->id, x1, y1, width, height); -} /* diffraction */ + py += dvert; + dest_row += dest_rgn.rowstride; + } + } + gimp_drawable_flush (drawable); + gimp_drawable_merge_shadow (drawable->id, TRUE); + gimp_drawable_update (drawable->id, x1, y1, width, height); +} static void -diff_init_luts(void) +diff_init_luts (void) { - int i; - double a; - double sina; - - a = -G_PI; + int i; + double a; + double sina; - for (i = 0; i <= ITERATIONS; i++) { - sina = sin(a); + a = -G_PI; - cos_lut[i] = cos(a); + for (i = 0; i <= ITERATIONS; i++) + { + sina = sin (a); - param_lut1[i] = 0.75 * sina; - param_lut2[i] = 0.5 * (4.0 * cos_lut[i] * cos_lut[i] + sina * sina); + cos_lut[i] = cos (a); - a += (2.0 * G_PI / ITERATIONS); - } /* for */ -} /* diff_init_luts */ + param_lut1[i] = 0.75 * sina; + param_lut2[i] = 0.5 * (4.0 * cos_lut[i] * cos_lut[i] + sina * sina); - -/*****/ + a += (2.0 * G_PI / ITERATIONS); + } +} static void -diff_diffract(double x, double y, double *r, double *g, double *b) +diff_diffract (double x, + double y, + double *r, + double *g, + double *b) { - *r = diff_point(x, y, dvals.edges_r, dvals.contour_r, dvals.lam_r); - *g = diff_point(x, y, dvals.edges_g, dvals.contour_g, dvals.lam_g); - *b = diff_point(x, y, dvals.edges_b, dvals.contour_b, dvals.lam_b); -} /* diff_diffract */ - - -/*****/ + *r = diff_point (x, y, dvals.edges_r, dvals.contour_r, dvals.lam_r); + *g = diff_point (x, y, dvals.edges_g, dvals.contour_g, dvals.lam_g); + *b = diff_point (x, y, dvals.edges_b, dvals.contour_b, dvals.lam_b); +} static double -diff_point(double x, double y, double edges, double contours, double lam) +diff_point (double x, + double y, + double edges, + double contours, + double lam) { - return fabs(edges * sin(contours * atan(dvals.brightness * diff_intensity(x, y, lam)))); -} /* diff_point */ - - -/*****/ + return fabs (edges * sin (contours * atan (dvals.brightness * + diff_intensity (x, y, lam)))); +} static double -diff_intensity(double x, double y, double lam) +diff_intensity (double x, + double y, + double lam) { - int i; - double cxy, sxy; - double param; - double polpi2; - double cospolpi2, sinpolpi2; + int i; + double cxy, sxy; + double param; + double polpi2; + double cospolpi2, sinpolpi2; - cxy = 0.0; - sxy = 0.0; + cxy = 0.0; + sxy = 0.0; - lam *= 4.0; + lam *= 4.0; - for (i = 0; i <= ITERATIONS; i++) { - param = lam * - (cos_lut[i] * x + - param_lut1[i] * y - - param_lut2[i]); + for (i = 0; i <= ITERATIONS; i++) + { + param = lam * + (cos_lut[i] * x + + param_lut1[i] * y - + param_lut2[i]); - cxy += cos(param); - sxy += sin(param); - } /* for */ + cxy += cos (param); + sxy += sin (param); + } - cxy *= WEIRD_FACTOR; - sxy *= WEIRD_FACTOR; + cxy *= WEIRD_FACTOR; + sxy *= WEIRD_FACTOR; - polpi2 = dvals.polarization * (G_PI / 2.0); + polpi2 = dvals.polarization * (G_PI / 2.0); - cospolpi2 = cos(polpi2); - sinpolpi2 = sin(polpi2); + cospolpi2 = cos (polpi2); + sinpolpi2 = sin (polpi2); - return dvals.scattering * ((cospolpi2 + sinpolpi2) * cxy * cxy + - (cospolpi2 - sinpolpi2) * sxy * sxy); -} /* diff_intensity */ + return dvals.scattering * ((cospolpi2 + sinpolpi2) * cxy * cxy + + (cospolpi2 - sinpolpi2) * sxy * sxy); +} #if 0 -/*****/ - static double -diff_intensity(double x, double y, double lam) +diff_intensity (double x, + double y, + double lam) { - int i; - double cxy, sxy; - double s; - double cosa, sina; - double twocosa, param; - double polpi2; - double cospolpi2, sinpolpi2; - - s = dvals.scattering; - cxy = 0.0; - sxy = 0.0; - - for (i = 0; i <= ITERATIONS; i++) { - cosa = cos_lut[i]; - sina = sin_lut[i]; - - twocosa = 2.0 * cosa; - - param = 4.0 * lam * - (cosa * x + - 0.75 * sina * y - - 0.5 * (twocosa * twocosa + sina * sina)); - - cxy += 0.04 * cos(param); - sxy += 0.04 * sin(param); - } /* for */ - - polpi2 = dvals.polarization * (G_PI / 2.0); - - cospolpi2 = cos(polpi2); - sinpolpi2 = sin(polpi2); - - return s * ((cospolpi2 + sinpolpi2) * cxy * cxy + - (cospolpi2 - sinpolpi2) * sxy * sxy); -} /* diff_intensity */ + int i; + double cxy, sxy; + double s; + double cosa, sina; + double twocosa, param; + double polpi2; + double cospolpi2, sinpolpi2; + + s = dvals.scattering; + cxy = 0.0; + sxy = 0.0; + + for (i = 0; i <= ITERATIONS; i++) + { + cosa = cos_lut[i]; + sina = sin_lut[i]; + + twocosa = 2.0 * cosa; + + param = 4.0 * lam * + (cosa * x + + 0.75 * sina * y - + 0.5 * (twocosa * twocosa + sina * sina)); + + cxy += 0.04 * cos (param); + sxy += 0.04 * sin (param); + } + + polpi2 = dvals.polarization * (G_PI / 2.0); + + cospolpi2 = cos (polpi2); + sinpolpi2 = sin (polpi2); + + return s * ((cospolpi2 + sinpolpi2) * cxy * cxy + + (cospolpi2 - sinpolpi2) * sxy * sxy); +} #endif - -/*****/ - static gint diffraction_dialog (void) { - GtkWidget *dialog; - GtkWidget *top_table; - GtkWidget *notebook; - GtkWidget *frame; - GtkWidget *vbox; - GtkWidget *table; - GtkWidget *label; - GtkWidget *button; - gint argc; - gchar **argv; - guchar *color_cube; + GtkWidget *dialog; + GtkWidget *top_table; + GtkWidget *notebook; + GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *table; + GtkWidget *label; + GtkWidget *button; + GtkObject *adj; + gint argc; + gchar **argv; + guchar *color_cube; #if 0 g_print ("Waiting... (pid %d)\n", getpid ()); @@ -558,273 +564,278 @@ diffraction_dialog (void) _("OK"), dialog_ok_callback, NULL, NULL, NULL, TRUE, FALSE, - _("Cancel"), dialog_cancel_callback, - NULL, NULL, NULL, FALSE, TRUE, + _("Cancel"), gtk_widget_destroy, + NULL, 1, NULL, FALSE, TRUE, NULL); gtk_signal_connect (GTK_OBJECT (dialog), "destroy", - GTK_SIGNAL_FUNC (dialog_close_callback), + GTK_SIGNAL_FUNC (gtk_main_quit), NULL); - top_table = gtk_table_new(2, 2, FALSE); - gtk_container_border_width(GTK_CONTAINER(top_table), 6); - gtk_table_set_row_spacings(GTK_TABLE(top_table), 4); - gtk_table_set_col_spacings(GTK_TABLE(top_table), 4); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), top_table, - FALSE, FALSE, 0); - gtk_widget_show(top_table); + top_table = gtk_table_new (2, 2, FALSE); + gtk_container_set_border_width(GTK_CONTAINER (top_table), 6); + gtk_table_set_row_spacings (GTK_TABLE (top_table), 4); + gtk_table_set_col_spacings (GTK_TABLE (top_table), 4); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), top_table, + FALSE, FALSE, 0); + gtk_widget_show (top_table); /* Preview */ - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_border_width(GTK_CONTAINER(vbox), 0); - gtk_table_attach(GTK_TABLE(top_table), vbox, 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show(vbox); - - frame = gtk_frame_new(NULL); - gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); - gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); - gtk_widget_show(frame); - - dint.preview = gtk_preview_new(GTK_PREVIEW_COLOR); - gtk_preview_size(GTK_PREVIEW(dint.preview), PREVIEW_WIDTH, PREVIEW_HEIGHT); - gtk_container_add(GTK_CONTAINER(frame), dint.preview); - gtk_widget_show(dint.preview); - - dint.progress = gtk_progress_bar_new(); - gtk_widget_set_usize(dint.progress, PROGRESS_WIDTH, PROGRESS_HEIGHT); - gtk_box_pack_start(GTK_BOX(vbox), dint.progress, TRUE, FALSE, 0); - gtk_widget_show(dint.progress); - - button = gtk_button_new_with_label( _("Preview!")); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - (GtkSignalFunc) dialog_update_callback, - NULL); - gtk_table_attach(GTK_TABLE(top_table), button, 0, 1, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show(button); + vbox = gtk_vbox_new (FALSE, 0); + gtk_table_attach (GTK_TABLE (top_table), vbox, 0, 1, 0, 1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (vbox); + + frame = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + dint.preview = gtk_preview_new (GTK_PREVIEW_COLOR); + gtk_preview_size (GTK_PREVIEW(dint.preview), PREVIEW_WIDTH, PREVIEW_HEIGHT); + gtk_container_add (GTK_CONTAINER (frame), dint.preview); + gtk_widget_show (dint.preview); + + dint.progress = gtk_progress_bar_new (); + gtk_widget_set_usize (dint.progress, PROGRESS_WIDTH, PROGRESS_HEIGHT); + gtk_box_pack_start (GTK_BOX (vbox), dint.progress, TRUE, FALSE, 0); + gtk_widget_show (dint.progress); + + button = gtk_button_new_with_label (_("Preview!")); + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (dialog_update_callback), + NULL); + gtk_table_attach (GTK_TABLE (top_table), button, 0, 1, 1, 2, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (button); /* Notebook */ - notebook = gtk_notebook_new(); - gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP); - gtk_table_attach(GTK_TABLE(top_table), notebook, 1, 2, 0, 2, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - gtk_widget_show(notebook); + notebook = gtk_notebook_new (); + gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP); + gtk_table_attach (GTK_TABLE (top_table), notebook, 1, 2, 0, 2, + GTK_EXPAND | GTK_FILL, 0, 0, 0); + gtk_widget_show (notebook); /* Frequencies tab */ - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_border_width(GTK_CONTAINER(vbox), 4); - - table = gtk_table_new(3, 2, FALSE); - gtk_container_border_width(GTK_CONTAINER(table), 0); - gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0); - gtk_widget_show(table); - - dialog_create_value( _("Red"), GTK_TABLE(table), 0, &dvals.lam_r, 0.0, 20.0); - dialog_create_value( _("Green"), GTK_TABLE(table), 1, &dvals.lam_g, 0.0, 20.0); - dialog_create_value( _("Blue"), GTK_TABLE(table), 2, &dvals.lam_b, 0.0, 20.0); - - label = gtk_label_new( _("Frequencies")); - gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label); - gtk_widget_show(vbox); + table = gtk_table_new (3, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_widget_show (table); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("Red:"), SCALE_WIDTH, 0, + dvals.lam_r, 0.0, 20.0, 0.2, 1.0, 3, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &dvals.lam_r); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, + _("Green:"), SCALE_WIDTH, 0, + dvals.lam_g, 0.0, 20.0, 0.2, 1.0, 3, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &dvals.lam_g); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, + _("Blue:"), SCALE_WIDTH, 0, + dvals.lam_b, 0.0, 20.0, 0.2, 1.0, 3, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &dvals.lam_b); + + label = gtk_label_new (_("Frequencies")); + gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, label); /* Contours tab */ - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_border_width(GTK_CONTAINER(vbox), 4); - - table = gtk_table_new(3, 2, FALSE); - gtk_container_border_width(GTK_CONTAINER(table), 0); - gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0); - gtk_widget_show(table); - - dialog_create_value( _("Red"), GTK_TABLE(table), 0, &dvals.contour_r, 0.0, 10.0); - dialog_create_value( _("Green"), GTK_TABLE(table), 1, &dvals.contour_g, 0.0, 10.0); - dialog_create_value( _("Blue"), GTK_TABLE(table), 2, &dvals.contour_b, 0.0, 10.0); - - label = gtk_label_new( _("Contours")); - gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label); - gtk_widget_show(vbox); + table = gtk_table_new (3, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_widget_show (table); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("Red:"), SCALE_WIDTH, 0, + dvals.contour_r, 0.0, 10.0, 0.1, 1.0, 3, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &dvals.contour_r); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, + _("Green:"), SCALE_WIDTH, 0, + dvals.contour_g, 0.0, 10.0, 0.1, 1.0, 3, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &dvals.contour_g); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, + _("Blue:"), SCALE_WIDTH, 0, + dvals.contour_b, 0.0, 10.0, 0.1, 1.0, 3, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &dvals.contour_b); + + label = gtk_label_new (_("Contours")); + gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, label); /* Sharp edges tab */ - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_border_width(GTK_CONTAINER(vbox), 4); - - table = gtk_table_new(3, 2, FALSE); - gtk_container_border_width(GTK_CONTAINER(table), 0); - gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0); - gtk_widget_show(table); - - dialog_create_value( _("Red"), GTK_TABLE(table), 0, &dvals.edges_r, 0.0, 1.0); - dialog_create_value( _("Green"), GTK_TABLE(table), 1, &dvals.edges_g, 0.0, 1.0); - dialog_create_value( _("Blue"), GTK_TABLE(table), 2, &dvals.edges_b, 0.0, 1.0); - - label = gtk_label_new( _("Sharp edges")); - gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label); - gtk_widget_show(vbox); + table = gtk_table_new (3, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_widget_show (table); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("Red:"), SCALE_WIDTH, 0, + dvals.edges_r, 0.0, 1.0, 0.01, 0.1, 3, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &dvals.edges_r); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, + _("Green:"), SCALE_WIDTH, 0, + dvals.edges_g, 0.0, 1.0, 0.01, 0.1, 3, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &dvals.edges_g); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, + _("Blue:"), SCALE_WIDTH, 0, + dvals.edges_b, 0.0, 1.0, 0.01, 0.1, 3, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &dvals.edges_b); + + label = gtk_label_new (_("Sharp edges")); + gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, label); /* Other options tab */ - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_border_width(GTK_CONTAINER(vbox), 4); - - table = gtk_table_new(3, 2, FALSE); - gtk_container_border_width(GTK_CONTAINER(table), 0); - gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0); - gtk_widget_show(table); - - dialog_create_value( _("Brightness"), GTK_TABLE(table), 0, &dvals.brightness, 0.0, 1.0); - dialog_create_value( _("Scattering"), GTK_TABLE(table), 1, &dvals.scattering, 0.0, 100.0); - dialog_create_value( _("Polarization"), GTK_TABLE(table), 2, &dvals.polarization, -1.0, 1.0); - - label = gtk_label_new( _("Other options")); - gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label); - gtk_widget_show(vbox); + table = gtk_table_new (3, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_widget_show (table); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("Brightness:"), SCALE_WIDTH, 0, + dvals.brightness, 0.0, 1.0, 0.01, 0.1, 3, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &dvals.brightness); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, + _("Scattering:"), SCALE_WIDTH, 0, + dvals.scattering, 0.0, 100.0, 1.0, 10.0, 3, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &dvals.scattering); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, + _("Polatization:"), SCALE_WIDTH, 0, + dvals.polarization, -1.0, 1.0, 0.02, 0.2, 3, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &dvals.polarization); + + label = gtk_label_new (_("Other options")); + gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, label); /* Done */ - gtk_widget_show(dialog); - dialog_update_preview(); + gtk_widget_show (dialog); + dialog_update_preview (); - gtk_main(); - gdk_flush(); + gtk_main (); + gdk_flush (); return dint.run; -} /* diffraction_dialog */ - - -/*****/ +} static void dialog_update_preview (void) { - double left, right, bottom, top; - double px, py; - double dx, dy; - double r, g, b; - int x, y; - guchar *p; - - left = -5.0; - right = 5.0; - bottom = -5.0; - top = 5.0; - - dx = (right - left) / (PREVIEW_WIDTH - 1); - dy = (bottom - top) / (PREVIEW_HEIGHT - 1); + double left, right, bottom, top; + double px, py; + double dx, dy; + double r, g, b; + int x, y; + guchar *p; - py = top; + left = -5.0; + right = 5.0; + bottom = -5.0; + top = 5.0; - for (y = 0; y < PREVIEW_HEIGHT; y++) { - px = left; - p = dint.preview_row; + dx = (right - left) / (PREVIEW_WIDTH - 1); + dy = (bottom - top) / (PREVIEW_HEIGHT - 1); - for (x = 0; x < PREVIEW_WIDTH; x++) { - diff_diffract(px, py, &r, &g, &b); + py = top; - *p++ = 255.0 * r; - *p++ = 255.0 * g; - *p++ = 255.0 * b; + for (y = 0; y < PREVIEW_HEIGHT; y++) + { + px = left; + p = dint.preview_row; - px += dx; - } /* for */ + for (x = 0; x < PREVIEW_WIDTH; x++) + { + diff_diffract (px, py, &r, &g, &b); - gtk_preview_draw_row(GTK_PREVIEW(dint.preview), dint.preview_row, 0, y, PREVIEW_WIDTH); + *p++ = 255.0 * r; + *p++ = 255.0 * g; + *p++ = 255.0 * b; - gtk_progress_bar_update(GTK_PROGRESS_BAR(dint.progress), (double) y / (PREVIEW_HEIGHT - 1)); + px += dx; + } - py += dy; - } /* for */ + gtk_preview_draw_row (GTK_PREVIEW (dint.preview), + dint.preview_row, 0, y, PREVIEW_WIDTH); - gtk_widget_draw(dint.preview, NULL); - gtk_progress_bar_update(GTK_PROGRESS_BAR(dint.progress), 0.0); - gdk_flush(); -} /* dialog_update_preview */ + gtk_progress_bar_update (GTK_PROGRESS_BAR (dint.progress), + (double) y / (PREVIEW_HEIGHT - 1)); + py += dy; + } -/*****/ + gtk_widget_draw (dint.preview, NULL); + gtk_progress_bar_update (GTK_PROGRESS_BAR (dint.progress), 0.0); + gdk_flush (); +} static void -dialog_create_value(char *title, GtkTable *table, int row, gdouble *value, double left, double right) +dialog_update_callback (GtkWidget *widget, + gpointer data) { - GtkWidget *label; - GtkWidget *scale; - GtkObject *scale_data; - - label = gtk_label_new(title); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 1.0); - gtk_table_attach(table, label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 4, 0); - gtk_widget_show(label); - - scale_data = gtk_adjustment_new(*value, left, right, - (right - left) / 50.0, - (right - left) / 100.0, - 0.0); - - scale = gtk_hscale_new(GTK_ADJUSTMENT(scale_data)); - gtk_widget_set_usize(scale, SCALE_WIDTH, 0); - gtk_table_attach(table, scale, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); - gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_TOP); - gtk_scale_set_digits(GTK_SCALE(scale), 3); - gtk_range_set_update_policy(GTK_RANGE(scale), GTK_UPDATE_CONTINUOUS); - gtk_signal_connect(GTK_OBJECT(scale_data), "value_changed", - (GtkSignalFunc) dialog_scale_update, - value); - - gtk_widget_show(scale); -} /* dialog_create_value */ - - -/*****/ - -static void -dialog_update_callback(GtkWidget *widget, gpointer data) -{ - dialog_update_preview(); -} /* dialog_update_callback */ - - -/*****/ - -static void -dialog_scale_update(GtkAdjustment *adjustment, gdouble *value) -{ - *value = adjustment->value; -} /* dialog_scale_update */ - - -/*****/ - -static void -dialog_close_callback(GtkWidget *widget, gpointer data) -{ - gtk_main_quit(); -} /* dialog_close_callback */ - - -/*****/ + dialog_update_preview (); +} static void -dialog_ok_callback(GtkWidget *widget, gpointer data) +dialog_ok_callback (GtkWidget *widget, + gpointer data) { - dint.run = TRUE; - gtk_widget_destroy(GTK_WIDGET(data)); -} /* dialog_ok_callback */ - - -/*****/ + dint.run = TRUE; -static void -dialog_cancel_callback(GtkWidget *widget, gpointer data) -{ - gtk_widget_destroy(GTK_WIDGET(data)); -} /* dialog_cancel_callback */ + gtk_widget_destroy (GTK_WIDGET (data)); +} diff --git a/plug-ins/common/jpeg.c b/plug-ins/common/jpeg.c index 17fa18d82d05250399a82a6b529c2979a0091e16..558e4c380de226442a49d0a508bc87608b1e2c5d 100644 --- a/plug-ins/common/jpeg.c +++ b/plug-ins/common/jpeg.c @@ -120,8 +120,8 @@ #include #include -#include "libgimp/gimp.h" -#include "libgimp/gimpui.h" +#include +#include #include "libgimp/stdplugins-intl.h" @@ -193,19 +193,19 @@ typedef void (*MenuItemCallback) (GtkWidget *widget, /* Declare local functions. */ static void query (void); -static void run (char *name, - int nparams, - GParam *param, - int *nreturn_vals, - GParam **return_vals); -static gint32 load_image (char *filename, - GRunModeType runmode, - int preview); -static gint save_image (char *filename, - gint32 image_ID, - gint32 drawable_ID, - gint32 orig_image_ID, - int preview); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); +static gint32 load_image (gchar *filename, + GRunModeType runmode, + gint preview); +static gint save_image (gchar *filename, + gint32 image_ID, + gint32 drawable_ID, + gint32 orig_image_ID, + gint preview); static void add_menu_item (GtkWidget *menu, char *label, @@ -1529,11 +1529,14 @@ static gint save_dialog (void) { GtkWidget *dlg; + GtkWidget *vbox; + GtkWidget *main_vbox; GtkWidget *label; GtkWidget *scale; GtkWidget *frame; GtkWidget *table; GtkWidget *toggle; + GtkWidget *abox; GtkObject *scale_data; GtkWidget *progressive; @@ -1553,7 +1556,6 @@ save_dialog (void) GtkWidget *vscrollbar; GtkWidget *prv_frame; - GtkWidget *prv_table; GDrawableType dtype; dlg = gimp_dialog_new (_("Save as Jpeg"), "jpeg", @@ -1572,28 +1574,35 @@ save_dialog (void) GTK_SIGNAL_FUNC (save_close_callback), NULL); + main_vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox, + TRUE, TRUE, 0); + gtk_widget_show (main_vbox); + /* sg - preview */ prv_frame = gtk_frame_new (_("Image Preview")); gtk_frame_set_shadow_type (GTK_FRAME (prv_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (prv_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), prv_frame, TRUE, TRUE, 0); - prv_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (prv_table), 10); - gtk_container_add (GTK_CONTAINER (prv_frame), prv_table); - - preview = gtk_check_button_new_with_label(_("Preview (in image window)")); - gtk_table_attach(GTK_TABLE(prv_table), preview, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - gtk_signal_connect(GTK_OBJECT(preview), "toggled", - (GtkSignalFunc) save_preview_toggle, NULL); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (preview), jsvals.preview); + gtk_box_pack_start (GTK_BOX (main_vbox), prv_frame, FALSE, FALSE, 0); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (prv_frame), vbox); + gtk_widget_show (vbox); + + preview = gtk_check_button_new_with_label (_("Preview (in Image Window)")); + gtk_box_pack_start (GTK_BOX (vbox), preview, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (preview), "toggled", + GTK_SIGNAL_FUNC (save_preview_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preview), jsvals.preview); gtk_widget_show (preview); preview_size = gtk_label_new (_("Size: unknown")); gtk_misc_set_alignment (GTK_MISC (preview_size), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (prv_table), preview_size, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + gtk_box_pack_start (GTK_BOX (vbox), preview_size, FALSE, FALSE, 0); gtk_widget_show (preview_size); - - gtk_widget_show (prv_table); + gtk_widget_show (prv_frame); make_preview (); @@ -1601,86 +1610,109 @@ save_dialog (void) /* parameter settings */ frame = gtk_frame_new (_("Parameter Settings")); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0); - table = gtk_table_new (8, 2, FALSE); - gtk_container_border_width (GTK_CONTAINER (table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); + + table = gtk_table_new (9, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); gtk_container_add (GTK_CONTAINER (frame), table); - label = gtk_label_new (_("Quality")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Quality:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.quality, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 0, 1, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.quality); - gtk_widget_show (label); gtk_widget_show (scale); - label = gtk_label_new (_("Smoothing")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Smoothing:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.smoothing, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 1, 2, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.smoothing); - gtk_widget_show (label); gtk_widget_show (scale); /* sg - have to init scale here */ - scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, 1, 64, 1, 1, 0.0); + scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, + 1, 64, 1, 1, 0.0); restart_markers_scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); - restart = gtk_check_button_new_with_label (_("Restart markers")); - gtk_table_attach (GTK_TABLE (table), restart, 0, 2, 2, 3, GTK_FILL, 0, 0, 0); + restart = gtk_check_button_new_with_label (_("Restart Markers")); + gtk_table_attach (GTK_TABLE (table), restart, 0, 1, 2, 3, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (restart), "toggled", - (GtkSignalFunc) save_restart_toggle_update, scale_data); + GTK_SIGNAL_FUNC (save_restart_toggle_update), + scale_data); gtk_widget_show (restart); - restart_markers_label = gtk_label_new (_("Restart frequency (rows)")); - gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + restart_markers_label = gtk_label_new (_("Restart Frequency (Rows):")); + gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (restart_markers_label); + + abox = gtk_alignment_new (0.5, 1.0, 1.0, 0.0); + gtk_table_attach (GTK_TABLE (table), abox, 1, 3, 2, 4, + GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_show (abox); gtk_widget_set_usize (restart_markers_scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), restart_markers_scale, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_container_add (GTK_CONTAINER (abox), restart_markers_scale); gtk_scale_set_value_pos (GTK_SCALE (restart_markers_scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (restart_markers_scale), 0); - gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), GTK_UPDATE_DELAYED); + gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), + GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_restart_update, + GTK_SIGNAL_FUNC (save_restart_update), restart); - gtk_widget_set_sensitive (restart_markers_label, (jsvals.restart ? TRUE : FALSE)); - gtk_widget_set_sensitive (restart_markers_scale, (jsvals.restart ? TRUE : FALSE)); - - gtk_widget_show (restart_markers_label); + gtk_widget_set_sensitive (restart_markers_label, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_set_sensitive (restart_markers_scale, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_show (restart_markers_scale); toggle = gtk_check_button_new_with_label (_("Optimize")); - gtk_table_attach (GTK_TABLE (table), toggle, 0, 2, 4, 5, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), toggle, 0, 3, 4, 5, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (toggle), "toggled", - (GtkSignalFunc)save_optimize_update, NULL); + GTK_SIGNAL_FUNC (save_optimize_update), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.optimize); - gtk_widget_show(toggle); + gtk_widget_show (toggle); progressive = gtk_check_button_new_with_label (_("Progressive")); - gtk_table_attach (GTK_TABLE (table), progressive, 0, 2, 5, 6, + gtk_table_attach (GTK_TABLE (table), progressive, 0, 3, 5, 6, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (progressive), "toggled", - (GtkSignalFunc)save_progressive_toggle, NULL); + GTK_SIGNAL_FUNC (save_progressive_toggle), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (progressive), jsvals.progressive); gtk_widget_show (progressive); @@ -1689,28 +1721,31 @@ save_dialog (void) gtk_widget_set_sensitive (progressive, FALSE); #endif - baseline = gtk_check_button_new_with_label (_("Force baseline JPEG (readable by all decoders)")); - gtk_table_attach (GTK_TABLE (table), baseline, 0, 2, 6, 7, + baseline = gtk_check_button_new_with_label (_("Force Baseline JPEG (Readable by all Decoders)")); + gtk_table_attach (GTK_TABLE (table), baseline, 0, 3, 6, 7, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (baseline), "toggled", - (GtkSignalFunc)save_baseline_toggle, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(baseline), + GTK_SIGNAL_FUNC (save_baseline_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (baseline), jsvals.baseline); - gtk_widget_show(baseline); + gtk_widget_show (baseline); /* build option menu (code taken from app/buildmenu.c) */ menu = gtk_menu_new (); - add_menu_item(menu, "2x2,1x1,1x1", 0, subsmp_callback); - add_menu_item(menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); - add_menu_item(menu, "1x1,1x1,1x1", 2, subsmp_callback); + add_menu_item (menu, "2x2,1x1,1x1", 0, subsmp_callback); + add_menu_item (menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); + add_menu_item (menu, "1x1,1x1,1x1", 2, subsmp_callback); subsmp_menu = gtk_option_menu_new (); - label = gtk_label_new (_("Subsampling")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), subsmp_menu, 1, 2, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("Subsampling:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 7, 8, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), subsmp_menu, 2, 3, 7, 8, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (subsmp_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (subsmp_menu), menu); @@ -1724,10 +1759,12 @@ save_dialog (void) dct_menu = gtk_option_menu_new (); - label = gtk_label_new (_("DCT method (speed/quality tradeoff)")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), dct_menu, 1, 2, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("DCT Method (Speed/Quality Tradeoff):")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 8, 9, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), dct_menu, 2, 3, 8, 9, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (dct_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (dct_menu), menu); @@ -1741,18 +1778,18 @@ save_dialog (void) com_frame = gtk_frame_new (_("Image Comments")); gtk_frame_set_shadow_type (GTK_FRAME (com_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (com_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), com_frame, TRUE, TRUE, 0); - com_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (com_table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), com_frame, TRUE, TRUE, 0); + + com_table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (com_table), 4); gtk_container_add (GTK_CONTAINER (com_frame), com_table); text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), TRUE); - gtk_widget_set_usize(text,-1,3); /* //HB: restrict to 3 line height - * to allow 800x600 mode */ + gtk_widget_set_usize (text, -1, 3); /* //HB: restrict to 3 line height + * to allow 800x600 mode */ if (image_comment) - gtk_text_insert(GTK_TEXT(text),NULL,NULL,NULL,image_comment,-1); + gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, image_comment, -1); gtk_table_attach (GTK_TABLE (com_table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); @@ -1786,7 +1823,6 @@ save_dialog (void) return jsint.run; } - /* Save interface functions */ static void @@ -1850,7 +1886,7 @@ save_restart_update (GtkAdjustment *adjustment, static void save_optimize_update (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.optimize = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1858,7 +1894,7 @@ save_optimize_update (GtkWidget *widget, static void save_progressive_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.progressive = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1866,7 +1902,7 @@ save_progressive_toggle (GtkWidget *widget, static void save_baseline_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.baseline = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1874,7 +1910,7 @@ save_baseline_toggle (GtkWidget *widget, static void save_preview_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.preview = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1882,7 +1918,7 @@ save_preview_toggle (GtkWidget *widget, static void subsmp_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.subsmp = *((guchar *)data); make_preview (); @@ -1890,7 +1926,7 @@ subsmp_callback (GtkWidget *widget, static void dct_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.dct = *((guchar *)data); make_preview (); diff --git a/plug-ins/common/png.c b/plug-ins/common/png.c index 756bda94f576f5fe3525052eaa24474cddccafb9..94a70c2fc51fe46c1c3cc086d7aec730f9ad4e4a 100644 --- a/plug-ins/common/png.c +++ b/plug-ins/common/png.c @@ -29,7 +29,6 @@ * run() - Run the plug-in... * load_image() - Load a PNG image into a new image window. * save_image() - Save the specified image to a PNG file. - * save_close_callback() - Close the save dialog window. * save_ok_callback() - Destroy the save dialog and save the image. * save_compression_callback() - Update the image compression level. * save_interlace_update() - Update the interlacing option. @@ -81,14 +80,26 @@ typedef struct */ static void query (void); -static void run (char *, int, GParam *, int *, GParam **); -static gint32 load_image (char *); -static gint save_image (char *, gint32, gint32, gint32); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); + +static gint32 load_image (gchar *filename); +static gint save_image (gchar *filename, + gint32 image_ID, + gint32 drawable_ID, + gint32 orig_image_ID); + static void init_gtk (void); static gint save_dialog (void); -static void save_ok_callback (GtkWidget *, gpointer); -static void save_compression_update (GtkAdjustment *, gpointer); -static void save_interlace_update (GtkWidget *, gpointer); +static void save_ok_callback (GtkWidget *widget, + gpointer data); +static void save_compression_update (GtkAdjustment *adjustment, + gpointer data); +static void save_interlace_update (GtkWidget *widget, + gpointer data); /* @@ -126,7 +137,7 @@ MAIN() static void query (void) { - static GParamDef load_args[] = + static GParamDef load_args[] = { { PARAM_INT32, "run_mode", "Interactive, non-interactive" }, { PARAM_STRING, "filename", "The name of the file to load" }, @@ -154,23 +165,31 @@ query (void) INIT_I18N (); gimp_install_procedure ("file_png_load", - _("Loads files in PNG file format"), - _("This plug-in loads Portable Network Graphics (PNG) files."), - "Michael Sweet , Daniel Skarda <0rfelyus@atrey.karlin.mff.cuni.cz>", - "Michael Sweet , Daniel Skarda <0rfelyus@atrey.karlin.mff.cuni.cz>, Nick Lamb ", - PLUG_IN_VERSION, - "/PNG", NULL, PROC_PLUG_IN, nload_args, nload_return_vals, - load_args, load_return_vals); - - gimp_install_procedure ("file_png_save", - "Saves files in PNG file format", - "This plug-in saves Portable Network Graphics (PNG) files.", - "Michael Sweet , Daniel Skarda <0rfelyus@atrey.karlin.mff.cuni.cz>", - "Michael Sweet , Daniel Skarda <0rfelyus@atrey.karlin.mff.cuni.cz>, Nick Lamb ", - PLUG_IN_VERSION, - "/PNG", "RGB*,GRAY*,INDEXED", PROC_PLUG_IN, nsave_args, 0, save_args, NULL); - - gimp_register_magic_load_handler ("file_png_load", "png", "", "0,string,\211PNG\r\n\032\n"); + _("Loads files in PNG file format"), + _("This plug-in loads Portable Network Graphics (PNG) files."), + "Michael Sweet , Daniel Skarda <0rfelyus@atrey.karlin.mff.cuni.cz>", + "Michael Sweet , Daniel Skarda <0rfelyus@atrey.karlin.mff.cuni.cz>, Nick Lamb ", + PLUG_IN_VERSION, + "/PNG", + NULL, + PROC_PLUG_IN, + nload_args, nload_return_vals, + load_args, load_return_vals); + + gimp_install_procedure ("file_png_save", + "Saves files in PNG file format", + "This plug-in saves Portable Network Graphics (PNG) files.", + "Michael Sweet , Daniel Skarda <0rfelyus@atrey.karlin.mff.cuni.cz>", + "Michael Sweet , Daniel Skarda <0rfelyus@atrey.karlin.mff.cuni.cz>, Nick Lamb ", + PLUG_IN_VERSION, + "/PNG", + "RGB*,GRAY*,INDEXED", + PROC_PLUG_IN, + nsave_args, 0, + save_args, NULL); + + gimp_register_magic_load_handler ("file_png_load", "png", "", + "0,string,\211PNG\r\n\032\n"); gimp_register_save_handler ("file_png_save", "png", ""); } @@ -180,10 +199,10 @@ query (void) */ static void -run (char *name, /* I - Name of filter program. */ - int nparams, /* I - Number of parameters passed in */ +run (gchar *name, /* I - Name of filter program. */ + gint nparams, /* I - Number of parameters passed in */ GParam *param, /* I - Parameter values */ - int *nreturn_vals, /* O - Number of return values */ + gint *nreturn_vals, /* O - Number of return values */ GParam **return_vals) /* O - Return values */ { gint32 image_ID; @@ -209,107 +228,110 @@ run (char *name, /* I - Name of filter program. */ */ if (strcmp (name, "file_png_load") == 0) - { - INIT_I18N (); + { + INIT_I18N (); - *nreturn_vals = 2; + *nreturn_vals = 2; - image_ID = load_image (param[1].data.d_string); + image_ID = load_image (param[1].data.d_string); - if (image_ID != -1) - { - values[1].type = PARAM_IMAGE; - values[1].data.d_image = image_ID; + if (image_ID != -1) + { + values[1].type = PARAM_IMAGE; + values[1].data.d_image = image_ID; + } + else + values[0].data.d_status = STATUS_EXECUTION_ERROR; } - else - values[0].data.d_status = STATUS_EXECUTION_ERROR; - } else if (strcmp (name, "file_png_save") == 0) - { - INIT_I18N_UI(); - - run_mode = param[0].data.d_int32; - image_ID = orig_image_ID = param[1].data.d_int32; - drawable_ID = param[2].data.d_int32; - *nreturn_vals = 1; - - /* eventually export the image */ - switch (run_mode) - { - case RUN_INTERACTIVE: - case RUN_WITH_LAST_VALS: - init_gtk (); - export = gimp_export_image (&image_ID, &drawable_ID, "PNG", - (CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED | CAN_HANDLE_ALPHA)); - if (export == EXPORT_CANCEL) - { - *nreturn_vals = 1; - values[0].data.d_status = STATUS_EXECUTION_ERROR; - return; - } - break; - default: - break; - } - - switch (run_mode) { - case RUN_INTERACTIVE : - /* - * Possibly retrieve data... - */ + INIT_I18N_UI(); + run_mode = param[0].data.d_int32; + image_ID = orig_image_ID = param[1].data.d_int32; + drawable_ID = param[2].data.d_int32; + *nreturn_vals = 1; + + /* eventually export the image */ + switch (run_mode) + { + case RUN_INTERACTIVE: + case RUN_WITH_LAST_VALS: + init_gtk (); + export = gimp_export_image (&image_ID, &drawable_ID, "PNG", + (CAN_HANDLE_RGB | + CAN_HANDLE_GRAY | + CAN_HANDLE_INDEXED | + CAN_HANDLE_ALPHA)); + if (export == EXPORT_CANCEL) + { + *nreturn_vals = 1; + values[0].data.d_status = STATUS_EXECUTION_ERROR; + return; + } + break; + default: + break; + } + + switch (run_mode) + { + case RUN_INTERACTIVE: + /* + * Possibly retrieve data... + */ gimp_get_data ("file_png_save", &pngvals); - /* - * Then acquire information with a dialog... - */ - + /* + * Then acquire information with a dialog... + */ if (!save_dialog()) - return; + goto finish; break; - case RUN_NONINTERACTIVE : - /* - * Make sure all the arguments are there! - */ - + case RUN_NONINTERACTIVE: + /* + * Make sure all the arguments are there! + */ if (nparams != 8) values[0].data.d_status = STATUS_CALLING_ERROR; else - { - pngvals.interlaced = param[5].data.d_int32; - pngvals.noextras = param[6].data.d_int32; - pngvals.compression_level = param[7].data.d_int32; - - if (pngvals.compression_level < 0 || - pngvals.compression_level > 9) - values[0].data.d_status = STATUS_CALLING_ERROR; - }; + { + pngvals.interlaced = param[5].data.d_int32; + pngvals.noextras = param[6].data.d_int32; + pngvals.compression_level = param[7].data.d_int32; + + if (pngvals.compression_level < 0 || + pngvals.compression_level > 9) + values[0].data.d_status = STATUS_CALLING_ERROR; + }; break; - case RUN_WITH_LAST_VALS : - /* - * Possibly retrieve data... - */ + case RUN_WITH_LAST_VALS : + /* + * Possibly retrieve data... + */ gimp_get_data ("file_png_save", &pngvals); break; - default : + default: break; - }; + }; + + if (values[0].data.d_status == STATUS_SUCCESS) + { + if (save_image (param[3].data.d_string, + image_ID, drawable_ID, orig_image_ID)) + gimp_set_data ("file_png_save", &pngvals, sizeof (pngvals)); + else + values[0].data.d_status = STATUS_EXECUTION_ERROR; + }; - if (values[0].data.d_status == STATUS_SUCCESS) - { - if (save_image (param[3].data.d_string, image_ID, drawable_ID, orig_image_ID)) - gimp_set_data ("file_png_save", &pngvals, sizeof (pngvals)); - else - values[0].data.d_status = STATUS_EXECUTION_ERROR; - }; + finish: - if (export == EXPORT_EXPORT) - gimp_image_delete (image_ID); - } + if (export == EXPORT_EXPORT) + gimp_image_delete (image_ID); + } else values[0].data.d_status = STATUS_EXECUTION_ERROR; } @@ -320,7 +342,7 @@ run (char *name, /* I - Name of filter program. */ */ static gint32 -load_image (char *filename) /* I - File to load */ +load_image (gchar *filename) /* I - File to load */ { int i, /* Looping var */ trns = 0, /* Transparency present */ @@ -632,7 +654,7 @@ load_image (char *filename) /* I - File to load */ */ static gint -save_image (char *filename, /* I - File to save to */ +save_image (gchar *filename, /* I - File to save to */ gint32 image_ID, /* I - Image to save */ gint32 drawable_ID, /* I - Current drawable */ gint32 orig_image_ID) /* I - Original image before export */ @@ -871,47 +893,32 @@ save_image (char *filename, /* I - File to save to */ return (1); } - -/* - * 'save_ok_callback()' - Destroy the save dialog and save the image. - */ - static void -save_ok_callback (GtkWidget *widget, /* I - OK button */ - gpointer data) /* I - Callback data */ +save_ok_callback (GtkWidget *widget, + gpointer data) { runme = TRUE; - gtk_widget_destroy(GTK_WIDGET(data)); + gtk_widget_destroy (GTK_WIDGET (data)); } - -/* - * 'save_compression_callback()' - Update the image compression level. - */ - static void -save_compression_update (GtkAdjustment *adjustment, /* I - Scale adjustment */ - gpointer data) /* I - Callback data */ +save_compression_update (GtkAdjustment *adjustment, + gpointer data) { - pngvals.compression_level = (gint32)adjustment->value; + pngvals.compression_level = (gint32) adjustment->value; } - -/* - * 'save_interlace_update()' - Update the interlacing option. - */ - static void -save_interlace_update (GtkWidget *widget, /* I - Interlace toggle button */ - gpointer data) /* I - Callback data */ +save_interlace_update (GtkWidget *widget, + gpointer data) { pngvals.interlaced = GTK_TOGGLE_BUTTON (widget)->active; } static void -save_noextras_update (GtkWidget *widget, /* I - Interlace toggle button */ - gpointer data) /* I - Callback data */ +save_noextras_update (GtkWidget *widget, + gpointer data) { pngvals.noextras = GTK_TOGGLE_BUTTON (widget)->active; } @@ -922,33 +929,24 @@ init_gtk (void) gchar **argv; gint argc; - argc = 1; - argv = g_new (gchar *, 1); + argc = 1; + argv = g_new (gchar *, 1); argv[0] = g_strdup ("png"); gtk_init (&argc, &argv); gtk_rc_parse (gimp_gtkrc ()); } - -/* - * 'save_dialog()' - Pop up the save dialog. - */ - static gint save_dialog (void) { - GtkWidget *dlg, /* Dialog window */ - *frame, /* Frame for dialog */ - *table, /* Table for dialog options */ - *toggle, /* Interlace toggle button */ - *label, /* Label for controls */ - *scale; /* Compression level scale */ - GtkObject *scale_data; /* Scale data */ - - /* - * Open a dialog window... - */ + GtkWidget *dlg; + GtkWidget *frame; + GtkWidget *table; + GtkWidget *toggle; + GtkWidget *label; + GtkWidget *scale; + GtkObject *scale_data; dlg = gimp_dialog_new (_("Save as PNG"), "png", gimp_plugin_help_func, "filters/png.html", @@ -966,59 +964,63 @@ save_dialog (void) GTK_SIGNAL_FUNC (gtk_main_quit), NULL); - /* - * Compression level, interlacing controls... - */ - frame = gtk_frame_new (_("Parameter Settings")); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); gtk_container_border_width (GTK_CONTAINER (frame), 6); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0); + gtk_widget_show (frame); table = gtk_table_new (2, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 4); gtk_table_set_row_spacings (GTK_TABLE (table), 2); - gtk_container_set_border_width(GTK_CONTAINER(table), 4); - gtk_container_add (GTK_CONTAINER(frame), table); - - toggle = gtk_check_button_new_with_label(_("Interlacing (Adam7)")); - gtk_table_attach(GTK_TABLE(table), toggle, 0, 2, 0, 1, GTK_FILL, 0, 0, 0); - gtk_signal_connect(GTK_OBJECT(toggle), "toggled", - (GtkSignalFunc)save_interlace_update, NULL); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), pngvals.interlaced); - gtk_widget_show(toggle); - - toggle = gtk_check_button_new_with_label(_("Skip ancillary chunks")); - gtk_table_attach(GTK_TABLE(table), toggle, 0, 2, 1, 2, GTK_FILL, 0, 0, 0); - gtk_signal_connect(GTK_OBJECT(toggle), "toggled", - (GtkSignalFunc)save_noextras_update, NULL); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), pngvals.noextras); - gtk_widget_show(toggle); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); + + toggle = gtk_check_button_new_with_label (_("Interlacing (Adam7)")); + gtk_table_attach (GTK_TABLE (table), toggle, 0, 2, 0, 1, + GTK_FILL, 0, 0, 0); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (save_interlace_update), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), pngvals.interlaced); + gtk_widget_show (toggle); + + toggle = gtk_check_button_new_with_label (_("Skip Ancillary Chunks")); + gtk_table_attach (GTK_TABLE (table), toggle, 0, 2, 1, 2, + GTK_FILL, 0, 0, 0); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (save_noextras_update), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), pngvals.noextras); + gtk_widget_show (toggle); label = gtk_label_new (_("Compression Level:")); - gtk_misc_set_alignment(GTK_MISC (label), 1.0, 1.0); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 0, 0); - - scale_data = gtk_adjustment_new(pngvals.compression_level, 1.0, 9.0, 1.0, 1.0, 0.0); - scale = gtk_hscale_new(GTK_ADJUSTMENT(scale_data)); - gtk_widget_set_usize(scale, SCALE_WIDTH, 0); - gtk_table_attach(GTK_TABLE(table), scale, 1, 2, 2, 3, GTK_FILL, 0, 0, 0); + gtk_widget_show (label); + + scale_data = gtk_adjustment_new (pngvals.compression_level, + 1.0, 9.0, 1.0, 1.0, 0.0); + scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); + gtk_widget_set_usize (scale, SCALE_WIDTH, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 2, 3, + GTK_FILL, 0, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); - gtk_scale_set_digits(GTK_SCALE (scale), 0); - gtk_range_set_update_policy(GTK_RANGE(scale), GTK_UPDATE_DELAYED); - gtk_signal_connect(GTK_OBJECT(scale_data), "value_changed", - (GtkSignalFunc)save_compression_update, NULL); - gtk_widget_show(label); - gtk_widget_show(scale); - gtk_widget_show(table); - gtk_widget_show(frame); - gtk_widget_show(dlg); - - gtk_main(); - gdk_flush(); - - return (runme); + gtk_scale_set_digits (GTK_SCALE (scale), 0); + gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); + gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", + GTK_SIGNAL_FUNC (save_compression_update), + NULL); + gtk_widget_show (scale); + + gtk_widget_show (dlg); + + gtk_main (); + gdk_flush (); + + return runme; } /* diff --git a/plug-ins/common/unsharp.c b/plug-ins/common/unsharp.c index d1718e0bd13a4ac9546a804b044134d9e87533c0..1c7beea0e32ede36bc555f1ee82b6314013a7eac 100644 --- a/plug-ins/common/unsharp.c +++ b/plug-ins/common/unsharp.c @@ -25,19 +25,20 @@ #include "config.h" #include -#include #include #include -#include "gtk/gtk.h" -#include "libgimp/gimp.h" -#include "libgimp/stdplugins-intl.h" +#include + +#include +#include +#include -#include "dialog_f.h" -#include "dialog_i.h" +#include "libgimp/stdplugins-intl.h" #define PLUG_IN_VERSION "0.10" +#define SCALE_WIDTH 150 /* to show both pretty unoptimized code and ugly optimized code blocks There's really no reason to define this, unless you want to see how @@ -49,770 +50,806 @@ plug-in takes to run */ /* #define TIMER */ #ifdef TIMER - #include - #include - static void timerstart(); - static void timerstop(); - static struct timeval time_start,time_stop; +#include +#include + +static void timerstart (void); +static void timerstop (void); +static struct timeval time_start, time_stop; #endif -typedef struct { - gdouble radius; - gdouble amount; - gint threshold; +typedef struct +{ + gdouble radius; + gdouble amount; + gint threshold; } UnsharpMaskParams; -typedef struct { - gint run; +typedef struct +{ + gint run; } UnsharpMaskInterface; /* local function prototypes */ -static inline void blur_line(gdouble* ctable, gdouble* cmatrix, gint cmatrix_length, - guchar* cur_col, guchar* dest_col, - gint y, glong bytes); -static int gen_convolve_matrix(double std_dev, double** cmatrix); -static gdouble* gen_lookup_table(gdouble* cmatrix, gint cmatrix_length); -static inline gint round2int(gdouble i); -static void unsharp_region (GPixelRgn srcPTR, GPixelRgn dstPTR, - gint width, gint height, gint bytes, - gdouble radius, gdouble amount, - gint x1, gint x2, gint y1, gint y2); - - - -static void query(void); -static void run (gchar *name, - gint nparams, - GParam *param, - gint *nreturn_vals, - GParam **return_vals); -static void unsharp_mask(GDrawable *drawable, gint radius, gdouble amount); - - -static void unsharp_cancel_callback (GtkWidget *widget, gpointer data); -static void unsharp_ok_callback (GtkWidget *widget, gpointer data); -static gint unsharp_mask_dialog(); +static void query (void); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); + +static inline void blur_line (gdouble *ctable, + gdouble *cmatrix, + gint cmatrix_length, + guchar *cur_col, + guchar *dest_col, + gint y, + glong bytes); +static int gen_convolve_matrix (gdouble std_dev, + gdouble **cmatrix); +static gdouble* gen_lookup_table (gdouble* cmatrix, + gint cmatrix_length); +static void unsharp_region (GPixelRgn srcPTR, + GPixelRgn dstPTR, + gint width, + gint height, + gint bytes, + gdouble radius, + gdouble amount, + gint x1, + gint x2, + gint y1, + gint y2); + +static void unsharp_mask (GDrawable *drawable, + gint radius, + gdouble amount); + +static void unsharp_ok_callback (GtkWidget *widget, + gpointer data); +static gint unsharp_mask_dialog (void); + /* preview shit -- not finished yet */ #undef PREVIEW #ifdef PREVIEW -static void preview_scroll_callback(void); -static void preview_init(void); -static void preview_exit(void); -static void preview_update(void); -static void dialog_create_ivalue(char *title, /* I - Label for control */ - GtkTable *table, /* I - Table container to use */ - int row, /* I - Row # for container */ - gint *value, /* I - Value holder */ - int left, /* I - Minimum value for slider */ - int right); /* I - Maximum value for slider */ - +static void preview_scroll_callback (void); +static void preview_init (void); +static void preview_exit (void); +static void preview_update (void); static GtkWidget* preview; -static int preview_width; /* Width of preview widget */ -static int preview_height; /* Height of preview widget */ -static int preview_x1; /* Upper-left X of preview */ -static int preview_y1; /* Upper-left Y of preview */ -static int preview_x2; /* Lower-right X of preview */ -static int preview_y2; /* Lower-right Y of preview */ - -static int sel_width; /* Selection width */ -static int sel_height; /* Selection height */ +static int preview_width; /* Width of preview widget */ +static int preview_height; /* Height of preview widget */ +static int preview_x1; /* Upper-left X of preview */ +static int preview_y1; /* Upper-left Y of preview */ +static int preview_x2; /* Lower-right X of preview */ +static int preview_y2; /* Lower-right Y of preview */ + +static int sel_width; /* Selection width */ +static int sel_height; /* Selection height */ static GtkObject *hscroll_data; /* Horizontal scrollbar data */ static GtkObject *vscroll_data; /* Vertical scrollbar data */ #endif -static gint run_filter = FALSE; +static gint run_filter = FALSE; - /* create a few globals, set default values */ static UnsharpMaskParams unsharp_params = { - 5.0, /* default radius = 5 */ - 0.5, /* default amount = .5 */ - 0 /* default threshold = 0 */ + 5.0, /* default radius = 5 */ + 0.5, /* default amount = .5 */ + 0 /* default threshold = 0 */ }; /* static UnsharpMaskInterface umint = { FALSE }; */ /* Setting PLUG_IN_INFO */ -GPlugInInfo PLUG_IN_INFO = { - NULL, /* init_proc */ - NULL, /* quit_proc */ - query, /* query_proc */ - run, /* run_proc */ +GPlugInInfo PLUG_IN_INFO = +{ + NULL, /* init_proc */ + NULL, /* quit_proc */ + query, /* query_proc */ + run, /* run_proc */ }; +MAIN () -MAIN() - - -static void query () { - - static GParamDef args[] = { - { PARAM_INT32, "run_mode", "Interactive, non-interactive" }, - { PARAM_IMAGE, "image", "(unused)" }, - { PARAM_DRAWABLE, "drawable", "Drawable to draw on" }, - { PARAM_FLOAT, "radius", "Radius of gaussian blur (in pixels > 1.0)" }, - { PARAM_FLOAT, "amount", "Strength of effect" }, - { PARAM_FLOAT, "threshold", "Threshold" } - }; - static gint nargs = sizeof(args) / sizeof(args[0]); - /* for return vals */ - static GParamDef *return_vals = NULL; - static int nreturn_vals = 0; +static void +query (void) +{ + static GParamDef args[] = + { + { PARAM_INT32, "run_mode", "Interactive, non-interactive" }, + { PARAM_IMAGE, "image", "(unused)" }, + { PARAM_DRAWABLE, "drawable", "Drawable to draw on" }, + { PARAM_FLOAT, "radius", "Radius of gaussian blur (in pixels > 1.0)" }, + { PARAM_FLOAT, "amount", "Strength of effect" }, + { PARAM_FLOAT, "threshold", "Threshold" } + }; + static gint nargs = sizeof(args) / sizeof(args[0]); + /* for return vals */ + static GParamDef *return_vals = NULL; + static int nreturn_vals = 0; - INIT_I18N(); - - /* Install a procedure in the procedure database. */ - gimp_install_procedure ("plug_in_unsharp_mask", - _("An unsharp mask filter"), - "", - "Winston Chang ", - "Winston Chang", - "1999", - N_("/Filters/Enhance/Unsharp Mask..."), - "GRAY*, RGB*", - PROC_PLUG_IN, - nargs, nreturn_vals, - args, return_vals); + INIT_I18N(); + + /* Install a procedure in the procedure database. */ + gimp_install_procedure ("plug_in_unsharp_mask", + _("An unsharp mask filter"), + "", + "Winston Chang ", + "Winston Chang", + "1999", + N_("/Filters/Enhance/Unsharp Mask..."), + "GRAY*, RGB*", + PROC_PLUG_IN, + nargs, nreturn_vals, + args, return_vals); } - /* this is the actual function */ -static void run(char *name, int nparams, GParam *param, int *nreturn_vals, - GParam **return_vals) { - - static GParam values[1]; - GDrawable *drawable; - GRunModeType run_mode; - GStatusType status = STATUS_SUCCESS; - -#ifdef TIMER - timerstart(); -#endif - - run_mode = param[0].data.d_int32; - - values[0].type = PARAM_STATUS; - values[0].data.d_status = status; - *return_vals = values; - *nreturn_vals = 1; - - INIT_I18N_UI(); - - switch (run_mode) { - case RUN_INTERACTIVE: - gimp_get_data ("plug_in_unsharp_mask", &unsharp_params); - if (! unsharp_mask_dialog ()) return; - break; - - case RUN_NONINTERACTIVE: - if (nparams != 6) status = STATUS_CALLING_ERROR; - /* get the parameters */ - else if (status == STATUS_SUCCESS) { - unsharp_params.radius = param[3].data.d_float; - unsharp_params.amount = param[4].data.d_float; - unsharp_params.threshold = param[5].data.d_int32; - - /* make sure there are legal values */ - if ( (unsharp_params.radius < 0.0) || - (unsharp_params.amount<0.0) ) - status = STATUS_CALLING_ERROR; - } - break; - - case RUN_WITH_LAST_VALS: - gimp_get_data ("plug_in_unsharp_mask", &unsharp_params); - break; - - default: - break; - } - - if (status == STATUS_SUCCESS) { - drawable = gimp_drawable_get (param[2].data.d_drawable); - gimp_tile_cache_ntiles(2 * (drawable->width / gimp_tile_width() + 1)); - - /* here we go */ - unsharp_mask(drawable, unsharp_params.radius, unsharp_params.amount); - - /* values[0].data.d_status = status; */ - gimp_displays_flush (); - - /* set data for next use of filter */ - gimp_set_data ("plug_in_unsharp_mask", &unsharp_params, - sizeof (UnsharpMaskParams)); - - /*fprintf(stderr, "%f %f\n", unsharp_params.radius, unsharp_params.amount);*/ - - gimp_drawable_detach(drawable); - values[0].data.d_status = status; +static void +run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals) +{ + static GParam values[1]; + GDrawable *drawable; + GRunModeType run_mode; + GStatusType status = STATUS_SUCCESS; - } #ifdef TIMER - timerstop(); + timerstart(); #endif -} + run_mode = param[0].data.d_int32; + + values[0].type = PARAM_STATUS; + values[0].data.d_status = status; + *return_vals = values; + *nreturn_vals = 1; + + INIT_I18N_UI(); + + switch (run_mode) + { + case RUN_INTERACTIVE: + gimp_get_data ("plug_in_unsharp_mask", &unsharp_params); + if (! unsharp_mask_dialog ()) return; + break; + + case RUN_NONINTERACTIVE: + if (nparams != 6) + status = STATUS_CALLING_ERROR; + /* get the parameters */ + else if (status == STATUS_SUCCESS) + { + unsharp_params.radius = param[3].data.d_float; + unsharp_params.amount = param[4].data.d_float; + unsharp_params.threshold = param[5].data.d_int32; + + /* make sure there are legal values */ + if ((unsharp_params.radius < 0.0) || + (unsharp_params.amount<0.0)) + status = STATUS_CALLING_ERROR; + } + break; + case RUN_WITH_LAST_VALS: + gimp_get_data ("plug_in_unsharp_mask", &unsharp_params); + break; -/* -------------------------- Unsharp Mask ------------------------- */ -static void unsharp_mask(GDrawable *drawable, gint radius, gdouble amount) { - GPixelRgn srcPR, destPR; - glong width, height; - glong bytes; - gint x1, y1, x2, y2; - gdouble* cmatrix = NULL; - gint cmatrix_length; - gdouble* ctable; - - /* Get the input */ - gimp_drawable_mask_bounds(drawable->id, &x1, &y1, &x2, &y2); - gimp_progress_init(_("Blurring...")); - - /* generate convolution matrix */ - cmatrix_length = gen_convolve_matrix(radius, &cmatrix); - /* generate lookup table */ - ctable = gen_lookup_table(cmatrix, cmatrix_length); + default: + break; + } + if (status == STATUS_SUCCESS) + { + drawable = gimp_drawable_get (param[2].data.d_drawable); + gimp_tile_cache_ntiles(2 * (drawable->width / gimp_tile_width() + 1)); - width = drawable->width; - height = drawable->height; - bytes = drawable->bpp; + /* here we go */ + unsharp_mask (drawable, unsharp_params.radius, unsharp_params.amount); - /* initialize pixel regions */ - gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE); - gimp_pixel_rgn_init (&destPR, drawable, 0, 0, width, height, TRUE, TRUE); + /* values[0].data.d_status = status; */ + gimp_displays_flush (); + /* set data for next use of filter */ + gimp_set_data ("plug_in_unsharp_mask", &unsharp_params, + sizeof (UnsharpMaskParams)); - unsharp_region (srcPR, destPR, width, height, bytes, radius, amount, - x1, x2, y1, y2); + /*fprintf(stderr, "%f %f\n", unsharp_params.radius, unsharp_params.amount);*/ - - gimp_drawable_flush(drawable); - gimp_drawable_merge_shadow(drawable->id, TRUE); - gimp_drawable_update(drawable->id, x1, y1, (x2-x1), (y2-y1)); + gimp_drawable_detach(drawable); + values[0].data.d_status = status; + } +#ifdef TIMER + timerstop (); +#endif } - +/* -------------------------- Unsharp Mask ------------------------- */ +static void +unsharp_mask (GDrawable *drawable, + gint radius, + gdouble amount) +{ + GPixelRgn srcPR, destPR; + glong width, height; + glong bytes; + gint x1, y1, x2, y2; + gdouble* cmatrix = NULL; + gint cmatrix_length; + gdouble* ctable; + + /* Get the input */ + gimp_drawable_mask_bounds(drawable->id, &x1, &y1, &x2, &y2); + gimp_progress_init(_("Blurring...")); + + /* generate convolution matrix */ + cmatrix_length = gen_convolve_matrix(radius, &cmatrix); + /* generate lookup table */ + ctable = gen_lookup_table(cmatrix, cmatrix_length); + + width = drawable->width; + height = drawable->height; + bytes = drawable->bpp; + + /* initialize pixel regions */ + gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE); + gimp_pixel_rgn_init (&destPR, drawable, 0, 0, width, height, TRUE, TRUE); + + unsharp_region (srcPR, destPR, width, height, bytes, radius, amount, + x1, x2, y1, y2); + + gimp_drawable_flush(drawable); + gimp_drawable_merge_shadow(drawable->id, TRUE); + gimp_drawable_update(drawable->id, x1, y1, (x2-x1), (y2-y1)); +} /* perform an unsharp mask on the region, given a source region, dest. region, width and height of the regions, and corner coordinates of a subregion to act upon. Everything outside the subregion is unaffected. */ -static void unsharp_region (GPixelRgn srcPR, GPixelRgn destPR, - gint width, gint height, gint bytes, - gdouble radius, gdouble amount, - gint x1, gint x2, gint y1, gint y2) { - guchar* cur_col; - guchar* dest_col; - guchar* cur_row; - guchar* dest_row; - gint x; - gint y; - gdouble* cmatrix = NULL; - gint cmatrix_length; - gdouble* ctable; - - gint row, col; /* these are counters for loops */ - - /* these are used for the merging step */ - gint threshold; - gint diff; - gint value; - gint u,v; - - /* find height and width of subregion to act on */ - x = x2-x1; - y = y2-y1; - - - /* generate convolution matrix and make sure it's smaller than each dimension */ - cmatrix_length = gen_convolve_matrix(radius, &cmatrix); - /* generate lookup table */ - ctable = gen_lookup_table(cmatrix, cmatrix_length); - - - - /* allocate row buffers */ - cur_row = (guchar *) g_malloc (x * bytes); - dest_row = (guchar *) g_malloc (x * bytes); - - /* find height and width of subregion to act on */ - x = x2-x1; - y = y2-y1; - - /* blank out a region of the destination memory area, I think */ - for (row = 0; row < y; row++) { - gimp_pixel_rgn_get_row(&destPR, dest_row, x1, y1+row, (x2-x1)); - memset(dest_row, 0, x*bytes); - gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y1+row, (x2-x1)); - } - - - /* blur the rows */ - for (row = 0; row < y; row++) { - gimp_pixel_rgn_get_row(&srcPR, cur_row, x1, y1+row, x); - gimp_pixel_rgn_get_row(&destPR, dest_row, x1, y1+row, x); - blur_line(ctable, cmatrix, cmatrix_length, cur_row, dest_row, x, bytes); - gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y1+row, x); - - if (row%5 == 0) gimp_progress_update((gdouble)row/(3*y)); - } - - - /* allocate column buffers */ - cur_col = (guchar *) g_malloc (y * bytes); - dest_col = (guchar *) g_malloc (y * bytes); - - /* blur the cols */ - for (col = 0; col < x; col++) { - gimp_pixel_rgn_get_col(&destPR, cur_col, x1+col, y1, y); - gimp_pixel_rgn_get_col(&destPR, dest_col, x1+col, y1, y); - blur_line(ctable, cmatrix, cmatrix_length, cur_col, dest_col, y, bytes); - gimp_pixel_rgn_set_col(&destPR, dest_col, x1+col, y1, y); - - if (col%5 == 0) gimp_progress_update((gdouble)col/(3*x) + 0.33); - } - - gimp_progress_init(_("Merging...")); - - /* find integer value of threshold */ - threshold = unsharp_params.threshold; +static void +unsharp_region (GPixelRgn srcPR, + GPixelRgn destPR, + gint width, + gint height, + gint bytes, + gdouble radius, + gdouble amount, + gint x1, + gint x2, + gint y1, + gint y2) +{ + guchar* cur_col; + guchar* dest_col; + guchar* cur_row; + guchar* dest_row; + gint x; + gint y; + gdouble* cmatrix = NULL; + gint cmatrix_length; + gdouble* ctable; + + gint row, col; /* these are counters for loops */ + + /* these are used for the merging step */ + gint threshold; + gint diff; + gint value; + gint u,v; + + /* find height and width of subregion to act on */ + x = x2-x1; + y = y2-y1; + + /* generate convolution matrix and make sure it's smaller than each dimension */ + cmatrix_length = gen_convolve_matrix(radius, &cmatrix); + /* generate lookup table */ + ctable = gen_lookup_table(cmatrix, cmatrix_length); + + /* allocate row buffers */ + cur_row = (guchar *) g_malloc (x * bytes); + dest_row = (guchar *) g_malloc (x * bytes); + + /* find height and width of subregion to act on */ + x = x2-x1; + y = y2-y1; + + /* blank out a region of the destination memory area, I think */ + for (row = 0; row < y; row++) + { + gimp_pixel_rgn_get_row(&destPR, dest_row, x1, y1+row, (x2-x1)); + memset(dest_row, 0, x*bytes); + gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y1+row, (x2-x1)); + } + + /* blur the rows */ + for (row = 0; row < y; row++) + { + gimp_pixel_rgn_get_row(&srcPR, cur_row, x1, y1+row, x); + gimp_pixel_rgn_get_row(&destPR, dest_row, x1, y1+row, x); + blur_line(ctable, cmatrix, cmatrix_length, cur_row, dest_row, x, bytes); + gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y1+row, x); + + if (row%5 == 0) + gimp_progress_update((gdouble)row/(3*y)); + } + + /* allocate column buffers */ + cur_col = (guchar *) g_malloc (y * bytes); + dest_col = (guchar *) g_malloc (y * bytes); + + /* blur the cols */ + for (col = 0; col < x; col++) + { + gimp_pixel_rgn_get_col(&destPR, cur_col, x1+col, y1, y); + gimp_pixel_rgn_get_col(&destPR, dest_col, x1+col, y1, y); + blur_line(ctable, cmatrix, cmatrix_length, cur_col, dest_col, y, bytes); + gimp_pixel_rgn_set_col(&destPR, dest_col, x1+col, y1, y); + + if (col%5 == 0) + gimp_progress_update((gdouble)col/(3*x) + 0.33); + } + + gimp_progress_init(_("Merging...")); + + /* find integer value of threshold */ + threshold = unsharp_params.threshold; - /* merge the source and destination (which currently contains - the blurred version) images */ - for (row = 0; row < y; row++) { - value = 0; - /* get source row */ - gimp_pixel_rgn_get_row(&srcPR, cur_row, x1, y1+row, x); - /* get dest row */ - gimp_pixel_rgn_get_row(&destPR, dest_row, x1, y1+row, x); - /* combine the two */ - for (u=0; u 255) dest_row[u*bytes+v] = 255; - else dest_row[u*bytes+v] = value; - } - } - /* update progress bar every five rows */ - if (row%5 == 0) gimp_progress_update((gdouble)row/(3*y) + 0.67); - gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y1+row, x); + if (value < 0) dest_row[u*bytes+v] =0; + else if (value > 255) dest_row[u*bytes+v] = 255; + else dest_row[u*bytes+v] = value; + } } - - /* free the memory we took */ - g_free(cur_row); - g_free(dest_row); - g_free(cur_col); - g_free(dest_col); - + /* update progress bar every five rows */ + if (row%5 == 0) gimp_progress_update((gdouble)row/(3*y) + 0.67); + gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y1+row, x); + } + + /* free the memory we took */ + g_free(cur_row); + g_free(dest_row); + g_free(cur_col); + g_free(dest_col); } /* this function is written as if it is blurring a column at a time, even though it can operate on rows, too. There is no difference in the processing of the lines, at least to the blur_line function. */ -static inline void blur_line(gdouble* ctable, gdouble* cmatrix, - gint cmatrix_length, - guchar* cur_col, guchar* dest_col, - gint y, glong bytes) { - - +static inline void +blur_line (gdouble *ctable, + gdouble *cmatrix, + gint cmatrix_length, + guchar *cur_col, + guchar *dest_col, + gint y, + glong bytes) +{ #ifdef READABLE_CODE /* ------------- semi-readable code ------------------- */ - gdouble scale; - gdouble sum; - gint i,j; - gint row; - - - /* this is to take care cases in which the matrix can go over - * both edges at once. It's not efficient, but this can only - * happen in small pictures anyway. - */ - if (cmatrix_length > y) { - - for (row = 0; row < y ; row++) { - scale=0; - /* find the scale factor */ - for (j = 0; j < y ; j++) { - /* if the index is in bounds, add it to the scale counter */ - if ((j + cmatrix_length/2 - row >= 0) && - (j + cmatrix_length/2 - row < cmatrix_length)) - scale += cmatrix[j + cmatrix_length/2 - row]; - } - for (i = 0; i= row - cmatrix_length/2) && (j <= row + cmatrix_length/2) ) - sum += cur_col[j*bytes + i] * cmatrix[j]; - } - dest_col[row*bytes + i] = (guchar)round2int(sum / scale); - } + gdouble scale; + gdouble sum; + gint i,j; + gint row; + + /* this is to take care cases in which the matrix can go over + * both edges at once. It's not efficient, but this can only + * happen in small pictures anyway. + */ + if (cmatrix_length > y) + { + for (row = 0; row < y ; row++) + { + scale = 0; + /* find the scale factor */ + for (j = 0; j < y ; j++) + { + /* if the index is in bounds, add it to the scale counter */ + if ((j + cmatrix_length/2 - row >= 0) && + (j + cmatrix_length/2 - row < cmatrix_length)) + scale += cmatrix[j + cmatrix_length/2 - row]; + } + for (i = 0; i= row - cmatrix_length/2) && + (j <= row + cmatrix_length/2)) + sum += cur_col[j*bytes + i] * cmatrix[j]; } + dest_col[row*bytes + i] = (guchar) ROUND (sum / scale); + } } - - else { /* when the cmatrix is smaller than row length */ - - /* for the edge condition, we only use available info, and scale to one */ - for (row = 0; row < cmatrix_length/2; row++) { - /* find scale factor */ - scale=0; - for (j = cmatrix_length/2 - row; j y) { - - for (row = 0; row < y ; row++) { - scale=0; - /* find the scale factor */ - for (j = 0; j < y ; j++) { - /* if the index is in bounds, add it to the scale counter */ - if ((j + cmatrix_length/2 - row >= 0) && - (j + cmatrix_length/2 - row < cmatrix_length)) - scale += cmatrix[j + cmatrix_length/2 - row]; - } - for (i = 0; i= row - cmatrix_length/2) && (j <= row + cmatrix_length/2) ) - sum += cur_col[j*bytes + i] * cmatrix[j]; - } - dest_col[row*bytes + i] = (guchar)round2int(sum / scale); - } + /* --------------- optimized, unreadable code -------------------*/ + gdouble scale; + gdouble sum; + gint i=0, j=0; + gint row; + gint cmatrix_middle = cmatrix_length/2; + + gdouble *cmatrix_p; + guchar *cur_col_p; + guchar *cur_col_p1; + guchar *dest_col_p; + gdouble *ctable_p; + + /* this first block is the same as the non-optimized version -- + * it is only used for very small pictures, so speed isn't a + * big concern. + */ + if (cmatrix_length > y) + { + for (row = 0; row < y ; row++) + { + scale=0; + /* find the scale factor */ + for (j = 0; j < y ; j++) + { + /* if the index is in bounds, add it to the scale counter */ + if ((j + cmatrix_length/2 - row >= 0) && + (j + cmatrix_length/2 - row < cmatrix_length)) + scale += cmatrix[j + cmatrix_length/2 - row]; + } + for (i = 0; i= row - cmatrix_length/2) && + (j <= row + cmatrix_length/2)) + sum += cur_col[j*bytes + i] * cmatrix[j]; } + dest_col[row*bytes + i] = (guchar) ROUND (sum / scale); + } } - - else { - /* for the edge condition, we only use available info and scale to one */ - for (row = 0; row < cmatrix_middle; row++) { - /* find scale factor */ - scale=0; - for (j = cmatrix_middle - row; j0; j--) { - sum += *(ctable_p + *cur_col_p1); - cur_col_p1 += bytes; - ctable_p += 256; - } - cur_col_p++; - *(dest_col_p++) = round2int(sum); - } + dest_col[row*bytes + i] = (guchar) ROUND (sum / scale); + } + } + /* go through each pixel in each col */ + dest_col_p = dest_col + row*bytes; + for (; row < y-cmatrix_middle; row++) + { + cur_col_p = (row - cmatrix_middle) * bytes + cur_col; + for (i = 0; i0; j--) + { + sum += *(ctable_p + *cur_col_p1); + cur_col_p1 += bytes; + ctable_p += 256; } + cur_col_p++; + *(dest_col_p++) = ROUND (sum); + } + } - /* for the edge condition , we only use available info, and scale to one */ - for ( ; row < y; row++) { - /* find scale factor */ - scale=0; - for (j = 0; j< y-row + cmatrix_middle; j++) - scale += cmatrix[j]; - for (i = 0; ivbox), table, - FALSE, FALSE, 0); - - + _("OK"), unsharp_ok_callback, + NULL, NULL, NULL, TRUE, FALSE, + _("Cancel"), gtk_widget_destroy, + NULL, 1, NULL, FALSE, TRUE, - /* create each of the inputs */ - dialog_create_value_f(_("Radius:"), GTK_TABLE(table), 1, &unsharp_params.radius, - 0.1, 1, 1.0, 25.0); - dialog_create_value_f(_("Amount:"), GTK_TABLE(table), 2, &unsharp_params.amount, - 0.01, 2, 0.01, 5.0); - dialog_create_value_i(_("Threshold:"), GTK_TABLE(table), 3, &unsharp_params.threshold, - 1, 0, 255); - - - /* show table */ - gtk_widget_show(table); - - - /* Action area */ - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (window)->action_area), 2); - gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (window)->action_area), FALSE); - hbbox = gtk_hbutton_box_new (); - gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4); - gtk_box_pack_end (GTK_BOX (GTK_DIALOG (window)->action_area), hbbox, FALSE, FALSE, 0); - gtk_widget_show (hbbox); - - button = gtk_button_new_with_label (_("OK")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) unsharp_ok_callback, - window); - gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); - gtk_widget_grab_default (button); - gtk_widget_show (button); - - button = gtk_button_new_with_label (_("Cancel")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) unsharp_cancel_callback, NULL); - gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); - gtk_widget_show (button); - - - /* show the window */ - gtk_widget_show (window); - - - gtk_main (); - gdk_flush(); - - /* return ok or cancel */ - return(run_filter); - + gtk_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (gtk_main_quit), + NULL); + + frame = gtk_frame_new (_("Parameter Settings")); + gtk_container_set_border_width (GTK_CONTAINER (frame), 6); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), frame, + FALSE, FALSE, 0); + gtk_widget_show (frame); + + table = gtk_table_new (3, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("Radius:"), SCALE_WIDTH, 0, + unsharp_params.radius, 1.0, 25.0, 0.1, 1.0, 1, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &unsharp_params.radius); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, + _("Amount:"), SCALE_WIDTH, 0, + unsharp_params.amount, 0.0, 5.0, 0.01, 0.1, 2, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &unsharp_params.amount); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, + _("Threshold:"), SCALE_WIDTH, 0, + unsharp_params.threshold, 0.0, 255.0, 1.0, 10.0, 0, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_int_adjustment_update), + &unsharp_params.threshold); + + gtk_widget_show (window); + + gtk_main (); + gdk_flush (); + + return run_filter; } @@ -821,13 +858,13 @@ static gint unsharp_mask_dialog() /* 'preview_init()' - Initialize the preview window... */ static void -preview_init(void) +preview_init (void) { int width; /* Byte width of the image */ - /* - * Setup for preview filter... - */ + /* + * Setup for preview filter... + */ width = preview_width * img_bpp; @@ -847,7 +884,7 @@ preview_init(void) */ static void -preview_scroll_callback(void) +preview_scroll_callback (void) { preview_x1 = sel_x1 + GTK_ADJUSTMENT(hscroll_data)->value; preview_y1 = sel_y1 + GTK_ADJUSTMENT(vscroll_data)->value; @@ -857,57 +894,48 @@ preview_scroll_callback(void) preview_update(); } - /* * 'preview_update()' - Update the preview window. */ static void -preview_update(void) { +preview_update (void) +{ } #endif -static void unsharp_cancel_callback (GtkWidget *widget, gpointer data) { - gtk_main_quit (); -} - -static void unsharp_ok_callback (GtkWidget *widget, gpointer data) { - run_filter = TRUE; - gtk_widget_destroy (GTK_WIDGET (data)); -} - -/* delete_event */ -gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ) { - - return FALSE; -} - +static void +unsharp_ok_callback (GtkWidget *widget, + gpointer data) +{ + run_filter = TRUE; -/* Destroy callback */ -void destroy( GtkWidget *widget, gpointer data ) { - gtk_main_quit(); + gtk_widget_destroy (GTK_WIDGET (data)); } - #ifdef TIMER -static void timerstart() { - gettimeofday(&time_start,NULL); +static void +timerstart (void) +{ + gettimeofday (&time_start, NULL); } -static void timerstop() { - long sec, usec; + +static void +timerstop (void) +{ + long sec, usec; - gettimeofday(&time_stop,NULL); - sec = time_stop.tv_sec - time_start.tv_sec; - usec = time_stop.tv_usec - time_start.tv_usec; + gettimeofday(&time_stop,NULL); + sec = time_stop.tv_sec - time_start.tv_sec; + usec = time_stop.tv_usec - time_start.tv_usec; - if (usec < 0) { - sec--; - usec += 1000000; - } + if (usec < 0) + { + sec--; + usec += 1000000; + } - fprintf(stderr, "%ld.%ld seconds\n", sec, usec); - + fprintf (stderr, "%ld.%ld seconds\n", sec, usec); } #endif - diff --git a/plug-ins/jpeg/jpeg-load.c b/plug-ins/jpeg/jpeg-load.c index 17fa18d82d05250399a82a6b529c2979a0091e16..558e4c380de226442a49d0a508bc87608b1e2c5d 100644 --- a/plug-ins/jpeg/jpeg-load.c +++ b/plug-ins/jpeg/jpeg-load.c @@ -120,8 +120,8 @@ #include #include -#include "libgimp/gimp.h" -#include "libgimp/gimpui.h" +#include +#include #include "libgimp/stdplugins-intl.h" @@ -193,19 +193,19 @@ typedef void (*MenuItemCallback) (GtkWidget *widget, /* Declare local functions. */ static void query (void); -static void run (char *name, - int nparams, - GParam *param, - int *nreturn_vals, - GParam **return_vals); -static gint32 load_image (char *filename, - GRunModeType runmode, - int preview); -static gint save_image (char *filename, - gint32 image_ID, - gint32 drawable_ID, - gint32 orig_image_ID, - int preview); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); +static gint32 load_image (gchar *filename, + GRunModeType runmode, + gint preview); +static gint save_image (gchar *filename, + gint32 image_ID, + gint32 drawable_ID, + gint32 orig_image_ID, + gint preview); static void add_menu_item (GtkWidget *menu, char *label, @@ -1529,11 +1529,14 @@ static gint save_dialog (void) { GtkWidget *dlg; + GtkWidget *vbox; + GtkWidget *main_vbox; GtkWidget *label; GtkWidget *scale; GtkWidget *frame; GtkWidget *table; GtkWidget *toggle; + GtkWidget *abox; GtkObject *scale_data; GtkWidget *progressive; @@ -1553,7 +1556,6 @@ save_dialog (void) GtkWidget *vscrollbar; GtkWidget *prv_frame; - GtkWidget *prv_table; GDrawableType dtype; dlg = gimp_dialog_new (_("Save as Jpeg"), "jpeg", @@ -1572,28 +1574,35 @@ save_dialog (void) GTK_SIGNAL_FUNC (save_close_callback), NULL); + main_vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox, + TRUE, TRUE, 0); + gtk_widget_show (main_vbox); + /* sg - preview */ prv_frame = gtk_frame_new (_("Image Preview")); gtk_frame_set_shadow_type (GTK_FRAME (prv_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (prv_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), prv_frame, TRUE, TRUE, 0); - prv_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (prv_table), 10); - gtk_container_add (GTK_CONTAINER (prv_frame), prv_table); - - preview = gtk_check_button_new_with_label(_("Preview (in image window)")); - gtk_table_attach(GTK_TABLE(prv_table), preview, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - gtk_signal_connect(GTK_OBJECT(preview), "toggled", - (GtkSignalFunc) save_preview_toggle, NULL); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (preview), jsvals.preview); + gtk_box_pack_start (GTK_BOX (main_vbox), prv_frame, FALSE, FALSE, 0); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (prv_frame), vbox); + gtk_widget_show (vbox); + + preview = gtk_check_button_new_with_label (_("Preview (in Image Window)")); + gtk_box_pack_start (GTK_BOX (vbox), preview, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (preview), "toggled", + GTK_SIGNAL_FUNC (save_preview_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preview), jsvals.preview); gtk_widget_show (preview); preview_size = gtk_label_new (_("Size: unknown")); gtk_misc_set_alignment (GTK_MISC (preview_size), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (prv_table), preview_size, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + gtk_box_pack_start (GTK_BOX (vbox), preview_size, FALSE, FALSE, 0); gtk_widget_show (preview_size); - - gtk_widget_show (prv_table); + gtk_widget_show (prv_frame); make_preview (); @@ -1601,86 +1610,109 @@ save_dialog (void) /* parameter settings */ frame = gtk_frame_new (_("Parameter Settings")); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0); - table = gtk_table_new (8, 2, FALSE); - gtk_container_border_width (GTK_CONTAINER (table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); + + table = gtk_table_new (9, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); gtk_container_add (GTK_CONTAINER (frame), table); - label = gtk_label_new (_("Quality")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Quality:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.quality, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 0, 1, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.quality); - gtk_widget_show (label); gtk_widget_show (scale); - label = gtk_label_new (_("Smoothing")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Smoothing:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.smoothing, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 1, 2, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.smoothing); - gtk_widget_show (label); gtk_widget_show (scale); /* sg - have to init scale here */ - scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, 1, 64, 1, 1, 0.0); + scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, + 1, 64, 1, 1, 0.0); restart_markers_scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); - restart = gtk_check_button_new_with_label (_("Restart markers")); - gtk_table_attach (GTK_TABLE (table), restart, 0, 2, 2, 3, GTK_FILL, 0, 0, 0); + restart = gtk_check_button_new_with_label (_("Restart Markers")); + gtk_table_attach (GTK_TABLE (table), restart, 0, 1, 2, 3, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (restart), "toggled", - (GtkSignalFunc) save_restart_toggle_update, scale_data); + GTK_SIGNAL_FUNC (save_restart_toggle_update), + scale_data); gtk_widget_show (restart); - restart_markers_label = gtk_label_new (_("Restart frequency (rows)")); - gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + restart_markers_label = gtk_label_new (_("Restart Frequency (Rows):")); + gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (restart_markers_label); + + abox = gtk_alignment_new (0.5, 1.0, 1.0, 0.0); + gtk_table_attach (GTK_TABLE (table), abox, 1, 3, 2, 4, + GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_show (abox); gtk_widget_set_usize (restart_markers_scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), restart_markers_scale, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_container_add (GTK_CONTAINER (abox), restart_markers_scale); gtk_scale_set_value_pos (GTK_SCALE (restart_markers_scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (restart_markers_scale), 0); - gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), GTK_UPDATE_DELAYED); + gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), + GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_restart_update, + GTK_SIGNAL_FUNC (save_restart_update), restart); - gtk_widget_set_sensitive (restart_markers_label, (jsvals.restart ? TRUE : FALSE)); - gtk_widget_set_sensitive (restart_markers_scale, (jsvals.restart ? TRUE : FALSE)); - - gtk_widget_show (restart_markers_label); + gtk_widget_set_sensitive (restart_markers_label, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_set_sensitive (restart_markers_scale, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_show (restart_markers_scale); toggle = gtk_check_button_new_with_label (_("Optimize")); - gtk_table_attach (GTK_TABLE (table), toggle, 0, 2, 4, 5, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), toggle, 0, 3, 4, 5, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (toggle), "toggled", - (GtkSignalFunc)save_optimize_update, NULL); + GTK_SIGNAL_FUNC (save_optimize_update), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.optimize); - gtk_widget_show(toggle); + gtk_widget_show (toggle); progressive = gtk_check_button_new_with_label (_("Progressive")); - gtk_table_attach (GTK_TABLE (table), progressive, 0, 2, 5, 6, + gtk_table_attach (GTK_TABLE (table), progressive, 0, 3, 5, 6, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (progressive), "toggled", - (GtkSignalFunc)save_progressive_toggle, NULL); + GTK_SIGNAL_FUNC (save_progressive_toggle), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (progressive), jsvals.progressive); gtk_widget_show (progressive); @@ -1689,28 +1721,31 @@ save_dialog (void) gtk_widget_set_sensitive (progressive, FALSE); #endif - baseline = gtk_check_button_new_with_label (_("Force baseline JPEG (readable by all decoders)")); - gtk_table_attach (GTK_TABLE (table), baseline, 0, 2, 6, 7, + baseline = gtk_check_button_new_with_label (_("Force Baseline JPEG (Readable by all Decoders)")); + gtk_table_attach (GTK_TABLE (table), baseline, 0, 3, 6, 7, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (baseline), "toggled", - (GtkSignalFunc)save_baseline_toggle, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(baseline), + GTK_SIGNAL_FUNC (save_baseline_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (baseline), jsvals.baseline); - gtk_widget_show(baseline); + gtk_widget_show (baseline); /* build option menu (code taken from app/buildmenu.c) */ menu = gtk_menu_new (); - add_menu_item(menu, "2x2,1x1,1x1", 0, subsmp_callback); - add_menu_item(menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); - add_menu_item(menu, "1x1,1x1,1x1", 2, subsmp_callback); + add_menu_item (menu, "2x2,1x1,1x1", 0, subsmp_callback); + add_menu_item (menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); + add_menu_item (menu, "1x1,1x1,1x1", 2, subsmp_callback); subsmp_menu = gtk_option_menu_new (); - label = gtk_label_new (_("Subsampling")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), subsmp_menu, 1, 2, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("Subsampling:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 7, 8, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), subsmp_menu, 2, 3, 7, 8, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (subsmp_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (subsmp_menu), menu); @@ -1724,10 +1759,12 @@ save_dialog (void) dct_menu = gtk_option_menu_new (); - label = gtk_label_new (_("DCT method (speed/quality tradeoff)")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), dct_menu, 1, 2, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("DCT Method (Speed/Quality Tradeoff):")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 8, 9, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), dct_menu, 2, 3, 8, 9, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (dct_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (dct_menu), menu); @@ -1741,18 +1778,18 @@ save_dialog (void) com_frame = gtk_frame_new (_("Image Comments")); gtk_frame_set_shadow_type (GTK_FRAME (com_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (com_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), com_frame, TRUE, TRUE, 0); - com_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (com_table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), com_frame, TRUE, TRUE, 0); + + com_table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (com_table), 4); gtk_container_add (GTK_CONTAINER (com_frame), com_table); text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), TRUE); - gtk_widget_set_usize(text,-1,3); /* //HB: restrict to 3 line height - * to allow 800x600 mode */ + gtk_widget_set_usize (text, -1, 3); /* //HB: restrict to 3 line height + * to allow 800x600 mode */ if (image_comment) - gtk_text_insert(GTK_TEXT(text),NULL,NULL,NULL,image_comment,-1); + gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, image_comment, -1); gtk_table_attach (GTK_TABLE (com_table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); @@ -1786,7 +1823,6 @@ save_dialog (void) return jsint.run; } - /* Save interface functions */ static void @@ -1850,7 +1886,7 @@ save_restart_update (GtkAdjustment *adjustment, static void save_optimize_update (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.optimize = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1858,7 +1894,7 @@ save_optimize_update (GtkWidget *widget, static void save_progressive_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.progressive = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1866,7 +1902,7 @@ save_progressive_toggle (GtkWidget *widget, static void save_baseline_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.baseline = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1874,7 +1910,7 @@ save_baseline_toggle (GtkWidget *widget, static void save_preview_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.preview = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1882,7 +1918,7 @@ save_preview_toggle (GtkWidget *widget, static void subsmp_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.subsmp = *((guchar *)data); make_preview (); @@ -1890,7 +1926,7 @@ subsmp_callback (GtkWidget *widget, static void dct_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.dct = *((guchar *)data); make_preview (); diff --git a/plug-ins/jpeg/jpeg-load.h b/plug-ins/jpeg/jpeg-load.h index 17fa18d82d05250399a82a6b529c2979a0091e16..558e4c380de226442a49d0a508bc87608b1e2c5d 100644 --- a/plug-ins/jpeg/jpeg-load.h +++ b/plug-ins/jpeg/jpeg-load.h @@ -120,8 +120,8 @@ #include #include -#include "libgimp/gimp.h" -#include "libgimp/gimpui.h" +#include +#include #include "libgimp/stdplugins-intl.h" @@ -193,19 +193,19 @@ typedef void (*MenuItemCallback) (GtkWidget *widget, /* Declare local functions. */ static void query (void); -static void run (char *name, - int nparams, - GParam *param, - int *nreturn_vals, - GParam **return_vals); -static gint32 load_image (char *filename, - GRunModeType runmode, - int preview); -static gint save_image (char *filename, - gint32 image_ID, - gint32 drawable_ID, - gint32 orig_image_ID, - int preview); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); +static gint32 load_image (gchar *filename, + GRunModeType runmode, + gint preview); +static gint save_image (gchar *filename, + gint32 image_ID, + gint32 drawable_ID, + gint32 orig_image_ID, + gint preview); static void add_menu_item (GtkWidget *menu, char *label, @@ -1529,11 +1529,14 @@ static gint save_dialog (void) { GtkWidget *dlg; + GtkWidget *vbox; + GtkWidget *main_vbox; GtkWidget *label; GtkWidget *scale; GtkWidget *frame; GtkWidget *table; GtkWidget *toggle; + GtkWidget *abox; GtkObject *scale_data; GtkWidget *progressive; @@ -1553,7 +1556,6 @@ save_dialog (void) GtkWidget *vscrollbar; GtkWidget *prv_frame; - GtkWidget *prv_table; GDrawableType dtype; dlg = gimp_dialog_new (_("Save as Jpeg"), "jpeg", @@ -1572,28 +1574,35 @@ save_dialog (void) GTK_SIGNAL_FUNC (save_close_callback), NULL); + main_vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox, + TRUE, TRUE, 0); + gtk_widget_show (main_vbox); + /* sg - preview */ prv_frame = gtk_frame_new (_("Image Preview")); gtk_frame_set_shadow_type (GTK_FRAME (prv_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (prv_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), prv_frame, TRUE, TRUE, 0); - prv_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (prv_table), 10); - gtk_container_add (GTK_CONTAINER (prv_frame), prv_table); - - preview = gtk_check_button_new_with_label(_("Preview (in image window)")); - gtk_table_attach(GTK_TABLE(prv_table), preview, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - gtk_signal_connect(GTK_OBJECT(preview), "toggled", - (GtkSignalFunc) save_preview_toggle, NULL); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (preview), jsvals.preview); + gtk_box_pack_start (GTK_BOX (main_vbox), prv_frame, FALSE, FALSE, 0); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (prv_frame), vbox); + gtk_widget_show (vbox); + + preview = gtk_check_button_new_with_label (_("Preview (in Image Window)")); + gtk_box_pack_start (GTK_BOX (vbox), preview, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (preview), "toggled", + GTK_SIGNAL_FUNC (save_preview_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preview), jsvals.preview); gtk_widget_show (preview); preview_size = gtk_label_new (_("Size: unknown")); gtk_misc_set_alignment (GTK_MISC (preview_size), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (prv_table), preview_size, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + gtk_box_pack_start (GTK_BOX (vbox), preview_size, FALSE, FALSE, 0); gtk_widget_show (preview_size); - - gtk_widget_show (prv_table); + gtk_widget_show (prv_frame); make_preview (); @@ -1601,86 +1610,109 @@ save_dialog (void) /* parameter settings */ frame = gtk_frame_new (_("Parameter Settings")); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0); - table = gtk_table_new (8, 2, FALSE); - gtk_container_border_width (GTK_CONTAINER (table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); + + table = gtk_table_new (9, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); gtk_container_add (GTK_CONTAINER (frame), table); - label = gtk_label_new (_("Quality")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Quality:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.quality, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 0, 1, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.quality); - gtk_widget_show (label); gtk_widget_show (scale); - label = gtk_label_new (_("Smoothing")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Smoothing:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.smoothing, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 1, 2, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.smoothing); - gtk_widget_show (label); gtk_widget_show (scale); /* sg - have to init scale here */ - scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, 1, 64, 1, 1, 0.0); + scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, + 1, 64, 1, 1, 0.0); restart_markers_scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); - restart = gtk_check_button_new_with_label (_("Restart markers")); - gtk_table_attach (GTK_TABLE (table), restart, 0, 2, 2, 3, GTK_FILL, 0, 0, 0); + restart = gtk_check_button_new_with_label (_("Restart Markers")); + gtk_table_attach (GTK_TABLE (table), restart, 0, 1, 2, 3, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (restart), "toggled", - (GtkSignalFunc) save_restart_toggle_update, scale_data); + GTK_SIGNAL_FUNC (save_restart_toggle_update), + scale_data); gtk_widget_show (restart); - restart_markers_label = gtk_label_new (_("Restart frequency (rows)")); - gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + restart_markers_label = gtk_label_new (_("Restart Frequency (Rows):")); + gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (restart_markers_label); + + abox = gtk_alignment_new (0.5, 1.0, 1.0, 0.0); + gtk_table_attach (GTK_TABLE (table), abox, 1, 3, 2, 4, + GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_show (abox); gtk_widget_set_usize (restart_markers_scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), restart_markers_scale, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_container_add (GTK_CONTAINER (abox), restart_markers_scale); gtk_scale_set_value_pos (GTK_SCALE (restart_markers_scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (restart_markers_scale), 0); - gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), GTK_UPDATE_DELAYED); + gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), + GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_restart_update, + GTK_SIGNAL_FUNC (save_restart_update), restart); - gtk_widget_set_sensitive (restart_markers_label, (jsvals.restart ? TRUE : FALSE)); - gtk_widget_set_sensitive (restart_markers_scale, (jsvals.restart ? TRUE : FALSE)); - - gtk_widget_show (restart_markers_label); + gtk_widget_set_sensitive (restart_markers_label, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_set_sensitive (restart_markers_scale, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_show (restart_markers_scale); toggle = gtk_check_button_new_with_label (_("Optimize")); - gtk_table_attach (GTK_TABLE (table), toggle, 0, 2, 4, 5, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), toggle, 0, 3, 4, 5, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (toggle), "toggled", - (GtkSignalFunc)save_optimize_update, NULL); + GTK_SIGNAL_FUNC (save_optimize_update), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.optimize); - gtk_widget_show(toggle); + gtk_widget_show (toggle); progressive = gtk_check_button_new_with_label (_("Progressive")); - gtk_table_attach (GTK_TABLE (table), progressive, 0, 2, 5, 6, + gtk_table_attach (GTK_TABLE (table), progressive, 0, 3, 5, 6, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (progressive), "toggled", - (GtkSignalFunc)save_progressive_toggle, NULL); + GTK_SIGNAL_FUNC (save_progressive_toggle), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (progressive), jsvals.progressive); gtk_widget_show (progressive); @@ -1689,28 +1721,31 @@ save_dialog (void) gtk_widget_set_sensitive (progressive, FALSE); #endif - baseline = gtk_check_button_new_with_label (_("Force baseline JPEG (readable by all decoders)")); - gtk_table_attach (GTK_TABLE (table), baseline, 0, 2, 6, 7, + baseline = gtk_check_button_new_with_label (_("Force Baseline JPEG (Readable by all Decoders)")); + gtk_table_attach (GTK_TABLE (table), baseline, 0, 3, 6, 7, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (baseline), "toggled", - (GtkSignalFunc)save_baseline_toggle, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(baseline), + GTK_SIGNAL_FUNC (save_baseline_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (baseline), jsvals.baseline); - gtk_widget_show(baseline); + gtk_widget_show (baseline); /* build option menu (code taken from app/buildmenu.c) */ menu = gtk_menu_new (); - add_menu_item(menu, "2x2,1x1,1x1", 0, subsmp_callback); - add_menu_item(menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); - add_menu_item(menu, "1x1,1x1,1x1", 2, subsmp_callback); + add_menu_item (menu, "2x2,1x1,1x1", 0, subsmp_callback); + add_menu_item (menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); + add_menu_item (menu, "1x1,1x1,1x1", 2, subsmp_callback); subsmp_menu = gtk_option_menu_new (); - label = gtk_label_new (_("Subsampling")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), subsmp_menu, 1, 2, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("Subsampling:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 7, 8, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), subsmp_menu, 2, 3, 7, 8, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (subsmp_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (subsmp_menu), menu); @@ -1724,10 +1759,12 @@ save_dialog (void) dct_menu = gtk_option_menu_new (); - label = gtk_label_new (_("DCT method (speed/quality tradeoff)")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), dct_menu, 1, 2, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("DCT Method (Speed/Quality Tradeoff):")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 8, 9, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), dct_menu, 2, 3, 8, 9, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (dct_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (dct_menu), menu); @@ -1741,18 +1778,18 @@ save_dialog (void) com_frame = gtk_frame_new (_("Image Comments")); gtk_frame_set_shadow_type (GTK_FRAME (com_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (com_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), com_frame, TRUE, TRUE, 0); - com_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (com_table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), com_frame, TRUE, TRUE, 0); + + com_table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (com_table), 4); gtk_container_add (GTK_CONTAINER (com_frame), com_table); text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), TRUE); - gtk_widget_set_usize(text,-1,3); /* //HB: restrict to 3 line height - * to allow 800x600 mode */ + gtk_widget_set_usize (text, -1, 3); /* //HB: restrict to 3 line height + * to allow 800x600 mode */ if (image_comment) - gtk_text_insert(GTK_TEXT(text),NULL,NULL,NULL,image_comment,-1); + gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, image_comment, -1); gtk_table_attach (GTK_TABLE (com_table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); @@ -1786,7 +1823,6 @@ save_dialog (void) return jsint.run; } - /* Save interface functions */ static void @@ -1850,7 +1886,7 @@ save_restart_update (GtkAdjustment *adjustment, static void save_optimize_update (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.optimize = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1858,7 +1894,7 @@ save_optimize_update (GtkWidget *widget, static void save_progressive_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.progressive = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1866,7 +1902,7 @@ save_progressive_toggle (GtkWidget *widget, static void save_baseline_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.baseline = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1874,7 +1910,7 @@ save_baseline_toggle (GtkWidget *widget, static void save_preview_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.preview = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1882,7 +1918,7 @@ save_preview_toggle (GtkWidget *widget, static void subsmp_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.subsmp = *((guchar *)data); make_preview (); @@ -1890,7 +1926,7 @@ subsmp_callback (GtkWidget *widget, static void dct_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.dct = *((guchar *)data); make_preview (); diff --git a/plug-ins/jpeg/jpeg-save.c b/plug-ins/jpeg/jpeg-save.c index 17fa18d82d05250399a82a6b529c2979a0091e16..558e4c380de226442a49d0a508bc87608b1e2c5d 100644 --- a/plug-ins/jpeg/jpeg-save.c +++ b/plug-ins/jpeg/jpeg-save.c @@ -120,8 +120,8 @@ #include #include -#include "libgimp/gimp.h" -#include "libgimp/gimpui.h" +#include +#include #include "libgimp/stdplugins-intl.h" @@ -193,19 +193,19 @@ typedef void (*MenuItemCallback) (GtkWidget *widget, /* Declare local functions. */ static void query (void); -static void run (char *name, - int nparams, - GParam *param, - int *nreturn_vals, - GParam **return_vals); -static gint32 load_image (char *filename, - GRunModeType runmode, - int preview); -static gint save_image (char *filename, - gint32 image_ID, - gint32 drawable_ID, - gint32 orig_image_ID, - int preview); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); +static gint32 load_image (gchar *filename, + GRunModeType runmode, + gint preview); +static gint save_image (gchar *filename, + gint32 image_ID, + gint32 drawable_ID, + gint32 orig_image_ID, + gint preview); static void add_menu_item (GtkWidget *menu, char *label, @@ -1529,11 +1529,14 @@ static gint save_dialog (void) { GtkWidget *dlg; + GtkWidget *vbox; + GtkWidget *main_vbox; GtkWidget *label; GtkWidget *scale; GtkWidget *frame; GtkWidget *table; GtkWidget *toggle; + GtkWidget *abox; GtkObject *scale_data; GtkWidget *progressive; @@ -1553,7 +1556,6 @@ save_dialog (void) GtkWidget *vscrollbar; GtkWidget *prv_frame; - GtkWidget *prv_table; GDrawableType dtype; dlg = gimp_dialog_new (_("Save as Jpeg"), "jpeg", @@ -1572,28 +1574,35 @@ save_dialog (void) GTK_SIGNAL_FUNC (save_close_callback), NULL); + main_vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox, + TRUE, TRUE, 0); + gtk_widget_show (main_vbox); + /* sg - preview */ prv_frame = gtk_frame_new (_("Image Preview")); gtk_frame_set_shadow_type (GTK_FRAME (prv_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (prv_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), prv_frame, TRUE, TRUE, 0); - prv_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (prv_table), 10); - gtk_container_add (GTK_CONTAINER (prv_frame), prv_table); - - preview = gtk_check_button_new_with_label(_("Preview (in image window)")); - gtk_table_attach(GTK_TABLE(prv_table), preview, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - gtk_signal_connect(GTK_OBJECT(preview), "toggled", - (GtkSignalFunc) save_preview_toggle, NULL); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (preview), jsvals.preview); + gtk_box_pack_start (GTK_BOX (main_vbox), prv_frame, FALSE, FALSE, 0); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (prv_frame), vbox); + gtk_widget_show (vbox); + + preview = gtk_check_button_new_with_label (_("Preview (in Image Window)")); + gtk_box_pack_start (GTK_BOX (vbox), preview, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (preview), "toggled", + GTK_SIGNAL_FUNC (save_preview_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preview), jsvals.preview); gtk_widget_show (preview); preview_size = gtk_label_new (_("Size: unknown")); gtk_misc_set_alignment (GTK_MISC (preview_size), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (prv_table), preview_size, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + gtk_box_pack_start (GTK_BOX (vbox), preview_size, FALSE, FALSE, 0); gtk_widget_show (preview_size); - - gtk_widget_show (prv_table); + gtk_widget_show (prv_frame); make_preview (); @@ -1601,86 +1610,109 @@ save_dialog (void) /* parameter settings */ frame = gtk_frame_new (_("Parameter Settings")); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0); - table = gtk_table_new (8, 2, FALSE); - gtk_container_border_width (GTK_CONTAINER (table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); + + table = gtk_table_new (9, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); gtk_container_add (GTK_CONTAINER (frame), table); - label = gtk_label_new (_("Quality")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Quality:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.quality, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 0, 1, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.quality); - gtk_widget_show (label); gtk_widget_show (scale); - label = gtk_label_new (_("Smoothing")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Smoothing:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.smoothing, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 1, 2, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.smoothing); - gtk_widget_show (label); gtk_widget_show (scale); /* sg - have to init scale here */ - scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, 1, 64, 1, 1, 0.0); + scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, + 1, 64, 1, 1, 0.0); restart_markers_scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); - restart = gtk_check_button_new_with_label (_("Restart markers")); - gtk_table_attach (GTK_TABLE (table), restart, 0, 2, 2, 3, GTK_FILL, 0, 0, 0); + restart = gtk_check_button_new_with_label (_("Restart Markers")); + gtk_table_attach (GTK_TABLE (table), restart, 0, 1, 2, 3, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (restart), "toggled", - (GtkSignalFunc) save_restart_toggle_update, scale_data); + GTK_SIGNAL_FUNC (save_restart_toggle_update), + scale_data); gtk_widget_show (restart); - restart_markers_label = gtk_label_new (_("Restart frequency (rows)")); - gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + restart_markers_label = gtk_label_new (_("Restart Frequency (Rows):")); + gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (restart_markers_label); + + abox = gtk_alignment_new (0.5, 1.0, 1.0, 0.0); + gtk_table_attach (GTK_TABLE (table), abox, 1, 3, 2, 4, + GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_show (abox); gtk_widget_set_usize (restart_markers_scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), restart_markers_scale, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_container_add (GTK_CONTAINER (abox), restart_markers_scale); gtk_scale_set_value_pos (GTK_SCALE (restart_markers_scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (restart_markers_scale), 0); - gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), GTK_UPDATE_DELAYED); + gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), + GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_restart_update, + GTK_SIGNAL_FUNC (save_restart_update), restart); - gtk_widget_set_sensitive (restart_markers_label, (jsvals.restart ? TRUE : FALSE)); - gtk_widget_set_sensitive (restart_markers_scale, (jsvals.restart ? TRUE : FALSE)); - - gtk_widget_show (restart_markers_label); + gtk_widget_set_sensitive (restart_markers_label, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_set_sensitive (restart_markers_scale, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_show (restart_markers_scale); toggle = gtk_check_button_new_with_label (_("Optimize")); - gtk_table_attach (GTK_TABLE (table), toggle, 0, 2, 4, 5, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), toggle, 0, 3, 4, 5, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (toggle), "toggled", - (GtkSignalFunc)save_optimize_update, NULL); + GTK_SIGNAL_FUNC (save_optimize_update), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.optimize); - gtk_widget_show(toggle); + gtk_widget_show (toggle); progressive = gtk_check_button_new_with_label (_("Progressive")); - gtk_table_attach (GTK_TABLE (table), progressive, 0, 2, 5, 6, + gtk_table_attach (GTK_TABLE (table), progressive, 0, 3, 5, 6, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (progressive), "toggled", - (GtkSignalFunc)save_progressive_toggle, NULL); + GTK_SIGNAL_FUNC (save_progressive_toggle), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (progressive), jsvals.progressive); gtk_widget_show (progressive); @@ -1689,28 +1721,31 @@ save_dialog (void) gtk_widget_set_sensitive (progressive, FALSE); #endif - baseline = gtk_check_button_new_with_label (_("Force baseline JPEG (readable by all decoders)")); - gtk_table_attach (GTK_TABLE (table), baseline, 0, 2, 6, 7, + baseline = gtk_check_button_new_with_label (_("Force Baseline JPEG (Readable by all Decoders)")); + gtk_table_attach (GTK_TABLE (table), baseline, 0, 3, 6, 7, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (baseline), "toggled", - (GtkSignalFunc)save_baseline_toggle, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(baseline), + GTK_SIGNAL_FUNC (save_baseline_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (baseline), jsvals.baseline); - gtk_widget_show(baseline); + gtk_widget_show (baseline); /* build option menu (code taken from app/buildmenu.c) */ menu = gtk_menu_new (); - add_menu_item(menu, "2x2,1x1,1x1", 0, subsmp_callback); - add_menu_item(menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); - add_menu_item(menu, "1x1,1x1,1x1", 2, subsmp_callback); + add_menu_item (menu, "2x2,1x1,1x1", 0, subsmp_callback); + add_menu_item (menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); + add_menu_item (menu, "1x1,1x1,1x1", 2, subsmp_callback); subsmp_menu = gtk_option_menu_new (); - label = gtk_label_new (_("Subsampling")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), subsmp_menu, 1, 2, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("Subsampling:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 7, 8, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), subsmp_menu, 2, 3, 7, 8, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (subsmp_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (subsmp_menu), menu); @@ -1724,10 +1759,12 @@ save_dialog (void) dct_menu = gtk_option_menu_new (); - label = gtk_label_new (_("DCT method (speed/quality tradeoff)")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), dct_menu, 1, 2, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("DCT Method (Speed/Quality Tradeoff):")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 8, 9, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), dct_menu, 2, 3, 8, 9, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (dct_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (dct_menu), menu); @@ -1741,18 +1778,18 @@ save_dialog (void) com_frame = gtk_frame_new (_("Image Comments")); gtk_frame_set_shadow_type (GTK_FRAME (com_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (com_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), com_frame, TRUE, TRUE, 0); - com_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (com_table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), com_frame, TRUE, TRUE, 0); + + com_table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (com_table), 4); gtk_container_add (GTK_CONTAINER (com_frame), com_table); text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), TRUE); - gtk_widget_set_usize(text,-1,3); /* //HB: restrict to 3 line height - * to allow 800x600 mode */ + gtk_widget_set_usize (text, -1, 3); /* //HB: restrict to 3 line height + * to allow 800x600 mode */ if (image_comment) - gtk_text_insert(GTK_TEXT(text),NULL,NULL,NULL,image_comment,-1); + gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, image_comment, -1); gtk_table_attach (GTK_TABLE (com_table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); @@ -1786,7 +1823,6 @@ save_dialog (void) return jsint.run; } - /* Save interface functions */ static void @@ -1850,7 +1886,7 @@ save_restart_update (GtkAdjustment *adjustment, static void save_optimize_update (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.optimize = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1858,7 +1894,7 @@ save_optimize_update (GtkWidget *widget, static void save_progressive_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.progressive = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1866,7 +1902,7 @@ save_progressive_toggle (GtkWidget *widget, static void save_baseline_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.baseline = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1874,7 +1910,7 @@ save_baseline_toggle (GtkWidget *widget, static void save_preview_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.preview = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1882,7 +1918,7 @@ save_preview_toggle (GtkWidget *widget, static void subsmp_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.subsmp = *((guchar *)data); make_preview (); @@ -1890,7 +1926,7 @@ subsmp_callback (GtkWidget *widget, static void dct_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.dct = *((guchar *)data); make_preview (); diff --git a/plug-ins/jpeg/jpeg-save.h b/plug-ins/jpeg/jpeg-save.h index 17fa18d82d05250399a82a6b529c2979a0091e16..558e4c380de226442a49d0a508bc87608b1e2c5d 100644 --- a/plug-ins/jpeg/jpeg-save.h +++ b/plug-ins/jpeg/jpeg-save.h @@ -120,8 +120,8 @@ #include #include -#include "libgimp/gimp.h" -#include "libgimp/gimpui.h" +#include +#include #include "libgimp/stdplugins-intl.h" @@ -193,19 +193,19 @@ typedef void (*MenuItemCallback) (GtkWidget *widget, /* Declare local functions. */ static void query (void); -static void run (char *name, - int nparams, - GParam *param, - int *nreturn_vals, - GParam **return_vals); -static gint32 load_image (char *filename, - GRunModeType runmode, - int preview); -static gint save_image (char *filename, - gint32 image_ID, - gint32 drawable_ID, - gint32 orig_image_ID, - int preview); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); +static gint32 load_image (gchar *filename, + GRunModeType runmode, + gint preview); +static gint save_image (gchar *filename, + gint32 image_ID, + gint32 drawable_ID, + gint32 orig_image_ID, + gint preview); static void add_menu_item (GtkWidget *menu, char *label, @@ -1529,11 +1529,14 @@ static gint save_dialog (void) { GtkWidget *dlg; + GtkWidget *vbox; + GtkWidget *main_vbox; GtkWidget *label; GtkWidget *scale; GtkWidget *frame; GtkWidget *table; GtkWidget *toggle; + GtkWidget *abox; GtkObject *scale_data; GtkWidget *progressive; @@ -1553,7 +1556,6 @@ save_dialog (void) GtkWidget *vscrollbar; GtkWidget *prv_frame; - GtkWidget *prv_table; GDrawableType dtype; dlg = gimp_dialog_new (_("Save as Jpeg"), "jpeg", @@ -1572,28 +1574,35 @@ save_dialog (void) GTK_SIGNAL_FUNC (save_close_callback), NULL); + main_vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox, + TRUE, TRUE, 0); + gtk_widget_show (main_vbox); + /* sg - preview */ prv_frame = gtk_frame_new (_("Image Preview")); gtk_frame_set_shadow_type (GTK_FRAME (prv_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (prv_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), prv_frame, TRUE, TRUE, 0); - prv_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (prv_table), 10); - gtk_container_add (GTK_CONTAINER (prv_frame), prv_table); - - preview = gtk_check_button_new_with_label(_("Preview (in image window)")); - gtk_table_attach(GTK_TABLE(prv_table), preview, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - gtk_signal_connect(GTK_OBJECT(preview), "toggled", - (GtkSignalFunc) save_preview_toggle, NULL); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (preview), jsvals.preview); + gtk_box_pack_start (GTK_BOX (main_vbox), prv_frame, FALSE, FALSE, 0); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (prv_frame), vbox); + gtk_widget_show (vbox); + + preview = gtk_check_button_new_with_label (_("Preview (in Image Window)")); + gtk_box_pack_start (GTK_BOX (vbox), preview, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (preview), "toggled", + GTK_SIGNAL_FUNC (save_preview_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preview), jsvals.preview); gtk_widget_show (preview); preview_size = gtk_label_new (_("Size: unknown")); gtk_misc_set_alignment (GTK_MISC (preview_size), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (prv_table), preview_size, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + gtk_box_pack_start (GTK_BOX (vbox), preview_size, FALSE, FALSE, 0); gtk_widget_show (preview_size); - - gtk_widget_show (prv_table); + gtk_widget_show (prv_frame); make_preview (); @@ -1601,86 +1610,109 @@ save_dialog (void) /* parameter settings */ frame = gtk_frame_new (_("Parameter Settings")); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0); - table = gtk_table_new (8, 2, FALSE); - gtk_container_border_width (GTK_CONTAINER (table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); + + table = gtk_table_new (9, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); gtk_container_add (GTK_CONTAINER (frame), table); - label = gtk_label_new (_("Quality")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Quality:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.quality, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 0, 1, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.quality); - gtk_widget_show (label); gtk_widget_show (scale); - label = gtk_label_new (_("Smoothing")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Smoothing:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.smoothing, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 1, 2, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.smoothing); - gtk_widget_show (label); gtk_widget_show (scale); /* sg - have to init scale here */ - scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, 1, 64, 1, 1, 0.0); + scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, + 1, 64, 1, 1, 0.0); restart_markers_scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); - restart = gtk_check_button_new_with_label (_("Restart markers")); - gtk_table_attach (GTK_TABLE (table), restart, 0, 2, 2, 3, GTK_FILL, 0, 0, 0); + restart = gtk_check_button_new_with_label (_("Restart Markers")); + gtk_table_attach (GTK_TABLE (table), restart, 0, 1, 2, 3, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (restart), "toggled", - (GtkSignalFunc) save_restart_toggle_update, scale_data); + GTK_SIGNAL_FUNC (save_restart_toggle_update), + scale_data); gtk_widget_show (restart); - restart_markers_label = gtk_label_new (_("Restart frequency (rows)")); - gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + restart_markers_label = gtk_label_new (_("Restart Frequency (Rows):")); + gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (restart_markers_label); + + abox = gtk_alignment_new (0.5, 1.0, 1.0, 0.0); + gtk_table_attach (GTK_TABLE (table), abox, 1, 3, 2, 4, + GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_show (abox); gtk_widget_set_usize (restart_markers_scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), restart_markers_scale, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_container_add (GTK_CONTAINER (abox), restart_markers_scale); gtk_scale_set_value_pos (GTK_SCALE (restart_markers_scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (restart_markers_scale), 0); - gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), GTK_UPDATE_DELAYED); + gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), + GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_restart_update, + GTK_SIGNAL_FUNC (save_restart_update), restart); - gtk_widget_set_sensitive (restart_markers_label, (jsvals.restart ? TRUE : FALSE)); - gtk_widget_set_sensitive (restart_markers_scale, (jsvals.restart ? TRUE : FALSE)); - - gtk_widget_show (restart_markers_label); + gtk_widget_set_sensitive (restart_markers_label, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_set_sensitive (restart_markers_scale, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_show (restart_markers_scale); toggle = gtk_check_button_new_with_label (_("Optimize")); - gtk_table_attach (GTK_TABLE (table), toggle, 0, 2, 4, 5, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), toggle, 0, 3, 4, 5, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (toggle), "toggled", - (GtkSignalFunc)save_optimize_update, NULL); + GTK_SIGNAL_FUNC (save_optimize_update), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.optimize); - gtk_widget_show(toggle); + gtk_widget_show (toggle); progressive = gtk_check_button_new_with_label (_("Progressive")); - gtk_table_attach (GTK_TABLE (table), progressive, 0, 2, 5, 6, + gtk_table_attach (GTK_TABLE (table), progressive, 0, 3, 5, 6, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (progressive), "toggled", - (GtkSignalFunc)save_progressive_toggle, NULL); + GTK_SIGNAL_FUNC (save_progressive_toggle), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (progressive), jsvals.progressive); gtk_widget_show (progressive); @@ -1689,28 +1721,31 @@ save_dialog (void) gtk_widget_set_sensitive (progressive, FALSE); #endif - baseline = gtk_check_button_new_with_label (_("Force baseline JPEG (readable by all decoders)")); - gtk_table_attach (GTK_TABLE (table), baseline, 0, 2, 6, 7, + baseline = gtk_check_button_new_with_label (_("Force Baseline JPEG (Readable by all Decoders)")); + gtk_table_attach (GTK_TABLE (table), baseline, 0, 3, 6, 7, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (baseline), "toggled", - (GtkSignalFunc)save_baseline_toggle, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(baseline), + GTK_SIGNAL_FUNC (save_baseline_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (baseline), jsvals.baseline); - gtk_widget_show(baseline); + gtk_widget_show (baseline); /* build option menu (code taken from app/buildmenu.c) */ menu = gtk_menu_new (); - add_menu_item(menu, "2x2,1x1,1x1", 0, subsmp_callback); - add_menu_item(menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); - add_menu_item(menu, "1x1,1x1,1x1", 2, subsmp_callback); + add_menu_item (menu, "2x2,1x1,1x1", 0, subsmp_callback); + add_menu_item (menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); + add_menu_item (menu, "1x1,1x1,1x1", 2, subsmp_callback); subsmp_menu = gtk_option_menu_new (); - label = gtk_label_new (_("Subsampling")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), subsmp_menu, 1, 2, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("Subsampling:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 7, 8, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), subsmp_menu, 2, 3, 7, 8, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (subsmp_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (subsmp_menu), menu); @@ -1724,10 +1759,12 @@ save_dialog (void) dct_menu = gtk_option_menu_new (); - label = gtk_label_new (_("DCT method (speed/quality tradeoff)")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), dct_menu, 1, 2, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("DCT Method (Speed/Quality Tradeoff):")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 8, 9, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), dct_menu, 2, 3, 8, 9, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (dct_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (dct_menu), menu); @@ -1741,18 +1778,18 @@ save_dialog (void) com_frame = gtk_frame_new (_("Image Comments")); gtk_frame_set_shadow_type (GTK_FRAME (com_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (com_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), com_frame, TRUE, TRUE, 0); - com_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (com_table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), com_frame, TRUE, TRUE, 0); + + com_table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (com_table), 4); gtk_container_add (GTK_CONTAINER (com_frame), com_table); text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), TRUE); - gtk_widget_set_usize(text,-1,3); /* //HB: restrict to 3 line height - * to allow 800x600 mode */ + gtk_widget_set_usize (text, -1, 3); /* //HB: restrict to 3 line height + * to allow 800x600 mode */ if (image_comment) - gtk_text_insert(GTK_TEXT(text),NULL,NULL,NULL,image_comment,-1); + gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, image_comment, -1); gtk_table_attach (GTK_TABLE (com_table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); @@ -1786,7 +1823,6 @@ save_dialog (void) return jsint.run; } - /* Save interface functions */ static void @@ -1850,7 +1886,7 @@ save_restart_update (GtkAdjustment *adjustment, static void save_optimize_update (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.optimize = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1858,7 +1894,7 @@ save_optimize_update (GtkWidget *widget, static void save_progressive_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.progressive = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1866,7 +1902,7 @@ save_progressive_toggle (GtkWidget *widget, static void save_baseline_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.baseline = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1874,7 +1910,7 @@ save_baseline_toggle (GtkWidget *widget, static void save_preview_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.preview = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1882,7 +1918,7 @@ save_preview_toggle (GtkWidget *widget, static void subsmp_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.subsmp = *((guchar *)data); make_preview (); @@ -1890,7 +1926,7 @@ subsmp_callback (GtkWidget *widget, static void dct_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.dct = *((guchar *)data); make_preview (); diff --git a/plug-ins/jpeg/jpeg.c b/plug-ins/jpeg/jpeg.c index 17fa18d82d05250399a82a6b529c2979a0091e16..558e4c380de226442a49d0a508bc87608b1e2c5d 100644 --- a/plug-ins/jpeg/jpeg.c +++ b/plug-ins/jpeg/jpeg.c @@ -120,8 +120,8 @@ #include #include -#include "libgimp/gimp.h" -#include "libgimp/gimpui.h" +#include +#include #include "libgimp/stdplugins-intl.h" @@ -193,19 +193,19 @@ typedef void (*MenuItemCallback) (GtkWidget *widget, /* Declare local functions. */ static void query (void); -static void run (char *name, - int nparams, - GParam *param, - int *nreturn_vals, - GParam **return_vals); -static gint32 load_image (char *filename, - GRunModeType runmode, - int preview); -static gint save_image (char *filename, - gint32 image_ID, - gint32 drawable_ID, - gint32 orig_image_ID, - int preview); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); +static gint32 load_image (gchar *filename, + GRunModeType runmode, + gint preview); +static gint save_image (gchar *filename, + gint32 image_ID, + gint32 drawable_ID, + gint32 orig_image_ID, + gint preview); static void add_menu_item (GtkWidget *menu, char *label, @@ -1529,11 +1529,14 @@ static gint save_dialog (void) { GtkWidget *dlg; + GtkWidget *vbox; + GtkWidget *main_vbox; GtkWidget *label; GtkWidget *scale; GtkWidget *frame; GtkWidget *table; GtkWidget *toggle; + GtkWidget *abox; GtkObject *scale_data; GtkWidget *progressive; @@ -1553,7 +1556,6 @@ save_dialog (void) GtkWidget *vscrollbar; GtkWidget *prv_frame; - GtkWidget *prv_table; GDrawableType dtype; dlg = gimp_dialog_new (_("Save as Jpeg"), "jpeg", @@ -1572,28 +1574,35 @@ save_dialog (void) GTK_SIGNAL_FUNC (save_close_callback), NULL); + main_vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox, + TRUE, TRUE, 0); + gtk_widget_show (main_vbox); + /* sg - preview */ prv_frame = gtk_frame_new (_("Image Preview")); gtk_frame_set_shadow_type (GTK_FRAME (prv_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (prv_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), prv_frame, TRUE, TRUE, 0); - prv_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (prv_table), 10); - gtk_container_add (GTK_CONTAINER (prv_frame), prv_table); - - preview = gtk_check_button_new_with_label(_("Preview (in image window)")); - gtk_table_attach(GTK_TABLE(prv_table), preview, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - gtk_signal_connect(GTK_OBJECT(preview), "toggled", - (GtkSignalFunc) save_preview_toggle, NULL); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (preview), jsvals.preview); + gtk_box_pack_start (GTK_BOX (main_vbox), prv_frame, FALSE, FALSE, 0); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (prv_frame), vbox); + gtk_widget_show (vbox); + + preview = gtk_check_button_new_with_label (_("Preview (in Image Window)")); + gtk_box_pack_start (GTK_BOX (vbox), preview, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (preview), "toggled", + GTK_SIGNAL_FUNC (save_preview_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preview), jsvals.preview); gtk_widget_show (preview); preview_size = gtk_label_new (_("Size: unknown")); gtk_misc_set_alignment (GTK_MISC (preview_size), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (prv_table), preview_size, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + gtk_box_pack_start (GTK_BOX (vbox), preview_size, FALSE, FALSE, 0); gtk_widget_show (preview_size); - - gtk_widget_show (prv_table); + gtk_widget_show (prv_frame); make_preview (); @@ -1601,86 +1610,109 @@ save_dialog (void) /* parameter settings */ frame = gtk_frame_new (_("Parameter Settings")); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0); - table = gtk_table_new (8, 2, FALSE); - gtk_container_border_width (GTK_CONTAINER (table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); + + table = gtk_table_new (9, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); gtk_container_add (GTK_CONTAINER (frame), table); - label = gtk_label_new (_("Quality")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Quality:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.quality, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 0, 1, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.quality); - gtk_widget_show (label); gtk_widget_show (scale); - label = gtk_label_new (_("Smoothing")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Smoothing:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.smoothing, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 1, 2, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.smoothing); - gtk_widget_show (label); gtk_widget_show (scale); /* sg - have to init scale here */ - scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, 1, 64, 1, 1, 0.0); + scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, + 1, 64, 1, 1, 0.0); restart_markers_scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); - restart = gtk_check_button_new_with_label (_("Restart markers")); - gtk_table_attach (GTK_TABLE (table), restart, 0, 2, 2, 3, GTK_FILL, 0, 0, 0); + restart = gtk_check_button_new_with_label (_("Restart Markers")); + gtk_table_attach (GTK_TABLE (table), restart, 0, 1, 2, 3, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (restart), "toggled", - (GtkSignalFunc) save_restart_toggle_update, scale_data); + GTK_SIGNAL_FUNC (save_restart_toggle_update), + scale_data); gtk_widget_show (restart); - restart_markers_label = gtk_label_new (_("Restart frequency (rows)")); - gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + restart_markers_label = gtk_label_new (_("Restart Frequency (Rows):")); + gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (restart_markers_label); + + abox = gtk_alignment_new (0.5, 1.0, 1.0, 0.0); + gtk_table_attach (GTK_TABLE (table), abox, 1, 3, 2, 4, + GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_show (abox); gtk_widget_set_usize (restart_markers_scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), restart_markers_scale, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_container_add (GTK_CONTAINER (abox), restart_markers_scale); gtk_scale_set_value_pos (GTK_SCALE (restart_markers_scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (restart_markers_scale), 0); - gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), GTK_UPDATE_DELAYED); + gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), + GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_restart_update, + GTK_SIGNAL_FUNC (save_restart_update), restart); - gtk_widget_set_sensitive (restart_markers_label, (jsvals.restart ? TRUE : FALSE)); - gtk_widget_set_sensitive (restart_markers_scale, (jsvals.restart ? TRUE : FALSE)); - - gtk_widget_show (restart_markers_label); + gtk_widget_set_sensitive (restart_markers_label, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_set_sensitive (restart_markers_scale, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_show (restart_markers_scale); toggle = gtk_check_button_new_with_label (_("Optimize")); - gtk_table_attach (GTK_TABLE (table), toggle, 0, 2, 4, 5, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), toggle, 0, 3, 4, 5, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (toggle), "toggled", - (GtkSignalFunc)save_optimize_update, NULL); + GTK_SIGNAL_FUNC (save_optimize_update), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.optimize); - gtk_widget_show(toggle); + gtk_widget_show (toggle); progressive = gtk_check_button_new_with_label (_("Progressive")); - gtk_table_attach (GTK_TABLE (table), progressive, 0, 2, 5, 6, + gtk_table_attach (GTK_TABLE (table), progressive, 0, 3, 5, 6, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (progressive), "toggled", - (GtkSignalFunc)save_progressive_toggle, NULL); + GTK_SIGNAL_FUNC (save_progressive_toggle), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (progressive), jsvals.progressive); gtk_widget_show (progressive); @@ -1689,28 +1721,31 @@ save_dialog (void) gtk_widget_set_sensitive (progressive, FALSE); #endif - baseline = gtk_check_button_new_with_label (_("Force baseline JPEG (readable by all decoders)")); - gtk_table_attach (GTK_TABLE (table), baseline, 0, 2, 6, 7, + baseline = gtk_check_button_new_with_label (_("Force Baseline JPEG (Readable by all Decoders)")); + gtk_table_attach (GTK_TABLE (table), baseline, 0, 3, 6, 7, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (baseline), "toggled", - (GtkSignalFunc)save_baseline_toggle, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(baseline), + GTK_SIGNAL_FUNC (save_baseline_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (baseline), jsvals.baseline); - gtk_widget_show(baseline); + gtk_widget_show (baseline); /* build option menu (code taken from app/buildmenu.c) */ menu = gtk_menu_new (); - add_menu_item(menu, "2x2,1x1,1x1", 0, subsmp_callback); - add_menu_item(menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); - add_menu_item(menu, "1x1,1x1,1x1", 2, subsmp_callback); + add_menu_item (menu, "2x2,1x1,1x1", 0, subsmp_callback); + add_menu_item (menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); + add_menu_item (menu, "1x1,1x1,1x1", 2, subsmp_callback); subsmp_menu = gtk_option_menu_new (); - label = gtk_label_new (_("Subsampling")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), subsmp_menu, 1, 2, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("Subsampling:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 7, 8, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), subsmp_menu, 2, 3, 7, 8, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (subsmp_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (subsmp_menu), menu); @@ -1724,10 +1759,12 @@ save_dialog (void) dct_menu = gtk_option_menu_new (); - label = gtk_label_new (_("DCT method (speed/quality tradeoff)")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), dct_menu, 1, 2, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("DCT Method (Speed/Quality Tradeoff):")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 8, 9, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), dct_menu, 2, 3, 8, 9, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (dct_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (dct_menu), menu); @@ -1741,18 +1778,18 @@ save_dialog (void) com_frame = gtk_frame_new (_("Image Comments")); gtk_frame_set_shadow_type (GTK_FRAME (com_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (com_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), com_frame, TRUE, TRUE, 0); - com_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (com_table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), com_frame, TRUE, TRUE, 0); + + com_table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (com_table), 4); gtk_container_add (GTK_CONTAINER (com_frame), com_table); text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), TRUE); - gtk_widget_set_usize(text,-1,3); /* //HB: restrict to 3 line height - * to allow 800x600 mode */ + gtk_widget_set_usize (text, -1, 3); /* //HB: restrict to 3 line height + * to allow 800x600 mode */ if (image_comment) - gtk_text_insert(GTK_TEXT(text),NULL,NULL,NULL,image_comment,-1); + gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, image_comment, -1); gtk_table_attach (GTK_TABLE (com_table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); @@ -1786,7 +1823,6 @@ save_dialog (void) return jsint.run; } - /* Save interface functions */ static void @@ -1850,7 +1886,7 @@ save_restart_update (GtkAdjustment *adjustment, static void save_optimize_update (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.optimize = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1858,7 +1894,7 @@ save_optimize_update (GtkWidget *widget, static void save_progressive_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.progressive = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1866,7 +1902,7 @@ save_progressive_toggle (GtkWidget *widget, static void save_baseline_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.baseline = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1874,7 +1910,7 @@ save_baseline_toggle (GtkWidget *widget, static void save_preview_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.preview = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1882,7 +1918,7 @@ save_preview_toggle (GtkWidget *widget, static void subsmp_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.subsmp = *((guchar *)data); make_preview (); @@ -1890,7 +1926,7 @@ subsmp_callback (GtkWidget *widget, static void dct_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.dct = *((guchar *)data); make_preview (); diff --git a/plug-ins/jpeg/jpeg.h b/plug-ins/jpeg/jpeg.h index 17fa18d82d05250399a82a6b529c2979a0091e16..558e4c380de226442a49d0a508bc87608b1e2c5d 100644 --- a/plug-ins/jpeg/jpeg.h +++ b/plug-ins/jpeg/jpeg.h @@ -120,8 +120,8 @@ #include #include -#include "libgimp/gimp.h" -#include "libgimp/gimpui.h" +#include +#include #include "libgimp/stdplugins-intl.h" @@ -193,19 +193,19 @@ typedef void (*MenuItemCallback) (GtkWidget *widget, /* Declare local functions. */ static void query (void); -static void run (char *name, - int nparams, - GParam *param, - int *nreturn_vals, - GParam **return_vals); -static gint32 load_image (char *filename, - GRunModeType runmode, - int preview); -static gint save_image (char *filename, - gint32 image_ID, - gint32 drawable_ID, - gint32 orig_image_ID, - int preview); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); +static gint32 load_image (gchar *filename, + GRunModeType runmode, + gint preview); +static gint save_image (gchar *filename, + gint32 image_ID, + gint32 drawable_ID, + gint32 orig_image_ID, + gint preview); static void add_menu_item (GtkWidget *menu, char *label, @@ -1529,11 +1529,14 @@ static gint save_dialog (void) { GtkWidget *dlg; + GtkWidget *vbox; + GtkWidget *main_vbox; GtkWidget *label; GtkWidget *scale; GtkWidget *frame; GtkWidget *table; GtkWidget *toggle; + GtkWidget *abox; GtkObject *scale_data; GtkWidget *progressive; @@ -1553,7 +1556,6 @@ save_dialog (void) GtkWidget *vscrollbar; GtkWidget *prv_frame; - GtkWidget *prv_table; GDrawableType dtype; dlg = gimp_dialog_new (_("Save as Jpeg"), "jpeg", @@ -1572,28 +1574,35 @@ save_dialog (void) GTK_SIGNAL_FUNC (save_close_callback), NULL); + main_vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox, + TRUE, TRUE, 0); + gtk_widget_show (main_vbox); + /* sg - preview */ prv_frame = gtk_frame_new (_("Image Preview")); gtk_frame_set_shadow_type (GTK_FRAME (prv_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (prv_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), prv_frame, TRUE, TRUE, 0); - prv_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (prv_table), 10); - gtk_container_add (GTK_CONTAINER (prv_frame), prv_table); - - preview = gtk_check_button_new_with_label(_("Preview (in image window)")); - gtk_table_attach(GTK_TABLE(prv_table), preview, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - gtk_signal_connect(GTK_OBJECT(preview), "toggled", - (GtkSignalFunc) save_preview_toggle, NULL); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (preview), jsvals.preview); + gtk_box_pack_start (GTK_BOX (main_vbox), prv_frame, FALSE, FALSE, 0); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (prv_frame), vbox); + gtk_widget_show (vbox); + + preview = gtk_check_button_new_with_label (_("Preview (in Image Window)")); + gtk_box_pack_start (GTK_BOX (vbox), preview, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (preview), "toggled", + GTK_SIGNAL_FUNC (save_preview_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preview), jsvals.preview); gtk_widget_show (preview); preview_size = gtk_label_new (_("Size: unknown")); gtk_misc_set_alignment (GTK_MISC (preview_size), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (prv_table), preview_size, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + gtk_box_pack_start (GTK_BOX (vbox), preview_size, FALSE, FALSE, 0); gtk_widget_show (preview_size); - - gtk_widget_show (prv_table); + gtk_widget_show (prv_frame); make_preview (); @@ -1601,86 +1610,109 @@ save_dialog (void) /* parameter settings */ frame = gtk_frame_new (_("Parameter Settings")); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, TRUE, TRUE, 0); - table = gtk_table_new (8, 2, FALSE); - gtk_container_border_width (GTK_CONTAINER (table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); + + table = gtk_table_new (9, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); gtk_container_add (GTK_CONTAINER (frame), table); - label = gtk_label_new (_("Quality")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Quality:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.quality, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 0, 1, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.quality); - gtk_widget_show (label); gtk_widget_show (scale); - label = gtk_label_new (_("Smoothing")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + label = gtk_label_new (_("Smoothing:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (label); + scale_data = gtk_adjustment_new (jsvals.smoothing, 0.0, 1.0, 0.01, 0.01, 0.0); scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); gtk_widget_set_usize (scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), scale, 1, 3, 1, 2, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (scale), 2); gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_scale_update, + GTK_SIGNAL_FUNC (save_scale_update), &jsvals.smoothing); - gtk_widget_show (label); gtk_widget_show (scale); /* sg - have to init scale here */ - scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, 1, 64, 1, 1, 0.0); + scale_data = gtk_adjustment_new ((jsvals.restart == 0) ? 1 : jsvals.restart, + 1, 64, 1, 1, 0.0); restart_markers_scale = gtk_hscale_new (GTK_ADJUSTMENT (scale_data)); - restart = gtk_check_button_new_with_label (_("Restart markers")); - gtk_table_attach (GTK_TABLE (table), restart, 0, 2, 2, 3, GTK_FILL, 0, 0, 0); + restart = gtk_check_button_new_with_label (_("Restart Markers")); + gtk_table_attach (GTK_TABLE (table), restart, 0, 1, 2, 3, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (restart), "toggled", - (GtkSignalFunc) save_restart_toggle_update, scale_data); + GTK_SIGNAL_FUNC (save_restart_toggle_update), + scale_data); gtk_widget_show (restart); - restart_markers_label = gtk_label_new (_("Restart frequency (rows)")); - gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); + restart_markers_label = gtk_label_new (_("Restart Frequency (Rows):")); + gtk_misc_set_alignment (GTK_MISC (restart_markers_label), 1.0, 1.0); + gtk_table_attach (GTK_TABLE (table), restart_markers_label, 0, 1, 3, 4, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_widget_show (restart_markers_label); + + abox = gtk_alignment_new (0.5, 1.0, 1.0, 0.0); + gtk_table_attach (GTK_TABLE (table), abox, 1, 3, 2, 4, + GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_widget_show (abox); gtk_widget_set_usize (restart_markers_scale, SCALE_WIDTH, 0); - gtk_table_attach (GTK_TABLE (table), restart_markers_scale, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + gtk_container_add (GTK_CONTAINER (abox), restart_markers_scale); gtk_scale_set_value_pos (GTK_SCALE (restart_markers_scale), GTK_POS_TOP); gtk_scale_set_digits (GTK_SCALE (restart_markers_scale), 0); - gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), GTK_UPDATE_DELAYED); + gtk_range_set_update_policy (GTK_RANGE (restart_markers_scale), + GTK_UPDATE_DELAYED); gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - (GtkSignalFunc) save_restart_update, + GTK_SIGNAL_FUNC (save_restart_update), restart); - gtk_widget_set_sensitive (restart_markers_label, (jsvals.restart ? TRUE : FALSE)); - gtk_widget_set_sensitive (restart_markers_scale, (jsvals.restart ? TRUE : FALSE)); - - gtk_widget_show (restart_markers_label); + gtk_widget_set_sensitive (restart_markers_label, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_set_sensitive (restart_markers_scale, + (jsvals.restart ? TRUE : FALSE)); + gtk_widget_show (restart_markers_scale); toggle = gtk_check_button_new_with_label (_("Optimize")); - gtk_table_attach (GTK_TABLE (table), toggle, 0, 2, 4, 5, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), toggle, 0, 3, 4, 5, + GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (toggle), "toggled", - (GtkSignalFunc)save_optimize_update, NULL); + GTK_SIGNAL_FUNC (save_optimize_update), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), jsvals.optimize); - gtk_widget_show(toggle); + gtk_widget_show (toggle); progressive = gtk_check_button_new_with_label (_("Progressive")); - gtk_table_attach (GTK_TABLE (table), progressive, 0, 2, 5, 6, + gtk_table_attach (GTK_TABLE (table), progressive, 0, 3, 5, 6, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (progressive), "toggled", - (GtkSignalFunc)save_progressive_toggle, NULL); + GTK_SIGNAL_FUNC (save_progressive_toggle), + NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (progressive), jsvals.progressive); gtk_widget_show (progressive); @@ -1689,28 +1721,31 @@ save_dialog (void) gtk_widget_set_sensitive (progressive, FALSE); #endif - baseline = gtk_check_button_new_with_label (_("Force baseline JPEG (readable by all decoders)")); - gtk_table_attach (GTK_TABLE (table), baseline, 0, 2, 6, 7, + baseline = gtk_check_button_new_with_label (_("Force Baseline JPEG (Readable by all Decoders)")); + gtk_table_attach (GTK_TABLE (table), baseline, 0, 3, 6, 7, GTK_FILL, 0, 0, 0); gtk_signal_connect (GTK_OBJECT (baseline), "toggled", - (GtkSignalFunc)save_baseline_toggle, NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(baseline), + GTK_SIGNAL_FUNC (save_baseline_toggle), + NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (baseline), jsvals.baseline); - gtk_widget_show(baseline); + gtk_widget_show (baseline); /* build option menu (code taken from app/buildmenu.c) */ menu = gtk_menu_new (); - add_menu_item(menu, "2x2,1x1,1x1", 0, subsmp_callback); - add_menu_item(menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); - add_menu_item(menu, "1x1,1x1,1x1", 2, subsmp_callback); + add_menu_item (menu, "2x2,1x1,1x1", 0, subsmp_callback); + add_menu_item (menu, "2x1,1x1,1x1 (4:2:2)", 1, subsmp_callback); + add_menu_item (menu, "1x1,1x1,1x1", 2, subsmp_callback); subsmp_menu = gtk_option_menu_new (); - label = gtk_label_new (_("Subsampling")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), subsmp_menu, 1, 2, 7, 8, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("Subsampling:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 7, 8, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), subsmp_menu, 2, 3, 7, 8, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (subsmp_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (subsmp_menu), menu); @@ -1724,10 +1759,12 @@ save_dialog (void) dct_menu = gtk_option_menu_new (); - label = gtk_label_new (_("DCT method (speed/quality tradeoff)")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 0); - gtk_table_attach (GTK_TABLE (table), dct_menu, 1, 2, 8, 9, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); + label = gtk_label_new (_("DCT Method (Speed/Quality Tradeoff):")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, 0, 2, 8, 9, + GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), dct_menu, 2, 3, 8, 9, + GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); gtk_widget_show (label); gtk_widget_show (dct_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (dct_menu), menu); @@ -1741,18 +1778,18 @@ save_dialog (void) com_frame = gtk_frame_new (_("Image Comments")); gtk_frame_set_shadow_type (GTK_FRAME (com_frame), GTK_SHADOW_ETCHED_IN); - gtk_container_border_width (GTK_CONTAINER (com_frame), 10); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), com_frame, TRUE, TRUE, 0); - com_table = gtk_table_new (1, 1, FALSE); - gtk_container_border_width (GTK_CONTAINER (com_table), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), com_frame, TRUE, TRUE, 0); + + com_table = gtk_table_new (1, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (com_table), 4); gtk_container_add (GTK_CONTAINER (com_frame), com_table); text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), TRUE); - gtk_widget_set_usize(text,-1,3); /* //HB: restrict to 3 line height - * to allow 800x600 mode */ + gtk_widget_set_usize (text, -1, 3); /* //HB: restrict to 3 line height + * to allow 800x600 mode */ if (image_comment) - gtk_text_insert(GTK_TEXT(text),NULL,NULL,NULL,image_comment,-1); + gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, image_comment, -1); gtk_table_attach (GTK_TABLE (com_table), text, 0, 1, 0, 1, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); @@ -1786,7 +1823,6 @@ save_dialog (void) return jsint.run; } - /* Save interface functions */ static void @@ -1850,7 +1886,7 @@ save_restart_update (GtkAdjustment *adjustment, static void save_optimize_update (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.optimize = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1858,7 +1894,7 @@ save_optimize_update (GtkWidget *widget, static void save_progressive_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.progressive = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1866,7 +1902,7 @@ save_progressive_toggle (GtkWidget *widget, static void save_baseline_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.baseline = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1874,7 +1910,7 @@ save_baseline_toggle (GtkWidget *widget, static void save_preview_toggle (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.preview = GTK_TOGGLE_BUTTON (widget)->active; make_preview (); @@ -1882,7 +1918,7 @@ save_preview_toggle (GtkWidget *widget, static void subsmp_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.subsmp = *((guchar *)data); make_preview (); @@ -1890,7 +1926,7 @@ subsmp_callback (GtkWidget *widget, static void dct_callback (GtkWidget *widget, - gpointer data) + gpointer data) { jsvals.dct = *((guchar *)data); make_preview (); diff --git a/plug-ins/unsharp/Makefile.am b/plug-ins/unsharp/Makefile.am index e73a3d948b0941d76f80dfd6dcccfecd4ad56845..0544491b28c5df70df6102e61d2aa1484ef1feff 100644 --- a/plug-ins/unsharp/Makefile.am +++ b/plug-ins/unsharp/Makefile.am @@ -5,10 +5,6 @@ libexecdir = $(gimpplugindir)/plug-ins libexec_PROGRAMS = unsharp unsharp_SOURCES = \ - dialog_f.h \ - dialog_f.c \ - dialog_i.h \ - dialog_i.c \ unsharp.c AM_CPPFLAGS = \ @@ -20,6 +16,7 @@ INCLUDES = \ -I$(includedir) LDADD = \ + $(top_builddir)/libgimp/libgimpui.la \ $(top_builddir)/libgimp/libgimp.la \ $(GTK_LIBS) \ $(INTLLIBS) diff --git a/plug-ins/unsharp/dialog_f.c b/plug-ins/unsharp/dialog_f.c deleted file mode 100644 index 2ab5947039ad24f75e043cff43319b087852d344..0000000000000000000000000000000000000000 --- a/plug-ins/unsharp/dialog_f.c +++ /dev/null @@ -1,220 +0,0 @@ -/* $Id$ - * dialog_f.c -- functions for creating a GTK gdouble slider/value input. - * - * Copyright (C) 1999 Winston Chang - * - * - * - * 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 -#include -#include -#include - -#include "dialog_f.h" - -/* - * 'dialog_create_value_f()' - Create an gdouble value control... - */ -void -dialog_create_value_f(char *title, /* Label for control */ - GtkTable *table, /* Table container to use */ - int row, /* Row # for container */ - gdouble *value, /* Value holder */ - gdouble increment,/* Size of mouse-click and - keyboard increment */ - gint precision,/* Number of digits after decimal point */ - int left, /* Minimum value for slider */ - int right) /* Maximum value for slider */ -{ - GtkWidget *label; /* Control label */ - GtkWidget *scale; /* Scale widget */ - GtkWidget *entry; /* Text widget */ - GtkObject *scale_data; /* Scale data */ - char buf[256]; /* String buffer */ - - /* Create label... */ - - label = gtk_label_new(title); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 1.0); - gtk_table_attach(table, label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 4, 0); - gtk_widget_show(label); - - /* - * Scale... - */ - /* the "right+increment" is necessary to make it stop on 5.0 instead - of 4.9. I think this is a shortcoming of GTK's adjustments */ - scale_data = gtk_adjustment_new(*value, left, right+increment, - increment, increment, increment); - - gtk_signal_connect(GTK_OBJECT(scale_data), "value_changed", - (GtkSignalFunc) dialog_fscale_update, value); - - scale = gtk_hscale_new(GTK_ADJUSTMENT(scale_data)); - gtk_scale_set_digits( GTK_SCALE(scale), precision); - gtk_widget_set_usize(scale, SCALE_WIDTH, 0); - gtk_table_attach( table, scale, 1, 2, row, row + 1, - GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_scale_set_draw_value( GTK_SCALE(scale), FALSE); - gtk_range_set_update_policy( GTK_RANGE(scale), GTK_UPDATE_CONTINUOUS); - gtk_widget_show(scale); - - /* - * Text entry... - */ - - entry = gtk_entry_new(); - gtk_object_set_user_data(GTK_OBJECT(entry), scale_data); - gtk_object_set_user_data(scale_data, entry); - gtk_widget_set_usize(entry, ENTRY_WIDTH, 0); - sprintf(buf, "%g", *value); - gtk_entry_set_text(GTK_ENTRY(entry), buf); - gtk_signal_connect(GTK_OBJECT(entry), "changed", - (GtkSignalFunc) dialog_fentry_update, - value); - gtk_table_attach( GTK_TABLE(table), entry, 2, 3, row, row + 1, - GTK_FILL, GTK_FILL, 4, 0); - gtk_widget_show(entry); -} - - -/* - * 'dialog_fscale_update()' - Update the value field using the scale. - */ - -void -dialog_fscale_update(GtkAdjustment *adjustment, /* I - New value */ - gdouble *value) /* I - Current value */ -{ - GtkWidget *entry; /* Text entry widget */ - char buf[256]; /* Text buffer */ - - - if (*value != adjustment->value) - { - *value = adjustment->value; - - entry = gtk_object_get_user_data(GTK_OBJECT(adjustment)); - - /* UGLY HACK ALERT */ - /* use precision of 5 */ - sprintf(buf, "%.5g", *value); - /* This is to round the number to a reasonable value. For some - some reason it wants to increment by about 0.1000000105 instead - of 0.1. That annoys me. */ - *value = atof(buf); - - /* assign the text value to the entry */ - gtk_signal_handler_block_by_data(GTK_OBJECT(entry), value); - gtk_entry_set_text(GTK_ENTRY(entry), buf); - gtk_signal_handler_unblock_by_data(GTK_OBJECT(entry), value); - - /* assign the rounded value back the adjustment */ - adjustment->value = *value; - - - } -} - - -/* - * 'dialog_fentry_update()' - Update the value field using the text entry. - */ - -void -dialog_fentry_update(GtkWidget *widget, /* I - Entry widget */ - gdouble *value) /* I - Current value */ -{ - GtkAdjustment *adjustment; - gdouble new_value; - /* these three are for the string cleaner */ - gint shift; - gboolean periodfound; - gint digits_after_period; - gchar* textvalue; - gchar newtextvalue[MAX_ENTRY_LENGTH+1]; - gint oldtextlength; - gint i; - -/* new_value = atod(gtk_entry_get_text(GTK_ENTRY(widget))); */ - - textvalue = gtk_entry_get_text( GTK_ENTRY(widget)); - strncpy(newtextvalue, textvalue, MAX_ENTRY_LENGTH); - /* clean up new value so that it only has one digit after decimal - and no weird chars */ - newtextvalue[MAX_ENTRY_LENGTH] ='\0'; - oldtextlength = strlen(newtextvalue); - - /* this stuff cleans up non-numeric chars */ - shift=0; - periodfound = FALSE; - digits_after_period = 0; - for (i=0; i+shift < oldtextlength; i++) { - if (newtextvalue[i] == '.') { - if (periodfound) shift++; /* if not first period, ignore */ - else periodfound = TRUE; /* if first period, mark periodfound */ - } - else if (newtextvalue[i]>='0' && newtextvalue[i]<='9') { - if (periodfound) { - digits_after_period++; - /* this is to ignore a certain number of digits after period */ - if (digits_after_period > ENTRY_PRECISION) shift++; - } - } - else shift++; /* ignore non-numeric chars */ - - /* copy shifted value back, making sure we don't run off end */ - if (i+shift >= MAX_ENTRY_LENGTH) newtextvalue[i] = '\0'; - else newtextvalue[i] = newtextvalue[i+shift]; - } - newtextvalue[i]='\0'; - - - - /* write the cleaned-up value into the entry box */ - /* block the signal handler so we don't go into an infinite recursion */ - gtk_signal_handler_block_by_data(GTK_OBJECT(widget), value); - /* update the entry text */ - gtk_entry_set_text( GTK_ENTRY(widget), newtextvalue); - /* gtk_entry_set_position( GTK_ENTRY(widget), i); */ /* doesn't seem to work */ - /* unblock signal handler */ - gtk_signal_handler_unblock_by_data(GTK_OBJECT(widget), value); - - -/* g_print(newtextvalue); */ -/* g_print("\n"); */ - /* set the adjustment thingy */ - new_value = atof(newtextvalue); - -/* g_print("%e.", new_value); */ - - /* set the new value */ - if (*value != new_value) { - adjustment = gtk_object_get_user_data(GTK_OBJECT(widget)); - - if ((new_value >= adjustment->lower) && - (new_value <= adjustment->upper)) { - *value = new_value; - adjustment->value = new_value; - - gtk_signal_emit_by_name(GTK_OBJECT(adjustment), "value_changed"); - - } - } -} - diff --git a/plug-ins/unsharp/dialog_f.h b/plug-ins/unsharp/dialog_f.h deleted file mode 100644 index 1947b66df6039177bc8a79e4b7131bd719dcdac1..0000000000000000000000000000000000000000 --- a/plug-ins/unsharp/dialog_f.h +++ /dev/null @@ -1,22 +0,0 @@ -/* $Id$ - * - */ - -#ifndef __DIALOG_F_H__ -#define __DIALOG_F_H__ - -#define MAX_ENTRY_LENGTH 5 -#define ENTRY_WIDTH 40 -#define SCALE_WIDTH 100 -#define ENTRY_PRECISION 1 - - -void dialog_create_value_f(char *title, GtkTable *table, int row, - gdouble *value, - gdouble increment, int precision, - int left, int right); - -void dialog_fscale_update(GtkAdjustment *adjustment, gdouble *value); -void dialog_fentry_update(GtkWidget *widget, gdouble *value); - -#endif /* __DIALOG_F_H__ */ diff --git a/plug-ins/unsharp/dialog_i.c b/plug-ins/unsharp/dialog_i.c deleted file mode 100644 index 0b5a64f16f319c3344a42a7232b7abae88354bbd..0000000000000000000000000000000000000000 --- a/plug-ins/unsharp/dialog_i.c +++ /dev/null @@ -1,194 +0,0 @@ -/* $Id$ - * dialog_i.c -- functions for creating a GTK int slider/value input. - * - * Copyright (C) 1999 Winston Chang - * - * - * - * 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 -#include -#include -#include - -#include "dialog_i.h" - -/* - * 'dialog_create_value_i()' - Create an gint value control... - */ -void -dialog_create_value_i(char *title, /* Label for control */ - GtkTable *table, /* Table container to use */ - int row, /* Row # for container */ - gint *value, /* Value holder */ - gint increment,/* Size of mouse-click and - keyboard increment */ - int left, /* Minimum value for slider */ - int right) /* Maximum value for slider */ -{ - GtkWidget *label; /* Control label */ - GtkWidget *scale; /* Scale widget */ - GtkWidget *entry; /* Text widget */ - GtkObject *scale_data; /* Scale data */ - char buf[256]; /* String buffer */ - - /* Create label... */ - - label = gtk_label_new(title); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 1.0); - gtk_table_attach(table, label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 4, 0); - gtk_widget_show(label); - - /* - * Scale... - */ - /* the "right+increment" is necessary to make it stop on 5.0 instead - of 4.9. I think this is a shortcoming of GTK's adjustments */ - scale_data = gtk_adjustment_new((gfloat)*value, left, right+increment, - increment, increment, increment); - - gtk_signal_connect(GTK_OBJECT(scale_data), "value_changed", - (GtkSignalFunc) dialog_iscale_update, value); - - scale = gtk_hscale_new(GTK_ADJUSTMENT(scale_data)); - gtk_scale_set_digits( GTK_SCALE(scale), 0); - gtk_widget_set_usize(scale, SCALE_WIDTH, 0); - gtk_table_attach( table, scale, 1, 2, row, row + 1, - GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_scale_set_draw_value( GTK_SCALE(scale), FALSE); - gtk_range_set_update_policy( GTK_RANGE(scale), GTK_UPDATE_CONTINUOUS); - gtk_widget_show(scale); - - /* - * Text entry... - */ - - entry = gtk_entry_new(); - gtk_object_set_user_data(GTK_OBJECT(entry), scale_data); - gtk_object_set_user_data(scale_data, entry); - gtk_widget_set_usize(entry, ENTRY_WIDTH, 0); - sprintf(buf, "%d", *value); - gtk_entry_set_text(GTK_ENTRY(entry), buf); - gtk_signal_connect(GTK_OBJECT(entry), "changed", - (GtkSignalFunc) dialog_ientry_update, - value); - gtk_table_attach( GTK_TABLE(table), entry, 2, 3, row, row + 1, - GTK_FILL, GTK_FILL, 4, 0); - gtk_widget_show(entry); -} - - -/* - * 'dialog_iscale_update()' - Update the value field using the scale. - */ - -void -dialog_iscale_update(GtkAdjustment *adjustment, /* I - New value */ - gint *value) /* I - Current value */ -{ - GtkWidget *entry; /* Text entry widget */ - char buf[256]; /* Text buffer */ - - if (*value != (int)adjustment->value) - { - *value = (int)adjustment->value; - - sprintf(buf, "%d", *value); - - - entry = gtk_object_get_user_data(GTK_OBJECT(adjustment)); - - /* assign the text value to the entry */ - gtk_signal_handler_block_by_data(GTK_OBJECT(entry), value); - gtk_entry_set_text(GTK_ENTRY(entry), buf); - gtk_signal_handler_unblock_by_data(GTK_OBJECT(entry), value); - - /* assign the rounded value back the adjustment */ - adjustment->value = (gdouble)*value; - - - } -} - - -/* - * 'dialog_ientry_update()' - Update the value field using the text entry. - */ - -void -dialog_ientry_update(GtkWidget *widget, /* I - Entry widget */ - gint *value) /* I - Current value */ -{ - GtkAdjustment *adjustment; - gint new_value; - gint shift; - gchar* textvalue; - gchar newtextvalue[MAX_ENTRY_LENGTH+1]; - gint oldtextlength; - gint i; - - - textvalue = gtk_entry_get_text( GTK_ENTRY(widget)); - strncpy(newtextvalue, textvalue, MAX_ENTRY_LENGTH); - /* clean up new value so that it only has one digit after decimal - and no weird chars */ - newtextvalue[MAX_ENTRY_LENGTH] ='\0'; - oldtextlength = strlen(newtextvalue); - - /* this stuff cleans up non-numeric chars */ - shift=0; - for (i=0; i+shift < oldtextlength; i++) { - if ( !(newtextvalue[i]>='0' && newtextvalue[i]<='9')) - shift++; /* ignore non-numeric chars */ - - /* copy shifted value back, making sure we don't run off end */ - if (i+shift >= MAX_ENTRY_LENGTH) newtextvalue[i] = '\0'; - else newtextvalue[i] = newtextvalue[i+shift]; - } - newtextvalue[i]='\0'; - - - - /* write the cleaned-up value into the entry box */ - /* block the signal handler so we don't go into an infinite recursion */ - gtk_signal_handler_block_by_data(GTK_OBJECT(widget), value); - /* update the entry text */ - gtk_entry_set_text( GTK_ENTRY(widget), newtextvalue); - /* gtk_entry_set_position( GTK_ENTRY(widget), i); */ /* doesn't seem to work */ - /* unblock signal handler */ - gtk_signal_handler_unblock_by_data(GTK_OBJECT(widget), value); - - - /* set the adjustment thingy */ - new_value = atoi(newtextvalue); - - - /* set the new value */ - if (*value != new_value) { - adjustment = gtk_object_get_user_data(GTK_OBJECT(widget)); - - if ((new_value >= adjustment->lower) && - (new_value <= adjustment->upper)) { - *value = new_value; - adjustment->value = new_value; - - gtk_signal_emit_by_name(GTK_OBJECT(adjustment), "value_changed"); - - } - } -} - diff --git a/plug-ins/unsharp/dialog_i.h b/plug-ins/unsharp/dialog_i.h deleted file mode 100644 index 808cbea0a9d8f7cd30aada2d05546df51117ba42..0000000000000000000000000000000000000000 --- a/plug-ins/unsharp/dialog_i.h +++ /dev/null @@ -1,22 +0,0 @@ -/* $Id$ - * - */ - -#ifndef __DIALOG_I_H__ -#define __DIALOG_I_H__ - -#define MAX_ENTRY_LENGTH 5 -#define ENTRY_WIDTH 40 -#define SCALE_WIDTH 100 -#define ENTRY_PRECISION 1 - - -void dialog_create_value_i(char *title, GtkTable *table, int row, - gint *value, - gint increment, - int left, int right); - -void dialog_iscale_update(GtkAdjustment *adjustment, gint *value); -void dialog_ientry_update(GtkWidget *widget, gint *value); - -#endif /* __DIALOG_I_H__ */ diff --git a/plug-ins/unsharp/unsharp.c b/plug-ins/unsharp/unsharp.c index d1718e0bd13a4ac9546a804b044134d9e87533c0..1c7beea0e32ede36bc555f1ee82b6314013a7eac 100644 --- a/plug-ins/unsharp/unsharp.c +++ b/plug-ins/unsharp/unsharp.c @@ -25,19 +25,20 @@ #include "config.h" #include -#include #include #include -#include "gtk/gtk.h" -#include "libgimp/gimp.h" -#include "libgimp/stdplugins-intl.h" +#include + +#include +#include +#include -#include "dialog_f.h" -#include "dialog_i.h" +#include "libgimp/stdplugins-intl.h" #define PLUG_IN_VERSION "0.10" +#define SCALE_WIDTH 150 /* to show both pretty unoptimized code and ugly optimized code blocks There's really no reason to define this, unless you want to see how @@ -49,770 +50,806 @@ plug-in takes to run */ /* #define TIMER */ #ifdef TIMER - #include - #include - static void timerstart(); - static void timerstop(); - static struct timeval time_start,time_stop; +#include +#include + +static void timerstart (void); +static void timerstop (void); +static struct timeval time_start, time_stop; #endif -typedef struct { - gdouble radius; - gdouble amount; - gint threshold; +typedef struct +{ + gdouble radius; + gdouble amount; + gint threshold; } UnsharpMaskParams; -typedef struct { - gint run; +typedef struct +{ + gint run; } UnsharpMaskInterface; /* local function prototypes */ -static inline void blur_line(gdouble* ctable, gdouble* cmatrix, gint cmatrix_length, - guchar* cur_col, guchar* dest_col, - gint y, glong bytes); -static int gen_convolve_matrix(double std_dev, double** cmatrix); -static gdouble* gen_lookup_table(gdouble* cmatrix, gint cmatrix_length); -static inline gint round2int(gdouble i); -static void unsharp_region (GPixelRgn srcPTR, GPixelRgn dstPTR, - gint width, gint height, gint bytes, - gdouble radius, gdouble amount, - gint x1, gint x2, gint y1, gint y2); - - - -static void query(void); -static void run (gchar *name, - gint nparams, - GParam *param, - gint *nreturn_vals, - GParam **return_vals); -static void unsharp_mask(GDrawable *drawable, gint radius, gdouble amount); - - -static void unsharp_cancel_callback (GtkWidget *widget, gpointer data); -static void unsharp_ok_callback (GtkWidget *widget, gpointer data); -static gint unsharp_mask_dialog(); +static void query (void); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); + +static inline void blur_line (gdouble *ctable, + gdouble *cmatrix, + gint cmatrix_length, + guchar *cur_col, + guchar *dest_col, + gint y, + glong bytes); +static int gen_convolve_matrix (gdouble std_dev, + gdouble **cmatrix); +static gdouble* gen_lookup_table (gdouble* cmatrix, + gint cmatrix_length); +static void unsharp_region (GPixelRgn srcPTR, + GPixelRgn dstPTR, + gint width, + gint height, + gint bytes, + gdouble radius, + gdouble amount, + gint x1, + gint x2, + gint y1, + gint y2); + +static void unsharp_mask (GDrawable *drawable, + gint radius, + gdouble amount); + +static void unsharp_ok_callback (GtkWidget *widget, + gpointer data); +static gint unsharp_mask_dialog (void); + /* preview shit -- not finished yet */ #undef PREVIEW #ifdef PREVIEW -static void preview_scroll_callback(void); -static void preview_init(void); -static void preview_exit(void); -static void preview_update(void); -static void dialog_create_ivalue(char *title, /* I - Label for control */ - GtkTable *table, /* I - Table container to use */ - int row, /* I - Row # for container */ - gint *value, /* I - Value holder */ - int left, /* I - Minimum value for slider */ - int right); /* I - Maximum value for slider */ - +static void preview_scroll_callback (void); +static void preview_init (void); +static void preview_exit (void); +static void preview_update (void); static GtkWidget* preview; -static int preview_width; /* Width of preview widget */ -static int preview_height; /* Height of preview widget */ -static int preview_x1; /* Upper-left X of preview */ -static int preview_y1; /* Upper-left Y of preview */ -static int preview_x2; /* Lower-right X of preview */ -static int preview_y2; /* Lower-right Y of preview */ - -static int sel_width; /* Selection width */ -static int sel_height; /* Selection height */ +static int preview_width; /* Width of preview widget */ +static int preview_height; /* Height of preview widget */ +static int preview_x1; /* Upper-left X of preview */ +static int preview_y1; /* Upper-left Y of preview */ +static int preview_x2; /* Lower-right X of preview */ +static int preview_y2; /* Lower-right Y of preview */ + +static int sel_width; /* Selection width */ +static int sel_height; /* Selection height */ static GtkObject *hscroll_data; /* Horizontal scrollbar data */ static GtkObject *vscroll_data; /* Vertical scrollbar data */ #endif -static gint run_filter = FALSE; +static gint run_filter = FALSE; - /* create a few globals, set default values */ static UnsharpMaskParams unsharp_params = { - 5.0, /* default radius = 5 */ - 0.5, /* default amount = .5 */ - 0 /* default threshold = 0 */ + 5.0, /* default radius = 5 */ + 0.5, /* default amount = .5 */ + 0 /* default threshold = 0 */ }; /* static UnsharpMaskInterface umint = { FALSE }; */ /* Setting PLUG_IN_INFO */ -GPlugInInfo PLUG_IN_INFO = { - NULL, /* init_proc */ - NULL, /* quit_proc */ - query, /* query_proc */ - run, /* run_proc */ +GPlugInInfo PLUG_IN_INFO = +{ + NULL, /* init_proc */ + NULL, /* quit_proc */ + query, /* query_proc */ + run, /* run_proc */ }; +MAIN () -MAIN() - - -static void query () { - - static GParamDef args[] = { - { PARAM_INT32, "run_mode", "Interactive, non-interactive" }, - { PARAM_IMAGE, "image", "(unused)" }, - { PARAM_DRAWABLE, "drawable", "Drawable to draw on" }, - { PARAM_FLOAT, "radius", "Radius of gaussian blur (in pixels > 1.0)" }, - { PARAM_FLOAT, "amount", "Strength of effect" }, - { PARAM_FLOAT, "threshold", "Threshold" } - }; - static gint nargs = sizeof(args) / sizeof(args[0]); - /* for return vals */ - static GParamDef *return_vals = NULL; - static int nreturn_vals = 0; +static void +query (void) +{ + static GParamDef args[] = + { + { PARAM_INT32, "run_mode", "Interactive, non-interactive" }, + { PARAM_IMAGE, "image", "(unused)" }, + { PARAM_DRAWABLE, "drawable", "Drawable to draw on" }, + { PARAM_FLOAT, "radius", "Radius of gaussian blur (in pixels > 1.0)" }, + { PARAM_FLOAT, "amount", "Strength of effect" }, + { PARAM_FLOAT, "threshold", "Threshold" } + }; + static gint nargs = sizeof(args) / sizeof(args[0]); + /* for return vals */ + static GParamDef *return_vals = NULL; + static int nreturn_vals = 0; - INIT_I18N(); - - /* Install a procedure in the procedure database. */ - gimp_install_procedure ("plug_in_unsharp_mask", - _("An unsharp mask filter"), - "", - "Winston Chang ", - "Winston Chang", - "1999", - N_("/Filters/Enhance/Unsharp Mask..."), - "GRAY*, RGB*", - PROC_PLUG_IN, - nargs, nreturn_vals, - args, return_vals); + INIT_I18N(); + + /* Install a procedure in the procedure database. */ + gimp_install_procedure ("plug_in_unsharp_mask", + _("An unsharp mask filter"), + "", + "Winston Chang ", + "Winston Chang", + "1999", + N_("/Filters/Enhance/Unsharp Mask..."), + "GRAY*, RGB*", + PROC_PLUG_IN, + nargs, nreturn_vals, + args, return_vals); } - /* this is the actual function */ -static void run(char *name, int nparams, GParam *param, int *nreturn_vals, - GParam **return_vals) { - - static GParam values[1]; - GDrawable *drawable; - GRunModeType run_mode; - GStatusType status = STATUS_SUCCESS; - -#ifdef TIMER - timerstart(); -#endif - - run_mode = param[0].data.d_int32; - - values[0].type = PARAM_STATUS; - values[0].data.d_status = status; - *return_vals = values; - *nreturn_vals = 1; - - INIT_I18N_UI(); - - switch (run_mode) { - case RUN_INTERACTIVE: - gimp_get_data ("plug_in_unsharp_mask", &unsharp_params); - if (! unsharp_mask_dialog ()) return; - break; - - case RUN_NONINTERACTIVE: - if (nparams != 6) status = STATUS_CALLING_ERROR; - /* get the parameters */ - else if (status == STATUS_SUCCESS) { - unsharp_params.radius = param[3].data.d_float; - unsharp_params.amount = param[4].data.d_float; - unsharp_params.threshold = param[5].data.d_int32; - - /* make sure there are legal values */ - if ( (unsharp_params.radius < 0.0) || - (unsharp_params.amount<0.0) ) - status = STATUS_CALLING_ERROR; - } - break; - - case RUN_WITH_LAST_VALS: - gimp_get_data ("plug_in_unsharp_mask", &unsharp_params); - break; - - default: - break; - } - - if (status == STATUS_SUCCESS) { - drawable = gimp_drawable_get (param[2].data.d_drawable); - gimp_tile_cache_ntiles(2 * (drawable->width / gimp_tile_width() + 1)); - - /* here we go */ - unsharp_mask(drawable, unsharp_params.radius, unsharp_params.amount); - - /* values[0].data.d_status = status; */ - gimp_displays_flush (); - - /* set data for next use of filter */ - gimp_set_data ("plug_in_unsharp_mask", &unsharp_params, - sizeof (UnsharpMaskParams)); - - /*fprintf(stderr, "%f %f\n", unsharp_params.radius, unsharp_params.amount);*/ - - gimp_drawable_detach(drawable); - values[0].data.d_status = status; +static void +run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals) +{ + static GParam values[1]; + GDrawable *drawable; + GRunModeType run_mode; + GStatusType status = STATUS_SUCCESS; - } #ifdef TIMER - timerstop(); + timerstart(); #endif -} + run_mode = param[0].data.d_int32; + + values[0].type = PARAM_STATUS; + values[0].data.d_status = status; + *return_vals = values; + *nreturn_vals = 1; + + INIT_I18N_UI(); + + switch (run_mode) + { + case RUN_INTERACTIVE: + gimp_get_data ("plug_in_unsharp_mask", &unsharp_params); + if (! unsharp_mask_dialog ()) return; + break; + + case RUN_NONINTERACTIVE: + if (nparams != 6) + status = STATUS_CALLING_ERROR; + /* get the parameters */ + else if (status == STATUS_SUCCESS) + { + unsharp_params.radius = param[3].data.d_float; + unsharp_params.amount = param[4].data.d_float; + unsharp_params.threshold = param[5].data.d_int32; + + /* make sure there are legal values */ + if ((unsharp_params.radius < 0.0) || + (unsharp_params.amount<0.0)) + status = STATUS_CALLING_ERROR; + } + break; + case RUN_WITH_LAST_VALS: + gimp_get_data ("plug_in_unsharp_mask", &unsharp_params); + break; -/* -------------------------- Unsharp Mask ------------------------- */ -static void unsharp_mask(GDrawable *drawable, gint radius, gdouble amount) { - GPixelRgn srcPR, destPR; - glong width, height; - glong bytes; - gint x1, y1, x2, y2; - gdouble* cmatrix = NULL; - gint cmatrix_length; - gdouble* ctable; - - /* Get the input */ - gimp_drawable_mask_bounds(drawable->id, &x1, &y1, &x2, &y2); - gimp_progress_init(_("Blurring...")); - - /* generate convolution matrix */ - cmatrix_length = gen_convolve_matrix(radius, &cmatrix); - /* generate lookup table */ - ctable = gen_lookup_table(cmatrix, cmatrix_length); + default: + break; + } + if (status == STATUS_SUCCESS) + { + drawable = gimp_drawable_get (param[2].data.d_drawable); + gimp_tile_cache_ntiles(2 * (drawable->width / gimp_tile_width() + 1)); - width = drawable->width; - height = drawable->height; - bytes = drawable->bpp; + /* here we go */ + unsharp_mask (drawable, unsharp_params.radius, unsharp_params.amount); - /* initialize pixel regions */ - gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE); - gimp_pixel_rgn_init (&destPR, drawable, 0, 0, width, height, TRUE, TRUE); + /* values[0].data.d_status = status; */ + gimp_displays_flush (); + /* set data for next use of filter */ + gimp_set_data ("plug_in_unsharp_mask", &unsharp_params, + sizeof (UnsharpMaskParams)); - unsharp_region (srcPR, destPR, width, height, bytes, radius, amount, - x1, x2, y1, y2); + /*fprintf(stderr, "%f %f\n", unsharp_params.radius, unsharp_params.amount);*/ - - gimp_drawable_flush(drawable); - gimp_drawable_merge_shadow(drawable->id, TRUE); - gimp_drawable_update(drawable->id, x1, y1, (x2-x1), (y2-y1)); + gimp_drawable_detach(drawable); + values[0].data.d_status = status; + } +#ifdef TIMER + timerstop (); +#endif } - +/* -------------------------- Unsharp Mask ------------------------- */ +static void +unsharp_mask (GDrawable *drawable, + gint radius, + gdouble amount) +{ + GPixelRgn srcPR, destPR; + glong width, height; + glong bytes; + gint x1, y1, x2, y2; + gdouble* cmatrix = NULL; + gint cmatrix_length; + gdouble* ctable; + + /* Get the input */ + gimp_drawable_mask_bounds(drawable->id, &x1, &y1, &x2, &y2); + gimp_progress_init(_("Blurring...")); + + /* generate convolution matrix */ + cmatrix_length = gen_convolve_matrix(radius, &cmatrix); + /* generate lookup table */ + ctable = gen_lookup_table(cmatrix, cmatrix_length); + + width = drawable->width; + height = drawable->height; + bytes = drawable->bpp; + + /* initialize pixel regions */ + gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE); + gimp_pixel_rgn_init (&destPR, drawable, 0, 0, width, height, TRUE, TRUE); + + unsharp_region (srcPR, destPR, width, height, bytes, radius, amount, + x1, x2, y1, y2); + + gimp_drawable_flush(drawable); + gimp_drawable_merge_shadow(drawable->id, TRUE); + gimp_drawable_update(drawable->id, x1, y1, (x2-x1), (y2-y1)); +} /* perform an unsharp mask on the region, given a source region, dest. region, width and height of the regions, and corner coordinates of a subregion to act upon. Everything outside the subregion is unaffected. */ -static void unsharp_region (GPixelRgn srcPR, GPixelRgn destPR, - gint width, gint height, gint bytes, - gdouble radius, gdouble amount, - gint x1, gint x2, gint y1, gint y2) { - guchar* cur_col; - guchar* dest_col; - guchar* cur_row; - guchar* dest_row; - gint x; - gint y; - gdouble* cmatrix = NULL; - gint cmatrix_length; - gdouble* ctable; - - gint row, col; /* these are counters for loops */ - - /* these are used for the merging step */ - gint threshold; - gint diff; - gint value; - gint u,v; - - /* find height and width of subregion to act on */ - x = x2-x1; - y = y2-y1; - - - /* generate convolution matrix and make sure it's smaller than each dimension */ - cmatrix_length = gen_convolve_matrix(radius, &cmatrix); - /* generate lookup table */ - ctable = gen_lookup_table(cmatrix, cmatrix_length); - - - - /* allocate row buffers */ - cur_row = (guchar *) g_malloc (x * bytes); - dest_row = (guchar *) g_malloc (x * bytes); - - /* find height and width of subregion to act on */ - x = x2-x1; - y = y2-y1; - - /* blank out a region of the destination memory area, I think */ - for (row = 0; row < y; row++) { - gimp_pixel_rgn_get_row(&destPR, dest_row, x1, y1+row, (x2-x1)); - memset(dest_row, 0, x*bytes); - gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y1+row, (x2-x1)); - } - - - /* blur the rows */ - for (row = 0; row < y; row++) { - gimp_pixel_rgn_get_row(&srcPR, cur_row, x1, y1+row, x); - gimp_pixel_rgn_get_row(&destPR, dest_row, x1, y1+row, x); - blur_line(ctable, cmatrix, cmatrix_length, cur_row, dest_row, x, bytes); - gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y1+row, x); - - if (row%5 == 0) gimp_progress_update((gdouble)row/(3*y)); - } - - - /* allocate column buffers */ - cur_col = (guchar *) g_malloc (y * bytes); - dest_col = (guchar *) g_malloc (y * bytes); - - /* blur the cols */ - for (col = 0; col < x; col++) { - gimp_pixel_rgn_get_col(&destPR, cur_col, x1+col, y1, y); - gimp_pixel_rgn_get_col(&destPR, dest_col, x1+col, y1, y); - blur_line(ctable, cmatrix, cmatrix_length, cur_col, dest_col, y, bytes); - gimp_pixel_rgn_set_col(&destPR, dest_col, x1+col, y1, y); - - if (col%5 == 0) gimp_progress_update((gdouble)col/(3*x) + 0.33); - } - - gimp_progress_init(_("Merging...")); - - /* find integer value of threshold */ - threshold = unsharp_params.threshold; +static void +unsharp_region (GPixelRgn srcPR, + GPixelRgn destPR, + gint width, + gint height, + gint bytes, + gdouble radius, + gdouble amount, + gint x1, + gint x2, + gint y1, + gint y2) +{ + guchar* cur_col; + guchar* dest_col; + guchar* cur_row; + guchar* dest_row; + gint x; + gint y; + gdouble* cmatrix = NULL; + gint cmatrix_length; + gdouble* ctable; + + gint row, col; /* these are counters for loops */ + + /* these are used for the merging step */ + gint threshold; + gint diff; + gint value; + gint u,v; + + /* find height and width of subregion to act on */ + x = x2-x1; + y = y2-y1; + + /* generate convolution matrix and make sure it's smaller than each dimension */ + cmatrix_length = gen_convolve_matrix(radius, &cmatrix); + /* generate lookup table */ + ctable = gen_lookup_table(cmatrix, cmatrix_length); + + /* allocate row buffers */ + cur_row = (guchar *) g_malloc (x * bytes); + dest_row = (guchar *) g_malloc (x * bytes); + + /* find height and width of subregion to act on */ + x = x2-x1; + y = y2-y1; + + /* blank out a region of the destination memory area, I think */ + for (row = 0; row < y; row++) + { + gimp_pixel_rgn_get_row(&destPR, dest_row, x1, y1+row, (x2-x1)); + memset(dest_row, 0, x*bytes); + gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y1+row, (x2-x1)); + } + + /* blur the rows */ + for (row = 0; row < y; row++) + { + gimp_pixel_rgn_get_row(&srcPR, cur_row, x1, y1+row, x); + gimp_pixel_rgn_get_row(&destPR, dest_row, x1, y1+row, x); + blur_line(ctable, cmatrix, cmatrix_length, cur_row, dest_row, x, bytes); + gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y1+row, x); + + if (row%5 == 0) + gimp_progress_update((gdouble)row/(3*y)); + } + + /* allocate column buffers */ + cur_col = (guchar *) g_malloc (y * bytes); + dest_col = (guchar *) g_malloc (y * bytes); + + /* blur the cols */ + for (col = 0; col < x; col++) + { + gimp_pixel_rgn_get_col(&destPR, cur_col, x1+col, y1, y); + gimp_pixel_rgn_get_col(&destPR, dest_col, x1+col, y1, y); + blur_line(ctable, cmatrix, cmatrix_length, cur_col, dest_col, y, bytes); + gimp_pixel_rgn_set_col(&destPR, dest_col, x1+col, y1, y); + + if (col%5 == 0) + gimp_progress_update((gdouble)col/(3*x) + 0.33); + } + + gimp_progress_init(_("Merging...")); + + /* find integer value of threshold */ + threshold = unsharp_params.threshold; - /* merge the source and destination (which currently contains - the blurred version) images */ - for (row = 0; row < y; row++) { - value = 0; - /* get source row */ - gimp_pixel_rgn_get_row(&srcPR, cur_row, x1, y1+row, x); - /* get dest row */ - gimp_pixel_rgn_get_row(&destPR, dest_row, x1, y1+row, x); - /* combine the two */ - for (u=0; u 255) dest_row[u*bytes+v] = 255; - else dest_row[u*bytes+v] = value; - } - } - /* update progress bar every five rows */ - if (row%5 == 0) gimp_progress_update((gdouble)row/(3*y) + 0.67); - gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y1+row, x); + if (value < 0) dest_row[u*bytes+v] =0; + else if (value > 255) dest_row[u*bytes+v] = 255; + else dest_row[u*bytes+v] = value; + } } - - /* free the memory we took */ - g_free(cur_row); - g_free(dest_row); - g_free(cur_col); - g_free(dest_col); - + /* update progress bar every five rows */ + if (row%5 == 0) gimp_progress_update((gdouble)row/(3*y) + 0.67); + gimp_pixel_rgn_set_row(&destPR, dest_row, x1, y1+row, x); + } + + /* free the memory we took */ + g_free(cur_row); + g_free(dest_row); + g_free(cur_col); + g_free(dest_col); } /* this function is written as if it is blurring a column at a time, even though it can operate on rows, too. There is no difference in the processing of the lines, at least to the blur_line function. */ -static inline void blur_line(gdouble* ctable, gdouble* cmatrix, - gint cmatrix_length, - guchar* cur_col, guchar* dest_col, - gint y, glong bytes) { - - +static inline void +blur_line (gdouble *ctable, + gdouble *cmatrix, + gint cmatrix_length, + guchar *cur_col, + guchar *dest_col, + gint y, + glong bytes) +{ #ifdef READABLE_CODE /* ------------- semi-readable code ------------------- */ - gdouble scale; - gdouble sum; - gint i,j; - gint row; - - - /* this is to take care cases in which the matrix can go over - * both edges at once. It's not efficient, but this can only - * happen in small pictures anyway. - */ - if (cmatrix_length > y) { - - for (row = 0; row < y ; row++) { - scale=0; - /* find the scale factor */ - for (j = 0; j < y ; j++) { - /* if the index is in bounds, add it to the scale counter */ - if ((j + cmatrix_length/2 - row >= 0) && - (j + cmatrix_length/2 - row < cmatrix_length)) - scale += cmatrix[j + cmatrix_length/2 - row]; - } - for (i = 0; i= row - cmatrix_length/2) && (j <= row + cmatrix_length/2) ) - sum += cur_col[j*bytes + i] * cmatrix[j]; - } - dest_col[row*bytes + i] = (guchar)round2int(sum / scale); - } + gdouble scale; + gdouble sum; + gint i,j; + gint row; + + /* this is to take care cases in which the matrix can go over + * both edges at once. It's not efficient, but this can only + * happen in small pictures anyway. + */ + if (cmatrix_length > y) + { + for (row = 0; row < y ; row++) + { + scale = 0; + /* find the scale factor */ + for (j = 0; j < y ; j++) + { + /* if the index is in bounds, add it to the scale counter */ + if ((j + cmatrix_length/2 - row >= 0) && + (j + cmatrix_length/2 - row < cmatrix_length)) + scale += cmatrix[j + cmatrix_length/2 - row]; + } + for (i = 0; i= row - cmatrix_length/2) && + (j <= row + cmatrix_length/2)) + sum += cur_col[j*bytes + i] * cmatrix[j]; } + dest_col[row*bytes + i] = (guchar) ROUND (sum / scale); + } } - - else { /* when the cmatrix is smaller than row length */ - - /* for the edge condition, we only use available info, and scale to one */ - for (row = 0; row < cmatrix_length/2; row++) { - /* find scale factor */ - scale=0; - for (j = cmatrix_length/2 - row; j y) { - - for (row = 0; row < y ; row++) { - scale=0; - /* find the scale factor */ - for (j = 0; j < y ; j++) { - /* if the index is in bounds, add it to the scale counter */ - if ((j + cmatrix_length/2 - row >= 0) && - (j + cmatrix_length/2 - row < cmatrix_length)) - scale += cmatrix[j + cmatrix_length/2 - row]; - } - for (i = 0; i= row - cmatrix_length/2) && (j <= row + cmatrix_length/2) ) - sum += cur_col[j*bytes + i] * cmatrix[j]; - } - dest_col[row*bytes + i] = (guchar)round2int(sum / scale); - } + /* --------------- optimized, unreadable code -------------------*/ + gdouble scale; + gdouble sum; + gint i=0, j=0; + gint row; + gint cmatrix_middle = cmatrix_length/2; + + gdouble *cmatrix_p; + guchar *cur_col_p; + guchar *cur_col_p1; + guchar *dest_col_p; + gdouble *ctable_p; + + /* this first block is the same as the non-optimized version -- + * it is only used for very small pictures, so speed isn't a + * big concern. + */ + if (cmatrix_length > y) + { + for (row = 0; row < y ; row++) + { + scale=0; + /* find the scale factor */ + for (j = 0; j < y ; j++) + { + /* if the index is in bounds, add it to the scale counter */ + if ((j + cmatrix_length/2 - row >= 0) && + (j + cmatrix_length/2 - row < cmatrix_length)) + scale += cmatrix[j + cmatrix_length/2 - row]; + } + for (i = 0; i= row - cmatrix_length/2) && + (j <= row + cmatrix_length/2)) + sum += cur_col[j*bytes + i] * cmatrix[j]; } + dest_col[row*bytes + i] = (guchar) ROUND (sum / scale); + } } - - else { - /* for the edge condition, we only use available info and scale to one */ - for (row = 0; row < cmatrix_middle; row++) { - /* find scale factor */ - scale=0; - for (j = cmatrix_middle - row; j0; j--) { - sum += *(ctable_p + *cur_col_p1); - cur_col_p1 += bytes; - ctable_p += 256; - } - cur_col_p++; - *(dest_col_p++) = round2int(sum); - } + dest_col[row*bytes + i] = (guchar) ROUND (sum / scale); + } + } + /* go through each pixel in each col */ + dest_col_p = dest_col + row*bytes; + for (; row < y-cmatrix_middle; row++) + { + cur_col_p = (row - cmatrix_middle) * bytes + cur_col; + for (i = 0; i0; j--) + { + sum += *(ctable_p + *cur_col_p1); + cur_col_p1 += bytes; + ctable_p += 256; } + cur_col_p++; + *(dest_col_p++) = ROUND (sum); + } + } - /* for the edge condition , we only use available info, and scale to one */ - for ( ; row < y; row++) { - /* find scale factor */ - scale=0; - for (j = 0; j< y-row + cmatrix_middle; j++) - scale += cmatrix[j]; - for (i = 0; ivbox), table, - FALSE, FALSE, 0); - - + _("OK"), unsharp_ok_callback, + NULL, NULL, NULL, TRUE, FALSE, + _("Cancel"), gtk_widget_destroy, + NULL, 1, NULL, FALSE, TRUE, - /* create each of the inputs */ - dialog_create_value_f(_("Radius:"), GTK_TABLE(table), 1, &unsharp_params.radius, - 0.1, 1, 1.0, 25.0); - dialog_create_value_f(_("Amount:"), GTK_TABLE(table), 2, &unsharp_params.amount, - 0.01, 2, 0.01, 5.0); - dialog_create_value_i(_("Threshold:"), GTK_TABLE(table), 3, &unsharp_params.threshold, - 1, 0, 255); - - - /* show table */ - gtk_widget_show(table); - - - /* Action area */ - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (window)->action_area), 2); - gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (window)->action_area), FALSE); - hbbox = gtk_hbutton_box_new (); - gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4); - gtk_box_pack_end (GTK_BOX (GTK_DIALOG (window)->action_area), hbbox, FALSE, FALSE, 0); - gtk_widget_show (hbbox); - - button = gtk_button_new_with_label (_("OK")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) unsharp_ok_callback, - window); - gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); - gtk_widget_grab_default (button); - gtk_widget_show (button); - - button = gtk_button_new_with_label (_("Cancel")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) unsharp_cancel_callback, NULL); - gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0); - gtk_widget_show (button); - - - /* show the window */ - gtk_widget_show (window); - - - gtk_main (); - gdk_flush(); - - /* return ok or cancel */ - return(run_filter); - + gtk_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (gtk_main_quit), + NULL); + + frame = gtk_frame_new (_("Parameter Settings")); + gtk_container_set_border_width (GTK_CONTAINER (frame), 6); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), frame, + FALSE, FALSE, 0); + gtk_widget_show (frame); + + table = gtk_table_new (3, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("Radius:"), SCALE_WIDTH, 0, + unsharp_params.radius, 1.0, 25.0, 0.1, 1.0, 1, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &unsharp_params.radius); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, + _("Amount:"), SCALE_WIDTH, 0, + unsharp_params.amount, 0.0, 5.0, 0.01, 0.1, 2, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &unsharp_params.amount); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, + _("Threshold:"), SCALE_WIDTH, 0, + unsharp_params.threshold, 0.0, 255.0, 1.0, 10.0, 0, + NULL, NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_int_adjustment_update), + &unsharp_params.threshold); + + gtk_widget_show (window); + + gtk_main (); + gdk_flush (); + + return run_filter; } @@ -821,13 +858,13 @@ static gint unsharp_mask_dialog() /* 'preview_init()' - Initialize the preview window... */ static void -preview_init(void) +preview_init (void) { int width; /* Byte width of the image */ - /* - * Setup for preview filter... - */ + /* + * Setup for preview filter... + */ width = preview_width * img_bpp; @@ -847,7 +884,7 @@ preview_init(void) */ static void -preview_scroll_callback(void) +preview_scroll_callback (void) { preview_x1 = sel_x1 + GTK_ADJUSTMENT(hscroll_data)->value; preview_y1 = sel_y1 + GTK_ADJUSTMENT(vscroll_data)->value; @@ -857,57 +894,48 @@ preview_scroll_callback(void) preview_update(); } - /* * 'preview_update()' - Update the preview window. */ static void -preview_update(void) { +preview_update (void) +{ } #endif -static void unsharp_cancel_callback (GtkWidget *widget, gpointer data) { - gtk_main_quit (); -} - -static void unsharp_ok_callback (GtkWidget *widget, gpointer data) { - run_filter = TRUE; - gtk_widget_destroy (GTK_WIDGET (data)); -} - -/* delete_event */ -gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ) { - - return FALSE; -} - +static void +unsharp_ok_callback (GtkWidget *widget, + gpointer data) +{ + run_filter = TRUE; -/* Destroy callback */ -void destroy( GtkWidget *widget, gpointer data ) { - gtk_main_quit(); + gtk_widget_destroy (GTK_WIDGET (data)); } - #ifdef TIMER -static void timerstart() { - gettimeofday(&time_start,NULL); +static void +timerstart (void) +{ + gettimeofday (&time_start, NULL); } -static void timerstop() { - long sec, usec; + +static void +timerstop (void) +{ + long sec, usec; - gettimeofday(&time_stop,NULL); - sec = time_stop.tv_sec - time_start.tv_sec; - usec = time_stop.tv_usec - time_start.tv_usec; + gettimeofday(&time_stop,NULL); + sec = time_stop.tv_sec - time_start.tv_sec; + usec = time_stop.tv_usec - time_start.tv_usec; - if (usec < 0) { - sec--; - usec += 1000000; - } + if (usec < 0) + { + sec--; + usec += 1000000; + } - fprintf(stderr, "%ld.%ld seconds\n", sec, usec); - + fprintf (stderr, "%ld.%ld seconds\n", sec, usec); } #endif -