1998-03-15 10:46:15 +08: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>
|
|
|
|
*/
|
|
|
|
|
2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2004-05-10 02:45:14 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2004-05-10 02:45:14 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-05-10 02:45:14 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-05-10 02:45:14 +08:00
|
|
|
*/
|
|
|
|
|
1999-12-18 05:24:24 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-03-15 10:46:15 +08:00
|
|
|
#include <string.h>
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2005-03-04 23:12:29 +08:00
|
|
|
#include <aalib.h>
|
2000-01-13 23:39:26 +08:00
|
|
|
|
1998-03-15 10:46:15 +08:00
|
|
|
#include <libgimp/gimp.h>
|
1999-10-09 04:09:04 +08:00
|
|
|
#include <libgimp/gimpui.h>
|
1998-03-15 10:46:15 +08:00
|
|
|
|
1999-12-18 05:24:24 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
|
|
|
|
2005-08-14 02:29:14 +08:00
|
|
|
|
|
|
|
#define SAVE_PROC "file-aa-save"
|
2008-08-11 18:06:13 +08:00
|
|
|
#define PLUG_IN_BINARY "file-aa"
|
2011-04-09 02:31:34 +08:00
|
|
|
#define PLUG_IN_ROLE "gimp-file-aa"
|
2005-08-14 02:29:14 +08:00
|
|
|
|
|
|
|
|
2003-09-07 23:08:42 +08:00
|
|
|
/*
|
1998-03-15 10:46:15 +08:00
|
|
|
* Declare some local functions.
|
|
|
|
*/
|
2004-09-13 05:29:46 +08: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 10:46:15 +08:00
|
|
|
|
2003-09-07 23:08:42 +08:00
|
|
|
/*
|
1998-03-15 10:46:15 +08:00
|
|
|
* Some global variables.
|
|
|
|
*/
|
|
|
|
|
2006-05-16 20:26:20 +08:00
|
|
|
const GimpPlugInInfo PLUG_IN_INFO =
|
1998-03-15 10:46:15 +08:00
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
1999-10-09 04:09:04 +08:00
|
|
|
query, /* query_proc */
|
2000-01-26 01:46:56 +08:00
|
|
|
run, /* run_proc */
|
1998-03-15 10:46:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
MAIN ()
|
|
|
|
|
2003-09-07 23:08:42 +08:00
|
|
|
static void
|
2000-01-13 23:39:26 +08:00
|
|
|
query (void)
|
1998-03-15 10:46:15 +08:00
|
|
|
{
|
2006-05-16 20:26:20 +08:00
|
|
|
static const GimpParamDef save_args[] =
|
1999-10-09 04:09:04 +08:00
|
|
|
{
|
2009-01-20 04:11:36 +08:00
|
|
|
{GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }"},
|
2000-08-22 09:26:57 +08: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-14 02:29:14 +08:00
|
|
|
{GIMP_PDB_STRING, "raw-filename", "The name entered"},
|
|
|
|
{GIMP_PDB_STRING, "file-type", "File type to use"}
|
1999-10-09 04:09:04 +08:00
|
|
|
};
|
|
|
|
|
2005-08-14 02:29:14 +08:00
|
|
|
gimp_install_procedure (SAVE_PROC,
|
2003-12-24 06:07:06 +08:00
|
|
|
"Saves grayscale image in various text formats",
|
|
|
|
"This plug-in uses aalib to save grayscale image "
|
2002-02-18 05:14:53 +08:00
|
|
|
"as ascii art into a variety of text formats",
|
2003-12-24 06:07:06 +08:00
|
|
|
"Tim Newsome <nuisance@cmu.edu>",
|
|
|
|
"Tim Newsome <nuisance@cmu.edu>",
|
|
|
|
"1997",
|
2004-05-14 08:42:38 +08:00
|
|
|
N_("ASCII art"),
|
2003-12-24 06:07:06 +08:00
|
|
|
"RGB*, GRAY*",
|
|
|
|
GIMP_PLUGIN,
|
|
|
|
G_N_ELEMENTS (save_args), 0,
|
|
|
|
save_args, NULL);
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2005-08-14 02:29:14 +08:00
|
|
|
gimp_register_file_handler_mime (SAVE_PROC, "text/plain");
|
|
|
|
gimp_register_save_handler (SAVE_PROC, "txt,ansi,text", "");
|
1998-03-15 10:46:15 +08: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 23:08:42 +08:00
|
|
|
static gint
|
2002-02-18 05:14:53 +08:00
|
|
|
get_type_from_string (const gchar *string)
|
1998-03-15 10:46:15 +08:00
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
gint type = 0;
|
2001-05-20 22:15:09 +08:00
|
|
|
aa_format **p = (aa_format **) aa_formats;
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
while (*p && strcmp ((*p)->formatname, string))
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
type++;
|
|
|
|
}
|
1999-10-09 04:09:04 +08:00
|
|
|
|
|
|
|
if (*p == NULL)
|
|
|
|
return -1;
|
2000-01-13 23:39:26 +08:00
|
|
|
|
1999-10-09 04:09:04 +08:00
|
|
|
return type;
|
1998-03-15 10:46:15 +08:00
|
|
|
}
|
|
|
|
|
2003-09-07 23:08:42 +08:00
|
|
|
static void
|
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
2003-07-02 02:54:28 +08:00
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1998-03-15 10:46:15 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08: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-09 04:09:04 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
|
|
|
|
1999-10-09 04:09:04 +08:00
|
|
|
/* Set us up to return a status. */
|
|
|
|
*nreturn_vals = 1;
|
2000-01-26 01:46:56 +08:00
|
|
|
*return_vals = values;
|
2000-08-22 09:26:57 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
|
|
|
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
1999-10-09 08:11:50 +08: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 23:39:26 +08:00
|
|
|
|
2003-09-07 23:08:42 +08:00
|
|
|
/* eventually export the image */
|
1999-10-09 08:11:50 +08:00
|
|
|
switch (run_mode)
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
2005-08-14 02:29:14 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
2009-07-21 20:10:29 +08:00
|
|
|
export = gimp_export_image (&image_ID, &drawable_ID, NULL,
|
2003-12-24 06:07:06 +08:00
|
|
|
(GIMP_EXPORT_CAN_HANDLE_RGB |
|
2002-12-05 03:02:45 +08:00
|
|
|
GIMP_EXPORT_CAN_HANDLE_GRAY |
|
2003-12-24 06:07:06 +08:00
|
|
|
GIMP_EXPORT_CAN_HANDLE_ALPHA ));
|
2000-08-24 22:17:34 +08:00
|
|
|
if (export == GIMP_EXPORT_CANCEL)
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
|
|
|
values[0].data.d_status = GIMP_PDB_CANCEL;
|
|
|
|
return;
|
|
|
|
}
|
1999-10-09 08:11:50 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2002-12-05 03:02:45 +08:00
|
|
|
if (! (gimp_drawable_is_rgb (drawable_ID) ||
|
2003-09-07 23:08:42 +08:00
|
|
|
gimp_drawable_is_gray (drawable_ID)))
|
1999-10-09 04:09:04 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
1999-10-09 04:09:04 +08:00
|
|
|
}
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
1999-10-09 04:09:04 +08:00
|
|
|
{
|
2003-09-07 23:08:42 +08:00
|
|
|
switch (run_mode)
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
|
|
|
case GIMP_RUN_INTERACTIVE:
|
2005-08-14 02:29:14 +08:00
|
|
|
gimp_get_data (SAVE_PROC, &output_type);
|
2004-09-13 05:29:46 +08:00
|
|
|
output_type = aa_dialog (output_type);
|
2003-12-24 06:07:06 +08: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-14 02:29:14 +08:00
|
|
|
gimp_get_data (SAVE_PROC, &output_type);
|
2003-12-24 06:07:06 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-10-09 04:09:04 +08:00
|
|
|
}
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
1999-10-09 04:09:04 +08:00
|
|
|
{
|
2002-02-18 05:14:53 +08:00
|
|
|
if (save_aa (drawable_ID, param[3].data.d_string, output_type))
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
2005-08-14 02:29:14 +08:00
|
|
|
gimp_set_data (SAVE_PROC, &output_type, sizeof (output_type));
|
2003-12-24 06:07:06 +08:00
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
else
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
|
|
|
}
|
1999-10-09 04:09:04 +08:00
|
|
|
}
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2000-08-24 22:17:34 +08:00
|
|
|
if (export == GIMP_EXPORT_EXPORT)
|
2003-09-07 23:08:42 +08:00
|
|
|
gimp_image_delete (image_ID);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
|
|
|
values[0].data.d_status = status;
|
1998-03-15 10:46:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The actual save function. What it's all about.
|
|
|
|
* The image type has to be GRAY.
|
|
|
|
*/
|
2000-01-13 23:39:26 +08:00
|
|
|
static gboolean
|
2002-02-18 05:14:53 +08:00
|
|
|
save_aa (gint32 drawable_ID,
|
|
|
|
gchar *filename,
|
|
|
|
gint output_type)
|
1998-03-15 10:46:15 +08:00
|
|
|
{
|
2002-02-18 05:14:53 +08:00
|
|
|
aa_savedata savedata;
|
|
|
|
aa_context *context;
|
2003-01-15 11:55:20 +08:00
|
|
|
aa_format format = *aa_formats[output_type];
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2002-02-18 05:14:53 +08:00
|
|
|
format.width = gimp_drawable_width (drawable_ID) / 2;
|
|
|
|
format.height = gimp_drawable_height (drawable_ID) / 2;
|
2000-01-13 23:39:26 +08:00
|
|
|
|
1999-10-09 04:09:04 +08:00
|
|
|
/* Get a libaa context which will save its output to filename. */
|
2002-02-18 05:14:53 +08:00
|
|
|
savedata.name = filename;
|
1999-10-09 04:09:04 +08:00
|
|
|
savedata.format = &format;
|
2000-01-13 23:39:26 +08:00
|
|
|
|
1999-10-09 04:09:04 +08:00
|
|
|
context = aa_init (&save_d, &aa_defparams, &savedata);
|
2002-02-18 05:14:53 +08:00
|
|
|
if (!context)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gimp2aa (drawable_ID, context);
|
1999-10-09 04:09:04 +08:00
|
|
|
aa_flush (context);
|
|
|
|
aa_close (context);
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2002-02-18 05:14:53 +08:00
|
|
|
return TRUE;
|
1998-03-15 10:46:15 +08:00
|
|
|
}
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
static void
|
2003-09-07 23:08:42 +08:00
|
|
|
gimp2aa (gint32 drawable_ID,
|
2003-12-24 06:07:06 +08:00
|
|
|
aa_context *context)
|
1998-03-15 10:46:15 +08:00
|
|
|
{
|
2002-02-18 05:14:53 +08:00
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpPixelRgn pixel_rgn;
|
|
|
|
aa_renderparams *renderparams;
|
|
|
|
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gint x, y;
|
|
|
|
gint bpp;
|
1999-10-09 04:09:04 +08:00
|
|
|
guchar *buffer;
|
2002-12-05 03:02:45 +08:00
|
|
|
guchar *p;
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2002-02-18 05:14:53 +08:00
|
|
|
drawable = gimp_drawable_get (drawable_ID);
|
|
|
|
|
|
|
|
width = aa_imgwidth (context);
|
1999-10-09 08:11:50 +08:00
|
|
|
height = aa_imgheight (context);
|
2002-02-18 05:14:53 +08:00
|
|
|
bpp = drawable->bpp;
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2003-09-07 23:08:42 +08:00
|
|
|
gimp_tile_cache_ntiles ((width / gimp_tile_width ()) + 1);
|
|
|
|
|
|
|
|
gimp_pixel_rgn_init (&pixel_rgn,
|
|
|
|
drawable, 0, 0, width, height,
|
2002-02-18 05:14:53 +08:00
|
|
|
FALSE, FALSE);
|
2000-01-13 23:39:26 +08:00
|
|
|
|
|
|
|
buffer = g_new (guchar, width * bpp);
|
|
|
|
|
2003-09-07 23:08:42 +08:00
|
|
|
for (y = 0; y < height; y++)
|
1999-10-09 04:09:04 +08:00
|
|
|
{
|
|
|
|
gimp_pixel_rgn_get_row (&pixel_rgn, buffer, 0, y, width);
|
2002-12-05 03:02:45 +08:00
|
|
|
|
|
|
|
switch (bpp)
|
|
|
|
{
|
|
|
|
case 1: /* GRAY */
|
2003-09-07 23:08:42 +08:00
|
|
|
for (x = 0, p = buffer; x < width; x++, p++)
|
2002-12-05 03:02:45 +08:00
|
|
|
aa_putpixel (context, x, y, *p);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* GRAYA, blend over black */
|
2003-09-07 23:08:42 +08:00
|
|
|
for (x = 0, p = buffer; x < width; x++, p += 2)
|
2002-12-05 03:02:45 +08:00
|
|
|
aa_putpixel (context, x, y, (p[0] * (p[1] + 1)) >> 8);
|
|
|
|
break;
|
2003-09-07 23:08:42 +08:00
|
|
|
|
2002-12-05 03:02:45 +08:00
|
|
|
case 3: /* RGB */
|
2003-09-07 23:08:42 +08:00
|
|
|
for (x = 0, p = buffer; x < width; x++, p += 3)
|
2003-11-18 01:33:14 +08:00
|
|
|
aa_putpixel (context, x, y,
|
2005-08-03 08:36:41 +08:00
|
|
|
GIMP_RGB_LUMINANCE (p[0], p[1], p[2]) + 0.5);
|
2002-12-05 03:02:45 +08:00
|
|
|
break;
|
2003-09-07 23:08:42 +08:00
|
|
|
|
2002-12-05 03:02:45 +08:00
|
|
|
case 4: /* RGBA, blend over black */
|
2003-09-07 23:08:42 +08:00
|
|
|
for (x = 0, p = buffer; x < width; x++, p += 4)
|
2002-12-05 03:02:45 +08:00
|
|
|
aa_putpixel (context, x, y,
|
2005-08-03 08:36:41 +08:00
|
|
|
((guchar) (GIMP_RGB_LUMINANCE (p[0], p[1], p[2]) + 0.5)
|
2003-11-18 01:33:14 +08:00
|
|
|
* (p[3] + 1)) >> 8);
|
2002-12-05 03:02:45 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
1999-10-09 04:09:04 +08:00
|
|
|
}
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2002-02-18 05:14:53 +08:00
|
|
|
g_free (buffer);
|
|
|
|
|
1999-10-09 04:09:04 +08:00
|
|
|
renderparams = aa_getrenderparams ();
|
|
|
|
renderparams->dither = AA_FLOYD_S;
|
2002-02-18 05:14:53 +08:00
|
|
|
|
2003-09-07 23:08:42 +08:00
|
|
|
aa_render (context, renderparams, 0, 0,
|
2003-12-24 06:07:06 +08:00
|
|
|
aa_scrwidth (context), aa_scrheight (context));
|
1998-03-15 10:46:15 +08:00
|
|
|
}
|
|
|
|
|
2003-09-07 23:08:42 +08:00
|
|
|
static gint
|
2004-09-13 05:29:46 +08:00
|
|
|
aa_dialog (gint selected)
|
1999-10-09 04:09:04 +08:00
|
|
|
{
|
2004-09-13 05:29:46 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *combo;
|
|
|
|
gint i;
|
2000-01-13 23:39:26 +08:00
|
|
|
|
1999-10-09 04:09:04 +08:00
|
|
|
/* Create the actual window. */
|
2009-07-21 20:10:29 +08:00
|
|
|
dialog = gimp_export_dialog_new (_("Text"), PLUG_IN_BINARY, SAVE_PROC);
|
2005-09-10 02:38:00 +08:00
|
|
|
|
2004-09-13 05:29:46 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 6);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
|
2009-07-21 20:10:29 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gimp_export_dialog_get_content_area (dialog)),
|
2004-09-13 05:29:46 +08:00
|
|
|
hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
2003-09-07 23:08:42 +08:00
|
|
|
|
2004-09-13 05:29:46 +08: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 21:26:29 +08:00
|
|
|
|
2005-09-28 04:51:29 +08:00
|
|
|
combo = g_object_new (GIMP_TYPE_INT_COMBO_BOX, NULL);
|
2004-09-13 05:29:46 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (combo);
|
2003-09-07 23:08:42 +08:00
|
|
|
|
2004-09-13 05:29:46 +08:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2004-09-13 05:29:46 +08: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 23:39:26 +08:00
|
|
|
|
2004-09-13 05:29:46 +08:00
|
|
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), selected,
|
|
|
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
|
|
|
&selected);
|
1999-10-09 04:09:04 +08:00
|
|
|
|
2004-09-13 05:29:46 +08:00
|
|
|
gtk_widget_show (dialog);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-09-13 05:29:46 +08:00
|
|
|
if (gimp_dialog_run (GIMP_DIALOG (dialog)) != GTK_RESPONSE_OK)
|
|
|
|
selected = -1;
|
1999-10-09 04:09:04 +08:00
|
|
|
|
2004-09-13 05:29:46 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
1998-03-15 10:46:15 +08:00
|
|
|
|
2004-09-13 05:29:46 +08:00
|
|
|
return selected;
|
1998-03-15 10:46:15 +08:00
|
|
|
}
|