Index: NEWS
===================================================================
RCS file: /cvs/gnome/gthumb/NEWS,v
retrieving revision 1.72
diff -u -p -r1.72 NEWS
--- NEWS	1 Oct 2006 16:08:23 -0000	1.72
+++ NEWS	12 Oct 2006 12:33:11 -0000
@@ -1,3 +1,10 @@
+version 2.9.0
+-------------
+        * Added proper support for the Exif orientation tag when importing,
+          rotating, and displaying JPEG images. See bug #343867: Rotating image 
+          should alter EXIF data
+        * Fixed bug #361416: Reset Exif orientation tag tool
+
 version 2.7.9
 -------------
 	* Fixed bug #351058: build failure when -Wl,--as-needed is passed to 
Index: README
===================================================================
RCS file: /cvs/gnome/gthumb/README,v
retrieving revision 1.7
diff -u -p -r1.7 README
--- README	18 Oct 2004 14:21:36 -0000	1.7
+++ README	12 Oct 2006 12:33:11 -0000
@@ -9,7 +9,9 @@ Notes:
    they can be used even in the GNOME 2.2 environment but in this case
    gThumb and Nautilus do not share the thumbnails database. 
 
- * versions 2.2.0 and higher are for GNOME 2.2 and GNOME 2.4.
+ * versions 2.2.0 to 2.4.2 are for GNOME 2.2 and GNOME 2.4.
+
+ * versions 2.5 and higher are for GNOME 2.6.
 
  * more information about gthumb can be found at: 
    http://gthumb.sourceforge.net
@@ -82,33 +84,30 @@ Compiling
   version 2 or greater, with the development tools installed properly.  
   The following is the detailed list of libraries you need:
 
-	* glib	 		version >= 2.2.0
-	* gtk 			version >= 2.2.0 
+	* glib	 		version >= 2.6.0
+	* gtk 			version >= 2.8.0 
 	* libxml 		version >= 2.4.0
-	* libgnome 		version >= 2.2.0 
-	* libgnomeui 		version >= 2.2.0 
-	* libgnomecanvas 	version >= 2.0.0 
-	* gnome-vfs 		version >= 2.1.3 
-	* libglade 		version >= 2.0.0 
-	* libgnomeprint 	version >= 2.1.0
-	* libgnomeprintui 	version >= 2.1.0
-	* libbonobo 		version >= 2.3.3 
-	* libbonoboui 		version >= 2.3.3 
-
-  If you want to view EXIF data attached to images, you need the libexif 
-  library version >= 0.5.12 that can be found at this web site : 
-  http://libexif.sourceforge.net
+	* libgnome 		version >= 2.6.0 
+	* libgnomeui 		version >= 2.6.0 
+	* libgnomecanvas 	version >= 2.6.0 
+	* gnome-vfs 		version >= 2.6.0 
+	* libglade 		version >= 2.4.0 
+	* libgnomeprint 	version >= 2.6.0
+	* libgnomeprintui 	version >= 2.6.0
+	* libbonobo 		version >= 2.6.0 
+	* libbonoboui 		version >= 2.6.0
+	* libexif               version >= 0.6.9
+	* libjpeg
 
   If the libtiff library is present you can save images in TIFF
   format.
 
-  If the libjpeg library is present you have more saving options for
-  the JPEG format and the 'rotate jpeg' tool is implemented internally
-  otherwise it is implemented calling the external command: jpegtran.
-
   If the libgphoto2 library version >= 2.1.3 is present you can import 
   photos from your camera.
 
+  If the libiptc library version >= 0.2.1 is present you can store
+  comments in the IPTC metadata of a JPEG image.
+
 Download
 ========
 
@@ -122,4 +121,4 @@ Download
     cvs -d:pserver:anonymous@anoncvs.gnome.org:/cvs/gnome co gthumb
 
 
