/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */

/* nautilus-undo.idl - Interface for view components that
 *                     support undo, used internally by the
 *                     undo support classes.
 *
 * Copyright (C) 2000 Eazel, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef NAUTILUS_UNDO_IDL_INCLUDED
#define NAUTILUS_UNDO_IDL_INCLUDED

#include <Bonobo.idl>

module Nautilus {

	module Undo {

		/* The specifications for a menu item. */
		struct MenuItem {
			string label;
			string hint;
		};

		/* A single undoable operation is represented by a
		 * transaction.  This is the interface a transaction
		 * must supply for use by an undo manager.
		 */
		interface Transaction : ::Bonobo::Unknown {
			/* These menu items are used to display undo
			 * or redo menu items for this transaction.
			 * The operation name is for lists of undoable
			 * operations that are listed somewhere other
			 * than an undo or redo object.
			 */
			readonly attribute MenuItem undo_menu_item;
			readonly attribute MenuItem redo_menu_item;
			readonly attribute string operation_name;

			/* Here's how you actually perform an undo.
			 * Once it's performed, calling this again is
			 * safe; it's guaranteed to do nothing.
			 */
			void undo ();
		};

		/* An undo manager deals with a list of transactions
		 * for a particular application or window. This is the
		 * interface of the manager from the transaction's
		 * point of view only.
		 */
		interface Manager : ::Bonobo::Unknown {
			/* Add a new transaction. This is normally called
			 * by the code that creates the transaction.
			 */
			void append (in Transaction transaction);

			/* Forget a transaction. This is typically called
			 * when the operation that the transaction does
			 * undo for no longer makes sense.
			 */
			void forget (in Transaction transaction);

			/* Sometimes an undo has to be "forced" from the
			 * client side when it recognizes an undo key
			 * equivalent.
			 */
			void undo ();

			/* FIXME bugzilla.gnome.org 41292: 
			 * We may need additional interface so the
			 * client can include an appropriate undo item in
			 * a contextual menu.
			 */
		};

		/* To locate the appropriate manager, a view component
		 * can query for this interface on its Bonobo control
		 * frame.  This is done automatically by functions in
		 * the undo manager.
		 */
		interface Context : ::Bonobo::Unknown {
			readonly attribute Manager undo_manager;
		};
	};
};

#endif /* NAUTILUS_UNDO_IDL_INCLUDED */
