~ubuntu-branches/ubuntu/karmic/gimp/karmic

« back to all changes in this revision

Viewing changes to app/tools/gimplevelstool.c

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2008-11-24 14:16:39 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20081124141639-12b1g29vvadd5pzp
Tags: 2.6.3-1ubuntu1
* Sync with Debian experimental (LP: #301724)
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch:
  - updated some strings for ubuntu
* debian/rules:
  - updated translation templates
* debian/control:
  - Drop webkit build dependency. gimp is the only thing pulling
    in webkit for the desktop CDs, and makes them explode
    Without the webkit help browser
    plugin, help will just be displayed in the default browser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
                                                   const gchar       *filename,
95
95
                                                   GError           **error);
96
96
 
 
97
static void       gimp_levels_tool_export_setup   (GimpSettingsBox      *settings_box,
 
98
                                                   GtkFileChooserDialog *dialog,
 
99
                                                   gboolean              export,
 
100
                                                   GimpLevelsTool       *tool);
97
101
static void       gimp_levels_tool_config_notify  (GObject           *object,
98
102
                                                   GParamSpec        *pspec,
99
103
                                                   GimpLevelsTool    *tool);
361
365
  GtkObject        *data;
362
366
  gint              border;
363
367
 
 
368
  g_signal_connect (image_map_tool->settings_box, "file-dialog-setup",
 
369
                    G_CALLBACK (gimp_levels_tool_export_setup),
 
370
                    image_map_tool);
 
371
 
364
372
  main_vbox   = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
365
373
  label_group = gimp_image_map_tool_dialog_get_label_group (image_map_tool);
366
374
 
725
733
{
726
734
  GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
727
735
  FILE           *file;
728
 
  gboolean        success;
 
736
  gchar           header[64];
729
737
 
730
738
  file = g_fopen (filename, "rt");
731
739
 
738
746
      return FALSE;
739
747
    }
740
748
 
741
 
  success = gimp_levels_config_load_cruft (tool->config, file, error);
 
749
  if (! fgets (header, sizeof (header), file))
 
750
    {
 
751
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
 
752
                   _("Could not read header from '%s': %s"),
 
753
                   gimp_filename_to_utf8 (filename),
 
754
                   g_strerror (errno));
 
755
      fclose (file);
 
756
      return FALSE;
 
757
    }
 
758
 
 
759
  if (g_str_has_prefix (header, "# GIMP Levels File\n"))
 
760
    {
 
761
      gboolean success;
 
762
 
 
763
      rewind (file);
 
764
 
 
765
      success = gimp_levels_config_load_cruft (tool->config, file, error);
 
766
 
 
767
      fclose (file);
 
768
 
 
769
      return success;
 
770
    }
742
771
 
743
772
  fclose (file);
744
773
 
745
 
  return success;
 
774
  return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_import (image_map_tool,
 
775
                                                                    filename,
 
776
                                                                    error);
746
777
}
747
778
 
748
779
static gboolean
751
782
                                  GError           **error)
752
783
{
753
784
  GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
754
 
  FILE           *file;
755
 
  gboolean        success;
756
 
 
757
 
  file = g_fopen (filename, "wt");
758
 
 
759
 
  if (! file)
 
785
 
 
786
  if (tool->export_old_format)
760
787
    {
761
 
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
762
 
                   _("Could not open '%s' for writing: %s"),
763
 
                   gimp_filename_to_utf8 (filename),
764
 
                   g_strerror (errno));
765
 
      return FALSE;
 
788
      FILE     *file;
 
789
      gboolean  success;
 
790
 
 
791
      file = g_fopen (filename, "wt");
 
792
 
 
793
      if (! file)
 
794
        {
 
795
          g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
 
796
                       _("Could not open '%s' for writing: %s"),
 
797
                       gimp_filename_to_utf8 (filename),
 
798
                       g_strerror (errno));
 
799
          return FALSE;
 
800
        }
 
801
 
 
802
      success = gimp_levels_config_save_cruft (tool->config, file, error);
 
803
 
 
804
      fclose (file);
 
805
 
 
806
      return success;
766
807
    }
767
808
 
768
 
  success = gimp_levels_config_save_cruft (tool->config, file, error);
769
 
 
770
 
  fclose (file);
771
 
 
772
 
  return success;
 
809
  return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_export (image_map_tool,
 
810
                                                                    filename,
 
811
                                                                    error);
 
812
}
 
813
 
 
814
static void
 
815
gimp_levels_tool_export_setup (GimpSettingsBox      *settings_box,
 
816
                               GtkFileChooserDialog *dialog,
 
817
                               gboolean              export,
 
818
                               GimpLevelsTool       *tool)
 
819
{
 
820
  GtkWidget *button;
 
821
 
 
822
  if (! export)
 
823
    return;
 
824
 
 
825
  button = gtk_check_button_new_with_mnemonic (_("Use _old levels file format"));
 
826
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
 
827
                                tool->export_old_format);
 
828
  gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), button);
 
829
  gtk_widget_show (button);
 
830
 
 
831
  g_signal_connect (button, "toggled",
 
832
                    G_CALLBACK (gimp_toggle_button_update),
 
833
                    &tool->export_old_format);
773
834
}
774
835
 
775
836
static void