added some stock icons to the dialog.

2003-03-24  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/compose.c: added some stock icons to the dialog.
This commit is contained in:
Sven Neumann 2003-03-24 15:33:48 +00:00 committed by Sven Neumann
parent 248afa55aa
commit 706de31960
2 changed files with 184 additions and 126 deletions

View File

@ -1,3 +1,7 @@
2003-03-24 Sven Neumann <sven@gimp.org>
* plug-ins/common/compose.c: added some stock icons to the dialog.
2003-03-24 Michael Natterer <mitch@gimp.org> 2003-03-24 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage.c: use GIMP_STOCK_IMAGE as default_stock_id. * app/core/gimpimage.c: use GIMP_STOCK_IMAGE as default_stock_id.

View File

@ -64,11 +64,11 @@ static void run (gchar *name,
gint *nreturn_vals, gint *nreturn_vals,
GimpParam **return_vals); GimpParam **return_vals);
static gint32 compose (gchar *compose_type, static gint32 compose (const gchar *compose_type,
gint32 *compose_ID, gint32 *compose_ID,
gint compose_by_drawable); gboolean compose_by_drawable);
static gint32 create_new_image (gchar *filename, static gint32 create_new_image (const gchar *filename,
guint width, guint width,
guint height, guint height,
GimpImageType gdtype, GimpImageType gdtype,
@ -83,13 +83,13 @@ static void compose_cmy (guchar **src, gint *incr, gint numpix, guchar *dst);
static void compose_cmyk (guchar **src, gint *incr, gint numpix, guchar *dst); static void compose_cmyk (guchar **src, gint *incr, gint numpix, guchar *dst);
static void compose_ycbcr470 (guchar **src, gint *incr, gint numpix, guchar *dst); static void compose_ycbcr470 (guchar **src, gint *incr, gint numpix, guchar *dst);
static void compose_ycbcr709 (guchar **src, gint *incr, gint numpix, guchar *dst); static void compose_ycbcr709 (guchar **src, gint *incr, gint numpix, guchar *dst);
static void compose_ycbcr470f(guchar **src, gint *incr, gint numpix, guchar *dst); static void compose_ycbcr470f (guchar **src, gint *incr, gint numpix, guchar *dst);
static void compose_ycbcr709f(guchar **src, gint *incr, gint numpix, guchar *dst); static void compose_ycbcr709f (guchar **src, gint *incr, gint numpix, guchar *dst);
static gint compose_dialog (gchar *compose_type, static gboolean compose_dialog (gchar *compose_type,
gint32 drawable_ID); gint32 drawable_ID);
static gint check_gray (gint32 image_id, static gboolean check_gray (gint32 image_id,
gint32 drawable_id, gint32 drawable_id,
gpointer data); gpointer data);
@ -108,59 +108,92 @@ static void compose_type_toggle_update (GtkWidget *widget,
/* Description of a composition */ /* Description of a composition */
typedef struct typedef struct
{ {
gchar *compose_type; /* Type of composition ("RGB", "RGBA",...) */ const gchar *compose_type; /* Type of composition ("RGB", "RGBA",...) */
gint num_images; /* Number of input images needed */ gint num_images; /* Number of input images needed */
gchar *channel_name[MAX_COMPOSE_IMAGES]; /* channel names for dialog */ /* Channel names and stock ids for dialog */
gchar *filename; /* Name of new image */ const gchar *channel_name[MAX_COMPOSE_IMAGES];
const gchar *channel_icon[MAX_COMPOSE_IMAGES];
const gchar *filename; /* Name of new image */
/* Compose functon */ /* Compose functon */
void (*compose_fun) (guchar **src, gint *incr_src, gint numpix, guchar *dst); void (*compose_fun) (guchar **src,
gint *incr_src,
gint numpix,
guchar *dst);
} COMPOSE_DSC; } COMPOSE_DSC;
/* Array of available compositions. */ /* Array of available compositions. */
#define CHNL_NA "-"
static COMPOSE_DSC compose_dsc[] = static COMPOSE_DSC compose_dsc[] =
{ {
{ N_("RGB"), 3, { N_("Red:"), { N_("RGB"), 3,
{ N_("Red:"),
N_("Green:"), N_("Green:"),
N_("Blue:"), N_("Blue:"),
CHNL_NA }, "rgb-compose", compose_rgb }, NULL },
{ N_("RGBA"), 4, { N_("Red:"), { GIMP_STOCK_CHANNEL_RED,
GIMP_STOCK_CHANNEL_GREEN,
GIMP_STOCK_CHANNEL_BLUE,
NULL },
"rgb-compose", compose_rgb },
{ N_("RGBA"), 4,
{ N_("Red:"),
N_("Green:"), N_("Green:"),
N_("Blue:"), N_("Blue:"),
N_("Alpha:") }, "rgba-compose", compose_rgba }, N_("Alpha:") },
{ N_("HSV"), 3, { N_("Hue:"), { GIMP_STOCK_CHANNEL_RED,
GIMP_STOCK_CHANNEL_GREEN,
GIMP_STOCK_CHANNEL_BLUE,
GIMP_STOCK_CHANNEL_ALPHA },
"rgba-compose", compose_rgba },
{ N_("HSV"), 3,
{ N_("Hue:"),
N_("Saturation:"), N_("Saturation:"),
N_("Value:"), N_("Value:"),
CHNL_NA }, "hsv-compose", compose_hsv }, NULL },
{ N_("CMY"), 3, { N_("Cyan:"), { NULL, NULL, NULL, NULL },
"hsv-compose", compose_hsv },
{ N_("CMY"), 3,
{ N_("Cyan:"),
N_("Magenta:"), N_("Magenta:"),
N_("Yellow:"), N_("Yellow:"),
CHNL_NA }, "cmy-compose", compose_cmy }, NULL },
{ N_("CMYK"), 4, { N_("Cyan:"), { NULL, NULL, NULL, NULL },
"cmy-compose", compose_cmy },
{ N_("CMYK"), 4,
{ N_("Cyan:"),
N_("Magenta:"), N_("Magenta:"),
N_("Yellow:"), N_("Yellow:"),
N_("Black:") }, "cmyk-compose", compose_cmyk }, N_("Black:") },
{ "YCbCr_ITU_R470", { NULL, NULL, NULL, NULL },
3, { N_("Luma_y470:"), "cmyk-compose", compose_cmyk },
{ "YCbCr_ITU_R470", 3,
{ N_("Luma_y470:"),
N_("Blueness_cb470:"), N_("Blueness_cb470:"),
N_("Redness_cr470:"), N_("Redness_cr470:"),
CHNL_NA }, "ycbcr470-compose", compose_ycbcr470 }, NULL },
{ "YCbCr_ITU_R709", { NULL, NULL, NULL, NULL },
3, { N_("Luma_y709:"), "ycbcr470-compose", compose_ycbcr470 },
{ "YCbCr_ITU_R709", 3,
{ N_("Luma_y709:"),
N_("Blueness_cb709:"), N_("Blueness_cb709:"),
N_("Redness_cr709:"), N_("Redness_cr709:"),
CHNL_NA }, "ycbcr709-compose", compose_ycbcr709 }, NULL },
{ "YCbCr_ITU_R470_256", { NULL, NULL, NULL, NULL },
3, { N_("Luma_y470f:"), "ycbcr709-compose", compose_ycbcr709 },
{ "YCbCr_ITU_R470_256", 3,
{ N_("Luma_y470f:"),
N_("Blueness_cb470f:"), N_("Blueness_cb470f:"),
N_("Redness_cr470f:"), N_("Redness_cr470f:"),
CHNL_NA }, "ycbcr470F-compose", compose_ycbcr470f }, NULL },
{ "YCbCr_ITU_R709_256", { NULL, NULL, NULL, NULL },
3, { N_("Luma_y709f:"), "ycbcr470F-compose", compose_ycbcr470f },
{ "YCbCr_ITU_R709_256", 3,
{ N_("Luma_y709f:"),
N_("Blueness_cb709f:"), N_("Blueness_cb709f:"),
N_("Redness_cr709f:"), N_("Redness_cr709f:"),
CHNL_NA }, "ycbcr709F-compose", compose_ycbcr709f }, NULL },
{ NULL, NULL, NULL, NULL },
"ycbcr709F-compose", compose_ycbcr709f },
}; };
#define MAX_COMPOSE_TYPES (G_N_ELEMENTS (compose_dsc)) #define MAX_COMPOSE_TYPES (G_N_ELEMENTS (compose_dsc))
@ -178,11 +211,12 @@ typedef struct
gint width, height; /* Size of selected image */ gint width, height; /* Size of selected image */
GtkWidget *channel_label[MAX_COMPOSE_IMAGES]; /* The labels to change */ GtkWidget *channel_label[MAX_COMPOSE_IMAGES]; /* The labels to change */
GtkWidget *channel_icon[MAX_COMPOSE_IMAGES]; /* The icons */
GtkWidget *channel_menu[MAX_COMPOSE_IMAGES]; /* The menues */ GtkWidget *channel_menu[MAX_COMPOSE_IMAGES]; /* The menues */
gint32 select_ID[MAX_COMPOSE_IMAGES]; /* Image Ids selected by menu */ gint32 select_ID[MAX_COMPOSE_IMAGES]; /* Image Ids selected by menu */
gint compose_flag[MAX_COMPOSE_TYPES]; /* toggle data of compose type */ gint compose_flag[MAX_COMPOSE_TYPES]; /* toggle data of compose type */
gint run; gboolean run;
} ComposeInterface; } ComposeInterface;
GimpPlugInInfo PLUG_IN_INFO = GimpPlugInInfo PLUG_IN_INFO =
@ -203,6 +237,7 @@ static ComposeInterface composeint =
{ {
0, 0, /* width, height */ 0, 0, /* width, height */
{ NULL }, /* Label Widgets */ { NULL }, /* Label Widgets */
{ NULL }, /* Icon Widgets */
{ NULL }, /* Menu Widgets */ { NULL }, /* Menu Widgets */
{ 0 }, /* Image IDs from menues */ { 0 }, /* Image IDs from menues */
{ 0 }, /* Compose type toggle flags */ { 0 }, /* Compose type toggle flags */
@ -345,8 +380,9 @@ run (gchar *name,
} }
else else
{ {
composevals.compose_ID[0] = composevals.compose_ID[0] = (compose_by_drawable ?
compose_by_drawable ? param[2].data.d_int32 : param[1].data.d_int32; param[2].data.d_int32 :
param[1].data.d_int32);
composevals.compose_ID[1] = param[3].data.d_int32; composevals.compose_ID[1] = param[3].data.d_int32;
composevals.compose_ID[2] = param[4].data.d_int32; composevals.compose_ID[2] = param[4].data.d_int32;
composevals.compose_ID[3] = param[5].data.d_int32; composevals.compose_ID[3] = param[5].data.d_int32;
@ -398,9 +434,9 @@ run (gchar *name,
/* Compose an image from several gray-images */ /* Compose an image from several gray-images */
static gint32 static gint32
compose (gchar *compose_type, compose (const gchar *compose_type,
gint32 *compose_ID, gint32 *compose_ID,
gint compose_by_drawable) gboolean compose_by_drawable)
{ {
gint width, height, tile_height, scan_lines; gint width, height, tile_height, scan_lines;
gint num_images, compose_idx, incr_src[MAX_COMPOSE_IMAGES]; gint num_images, compose_idx, incr_src[MAX_COMPOSE_IMAGES];
@ -544,7 +580,7 @@ compose (gchar *compose_type,
/* Create an image. Sets layer_ID, drawable and rgn. Returns image_ID */ /* Create an image. Sets layer_ID, drawable and rgn. Returns image_ID */
static gint32 static gint32
create_new_image (gchar *filename, create_new_image (const gchar *filename,
guint width, guint width,
guint height, guint height,
GimpImageType gdtype, GimpImageType gdtype,
@ -563,7 +599,7 @@ create_new_image (gchar *filename,
gitype = GIMP_RGB; gitype = GIMP_RGB;
image_ID = gimp_image_new (width, height, gitype); image_ID = gimp_image_new (width, height, gitype);
gimp_image_set_filename (image_ID, filename); gimp_image_set_filename (image_ID, (gchar *) filename);
*layer_ID = gimp_layer_new (image_ID, _("Background"), width, height, *layer_ID = gimp_layer_new (image_ID, _("Background"), width, height,
gdtype, 100, GIMP_NORMAL_MODE); gdtype, 100, GIMP_NORMAL_MODE);
@ -921,7 +957,7 @@ compose_ycbcr709f (guchar **src,
} }
static gint static gboolean
compose_dialog (gchar *compose_type, compose_dialog (gchar *compose_type,
gint32 drawable_ID) gint32 drawable_ID)
{ {
@ -932,9 +968,10 @@ compose_dialog (gchar *compose_type,
GtkWidget *hbox; GtkWidget *hbox;
GtkWidget *label; GtkWidget *label;
GtkWidget *table; GtkWidget *table;
GtkWidget *image;
GtkWidget *image_option_menu, *image_menu; GtkWidget *image_option_menu, *image_menu;
GSList *group; GSList *group;
gint j, compose_idx, sensitive; gint j, compose_idx;
/* Check default compose type */ /* Check default compose type */
compose_idx = -1; compose_idx = -1;
@ -995,49 +1032,56 @@ compose_dialog (gchar *compose_type,
gtk_container_set_border_width (GTK_CONTAINER (right_vbox), 4); gtk_container_set_border_width (GTK_CONTAINER (right_vbox), 4);
gtk_container_add (GTK_CONTAINER (right_frame), right_vbox); gtk_container_add (GTK_CONTAINER (right_frame), right_vbox);
table = gtk_table_new (MAX_COMPOSE_IMAGES, 2, FALSE); table = gtk_table_new (MAX_COMPOSE_IMAGES, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 4); gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_box_pack_start (GTK_BOX (right_vbox), table, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (right_vbox), table, TRUE, TRUE, 0);
gtk_widget_show (table); gtk_widget_show (table);
/* Channel names */
for (j = 0; j < MAX_COMPOSE_IMAGES; j++) for (j = 0; j < MAX_COMPOSE_IMAGES; j++)
{ {
composeint.channel_label[j] = label = const gchar *text;
gtk_label_new (gettext (compose_dsc[compose_idx].channel_name[j]));
image = gtk_image_new_from_stock (compose_dsc[compose_idx].channel_icon[j],
GTK_ICON_SIZE_BUTTON);
composeint.channel_icon[j] = image;
gtk_table_attach (GTK_TABLE (table), image, 0, 1, j, j+1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (image);
text = (compose_dsc[compose_idx].channel_name[j] ?
gettext (compose_dsc[compose_idx].channel_name[j]) : NULL);
composeint.channel_label[j] = label = gtk_label_new (text);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, j, j+1, gtk_table_attach (GTK_TABLE (table), label, 1, 2, j, j+1,
GTK_FILL, GTK_FILL, 0, 0); GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label); gtk_widget_show (label);
}
/* Set sensitivity of last label */
sensitive = (strcmp (compose_dsc[compose_idx].channel_name[3],
CHNL_NA) != 0);
gtk_widget_set_sensitive (composeint.channel_label[3], sensitive);
/* Menues to select images */
for (j = 0; j < MAX_COMPOSE_IMAGES; j++)
{
composeint.select_ID[j] = drawable_ID; composeint.select_ID[j] = drawable_ID;
composeint.channel_menu[j] = image_option_menu = gtk_option_menu_new (); composeint.channel_menu[j] = image_option_menu = gtk_option_menu_new ();
image_menu = gimp_drawable_menu_new (check_gray, image_menu_callback, image_menu = gimp_drawable_menu_new (check_gray,
image_menu_callback,
&(composeint.select_ID[j]), &(composeint.select_ID[j]),
composeint.select_ID[j]); composeint.select_ID[j]);
gtk_table_attach (GTK_TABLE (table), image_option_menu, 1, 2, j, j+1, gtk_table_attach (GTK_TABLE (table), image_option_menu, 2, 3, j, j+1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (image_option_menu); gtk_widget_show (image_option_menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (image_option_menu), image_menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (image_option_menu),
image_menu);
} }
gtk_widget_set_sensitive (composeint.channel_menu[3], sensitive);
/* Set sensitivity of last menu */
gtk_widget_set_sensitive (composeint.channel_menu[3],
compose_dsc[compose_idx].channel_name[3] != NULL);
/* Compose types */ /* Compose types */
group = NULL; group = NULL;
for (j = 0; j < MAX_COMPOSE_TYPES; j++) for (j = 0; j < MAX_COMPOSE_TYPES; j++)
{ {
toggle = gtk_radio_button_new_with_label (group, toggle = gtk_radio_button_new_with_label (group,
gettext(compose_dsc[j].compose_type)); gettext (compose_dsc[j].compose_type));
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggle)); group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggle));
gtk_box_pack_start (GTK_BOX (left_vbox), toggle, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (left_vbox), toggle, TRUE, TRUE, 0);
composeint.compose_flag[j] = (j == compose_idx); composeint.compose_flag[j] = (j == compose_idx);
@ -1058,14 +1102,13 @@ compose_dialog (gchar *compose_type,
gtk_widget_show (dlg); gtk_widget_show (dlg);
gtk_main (); gtk_main ();
gdk_flush ();
return composeint.run; return composeint.run;
} }
/* Compose interface functions */ /* Compose interface functions */
static gint static gboolean
check_gray (gint32 image_id, check_gray (gint32 image_id,
gint32 drawable_id, gint32 drawable_id,
gpointer data) gpointer data)
@ -1112,26 +1155,37 @@ static void
compose_type_toggle_update (GtkWidget *widget, compose_type_toggle_update (GtkWidget *widget,
gpointer data) gpointer data)
{ {
gint *toggle_val; gboolean *toggle_val;
gint compose_idx, j; gint compose_idx, j;
gint sensitive;
toggle_val = (gint *) data; toggle_val = (gboolean *) data;
if (GTK_TOGGLE_BUTTON (widget)->active) if (GTK_TOGGLE_BUTTON (widget)->active)
{ {
*toggle_val = TRUE; const gchar *text;
compose_idx = toggle_val - &(composeint.compose_flag[0]);
for (j = 0; j < MAX_COMPOSE_IMAGES; j++)
gtk_label_set_text (GTK_LABEL (composeint.channel_label[j]),
compose_dsc[compose_idx].channel_name[j]);
/* Set sensitivity of last label */ *toggle_val = TRUE;
sensitive = (strcmp (compose_dsc[compose_idx].channel_name[3],
CHNL_NA) != 0); compose_idx = toggle_val - &(composeint.compose_flag[0]);
gtk_widget_set_sensitive (composeint.channel_label[3], sensitive);
gtk_widget_set_sensitive (composeint.channel_menu[3], sensitive); for (j = 0; j < MAX_COMPOSE_IMAGES; j++)
{
text = (compose_dsc[compose_idx].channel_name[j] ?
gettext (compose_dsc[compose_idx].channel_name[j]) : NULL);
gtk_label_set_text (GTK_LABEL (composeint.channel_label[j]), text);
gtk_image_set_from_stock (GTK_IMAGE (composeint.channel_icon[j]),
compose_dsc[compose_idx].channel_icon[j],
GTK_ICON_SIZE_BUTTON);
}
/* Set sensitivity of last menu */
gtk_widget_set_sensitive (composeint.channel_menu[3],
compose_dsc[compose_idx].channel_name[3] != NULL);
} }
else else
{
*toggle_val = FALSE; *toggle_val = FALSE;
}
} }