1997-11-25 06:05:25 +08:00
|
|
|
/**************************************************
|
|
|
|
* file: megawidget/megawidget.c
|
|
|
|
*
|
|
|
|
* Copyright (c) 1997 Eric L. Hernes (erich@rrnet.com)
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software withough specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Functions added by Xavier Bouchoux (Xavier.Bouchoux@ensimag.imag.fr)
|
|
|
|
* mw_value_radio_group_new()
|
|
|
|
* --> it modifies a user variable to a value associated with the current
|
|
|
|
* button
|
|
|
|
* mw_ientry_button_new()
|
|
|
|
* mw_fentry_button_new()
|
|
|
|
* ---> Guess...
|
|
|
|
* mw_color_select_button_create()
|
|
|
|
* --> Creates a colored button, wich creates a colorselection window
|
|
|
|
* (just like ifs compose)
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1998-06-09 19:41:13 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
|
|
|
|
#include <plug-ins/megawidget/megawidget.h>
|
|
|
|
|
|
|
|
static void mw_scale_entry_new(GtkWidget *table, gchar *name,
|
|
|
|
gfloat defval, gfloat lorange,
|
|
|
|
gfloat hirange, gfloat st_inc,
|
|
|
|
gfloat pg_inc, gfloat pgsiz,
|
|
|
|
gpointer variablep, gchar *fmtvar,
|
|
|
|
gint left_a, gint right_a, gint top_a,
|
|
|
|
gint bottom_a, GtkCallback scale_cb,
|
|
|
|
GtkCallback entry_cb);
|
|
|
|
static void mw_entry_new(GtkWidget *parent, gchar *fname,
|
|
|
|
gchar *name, gpointer variablep,
|
|
|
|
guchar *buffer, GtkCallback entry_cb);
|
|
|
|
static void ui_ok_callback(GtkWidget *widget, gpointer data);
|
|
|
|
static void ui_close_callback(GtkWidget *widget, gpointer data);
|
|
|
|
static void ui_fscale_callback(GtkAdjustment *adj, gpointer data);
|
|
|
|
static void ui_fentry_callback(GtkWidget *widget, gpointer data);
|
|
|
|
static void ui_iscale_callback(GtkAdjustment *adj, gpointer data);
|
|
|
|
static void ui_ientry_callback(GtkWidget *widget, gpointer data);
|
|
|
|
static void ui_toggle_callback(GtkWidget *widget, gpointer data);
|
|
|
|
static void ui_ientry_alone_callback(GtkWidget *widget, gpointer data);
|
|
|
|
static void ui_fentry_alone_callback(GtkWidget *widget, gpointer data);
|
|
|
|
static void ui_value_toggle_callback(GtkWidget *widget, gpointer data);
|
|
|
|
static void create_color_selection (GtkWidget *widget, struct mwColorSel *cs);
|
|
|
|
static void color_selection_cancel (GtkWidget *widget, struct mwColorSel *cs);
|
|
|
|
static void color_selection_destroy_window (GtkWidget *widget,
|
|
|
|
GtkWidget **window);
|
|
|
|
static void color_selection_changed_cb (GtkWidget *w, struct mwColorSel *cs);
|
|
|
|
static void color_selection_ok_cb (GtkWidget *w, struct mwColorSel *cs);
|
|
|
|
static void color_select_fill_button_color(GtkWidget *preview, gdouble *color);
|
|
|
|
|
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
static mw_preview_t *mw_do_preview = NULL;
|
|
|
|
static gint do_preview = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
mw_app_new(gchar *resname, gchar *appname, gint *runpp){
|
|
|
|
gchar **argv;
|
|
|
|
gint argc;
|
|
|
|
GtkWidget *dlg;
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
argc = 1;
|
|
|
|
argv = g_new(gchar *, 1);
|
|
|
|
*runpp = 0;
|
|
|
|
|
|
|
|
argv[0] = g_strdup(resname);
|
|
|
|
gtk_init(&argc, &argv);
|
1998-03-16 14:33:58 +08:00
|
|
|
gtk_rc_parse(gimp_gtkrc());
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
dlg = gtk_dialog_new();
|
|
|
|
gtk_object_set_data(GTK_OBJECT(dlg), "runp", runpp);
|
|
|
|
|
|
|
|
gtk_window_set_title(GTK_WINDOW(dlg), appname);
|
|
|
|
gtk_window_position(GTK_WINDOW(dlg), GTK_WIN_POS_MOUSE);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(dlg), "destroy",
|
|
|
|
(GtkSignalFunc) ui_close_callback,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_label("OK");
|
|
|
|
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
|
|
|
|
gtk_signal_connect(GTK_OBJECT (button), "clicked",
|
|
|
|
(GtkSignalFunc) ui_ok_callback,
|
|
|
|
dlg);
|
|
|
|
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg)->action_area), button,
|
|
|
|
TRUE, TRUE, 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_object(GTK_OBJECT(button), "clicked",
|
|
|
|
(GtkSignalFunc) gtk_widget_destroy,
|
|
|
|
GTK_OBJECT(dlg));
|
|
|
|
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg)->action_area), button,
|
|
|
|
TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
|
|
|
return dlg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mw_fscale_entry_new(GtkWidget *table, gchar *name,
|
|
|
|
gfloat lorange, gfloat hirange,
|
|
|
|
gfloat st_inc, gfloat pg_inc, gfloat pgsiz,
|
|
|
|
gint left_a, gint right_a, gint top_a, gint bottom_a,
|
|
|
|
gdouble *var) {
|
|
|
|
gchar buffer[40];
|
|
|
|
|
|
|
|
sprintf(buffer, "%0.3f", *var);
|
|
|
|
mw_scale_entry_new(table, name, *var, lorange, hirange,
|
|
|
|
st_inc, pg_inc, pgsiz, var, buffer,
|
|
|
|
left_a, right_a, top_a, bottom_a,
|
|
|
|
(GtkCallback)ui_fscale_callback,
|
|
|
|
(GtkCallback)ui_fentry_callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mw_iscale_entry_new(GtkWidget *table, gchar *name,
|
|
|
|
gint lorange, gint hirange,
|
|
|
|
gint st_inc, gint pg_inc, gint pgsiz,
|
|
|
|
gint left_a, gint right_a, gint top_a, gint bottom_a,
|
|
|
|
gint *varp) {
|
|
|
|
gchar buffer[40];
|
|
|
|
|
|
|
|
sprintf(buffer, "%d", *varp);
|
|
|
|
|
|
|
|
mw_scale_entry_new(table, name, (gfloat)*varp, (gfloat)lorange,
|
|
|
|
(gfloat)hirange, (gfloat)st_inc, (gfloat)pg_inc,
|
|
|
|
(gfloat)pgsiz, varp, buffer,
|
|
|
|
left_a, right_a, top_a, bottom_a,
|
|
|
|
(GtkCallback)ui_iscale_callback,
|
|
|
|
(GtkCallback)ui_ientry_callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
GSList *
|
|
|
|
mw_radio_group_new(GtkWidget *parent, gchar *name, struct mwRadioGroup *rg){
|
|
|
|
GSList *lst = NULL;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
struct mwRadioGroup *c;
|
|
|
|
|
|
|
|
|
|
|
|
if (name != NULL) {
|
|
|
|
frame = gtk_frame_new(name);
|
|
|
|
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
|
|
|
|
/* gtk_container_border_width(GTK_CONTAINER(frame), 0);*/
|
|
|
|
gtk_box_pack_start(GTK_BOX(parent), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(frame);
|
|
|
|
|
|
|
|
vbox=gtk_vbox_new(TRUE, 3);
|
|
|
|
/* gtk_container_border_width(GTK_CONTAINER(vbox), 0);*/
|
|
|
|
gtk_container_add(GTK_CONTAINER(frame), vbox);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
|
|
|
|
for(c=rg;c->name; c++)
|
|
|
|
lst = mw_radio_new(lst, vbox, c->name, &c->var, c->var);
|
|
|
|
|
|
|
|
} else { /* name == NULL */
|
|
|
|
|
|
|
|
vbox=gtk_vbox_new(TRUE, 3);
|
|
|
|
gtk_box_pack_start(GTK_BOX(parent), vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
|
|
|
|
for(c=rg;c->name; c++)
|
|
|
|
lst = mw_radio_new(lst, vbox, c->name, &c->var, c->var);
|
|
|
|
}
|
|
|
|
return lst;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GSList *
|
|
|
|
mw_radio_new(GSList *gsl, GtkWidget *parent, gchar *name,
|
|
|
|
gint *varp, gint init) {
|
|
|
|
GtkWidget *button;
|
|
|
|
GSList *rv;
|
|
|
|
|
|
|
|
button=gtk_radio_button_new_with_label(gsl, name);
|
|
|
|
rv=gtk_radio_button_group(GTK_RADIO_BUTTON(button));
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), init);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "toggled",
|
|
|
|
(GtkSignalFunc) ui_toggle_callback,
|
|
|
|
varp);
|
|
|
|
gtk_box_pack_start(GTK_BOX(parent), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
return(rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
mw_radio_result(struct mwRadioGroup *rg) {
|
|
|
|
gint i=0;
|
|
|
|
|
|
|
|
for(i=0;rg[i].name;i++)
|
|
|
|
if (rg[i].var) return i;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
GSList *
|
|
|
|
mw_value_radio_group_new(GtkWidget *parent, gchar *name,
|
gimp-joke-980321
* app/iscissors.c, app/tips_dialog.c, app/gradient.c,
libgimp/gimp.c, plug-ins/AlienMap/AlienMap.c,
plug-ins/bmp/bmp.c, plug-ins/fits/fitsrw.h,
plug-ins/fits/fitsrw.c, plug-ins/flarefx/flarefx.c,
plug-ins/gfig/gfig.c, plug-ins/gfli/gfli.c,
plug-ins/gicon/gicon.c, plug-ins/gqbist/gqbist.c,
plug-ins/gtm/gtm.c, plug-ins/hot/hot.c,
plug-ins/ifscompose/ifscompose.c,
plug-ins/ifscompose/ifscompose_utils.c
plug-ins/max_rgb/max_rgb.c, plug-ins/nlfilt/nlfilt.c,
plug-ins/pat/pat.c, plug-ins/pcx/pcx.c, plug-ins/rotate/rotate.c,
plug-ins/script-fu/script-fu-server.c, plug-ins/snoise/snoise.c,
plug-ins/threshold_alpha/threshold_alpha.c,
plug-ins/zealouscrop/zealouscrop.c :gimp-joke-980321
plug-ins/CML_explorer, plug-ins/autocrop,
plug-ins/align_layers, plug-ins/blinds,
plug-ins/bmp, plug-ins/megawidget: gimp-joke-980322
Applied gimp-joke-980322-0.patch and gimp-joke-980321-0.patch
from Yasuhiro SHIRASAKI <joke@awa.tohoku.ac.jp>. Mostly
portability for DEC osf1's cc. Lots of MAIN();'s, trailing
commas in enums, and guchar/gchar madness.
Gimp now sends mail, cleans vinyl records,
removes stubborn stains, julien fries, and more!
-adrian
1998-03-23 04:44:39 +08:00
|
|
|
struct mwValueRadioGroup *rg, glong *var)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GSList *lst = NULL;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
struct mwValueRadioGroup *c;
|
gimp-joke-980321
* app/iscissors.c, app/tips_dialog.c, app/gradient.c,
libgimp/gimp.c, plug-ins/AlienMap/AlienMap.c,
plug-ins/bmp/bmp.c, plug-ins/fits/fitsrw.h,
plug-ins/fits/fitsrw.c, plug-ins/flarefx/flarefx.c,
plug-ins/gfig/gfig.c, plug-ins/gfli/gfli.c,
plug-ins/gicon/gicon.c, plug-ins/gqbist/gqbist.c,
plug-ins/gtm/gtm.c, plug-ins/hot/hot.c,
plug-ins/ifscompose/ifscompose.c,
plug-ins/ifscompose/ifscompose_utils.c
plug-ins/max_rgb/max_rgb.c, plug-ins/nlfilt/nlfilt.c,
plug-ins/pat/pat.c, plug-ins/pcx/pcx.c, plug-ins/rotate/rotate.c,
plug-ins/script-fu/script-fu-server.c, plug-ins/snoise/snoise.c,
plug-ins/threshold_alpha/threshold_alpha.c,
plug-ins/zealouscrop/zealouscrop.c :gimp-joke-980321
plug-ins/CML_explorer, plug-ins/autocrop,
plug-ins/align_layers, plug-ins/blinds,
plug-ins/bmp, plug-ins/megawidget: gimp-joke-980322
Applied gimp-joke-980322-0.patch and gimp-joke-980321-0.patch
from Yasuhiro SHIRASAKI <joke@awa.tohoku.ac.jp>. Mostly
portability for DEC osf1's cc. Lots of MAIN();'s, trailing
commas in enums, and guchar/gchar madness.
Gimp now sends mail, cleans vinyl records,
removes stubborn stains, julien fries, and more!
-adrian
1998-03-23 04:44:39 +08:00
|
|
|
glong value;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (name != NULL) {
|
|
|
|
frame = gtk_frame_new(name);
|
|
|
|
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
|
|
|
|
gtk_box_pack_start(GTK_BOX(parent), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(frame);
|
|
|
|
|
|
|
|
vbox=gtk_vbox_new(TRUE, 3);
|
|
|
|
gtk_container_add(GTK_CONTAINER(frame), vbox);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
|
|
|
|
} else { /* name == NULL */
|
|
|
|
|
|
|
|
vbox=gtk_vbox_new(TRUE, 3);
|
|
|
|
gtk_box_pack_start(GTK_BOX(parent), vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
value = *var;
|
|
|
|
for(c=rg; c->name!=NULL; c++) {
|
|
|
|
button=gtk_radio_button_new_with_label(lst, c->name);
|
|
|
|
lst=gtk_radio_button_group(GTK_RADIO_BUTTON(button));
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), (c->val==value));
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "toggled",
|
|
|
|
(GtkSignalFunc) ui_value_toggle_callback,
|
|
|
|
(gpointer)var);
|
|
|
|
gtk_object_set_data(GTK_OBJECT(button),"Radio_ID",(gpointer)c->val);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
}
|
|
|
|
return lst;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
mw_toggle_button_new(GtkWidget *parent, gchar *fname,
|
|
|
|
gchar *label, gint *varp){
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
if (fname != NULL) {
|
|
|
|
frame = gtk_frame_new(fname);
|
|
|
|
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
|
|
|
|
gtk_box_pack_start(GTK_BOX(parent), frame, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show(frame);
|
|
|
|
button=gtk_check_button_new_with_label(label);
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *varp);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "toggled",
|
|
|
|
(GtkSignalFunc) ui_toggle_callback,
|
|
|
|
varp);
|
|
|
|
gtk_container_add(GTK_CONTAINER(frame), button);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
|
|
|
|
|
|
|
|
} else { /*Name == NULL */
|
|
|
|
|
|
|
|
button=gtk_check_button_new_with_label(label);
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *varp);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "toggled",
|
|
|
|
(GtkSignalFunc) ui_toggle_callback,
|
|
|
|
varp);
|
|
|
|
gtk_box_pack_start(GTK_BOX(parent), button, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
return parent; /* ????? */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct mwColorSel * mw_color_select_button_create(
|
|
|
|
GtkWidget *parent, gchar *name, gdouble *color,
|
|
|
|
gint opacity)
|
|
|
|
{
|
|
|
|
#define COLOR_SAMPLE_SIZE 30
|
|
|
|
GtkWidget *button;
|
|
|
|
struct mwColorSel *cs = g_new(struct mwColorSel,1);
|
|
|
|
|
1998-03-19 10:11:53 +08:00
|
|
|
cs->name = (guchar *)name;
|
1997-11-25 06:05:25 +08:00
|
|
|
cs->color = color;
|
|
|
|
cs->opacity = opacity;
|
|
|
|
cs->window = NULL;
|
|
|
|
|
|
|
|
button = gtk_button_new();
|
|
|
|
gtk_box_pack_start(GTK_BOX(parent),button,FALSE,FALSE,0);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
|
|
|
cs->preview = gtk_preview_new(GTK_PREVIEW_COLOR);
|
|
|
|
gtk_preview_size(GTK_PREVIEW(cs->preview),
|
|
|
|
COLOR_SAMPLE_SIZE,COLOR_SAMPLE_SIZE);
|
|
|
|
gtk_container_add (GTK_CONTAINER(button),cs->preview);
|
|
|
|
gtk_widget_show(cs->preview);
|
|
|
|
|
|
|
|
color_select_fill_button_color(cs->preview,color);
|
|
|
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(button),"clicked",
|
|
|
|
(GtkSignalFunc)create_color_selection,
|
|
|
|
cs);
|
|
|
|
|
|
|
|
return cs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mw_ientry_new(GtkWidget *parent, gchar *fname,
|
|
|
|
gchar *name, gint *varp)
|
|
|
|
{
|
|
|
|
gchar buffer[40];
|
|
|
|
|
|
|
|
sprintf (buffer, "%d", *varp);
|
|
|
|
mw_entry_new(parent, fname, name,
|
1998-03-19 10:11:53 +08:00
|
|
|
varp, (guchar *)buffer,
|
1997-11-25 06:05:25 +08:00
|
|
|
(GtkCallback)ui_ientry_alone_callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mw_fentry_new(GtkWidget *parent, gchar *fname,
|
|
|
|
gchar *name, gdouble *varp)
|
|
|
|
{
|
|
|
|
gchar buffer[40];
|
|
|
|
|
|
|
|
sprintf (buffer, "%f0.3", *varp);
|
|
|
|
mw_entry_new(parent, fname, name,
|
1998-03-19 10:11:53 +08:00
|
|
|
varp, (guchar *)buffer,
|
1997-11-25 06:05:25 +08:00
|
|
|
(GtkCallback)ui_fentry_alone_callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
struct mwPreview *
|
|
|
|
mw_preview_build_virgin(GDrawable *drw) {
|
|
|
|
struct mwPreview *mwp;
|
|
|
|
|
|
|
|
mwp = (struct mwPreview *)malloc(sizeof(struct mwPreview));
|
|
|
|
if (drw->width > drw->height) {
|
|
|
|
mwp->scale = (gdouble)drw->width/(gdouble)PREVIEW_SIZE;
|
|
|
|
mwp->width = PREVIEW_SIZE;
|
|
|
|
mwp->height = (drw->height)/(mwp->scale);
|
|
|
|
} else {
|
|
|
|
mwp->scale = (gdouble)drw->height/(gdouble)PREVIEW_SIZE;
|
|
|
|
mwp->height = PREVIEW_SIZE;
|
|
|
|
mwp->width = (drw->width)/(mwp->scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
mwp->bpp = 3;
|
|
|
|
mwp->bits = NULL;
|
|
|
|
return(mwp);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct mwPreview *
|
|
|
|
mw_preview_build(GDrawable *drw) {
|
|
|
|
struct mwPreview *mwp;
|
|
|
|
gint x, y, b;
|
|
|
|
guchar *bc, *drwBits;
|
|
|
|
GPixelRgn pr;
|
|
|
|
|
|
|
|
mwp= mw_preview_build_virgin(drw);
|
|
|
|
|
|
|
|
gimp_pixel_rgn_init(&pr, drw, 0, 0, drw->width, drw->height, FALSE, FALSE);
|
applied gimp-lecorfec-99041[02]-0, changes follow
* applied gimp-lecorfec-99041[02]-0, changes follow
* plug-ins/FractalExplorer/Dialogs.h (make_color_map):
replaced free with g_free to fix segfault.
* plug-ins/Lighting/lighting_preview.c (compute_preview):
allocate xpostab and ypostab only when needed (it could also be
allocated on stack with a compilation-fixed size like MapObject).
It avoids to lose some Kb on each preview :)
Also reindented (unfortunate C-c C-q) some other lines.
* plug-ins/Lighting/lighting_main.c (run):
release allocated postabs.
* plug-ins/Lighting/lighting_ui.c:
callbacks now have only one argument because gck widget use
gtk_signal_connect_object. Caused segfault for scale widget.
* plug-ins/autocrop/autocrop.c (doit):
return if image has only background (thus fixing a segfault).
* plug-ins/emboss/emboss.c (pluginCore, emboss_do_preview):
replaced malloc/free with g_malloc/g_free (unneeded, but
shouldn't everyone use glib calls ? :)
* plug-ins/flame/flame.c :
replaced a segfaulting free, and several harmless malloc/free pairs.
* plug-ins/flame/megawidget.c (mw_preview_build):
replaced harmless malloc/free pair.
Note : mwp->bits is malloc'ed but seems to be never freed.
* plug-ins/fractaltrace/fractaltrace.c (pixels_free):
replaced a bunch of segfaulting free.
(pixels_get, dialog_show): replaced gtk_signal_connect_object
with gtk_signal_connect to accomodate callbacks (caused STRANGE
dialog behaviour, coz you destroyed buttons one by one).
* plug-ins/illusion/illusion.c (dialog):
same gtk_signal_connect_object replacement for same reasons.
* plug-ins/libgck/gck/gckcolor.c :
changed all gck_rgb_to_color* functions to use a static GdkColor
instead of a malloc'ed area. Provided reentrant functions with
the old behaviour (gck_rgb_to_color*_r). Made some private functions
static, too.
gck_rgb_to_gdkcolor now use the new functions while
gck_rgb_to_gdkcolor_r is the reentrant version.
Also affected by this change: gck_gc_set_foreground and
gck_gc_set_background (no more free(color)).
* plug-ins/libgck/gck/gckcolor.h :
added the gck_rgb_to_gdkcolor_r proto.
* plug-ins/lic/lic.c (ok_button_clicked, cancel_button_clicked) :
segfault on gtk_widget_destroy, now calls gtk_main_quit.
(dialog_destroy) : segfault on window closure when called by
"destroy" event. Now called by "delete_event".
* plug-ins/megawidget/megawidget.c (mw_preview_build):
replaced harmless malloc/free pair.
Note : mwp->bits is malloc'ed but seems to be never freed.
* plug-ins/png/png.c (load_image):
replaced 2 segfaulting free.
* plug-ins/print/print-ps.c (ps_print):
replaced a segfaulting free (called many times :).
* plug-ins/sgi/sgi.c (load_image, save_image):
replaced a bunch of segfaulting free, and did some harmless
inits to avoid a few gcc warnings.
* plug-ins/wind/wind.c (render_wind):
replaced a segfaulting free.
(render_blast): replaced harmless malloc/free pair.
* plug-ins/bmp/bmpread.c (ReadImage):
yet another free()/g_free() problem fixed.
* plug-ins/exchange/exchange.c (real_exchange):
ditto.
* plug-ins/fp/fp.h: added Frames_Check_Button_In_A_Box proto.
* plug-ins/fp/fp_gtk.c: closing subdialogs via window manager
wasn't handled, thus leading to errors and crashes.
Now delete_event signals the dialog control button
to close a dialog with the good way.
* plug-ins/ifscompose/ifscompose.c (value_pair_create):
tried to set events mask on scale widget (a NO_WINDOW widget).
* plug-ins/png/png.c (save_image):
Replaced 2 free() with g_free() for g_malloc'ed memory.
Mysteriously I corrected the loading bug but not the saving one :)
-Yosh
1999-04-16 05:49:09 +08:00
|
|
|
drwBits = (guchar *)g_malloc(drw->width * drw->bpp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
mwp->bpp = 3;
|
|
|
|
bc = mwp->bits = (guchar *)malloc(mwp->width*mwp->height*mwp->bpp);
|
|
|
|
for(y=0;y<mwp->height;y++) {
|
|
|
|
gimp_pixel_rgn_get_row(&pr, drwBits, 0, (int)(y*mwp->scale), drw->width);
|
|
|
|
for(x=0;x<mwp->width;x++) {
|
|
|
|
for(b=0;b<mwp->bpp;b++)
|
|
|
|
*bc++=*(drwBits+((gint)(x*mwp->scale)*drw->bpp)+b%drw->bpp);
|
|
|
|
}
|
|
|
|
}
|
applied gimp-lecorfec-99041[02]-0, changes follow
* applied gimp-lecorfec-99041[02]-0, changes follow
* plug-ins/FractalExplorer/Dialogs.h (make_color_map):
replaced free with g_free to fix segfault.
* plug-ins/Lighting/lighting_preview.c (compute_preview):
allocate xpostab and ypostab only when needed (it could also be
allocated on stack with a compilation-fixed size like MapObject).
It avoids to lose some Kb on each preview :)
Also reindented (unfortunate C-c C-q) some other lines.
* plug-ins/Lighting/lighting_main.c (run):
release allocated postabs.
* plug-ins/Lighting/lighting_ui.c:
callbacks now have only one argument because gck widget use
gtk_signal_connect_object. Caused segfault for scale widget.
* plug-ins/autocrop/autocrop.c (doit):
return if image has only background (thus fixing a segfault).
* plug-ins/emboss/emboss.c (pluginCore, emboss_do_preview):
replaced malloc/free with g_malloc/g_free (unneeded, but
shouldn't everyone use glib calls ? :)
* plug-ins/flame/flame.c :
replaced a segfaulting free, and several harmless malloc/free pairs.
* plug-ins/flame/megawidget.c (mw_preview_build):
replaced harmless malloc/free pair.
Note : mwp->bits is malloc'ed but seems to be never freed.
* plug-ins/fractaltrace/fractaltrace.c (pixels_free):
replaced a bunch of segfaulting free.
(pixels_get, dialog_show): replaced gtk_signal_connect_object
with gtk_signal_connect to accomodate callbacks (caused STRANGE
dialog behaviour, coz you destroyed buttons one by one).
* plug-ins/illusion/illusion.c (dialog):
same gtk_signal_connect_object replacement for same reasons.
* plug-ins/libgck/gck/gckcolor.c :
changed all gck_rgb_to_color* functions to use a static GdkColor
instead of a malloc'ed area. Provided reentrant functions with
the old behaviour (gck_rgb_to_color*_r). Made some private functions
static, too.
gck_rgb_to_gdkcolor now use the new functions while
gck_rgb_to_gdkcolor_r is the reentrant version.
Also affected by this change: gck_gc_set_foreground and
gck_gc_set_background (no more free(color)).
* plug-ins/libgck/gck/gckcolor.h :
added the gck_rgb_to_gdkcolor_r proto.
* plug-ins/lic/lic.c (ok_button_clicked, cancel_button_clicked) :
segfault on gtk_widget_destroy, now calls gtk_main_quit.
(dialog_destroy) : segfault on window closure when called by
"destroy" event. Now called by "delete_event".
* plug-ins/megawidget/megawidget.c (mw_preview_build):
replaced harmless malloc/free pair.
Note : mwp->bits is malloc'ed but seems to be never freed.
* plug-ins/png/png.c (load_image):
replaced 2 segfaulting free.
* plug-ins/print/print-ps.c (ps_print):
replaced a segfaulting free (called many times :).
* plug-ins/sgi/sgi.c (load_image, save_image):
replaced a bunch of segfaulting free, and did some harmless
inits to avoid a few gcc warnings.
* plug-ins/wind/wind.c (render_wind):
replaced a segfaulting free.
(render_blast): replaced harmless malloc/free pair.
* plug-ins/bmp/bmpread.c (ReadImage):
yet another free()/g_free() problem fixed.
* plug-ins/exchange/exchange.c (real_exchange):
ditto.
* plug-ins/fp/fp.h: added Frames_Check_Button_In_A_Box proto.
* plug-ins/fp/fp_gtk.c: closing subdialogs via window manager
wasn't handled, thus leading to errors and crashes.
Now delete_event signals the dialog control button
to close a dialog with the good way.
* plug-ins/ifscompose/ifscompose.c (value_pair_create):
tried to set events mask on scale widget (a NO_WINDOW widget).
* plug-ins/png/png.c (save_image):
Replaced 2 free() with g_free() for g_malloc'ed memory.
Mysteriously I corrected the loading bug but not the saving one :)
-Yosh
1999-04-16 05:49:09 +08:00
|
|
|
g_free(drwBits);
|
1997-11-25 06:05:25 +08:00
|
|
|
return(mwp);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
mw_preview_new(GtkWidget *parent, struct mwPreview *mwp, mw_preview_t *fcn){
|
|
|
|
GtkWidget *preview;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *pframe;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
guchar *color_cube;
|
|
|
|
|
|
|
|
gtk_preview_set_gamma (gimp_gamma ());
|
|
|
|
gtk_preview_set_install_cmap (gimp_install_cmap ());
|
|
|
|
color_cube = gimp_color_cube ();
|
|
|
|
gtk_preview_set_color_cube (color_cube[0], color_cube[1],
|
|
|
|
color_cube[2], color_cube[3]);
|
|
|
|
|
|
|
|
gtk_widget_set_default_visual (gtk_preview_get_visual ());
|
|
|
|
gtk_widget_set_default_colormap (gtk_preview_get_cmap ());
|
|
|
|
|
|
|
|
frame = gtk_frame_new("Preview");
|
|
|
|
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
|
|
|
|
gtk_box_pack_start(GTK_BOX(parent), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(frame);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new(FALSE, 2);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(vbox), 2);
|
|
|
|
gtk_container_add(GTK_CONTAINER(frame), vbox);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
|
|
|
|
pframe = gtk_frame_new(NULL);
|
|
|
|
gtk_frame_set_shadow_type(GTK_FRAME(pframe), GTK_SHADOW_IN);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(pframe), 3);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), pframe, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(pframe);
|
|
|
|
|
|
|
|
preview = gtk_preview_new(GTK_PREVIEW_COLOR);
|
|
|
|
gtk_preview_size(GTK_PREVIEW(preview), mwp->width, mwp->height);
|
|
|
|
gtk_container_add(GTK_CONTAINER(pframe), preview);
|
|
|
|
gtk_widget_show(preview);
|
|
|
|
mw_do_preview = fcn;
|
|
|
|
|
|
|
|
button=gtk_check_button_new_with_label("Do Preview");
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), do_preview);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "toggled",
|
|
|
|
(GtkSignalFunc) ui_toggle_callback,
|
|
|
|
&do_preview);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
|
|
|
return preview;
|
|
|
|
}
|
|
|
|
#endif /* NO_PREVIEW */
|
|
|
|
|
|
|
|
/* internals */
|
|
|
|
static void
|
|
|
|
mw_scale_entry_new(GtkWidget *table, gchar *name,
|
|
|
|
gfloat defval, gfloat lorange, gfloat hirange,
|
|
|
|
gfloat st_inc, gfloat pg_inc, gfloat pgsiz,
|
|
|
|
gpointer variablep, gchar *fmtvar,
|
|
|
|
gint left_a, gint right_a, gint top_a, gint bottom_a,
|
|
|
|
GtkCallback scale_cb, GtkCallback entry_cb) {
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *scale;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkObject *adjustment;
|
|
|
|
|
|
|
|
label = gtk_label_new(name);
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
|
|
|
|
|
|
|
|
gtk_table_attach(GTK_TABLE(table), label,
|
|
|
|
left_a, right_a, top_a, bottom_a,
|
|
|
|
GTK_FILL, GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show(label);
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new(FALSE, 5);
|
|
|
|
gtk_table_attach(GTK_TABLE(table), hbox,
|
|
|
|
left_a+1, right_a+1, top_a, bottom_a,
|
|
|
|
GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show(hbox);
|
|
|
|
|
|
|
|
adjustment = gtk_adjustment_new(defval, lorange, hirange, st_inc,
|
|
|
|
pg_inc, pgsiz);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(adjustment), "value_changed",
|
|
|
|
(GtkSignalFunc) scale_cb,
|
|
|
|
variablep);
|
|
|
|
|
|
|
|
scale = gtk_hscale_new(GTK_ADJUSTMENT(adjustment));
|
|
|
|
gtk_widget_set_usize(GTK_WIDGET(scale), 140, 0);
|
|
|
|
gtk_scale_set_digits(GTK_SCALE(scale), 2);
|
|
|
|
gtk_scale_set_draw_value(GTK_SCALE(scale), FALSE);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), scale, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(scale);
|
|
|
|
|
|
|
|
entry = gtk_entry_new();
|
|
|
|
gtk_object_set_user_data(GTK_OBJECT(entry), adjustment);
|
|
|
|
gtk_object_set_user_data(adjustment, entry);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_set_usize(entry, 75, 0);
|
|
|
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(entry), fmtvar);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(entry), "changed",
|
|
|
|
(GtkSignalFunc) entry_cb,
|
|
|
|
variablep);
|
|
|
|
gtk_widget_show(entry);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mw_entry_new(GtkWidget *parent, gchar *fname,
|
|
|
|
gchar *name, gpointer variablep,
|
|
|
|
guchar *buffer, GtkCallback entry_cb)
|
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *entry, *label;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
|
|
|
|
if (fname != NULL) {
|
|
|
|
frame = gtk_frame_new(fname);
|
|
|
|
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
|
|
|
|
gtk_box_pack_start(GTK_BOX(parent), frame, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show(frame);
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 5);
|
|
|
|
gtk_container_add(GTK_CONTAINER(frame), hbox);
|
|
|
|
|
|
|
|
} else { /*Name == NULL */
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (parent), hbox, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
label = gtk_label_new (name);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
entry = gtk_entry_new();
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_set_usize (entry, 75, 0);
|
1998-03-19 10:11:53 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), (const gchar *)buffer);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (entry), "changed",
|
|
|
|
(GtkSignalFunc) entry_cb,
|
|
|
|
variablep);
|
|
|
|
gtk_widget_show (entry);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ui_close_callback(GtkWidget *widget, gpointer data){
|
|
|
|
gtk_main_quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ui_ok_callback(GtkWidget *widget, gpointer data){
|
|
|
|
gint *rp;
|
|
|
|
rp = gtk_object_get_data(GTK_OBJECT(data), "runp");
|
|
|
|
*rp=1;
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ui_fscale_callback(GtkAdjustment *adj, gpointer data){
|
|
|
|
GtkWidget *ent;
|
|
|
|
double *nval;
|
|
|
|
gchar buf[40];
|
|
|
|
|
|
|
|
nval = (double*)data;
|
|
|
|
|
|
|
|
if (*nval != adj->value) {
|
|
|
|
*nval = adj->value;
|
|
|
|
ent = gtk_object_get_user_data(GTK_OBJECT(adj));
|
|
|
|
sprintf(buf, "%0.2f", adj->value);
|
|
|
|
|
|
|
|
gtk_signal_handler_block_by_data(GTK_OBJECT(ent), data);
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(ent), buf);
|
|
|
|
gtk_signal_handler_unblock_by_data(GTK_OBJECT(ent), data);
|
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
if (do_preview && mw_do_preview!=NULL) (*mw_do_preview)(NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ui_fentry_callback(GtkWidget *widget, gpointer data){
|
|
|
|
GtkAdjustment *adjustment;
|
|
|
|
double new_val;
|
|
|
|
double *val;
|
|
|
|
|
|
|
|
val = (double*)data;
|
|
|
|
new_val = atof(gtk_entry_get_text(GTK_ENTRY(widget)));
|
|
|
|
|
|
|
|
if (*val != new_val) {
|
|
|
|
adjustment = gtk_object_get_user_data(GTK_OBJECT(widget));
|
|
|
|
|
|
|
|
if ((new_val >= adjustment->lower) &&
|
|
|
|
(new_val <= adjustment->upper)) {
|
|
|
|
*val = new_val;
|
|
|
|
adjustment->value = new_val;
|
|
|
|
gtk_signal_emit_by_name(GTK_OBJECT(adjustment), "value_changed");
|
|
|
|
}
|
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
if (do_preview && mw_do_preview!=NULL) (*mw_do_preview)(NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ui_iscale_callback(GtkAdjustment *adj, gpointer data){
|
|
|
|
GtkWidget *ent;
|
|
|
|
gint *nval;
|
|
|
|
gchar buf[40];
|
|
|
|
|
|
|
|
nval = (gint*)data;
|
|
|
|
|
|
|
|
if (*nval != (gint)adj->value) {
|
|
|
|
*nval = (gint)adj->value;
|
|
|
|
ent = gtk_object_get_user_data(GTK_OBJECT(adj));
|
|
|
|
sprintf(buf, "%d", (gint)adj->value);
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(ent), buf);
|
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
if (do_preview && mw_do_preview!=NULL) (*mw_do_preview)(NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ui_ientry_callback(GtkWidget *widget, gpointer data){
|
|
|
|
GtkAdjustment *adj;
|
|
|
|
gint new_val;
|
|
|
|
gint *val;
|
|
|
|
|
|
|
|
val = (gint *)data;
|
|
|
|
new_val = strtol(gtk_entry_get_text(GTK_ENTRY(widget)), NULL, 0);
|
|
|
|
|
|
|
|
if (*val != new_val) {
|
|
|
|
adj = gtk_object_get_user_data(GTK_OBJECT(widget));
|
|
|
|
|
|
|
|
if ((new_val >= adj->lower) &&
|
|
|
|
(new_val <= adj->upper)) {
|
|
|
|
*val = new_val;
|
|
|
|
adj->value = new_val;
|
|
|
|
gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed");
|
|
|
|
}
|
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
if (do_preview && mw_do_preview!=NULL) (*mw_do_preview)(NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
ui_ientry_alone_callback(GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
gint new_val;
|
|
|
|
gint *val;
|
|
|
|
|
|
|
|
val = (gint *)data;
|
|
|
|
new_val = strtol(gtk_entry_get_text(GTK_ENTRY(widget)), NULL, 0);
|
|
|
|
|
|
|
|
if (*val != new_val) {
|
|
|
|
*val= new_val;
|
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
if (do_preview && mw_do_preview!=NULL) (*mw_do_preview)(NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ui_fentry_alone_callback(GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
gdouble new_val;
|
|
|
|
gdouble *val;
|
|
|
|
|
|
|
|
val = (gdouble *)data;
|
|
|
|
new_val = atof(gtk_entry_get_text(GTK_ENTRY(widget)));
|
|
|
|
|
|
|
|
if (*val != new_val) {
|
|
|
|
*val= new_val;
|
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
if (do_preview && mw_do_preview!=NULL) (*mw_do_preview)(NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
ui_toggle_callback(GtkWidget *widget, gpointer data) {
|
|
|
|
gint *toggle_val;
|
|
|
|
toggle_val = (gint *) data;
|
|
|
|
if (GTK_TOGGLE_BUTTON (widget)->active)
|
|
|
|
*toggle_val = TRUE;
|
|
|
|
else
|
|
|
|
*toggle_val = FALSE;
|
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
if (do_preview && mw_do_preview!=NULL) (*mw_do_preview)(NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
ui_value_toggle_callback(GtkWidget *widget, gpointer data) {
|
gimp-joke-980321
* app/iscissors.c, app/tips_dialog.c, app/gradient.c,
libgimp/gimp.c, plug-ins/AlienMap/AlienMap.c,
plug-ins/bmp/bmp.c, plug-ins/fits/fitsrw.h,
plug-ins/fits/fitsrw.c, plug-ins/flarefx/flarefx.c,
plug-ins/gfig/gfig.c, plug-ins/gfli/gfli.c,
plug-ins/gicon/gicon.c, plug-ins/gqbist/gqbist.c,
plug-ins/gtm/gtm.c, plug-ins/hot/hot.c,
plug-ins/ifscompose/ifscompose.c,
plug-ins/ifscompose/ifscompose_utils.c
plug-ins/max_rgb/max_rgb.c, plug-ins/nlfilt/nlfilt.c,
plug-ins/pat/pat.c, plug-ins/pcx/pcx.c, plug-ins/rotate/rotate.c,
plug-ins/script-fu/script-fu-server.c, plug-ins/snoise/snoise.c,
plug-ins/threshold_alpha/threshold_alpha.c,
plug-ins/zealouscrop/zealouscrop.c :gimp-joke-980321
plug-ins/CML_explorer, plug-ins/autocrop,
plug-ins/align_layers, plug-ins/blinds,
plug-ins/bmp, plug-ins/megawidget: gimp-joke-980322
Applied gimp-joke-980322-0.patch and gimp-joke-980321-0.patch
from Yasuhiro SHIRASAKI <joke@awa.tohoku.ac.jp>. Mostly
portability for DEC osf1's cc. Lots of MAIN();'s, trailing
commas in enums, and guchar/gchar madness.
Gimp now sends mail, cleans vinyl records,
removes stubborn stains, julien fries, and more!
-adrian
1998-03-23 04:44:39 +08:00
|
|
|
glong id;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Get radio button ID */
|
gimp-joke-980321
* app/iscissors.c, app/tips_dialog.c, app/gradient.c,
libgimp/gimp.c, plug-ins/AlienMap/AlienMap.c,
plug-ins/bmp/bmp.c, plug-ins/fits/fitsrw.h,
plug-ins/fits/fitsrw.c, plug-ins/flarefx/flarefx.c,
plug-ins/gfig/gfig.c, plug-ins/gfli/gfli.c,
plug-ins/gicon/gicon.c, plug-ins/gqbist/gqbist.c,
plug-ins/gtm/gtm.c, plug-ins/hot/hot.c,
plug-ins/ifscompose/ifscompose.c,
plug-ins/ifscompose/ifscompose_utils.c
plug-ins/max_rgb/max_rgb.c, plug-ins/nlfilt/nlfilt.c,
plug-ins/pat/pat.c, plug-ins/pcx/pcx.c, plug-ins/rotate/rotate.c,
plug-ins/script-fu/script-fu-server.c, plug-ins/snoise/snoise.c,
plug-ins/threshold_alpha/threshold_alpha.c,
plug-ins/zealouscrop/zealouscrop.c :gimp-joke-980321
plug-ins/CML_explorer, plug-ins/autocrop,
plug-ins/align_layers, plug-ins/blinds,
plug-ins/bmp, plug-ins/megawidget: gimp-joke-980322
Applied gimp-joke-980322-0.patch and gimp-joke-980321-0.patch
from Yasuhiro SHIRASAKI <joke@awa.tohoku.ac.jp>. Mostly
portability for DEC osf1's cc. Lots of MAIN();'s, trailing
commas in enums, and guchar/gchar madness.
Gimp now sends mail, cleans vinyl records,
removes stubborn stains, julien fries, and more!
-adrian
1998-03-23 04:44:39 +08:00
|
|
|
id=(glong)gtk_object_get_data(GTK_OBJECT(widget),"Radio_ID");
|
1997-11-25 06:05:25 +08:00
|
|
|
if (GTK_TOGGLE_BUTTON (widget)->active) {
|
gimp-joke-980321
* app/iscissors.c, app/tips_dialog.c, app/gradient.c,
libgimp/gimp.c, plug-ins/AlienMap/AlienMap.c,
plug-ins/bmp/bmp.c, plug-ins/fits/fitsrw.h,
plug-ins/fits/fitsrw.c, plug-ins/flarefx/flarefx.c,
plug-ins/gfig/gfig.c, plug-ins/gfli/gfli.c,
plug-ins/gicon/gicon.c, plug-ins/gqbist/gqbist.c,
plug-ins/gtm/gtm.c, plug-ins/hot/hot.c,
plug-ins/ifscompose/ifscompose.c,
plug-ins/ifscompose/ifscompose_utils.c
plug-ins/max_rgb/max_rgb.c, plug-ins/nlfilt/nlfilt.c,
plug-ins/pat/pat.c, plug-ins/pcx/pcx.c, plug-ins/rotate/rotate.c,
plug-ins/script-fu/script-fu-server.c, plug-ins/snoise/snoise.c,
plug-ins/threshold_alpha/threshold_alpha.c,
plug-ins/zealouscrop/zealouscrop.c :gimp-joke-980321
plug-ins/CML_explorer, plug-ins/autocrop,
plug-ins/align_layers, plug-ins/blinds,
plug-ins/bmp, plug-ins/megawidget: gimp-joke-980322
Applied gimp-joke-980322-0.patch and gimp-joke-980321-0.patch
from Yasuhiro SHIRASAKI <joke@awa.tohoku.ac.jp>. Mostly
portability for DEC osf1's cc. Lots of MAIN();'s, trailing
commas in enums, and guchar/gchar madness.
Gimp now sends mail, cleans vinyl records,
removes stubborn stains, julien fries, and more!
-adrian
1998-03-23 04:44:39 +08:00
|
|
|
*(glong *)data= id;
|
1997-11-25 06:05:25 +08:00
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
if (do_preview && mw_do_preview!=NULL) (*mw_do_preview)(NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* color_selection_* stuff */
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_selection_ok_cb (GtkWidget *w,
|
|
|
|
struct mwColorSel *cs)
|
|
|
|
{
|
|
|
|
GtkColorSelection *colorsel;
|
|
|
|
|
|
|
|
colorsel=GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(cs->window)->colorsel);
|
|
|
|
gtk_color_selection_get_color(colorsel,cs->color);
|
|
|
|
gtk_widget_destroy(cs->window);
|
|
|
|
color_select_fill_button_color(cs->preview, cs->color);
|
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
if (do_preview && mw_do_preview!=NULL) (*mw_do_preview)(NULL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_selection_changed_cb (GtkWidget *w,
|
|
|
|
struct mwColorSel *cs)
|
|
|
|
{
|
|
|
|
GtkColorSelection *colorsel;
|
|
|
|
|
|
|
|
colorsel=GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(cs->window)->colorsel);
|
|
|
|
gtk_color_selection_get_color(colorsel,cs->color);
|
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
if (do_preview && mw_do_preview!=NULL) (*mw_do_preview)(NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_selection_destroy_window (GtkWidget *widget,
|
|
|
|
GtkWidget **window)
|
|
|
|
{
|
|
|
|
*window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_selection_cancel (GtkWidget *widget,
|
|
|
|
struct mwColorSel *cs)
|
|
|
|
{
|
|
|
|
(cs->color)[0]=cs->savcolor[0];
|
|
|
|
(cs->color)[1]=cs->savcolor[1];
|
|
|
|
(cs->color)[2]=cs->savcolor[2];
|
|
|
|
if (cs->opacity)
|
|
|
|
(cs->color)[3]=cs->savcolor[3];
|
|
|
|
gtk_widget_destroy(cs->window);
|
|
|
|
cs->window = NULL;
|
|
|
|
#ifndef NO_PREVIEW
|
|
|
|
if (do_preview && mw_do_preview!=NULL) (*mw_do_preview)(NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_color_selection (GtkWidget *widget,
|
|
|
|
struct mwColorSel *cs)
|
|
|
|
{
|
|
|
|
if (!(cs->window)) {
|
1998-03-19 10:11:53 +08:00
|
|
|
cs->window = gtk_color_selection_dialog_new ((const gchar *)cs->name);
|
1997-11-25 06:05:25 +08:00
|
|
|
cs->savcolor[0]=cs->color[0]; /* For the cancel .... */
|
|
|
|
cs->savcolor[1]=cs->color[1];
|
|
|
|
cs->savcolor[2]=cs->color[2];
|
|
|
|
if (cs->opacity)
|
|
|
|
cs->savcolor[3]=cs->color[3];
|
|
|
|
|
|
|
|
gtk_color_selection_set_opacity(
|
|
|
|
GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(cs->window)->colorsel),cs->opacity);
|
|
|
|
|
|
|
|
gtk_color_selection_set_update_policy(
|
|
|
|
GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(cs->window)->colorsel),GTK_UPDATE_DELAYED);
|
|
|
|
gtk_widget_destroy ( GTK_COLOR_SELECTION_DIALOG(cs->window)->help_button );
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (cs->window), "destroy",
|
|
|
|
(GtkSignalFunc) color_selection_destroy_window,
|
|
|
|
&(cs->window));
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(cs->window)->colorsel),
|
|
|
|
"color_changed",(GtkSignalFunc) color_selection_changed_cb,
|
|
|
|
cs);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG (cs->window)->ok_button),
|
|
|
|
"clicked", (GtkSignalFunc) color_selection_ok_cb,
|
|
|
|
cs);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (GTK_COLOR_SELECTION_DIALOG (cs->window)->cancel_button),
|
|
|
|
"clicked", (GtkSignalFunc) color_selection_cancel,
|
|
|
|
cs);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_color_selection_set_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(cs->window)->colorsel),cs->color);
|
|
|
|
|
|
|
|
gtk_window_position (GTK_WINDOW (cs->window), GTK_WIN_POS_MOUSE);
|
|
|
|
gtk_widget_show(cs->window);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_fill_button_color(GtkWidget *preview, gdouble *color)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
guchar buf[3*COLOR_SAMPLE_SIZE];
|
|
|
|
|
|
|
|
for (i=0;i<COLOR_SAMPLE_SIZE;i++)
|
|
|
|
{
|
|
|
|
buf[3*i] = (guchar)(255.999*color[0]);
|
|
|
|
buf[3*i+1] = (guchar)(255.999*color[1]);
|
|
|
|
buf[3*i+2] = (guchar)(255.999*color[2]);
|
|
|
|
}
|
|
|
|
for (i=0;i<COLOR_SAMPLE_SIZE;i++)
|
|
|
|
gtk_preview_draw_row(GTK_PREVIEW(preview),buf,0,i,COLOR_SAMPLE_SIZE);
|
|
|
|
|
|
|
|
gtk_widget_draw (preview, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* end of megawidget/megawidget.c */
|
|
|
|
|
|
|
|
|