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

« back to all changes in this revision

Viewing changes to plug-ins/common/xpm.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
 * This program is free software; you can redistribute it and/or modify
43
43
 
44
44
#include "config.h"
45
45
 
46
 
#include <stdlib.h>
47
 
#include <stdio.h>
48
46
#include <string.h>
49
47
 
50
 
#include <gtk/gtk.h>
51
 
 
52
 
#ifdef GDK_WINDOWING_WIN32
 
48
#include <glib/gstdio.h>
 
49
 
 
50
#include <gdkconfig.h>          /* For GDK_WINDOWING_WIN32 */
 
51
 
 
52
#ifndef GDK_WINDOWING_X11
53
53
#ifndef XPM_NO_X
54
54
#define XPM_NO_X
55
55
#endif
69
69
" .+@#$%&*=-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyz\
70
70
ABCDEFGHIJKLMNOPQRSTUVWXYZ`";
71
71
 
72
 
#define SCALE_WIDTH 125
 
72
#define LOAD_PROC      "file-xpm-load"
 
73
#define SAVE_PROC      "file-xpm-save"
 
74
#define PLUG_IN_BINARY "xpm"
 
75
#define SCALE_WIDTH    125
73
76
 
74
77
/* Structs for the save dialog */
75
78
typedef struct
114
117
static gboolean   save_dialog         (void);
115
118
 
116
119
 
117
 
GimpPlugInInfo PLUG_IN_INFO =
 
120
const GimpPlugInInfo PLUG_IN_INFO =
118
121
{
119
122
  NULL,  /* init_proc  */
120
123
  NULL,  /* quit_proc  */
133
136
static void
134
137
query (void)
135
138
{
136
 
  static GimpParamDef load_args[] =
 
139
  static const GimpParamDef load_args[] =
137
140
  {
138
 
    { GIMP_PDB_INT32,     "run_mode",     "Interactive, non-interactive" },
 
141
    { GIMP_PDB_INT32,     "run-mode",     "Interactive, non-interactive" },
139
142
    { GIMP_PDB_STRING,    "filename",     "The name of the file to load" },
140
 
    { GIMP_PDB_STRING,    "raw_filename", "The name entered" }
 
143
    { GIMP_PDB_STRING,    "raw-filename", "The name entered"             }
141
144
  };
142
145
 
143
 
  static GimpParamDef load_return_vals[] =
 
146
  static const GimpParamDef load_return_vals[] =
144
147
  {
145
148
    { GIMP_PDB_IMAGE,    "image",         "Output image" }
146
149
  };
147
150
 
148
 
  static GimpParamDef save_args[] =
 
151
  static const GimpParamDef save_args[] =
149
152
  {
150
 
    { GIMP_PDB_INT32,    "run_mode",      "Interactive, non-interactive" },
 
153
    { GIMP_PDB_INT32,    "run-mode",      "Interactive, non-interactive" },
151
154
    { GIMP_PDB_IMAGE,    "image",         "Input image" },
152
155
    { GIMP_PDB_DRAWABLE, "drawable",      "Drawable to save" },
153
156
    { GIMP_PDB_STRING,   "filename",      "The name of the file to save the image in" },
154
 
    { GIMP_PDB_STRING,   "raw_filename",  "The name of the file to save the image in" },
 
157
    { GIMP_PDB_STRING,   "raw-filename",  "The name of the file to save the image in" },
155
158
    { GIMP_PDB_INT32,    "threshold",     "Alpha threshold (0-255)" }
156
159
  };
157
160
 
158
 
  gimp_install_procedure ("file_xpm_load",
 
161
  gimp_install_procedure (LOAD_PROC,
159
162
                          "Load files in XPM (X11 Pixmap) format.",
160
163
                          "Load files in XPM (X11 Pixmap) format. "
161
164
                          "XPM is a portable image format designed to be "
174
177
                          G_N_ELEMENTS (load_return_vals),
175
178
                          load_args, load_return_vals);
176
179
 
177
 
  gimp_register_file_handler_mime ("file_xpm_load", "image/x-xpixmap");
178
 
  gimp_register_magic_load_handler ("file_xpm_load",
 
180
  gimp_register_file_handler_mime (LOAD_PROC, "image/x-xpixmap");
 
181
  gimp_register_magic_load_handler (LOAD_PROC,
179
182
                                    "xpm",
180
183
                                    "",
181
184
                                    "0, string,/*\\040XPM\\040*/");
182
185
 
183
 
  gimp_install_procedure ("file_xpm_save",
 
186
  gimp_install_procedure (SAVE_PROC,
184
187
                          "Save files in XPM (X11 Pixmap) format.",
185
188
                          "Save files in XPM (X11 Pixmap) format. "
186
189
                          "XPM is a portable image format designed to be "
198
201
                          G_N_ELEMENTS (save_args), 0,
199
202
                          save_args, NULL);
200
203
 
201
 
  gimp_register_file_handler_mime ("file_xpm_save", "image/x-xpixmap");
202
 
  gimp_register_save_handler ("file_xpm_save", "xpm", "");
 
204
  gimp_register_file_handler_mime (SAVE_PROC, "image/x-xpixmap");
 
205
  gimp_register_save_handler (SAVE_PROC, "xpm", "");
203
206
}
204
207
 
205
208
static void
226
229
  values[0].type          = GIMP_PDB_STATUS;
227
230
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
228
231
 
229
 
  if (strcmp (name, "file_xpm_load") == 0)
 
232
  if (strcmp (name, LOAD_PROC) == 0)
230
233
    {
231
234
      image_ID = load_image (param[1].data.d_string);
232
235
 
241
244
          status = GIMP_PDB_EXECUTION_ERROR;
242
245
        }
243
246
    }
244
 
  else if (strcmp (name, "file_xpm_save") == 0)
 
247
  else if (strcmp (name, SAVE_PROC) == 0)
245
248
    {
246
 
      gimp_ui_init ("xpm", FALSE);
 
249
      gimp_ui_init (PLUG_IN_BINARY, FALSE);
247
250
 
248
251
      image_ID    = param[1].data.d_int32;
249
252
      drawable_ID = param[2].data.d_int32;
336
339
  XpmImage  xpm_image;
337
340
  guchar   *cmap;
338
341
  gint32    image_ID;
339
 
  gchar    *name;
340
342
 
341
 
  /* put up a progress bar */
342
 
  name = g_strdup_printf (_("Opening '%s'..."),
343
 
                          gimp_filename_to_utf8 (filename));
344
 
  gimp_progress_init (name);
345
 
  g_free (name);
 
343
  gimp_progress_init_printf (_("Opening '%s'"),
 
344
                             gimp_filename_to_utf8 (filename));
346
345
 
347
346
  /* read the raw file */
348
347
  switch (XpmReadFileToXpmImage ((char *) filename, &xpm_image, NULL))
621
620
 
622
621
  hash = g_hash_table_new ((GHashFunc) rgbhash, (GCompareFunc) compare);
623
622
 
624
 
  /* put up a progress bar */
625
 
  {
626
 
    gchar *name;
627
 
 
628
 
    name = g_strdup_printf (_("Saving '%s'..."),
629
 
                            gimp_filename_to_utf8 (filename));
630
 
    gimp_progress_init (name);
631
 
    g_free (name);
632
 
  }
 
623
  gimp_progress_init_printf (_("Saving '%s'"),
 
624
                             gimp_filename_to_utf8 (filename));
633
625
 
634
626
  ncolors = alpha ? 1 : 0;
635
627
 
772
764
static gboolean
773
765
save_dialog (void)
774
766
{
775
 
  GtkWidget *dlg;
 
767
  GtkWidget *dialog;
776
768
  GtkWidget *table;
777
769
  GtkObject *scale_data;
778
770
  gboolean   run;
779
771
 
780
 
  dlg = gimp_dialog_new (_("Save as XPM"), "xpm",
781
 
                         NULL, 0,
782
 
                         gimp_standard_help_func, "file-xpm-save",
783
 
 
784
 
                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
785
 
                         GTK_STOCK_OK,     GTK_RESPONSE_OK,
786
 
 
787
 
                         NULL);
 
772
  dialog = gimp_dialog_new (_("Save as XPM"), PLUG_IN_BINARY,
 
773
                            NULL, 0,
 
774
                            gimp_standard_help_func, SAVE_PROC,
 
775
 
 
776
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 
777
                            GTK_STOCK_SAVE,   GTK_RESPONSE_OK,
 
778
 
 
779
                            NULL);
 
780
 
 
781
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
782
                                           GTK_RESPONSE_OK,
 
783
                                           GTK_RESPONSE_CANCEL,
 
784
                                           -1);
 
785
 
 
786
  gimp_window_set_transient (GTK_WINDOW (dialog));
788
787
 
789
788
  table = gtk_table_new (1, 3, FALSE);
790
789
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
791
790
  gtk_container_set_border_width (GTK_CONTAINER (table), 12);
792
 
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), table, TRUE, TRUE, 0);
 
791
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
 
792
                      table, TRUE, TRUE, 0);
793
793
  gtk_widget_show (table);
794
794
 
795
795
  scale_data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
798
798
                                     TRUE, 0, 0,
799
799
                                     NULL, NULL);
800
800
 
801
 
  g_signal_connect (scale_data, "value_changed",
 
801
  g_signal_connect (scale_data, "value-changed",
802
802
                    G_CALLBACK (gimp_int_adjustment_update),
803
803
                    &xpmvals.threshold);
804
804
 
805
 
  gtk_widget_show (dlg);
806
 
 
807
 
  run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK);
808
 
 
809
 
  gtk_widget_destroy (dlg);
 
805
  gtk_widget_show (dialog);
 
806
 
 
807
  run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
 
808
 
 
809
  gtk_widget_destroy (dialog);
810
810
 
811
811
  return run;
812
812
}