Commit 0cc32e99 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

plug-ins/common/blur.c plug-ins/common/borderaverage.c

2004-05-18  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/blur.c
	* plug-ins/common/borderaverage.c
	* plug-ins/common/bumpmap.c
	* plug-ins/common/ccanalyze.c: HIG-ified.
parent 63133b30
2004-05-18 Sven Neumann <sven@gimp.org>
* plug-ins/common/blur.c
* plug-ins/common/borderaverage.c
* plug-ins/common/bumpmap.c
* plug-ins/common/ccanalyze.c: HIG-ified.
2004-05-18 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpsizeentry.[ch] (gimp_size_entry_attach_label):
......
......@@ -82,9 +82,10 @@
#define HELP_ID "plug-in-blur"
#define SEED_DEFAULT 10
#define SEED_USER 11
#define SEED_USER 11
#define SCALE_WIDTH 64
#define SCALE_WIDTH 100
/*********************************
*
......@@ -130,15 +131,15 @@ GimpPlugInInfo PLUG_IN_INFO =
run, /* run_proc */
};
static void blur (GimpDrawable *drawable);
static void blur (GimpDrawable *drawable);
static inline void blur_prepare_row (GimpPixelRgn *pixel_rgn,
guchar *data,
gint x,
gint y,
gint w);
static inline void blur_prepare_row (GimpPixelRgn *pixel_rgn,
guchar *data,
gint x,
gint y,
gint w);
static gint blur_dialog (void);
static gboolean blur_dialog (void);
/************************************ Guts ***********************************/
......@@ -577,11 +578,10 @@ blur (GimpDrawable *drawable)
* GUI ROUTINES
********************************/
static gint
static gboolean
blur_dialog (void)
{
GtkWidget *dlg;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *label;
GtkWidget *seed_hbox;
......@@ -604,23 +604,18 @@ blur_dialog (void)
*
* First set up the basic containers, label them, etc.
*/
frame = gtk_frame_new (_("Parameter Settings"));
gtk_container_set_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 (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_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_container_set_border_width (GTK_CONTAINER (table), 12);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dlg)->vbox), table, TRUE, TRUE, 0);
gtk_widget_show (table);
/* Random Seed */
seed_hbox = gimp_random_seed_new (&pivals.blur_seed, &pivals.blur_randomize);
label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("_Random Seed:"), 1.0, 0.5,
seed_hbox, 1, TRUE);
_("_Random Seed:"), 0.0, 0.5,
seed_hbox, 2, TRUE);
gtk_label_set_mnemonic_widget (GTK_LABEL (label),
GIMP_RANDOM_SEED_SPINBUTTON (seed_hbox));
......
......@@ -41,7 +41,7 @@ static void run (const gchar *name,
static void borderaverage (GimpDrawable *drawable,
GimpRGB *result);
static gint borderaverage_dialog (void);
static gboolean borderaverage_dialog (void);
static void add_new_color (gint bytes,
guchar *buffer,
......@@ -344,18 +344,19 @@ add_new_color (gint bytes,
cube[(r << (bucket_rexpo << 1)) + (g << bucket_rexpo) + b]++;
}
static gint
static gboolean
borderaverage_dialog (void)
{
GtkWidget *dlg;
GtkWidget *frame;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *spinbutton;
GtkObject *adj;
GtkWidget *combo;
gboolean run;
GtkWidget *dlg;
GtkWidget *frame;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *spinbutton;
GtkWidget *combo;
GtkSizeGroup *group;
GtkObject *adj;
gboolean run;
const gchar *labels[] =
{ "1", "2", "4", "8", "16", "32", "64", "128", "256" };
......@@ -371,24 +372,28 @@ borderaverage_dialog (void)
NULL);
vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
vbox = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
frame = gtk_frame_new (_("Border Size"));
frame = gimp_frame_new (_("Border Size"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
hbox = gtk_hbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_widget_show (hbox);
label = gtk_label_new_with_mnemonic (_("_Thickness:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (group, label);
g_object_unref (group);
spinbutton = gimp_spin_button_new (&adj, borderaverage_thickness,
0, 256, 1, 5, 0, 0, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
......@@ -399,19 +404,21 @@ borderaverage_dialog (void)
G_CALLBACK (gimp_int_adjustment_update),
&borderaverage_thickness);
frame = gtk_frame_new (_("Number of Colors"));
frame = gimp_frame_new (_("Number of Colors"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
hbox = gtk_hbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_widget_show (hbox);
label = gtk_label_new_with_mnemonic (_("_Bucket Size:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
gtk_size_group_add_widget (group, label);
combo = gimp_int_combo_box_new_array (G_N_ELEMENTS (labels), labels);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo),
borderaverage_bucket_exponent);
......
......@@ -238,7 +238,7 @@ static void bumpmap_convert_row (guchar *row,
gint has_alpha,
guchar *lut);
static gint bumpmap_dialog (void);
static gboolean bumpmap_dialog (void);
static void dialog_init_preview (void);
static void dialog_new_bumpmap (gboolean init_offsets);
static void dialog_update_preview (void);
......@@ -849,22 +849,20 @@ bumpmap_convert_row (guchar *row,
}
}
static gint
static gboolean
bumpmap_dialog (void)
{
GtkWidget *dialog;
GtkWidget *top_vbox;
GtkWidget *main_vbox;
GtkWidget *hbox;
GtkWidget *frame;
GtkWidget *preview;
GtkWidget *vbox;
GtkWidget *sep;
GtkWidget *abox;
GtkWidget *pframe;
GtkWidget *ptable;
GtkWidget *scrollbar;
GtkWidget *table;
GtkWidget *right_vbox;
GtkWidget *combo;
GtkWidget *button;
GtkObject *adj;
......@@ -883,18 +881,18 @@ bumpmap_dialog (void)
NULL);
top_vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (top_vbox), 6);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), top_vbox,
main_vbox = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_vbox,
FALSE, FALSE, 0);
gtk_widget_show (top_vbox);
gtk_widget_show (main_vbox);
hbox = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (top_vbox), hbox, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
/* Preview */
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
abox = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
gtk_box_pack_start (GTK_BOX (hbox), abox, FALSE, FALSE, 0);
gtk_widget_show (abox);
......@@ -957,6 +955,10 @@ bumpmap_dialog (void)
dialog_init_preview ();
vbox = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
/* Type of map */
frame =
gimp_int_radio_group_new (TRUE, _("Map Type"),
......@@ -968,18 +970,12 @@ bumpmap_dialog (void)
_("S_inuosidal Map"), SINUOSIDAL, NULL,
NULL);
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
right_vbox = GTK_BIN (frame)->child;
sep = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (right_vbox), sep, FALSE, FALSE, 1);
gtk_widget_show (sep);
/* Compensate darkening */
button = gtk_check_button_new_with_mnemonic (_("Co_mpensate for Darkening"));
gtk_box_pack_start (GTK_BOX (right_vbox), button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
bmvals.compensate ? TRUE : FALSE);
gtk_widget_show (button);
......@@ -990,7 +986,7 @@ bumpmap_dialog (void)
/* Invert bumpmap */
button = gtk_check_button_new_with_mnemonic (_("I_nvert Bumpmap"));
gtk_box_pack_start (GTK_BOX (right_vbox), button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
bmvals.invert ? TRUE : FALSE);
gtk_widget_show (button);
......@@ -1001,7 +997,7 @@ bumpmap_dialog (void)
/* Tile bumpmap */
button = gtk_check_button_new_with_mnemonic (_("_Tile Bumpmap"));
gtk_box_pack_start (GTK_BOX (right_vbox), button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
bmvals.tiled ? TRUE : FALSE);
gtk_widget_show (button);
......@@ -1010,19 +1006,11 @@ bumpmap_dialog (void)
G_CALLBACK (dialog_tiled_callback),
NULL);
frame = gtk_frame_new (_("Parameter Settings"));
gtk_box_pack_start (GTK_BOX (top_vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
/* Bump map menu */
table = gtk_table_new (1, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
table = gtk_table_new (8, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
combo = gimp_drawable_combo_box_new (dialog_constrain, NULL);
......@@ -1030,23 +1018,9 @@ bumpmap_dialog (void)
G_CALLBACK (dialog_bumpmap_callback),
NULL);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("_Bump Map:"), 1.0, 0.5, combo, 2, TRUE);
sep = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0);
gtk_widget_show (sep);
/* Table for bottom controls */
table = gtk_table_new (7, 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 (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
/* Controls */
row = 0;
gimp_table_attach_aligned (GTK_TABLE (table), row++, 0,
_("_Bump Map:"), 1.0, 0.5, combo, 2, FALSE);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++,
_("_Azimuth:"), SCALE_WIDTH, 6,
......
......@@ -551,9 +551,9 @@ static void
doDialog (void)
{
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *frame;
GtkWidget *xframe;
GtkWidget *table;
GtkWidget *preview;
gchar *memsize;
struct stat st;
......@@ -569,51 +569,46 @@ doDialog (void)
NULL);
/* set up frame */
frame = gtk_frame_new (_("Results"));
gtk_container_border_width (GTK_CONTAINER (frame), 6);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), frame,
vbox = gtk_vbox_new (FALSE, 6);
gtk_container_border_width (GTK_CONTAINER (vbox), 12);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox,
TRUE, TRUE, 0);
table = gtk_table_new (12, 1, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_container_border_width (GTK_CONTAINER (table), 6);
gtk_container_add (GTK_CONTAINER (frame), table);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
xframe = gtk_frame_new (NULL);
gtk_frame_set_shadow_type(GTK_FRAME (xframe), GTK_SHADOW_IN);
gtk_table_attach (GTK_TABLE (table), xframe,
0, 1, 0, 1,
GTK_EXPAND, GTK_EXPAND, 0, 0);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
/* use preview for histogram window */
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (preview), PREWIDTH, PREHEIGHT);
gtk_container_add (GTK_CONTAINER (xframe), preview);
gtk_container_add (GTK_CONTAINER (frame), preview);
fillPreview (preview);
/* output results */
doLabel (table, _("Image dimensions: %d x %d"), width, height);
doLabel (vbox, _("Image dimensions: %d x %d"), width, height);
if (uniques == 0)
doLabel (table, _("No colors"));
doLabel (vbox, _("No colors"));
else if (uniques == 1)
doLabel (table, _("Only one unique color"));
doLabel (vbox, _("Only one unique color"));
else
doLabel (table, _("Number of unique colors: %d"), uniques);
doLabel (vbox, _("Number of unique colors: %d"), uniques);
memsize = gimp_memsize_to_string (width * height * bpp);
doLabel (table, _("Uncompressed size: %s"), memsize);
doLabel (vbox, _("Uncompressed size: %s"), memsize);
g_free (memsize);
if (filename && !stat (filename, &st) && !gimp_image_is_dirty (imageID))
{
gchar *memsize = gimp_memsize_to_string (st.st_size);
doLabel (table, _("Filename: %s"), filename);
doLabel (table, _("Compressed size: %s"), memsize);
doLabel (table, _("Compression ratio (approx.): %d to 1"),
doLabel (vbox, _("Filename: %s"), filename);
doLabel (vbox, _("Compressed size: %s"), memsize);
doLabel (vbox, _("Compression ratio (approx.): %d to 1"),
(gint) RINT ((gdouble) (width * height * bpp) / st.st_size));
g_free (memsize);
......@@ -629,14 +624,13 @@ doDialog (void)
/* shortcut */
static void
doLabel (GtkWidget *table,
const char *format,
doLabel (GtkWidget *vbox,
const gchar *format,
...)
{
static gint idx = 1;
GtkWidget *label;
gchar *text;
va_list args;
GtkWidget *label;
gchar *text;
va_list args;
va_start (args, format);
text = g_strdup_vprintf (format, args);
......@@ -644,15 +638,10 @@ doLabel (GtkWidget *table,
label = gtk_label_new (text);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
gtk_table_attach (GTK_TABLE (table), label,
0, 1, idx, idx + 1,
GTK_FILL, 0, 5, 0);
g_free (text);
idx += 2;
}
/* fill our preview image with the color-histogram */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment