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

« back to all changes in this revision

Viewing changes to plug-ins/common/tileit.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:
3
3
 *
4
4
 * This is a plug-in for the GIMP.
5
5
 *
6
 
 * Tileit - This plugin will take an image an make repeated
7
 
 * copies of it the stepping is 1/(2**n); 1<=n<=6
 
6
 * Tileit - This plugin take an image and makes repeated copies of it.
8
7
 *
9
8
 * Copyright (C) 1997 Andy Thomas  alt@picnic.demon.co.uk
10
9
 *
38
37
 
39
38
#include "config.h"
40
39
 
41
 
#include <stdio.h>
42
 
#include <stdlib.h>
43
40
#include <string.h>
44
41
 
45
 
#include <gtk/gtk.h>
46
 
 
47
42
#include <libgimp/gimp.h>
48
43
#include <libgimp/gimpui.h>
49
44
 
50
45
#include "libgimp/stdplugins-intl.h"
51
46
 
52
 
#define PLUG_IN_NAME  "plug_in_small_tiles"
 
47
#define PLUG_IN_PROC   "plug-in-small-tiles"
 
48
#define PLUG_IN_BINARY "tileit"
53
49
 
54
50
/***** Magic numbers *****/
55
51
 
126
122
                                        GdkEvent  *event);
127
123
 
128
124
 
129
 
GimpPlugInInfo PLUG_IN_INFO =
 
