~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to plug-ins/common/gtm.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * GTM plug-in --- GIMP Table Magic
51
51
#include "config.h"
52
52
 
53
53
#include <errno.h>
54
 
#include <stdlib.h>
55
 
#include <stdio.h>
56
54
#include <string.h>
57
55
 
58
 
#include <gtk/gtk.h>
 
56
#include <glib/gstdio.h>
59
57
 
60
58
#include <libgimp/gimp.h>
61
59
#include <libgimp/gimpui.h>
63
61
#include "libgimp/stdplugins-intl.h"
64
62
 
65
63
 
 
64
#define SAVE_PROC      "file-gtm-save"
 
65
#define PLUG_IN_BINARY "gtm"
 
66
 
66
67
/* Typedefs */
67
68
 
68
69
typedef struct
122
123
                                        gpointer   data);
123
124
 
124
125
 
125
 
GimpPlugInInfo PLUG_IN_INFO =
 
126
const GimpPlugInInfo PLUG_IN_INFO =
126
127
{
127
128
  NULL,  /* init_proc  */
128
129
  NULL,  /* quit_proc  */
136
137
static void
137
138
query (void)
138
139
{
139
 
  static GimpParamDef save_args[] =
 
140
  static const GimpParamDef save_args[] =
140
141
  {
141
 
    { GIMP_PDB_INT32,    "run_mode",     "Interactive" },
 
142
    { GIMP_PDB_INT32,    "run-mode",     "Interactive" },
142
143
    { GIMP_PDB_IMAGE,    "image",        "Input image" },
143
144
    { GIMP_PDB_DRAWABLE, "drawable",     "Drawable to save" },
144
145
    { GIMP_PDB_STRING,   "filename",     "The name of the file to save the image in" },
145
 
    { GIMP_PDB_STRING,   "raw_filename", "The name of the file to save the image in" }
 
146
    { GIMP_PDB_STRING,   "raw-filename", "The name of the file to save the image in" }
146
147
  };
147
148
 
148
 
  gimp_install_procedure ("file_gtm_save",
 
149
  gimp_install_procedure (SAVE_PROC,
149
150
                          "GIMP Table Magic",
150
151
                          "Allows you to draw an HTML table in GIMP. See help for more info.",
151
152
                          "Daniel Dunbar",
157
158
                          G_N_ELEMENTS (save_args), 0,
158
159
                          save_args, NULL);
159
160
 
160
 
  gimp_register_file_handler_mime ("file_gtm_save", "text/html");
161
 
  gimp_register_save_handler ("file_gtm_save", "html,htm", "");
 
161
  gimp_register_file_handler_mime (SAVE_PROC, "text/html");
 
162
  gimp_register_save_handler (SAVE_PROC, "html,htm", "");
162
163
}
163
164
 
164
165
static void
182
183
  values[0].type          = GIMP_PDB_STATUS;
183
184
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
184
185
 
185
 
  gimp_get_data ("file_gtm_save", &gtmvals);
 
186
  gimp_get_data (SAVE_PROC, &gtmvals);
186
187
 
187
188
  if (save_dialog (param[1].data.d_int32))
188
189
    {
189
190
      if (save_image (param[3].data.d_string, drawable))
190
191
        {
191
 
          gimp_set_data ("file_gtm_save", &gtmvals, sizeof (GTMValues));
 
192
          gimp_set_data (SAVE_PROC, &gtmvals, sizeof (GTMValues));
192
193
        }
193
194
      else
194
195
        {
213
214
  guchar       *buffer, *buf2;
214
215
  gchar        *width, *height;
215
216
  GimpPixelRgn  pixel_rgn;
216
 
  gchar        *name;
217
217
  FILE         *fp;
218
218
 
219
219
  palloc = g_new (int, drawable->width * drawable->height);
220
220
 
221
 
  fp = fopen (filename, "w");
 
221
  fp = g_fopen (filename, "w");
222
222
 
223
223
  if (! fp)
224
224
    {
242
242
    fprintf (fp, "<CAPTION>%s</CAPTION>\n",
243
243
             gtmvals.captiontxt);
244
244
 
245
 
  name = g_strdup_printf (_("Saving '%s'..."),
246
 
                          gimp_filename_to_utf8 (filename));
247
 
  gimp_progress_init (name);
248
 
  g_free (name);
 
245
  gimp_progress_init_printf (_("Saving '%s'"),
 
246
                             gimp_filename_to_utf8 (filename));
249
247
 
250
248
  gimp_pixel_rgn_init (&pixel_rgn, drawable,
251
249
                       0, 0, drawable->width, drawable->height,
383
381
static gint
384
382
save_dialog (gint32 image_ID)
385
383
{
386
 
  GtkWidget *dlg;
 
384
  GtkWidget *dialog;
387
385
  GtkWidget *main_vbox;
388
386
  GtkWidget *frame;
389
387
  GtkWidget *vbox;
394
392
  GtkWidget *toggle;
395
393
  gboolean   run;
396
394
 
397
 
  gimp_ui_init ("gtm", FALSE);
398
 
 
399
 
  dlg = gimp_dialog_new (_("GIMP Table Magic"), "gtm",
400
 
                         NULL, 0,
401
 
                         gimp_standard_help_func, "file-gtm-save",
402
 
 
403
 
                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
404
 
                         GTK_STOCK_OK,     GTK_RESPONSE_OK,
405
 
 
406
 
                         NULL);
 
395
  gimp_ui_init (PLUG_IN_BINARY, FALSE);
 
396
 
 
397
  dialog = gimp_dialog_new (_("Save as HTML table"), PLUG_IN_BINARY,
 
398
                            NULL, 0,
 
399
                            gimp_standard_help_func, SAVE_PROC,
 
400
 
 
401
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 
402
                            GTK_STOCK_SAVE,   GTK_RESPONSE_OK,
 
403
 
 
404
                            NULL);
 
405
 
 
406
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
407
                                           GTK_RESPONSE_OK,
 
408
                                           GTK_RESPONSE_CANCEL,
 
409
                                           -1);
 
410
 
 
411
  gimp_window_set_transient (GTK_WINDOW (dialog));
407
412
 
408
413
  main_vbox = gtk_vbox_new (FALSE, 12);
409
414
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
410
 
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox,
 
415
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_vbox,
411
416
                      TRUE, TRUE, 0);
412
417
 
413
418
  if (gimp_image_width (image_ID) * gimp_image_height (image_ID) > 4096)
567
572
                           _("The number of pixels in the table border."),
568
573
                           NULL);
569
574
 
570
 
  g_signal_connect (adj, "value_changed",
 
575
  g_signal_connect (adj, "value-changed",
571
576
                    G_CALLBACK (gimp_int_adjustment_update),
572
577
                    &gtmvals.border);
573
578
 
612
617
  gimp_help_set_help_data (spinbutton,
613
618
                           _("The amount of cellpadding."), NULL);
614
619
 
615
 
  g_signal_connect (adj, "value_changed",
 
620
  g_signal_connect (adj, "value-changed",
616
621
                    G_CALLBACK (gimp_int_adjustment_update),
617
622
                    &gtmvals.cellpadding);
618
623
 
625
630
  gimp_help_set_help_data (spinbutton,
626
631
                           _("The amount of cellspacing."), NULL);
627
632
 
628
 
  g_signal_connect (adj, "value_changed",
 
633
  g_signal_connect (adj, "value-changed",
629
634
                    G_CALLBACK (gimp_int_adjustment_update),
630
635
                    &gtmvals.cellspacing);
631
636
 
632
637
  gtk_widget_show (table);
633
638
  gtk_widget_show (frame);
634
639
 
635
 
  gtk_widget_show (dlg);
636
 
 
637
 
  run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK);
638
 
 
639
 
  gtk_widget_destroy (dlg);
 
640
  gtk_widget_show (dialog);
 
641
 
 
642
  run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
 
643
 
 
644
  gtk_widget_destroy (dialog);
640
645
 
641
646
  return run;
642
647
}