Commit 19159e79 authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan

CVS:

2000-05-17  Gene Z. Ragan  <gzr@eazel.com>
											      CVS: ----------------------------------------------------------------------
	First phase of modifying undo code.  These changes				      CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
	affect the way undo is handled internally to Nautilus and			      CVS:
	also defines a new IDL.  This is work in progress.				      CVS: Committing in .
											      CVS:
	* libnautilus-extensions/nautilus-entry.c:					      CVS: Modified Files:
	Modified to use gtk_object_get_data() mechanism to locate undo manager		      CVS:    ChangeLog libnautilus/.cvsignore libnautilus/Makefile.am
											      CVS:    libnautilus/nautilus-undo-manager-private.h
	* libnautilus-extensions/nautilus-icon-container.c:				      CVS:    libnautilus/nautilus-undo-manager.c
	(nautilus_icon_container_start_renaming_selected_item): 			      CVS:    libnautilus/nautilus-undo-manager.h
	Modified to use gtk_object_get_data() mechanism to locate undo manager		      CVS:    libnautilus/nautilus-undo-transaction.h
											      CVS:    libnautilus/nautilus-undoable.c
	* libnautilus-extensions/nautilus-icon-text-item.c: (iti_event),		      CVS:    libnautilus/nautilus-undoable.h
	(restore_from_undo_snapshot_callback):						      CVS:    libnautilus/nautilus-view-component.idl
	Modified to use gtk_object_get_data() mechanism to locate undo manager		      CVS:    libnautilus-extensions/nautilus-entry.c
											      CVS:    libnautilus-extensions/nautilus-entry.h
	* libnautilus/.cvsignore:							      CVS:    libnautilus-extensions/nautilus-icon-container.c
	Added generated IDL source and header files to ignore				      CVS:    libnautilus-extensions/nautilus-icon-text-item.c
											      CVS:    src/nautilus-bookmarks-window.c
	* libnautilus/Makefile.am:							      CVS:    src/nautilus-bookmarks-window.h src/nautilus-location-bar.c
	Modified makefile to include new IDL file for undo manager			      CVS:    src/nautilus-location-bar.h src/nautilus-window-menus.c
											      CVS:    src/ntl-app.c src/ntl-window-private.h src/ntl-window.c
	* libnautilus/nautilus-undo-manager.c:						      CVS:    src/ntl-window.h src/file-manager/fm-properties-window.c
	(impl_Nautilus_Undo_Manager__destroy),						      CVS: Added Files:
	(impl_Nautilus_Undo_Manager__create),						      CVS:    libnautilus/nautilus-undo.idl
	(impl_Nautilus_Undo_Manager__append),						      CVS: Removed Files:
	(impl_Nautilus_Undo_Manager__forget),						      CVS:    libnautilus/nautilus-undo-manager-component.idl
	(nautilus_undo_manager_initialize),						      CVS: ----------------------------------------------------------------------
	(nautilus_undo_manager_initialize_class),
	(nautilus_undo_manager_begin_transaction),
	(nautilus_undo_manager_end_transaction),
	(nautilus_undo_manager_undo), (nautilus_undo_manager_redo),
	(nautilus_undo_manager_add_transaction),
	(nautilus_undo_manager_unregister_object),
	(nautilus_undo_manager_can_undo), (nautilus_undo_manager_can_redo),
	(get_current_transaction_name),
	(nautilus_undo_manager_get_current_undo_transaction_name),
	(nautilus_undo_manager_get_current_redo_transaction_name),
	(destroy), (nautilus_undo_manager_enable_redo),
	(nautilus_undo_manager_set_queue_depth),
	(free_undo_manager_list_data), (prune_undo_manager_list):
	Changes to support new IDL and new undo manager mechanism.

	* libnautilus/nautilus-undo.idl:
	New undo manager IDL file

	* libnautilus/nautilus-undo-manager-component.idl:
	Removed old undo manager IDL file

	* src/file-manager/fm-properties-window.c:
	(create_basic_page):
	Modified to use gtk_object_get_data() mechanism to locate undo manager

	* src/nautilus-bookmarks-window.c:
	(create_bookmarks_window),
	(on_text_field_focus_in_event),
	(on_window_delete_event):
	Modified to use gtk_object_get_data() mechanism to locate undo manager

	* src/nautilus-location-bar.c:
	(nautilus_location_bar_set_location),
	(nautilus_location_bar_enable_undo):
	Modified to use gtk_object_get_data() mechanism to locate undo manager

	* src/nautilus-window-menus.c:
	(edit_menu_undo_callback),
	(edit_menu_cut_callback),
	(bookmarks_menu_edit_bookmarks_callback),
	(get_bookmarks_window),
	(nautilus_bookmarks_exiting),
	(nautilus_window_edit_bookmarks),
	(nautilus_window_initialize_menus),
	(update_undo_menu_item):
	Modified to use gtk_object_get_data() mechanism to locate undo manager

	* src/ntl-app.c:
	(impl_Nautilus_Application__get_view_windows),
	(impl_Nautilus_Application_new_view_window),
	(impl_Nautilus_Application_supports),
	(impl_Nautilus_Application_create_object),
	(impl_Nautilus_Application__create), (nautilus_app_get_type),
	(nautilus_app_class_init), (nautilus_app_init), (nautilus_app_new),
	(nautilus_app_destroy), (nautilus_app_startup),
	(nautilus_app_create_window):
	Modified to use gtk_object_get_data() mechanism to locate undo manager.
	Added and modified IDL C stubs to match new IDL interface.

	* src/ntl-window.c:
	(nautilus_window_constructed),
	(nautilus_window_set_arg):
	Changed order that arguments are set at time of main window create so the app instance
	variable is valid when the main window is contructed.