125
const GimpPlugInInfo PLUG_IN_INFO =
130
126
{
131
127
  NULL,  /* init_proc  */
132
128
  NULL,  /* quit_proc  */
207
203
static void
208
204
query (void)
209
205
{
210
 
  static GimpParamDef args[] =
 
206
  static const GimpParamDef args[] =
211
207
  {
212
 
    { GIMP_PDB_INT32,    "run_mode",        "Interactive, non-interactive" },
213
 
    { GIMP_PDB_IMAGE,    "image",           "Input image (unused)"         },
214
 
    { GIMP_PDB_DRAWABLE, "drawable",        "Input drawable"               },
215
 
    { GIMP_PDB_INT32,    "number_of_tiles", "Number of tiles to make"      }
 
208
    { GIMP_PDB_INT32,    "run-mode",  "Interactive, non-interactive" },
 
209
    { GIMP_PDB_IMAGE,    "image",     "Input image (unused)"         },
 
210
    { GIMP_PDB_DRAWABLE, "drawable",  "Input drawable"               },
 
211
    { GIMP_PDB_INT32,    "num-tiles", "Number of tiles to make"      }
216
212
  };
217
213
 
218
 
  gimp_install_procedure (PLUG_IN_NAME,
219
 
                          "Tiles image into smaller versions of the orginal",
 
214
  gimp_install_procedure (PLUG_IN_PROC,
 
215
                          N_("Tile image into smaller versions of the original"),
220
216
                          "More here later",
221
217
                          "Andy Thomas",
222
218
                          "Andy Thomas",
227
223
                          G_N_ELEMENTS (args), 0,
228
224
                          args, NULL);
229
225
 
230
 
  gimp_plugin_menu_register (PLUG_IN_NAME, "<Image>/Filters/Map");
 
226
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Map");
231
227
}
232
228
 
233
229
static void
260
256
 
261
257
  has_alpha = gimp_drawable_has_alpha (tileitdrawable->drawable_id);
262
258
 
263
 
  gimp_drawable_mask_bounds (drawable->drawable_id,
264
 
                             &sel_x1, &sel_y1, &sel_x2, &sel_y2);
 
259
  if (! gimp_drawable_mask_intersect (drawable->drawable_id,
 
260
                                      &sel_x1, &sel_y1, &sel_x2, &sel_y2))
 
261
    {
 
262
      g_message (_("Region selected for filter is empty."));
 
263
      return;
 
264
    }
265
265
 
266
266
  sel_width  = sel_x2 - sel_x1;
267
267
  sel_height = sel_y2 - sel_y1;
285
285
  switch (run_mode)
286
286
    {
287
287
    case GIMP_RUN_INTERACTIVE:
288
 
      gimp_get_data (PLUG_IN_NAME, &itvals);
 
288
      gimp_get_data (PLUG_IN_PROC, &itvals);
289
289
      if (! tileit_dialog ())
290
290
        {
291
291
          gimp_drawable_detach (drawable);
305
305
      break;
306
306
 
307
307
    case GIMP_RUN_WITH_LAST_VALS:
308
 
      gimp_get_data (PLUG_IN_NAME, &itvals);
 
308
      gimp_get_data (PLUG_IN_PROC, &itvals);
309
309
      break;
310
310
 
311
311
    default:
317
317
    {
318
318
      /* Set the tile cache size */
319
319
 
320
 
      gimp_progress_init (_("Tiling..."));
 
320
      gimp_progress_init (_("Tiling"));
321
321
 
322
322
      do_tiles ();
323
323
 
325
325
        gimp_displays_flush ();
326
326
 
327
327
      if (run_mode == GIMP_RUN_INTERACTIVE)
328
 
        gimp_set_data (PLUG_IN_NAME, &itvals, sizeof (TileItVals));
 
328
        gimp_set_data (PLUG_IN_PROC, &itvals, sizeof (TileItVals));
329
329
    }
330
330
  else
331
331
    {
356
356
  GSList    *orientation_group = NULL;
357
357
  gboolean   run;
358
358
 
359
 
  gimp_ui_init ("tileit", TRUE);
 
359
  gimp_ui_init (PLUG_IN_BINARY, TRUE);
360
360
 
361
361
  cache_preview (); /* Get the preview image */
362
362
 
363
 
  dlg = gimp_dialog_new (_("TileIt"), "tileit",
 
363
  dlg = gimp_dialog_new (_("Small Tiles"), PLUG_IN_BINARY,
364
364
                         NULL, 0,
365
 
                         gimp_standard_help_func, "plug-in-small-tiles",
 
365
                         gimp_standard_help_func, PLUG_IN_PROC,
366
366
 
367
367
                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
368
368
                         GTK_STOCK_OK,     GTK_RESPONSE_OK,
369
369
 
370
370
                         NULL);
371
371
 
 
372
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dlg),
 
373
                                           GTK_RESPONSE_OK,
 
374
                                           GTK_RESPONSE_CANCEL,
 
375
                                           -1);
 
376
 
 
377
  gimp_window_set_transient (GTK_WINDOW (dlg));
 
378
 
372
379
  main_vbox = gtk_vbox_new (FALSE, 12);
373
380
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
374
381
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox,
394
401
  gtk_container_add (GTK_CONTAINER (frame), tint.preview);
395
402
  gtk_widget_show (tint.preview);
396
403
 
397
 
  g_signal_connect_after (tint.preview, "expose_event",
 
404
  g_signal_connect_after (tint.preview, "expose-event",
398
405
                          G_CALLBACK (tileit_preview_expose),
399
406
                          NULL);
400
407
  g_signal_connect (tint.preview, "event",
500
507
                    GTK_FILL | GTK_SHRINK, GTK_FILL, 0, 0);
501
508
  gtk_widget_show (spinbutton);
502
509
 
503
 
  g_signal_connect (adj, "value_changed",
 
510
  g_signal_connect (adj, "value-changed",
504
511
                    G_CALLBACK (tileit_exp_update_f),
505
512
                    &exp_call);
506
513
 
509
516
  gtk_widget_set_sensitive (spinbutton, FALSE);
510
517
  g_object_set_data (G_OBJECT (label), "set_sensitive", spinbutton);
511
518
 
512
 
  label = gtk_label_new_with_mnemonic ( _("Col_umn:"));
 
519
  label = gtk_label_new_with_mnemonic (_("Col_umn:"));
513
520
  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
514
521
  gtk_widget_show (label);
515
522
  gtk_table_attach (GTK_TABLE (table), label, 1, 2, 3, 4,
524
531
                    GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
525
532
  gtk_widget_show (spinbutton);
526
533
 
527
 
  g_signal_connect (adj, "value_changed",
 
534
  g_signal_connect (adj, "value-changed",
528
535
                    G_CALLBACK (tileit_exp_update_f),
529
536
                    &exp_call);
530
537
 
565
572
                                opacity, 0, 100, 1, 10, 0,
566
573
                                TRUE, 0, 0,
567
574
                                NULL, NULL);
568
 
  g_signal_connect (scale, "value_changed",
 
575
  g_signal_connect (scale, "value-changed",
569
576
                    G_CALLBACK (tileit_scale_update),
570
577
                    &opacity);
571
578
 
582
589
  gtk_widget_set_sensitive (table2, has_alpha);
583
590
 
584
591
  scale = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
585
 
                                "1 / (2 ** _n)", SCALE_WIDTH, -1,
 
592
                                "_n²", SCALE_WIDTH, -1,
586
593
                                itvals.numtiles, 2, MAX_SEGS, 1, 1, 0,
587
594
                                TRUE, 0, 0,
588
595
                                NULL, NULL);
589
 
  g_signal_connect (scale, "value_changed",
 
596
  g_signal_connect (scale, "value-changed",
590
597
                    G_CALLBACK (tileit_scale_update),
591
598
                    &itvals.numtiles);
592
599
 
683
690
  if (nx <= 0 || nx > itvals.numtiles || ny <= 0 || ny > itvals.numtiles)
684
691
    return;
685
692
 
686
 
  if( nx != exp_call.x ||
687
 
      ny != exp_call.y )
 
693
  if (nx != exp_call.x || ny != exp_call.y)
688
694
    {
689
695
      draw_explict_sel (); /* Clear old 'un */
690
696
      exp_call.x = nx;
736
742
      mevent = (GdkEventMotion *) event;
737
743
      if ( !mevent->state )
738
744
        break;
739
 
      if(mevent->x < 0 || mevent->y < 0)
 
745
      if (mevent->x < 0 || mevent->y < 0)
740
746
        break;
741
747
      nx = mevent->x/twidth + 1;
742
748
      ny = mevent->y/theight + 1;
1040
1046
 
1041
1047
  if ((actiontype = tileactions[cnum][rnum]))
1042
1048
    {
1043
 
      if (actiontype & HORIZONTAL)
 
1049
      if (actiontype & VERTICAL)
1044
1050
        {
1045
1051
          gdouble pyr;
1046
1052
 
1048
1054
          py = ((gint) (pyr * (gdouble) itvals.numtiles)) % height;
1049
1055
        }
1050
1056
 
1051
 
      if (actiontype & VERTICAL)
 
1057
      if (actiontype & HORIZONTAL)
1052
1058
        {
1053
1059
          gdouble pxr;
1054
1060
 
1090
1096
      px = (x*itvals.numtiles)%width;
1091
1097
      cnum = x*itvals.numtiles/width;
1092
1098
 
1093
 
      if((actiontype = tileactions[cnum][rnum]))
 
1099
      if ((actiontype = tileactions[cnum][rnum]))
1094
1100
        {
1095
 
          if(actiontype & HORIZONTAL)
 
1101
          if (actiontype & VERTICAL)
1096
1102
            {
1097
1103
              gdouble pyr;
1098
1104
              pyr =  height - dh - 1 + rnd;
1099
1105
              py = ((int)(pyr*(gdouble)itvals.numtiles))%height;
1100
1106
            }
1101
1107
 
1102
 
          if(actiontype & VERTICAL)
 
1108
          if (actiontype & HORIZONTAL)
1103
1109
            {
1104
1110
              gdouble pxr;
1105
1111
              pxr = width - x - 1 + rnd;