~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to plug-ins/common/file-wmf.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
 
 * This program is free software; you can redistribute it and/or modify
 
4
 * This program is free software: you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License, or
 
6
 * the Free Software Foundation; either version 3 of the License, or
7
7
 * (at your option) any later version.
8
8
 *
9
9
 * This program is distributed in the hope that it will be useful,
12
12
 * GNU General Public License for more details.
13
13
 *
14
14
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
16
 */
18
17
 
19
18
/* WMF loading file filter for GIMP
36
35
#define LOAD_PROC               "file-wmf-load"
37
36
#define LOAD_THUMB_PROC         "file-wmf-load-thumb"
38
37
#define PLUG_IN_BINARY          "file-wmf"
 
38
#define PLUG_IN_ROLE            "gimp-file-wmf"
39
39
 
40
 
#define WMF_DEFAULT_RESOLUTION  90.0
 
40
#define WMF_DEFAULT_RESOLUTION  90.0
41
41
#define WMF_DEFAULT_SIZE        500
42
42
#define WMF_PREVIEW_SIZE        128
43
43
 
95
95
{
96
96
  static const GimpParamDef load_args[] =
97
97
  {
98
 
    { GIMP_PDB_INT32,  "run-mode",     "Interactive, non-interactive" },
 
98
    { GIMP_PDB_INT32,  "run-mode",     "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
99
99
    { GIMP_PDB_STRING, "filename",     "The name of the file to load" },
100
100
    { GIMP_PDB_STRING, "raw-filename", "The name of the file to load" },
101
101
    { GIMP_PDB_FLOAT,  "resolution",   "Resolution to use for rendering the WMF (defaults to 72 dpi"     },
144
144
                          "Dom Lachowicz <cinamod@hotmail.com>",
145
145
                          "Dom Lachowicz <cinamod@hotmail.com>",
146
146
                          "(c) 2003 - Version 0.3.0",
147
 
                          NULL,
148
 
                          NULL,
 
147
                          NULL,
 
148
                          NULL,
149
149
                          GIMP_PLUGIN,
150
150
                          G_N_ELEMENTS (thumb_args),
151
151
                          G_N_ELEMENTS (thumb_return_vals),
340
340
    success = FALSE;
341
341
 
342
342
  wmf_mem_close (API);
343
 
  g_mapped_file_free (file);
 
343
  g_mapped_file_unref (file);
344
344
 
345
345
  if (width < 1 || height < 1)
346
346
    {
497
497
 
498
498
  gimp_ui_init (PLUG_IN_BINARY, FALSE);
499
499
 
500
 
  dialog = gimp_dialog_new (_("Render Windows Metafile"), PLUG_IN_BINARY,
 
500
  dialog = gimp_dialog_new (_("Render Windows Metafile"), PLUG_IN_ROLE,
501
501
                            NULL, 0,
502
502
                            gimp_standard_help_func, LOAD_PROC,
503
503
 
515
515
 
516
516
  gimp_window_set_transient (GTK_WINDOW (dialog));
517
517
 
518
 
  hbox = gtk_hbox_new (FALSE, 12);
 
518
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
519
519
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
520
 
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
521
 
                      TRUE, TRUE, 0);
 
520
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
 
521
                      hbox, TRUE, TRUE, 0);
522
522
  gtk_widget_show (hbox);
523
523
 
524
524
  /*  The WMF preview  */
525
 
  vbox = gtk_vbox_new (FALSE, 6);
 
525
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
526
526
  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
527
527
  gtk_widget_show (vbox);
528
528
 
580
580
                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
581
581
  gtk_widget_show (label);
582
582
 
583
 
  hbox = gtk_hbox_new (FALSE, 0);
 
583
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
584
584
  gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 0, 1,
585
585
                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
586
586
  gtk_widget_show (hbox);
590
590
  gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
591
591
  gtk_widget_show (spinbutton);
592
592
 
593
 
  hbox = gtk_hbox_new (FALSE, 0);
 
593
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
594
594
  gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 1, 2,
595
595
                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
596
596
  gtk_widget_show (hbox);
619
619
  gimp_size_entry_set_resolution (size, 1, load_vals.resolution, FALSE);
620
620
 
621
621
  g_signal_connect (size, "value-changed",
622
 
                    G_CALLBACK (load_dialog_size_callback),
 
622
                    G_CALLBACK (load_dialog_size_callback),
623
623
                    NULL);
624
624
 
625
625
  /*  Scale ratio  */
626
 
  hbox = gtk_hbox_new (FALSE, 0);
 
626
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
627
627
  gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 2, 4,
628
 
                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
 
628
                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
629
629
  gtk_widget_show (hbox);
630
630
 
631
631
  table2 = gtk_table_new (2, 2, FALSE);
645
645
  gtk_widget_show (spinbutton);
646
646
 
647
647
  g_signal_connect (xadj, "value-changed",
648
 
                    G_CALLBACK (load_dialog_ratio_callback),
649
 
                    NULL);
 
648
                    G_CALLBACK (load_dialog_ratio_callback),
 
649
                    NULL);
650
650
 
651
651
  label = gtk_label_new_with_mnemonic (_("_X ratio:"));
652
652
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
653
653
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
654
654
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
655
 
                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
 
655
                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
656
656
  gtk_widget_show (label);
657
657
 
658
658
  spinbutton =
667
667
  gtk_widget_show (spinbutton);
668
668
 
669
669
  g_signal_connect (yadj, "value-changed",
670
 
                    G_CALLBACK (load_dialog_ratio_callback),
671
 
                    NULL);
 
670
                    G_CALLBACK (load_dialog_ratio_callback),
 
671
                    NULL);
672
672
 
673
673
  label = gtk_label_new_with_mnemonic (_("_Y ratio:"));
674
674
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
675
675
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
676
676
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
677
 
                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
 
677
                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
678
678
  gtk_widget_show (label);
679
679
 
680
680
  /*  the constrain ratio chainbutton  */
871
871
      wmf_api_destroy (API);
872
872
    }
873
873
 
874
 
  g_mapped_file_free (file);
 
874
  g_mapped_file_unref (file);
875
875
 
876
876
  return pixels;
877
877
}
956
956
      wmf_api_destroy (API);
957
957
    }
958
958
 
959
 
  g_mapped_file_free (file);
 
959
  g_mapped_file_unref (file);
960
960
 
961
961
  /* FIXME: improve error message */
962
962
  g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
974
974
            GError      **error)
975
975
{
976
976
  gint32        image;
977
 
  gint32        layer;
 
977
  gint32        layer;
978
978
  GimpDrawable *drawable;
979
979
  guchar       *pixels;
980
 
  GimpPixelRgn  pixel_rgn;
 
980
  GimpPixelRgn  pixel_rgn;
981
981
  guint         width, height;
982
982
  guint         rowstride;
983
983
  guint         count = 0;
1038
1038
 
1039
1039
  /* Tell GIMP to display the image.
1040
1040
   */
1041
 
  gimp_image_add_layer (image, layer, 0);
 
1041
  gimp_image_insert_layer (image, layer, -1, 0);
1042
1042
  gimp_drawable_flush (drawable);
1043
1043
 
1044
1044
  return image;