+static void layout_menu_write_rotate(GtkToggleAction *action, gpointer data, gboolean keep_date)
+{
+ LayoutWindow *lw = data;
+ GtkTreeModel *store;
+ GList *work;
+ GtkTreeSelection *selection;
+ GtkTreePath *tpath;
+ FileData *fd_n;
+ GtkTreeIter iter;
+ IconData *id;
+ gchar *rotation;
+ gchar *command;
+ gint run_result;
+ GenericDialog *gd;
+ GString *message;
+
+ if (!layout_valid(&lw)) return;
+
+ if (!lw || !lw->vf) return;
+
+ if (lw->vf->type == FILEVIEW_ICON)
+ {
+ if (!VFICON(lw->vf)->selection) return;
+ work = VFICON(lw->vf)->selection;
+ }
+ else
+ {
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(lw->vf->listview));
+ work = gtk_tree_selection_get_selected_rows(selection, &store);
+ }
+
+ while (work)
+ {
+ if (lw->vf->type == FILEVIEW_ICON)
+ {
+ id = work->data;
+ fd_n = id->fd;
+ work = work->next;
+ }
+ else
+ {
+ tpath = work->data;
+ gtk_tree_model_get_iter(store, &iter, tpath);
+ gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd_n, -1);
+ work = work->next;
+ }
+
+ rotation = g_strdup_printf("%d", fd_n->user_orientation);
+ command = g_strconcat(GQ_BIN_DIR, "/geeqie-rotate -r ", rotation,
+ keep_date ? " -t " : " ", fd_n->path, NULL);
+
+ run_result = WEXITSTATUS(runcmd(command));
+ if (!run_result)
+ {
+ fd_n->user_orientation = 0;
+ }
+ else
+ {
+ message = g_string_new("");
+ message = g_string_append(message, _("Operation failed:\n"));
+
+ if (run_result == 3)
+ message = g_string_append(message, _("Cannot create tmp file"));
+ else
+ {
+ message = g_string_append(message, _("File: "));
+ message = g_string_append(message, fd_n->name);
+ }
+
+ gd = generic_dialog_new(_("Image orientation"),
+ "Image orientation", NULL, TRUE, NULL, NULL);
+ generic_dialog_add_message(gd, GTK_STOCK_DIALOG_ERROR,
+ "Image orientation", message->str);
+ generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, NULL, TRUE);
+
+ gtk_widget_show(gd->dialog);
+
+ g_string_free(message, TRUE);
+ }
+
+ g_free(rotation);
+ g_free(command);
+ }
+}
+
+static void layout_menu_write_rotate_keep_date_cb(GtkToggleAction *action, gpointer data)
+{
+ layout_menu_write_rotate(action, data, TRUE);
+}
+
+static void layout_menu_write_rotate_cb(GtkToggleAction *action, gpointer data)
+{
+ layout_menu_write_rotate(action, data, FALSE);
+}
+