1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
|
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GTM plug-in --- GIMP Table Magic
* Allows images to be exported as HTML tables with different colored cells.
* 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/
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
/* 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
* on using once just to see how it worked, and then posting a URL and
* 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.
*
* It's still not very useful, but I did manage to significantly improve my
* C programming skills in the process, so it was worth it.
*
* If you happen to find it useful I would appreciate any email about it.
* - Daniel Dunbar
* ddunbar@diads.com
*/
#include "config.h"
#include <string.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "libgimp/stdplugins-intl.h"
#define SAVE_PROC "file-gtm-save"
#define PLUG_IN_BINARY "file-html-table"
#define PLUG_IN_ROLE "gimp-file-html-table"
/* Typedefs */
typedef struct
{
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;
} GTMValues;
/* Declare some local functions */
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static gboolean save_image (GFile *file,
GeglBuffer *buffer,
GError **error);
static gboolean save_dialog (gint32 image_ID);
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);
/* Variables */
static GTMValues gtmvals =
{
"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 */
};
const GimpPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
};
MAIN ()
static void
query (void)
{
static const GimpParamDef save_args[] =
{
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0) }" },
{ GIMP_PDB_IMAGE, "image", "Input image" },
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to export" },
{ GIMP_PDB_STRING, "filename", "The name of the file to export the image in" },
{ GIMP_PDB_STRING, "raw-filename", "The name of the file to export the image in" }
};
gimp_install_procedure (SAVE_PROC,
"GIMP Table Magic",
"Allows you to draw an HTML table in GIMP. See help for more info.",
"Daniel Dunbar",
"Daniel Dunbar",
"1998",
_("HTML table"),
"RGB*, GRAY*, INDEXED*",
GIMP_PLUGIN,
G_N_ELEMENTS (save_args), 0,
save_args, NULL);
gimp_register_file_handler_mime (SAVE_PROC, "text/html");
gimp_register_file_handler_uri (SAVE_PROC);
gimp_register_save_handler (SAVE_PROC, "html,htm", "");
}
static void
run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[2];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
gimp_get_data (SAVE_PROC, >mvals);
if (save_dialog (param[1].data.d_int32))
{
GeglBuffer *buffer = gimp_drawable_get_buffer (param[2].data.d_int32);
if (save_image (g_file_new_for_uri (param[3].data.d_string),
buffer, &error))
{
gimp_set_data (SAVE_PROC, >mvals, sizeof (GTMValues));
}
else
{
status = GIMP_PDB_EXECUTION_ERROR;
}
g_object_unref (buffer);
}
else
{
status = GIMP_PDB_CANCEL;
}
if (status != GIMP_PDB_SUCCESS && error)
{
*nreturn_vals = 2;
values[1].type = GIMP_PDB_STRING;
values[1].data.d_string = error->message;
}
values[0].data.d_status = status;
}
static gboolean
save_image (GFile *file,
GeglBuffer *buffer,
GError **error)
{
const Babl *format = babl_format ("R'G'B'A u8");
GeglSampler *sampler;
GCancellable *cancellable;
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;
cols = gegl_buffer_get_width (buffer);
rows = gegl_buffer_get_height (buffer);
gimp_progress_init_printf (_("Exporting '%s'"),
gimp_file_get_utf8_name (file));
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);
output = buffered;
}
else
{
return FALSE;
}
sampler = gegl_buffer_sampler_new (buffer, format, GEGL_SAMPLER_NEAREST);
palloc = g_new (int, rows * cols);
if (gtmvals.fulldoc)
{
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;
}
}
if (! print (output, error,
"<TABLE BORDER=%d CELLPADDING=%d CELLSPACING=%d>\n",
gtmvals.border, gtmvals.cellpadding, gtmvals.cellspacing))
goto fail;
if (gtmvals.caption)
{
if (! print (output, error, "<CAPTION>%s</CAPTION>\n",
gtmvals.captiontxt))
goto fail;
}
buf = g_newa (guchar, babl_format_get_bytes_per_pixel (format));
buf2 = g_newa (guchar, babl_format_get_bytes_per_pixel (format));
if (strcmp (gtmvals.clwidth, "") != 0)
{
width = g_strdup_printf (" WIDTH=\"%s\"", gtmvals.clwidth);
}
if (strcmp (gtmvals.clheight, "") != 0)
{
height = g_strdup_printf (" HEIGHT=\"%s\" ", gtmvals.clheight);
}
if (! width)
width = g_strdup (" ");
if (! height)
height = g_strdup (" ");
/* Initialize array to hold ROWSPAN and COLSPAN cell allocation table */
for (row = 0; row < rows; row++)
for (col = 0; col < cols; col++)
palloc[cols * row + col] = 1;
colspan = 0;
rowspan = 0;
for (y = 0; y < rows; y++)
{
if (! print (output, error, " <TR>\n"))
goto fail;
for (x = 0; x < cols; x++)
{
gegl_sampler_get (sampler, x, y, NULL, buf, GEGL_ABYSS_NONE);
/* Determine ROWSPAN and COLSPAN */
if (gtmvals.spantags)
{
col = x;
row = y;
colcount = 0;
colspan = 0;
rowspan = 0;
gegl_sampler_get (sampler, col, row, NULL, buf2, GEGL_ABYSS_NONE);
while (color_comp (buf, buf2) &&
palloc[cols * row + col] == 1 &&
row < rows)
{
while (color_comp (buf, buf2) &&
palloc[cols * row + col] == 1 &&
col < cols)
{
colcount++;
col++;
gegl_sampler_get (sampler,
col, row, NULL, buf2, GEGL_ABYSS_NONE);
}
if (colcount != 0)
{
row++;
rowspan++;
}
if (colcount < colspan || colspan == 0)
colspan = colcount;
col = x;
colcount = 0;
gegl_sampler_get (sampler,
col, row, NULL, buf2, GEGL_ABYSS_NONE);
}
if (colspan > 1 || rowspan > 1)
{
for (row = 0; row < rowspan; row++)
for (col = 0; col < colspan; col++)
palloc[cols * (row + y) + (col + x)] = 0;
palloc[cols * y + x] = 2;
}
}
if (palloc[cols * y + x] == 1)
{
if (! print (output, error,
" <TD%s%sBGCOLOR=#%02x%02x%02x>",
width, height, buf[0], buf[1], buf[2]))
goto fail;
}
if (palloc[cols * y + x] == 2)
{
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;
}
if (palloc[cols * y + x] != 0)
{
if (gtmvals.tdcomp)
{
if (! print (output, error,
"%s</TD>\n", gtmvals.cellcontent))
goto fail;
}
else
{
if (! print (output, error,
"\n %s\n </TD>\n", gtmvals.cellcontent))
goto fail;
}
}
}
if (! print (output, error, " </TR>\n"))
goto fail;
gimp_progress_update ((double) y / (double) rows);
}
if (gtmvals.fulldoc)
{
if (! print (output, error, "</TABLE></BODY></HTML>\n"))
goto fail;
}
else
{
if (! print (output, error, "</TABLE>\n"))
goto fail;
}
if (! g_output_stream_close (output, NULL, error))
goto fail;
g_object_unref (output);
g_object_unref (sampler);
g_free (width);
g_free (height);
g_free (palloc);
gimp_progress_update (1.0);
return TRUE;
fail:
cancellable = g_cancellable_new ();
g_cancellable_cancel (cancellable);
g_output_stream_close (output, cancellable, NULL);
g_object_unref (cancellable);
g_object_unref (output);
g_object_unref (sampler);
g_free (width);
g_free (height);
g_free (palloc);
return FALSE;
}
static gint
save_dialog (gint32 image_ID)
{
GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *frame;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *spinbutton;
GtkAdjustment *adj;
GtkWidget *entry;
GtkWidget *toggle;
gboolean run;
gimp_ui_init (PLUG_IN_BINARY, FALSE);
dialog = gimp_export_dialog_new (_("HTML table"), PLUG_IN_BINARY, SAVE_PROC);
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
gtk_box_pack_start (GTK_BOX (gimp_export_dialog_get_content_area (dialog)),
main_vbox, TRUE, TRUE, 0);
if (gimp_image_width (image_ID) * gimp_image_height (image_ID) > 4096)
{
GtkWidget *eek;
GtkWidget *label;
GtkWidget *hbox;
frame = gimp_frame_new (_("Warning"));
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_container_add (GTK_CONTAINER (frame), hbox);
eek = gtk_image_new_from_icon_name (GIMP_ICON_WILBER_EEK,
GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox), eek, FALSE, FALSE, 0);
label = gtk_label_new (_("You are about to create a huge\n"
"HTML file which will most likely\n"
"crash your browser."));
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
gtk_widget_show_all (frame);
}
/* HTML Page Options */
frame = gimp_frame_new (_("HTML Page Options"));
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
toggle = gtk_check_button_new_with_mnemonic (_("_Generate full HTML document"));
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), gtmvals.fulldoc);
gtk_widget_show (toggle);
gimp_help_set_help_data (toggle,
_("If checked GTM will output a full HTML document "
"with <HTML>, <BODY>, etc. tags instead of just "
"the table html."),
NULL);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
>mvals.fulldoc);
gtk_widget_show (main_vbox);
gtk_widget_show (frame);
/* HTML Table Creation Options */
frame = gimp_frame_new (_("Table Creation Options"));
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
table = gtk_table_new (4, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_container_add (GTK_CONTAINER (frame), table);
toggle = gtk_check_button_new_with_mnemonic (_("_Use cellspan"));
gtk_table_attach (GTK_TABLE (table), toggle, 0, 2, 0, 1, GTK_FILL, 0, 0, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), gtmvals.spantags);
gtk_widget_show (toggle);
gimp_help_set_help_data (toggle,
_("If checked GTM will replace any rectangular "
"sections of identically colored blocks with one "
"large cell with ROWSPAN and COLSPAN values."),
NULL);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
>mvals.spantags);
toggle = gtk_check_button_new_with_mnemonic (_("Co_mpress TD tags"));
gtk_table_attach (GTK_TABLE (table), toggle, 0, 2, 1, 2, GTK_FILL, 0, 0, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), gtmvals.tdcomp);
gtk_widget_show (toggle);
gimp_help_set_help_data (toggle,
_("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);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
>mvals.tdcomp);
toggle = gtk_check_button_new_with_mnemonic (_("C_aption"));
gtk_table_attach (GTK_TABLE (table), toggle, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), gtmvals.caption);
gtk_widget_show (toggle);
gimp_help_set_help_data (toggle,
_("Check if you would like to have the table "
"captioned."),
NULL);
g_signal_connect (toggle, "toggled",
G_CALLBACK (gimp_toggle_button_update),
>mvals.caption);
entry = gtk_entry_new ();
gtk_widget_set_size_request (entry, 200, -1);
gtk_entry_set_text (GTK_ENTRY (entry), gtmvals.captiontxt);
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3,
GTK_FILL | GTK_EXPAND, 0, 0, 0);
gtk_widget_show (entry);
gimp_help_set_help_data (entry, _("The text for the table caption."), NULL);
g_signal_connect (entry, "changed",
G_CALLBACK (entry_changed_callback),
gtmvals.captiontxt);
g_object_bind_property (toggle, "active",
entry, "sensitive",
G_BINDING_SYNC_CREATE);
entry = gtk_entry_new ();
gtk_widget_set_size_request (entry, 200, -1);
gtk_entry_set_text (GTK_ENTRY (entry), gtmvals.cellcontent);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
_("C_ell content:"), 0.0, 0.5,
entry, 1, FALSE);
gtk_widget_show (entry);
gimp_help_set_help_data (entry, _("The text to go into each cell."), NULL);
g_signal_connect (entry, "changed",
G_CALLBACK (entry_changed_callback),
gtmvals.cellcontent);
gtk_widget_show (table);
gtk_widget_show (frame);
/* HTML Table Options */
frame = gimp_frame_new (_("Table Options"));
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
table = gtk_table_new (5, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_container_add (GTK_CONTAINER (frame), table);
adj = (GtkAdjustment *) gtk_adjustment_new (gtmvals.border,
0, 1000, 1, 10, 0);
spinbutton = gimp_spin_button_new (adj, 1.0, 0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("_Border:"), 0.0, 0.5,
spinbutton, 1, TRUE);
gimp_help_set_help_data (spinbutton,
_("The number of pixels in the table border."),
NULL);
g_signal_connect (adj, "value-changed",
G_CALLBACK (gimp_int_adjustment_update),
>mvals.border);
entry = gtk_entry_new ();
gtk_widget_set_size_request (entry, 60, -1);
gtk_entry_set_text (GTK_ENTRY (entry), gtmvals.clwidth);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("_Width:"), 0.0, 0.5,
entry, 1, TRUE);
gimp_help_set_help_data (entry,
_("The width for each table cell. "
"Can be a number or a percent."),
NULL);
g_signal_connect (entry, "changed",
G_CALLBACK (entry_changed_callback),
gtmvals.clwidth);
entry = gtk_entry_new ();
gtk_widget_set_size_request (entry, 60, -1);
gtk_entry_set_text (GTK_ENTRY (entry), gtmvals.clheight);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
_("_Height:"), 0.0, 0.5,
entry, 1, TRUE);
gimp_help_set_help_data (entry,
_("The height for each table cell. "
"Can be a number or a percent."),
NULL);
g_signal_connect (entry, "changed",
G_CALLBACK (entry_changed_callback),
gtmvals.clheight);
adj = (GtkAdjustment *) gtk_adjustment_new (gtmvals.cellpadding,
0, 1000, 1, 10, 0);
spinbutton = gimp_spin_button_new (adj, 1.0, 0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
_("Cell-_padding:"), 0.0, 0.5,
spinbutton, 1, TRUE);
gimp_help_set_help_data (spinbutton,
_("The amount of cell padding."), NULL);
g_signal_connect (adj, "value-changed",
G_CALLBACK (gimp_int_adjustment_update),
>mvals.cellpadding);
adj = (GtkAdjustment *) gtk_adjustment_new (gtmvals.cellspacing,
0, 1000, 1, 10, 0);
spinbutton = gimp_spin_button_new (adj, 1.0, 0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
_("Cell-_spacing:"), 0.0, 0.5,
spinbutton, 1, TRUE);
gimp_help_set_help_data (spinbutton,
_("The amount of cell spacing."), NULL);
g_signal_connect (adj, "value-changed",
G_CALLBACK (gimp_int_adjustment_update),
>mvals.cellspacing);
gtk_widget_show (table);
gtk_widget_show (frame);
gtk_widget_show (dialog);
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
gtk_widget_destroy (dialog);
return run;
}
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;
}
static gboolean
color_comp (guchar *buf,
guchar *buf2)
{
return (buf[0] == buf2[0] &&
buf[1] == buf2[1] &&
buf[2] == buf2[2]);
}
/* Export interface functions */
static void
entry_changed_callback (GtkEntry *entry,
gchar *string)
{
strncpy (string, gtk_entry_get_text (entry), 255);
}
|