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

« back to all changes in this revision

Viewing changes to plug-ins/common/csource.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:
21
21
 
22
22
#include "config.h"
23
23
 
24
 
#include <stdlib.h>
25
24
#include <string.h>
26
 
#include <stdio.h>
27
25
 
28
 
#include <gtk/gtk.h>
 
26
#include <glib/gstdio.h>
29
27
 
30
28
#include <libgimp/gimp.h>
31
29
#include <libgimp/gimpui.h>
33
31
#include "libgimp/stdplugins-intl.h"
34
32
 
35
33
 
 
34
#define SAVE_PROC      "file-csource-save"
 
35
#define PLUG_IN_BINARY "csource"
 
36
 
 
37
 
36
38
typedef struct
37
39
{
38
40
  gchar    *file_name;
62
64
 
63
65
 
64
66
/* --- variables --- */
65
 
GimpPlugInInfo PLUG_IN_INFO =
 
67
const GimpPlugInInfo PLUG_IN_INFO =
66
68
{
67
69
  NULL,  /* init_proc  */
68
70
  NULL,  /* quit_proc  */
90
92
static void
91
93
query (void)
92
94
{
93
 
  static GimpParamDef save_args[] =
 
95
  static const GimpParamDef save_args[] =
94
96
  {
95
 
    { GIMP_PDB_INT32, "run_mode", "Interactive" },
96
 
    { GIMP_PDB_IMAGE, "image", "Input image" },
97
 
    { GIMP_PDB_DRAWABLE, "drawable", "Drawable to save" },
98
 
    { GIMP_PDB_STRING, "filename", "The name of the file to save the image in" },
99
 
    { GIMP_PDB_STRING, "raw_filename", "The name of the file to save the image in" }
 
97
    { GIMP_PDB_INT32,    "run-mode",     "Interactive" },
 
98
    { GIMP_PDB_IMAGE,    "image",        "Input image" },
 
99
    { GIMP_PDB_DRAWABLE, "drawable",     "Drawable to save" },
 
100
    { GIMP_PDB_STRING,   "filename",     "The name of the file to save the image in" },
 
101
    { GIMP_PDB_STRING,   "raw-filename", "The name of the file to save the image in" }
100
102
  };
101
103
 
102
 
  gimp_install_procedure ("file_csource_save",
 
104
  gimp_install_procedure (SAVE_PROC,
103
105
                          "Dump image data in RGB(A) format for C source",
104
106
                          "CSource cannot be run non-interactively.",
105
107
                          "Tim Janik",
111
113
                          G_N_ELEMENTS (save_args), 0,
112
114
                          save_args, NULL);
113
115
 
114
 
  gimp_register_file_handler_mime ("file_csource_save", "text/x-csrc");
115
 
  gimp_register_save_handler ("file_csource_save", "c", "");
 
116
  gimp_register_file_handler_mime (SAVE_PROC, "text/x-csrc");
 
117
  gimp_register_save_handler (SAVE_PROC, "c", "");
116
118
}
117
119
 
118
120
static void
138
140
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
139
141
 
140
142
  if (run_mode == GIMP_RUN_INTERACTIVE &&
141
 
      strcmp (name, "file_csource_save") == 0)
 
143
      strcmp (name, SAVE_PROC) == 0)
142
144
    {
143
145
      gint32         image_ID    = param[1].data.d_int32;
144
146
      gint32         drawable_ID = param[2].data.d_int32;
146
148
      gchar         *x;
147
149
      GimpImageType  drawable_type = gimp_drawable_type (drawable_ID);
148
150
 
149
 
      gimp_get_data ("file_csource_save", &config);
 
151
      gimp_get_data (SAVE_PROC, &config);
150
152
      config.prefixed_name = "gimp_image";
151
153
      config.comment       = NULL;
152
154
 
164
166
        }
165
167
      x = config.comment;
166
168
 
167
 
      gimp_ui_init ("csource", FALSE);
 
169
      gimp_ui_init (PLUG_IN_BINARY, FALSE);
168
170
      export = gimp_export_image (&image_ID, &drawable_ID, "C Source",
169
171
                                  (GIMP_EXPORT_CAN_HANDLE_RGB |
170
172
                                   GIMP_EXPORT_CAN_HANDLE_ALPHA ));
198
200
            }
199
201
          else
200
202
            {
201
 
              gimp_set_data ("file_csource_save", &config, sizeof (config));
 
203
              gimp_set_data (SAVE_PROC, &config, sizeof (config));
202
204
            }
203
205
        }
204
206
      else
382
384
  guint8 *img_buffer, *img_buffer_end;
383
385
  gchar *basename;
384
386
 
385
 
  fp = fopen (config->file_name, "w");
 
387
  fp = g_fopen (config->file_name, "w");
386
388
  if (!fp)
387
389
    return FALSE;
388
390
 
632
634
  GtkObject *adj;
633
635
  gboolean   run;
634
636
 
635
 
  dialog = gimp_dialog_new (_("Save as C-Source"), "csource",
 
637
  dialog = gimp_dialog_new (_("Save as C-Source"), PLUG_IN_BINARY,
636
638
                            NULL, 0,
637
 
                            gimp_standard_help_func, "file-csource-save",
 
639
                            gimp_standard_help_func, SAVE_PROC,
638
640
 
639
641
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
640
 
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,
 
642
                            GTK_STOCK_SAVE,   GTK_RESPONSE_OK,
641
643
 
642
644
                            NULL);
643
645
 
 
646
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
647
                                           GTK_RESPONSE_OK,
 
648
                                           GTK_RESPONSE_CANCEL,
 
649
                                           -1);
 
650
 
 
651
  gimp_window_set_transient (GTK_WINDOW (dialog));
 
652
 
644
653
  vbox = gtk_vbox_new (FALSE, 12);
645
654
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
646
655
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
742
751
                              config->opacity, 0, 100, 1, 10, 1,
743
752
                              TRUE, 0, 0,
744
753
                              NULL, NULL);
745
 
  g_signal_connect (adj, "value_changed",
 
754
  g_signal_connect (adj, "value-changed",
746
755
                    G_CALLBACK (gimp_double_adjustment_update),
747
756
                    &config->opacity);
748
757