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

« back to all changes in this revision

Viewing changes to plug-ins/common/borderaverage.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:
17
17
 * along with this program; if not, write to the Free Software
18
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
19
 */
 
20
 
20
21
#include "config.h"
21
22
 
22
 
#include <gtk/gtk.h>
23
 
 
24
23
#include <libgimp/gimp.h>
25
24
#include <libgimp/gimpui.h>
26
25
 
27
26
#include "libgimp/stdplugins-intl.h"
28
27
 
29
28
 
 
29
#define PLUG_IN_PROC   "plug-in-borderaverage"
 
30
#define PLUG_IN_BINARY "borderaverage"
 
31
 
 
32
 
30
33
/* Declare local functions.
31
34
 */
32
35
static void      query  (void);
51
54
static void      thickness_callback   (GtkWidget    *widget,
52
55
                                       gpointer      data);
53
56
 
54
 
GimpPlugInInfo PLUG_IN_INFO =
 
57
const GimpPlugInInfo PLUG_IN_INFO =
55
58
{
56
59
  NULL,  /* init  */
57
60
  NULL,  /* quit  */
79
82
static void
80
83
query (void)
81
84
{
82
 
  static GimpParamDef args[] =
 
85
  static const GimpParamDef args[] =
83
86
  {
84
 
    { GIMP_PDB_INT32,    "run_mode",        "Interactive, non-interactive" },
 
87
    { GIMP_PDB_INT32,    "run-mode",        "Interactive, non-interactive" },
85
88
    { GIMP_PDB_IMAGE,    "image",           "Input image (unused)" },
86
89
    { GIMP_PDB_DRAWABLE, "drawable",        "Input drawable" },
87
90
    { GIMP_PDB_INT32,    "thickness",       "Border size to take in count" },
88
 
    { GIMP_PDB_INT32,    "bucket_exponent", "Bits for bucket size (default=4: 16 Levels)" },
 
91
    { GIMP_PDB_INT32,    "bucket-exponent", "Bits for bucket size (default=4: 16 Levels)" },
89
92
  };
90
 
  static GimpParamDef return_vals[] =
 
93
  static const GimpParamDef return_vals[] =
91
94
  {
92
 
    { GIMP_PDB_COLOR,     "borderaverage",   "The average color of the specified border" },
 
95
    { GIMP_PDB_COLOR,    "borderaverage",   "Sends the average color of the specified border to the Toolbox foreground." },
93
96
  };
94
97
 
95
 
  gimp_install_procedure ("plug_in_borderaverage",
96
 
                          "Borderaverage",
 
98
  gimp_install_procedure (PLUG_IN_PROC,
 
99
                          N_("Set foreground to the average color of the image border"),
97
100
                          "",
98
101
                          "Philipp Klaus",
99
102
                          "Internet Access AG",
105
108
                          G_N_ELEMENTS (return_vals),
106
109
                          args, return_vals);
107
110
 
108
 
  gimp_plugin_menu_register ("plug_in_borderaverage", "<Image>/Filters/Colors");
 
111
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Colors/Info");
109
112
}
110
113
 
111
114
static void
133
136
  switch (run_mode)
134
137
    {
135
138
    case GIMP_RUN_INTERACTIVE:
136
 
      gimp_get_data ("plug_in_borderaverage", &borderaverage_data);
 
139
      gimp_get_data (PLUG_IN_PROC, &borderaverage_data);
137
140
      borderaverage_thickness       = borderaverage_data.thickness;
138
141
      borderaverage_bucket_exponent = borderaverage_data.bucket_exponent;
139
142
      if (! borderaverage_dialog (image_ID, drawable))
151
154
      break;
152
155
 
153
156
    case GIMP_RUN_WITH_LAST_VALS:
154
 
      gimp_get_data ("plug_in_borderaverage", &borderaverage_data);
 
157
      gimp_get_data (PLUG_IN_PROC, &borderaverage_data);
155
158
      borderaverage_thickness       = borderaverage_data.thickness;
156
159
      borderaverage_bucket_exponent = borderaverage_data.bucket_exponent;
157
160
      break;
165
168
      /*  Make sure that the drawable is RGB color  */
166
169
      if (gimp_drawable_is_rgb (drawable->drawable_id))
167
170
        {
168
 
          gimp_progress_init ( _("Border Average..."));
 
171
          gimp_progress_init ( _("Border Average"));
169
172
          borderaverage (drawable, &result_color);
170
173
 
171
174
          if (run_mode != GIMP_RUN_NONINTERACTIVE)
176
179
            {
177
180
              borderaverage_data.thickness       = borderaverage_thickness;
178
181
              borderaverage_data.bucket_exponent = borderaverage_bucket_exponent;
179
 
              gimp_set_data ("plug_in_borderaverage",
 
182
              gimp_set_data (PLUG_IN_PROC,
180
183
                             &borderaverage_data, sizeof (borderaverage_data));
181
184
            }
182
185
        }
186
189
        }
187
190
    }
188
191
  *nreturn_vals = 3;
189
 
  *return_vals = values;
 
192
  *return_vals  = values;
190
193
 
191
 
  values[0].type = GIMP_PDB_STATUS;
 
194
  values[0].type          = GIMP_PDB_STATUS;
192
195
  values[0].data.d_status = status;
193
196
 
194
 
  values[1].type = GIMP_PDB_COLOR;
 
197
  values[1].type         = GIMP_PDB_COLOR;
195
198
  values[1].data.d_color = result_color;
196
199
 
197
200
  gimp_drawable_detach (drawable);
343
346
  const gchar *labels[] =
344
347
    { "1", "2", "4", "8", "16", "32", "64", "128", "256" };
345
348
 
346
 
  gimp_ui_init ("borderaverage", FALSE);
 
349
  gimp_ui_init (PLUG_IN_BINARY, FALSE);
347
350
 
348
 
  dialog = gimp_dialog_new (_("Borderaverage"), "borderaverage",
 
351
  dialog = gimp_dialog_new (_("Borderaverage"), PLUG_IN_BINARY,
349
352
                            NULL, 0,
350
 
                            gimp_standard_help_func, "plug-in-borderaverage",
 
353
                            gimp_standard_help_func, PLUG_IN_PROC,
351
354
 
352
355
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
353
356
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,
354
357
 
355
358
                            NULL);
356
359
 
 
360
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
361
                                           GTK_RESPONSE_OK,
 
362
                                           GTK_RESPONSE_CANCEL,
 
363
                                           -1);
 
364
 
 
365
  gimp_window_set_transient (GTK_WINDOW (dialog));
 
366
 
357
367
  main_vbox = gtk_vbox_new (FALSE, 12);
358
368
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
359
369
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
397
407
  gtk_table_set_col_spacing (GTK_TABLE (size_entry), 2, 12);
398
408
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (size_entry), 0,
399
409
                              (gdouble) borderaverage_thickness);
400
 
  g_signal_connect (size_entry, "value_changed",
 
410
  g_signal_connect (size_entry, "value-changed",
401
411
                    G_CALLBACK (thickness_callback),
402
412
                    NULL);
403
413
  gtk_widget_show (size_entry);