-17 December 2003
+11 October 2006
Index: data/glade/gthumb_tools.glade
===================================================================
RCS file: /cvs/gnome/gthumb/data/glade/gthumb_tools.glade,v
retrieving revision 1.21
diff -u -p -r1.21 gthumb_tools.glade
--- data/glade/gthumb_tools.glade	11 Oct 2006 16:42:59 -0000	1.21
+++ data/glade/gthumb_tools.glade	12 Oct 2006 12:33:17 -0000
@@ -3607,4 +3607,123 @@ Overwrite</property>
   </child>
 </widget>
 
+<widget class="GtkDialog" id="reset_exif_dialog">
+  <property name="border_width">6</property>
+  <property name="title" translatable="yes">Rotate Images</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="resizable">False</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
+  <property name="has_separator">False</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="vbox69">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">12</property>
+
+      <child internal-child="action_area">
+	<widget class="GtkHButtonBox" id="hbuttonbox1">
+	  <property name="visible">True</property>
+	  <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+	  <child>
+	    <widget class="GtkButton" id="x_help_button">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-help</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-11</property>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class="GtkButton" id="x_cancel_button">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="has_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="has_focus">True</property>
+	      <property name="label">gtk-close</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-7</property>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class="GtkButton" id="x_ok_button">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-apply</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-5</property>
+	    </widget>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">False</property>
+	  <property name="fill">True</property>
+	  <property name="pack_type">GTK_PACK_END</property>
+	</packing>
+      </child>
+
+      <child>
+	<widget class="GtkVBox" id="vbox70">
+	  <property name="border_width">5</property>
+	  <property name="visible">True</property>
+	  <property name="homogeneous">False</property>
+	  <property name="spacing">6</property>
+
+	  <child>
+	    <widget class="GtkLabel" id="label120">
+	      <property name="visible">True</property>
+	      <property name="label" translatable="yes">To reset the Exif orientation tag for the selected images to &quot;Top Left&quot;, click Apply.</property>
+	      <property name="use_underline">False</property>
+	      <property name="use_markup">True</property>
+	      <property name="justify">GTK_JUSTIFY_LEFT</property>
+	      <property name="wrap">True</property>
+	      <property name="selectable">False</property>
+	      <property name="xalign">0</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">0</property>
+	      <property name="ypad">0</property>
+	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+	      <property name="width_chars">-1</property>
+	      <property name="single_line_mode">False</property>
+	      <property name="angle">0</property>
+	    </widget>
+	    <packing>
+	      <property name="padding">0</property>
+	      <property name="expand">False</property>
+	      <property name="fill">False</property>
+	    </packing>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">True</property>
+	  <property name="fill">True</property>
+	</packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>
Index: doc/C/gthumb.xml
===================================================================
RCS file: /cvs/gnome/gthumb/doc/C/gthumb.xml,v
retrieving revision 1.26
diff -u -p -r1.26 gthumb.xml
--- doc/C/gthumb.xml	11 Oct 2006 16:43:00 -0000	1.26
+++ doc/C/gthumb.xml	12 Oct 2006 12:33:19 -0000
@@ -2044,6 +2044,26 @@
         the <guilabel>Apply physical transform</guilabel> checkbox is enabled.
       </para>
     </sect2>
+    <sect2 id="gthumb-reset-exif">
+      <title>Resetting the Exif Orientation Tag</title>
+      <para>
+        The previous section describes how JPEG images can be rotated using two
+        methods (physical transforms or Exif orientation tag changes). &app; supports
+        both methods properly as of version 2.9.0. Some previous versions
+        of &app; auto-rotated images improperly when importing, by performing
+        a physical transformation without resetting the Exif orientation tag
+        to "top-left". These previous versions ignored the orientation tag when
+        displaying the images, so no problem was apparent (although the problem
+        was visible if other image viewers were used to view the same images). 
+        Versions 2.9.0 and later respect this tag, so the incorrect rotation will be visible.
+      </para>
+      <para>
+        The <guilabel>Reset Exif orientation tag</guilabel> tool is provided to fix
+        this problem. Simply select the affected images, and apply the
+        <guilabel>Reset Exif orientation tag</guilabel> tool. This will reset
+        the Exif orientation tag to "top-left".
+      </para>
+    </sect2>
     <sect2 id="gthumb-convert-format">
       <title>To Convert the Image Format</title>
       <para>
