1998-03-15 02:46:15 +00:00
|
|
|
/**
|
|
|
|
* aa.c version 1.0
|
|
|
|
* A plugin that uses libaa (ftp://ftp.ta.jcu.cz/pub/aa) to save images as
|
|
|
|
* ASCII.
|
|
|
|
* NOTE: This plugin *requires* aalib 1.2 or later. Earlier versions will
|
|
|
|
* not work.
|
|
|
|
* Code copied from all over the GIMP source.
|
|
|
|
* Tim Newsome <nuisance@cmu.edu>
|
|
|
|
*/
|
|
|
|
|
2004-05-09 18:45:14 +00:00
|
|
|
/* 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
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
1999-12-17 21:24:24 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-03-15 02:46:15 +00:00
|
|
|
#include <string.h>
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2005-03-04 15:12:29 +00:00
|
|
|
#include <aalib.h>
|
2000-01-13 15:39:26 +00:00
|
|
|
|
1998-03-15 02:46:15 +00:00
|
|
|
#include <libgimp/gimp.h>
|
1999-10-08 20:09:04 +00:00
|
|
|
#include <libgimp/gimpui.h>
|
1998-03-15 02:46:15 +00:00
|
|
|
|
1999-12-17 21:24:24 +00:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
|
|
|
|
2005-08-13 18:29:14 +00:00
|
|
|
|
|
|
|
#define SAVE_PROC "file-aa-save"
|
|
|
|
#define PLUG_IN_BINARY "aa"
|
|
|
|
|
|
|
|
|
2003-09-07 15:08:42 +00:00
|
|
|
/*
|
1998-03-15 02:46:15 +00:00
|
|
|
* Declare some local functions.
|
|
|
|
*/
|
2004-09-12 21:29:46 +00:00
|
|
|
static void query (void);
|
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
|
|
|
static gboolean save_aa (gint32 drawable_ID,
|
|
|
|
gchar *filename,
|
|
|
|
gint output_type);
|
|
|
|
static void gimp2aa (gint32 drawable_ID,
|
|
|
|
aa_context *context);
|
|
|
|
|
|
|
|
static gint aa_dialog (gint selected);
|
|
|
|
|
1998-03-15 02:46:15 +00:00
|
|
|
|
2003-09-07 15:08:42 +00:00
|
|
|
/*
|
1998-03-15 02:46:15 +00:00
|
|
|
* Some global variables.
|
|
|
|
*/
|
|
|
|
|
2000-08-22 01:26:57 +00:00
|
|
|
GimpPlugInInfo PLUG_IN_INFO =
|
1998-03-15 02:46:15 +00:00
|
|
|
{
|
2000-01-25 17:46:56 +00:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
1999-10-08 20:09:04 +00:00
|
|
|
query, /* query_proc */
|
2000-01-25 17:46:56 +00:00
|
|
|
run, /* run_proc */
|
1998-03-15 02:46:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-01-13 15:39:26 +00:00
|
|
|
MAIN ()
|
|
|
|
|
2003-09-07 15:08:42 +00:00
|
|
|
static void
|
2000-01-13 15:39:26 +00:00
|
|
|
query (void)
|
1998-03-15 02:46:15 +00:00
|
|
|
{
|
2000-08-22 01:26:57 +00:00
|
|
|
static GimpParamDef save_args[] =
|
1999-10-08 20:09:04 +00:00
|
|
|
{
|
2005-08-13 18:29:14 +00:00
|
|
|
{GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive"},
|
2000-08-22 01:26:57 +00:00
|
|
|
{GIMP_PDB_IMAGE, "image", "Input image"},
|
|
|
|
{GIMP_PDB_DRAWABLE, "drawable", "Drawable to save"},
|
|
|
|
{GIMP_PDB_STRING, "filename", "The name of the file to save the image in"},
|
2005-08-13 18:29:14 +00:00
|
|
|
{GIMP_PDB_STRING, "raw-filename", "The name entered"},
|
|
|
|
{GIMP_PDB_STRING, "file-type", "File type to use"}
|
1999-10-08 20:09:04 +00:00
|
|
|
};
|
|
|
|
|
2005-08-13 18:29:14 +00:00
|
|
|
gimp_install_procedure (SAVE_PROC,
|
2003-12-23 22:07:06 +00:00
|
|
|
"Saves grayscale image in various text formats",
|
|
|
|
"This plug-in uses aalib to save grayscale image "
|
2002-02-17 21:14:53 +00:00
|
|
|
"as ascii art into a variety of text formats",
|
2003-12-23 22:07:06 +00:00
|
|
|
"Tim Newsome <nuisance@cmu.edu>",
|
|
|
|
"Tim Newsome <nuisance@cmu.edu>",
|
|
|
|
"1997",
|
2004-05-14 00:42:38 +00:00
|
|
|
N_("ASCII art"),
|
2003-12-23 22:07:06 +00:00
|
|
|
"RGB*, GRAY*",
|
|
|
|
GIMP_PLUGIN,
|
|
|
|
G_N_ELEMENTS (save_args), 0,
|
|
|
|
save_args, NULL);
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2005-08-13 18:29:14 +00:00
|
|
|
gimp_register_file_handler_mime (SAVE_PROC, "text/plain");
|
|
|
|
gimp_register_save_handler (SAVE_PROC, "txt,ansi,text", "");
|
1998-03-15 02:46:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Searches aa_formats defined by aalib to find the index of the type
|
|
|
|
* specified by string.
|
|
|
|
* -1 means it wasn't found.
|
|
|
|
*/
|
2003-09-07 15:08:42 +00:00
|
|
|
static gint
|
2002-02-17 21:14:53 +00:00
|
|
|
get_type_from_string (const gchar *string)
|
1998-03-15 02:46:15 +00:00
|
|
|
{
|
2000-01-25 17:46:56 +00:00
|
|
|
gint type = 0;
|
2001-05-20 14:15:09 +00:00
|
|
|
aa_format **p = (aa_format **) aa_formats;
|
2000-01-25 17:46:56 +00:00
|
|
|
|
2000-01-13 15:39:26 +00:00
|
|
|
while (*p && strcmp ((*p)->formatname, string))
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
type++;
|
|
|
|
}
|
1999-10-08 20:09:04 +00:00
|
|
|
|
|
|
|
if (*p == NULL)
|
|
|
|
return -1;
|
2000-01-13 15:39:26 +00:00
|
|
|
|
1999-10-08 20:09:04 +00:00
|
|
|
return type;
|
1998-03-15 02:46:15 +00:00
|
|
|
}
|
|
|
|
|
2003-09-07 15:08:42 +00:00
|
|
|
static void
|
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
2003-07-01 18:54:28 +00:00
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1998-03-15 02:46:15 +00:00
|
|
|
{
|
2003-11-06 15:27:05 +00:00
|
|
|
static GimpParam values[2];
|
|
|
|
GimpRunMode run_mode;
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
|
|
|
gint output_type = 0;
|
|
|
|
gint32 image_ID;
|
|
|
|
gint32 drawable_ID;
|
|
|
|
GimpExportReturn export = GIMP_EXPORT_CANCEL;
|
1999-10-08 20:09:04 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
INIT_I18N ();
|
|
|
|
|
1999-10-08 20:09:04 +00:00
|
|
|
/* Set us up to return a status. */
|
|
|
|
*nreturn_vals = 1;
|
2000-01-25 17:46:56 +00:00
|
|
|
*return_vals = values;
|
2000-08-22 01:26:57 +00:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
|
|
|
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
1999-10-09 00:11:50 +00:00
|
|
|
run_mode = param[0].data.d_int32;
|
|
|
|
image_ID = param[1].data.d_int32;
|
|
|
|
drawable_ID = param[2].data.d_int32;
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2003-09-07 15:08:42 +00:00
|
|
|
/* eventually export the image */
|
1999-10-09 00:11:50 +00:00
|
|
|
switch (run_mode)
|
|
|
|
{
|
2000-08-22 01:26:57 +00:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
2005-08-13 18:29:14 +00:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
2003-09-07 15:08:42 +00:00
|
|
|
export = gimp_export_image (&image_ID, &drawable_ID, "AA",
|
2003-12-23 22:07:06 +00:00
|
|
|
(GIMP_EXPORT_CAN_HANDLE_RGB |
|
2002-12-04 19:02:45 +00:00
|
|
|
GIMP_EXPORT_CAN_HANDLE_GRAY |
|
2003-12-23 22:07:06 +00:00
|
|
|
GIMP_EXPORT_CAN_HANDLE_ALPHA ));
|
2000-08-24 14:17:34 +00:00
|
|
|
if (export == GIMP_EXPORT_CANCEL)
|
2003-12-23 22:07:06 +00:00
|
|
|
{
|
|
|
|
values[0].data.d_status = GIMP_PDB_CANCEL;
|
|
|
|
return;
|
|
|
|
}
|
1999-10-09 00:11:50 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2002-12-04 19:02:45 +00:00
|
|
|
if (! (gimp_drawable_is_rgb (drawable_ID) ||
|
2003-09-07 15:08:42 +00:00
|
|
|
gimp_drawable_is_gray (drawable_ID)))
|
1999-10-08 20:09:04 +00:00
|
|
|
{
|
2000-08-22 01:26:57 +00:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
1999-10-08 20:09:04 +00:00
|
|
|
}
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2000-08-22 01:26:57 +00:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
1999-10-08 20:09:04 +00:00
|
|
|
{
|
2003-09-07 15:08:42 +00:00
|
|
|
switch (run_mode)
|
2003-12-23 22:07:06 +00:00
|
|
|
{
|
|
|
|
case GIMP_RUN_INTERACTIVE:
|
2005-08-13 18:29:14 +00:00
|
|
|
gimp_get_data (SAVE_PROC, &output_type);
|
2004-09-12 21:29:46 +00:00
|
|
|
output_type = aa_dialog (output_type);
|
2003-12-23 22:07:06 +00:00
|
|
|
if (output_type < 0)
|
|
|
|
status = GIMP_PDB_CANCEL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
|
|
|
/* Make sure all the arguments are there! */
|
|
|
|
if (nparams != 6)
|
|
|
|
{
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
output_type = get_type_from_string (param[5].data.d_string);
|
|
|
|
if (output_type < 0)
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
2005-08-13 18:29:14 +00:00
|
|
|
gimp_get_data (SAVE_PROC, &output_type);
|
2003-12-23 22:07:06 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-10-08 20:09:04 +00:00
|
|
|
}
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2000-08-22 01:26:57 +00:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
1999-10-08 20:09:04 +00:00
|
|
|
{
|
2002-02-17 21:14:53 +00:00
|
|
|
if (save_aa (drawable_ID, param[3].data.d_string, output_type))
|
2003-12-23 22:07:06 +00:00
|
|
|
{
|
2005-08-13 18:29:14 +00:00
|
|
|
gimp_set_data (SAVE_PROC, &output_type, sizeof (output_type));
|
2003-12-23 22:07:06 +00:00
|
|
|
}
|
2000-01-25 17:46:56 +00:00
|
|
|
else
|
2003-12-23 22:07:06 +00:00
|
|
|
{
|
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
|
|
|
}
|
1999-10-08 20:09:04 +00:00
|
|
|
}
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2000-08-24 14:17:34 +00:00
|
|
|
if (export == GIMP_EXPORT_EXPORT)
|
2003-09-07 15:08:42 +00:00
|
|
|
gimp_image_delete (image_ID);
|
2000-01-25 17:46:56 +00:00
|
|
|
|
|
|
|
values[0].data.d_status = status;
|
1998-03-15 02:46:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The actual save function. What it's all about.
|
|
|
|
* The image type has to be GRAY.
|
|
|
|
*/
|
2000-01-13 15:39:26 +00:00
|
|
|
static gboolean
|
2002-02-17 21:14:53 +00:00
|
|
|
save_aa (gint32 drawable_ID,
|
|
|
|
gchar *filename,
|
|
|
|
gint output_type)
|
1998-03-15 02:46:15 +00:00
|
|
|
{
|
2002-02-17 21:14:53 +00:00
|
|
|
aa_savedata savedata;
|
|
|
|
aa_context *context;
|
2003-01-15 03:55:20 +00:00
|
|
|
aa_format format = *aa_formats[output_type];
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2002-02-17 21:14:53 +00:00
|
|
|
format.width = gimp_drawable_width (drawable_ID) / 2;
|
|
|
|
format.height = gimp_drawable_height (drawable_ID) / 2;
|
2000-01-13 15:39:26 +00:00
|
|
|
|
1999-10-08 20:09:04 +00:00
|
|
|
/* Get a libaa context which will save its output to filename. */
|
2002-02-17 21:14:53 +00:00
|
|
|
savedata.name = filename;
|
1999-10-08 20:09:04 +00:00
|
|
|
savedata.format = &format;
|
2000-01-13 15:39:26 +00:00
|
|
|
|
1999-10-08 20:09:04 +00:00
|
|
|
context = aa_init (&save_d, &aa_defparams, &savedata);
|
2002-02-17 21:14:53 +00:00
|
|
|
if (!context)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gimp2aa (drawable_ID, context);
|
1999-10-08 20:09:04 +00:00
|
|
|
aa_flush (context);
|
|
|
|
aa_close (context);
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2002-02-17 21:14:53 +00:00
|
|
|
return TRUE;
|
1998-03-15 02:46:15 +00:00
|
|
|
}
|
|
|
|
|
2000-01-13 15:39:26 +00:00
|
|
|
static void
|
2003-09-07 15:08:42 +00:00
|
|
|
gimp2aa (gint32 drawable_ID,
|
2003-12-23 22:07:06 +00:00
|
|
|
aa_context *context)
|
1998-03-15 02:46:15 +00:00
|
|
|
{
|
2002-02-17 21:14:53 +00:00
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpPixelRgn pixel_rgn;
|
|
|
|
aa_renderparams *renderparams;
|
|
|
|
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gint x, y;
|
|
|
|
gint bpp;
|
1999-10-08 20:09:04 +00:00
|
|
|
guchar *buffer;
|
2002-12-04 19:02:45 +00:00
|
|
|
guchar *p;
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2002-02-17 21:14:53 +00:00
|
|
|
drawable = gimp_drawable_get (drawable_ID);
|
|
|
|
|
|
|
|
width = aa_imgwidth (context);
|
1999-10-09 00:11:50 +00:00
|
|
|
height = aa_imgheight (context);
|
2002-02-17 21:14:53 +00:00
|
|
|
bpp = drawable->bpp;
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2003-09-07 15:08:42 +00:00
|
|
|
gimp_tile_cache_ntiles ((width / gimp_tile_width ()) + 1);
|
|
|
|
|
|
|
|
gimp_pixel_rgn_init (&pixel_rgn,
|
|
|
|
drawable, 0, 0, width, height,
|
2002-02-17 21:14:53 +00:00
|
|
|
FALSE, FALSE);
|
2000-01-13 15:39:26 +00:00
|
|
|
|
|
|
|
buffer = g_new (guchar, width * bpp);
|
|
|
|
|
2003-09-07 15:08:42 +00:00
|
|
|
for (y = 0; y < height; y++)
|
1999-10-08 20:09:04 +00:00
|
|
|
{
|
|
|
|
gimp_pixel_rgn_get_row (&pixel_rgn, buffer, 0, y, width);
|
2002-12-04 19:02:45 +00:00
|
|
|
|
|
|
|
switch (bpp)
|
|
|
|
{
|
|
|
|
case 1: /* GRAY */
|
2003-09-07 15:08:42 +00:00
|
|
|
for (x = 0, p = buffer; x < width; x++, p++)
|
2002-12-04 19:02:45 +00:00
|
|
|
aa_putpixel (context, x, y, *p);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* GRAYA, blend over black */
|
2003-09-07 15:08:42 +00:00
|
|
|
for (x = 0, p = buffer; x < width; x++, p += 2)
|
2002-12-04 19:02:45 +00:00
|
|
|
aa_putpixel (context, x, y, (p[0] * (p[1] + 1)) >> 8);
|
|
|
|
break;
|
2003-09-07 15:08:42 +00:00
|
|
|
|
2002-12-04 19:02:45 +00:00
|
|
|
case 3: /* RGB */
|
2003-09-07 15:08:42 +00:00
|
|
|
for (x = 0, p = buffer; x < width; x++, p += 3)
|
2003-11-17 17:33:14 +00:00
|
|
|
aa_putpixel (context, x, y,
|
2005-08-03 00:36:41 +00:00
|
|
|
GIMP_RGB_LUMINANCE (p[0], p[1], p[2]) + 0.5);
|
2002-12-04 19:02:45 +00:00
|
|
|
break;
|
2003-09-07 15:08:42 +00:00
|
|
|
|
2002-12-04 19:02:45 +00:00
|
|
|
case 4: /* RGBA, blend over black */
|
2003-09-07 15:08:42 +00:00
|
|
|
for (x = 0, p = buffer; x < width; x++, p += 4)
|
2002-12-04 19:02:45 +00:00
|
|
|
aa_putpixel (context, x, y,
|
2005-08-03 00:36:41 +00:00
|
|
|
((guchar) (GIMP_RGB_LUMINANCE (p[0], p[1], p[2]) + 0.5)
|
2003-11-17 17:33:14 +00:00
|
|
|
* (p[3] + 1)) >> 8);
|
2002-12-04 19:02:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
1999-10-08 20:09:04 +00:00
|
|
|
}
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2002-02-17 21:14:53 +00:00
|
|
|
g_free (buffer);
|
|
|
|
|
1999-10-08 20:09:04 +00:00
|
|
|
renderparams = aa_getrenderparams ();
|
|
|
|
renderparams->dither = AA_FLOYD_S;
|
2002-02-17 21:14:53 +00:00
|
|
|
|
2003-09-07 15:08:42 +00:00
|
|
|
aa_render (context, renderparams, 0, 0,
|
2003-12-23 22:07:06 +00:00
|
|
|
aa_scrwidth (context), aa_scrheight (context));
|
1998-03-15 02:46:15 +00:00
|
|
|
}
|
|
|
|
|
2003-09-07 15:08:42 +00:00
|
|
|
static gint
|
2004-09-12 21:29:46 +00:00
|
|
|
aa_dialog (gint selected)
|
1999-10-08 20:09:04 +00:00
|
|
|
{
|
2004-09-12 21:29:46 +00:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *combo;
|
|
|
|
gint i;
|
2000-01-13 15:39:26 +00:00
|
|
|
|
1999-10-08 20:09:04 +00:00
|
|
|
/* Create the actual window. */
|
2005-08-13 18:29:14 +00:00
|
|
|
dialog = gimp_dialog_new (_("Save as Text"), PLUG_IN_BINARY,
|
2003-11-06 15:27:05 +00:00
|
|
|
NULL, 0,
|
2005-08-13 18:29:14 +00:00
|
|
|
gimp_standard_help_func, SAVE_PROC,
|
2000-01-06 16:40:17 +00:00
|
|
|
|
2003-12-23 22:07:06 +00:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
2005-09-02 11:09:03 +00:00
|
|
|
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
|
2001-11-29 13:23:44 +00:00
|
|
|
|
2003-12-23 22:07:06 +00:00
|
|
|
NULL);
|
1999-11-26 20:58:27 +00:00
|
|
|
|
2005-02-08 20:40:33 +00:00
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2005-09-27 18:51:44 +00:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2005-02-08 20:40:33 +00:00
|
|
|
|
2005-09-09 18:38:00 +00:00
|
|
|
gimp_window_set_transient (GTK_WINDOW (dialog));
|
|
|
|
|
2004-09-12 21:29:46 +00:00
|
|
|
hbox = gtk_hbox_new (FALSE, 6);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
|
|
|
|
hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
2003-09-07 15:08:42 +00:00
|
|
|
|
2004-09-12 21:29:46 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_Format:"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
2001-12-29 13:26:29 +00:00
|
|
|
|
2005-09-27 20:51:29 +00:00
|
|
|
combo = g_object_new (GIMP_TYPE_INT_COMBO_BOX, NULL);
|
2004-09-12 21:29:46 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (combo);
|
2003-09-07 15:08:42 +00:00
|
|
|
|
2004-09-12 21:29:46 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2004-09-12 21:29:46 +00:00
|
|
|
for (i = 0; aa_formats[i]; i++)
|
|
|
|
gimp_int_combo_box_append (GIMP_INT_COMBO_BOX (combo),
|
|
|
|
GIMP_INT_STORE_VALUE, i,
|
|
|
|
GIMP_INT_STORE_LABEL, aa_formats[i]->formatname,
|
|
|
|
-1);
|
2000-01-13 15:39:26 +00:00
|
|
|
|
2004-09-12 21:29:46 +00:00
|
|
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), selected,
|
|
|
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
|
|
|
&selected);
|
1999-10-08 20:09:04 +00:00
|
|
|
|
2004-09-12 21:29:46 +00:00
|
|
|
gtk_widget_show (dialog);
|
2003-11-06 15:27:05 +00:00
|
|
|
|
2004-09-12 21:29:46 +00:00
|
|
|
if (gimp_dialog_run (GIMP_DIALOG (dialog)) != GTK_RESPONSE_OK)
|
|
|
|
selected = -1;
|
1999-10-08 20:09:04 +00:00
|
|
|
|
2004-09-12 21:29:46 +00:00
|
|
|
gtk_widget_destroy (dialog);
|
1998-03-15 02:46:15 +00:00
|
|
|
|
2004-09-12 21:29:46 +00:00
|
|
|
return selected;
|
1998-03-15 02:46:15 +00:00
|
|
|
}
|