parent 0cc8fb0b
2000-05-17 Gene Z. Ragan <gzr@eazel.com>
First phase of modifying undo code. These changes
affect the way undo is handled internally to Nautilus and
also defines a new IDL. This is work in progress.
* libnautilus-extensions/nautilus-entry.c:
Modified to use gtk_object_get_data() mechanism to locate undo manager
* libnautilus-extensions/nautilus-icon-container.c:
(nautilus_icon_container_start_renaming_selected_item):
Modified to use gtk_object_get_data() mechanism to locate undo manager
* libnautilus-extensions/nautilus-icon-text-item.c: (iti_event),
(restore_from_undo_snapshot_callback):
Modified to use gtk_object_get_data() mechanism to locate undo manager
* libnautilus/.cvsignore:
Added generated IDL source and header files to ignore
* libnautilus/Makefile.am:
Modified makefile to include new IDL file for undo manager
* libnautilus/nautilus-undo-manager.c:
(impl_Nautilus_Undo_Manager__destroy),
(impl_Nautilus_Undo_Manager__create),
(impl_Nautilus_Undo_Manager__append),
(impl_Nautilus_Undo_Manager__forget),
(nautilus_undo_manager_initialize),
(nautilus_undo_manager_initialize_class),
(nautilus_undo_manager_begin_transaction),
(nautilus_undo_manager_end_transaction),
(nautilus_undo_manager_undo), (nautilus_undo_manager_redo),
(nautilus_undo_manager_add_transaction),
(nautilus_undo_manager_unregister_object),
(nautilus_undo_manager_can_undo), (nautilus_undo_manager_can_redo),
(get_current_transaction_name),
(nautilus_undo_manager_get_current_undo_transaction_name),
(nautilus_undo_manager_get_current_redo_transaction_name),
(destroy), (nautilus_undo_manager_enable_redo),
(nautilus_undo_manager_set_queue_depth),
(free_undo_manager_list_data), (prune_undo_manager_list):
Changes to support new IDL and new undo manager mechanism.
* libnautilus/nautilus-undo.idl:
New undo manager IDL file
* libnautilus/nautilus-undo-manager-component.idl:
Removed old undo manager IDL file
* src/file-manager/fm-properties-window.c:
(create_basic_page):
Modified to use gtk_object_get_data() mechanism to locate undo manager
* src/nautilus-bookmarks-window.c:
(create_bookmarks_window),
(on_text_field_focus_in_event),
(on_window_delete_event):
Modified to use gtk_object_get_data() mechanism to locate undo manager
* src/nautilus-location-bar.c:
(nautilus_location_bar_set_location),
(nautilus_location_bar_enable_undo):
Modified to use gtk_object_get_data() mechanism to locate undo manager
* src/nautilus-window-menus.c:
(edit_menu_undo_callback),
(edit_menu_cut_callback),
(bookmarks_menu_edit_bookmarks_callback),
(get_bookmarks_window),
(nautilus_bookmarks_exiting),
(nautilus_window_edit_bookmarks),
(nautilus_window_initialize_menus),
(update_undo_menu_item):
Modified to use gtk_object_get_data() mechanism to locate undo manager
* src/ntl-app.c:
(impl_Nautilus_Application__get_view_windows),
(impl_Nautilus_Application_new_view_window),
(impl_Nautilus_Application_supports),
(impl_Nautilus_Application_create_object),
(impl_Nautilus_Application__create), (nautilus_app_get_type),
(nautilus_app_class_init), (nautilus_app_init), (nautilus_app_new),
(nautilus_app_destroy), (nautilus_app_startup),
(nautilus_app_create_window):
Modified to use gtk_object_get_data() mechanism to locate undo manager.
Added and modified IDL C stubs to match new IDL interface.
* src/ntl-window.c:
(nautilus_window_constructed),
(nautilus_window_set_arg):
Changed order that arguments are set at time of main window create so the app instance
variable is valid when the main window is contructed.
2000-05-17 J Shane Culpepper <pepper@eazel.com>
* components/services/install/command-line/eazel-install.c:
......
......@@ -28,7 +28,6 @@
#include "nautilus-entry.h"
#include "nautilus-gtk-macros.h"
#include <libnautilus/nautilus-undo-manager.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkmain.h>
......@@ -121,7 +120,10 @@ nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event)
case 'z':
if (event->state & GDK_CONTROL_MASK && entry->use_undo == TRUE
&& entry->handle_undo_key == TRUE) {
nautilus_undo_manager_undo_last_transaction();
NautilusUndoManager *undo_manager;
undo_manager = gtk_object_get_data ( GTK_OBJECT (entry), NAUTILUS_UNDO_MANAGER_NAME);
g_assert (undo_manager);
nautilus_undo_manager_undo (undo_manager);
return FALSE;
}
break;
......@@ -189,6 +191,7 @@ static void
nautilus_entry_changed (GtkEditable *editable)
{
NautilusEntry *entry;
NautilusUndoTransactionInProgress *tip;
g_assert (GTK_IS_EDITABLE (editable));
g_assert (NAUTILUS_IS_ENTRY (editable));
......@@ -197,10 +200,10 @@ nautilus_entry_changed (GtkEditable *editable)
/* Register undo transaction */
if (!entry->undo_registered && entry->use_undo) {
nautilus_undo_manager_begin_transaction (_("Edit"));
nautilus_undoable_save_undo_snapshot (GTK_OBJECT(entry), save_undo_snapshot_callback,
restore_from_undo_snapshot_callback);
nautilus_undo_manager_end_transaction ();
tip = nautilus_undo_manager_begin_transaction (GTK_OBJECT (entry), _("Edit"));
nautilus_undoable_save_undo_snapshot (tip->transaction, GTK_OBJECT(entry), save_undo_snapshot_callback,
restore_from_undo_snapshot_callback);
nautilus_undo_manager_end_transaction (tip);
entry->undo_registered = TRUE;
}
......@@ -270,15 +273,17 @@ restore_from_undo_snapshot_callback (NautilusUndoable *undoable)
* Enable undo mechanism in entry item.
*/
void
nautilus_entry_enable_undo (NautilusEntry *entry, gboolean value)
nautilus_entry_enable_undo (NautilusEntry *entry, NautilusUndoManager *manager, gboolean value)
{
g_assert (entry);
g_assert (NAUTILUS_IS_ENTRY (entry));
entry->undo_registered = !value;
entry->use_undo = value;
if (!entry->undo_registered) {
if (!entry->undo_registered) {
gtk_object_set_data ( GTK_OBJECT(entry), NAUTILUS_UNDO_MANAGER_NAME, manager);
/* Get copy of entry text */
if (entry->undo_text != NULL) {
g_free (entry->undo_text);
......
......@@ -29,6 +29,7 @@
#include <libgnome/gnome-defs.h>
#include <gtk/gtkentry.h>
#include <libnautilus/nautilus-undo-manager.h>
BEGIN_GNOME_DECLS
......@@ -48,7 +49,7 @@ typedef struct NautilusEntryClass NautilusEntryClass;
struct NautilusEntry {
GtkEntry parent;
gchar *undo_text;
gboolean undo_registered;
gboolean use_undo;
......@@ -59,13 +60,15 @@ struct NautilusEntryClass {
GtkEntryClass parent_class;
};
GtkType nautilus_entry_get_type (void);
GtkWidget* nautilus_entry_new (void);
GtkType nautilus_entry_get_type (void);
GtkWidget* nautilus_entry_new (void);
void nautilus_entry_select_all (NautilusEntry *entry);
void nautilus_entry_select_all_at_idle (NautilusEntry *entry);
void nautilus_entry_enable_undo (NautilusEntry *entry, gboolean value);
void nautilus_entry_enable_undo_key (NautilusEntry *entry, gboolean value);
void nautilus_entry_select_all (NautilusEntry *entry);
void nautilus_entry_select_all_at_idle (NautilusEntry *entry);
void nautilus_entry_enable_undo (NautilusEntry *entry,
NautilusUndoManager *manager,
gboolean value);
void nautilus_entry_enable_undo_key (NautilusEntry *entry, gboolean value);
END_GNOME_DECLS
......
......@@ -3453,6 +3453,8 @@ nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *con
{
NautilusIconContainerDetails *details;
NautilusIcon *icon;
GtkWidget *toplevel;
NautilusUndoManager *manager;
ArtIRect text_rect;
ArtDRect icon_rect;
GdkFont *font;
......@@ -3487,6 +3489,11 @@ nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *con
nautilus_icon_text_item_get_type (),
NULL));
/* Add undo manager */
toplevel = gtk_widget_get_toplevel ( GTK_WIDGET (container));
manager = gtk_object_get_data ( GTK_OBJECT (toplevel), NAUTILUS_UNDO_MANAGER_NAME);
gtk_object_set_data ( GTK_OBJECT (details->rename_widget), NAUTILUS_UNDO_MANAGER_NAME, manager);
/* Determine widget position widget in container */
font = details->label_font[details->zoom_level];
ppu = GNOME_CANVAS_ITEM (icon->item)->canvas->pixels_per_unit;
......
......@@ -20,6 +20,7 @@
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkwindow.h>
#include <libgnome/gnome-i18n.h>
/* Margins used to display the information */
#define MARGIN_X 2
......@@ -801,6 +802,8 @@ iti_event (GnomeCanvasItem *item, GdkEvent *event)
int idx;
double x, y;
int cx, cy;
NautilusUndoTransactionInProgress *tip;
iti = ITI (item);
priv = iti->priv;
......@@ -835,10 +838,10 @@ iti_event (GnomeCanvasItem *item, GdkEvent *event)
if (!priv->undo_registered) {
priv->undo_registered = TRUE;
nautilus_undo_manager_begin_transaction ("Rename");
nautilus_undoable_save_undo_snapshot (GTK_OBJECT(iti), save_undo_snapshot_callback,
restore_from_undo_snapshot_callback);
nautilus_undo_manager_end_transaction ();
tip = nautilus_undo_manager_begin_transaction ( GTK_OBJECT(iti), "Rename");
nautilus_undoable_save_undo_snapshot (tip->transaction, GTK_OBJECT(iti),
save_undo_snapshot_callback, restore_from_undo_snapshot_callback);
nautilus_undo_manager_end_transaction (tip);
}
/* Handle any events that reach us */
......@@ -1367,15 +1370,16 @@ restore_from_undo_snapshot_callback(NautilusUndoable *undoable)
char *undo_text;
NautilusIconTextItem *iti;
ItiPrivate *priv;
NautilusUndoTransactionInProgress *tip;
iti = NAUTILUS_ICON_TEXT_ITEM(undoable->undo_target_class);
priv = iti->priv;
/* Register undo transaction */
nautilus_undo_manager_begin_transaction ("Rename");
nautilus_undoable_save_undo_snapshot (GTK_OBJECT(iti), save_undo_snapshot_callback,
restore_from_undo_snapshot_callback);
nautilus_undo_manager_end_transaction ();
tip = nautilus_undo_manager_begin_transaction (GTK_OBJECT(iti), _("Rename"));
nautilus_undoable_save_undo_snapshot (tip->transaction, GTK_OBJECT(iti),
save_undo_snapshot_callback, restore_from_undo_snapshot_callback);
nautilus_undo_manager_end_transaction (tip);
undo_text = g_datalist_get_data(&undoable->undo_data, "undo_text");
if (undo_text != NULL) {
......
......@@ -26,9 +26,10 @@
#define NAUTILUS_UNDO_MANAGER_H
#include <bonobo/bonobo-object.h>
#include <libnautilus/nautilus-undo-manager-component.h>
#include <bonobo/bonobo-persist.h>
#include "nautilus-undo-transaction.h"
#include "nautilus-undo.h"
#define NAUTILUS_TYPE_UNDO_MANAGER \
(nautilus_undo_manager_get_type ())
......@@ -43,6 +44,7 @@
typedef struct NautilusUndoManagerClass NautilusUndoManagerClass;
typedef struct NautilusUndoManagerDetails NautilusUndoManagerDetails;
typedef struct NautilusUndoTransactionInProgress NautilusUndoTransactionInProgress;
struct NautilusUndoManager {
BonoboPersist parent;
......@@ -50,41 +52,44 @@ struct NautilusUndoManager {
};
struct NautilusUndoManagerClass {
BonoboPersistClass parent_class;
BonoboPersistClass parent_class;
void (* undo_transaction_occurred) (GtkObject *object, gpointer data);
gpointer servant_init_func, servant_destroy_func, vepv;
};
struct NautilusUndoTransactionInProgress {
NautilusUndoManager *manager;
NautilusUndoTransaction *transaction;
};
#define NAUTILUS_UNDO_MANAGER_NAME "NautilusUndoManager"
/* GtkObject */
GtkType nautilus_undo_manager_get_type (void);
NautilusUndoManager *nautilus_undo_manager_new (void);
GtkType nautilus_undo_manager_get_type (void);
NautilusUndoManager *nautilus_undo_manager_new (void);
/* Prototypes */
gboolean nautilus_undo_manager_initialize_global_manager (void);
gboolean nautilus_undo_manager_add_undoable_to_transaction (NautilusUndoable *undoable);
gboolean nautilus_undo_manager_begin_transaction (const gchar *name);
gboolean nautilus_undo_manager_end_transaction (void);
gboolean nautilus_undo_manager_undo_last_transaction (void);
gboolean nautilus_undo_manager_redo_last_undone_transaction (void);
NautilusUndoTransaction *nautilus_undo_manager_get_current_transaction (void);
gboolean nautilus_undo_manager_transaction_in_progress (void);
gboolean nautilus_undo_manager_add_undo_transaction (NautilusUndoTransaction
*transaction);
gboolean nautilus_undo_manager_add_redo_transaction (NautilusUndoTransaction
*transaction);
gboolean nautilus_undo_manager_remove_transaction (NautilusUndoTransaction
*transaction);
NautilusUndoTransactionInProgress *nautilus_undo_manager_begin_transaction (GtkObject *object, const gchar *name);
void nautilus_undo_manager_end_transaction (NautilusUndoTransactionInProgress *transaction);
void nautilus_undo_manager_undo (NautilusUndoManager *manager);
void nautilus_undo_manager_redo (NautilusUndoManager *manager);
void nautilus_undo_manager_add_transaction (NautilusUndoManager *manager,
NautilusUndoTransaction *transaction);
gboolean nautilus_undo_manager_can_undo (NautilusUndoManager *manager);
gboolean nautilus_undo_manager_can_redo (NautilusUndoManager *manager);
const gchar *nautilus_undo_manager_get_current_undo_transaction_name (NautilusUndoManager *manager);
const gchar *nautilus_undo_manager_get_current_redo_transaction_name (NautilusUndoManager *manager);
void nautilus_undo_manager_enable_redo (NautilusUndoManager *manager, gboolean value);
void nautilus_undo_manager_set_queue_depth (NautilusUndoManager *manager, gint depth);
gboolean nautilus_undo_manager_unregister_object (GtkObject *object);
gboolean nautilus_undo_manager_can_undo (void);
gboolean nautilus_undo_manager_can_redo (void);
gint nautilus_undo_manager_get_current_undo_transaction_name (gchar *name, gint max_length);
gint nautilus_undo_manager_get_current_redo_transaction_name (gchar *name, gint max_length);
NautilusUndoManager *nautilus_undo_manager_get_undo_manager (void);
gboolean nautilus_undo_manager_enable_redo (gboolean value);
gboolean nautilus_undo_manager_set_queue_depth (gint depth);
#endif
......@@ -28,7 +28,6 @@
#include "nautilus-entry.h"
#include "nautilus-gtk-macros.h"
#include <libnautilus/nautilus-undo-manager.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkmain.h>
......@@ -121,7 +120,10 @@ nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event)
case 'z':
if (event->state & GDK_CONTROL_MASK && entry->use_undo == TRUE
&& entry->handle_undo_key == TRUE) {
nautilus_undo_manager_undo_last_transaction();
NautilusUndoManager *undo_manager;
undo_manager = gtk_object_get_data ( GTK_OBJECT (entry), NAUTILUS_UNDO_MANAGER_NAME);
g_assert (undo_manager);
nautilus_undo_manager_undo (undo_manager);
return FALSE;
}
break;
......@@ -189,6 +191,7 @@ static void
nautilus_entry_changed (GtkEditable *editable)
{
NautilusEntry *entry;
NautilusUndoTransactionInProgress *tip;
g_assert (GTK_IS_EDITABLE (editable));
g_assert (NAUTILUS_IS_ENTRY (editable));
......@@ -197,10 +200,10 @@ nautilus_entry_changed (GtkEditable *editable)
/* Register undo transaction */
if (!entry->undo_registered && entry->use_undo) {
nautilus_undo_manager_begin_transaction (_("Edit"));
nautilus_undoable_save_undo_snapshot (GTK_OBJECT(entry), save_undo_snapshot_callback,
restore_from_undo_snapshot_callback);
nautilus_undo_manager_end_transaction ();
tip = nautilus_undo_manager_begin_transaction (GTK_OBJECT (entry), _("Edit"));
nautilus_undoable_save_undo_snapshot (tip->transaction, GTK_OBJECT(entry), save_undo_snapshot_callback,
restore_from_undo_snapshot_callback);
nautilus_undo_manager_end_transaction (tip);
entry->undo_registered = TRUE;
}
......@@ -270,15 +273,17 @@ restore_from_undo_snapshot_callback (NautilusUndoable *undoable)
* Enable undo mechanism in entry item.
*/
void
nautilus_entry_enable_undo (NautilusEntry *entry, gboolean value)
nautilus_entry_enable_undo (NautilusEntry *entry, NautilusUndoManager *manager, gboolean value)
{
g_assert (entry);
g_assert (NAUTILUS_IS_ENTRY (entry));
entry->undo_registered = !value;
entry->use_undo = value;
if (!entry->undo_registered) {
if (!entry->undo_registered) {
gtk_object_set_data ( GTK_OBJECT(entry), NAUTILUS_UNDO_MANAGER_NAME, manager);
/* Get copy of entry text */
if (entry->undo_text != NULL) {
g_free (entry->undo_text);
......
......@@ -29,6 +29,7 @@
#include <libgnome/gnome-defs.h>
#include <gtk/gtkentry.h>
#include <libnautilus/nautilus-undo-manager.h>
BEGIN_GNOME_DECLS
......@@ -48,7 +49,7 @@ typedef struct NautilusEntryClass NautilusEntryClass;
struct NautilusEntry {
GtkEntry parent;
gchar *undo_text;
gboolean undo_registered;
gboolean use_undo;
......@@ -59,13 +60,15 @@ struct NautilusEntryClass {
GtkEntryClass parent_class;
};
GtkType nautilus_entry_get_type (void);
GtkWidget* nautilus_entry_new (void);
GtkType nautilus_entry_get_type (void);
GtkWidget* nautilus_entry_new (void);
void nautilus_entry_select_all (NautilusEntry *entry);
void nautilus_entry_select_all_at_idle (NautilusEntry *entry);
void nautilus_entry_enable_undo (NautilusEntry *entry, gboolean value);
void nautilus_entry_enable_undo_key (NautilusEntry *entry, gboolean value);
void nautilus_entry_select_all (NautilusEntry *entry);
void nautilus_entry_select_all_at_idle (NautilusEntry *entry);
void nautilus_entry_enable_undo (NautilusEntry *entry,
NautilusUndoManager *manager,
gboolean value);
void nautilus_entry_enable_undo_key (NautilusEntry *entry, gboolean value);
END_GNOME_DECLS
......
......@@ -3453,6 +3453,8 @@ nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *con
{
NautilusIconContainerDetails *details;
NautilusIcon *icon;
GtkWidget *toplevel;
NautilusUndoManager *manager;
ArtIRect text_rect;
ArtDRect icon_rect;
GdkFont *font;
......@@ -3487,6 +3489,11 @@ nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *con
nautilus_icon_text_item_get_type (),
NULL));
/* Add undo manager */
toplevel = gtk_widget_get_toplevel ( GTK_WIDGET (container));
manager = gtk_object_get_data ( GTK_OBJECT (toplevel), NAUTILUS_UNDO_MANAGER_NAME);
gtk_object_set_data ( GTK_OBJECT (details->rename_widget), NAUTILUS_UNDO_MANAGER_NAME, manager);
/* Determine widget position widget in container */
font = details->label_font[details->zoom_level];
ppu = GNOME_CANVAS_ITEM (icon->item)->canvas->pixels_per_unit;
......
......@@ -20,6 +20,7 @@
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkwindow.h>
#include <libgnome/gnome-i18n.h>
/* Margins used to display the information */
#define MARGIN_X 2
......@@ -801,6 +802,8 @@ iti_event (GnomeCanvasItem *item, GdkEvent *event)
int idx;
double x, y;
int cx, cy;
NautilusUndoTransactionInProgress *tip;
iti = ITI (item);
priv = iti->priv;
......@@ -835,10 +838,10 @@ iti_event (GnomeCanvasItem *item, GdkEvent *event)
if (!priv->undo_registered) {
priv->undo_registered = TRUE;
nautilus_undo_manager_begin_transaction ("Rename");
nautilus_undoable_save_undo_snapshot (GTK_OBJECT(iti), save_undo_snapshot_callback,
restore_from_undo_snapshot_callback);
nautilus_undo_manager_end_transaction ();
tip = nautilus_undo_manager_begin_transaction ( GTK_OBJECT(iti), "Rename");
nautilus_undoable_save_undo_snapshot (tip->transaction, GTK_OBJECT(iti),
save_undo_snapshot_callback, restore_from_undo_snapshot_callback);
nautilus_undo_manager_end_transaction (tip);
}
/* Handle any events that reach us */
......@@ -1367,15 +1370,16 @@ restore_from_undo_snapshot_callback(NautilusUndoable *undoable)
char *undo_text;
NautilusIconTextItem *iti;
ItiPrivate *priv;
NautilusUndoTransactionInProgress *tip;
iti = NAUTILUS_ICON_TEXT_ITEM(undoable->undo_target_class);
priv = iti->priv;
/* Register undo transaction */
nautilus_undo_manager_begin_transaction ("Rename");
nautilus_undoable_save_undo_snapshot (GTK_OBJECT(iti), save_undo_snapshot_callback,
restore_from_undo_snapshot_callback);
nautilus_undo_manager_end_transaction ();
tip = nautilus_undo_manager_begin_transaction (GTK_OBJECT(iti), _("Rename"));
nautilus_undoable_save_undo_snapshot (tip->transaction, GTK_OBJECT(iti),
save_undo_snapshot_callback, restore_from_undo_snapshot_callback);
nautilus_undo_manager_end_transaction (tip);
undo_text = g_datalist_get_data(&undoable->undo_data, "undo_text");
if (undo_text != NULL) {
......
This diff is collapsed.
......@@ -26,9 +26,10 @@
#define NAUTILUS_UNDO_MANAGER_H
#include <bonobo/bonobo-object.h>
#include <libnautilus/nautilus-undo-manager-component.h>
#include <bonobo/bonobo-persist.h>
#include "nautilus-undo-transaction.h"
#include "nautilus-undo.h"
#define NAUTILUS_TYPE_UNDO_MANAGER \
(nautilus_undo_manager_get_type ())
......@@ -43,6 +44,7 @@
typedef struct NautilusUndoManagerClass NautilusUndoManagerClass;
typedef struct NautilusUndoManagerDetails NautilusUndoManagerDetails;
typedef struct NautilusUndoTransactionInProgress NautilusUndoTransactionInProgress;
struct NautilusUndoManager {
BonoboPersist parent;
......@@ -50,41 +52,44 @@ struct NautilusUndoManager {
};
struct NautilusUndoManagerClass {
BonoboPersistClass parent_class;
BonoboPersistClass parent_class;
void (* undo_transaction_occurred) (GtkObject *object, gpointer data);
gpointer servant_init_func, servant_destroy_func, vepv;
};
struct NautilusUndoTransactionInProgress {
NautilusUndoManager *manager;
NautilusUndoTransaction *transaction;
};
#define NAUTILUS_UNDO_MANAGER_NAME "NautilusUndoManager"
/* GtkObject */
GtkType nautilus_undo_manager_get_type (void);
NautilusUndoManager *nautilus_undo_manager_new (void);
GtkType nautilus_undo_manager_get_type (void);
NautilusUndoManager *nautilus_undo_manager_new (void);
/* Prototypes */
gboolean nautilus_undo_manager_initialize_global_manager (void);
gboolean nautilus_undo_manager_add_undoable_to_transaction (NautilusUndoable *undoable);
gboolean nautilus_undo_manager_begin_transaction (const gchar *name);
gboolean nautilus_undo_manager_end_transaction (void);
gboolean nautilus_undo_manager_undo_last_transaction (void);
gboolean nautilus_undo_manager_redo_last_undone_transaction (void);
NautilusUndoTransaction *nautilus_undo_manager_get_current_transaction (void);
gboolean nautilus_undo_manager_transaction_in_progress (void);
gboolean nautilus_undo_manager_add_undo_transaction (NautilusUndoTransaction
*transaction);
gboolean nautilus_undo_manager_add_redo_transaction (NautilusUndoTransaction
*transaction);
gboolean nautilus_undo_manager_remove_transaction (NautilusUndoTransaction
*transaction);
NautilusUndoTransactionInProgress *nautilus_undo_manager_begin_transaction (GtkObject *object, const gchar *name);
void nautilus_undo_manager_end_transaction (NautilusUndoTransactionInProgress *transaction);
void nautilus_undo_manager_undo (NautilusUndoManager *manager);
void nautilus_undo_manager_redo (NautilusUndoManager *manager);
void nautilus_undo_manager_add_transaction (NautilusUndoManager *manager,
NautilusUndoTransaction *transaction);
gboolean nautilus_undo_manager_can_undo (NautilusUndoManager *manager);
gboolean nautilus_undo_manager_can_redo (NautilusUndoManager *manager);
const gchar *nautilus_undo_manager_get_current_undo_transaction_name (NautilusUndoManager *manager);
const gchar *nautilus_undo_manager_get_current_redo_transaction_name (NautilusUndoManager *manager);
void nautilus_undo_manager_enable_redo (NautilusUndoManager *manager, gboolean value);
void nautilus_undo_manager_set_queue_depth (NautilusUndoManager *manager, gint depth);
gboolean nautilus_undo_manager_unregister_object (GtkObject *object);
gboolean nautilus_undo_manager_can_undo (void);
gboolean nautilus_undo_manager_can_redo (void);
gint nautilus_undo_manager_get_current_undo_transaction_name (gchar *name, gint max_length);
gint nautilus_undo_manager_get_current_redo_transaction_name (gchar *name, gint max_length);
NautilusUndoManager *nautilus_undo_manager_get_undo_manager (void);