Index: libgthumb/print-callbacks.c
===================================================================
RCS file: /cvs/gnome/gthumb/libgthumb/print-callbacks.c,v
retrieving revision 1.35
diff -u -p -r1.35 print-callbacks.c
--- libgthumb/print-callbacks.c	31 Aug 2006 18:49:37 -0000	1.35
+++ libgthumb/print-callbacks.c	12 Oct 2006 12:33:22 -0000
@@ -1253,8 +1253,6 @@ catalog_update_custom_page_size (PrintCa
 	height = gtk_spin_button_get_value (GTK_SPIN_BUTTON (data->height_spinbutton));
 	gnome_print_config_set_length (data->pci->config, UCHAR GNOME_PRINT_KEY_PAPER_WIDTH, width, unit);
 	gnome_print_config_set_length (data->pci->config, UCHAR GNOME_PRINT_KEY_PAPER_HEIGHT, height, unit);
-	gnome_print_config_set_length (data->pci->config, UCHAR GNOME_PRINT_KEY_LAYOUT_WIDTH, width, unit);
-	gnome_print_config_set_length (data->pci->config, UCHAR GNOME_PRINT_KEY_LAYOUT_HEIGHT, height, unit);
 
 	catalog_update_page (data);
 }
@@ -1386,8 +1384,6 @@ catalog_set_standard_page_size (PrintCat
 
 	gnome_print_config_set_length (data->pci->config, UCHAR GNOME_PRINT_KEY_PAPER_WIDTH, width, unit);
 	gnome_print_config_set_length (data->pci->config, UCHAR GNOME_PRINT_KEY_PAPER_HEIGHT, height, unit);
-	gnome_print_config_set_length (data->pci->config, UCHAR GNOME_PRINT_KEY_LAYOUT_WIDTH, width, unit);
-	gnome_print_config_set_length (data->pci->config, UCHAR GNOME_PRINT_KEY_LAYOUT_HEIGHT, height, unit);
 
 	catalog_update_page_size_from_config (data);
 	catalog_update_page (data);
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gnome/gthumb/src/Makefile.am,v
retrieving revision 1.40
diff -u -p -r1.40 Makefile.am
--- src/Makefile.am	8 Oct 2006 08:45:17 -0000	1.40
+++ src/Makefile.am	12 Oct 2006 12:33:22 -0000
@@ -77,6 +77,8 @@ gthumb_SOURCES = 				\
 	dlg-preferences.h			\
 	dlg-rename-series.c			\
 	dlg-rename-series.h			\
+        dlg-reset-exif.c                        \
+        dlg-reset-exif.h                        \
 	dlg-scale-image.c			\
 	dlg-scale-image.h			\
 	dlg-scale-series.c			\
Index: src/gth-browser-ui.h
===================================================================
RCS file: /cvs/gnome/gthumb/src/gth-browser-ui.h,v
retrieving revision 1.15
diff -u -p -r1.15 gth-browser-ui.h
--- src/gth-browser-ui.h	10 Oct 2006 20:29:27 -0000	1.15
+++ src/gth-browser-ui.h	12 Oct 2006 12:33:25 -0000
@@ -174,6 +174,7 @@ static const gchar *main_ui_info = 
 "      <menuitem action='Tools_ScaleSeries'/>"
 "      <menuitem action='Tools_ConvertFormat'/>"
 "      <menuitem action='Tools_ChangeDate'/>"
+"      <menuitem action='Tools_ResetExif'/>"
 "      <separator/>"
 "      <menuitem action='Tools_IndexImage'/>"
 "      <menuitem action='Tools_WebExporter'/>"
@@ -295,6 +296,7 @@ static const gchar *main_ui_info = 
 "  <popup name='RotateImageMenu'>"
 "    <menuitem action='Tools_JPEGRotate_Right'/>"
 "    <menuitem action='Tools_JPEGRotate_Left'/>"
+"    <menuitem action='Tools_ResetExif'/>"
 "  </popup>"
 "  <accelerator name='ControlEqualAccel' action='ControlEqual'/>"
 "</ui>";
Index: src/gth-browser.c
===================================================================
RCS file: /cvs/gnome/gthumb/src/gth-browser.c,v
retrieving revision 1.63
diff -u -p -r1.63 gth-browser.c
--- src/gth-browser.c	8 Oct 2006 08:45:16 -0000	1.63
+++ src/gth-browser.c	12 Oct 2006 12:33:31 -0000
@@ -960,6 +960,7 @@ window_update_sensitivity (GthBrowser *b
 	set_action_sensitive (browser, "Tools_WebExporter", sel_not_null);
 	set_action_sensitive (browser, "Tools_ConvertFormat", sel_not_null);
 	set_action_sensitive (browser, "Tools_ChangeDate", sel_not_null);
+	set_action_sensitive (browser, "Tools_ResetExif", sel_not_null);
 	set_action_sensitive (browser, "Tools_JPEGRotate", sel_not_null);
 	set_action_sensitive (browser, "Tools_ScaleSeries", sel_not_null);
 	set_action_sensitive (browser, "Wallpaper_Centered", ! image_is_void);
Index: src/gth-viewer-ui.h
===================================================================
RCS file: /cvs/gnome/gthumb/src/gth-viewer-ui.h,v
retrieving revision 1.12
diff -u -p -r1.12 gth-viewer-ui.h
--- src/gth-viewer-ui.h	10 Oct 2006 20:29:27 -0000	1.12
+++ src/gth-viewer-ui.h	12 Oct 2006 12:33:31 -0000
@@ -116,6 +116,7 @@ static const gchar *viewer_window_ui_inf
 "      <separator/>"
 "      <menuitem action='Tools_JPEGRotate'/>"
 "      <menuitem action='Tools_ChangeDate'/>"
+"      <menuitem action='Tools_ResetExif'/>"
 "    </menu>"
 "    <menu name='Help' action='HelpMenu'>"
 "      <menuitem action='Help_Help'/>"
@@ -154,6 +155,7 @@ static const gchar *viewer_window_ui_inf
 "  <popup name='RotateImageMenu'>"
 "    <menuitem action='Tools_JPEGRotate_Right'/>"
 "    <menuitem action='Tools_JPEGRotate_Left'/>"
+"    <menuitem action='Tools_ResetExif'/>"
 "  </popup>"
 "  <popup name='OpenWithMenu'>"
 "    <menuitem action='File_OpenFolder'/>"
Index: src/gth-window-actions-callbacks.c
===================================================================
RCS file: /cvs/gnome/gthumb/src/gth-window-actions-callbacks.c,v
retrieving revision 1.18
diff -u -p -r1.18 gth-window-actions-callbacks.c
--- src/gth-window-actions-callbacks.c	8 Oct 2006 08:45:14 -0000	1.18
+++ src/gth-window-actions-callbacks.c	12 Oct 2006 12:33:32 -0000
@@ -42,6 +42,7 @@
 #include "dlg-catalog.h"
 #include "dlg-categories.h"
 #include "dlg-change-date.h"
+#include "dlg-reset-exif.h"
 #include "dlg-comment.h"
 #include "dlg-convert.h"
 #include "dlg-file-utils.h"
@@ -870,6 +871,14 @@ gth_window_activate_action_tools_change_
 					      GthWindow *window)
 {
         dlg_change_date (window);
+}
+
+
+void
+gth_window_activate_action_tools_reset_exif (GtkAction *action,
+                                              GthWindow *window)
+{
+        dlg_reset_exif (window);
 }
 
 
Index: src/gth-window-actions-callbacks.h
===================================================================
RCS file: /cvs/gnome/gthumb/src/gth-window-actions-callbacks.h,v
retrieving revision 1.6
diff -u -p -r1.6 gth-window-actions-callbacks.h
--- src/gth-window-actions-callbacks.h	8 Oct 2006 08:45:16 -0000	1.6
+++ src/gth-window-actions-callbacks.h	12 Oct 2006 12:33:32 -0000
@@ -78,5 +78,6 @@ DEFINE_ACTION(gth_window_activate_action
 DEFINE_ACTION(gth_window_activate_action_tools_jpeg_rotate)
 DEFINE_ACTION(gth_window_activate_action_tools_jpeg_rotate_right)
 DEFINE_ACTION(gth_window_activate_action_tools_jpeg_rotate_left)
+DEFINE_ACTION(gth_window_activate_action_tools_reset_exif)
 
 #endif /* GTH_WINDOW_ACTIONS_CALLBACK_H */
Index: src/gth-window-actions-entries.h
===================================================================
RCS file: /cvs/gnome/gthumb/src/gth-window-actions-entries.h,v
retrieving revision 1.11
diff -u -p -r1.11 gth-window-actions-entries.h
--- src/gth-window-actions-entries.h	8 Oct 2006 08:45:17 -0000	1.11
+++ src/gth-window-actions-entries.h	12 Oct 2006 12:33:32 -0000
@@ -251,6 +251,11 @@ static GtkActionEntry gth_window_action_
 	  N_("Change images last modified date"),
 	  G_CALLBACK (gth_window_activate_action_tools_change_date) },
 
+        { "Tools_ResetExif", NULL,
+          N_("Reset Exif orientation"), NULL,
+          N_("Reset Exif orientation to top-left"),
+          G_CALLBACK (gth_window_activate_action_tools_reset_exif) },
+
 	{ "Tools_JPEGRotate", GTHUMB_STOCK_TRANSFORM,
 	  N_("Ro_tate Images"), NULL,
 	  N_("Rotate images without loss of quality"),
Index: src/main.c
===================================================================
RCS file: /cvs/gnome/gthumb/src/main.c,v
retrieving revision 1.52
diff -u -p -r1.52 main.c
--- src/main.c	13 Apr 2006 12:59:48 -0000	1.52
+++ src/main.c	12 Oct 2006 12:33:32 -0000
@@ -84,10 +84,10 @@ static GnomeIconTheme *icon_theme = NULL
 static BonoboObject   *gth_application = NULL;
 
 struct poptOption options[] = {
-	{ "fullscreen", '\0', POPT_ARG_NONE, &StartInFullscreen, 0,
+	{ "fullscreen", 'f', POPT_ARG_NONE, &StartInFullscreen, 0,
 	  N_("Start in fullscreen mode"),
 	  0 },
-	{ "slideshow", '\0', POPT_ARG_NONE, &StartSlideshow, 0,
+	{ "slideshow", 's', POPT_ARG_NONE, &StartSlideshow, 0,
 	  N_("Automatically start a slideshow"),
 	  0 },
 	{ "import-photos", '\0', POPT_ARG_NONE, &ImportPhotos, 0,
--- src/dlg-reset-exif.h	1969-12-31 19:00:00.000000000 -0500
+++ src/dlg-reset-exif.h	2006-10-11 15:47:31.000000000 -0400
@@ -0,0 +1,32 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  GThumb
+ *
+ *  Copyright (C) 2001 The Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef DLG_RESET_EXIF_H
+#define DLG_RESET_EXIF_H
+
+#include "gth-window.h"
+
+
+void dlg_reset_exif (GthWindow *window); 
+
+
+#endif /* DLG_RESET_EXIF_H */
--- src/dlg-reset-exif.c	1969-12-31 19:00:00.000000000 -0500
+++ src/dlg-reset-exif.c	2006-10-12 08:15:26.000000000 -0400
@@ -0,0 +1,329 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  GThumb
+ *
+ *  Copyright (C) 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <libgnome/gnome-help.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
+#include <glade/glade.h>
+
+#include "file-utils.h"
+#include "gth-window.h"
+#include "gtk-utils.h"
+#include "main.h"
+#include "gthumb-stock.h"
+#include "rotation-utils.h"
+
+
+#define RESET_GLADE_FILE "gthumb_tools.glade"
+#define PROGRESS_GLADE_FILE "gthumb_png_exporter.glade"
+
+
+typedef struct {
+	GthWindow    *window;
+	GladeXML     *gui;
+
+	GtkWidget    *dialog;
+	GList        *file_list;
+	GList        *files_changed_list;
+	GList        *current_image;
+} DialogData;
+
+
+static void
+dialog_data_free (DialogData *data)
+{
+	if (data->files_changed_list != NULL) {
+		all_windows_notify_files_changed (data->files_changed_list);
+		path_list_free (data->files_changed_list);
+		data->files_changed_list = NULL;
+	}
+
+	all_windows_add_monitor ();
+
+	path_list_free (data->file_list);
+	if (data->gui != NULL)
+		g_object_unref (data->gui);
+	g_free (data);
+}
+
+
+/* called when the main dialog is closed. */
+static void
+destroy_cb (GtkWidget  *widget, 
+	    DialogData *data)
+{
+	dialog_data_free (data);
+}
+
+
+static void
+notify_file_changed (DialogData *data,
+		     const char *filename,
+		     gboolean    notify_soon)
+{
+	if (notify_soon) {
+		GList *list = g_list_prepend (NULL, (char*) filename);
+		all_windows_notify_files_changed (list);
+		g_list_free (list);
+	} else 
+		data->files_changed_list = g_list_prepend (data->files_changed_list, g_strdup (filename));
+}
+
+
+
+static void
+apply_transformation (DialogData *data,
+		      GList      *current_image,
+		      gboolean    notify_soon)
+{
+	char             *path = current_image->data;
+	char             *dir;
+	GnomeVFSFileInfo  info;
+	GtkWindow  	 *window = GTK_WINDOW (data->dialog);
+	gint		  width = 0;
+	gint		  height = 0;
+	
+	/* Check directory permissions. */
+
+	dir = remove_level_from_path (path);
+	if (! check_permissions (dir, R_OK | W_OK | X_OK)) {
+		char *utf8_path = g_filename_display_name (dir);
+		_gtk_error_dialog_run (GTK_WINDOW (data->dialog),
+				       _("You don't have the right permissions to create images in the folder \"%s\""),
+				       utf8_path);
+		g_free (utf8_path);
+		g_free (dir);
+		return;
+	} 
+	g_free (dir);
+
+	gnome_vfs_get_file_info (path, &info, GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS|GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
+	reset_orientation_field (path);
+
+	gnome_vfs_set_file_info (path, &info, GNOME_VFS_SET_FILE_INFO_PERMISSIONS|GNOME_VFS_SET_FILE_INFO_OWNER);
+
+	notify_file_changed (data, path, notify_soon);
+}
+
+
+static void
+apply_transformation_to_all (DialogData *data)
+{
+	GladeXML  *gui;
+	GtkWidget *dialog;
+	GtkWidget *label;
+	GtkWidget *bar;
+	GList     *scan;
+	int        i, n;
+
+	gui = glade_xml_new (GTHUMB_GLADEDIR "/" PROGRESS_GLADE_FILE, 
+			     NULL,
+			     NULL);
+
+	dialog = glade_xml_get_widget (gui, "progress_dialog");
+	label = glade_xml_get_widget (gui, "progress_info");
+	bar = glade_xml_get_widget (gui, "progress_progressbar");
+
+	n = g_list_length (data->current_image);
+
+	if (data->dialog == NULL)
+		gtk_window_set_transient_for (GTK_WINDOW (dialog),
+					      GTK_WINDOW (data->window));
+	else {
+		gtk_window_set_modal (GTK_WINDOW (data->dialog), FALSE); 
+		gtk_window_set_transient_for (GTK_WINDOW (dialog),
+					      GTK_WINDOW (data->dialog));
+	}
+	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); 
+	gtk_widget_show (dialog);
+
+	while (gtk_events_pending())
+		gtk_main_iteration();
+
+	i = 0;
+	for (scan = data->current_image; scan; scan = scan->next) {
+		char *path = scan->data;
+		char *name;
+
+		name = g_filename_display_basename (path);
+		_gtk_label_set_filename_text (GTK_LABEL (label), name);
+		g_free (name);
+
+		gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar),
+					       (gdouble) (i + 0.5) / n);
+		
+		while (gtk_events_pending())
+			gtk_main_iteration();
+		
+		apply_transformation (data, scan, FALSE);
+		i++;
+	}
+	
+	gtk_widget_destroy (dialog);
+	g_object_unref (gui);
+
+	if (data->dialog == NULL)
+		dialog_data_free (data);
+	else
+		gtk_widget_destroy (data->dialog);
+}
+
+
+static void
+ok_clicked (GtkWidget  *button, 
+	    DialogData *data)
+{
+	gtk_widget_hide (data->dialog);
+	apply_transformation_to_all (data);
+}
+
+
+/* called when the "help" button is clicked. */
+static void
+help_cb (GtkWidget  *widget, 
+	 DialogData *data)
+{
+	GError *err;
+
+	err = NULL;  
+	gnome_help_display ("gthumb", "gthumb-reset-exif", &err);
+	
+	if (err != NULL) {
+		GtkWidget *dialog;
+		
+		dialog = gtk_message_dialog_new (GTK_WINDOW (data->dialog),
+						 0,
+						 GTK_MESSAGE_ERROR,
+						 GTK_BUTTONS_CLOSE,
+						 _("Could not display help: %s"),
+						 err->message);
+		
+		g_signal_connect (G_OBJECT (dialog), "response",
+				  G_CALLBACK (gtk_widget_destroy),
+				  NULL);
+		
+		gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+		
+		gtk_widget_show (dialog);
+		
+		g_error_free (err);
+	}
+}
+
+
+void
+dlg_reset_exif (GthWindow *window)
+{
+	DialogData  *data;
+	GtkWidget   *x_help_button;
+	GtkWidget   *x_cancel_button;
+	GtkWidget   *x_ok_button;
+	GList       *list;
+
+
+	list = gth_window_get_file_list_selection (window);
+	if (list == NULL) {
+		g_warning ("No file selected.");
+		return;
+	}
+
+	data = g_new0 (DialogData, 1);
+
+	data->window = window;
+	data->file_list = list;
+	data->current_image = list;
+	data->gui = glade_xml_new (GTHUMB_GLADEDIR "/" RESET_GLADE_FILE, NULL,
+				   NULL);
+
+	if (! data->gui) {
+		g_warning ("Could not find " RESET_GLADE_FILE "\n");
+		if (data->file_list != NULL) 
+			path_list_free (data->file_list);
+		g_free (data);
+		return;
+	}
+
+	data->dialog = glade_xml_get_widget (data->gui, "reset_exif_dialog");
+	x_help_button = glade_xml_get_widget (data->gui, "x_help_button");
+	x_cancel_button = glade_xml_get_widget (data->gui, "x_cancel_button");
+	x_ok_button = glade_xml_get_widget (data->gui, "x_ok_button");
+
+	/* Set the signals handlers. */
+
+	g_signal_connect (G_OBJECT (data->dialog),
+			  "destroy",
+			  G_CALLBACK (destroy_cb),
+			  data);
+
+	g_signal_connect_swapped (G_OBJECT (x_cancel_button), 
+				  "clicked",
+				  G_CALLBACK (gtk_widget_destroy),
+				  G_OBJECT (data->dialog));
+	g_signal_connect (G_OBJECT (x_help_button), 
+			  "clicked",
+			  G_CALLBACK (help_cb),
+			  data);
+	g_signal_connect (G_OBJECT (x_ok_button), 
+			  "clicked",
+			  G_CALLBACK (ok_clicked),
+			  data);
+
+	/* Run dialog. */
+
+	all_windows_remove_monitor ();
+
+	gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (window));
+	gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE); 
+	gtk_widget_show_all (data->dialog);
+}
+
+
+void
+dlg_apply_reset_exif (GthWindow    *window,
+		    GthTransform  rot_type,
+		    GthTransform  tran_type)
+{
+	DialogData  *data;
+	GList       *list;
+
+	list = gth_window_get_file_list_selection (window);
+	if (list == NULL) {
+		g_warning ("No file selected.");
+		return;
+	}
+
+	all_windows_remove_monitor ();
+
+	data = g_new0 (DialogData, 1);
+	data->window = window;
+	data->file_list = list;
+	data->current_image = list;
+
+	apply_transformation_to_all (data);
+}
