summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-undo-manager.c
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2000-05-18 22:31:58 +0000
committerDarin Adler <darin@src.gnome.org>2000-05-18 22:31:58 +0000
commit7e7fc3ecf236e3a2ae3cb12d02bad11e04e27826 (patch)
treec0d8d4b1337836a317ae364cae412a8a16291c58 /libnautilus-private/nautilus-undo-manager.c
parent4b5995ac28e8ca8b6b23c1464c077f115b5af734 (diff)
downloadnautilus-7e7fc3ecf236e3a2ae3cb12d02bad11e04e27826.tar.gz
Change format to make popt "pop" out more.
* HACKING: Change format to make popt "pop" out more. * libnautilus-extensions/nautilus-entry.h: * src/file-manager/fm-properties-window.c: (create_basic_page): * src/nautilus-bookmarks-window.c: (on_text_field_focus_in_event), (on_window_delete_event): * src/nautilus-location-bar.c: (nautilus_location_bar_enable_undo): * src/nautilus-location-bar.h: * src/nautilus-window-menus.c: (edit_menu_undo_callback), (bookmarks_menu_add_bookmark_callback), (bookmarks_menu_edit_bookmarks_callback), (get_or_create_bookmarks_window), (nautilus_bookmarks_exiting), (edit_bookmarks), (nautilus_window_initialize_menus), (update_undo_menu_item): * src/ntl-app.c: (nautilus_app_init), (nautilus_app_destroy): * libnautilus-extensions/nautilus-icon-container.c: (nautilus_icon_container_start_renaming_selected_item): * libnautilus-extensions/nautilus-entry.c: (nautilus_entry_key_press), (nautilus_entry_enable_undo): * libnautilus/nautilus-undo-manager.c: (nautilus_undo_manager_begin_transaction), (nautilus_undo_manager_unregister_object), (prune_undo_manager_list), (nautilus_get_undo_manager), (nautilus_attach_undo_manager), (nautilus_share_undo_manager): * libnautilus/nautilus-undo-manager.h: * src/ntl-window-private.h: * src/ntl-window.c: (nautilus_window_constructed), (nautilus_window_real_set_content_view), (nautilus_window_get_undo_manager): * src/ntl-window.h: Got rid of the undo manager parameter for the enable_undo operation. Eliminated code that sets up the undo manager except for the top widgets. We only need it attached to windows and to the top widget in each component. Change callers to get the undo manager in a few simple ways instead of calling gtk_object_get_data directly. Added some calls to attach the undo manager to an arbitrary object. * libnautilus/nautilus-undo.idl: Added comments to the IDL and also added the Undo::Context class. * libnautilus/nautilus-view-component.idl: Removed the dependency on the undo IDL and the undo_manager attribute. * src/nautilus-bookmarks-window.h: * src/nautilus-bookmarks-window.c: (create_bookmarks_window): Changed interface to take object to inherit the undo manager from instead of the undo manager itself. Got rid of unnecesary undo manager setting. (nautilus_bookmarks_window_save_geometry): Also changed interface to use GtkWindow instead of GtkWidget.
Diffstat (limited to 'libnautilus-private/nautilus-undo-manager.c')
-rw-r--r--libnautilus-private/nautilus-undo-manager.c111
1 files changed, 102 insertions, 9 deletions
diff --git a/libnautilus-private/nautilus-undo-manager.c b/libnautilus-private/nautilus-undo-manager.c
index 97b1c0948..8a5dc6c6a 100644
--- a/libnautilus-private/nautilus-undo-manager.c
+++ b/libnautilus-private/nautilus-undo-manager.c
@@ -52,7 +52,6 @@ typedef struct {
NautilusUndoManager *gtk_object;
} impl_POA_Nautilus_Undo_Manager;
-
/* GtkObject */
static void nautilus_undo_manager_initialize_class (NautilusUndoManagerClass *class);
static void nautilus_undo_manager_initialize (NautilusUndoManager *item);
@@ -214,7 +213,6 @@ nautilus_undo_manager_initialize_class (NautilusUndoManagerClass *klass)
gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
}
-
/* nautilus_undo_manager_begin_transaction */
NautilusUndoTransactionInProgress *
nautilus_undo_manager_begin_transaction (GtkObject *object, const gchar *name)
@@ -222,9 +220,12 @@ nautilus_undo_manager_begin_transaction (GtkObject *object, const gchar *name)
NautilusUndoManager *manager;
NautilusUndoTransactionInProgress *tip;
- /* Locate undo manager */
- manager = gtk_object_get_data (object, NAUTILUS_UNDO_MANAGER_NAME);
- g_return_val_if_fail (manager != NULL, NULL);
+ /* Locate undo manager. */
+ /* FIXME: We can't get a pointer to the actual undo manager, so this
+ * needs to work through the CORBA interface to the undo manager.
+ */
+ manager = nautilus_get_undo_manager (object);
+ g_assert (manager != NULL);
/* We aren't handling nested transactions currently */
if (manager->details->transaction_in_progress) {
@@ -375,11 +376,17 @@ nautilus_undo_manager_unregister_object (GtkObject *object)
GList *list;
int index, length;
- success = FALSE;
+ /* FIXME: We can't get a pointer to the actual undo manager, so this
+ * needs to work through the CORBA interface to the undo manager.
+ * Also there's no reason to assume that this object will have the
+ * right one.
+ */
+ manager = nautilus_get_undo_manager (object);
+ if (manager == NULL) {
+ return FALSE;
+ }
- /* Locate undo manager */
- manager = gtk_object_get_data (object, NAUTILUS_UNDO_MANAGER_NAME);
- g_return_val_if_fail (manager != NULL, success);
+ success = FALSE;
/* Check undo list */
length = g_list_length (manager->details->undo_list);
@@ -631,3 +638,89 @@ prune_undo_manager_list (GList *list, gint items)
return list;
}
+
+/* FIXME: This should return a Nautilus_Undo_Manager in the long run.
+ * And it's more likely that we'll want this in the transaction code
+ * than in here so it will probably be moved.
+ */
+NautilusUndoManager *
+nautilus_get_undo_manager (GtkObject *start_object)
+{
+ NautilusUndoManager *manager;
+ GtkWidget *parent;
+ GtkWindow *transient_parent;
+
+ if (start_object == NULL) {
+ return NULL;
+ }
+
+ g_return_val_if_fail (GTK_IS_OBJECT (start_object), NULL);
+
+ /* Check for an undo manager right here. */
+ manager = gtk_object_get_data (start_object, "Nautilus undo");
+ if (manager != NULL) {
+ g_assert (NAUTILUS_IS_UNDO_MANAGER (manager));
+ return manager;
+ }
+
+ /* Check for undo manager up the parent chain. */
+ if (GTK_IS_WIDGET (start_object)) {
+ parent = GTK_WIDGET (start_object)->parent;
+ if (parent != NULL) {
+ manager = nautilus_get_undo_manager (GTK_OBJECT (parent));
+ if (manager != NULL) {
+ return manager;
+ }
+ }
+
+ /* Check for undo manager in our window's parent. */
+ if (GTK_IS_WINDOW (start_object)) {
+ transient_parent = GTK_WINDOW (start_object)->transient_parent;
+ manager = nautilus_get_undo_manager (GTK_OBJECT (transient_parent));
+ if (manager != NULL) {
+ return manager;
+ }
+ }
+ }
+
+ /* In the case of a canvas item, try the canvas. */
+ if (GNOME_IS_CANVAS_ITEM (start_object)) {
+ manager = nautilus_get_undo_manager (GTK_OBJECT (GNOME_CANVAS_ITEM (start_object)->canvas));
+ if (manager != NULL) {
+ return manager;
+ }
+ }
+
+ /* Found nothing. I can live with that. */
+ return NULL;
+}
+
+void
+nautilus_attach_undo_manager (GtkObject *object,
+ NautilusUndoManager *manager)
+{
+ g_return_if_fail (GTK_IS_OBJECT (object));
+
+ if (manager == NULL) {
+ gtk_object_remove_data (object, "Nautilus undo");
+ }
+
+ g_return_if_fail (NAUTILUS_IS_UNDO_MANAGER (manager));
+
+ bonobo_object_ref (BONOBO_OBJECT (manager));
+ gtk_object_set_data_full
+ (object, "Nautilus undo",
+ manager, (GtkDestroyNotify) bonobo_object_unref);
+}
+
+/* This is useful because nautilus_get_undo_manager will be
+ * private one day.
+ */
+void
+nautilus_share_undo_manager (GtkObject *destination_object,
+ GtkObject *source_object)
+{
+ nautilus_attach_undo_manager
+ (destination_object,
+ nautilus_get_undo_manager (source_object));
+}