2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1998-02-22 06:14:06 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* GTM plug-in --- GIMP Table Magic
|
2016-02-16 09:35:43 +08:00
|
|
|
* Allows images to be exported as HTML tables with different colored cells.
|
1998-02-22 06:14:06 +08:00
|
|
|
* It doesn't have very much practical use other than being able to
|
|
|
|
* easily design a table by "painting" it in GIMP, or to make small HTML
|
|
|
|
* table images/icons.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1997 Daniel Dunbar
|
|
|
|
* Email: ddunbar@diads.com
|
|
|
|
* WWW: http://millennium.diads.com/gimp/
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1998-02-22 06:14:06 +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
|
1998-02-22 06:14:06 +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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1998-02-22 06:14:06 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Version 1.0:
|
|
|
|
* Once I first found out that it was possible to have pixel level control
|
|
|
|
* of HTML tables I instantly realized that it would be possible, however
|
|
|
|
* pointless, to save an image as a, albeit huge, HTML table.
|
|
|
|
*
|
|
|
|
* One night when I was feeling in an adventourously stupid programming mood
|
|
|
|
* I decided to write a program to do it.
|
|
|
|
*
|
|
|
|
* At first I just wrote a really ugly hack to do it, which I then planned
|
2003-11-06 23:27:05 +08:00
|
|
|
* on using once just to see how it worked, and then posting a URL and
|
1998-02-22 06:14:06 +08:00
|
|
|
* laughing about it on #gimp. As it turns out, tigert thought it actually
|
|
|
|
* had potential to be a useful plugin, so I started adding features and
|
|
|
|
* and making a nice UI.
|
|
|
|
*
|
2000-02-23 08:15:12 +08:00
|
|
|
* It's still not very useful, but I did manage to significantly improve my
|
1998-02-22 06:14:06 +08:00
|
|
|
* C programming skills in the process, so it was worth it.
|
|
|
|
*
|
2013-01-27 23:52:38 +08:00
|
|
|
* If you happen to find it useful I would appreciate any email about it.
|
1998-02-22 06:14:06 +08:00
|
|
|
* - Daniel Dunbar
|
|
|
|
* ddunbar@diads.com
|
|
|
|
*/
|
|
|
|
|
2000-01-07 06:26:10 +08:00
|
|
|
#include "config.h"
|
1998-02-22 06:14:06 +08:00
|
|
|
|
|
|
|
#include <string.h>
|
2000-01-07 06:26:10 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
2000-01-07 06:26:10 +08:00
|
|
|
|
1999-12-26 05:49:51 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2000-05-01 05:03:44 +08:00
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
#define SAVE_PROC "file-gtm-save"
|
2008-08-11 18:06:13 +08:00
|
|
|
#define PLUG_IN_BINARY "file-html-table"
|
2011-04-09 02:31:34 +08:00
|
|
|
#define PLUG_IN_ROLE "gimp-file-html-table"
|
2005-08-14 06:52:41 +08:00
|
|
|
|
2014-10-05 22:42:31 +08:00
|
|
|
|
1998-02-22 06:14:06 +08:00
|
|
|
/* Typedefs */
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2008-05-10 18:42:18 +08:00
|
|
|
gchar captiontxt[256];
|
|
|
|
gchar cellcontent[256];
|
|
|
|
gchar clwidth[256];
|
|
|
|
gchar clheight[256];
|
|
|
|
gboolean fulldoc;
|
|
|
|
gboolean caption;
|
|
|
|
gint border;
|
|
|
|
gboolean spantags;
|
|
|
|
gboolean tdcomp;
|
|
|
|
gint cellpadding;
|
|
|
|
gint cellspacing;
|
1998-02-22 06:14:06 +08:00
|
|
|
} GTMValues;
|
|
|
|
|
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
typedef struct _Html Html;
|
|
|
|
typedef struct _HtmlClass HtmlClass;
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
struct _Html
|
|
|
|
{
|
|
|
|
GimpPlugIn parent_instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _HtmlClass
|
|
|
|
{
|
|
|
|
GimpPlugInClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define HTML_TYPE (html_get_type ())
|
|
|
|
#define HTML (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HTML_TYPE, Html))
|
|
|
|
|
|
|
|
GType html_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
static GList * html_query_procedures (GimpPlugIn *plug_in);
|
|
|
|
static GimpProcedure * html_create_procedure (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name);
|
|
|
|
|
|
|
|
static GimpValueArray * html_save (GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GFile *file,
|
|
|
|
const GimpValueArray *args,
|
|
|
|
gpointer run_data);
|
2008-05-10 18:42:18 +08:00
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
static gboolean save_image (GFile *file,
|
|
|
|
GeglBuffer *buffer,
|
|
|
|
GError **error);
|
|
|
|
static gboolean save_dialog (GimpImage *image);
|
2008-05-10 18:42:18 +08:00
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
static gboolean print (GOutputStream *output,
|
|
|
|
GError **error,
|
|
|
|
const gchar *format,
|
|
|
|
...) G_GNUC_PRINTF (3, 0);
|
|
|
|
static gboolean color_comp (guchar *buffer,
|
|
|
|
guchar *buf2);
|
|
|
|
static void entry_changed_callback (GtkEntry *entry,
|
|
|
|
gchar *string);
|
2014-10-05 22:42:31 +08:00
|
|
|
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
G_DEFINE_TYPE (Html, html, GIMP_TYPE_PLUG_IN)
|
2014-10-05 22:42:31 +08:00
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
GIMP_MAIN (HTML_TYPE)
|
|
|
|
|
|
|
|
|
|
|
|
static GTMValues gtmvals =
|
2014-10-05 22:42:31 +08:00
|
|
|
{
|
|
|
|
"Made with GIMP Table Magic", /* caption text */
|
|
|
|
" ", /* cellcontent text */
|
|
|
|
"", /* cell width text */
|
|
|
|
"", /* cell height text */
|
|
|
|
TRUE, /* fulldoc */
|
|
|
|
FALSE, /* caption */
|
|
|
|
2, /* border */
|
|
|
|
FALSE, /* spantags */
|
|
|
|
FALSE, /* tdcomp */
|
|
|
|
4, /* cellpadding */
|
|
|
|
0 /* cellspacing */
|
|
|
|
};
|
1998-02-22 06:14:06 +08:00
|
|
|
|
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
static void
|
|
|
|
html_class_init (HtmlClass *klass)
|
|
|
|
{
|
|
|
|
GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
plug_in_class->query_procedures = html_query_procedures;
|
|
|
|
plug_in_class->create_procedure = html_create_procedure;
|
|
|
|
}
|
1998-02-22 06:14:06 +08:00
|
|
|
|
|
|
|
static void
|
2019-08-24 19:53:16 +08:00
|
|
|
html_init (Html *html)
|
1998-02-22 06:14:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
static GList *
|
|
|
|
html_query_procedures (GimpPlugIn *plug_in)
|
|
|
|
{
|
|
|
|
return g_list_append (NULL, g_strdup (SAVE_PROC));
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpProcedure *
|
|
|
|
html_create_procedure (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
GimpProcedure *procedure = NULL;
|
|
|
|
|
|
|
|
if (! strcmp (name, SAVE_PROC))
|
|
|
|
{
|
2019-08-30 18:52:28 +08:00
|
|
|
procedure = gimp_save_procedure_new (plug_in, name,
|
|
|
|
GIMP_PDB_PROC_TYPE_PLUGIN,
|
2019-08-24 19:53:16 +08:00
|
|
|
html_save, NULL, NULL);
|
|
|
|
|
|
|
|
gimp_procedure_set_image_types (procedure, "*");
|
|
|
|
|
|
|
|
gimp_procedure_set_menu_label (procedure, N_("HTML table"));
|
|
|
|
|
|
|
|
gimp_procedure_set_documentation (procedure,
|
|
|
|
"GIMP Table Magic",
|
|
|
|
"Allows you to draw an HTML table "
|
|
|
|
"in GIMP. See help for more info.",
|
|
|
|
name);
|
|
|
|
gimp_procedure_set_attribution (procedure,
|
|
|
|
"Daniel Dunbar",
|
|
|
|
"Daniel Dunbar",
|
|
|
|
"1998");
|
|
|
|
|
|
|
|
gimp_file_procedure_set_handles_remote (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
TRUE);
|
|
|
|
gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"text/html");
|
|
|
|
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"html,htm");
|
|
|
|
}
|
|
|
|
|
|
|
|
return procedure;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpValueArray *
|
|
|
|
html_save (GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GFile *file,
|
|
|
|
const GimpValueArray *args,
|
|
|
|
gpointer run_data)
|
1998-02-22 06:14:06 +08:00
|
|
|
{
|
2001-12-29 21:26:29 +08:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
2019-08-24 19:53:16 +08:00
|
|
|
GeglBuffer *buffer;
|
2008-08-20 22:00:44 +08:00
|
|
|
GError *error = NULL;
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
2012-11-20 02:34:33 +08:00
|
|
|
gegl_init (NULL, NULL);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_get_data (SAVE_PROC, >mvals);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
if (! save_dialog (image))
|
|
|
|
return gimp_procedure_new_return_values (procedure,
|
|
|
|
GIMP_PDB_CANCEL,
|
|
|
|
NULL);
|
2012-11-20 02:34:33 +08:00
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
buffer = gimp_drawable_get_buffer (drawable);
|
2012-11-20 02:34:33 +08:00
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
if (save_image (file, buffer,
|
|
|
|
&error))
|
|
|
|
{
|
|
|
|
gimp_set_data (SAVE_PROC, >mvals, sizeof (GTMValues));
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-24 19:53:16 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
g_object_unref (buffer);
|
2008-08-20 22:00:44 +08:00
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
return gimp_procedure_new_return_values (procedure, status, error);
|
1998-02-22 06:14:06 +08:00
|
|
|
}
|
|
|
|
|
2003-06-13 22:37:00 +08:00
|
|
|
static gboolean
|
2014-10-05 22:59:16 +08:00
|
|
|
save_image (GFile *file,
|
|
|
|
GeglBuffer *buffer,
|
|
|
|
GError **error)
|
1998-02-22 06:14:06 +08:00
|
|
|
{
|
2014-10-05 22:59:16 +08:00
|
|
|
const Babl *format = babl_format ("R'G'B'A u8");
|
2018-05-14 07:27:03 +08:00
|
|
|
GeglSampler *sampler;
|
2018-11-27 19:27:20 +08:00
|
|
|
GCancellable *cancellable;
|
2014-10-05 22:59:16 +08:00
|
|
|
GOutputStream *output;
|
|
|
|
gint row, col;
|
|
|
|
gint cols, rows;
|
|
|
|
gint x, y;
|
|
|
|
gint colcount, colspan, rowspan;
|
|
|
|
gint *palloc;
|
|
|
|
guchar *buf, *buf2;
|
|
|
|
gchar *width = NULL;
|
|
|
|
gchar *height = NULL;
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2012-11-20 02:34:33 +08:00
|
|
|
cols = gegl_buffer_get_width (buffer);
|
|
|
|
rows = gegl_buffer_get_height (buffer);
|
|
|
|
|
2016-02-16 09:35:43 +08:00
|
|
|
gimp_progress_init_printf (_("Exporting '%s'"),
|
2014-10-05 22:59:16 +08:00
|
|
|
gimp_file_get_utf8_name (file));
|
2014-07-23 22:39:00 +08:00
|
|
|
|
2014-10-05 22:59:16 +08:00
|
|
|
output = G_OUTPUT_STREAM (g_file_replace (file,
|
|
|
|
NULL, FALSE, G_FILE_CREATE_NONE,
|
|
|
|
NULL, error));
|
|
|
|
if (output)
|
|
|
|
{
|
|
|
|
GOutputStream *buffered;
|
|
|
|
|
|
|
|
buffered = g_buffered_output_stream_new (output);
|
|
|
|
g_object_unref (output);
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2014-10-05 22:59:16 +08:00
|
|
|
output = buffered;
|
|
|
|
}
|
|
|
|
else
|
2003-06-13 22:37:00 +08:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-05-14 07:27:03 +08:00
|
|
|
sampler = gegl_buffer_sampler_new (buffer, format, GEGL_SAMPLER_NEAREST);
|
|
|
|
|
2012-11-28 03:58:05 +08:00
|
|
|
palloc = g_new (int, rows * cols);
|
|
|
|
|
2003-06-13 22:37:00 +08:00
|
|
|
if (gtmvals.fulldoc)
|
|
|
|
{
|
2014-10-05 22:59:16 +08:00
|
|
|
if (! print (output, error,
|
|
|
|
"<HTML>\n<HEAD><TITLE>%s</TITLE></HEAD>\n<BODY>\n",
|
|
|
|
gimp_file_get_utf8_name (file)) ||
|
|
|
|
! print (output, error, "<H1>%s</H1>\n",
|
|
|
|
gimp_file_get_utf8_name (file)))
|
|
|
|
{
|
|
|
|
goto fail;
|
|
|
|
}
|
2003-06-13 22:37:00 +08:00
|
|
|
}
|
|
|
|
|
2014-10-05 22:59:16 +08:00
|
|
|
if (! print (output, error,
|
|
|
|
"<TABLE BORDER=%d CELLPADDING=%d CELLSPACING=%d>\n",
|
|
|
|
gtmvals.border, gtmvals.cellpadding, gtmvals.cellspacing))
|
|
|
|
goto fail;
|
2003-06-13 22:37:00 +08:00
|
|
|
|
1998-02-22 06:14:06 +08:00
|
|
|
if (gtmvals.caption)
|
2014-10-05 22:59:16 +08:00
|
|
|
{
|
|
|
|
if (! print (output, error, "<CAPTION>%s</CAPTION>\n",
|
|
|
|
gtmvals.captiontxt))
|
|
|
|
goto fail;
|
|
|
|
}
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2013-01-19 12:10:32 +08:00
|
|
|
buf = g_newa (guchar, babl_format_get_bytes_per_pixel (format));
|
|
|
|
buf2 = g_newa (guchar, babl_format_get_bytes_per_pixel (format));
|
2003-06-13 22:37:00 +08:00
|
|
|
|
|
|
|
if (strcmp (gtmvals.clwidth, "") != 0)
|
|
|
|
{
|
2007-05-31 01:37:42 +08:00
|
|
|
width = g_strdup_printf (" WIDTH=\"%s\"", gtmvals.clwidth);
|
2003-06-13 22:37:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp (gtmvals.clheight, "") != 0)
|
|
|
|
{
|
2007-05-31 01:37:42 +08:00
|
|
|
height = g_strdup_printf (" HEIGHT=\"%s\" ", gtmvals.clheight);
|
2003-06-13 22:37:00 +08:00
|
|
|
}
|
2008-05-10 18:42:18 +08:00
|
|
|
|
2007-05-31 01:37:42 +08:00
|
|
|
if (! width)
|
|
|
|
width = g_strdup (" ");
|
2008-05-10 18:42:18 +08:00
|
|
|
|
2007-05-31 01:37:42 +08:00
|
|
|
if (! height)
|
|
|
|
height = g_strdup (" ");
|
2003-06-13 22:37:00 +08:00
|
|
|
|
|
|
|
/* Initialize array to hold ROWSPAN and COLSPAN cell allocation table */
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2003-06-13 22:37:00 +08:00
|
|
|
for (row = 0; row < rows; row++)
|
|
|
|
for (col = 0; col < cols; col++)
|
2012-11-20 02:34:33 +08:00
|
|
|
palloc[cols * row + col] = 1;
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2003-06-13 22:37:00 +08:00
|
|
|
colspan = 0;
|
|
|
|
rowspan = 0;
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2003-06-13 22:37:00 +08:00
|
|
|
for (y = 0; y < rows; y++)
|
|
|
|
{
|
2014-10-05 22:59:16 +08:00
|
|
|
if (! print (output, error, " <TR>\n"))
|
|
|
|
goto fail;
|
2003-06-13 22:37:00 +08:00
|
|
|
|
|
|
|
for (x = 0; x < cols; x++)
|
|
|
|
{
|
2018-05-14 07:27:03 +08:00
|
|
|
gegl_sampler_get (sampler, x, y, NULL, buf, GEGL_ABYSS_NONE);
|
2003-06-13 22:37:00 +08:00
|
|
|
|
|
|
|
/* Determine ROWSPAN and COLSPAN */
|
|
|
|
|
|
|
|
if (gtmvals.spantags)
|
|
|
|
{
|
|
|
|
col = x;
|
|
|
|
row = y;
|
|
|
|
colcount = 0;
|
|
|
|
colspan = 0;
|
|
|
|
rowspan = 0;
|
|
|
|
|
2018-05-14 07:27:03 +08:00
|
|
|
gegl_sampler_get (sampler, col, row, NULL, buf2, GEGL_ABYSS_NONE);
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2012-11-20 02:34:33 +08:00
|
|
|
while (color_comp (buf, buf2) &&
|
|
|
|
palloc[cols * row + col] == 1 &&
|
|
|
|
row < rows)
|
2003-06-13 22:37:00 +08:00
|
|
|
{
|
2012-11-20 02:34:33 +08:00
|
|
|
while (color_comp (buf, buf2) &&
|
|
|
|
palloc[cols * row + col] == 1 &&
|
|
|
|
col < cols)
|
2003-06-13 22:37:00 +08:00
|
|
|
{
|
|
|
|
colcount++;
|
|
|
|
col++;
|
|
|
|
|
2018-05-14 07:27:03 +08:00
|
|
|
gegl_sampler_get (sampler,
|
|
|
|
col, row, NULL, buf2, GEGL_ABYSS_NONE);
|
2003-06-13 22:37:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (colcount != 0)
|
|
|
|
{
|
|
|
|
row++;
|
|
|
|
rowspan++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (colcount < colspan || colspan == 0)
|
|
|
|
colspan = colcount;
|
|
|
|
|
|
|
|
col = x;
|
|
|
|
colcount = 0;
|
|
|
|
|
2018-05-14 07:27:03 +08:00
|
|
|
gegl_sampler_get (sampler,
|
|
|
|
col, row, NULL, buf2, GEGL_ABYSS_NONE);
|
2003-06-13 22:37:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (colspan > 1 || rowspan > 1)
|
|
|
|
{
|
|
|
|
for (row = 0; row < rowspan; row++)
|
|
|
|
for (col = 0; col < colspan; col++)
|
2012-11-20 02:34:33 +08:00
|
|
|
palloc[cols * (row + y) + (col + x)] = 0;
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2012-11-20 02:34:33 +08:00
|
|
|
palloc[cols * y + x] = 2;
|
2003-06-13 22:37:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-20 02:34:33 +08:00
|
|
|
if (palloc[cols * y + x] == 1)
|
2014-10-05 22:59:16 +08:00
|
|
|
{
|
|
|
|
if (! print (output, error,
|
|
|
|
" <TD%s%sBGCOLOR=#%02x%02x%02x>",
|
|
|
|
width, height, buf[0], buf[1], buf[2]))
|
|
|
|
goto fail;
|
|
|
|
}
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2012-11-20 02:34:33 +08:00
|
|
|
if (palloc[cols * y + x] == 2)
|
2014-10-05 22:59:16 +08:00
|
|
|
{
|
|
|
|
if (! print (output, error,
|
|
|
|
" <TD ROWSPAN=\"%d\" COLSPAN=\"%d\"%s%sBGCOLOR=#%02x%02x%02x>",
|
|
|
|
rowspan, colspan, width, height,
|
|
|
|
buf[0], buf[1], buf[2]))
|
|
|
|
goto fail;
|
|
|
|
}
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2012-11-20 02:34:33 +08:00
|
|
|
if (palloc[cols * y + x] != 0)
|
2003-06-13 22:37:00 +08:00
|
|
|
{
|
|
|
|
if (gtmvals.tdcomp)
|
2014-10-05 22:59:16 +08:00
|
|
|
{
|
|
|
|
if (! print (output, error,
|
|
|
|
"%s</TD>\n", gtmvals.cellcontent))
|
|
|
|
goto fail;
|
|
|
|
}
|
2003-06-13 22:37:00 +08:00
|
|
|
else
|
2014-10-05 22:59:16 +08:00
|
|
|
{
|
|
|
|
if (! print (output, error,
|
|
|
|
"\n %s\n </TD>\n", gtmvals.cellcontent))
|
|
|
|
goto fail;
|
|
|
|
}
|
2003-06-13 22:37:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-05 22:59:16 +08:00
|
|
|
if (! print (output, error, " </TR>\n"))
|
|
|
|
goto fail;
|
2003-06-13 22:37:00 +08:00
|
|
|
|
|
|
|
gimp_progress_update ((double) y / (double) rows);
|
1998-02-22 06:14:06 +08:00
|
|
|
}
|
2012-11-20 02:34:33 +08:00
|
|
|
|
1998-02-22 06:14:06 +08:00
|
|
|
if (gtmvals.fulldoc)
|
2014-10-05 22:59:16 +08:00
|
|
|
{
|
|
|
|
if (! print (output, error, "</TABLE></BODY></HTML>\n"))
|
|
|
|
goto fail;
|
|
|
|
}
|
2003-06-13 22:37:00 +08:00
|
|
|
else
|
2014-10-05 22:59:16 +08:00
|
|
|
{
|
|
|
|
if (! print (output, error, "</TABLE>\n"))
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! g_output_stream_close (output, NULL, error))
|
|
|
|
goto fail;
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2014-10-05 22:59:16 +08:00
|
|
|
g_object_unref (output);
|
2018-05-14 07:27:03 +08:00
|
|
|
g_object_unref (sampler);
|
2003-06-13 22:37:00 +08:00
|
|
|
g_free (width);
|
|
|
|
g_free (height);
|
|
|
|
g_free (palloc);
|
1998-03-09 09:45:26 +08:00
|
|
|
|
2014-10-05 22:59:16 +08:00
|
|
|
gimp_progress_update (1.0);
|
|
|
|
|
2003-06-13 22:37:00 +08:00
|
|
|
return TRUE;
|
2014-10-05 22:59:16 +08:00
|
|
|
|
|
|
|
fail:
|
|
|
|
|
2018-11-27 19:27:20 +08:00
|
|
|
cancellable = g_cancellable_new ();
|
|
|
|
g_cancellable_cancel (cancellable);
|
|
|
|
g_output_stream_close (output, cancellable, NULL);
|
|
|
|
g_object_unref (cancellable);
|
|
|
|
|
2014-10-05 22:59:16 +08:00
|
|
|
g_object_unref (output);
|
2018-05-14 07:27:03 +08:00
|
|
|
g_object_unref (sampler);
|
2014-10-05 22:59:16 +08:00
|
|
|
g_free (width);
|
|
|
|
g_free (height);
|
|
|
|
g_free (palloc);
|
|
|
|
|
|
|
|
return FALSE;
|
1998-02-22 06:14:06 +08:00
|
|
|
}
|
|
|
|
|
2000-01-07 06:26:10 +08:00
|
|
|
static gint
|
2019-08-24 19:53:16 +08:00
|
|
|
save_dialog (GimpImage *image)
|
1998-02-22 06:14:06 +08:00
|
|
|
{
|
2014-06-23 05:01:31 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *vbox;
|
2018-05-11 17:29:40 +08:00
|
|
|
GtkWidget *grid;
|
2014-06-23 05:01:31 +08:00
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkAdjustment *adj;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *toggle;
|
|
|
|
gboolean run;
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2019-09-21 01:39:00 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2009-07-21 20:10:29 +08:00
|
|
|
dialog = gimp_export_dialog_new (_("HTML table"), PLUG_IN_BINARY, SAVE_PROC);
|
2005-09-10 02:38:00 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2004-05-19 23:28:01 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
2009-07-21 20:10:29 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gimp_export_dialog_get_content_area (dialog)),
|
2009-07-16 00:57:12 +08:00
|
|
|
main_vbox, TRUE, TRUE, 0);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2019-08-24 19:53:16 +08:00
|
|
|
if (gimp_image_width (image) * gimp_image_height (image) > 4096)
|
2000-02-23 08:15:12 +08:00
|
|
|
{
|
|
|
|
GtkWidget *eek;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
|
2004-05-19 23:28:01 +08:00
|
|
|
frame = gimp_frame_new (_("Warning"));
|
2000-02-23 08:15:12 +08:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
2000-02-23 08:15:12 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
eek = gtk_image_new_from_icon_name (GIMP_ICON_WILBER_EEK,
|
2014-05-12 06:20:48 +08:00
|
|
|
GTK_ICON_SIZE_DIALOG);
|
2004-05-19 23:28:01 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), eek, FALSE, FALSE, 0);
|
2000-02-23 08:15:12 +08:00
|
|
|
|
2003-11-18 02:02:45 +08:00
|
|
|
label = gtk_label_new (_("You are about to create a huge\n"
|
2008-10-20 14:04:39 +08:00
|
|
|
"HTML file which will most likely\n"
|
|
|
|
"crash your browser."));
|
2000-02-23 08:15:12 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
gtk_widget_show_all (frame);
|
|
|
|
}
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
/* HTML Page Options */
|
2004-05-19 23:28:01 +08:00
|
|
|
frame = gimp_frame_new (_("HTML Page Options"));
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2004-05-28 03:00:49 +08:00
|
|
|
toggle = gtk_check_button_new_with_mnemonic (_("_Generate full HTML document"));
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), gtmvals.fulldoc);
|
1998-02-22 06:14:06 +08:00
|
|
|
gtk_widget_show (toggle);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-07 06:26:10 +08:00
|
|
|
gimp_help_set_help_data (toggle,
|
2008-10-20 14:04:39 +08:00
|
|
|
_("If checked GTM will output a full HTML document "
|
|
|
|
"with <HTML>, <BODY>, etc. tags instead of just "
|
|
|
|
"the table html."),
|
|
|
|
NULL);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
>mvals.fulldoc);
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_widget_show (main_vbox);
|
1998-02-22 06:14:06 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
/* HTML Table Creation Options */
|
2004-05-19 23:28:01 +08:00
|
|
|
frame = gimp_frame_new (_("Table Creation Options"));
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2018-05-11 17:29:40 +08:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), grid);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2004-05-28 03:00:49 +08:00
|
|
|
toggle = gtk_check_button_new_with_mnemonic (_("_Use cellspan"));
|
2018-05-11 17:29:40 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), toggle, 0, 0, 2, 1);
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), gtmvals.spantags);
|
1998-02-22 06:14:06 +08:00
|
|
|
gtk_widget_show (toggle);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-07 06:26:10 +08:00
|
|
|
gimp_help_set_help_data (toggle,
|
2008-10-20 14:04:39 +08:00
|
|
|
_("If checked GTM will replace any rectangular "
|
|
|
|
"sections of identically colored blocks with one "
|
|
|
|
"large cell with ROWSPAN and COLSPAN values."),
|
|
|
|
NULL);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
>mvals.spantags);
|
|
|
|
|
2003-01-19 22:40:56 +08:00
|
|
|
toggle = gtk_check_button_new_with_mnemonic (_("Co_mpress TD tags"));
|
2018-05-11 17:29:40 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), toggle, 0, 1, 2, 1);
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), gtmvals.tdcomp);
|
1998-02-22 06:14:06 +08:00
|
|
|
gtk_widget_show (toggle);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-07 06:26:10 +08:00
|
|
|
gimp_help_set_help_data (toggle,
|
2008-10-20 14:04:39 +08:00
|
|
|
_("Checking this tag will cause GTM to leave no "
|
|
|
|
"whitespace between the TD tags and the "
|
|
|
|
"cellcontent. This is only necessary for pixel "
|
|
|
|
"level positioning control."),
|
|
|
|
NULL);
|
2000-01-07 06:26:10 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
>mvals.tdcomp);
|
|
|
|
|
2003-01-19 22:40:56 +08:00
|
|
|
toggle = gtk_check_button_new_with_mnemonic (_("C_aption"));
|
2018-05-11 17:29:40 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), toggle, 0, 2, 1, 1);
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), gtmvals.caption);
|
1998-02-22 06:14:06 +08:00
|
|
|
gtk_widget_show (toggle);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-07 06:26:10 +08:00
|
|
|
gimp_help_set_help_data (toggle,
|
2008-10-20 14:04:39 +08:00
|
|
|
_("Check if you would like to have the table "
|
|
|
|
"captioned."),
|
|
|
|
NULL);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
>mvals.caption);
|
|
|
|
|
1998-02-22 06:14:06 +08:00
|
|
|
entry = gtk_entry_new ();
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_widget_set_size_request (entry, 200, -1);
|
1998-02-22 06:14:06 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), gtmvals.captiontxt);
|
2018-05-11 17:29:40 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), entry, 1, 2, 1, 1);
|
1998-02-22 06:14:06 +08:00
|
|
|
gtk_widget_show (entry);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-07 06:26:10 +08:00
|
|
|
gimp_help_set_help_data (entry, _("The text for the table caption."), NULL);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (entry, "changed",
|
2014-10-05 22:42:31 +08:00
|
|
|
G_CALLBACK (entry_changed_callback),
|
|
|
|
gtmvals.captiontxt);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2011-05-11 17:41:26 +08:00
|
|
|
g_object_bind_property (toggle, "active",
|
|
|
|
entry, "sensitive",
|
|
|
|
G_BINDING_SYNC_CREATE);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
|
|
|
entry = gtk_entry_new ();
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_widget_set_size_request (entry, 200, -1);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), gtmvals.cellcontent);
|
2018-05-11 17:29:40 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 3,
|
|
|
|
_("C_ell content:"), 0.0, 0.5,
|
|
|
|
entry, 1);
|
1998-02-22 06:14:06 +08:00
|
|
|
gtk_widget_show (entry);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-07 06:26:10 +08:00
|
|
|
gimp_help_set_help_data (entry, _("The text to go into each cell."), NULL);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (entry, "changed",
|
2014-10-05 22:42:31 +08:00
|
|
|
G_CALLBACK (entry_changed_callback),
|
|
|
|
gtmvals.cellcontent);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2018-05-11 17:29:40 +08:00
|
|
|
gtk_widget_show (grid);
|
1998-02-22 06:14:06 +08:00
|
|
|
gtk_widget_show (frame);
|
2000-01-07 06:26:10 +08:00
|
|
|
|
1998-02-22 06:14:06 +08:00
|
|
|
/* HTML Table Options */
|
2004-05-19 23:28:01 +08:00
|
|
|
frame = gimp_frame_new (_("Table Options"));
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2018-05-11 17:29:40 +08:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), grid);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2018-06-25 00:15:16 +08:00
|
|
|
adj = gtk_adjustment_new (gtmvals.border, 0, 1000, 1, 10, 0);
|
2019-03-09 20:25:19 +08:00
|
|
|
spinbutton = gimp_spin_button_new (adj, 1.0, 0);
|
2014-06-23 05:01:31 +08:00
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2018-05-11 17:29:40 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 0,
|
|
|
|
_("_Border:"), 0.0, 0.5,
|
|
|
|
spinbutton, 1);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
gimp_help_set_help_data (spinbutton,
|
2008-10-20 14:04:39 +08:00
|
|
|
_("The number of pixels in the table border."),
|
|
|
|
NULL);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (adj, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_int_adjustment_update),
|
|
|
|
>mvals.border);
|
|
|
|
|
1998-02-22 06:14:06 +08:00
|
|
|
entry = gtk_entry_new ();
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_widget_set_size_request (entry, 60, -1);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), gtmvals.clwidth);
|
2018-05-11 17:29:40 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1,
|
|
|
|
_("_Width:"), 0.0, 0.5,
|
|
|
|
entry, 1);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-07 06:26:10 +08:00
|
|
|
gimp_help_set_help_data (entry,
|
2008-10-20 14:04:39 +08:00
|
|
|
_("The width for each table cell. "
|
|
|
|
"Can be a number or a percent."),
|
|
|
|
NULL);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (entry, "changed",
|
2014-10-05 22:42:31 +08:00
|
|
|
G_CALLBACK (entry_changed_callback),
|
|
|
|
gtmvals.clwidth);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
1998-02-22 06:14:06 +08:00
|
|
|
entry = gtk_entry_new ();
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_widget_set_size_request (entry, 60, -1);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), gtmvals.clheight);
|
2018-05-11 17:29:40 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 2,
|
|
|
|
_("_Height:"), 0.0, 0.5,
|
|
|
|
entry, 1);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-07 06:26:10 +08:00
|
|
|
gimp_help_set_help_data (entry,
|
2008-10-20 14:04:39 +08:00
|
|
|
_("The height for each table cell. "
|
|
|
|
"Can be a number or a percent."),
|
|
|
|
NULL);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (entry, "changed",
|
2014-10-05 22:42:31 +08:00
|
|
|
G_CALLBACK (entry_changed_callback),
|
|
|
|
gtmvals.clheight);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2018-06-25 00:15:16 +08:00
|
|
|
adj = gtk_adjustment_new (gtmvals.cellpadding, 0, 1000, 1, 10, 0);
|
2019-03-09 20:25:19 +08:00
|
|
|
spinbutton = gimp_spin_button_new (adj, 1.0, 0);
|
2014-06-23 05:01:31 +08:00
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2018-05-11 17:29:40 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 3,
|
|
|
|
_("Cell-_padding:"), 0.0, 0.5,
|
|
|
|
spinbutton, 1);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
gimp_help_set_help_data (spinbutton,
|
2011-08-27 20:49:19 +08:00
|
|
|
_("The amount of cell padding."), NULL);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (adj, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_int_adjustment_update),
|
|
|
|
>mvals.cellpadding);
|
|
|
|
|
2018-06-25 00:15:16 +08:00
|
|
|
adj = gtk_adjustment_new (gtmvals.cellspacing, 0, 1000, 1, 10, 0);
|
2019-03-09 20:25:19 +08:00
|
|
|
spinbutton = gimp_spin_button_new (adj, 1.0, 0);
|
2014-06-23 05:01:31 +08:00
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2018-05-11 17:29:40 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 4,
|
|
|
|
_("Cell-_spacing:"), 0.0, 0.5,
|
|
|
|
spinbutton, 1);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
gimp_help_set_help_data (spinbutton,
|
2011-08-27 20:49:19 +08:00
|
|
|
_("The amount of cell spacing."), NULL);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (adj, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_int_adjustment_update),
|
|
|
|
>mvals.cellspacing);
|
|
|
|
|
2018-05-11 17:29:40 +08:00
|
|
|
gtk_widget_show (grid);
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2005-09-10 02:38:00 +08:00
|
|
|
gtk_widget_show (dialog);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2005-09-10 02:38:00 +08:00
|
|
|
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2005-09-10 02:38:00 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
return run;
|
1998-02-22 06:14:06 +08:00
|
|
|
}
|
|
|
|
|
2014-10-05 22:59:16 +08:00
|
|
|
static gboolean
|
|
|
|
print (GOutputStream *output,
|
|
|
|
GError **error,
|
|
|
|
const gchar *format,
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
gboolean success;
|
|
|
|
|
|
|
|
va_start (args, format);
|
|
|
|
success = g_output_stream_vprintf (output, NULL, NULL,
|
|
|
|
error, format, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2003-01-19 22:40:56 +08:00
|
|
|
static gboolean
|
2012-11-20 02:34:33 +08:00
|
|
|
color_comp (guchar *buf,
|
2008-10-20 14:04:39 +08:00
|
|
|
guchar *buf2)
|
2000-01-07 06:26:10 +08:00
|
|
|
{
|
2012-11-20 02:34:33 +08:00
|
|
|
return (buf[0] == buf2[0] &&
|
|
|
|
buf[1] == buf2[1] &&
|
|
|
|
buf[2] == buf2[2]);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2016-02-16 09:35:43 +08:00
|
|
|
/* Export interface functions */
|
1998-02-22 06:14:06 +08:00
|
|
|
|
2000-01-07 06:26:10 +08:00
|
|
|
static void
|
2014-10-05 22:42:31 +08:00
|
|
|
entry_changed_callback (GtkEntry *entry,
|
|
|
|
gchar *string)
|
1998-02-22 06:14:06 +08:00
|
|
|
{
|
2019-08-15 05:52:38 +08:00
|
|
|
g_strlcpy (string, gtk_entry_get_text (entry), 256);
|
1998-02-22 06:14:06 +08:00
|
|
|
}
|