diff options
author | Stefano Karapetsas <[email protected]> | 2012-09-06 23:34:12 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2012-09-06 23:34:12 +0200 |
commit | 278df62878f2981dea980c5f48e791e047b9d5f1 (patch) | |
tree | 3a3bcc3a2360d9fd16adc44821b2343085247858 | |
parent | f426641aacea9d5f7683be776536bc6301c7baef (diff) | |
download | caja-278df62878f2981dea980c5f48e791e047b9d5f1.tar.bz2 caja-278df62878f2981dea980c5f48e791e047b9d5f1.tar.xz |
remove old undo code
24 files changed, 19 insertions, 1635 deletions
diff --git a/libcaja-private/Makefile.am b/libcaja-private/Makefile.am index da22bd94..6d1c343d 100644 --- a/libcaja-private/Makefile.am +++ b/libcaja-private/Makefile.am @@ -180,15 +180,6 @@ libcaja_private_la_SOURCES = \ caja-tree-view-drag-dest.h \ caja-ui-utilities.c \ caja-ui-utilities.h \ - caja-undo-manager.c \ - caja-undo-manager.h \ - caja-undo-private.h \ - caja-undo-signal-handlers.c \ - caja-undo-signal-handlers.h \ - caja-undo-transaction.c \ - caja-undo-transaction.h \ - caja-undo.c \ - caja-undo.h \ caja-users-groups-cache.c \ caja-users-groups-cache.h \ caja-vfs-directory.c \ diff --git a/libcaja-private/caja-entry.c b/libcaja-private/caja-entry.c index 5e34c84e..31b590c3 100644 --- a/libcaja-private/caja-entry.c +++ b/libcaja-private/caja-entry.c @@ -29,7 +29,6 @@ #include <string.h> #include "caja-global-preferences.h" -#include "caja-undo-signal-handlers.h" #include <eel/eel-gdk-extensions.h> #include <eel/eel-gtk-macros.h> #include <gdk/gdkkeysyms.h> @@ -69,8 +68,6 @@ caja_entry_init (CajaEntry *entry) entry->details = g_new0 (CajaEntryDetails, 1); entry->details->user_edit = TRUE; - - caja_undo_set_up_caja_entry_for_undo (entry); } GtkWidget * diff --git a/libcaja-private/caja-undo-manager.c b/libcaja-private/caja-undo-manager.c deleted file mode 100644 index 8f999dd0..00000000 --- a/libcaja-private/caja-undo-manager.c +++ /dev/null @@ -1,320 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* CajaUndoManager - Undo/Redo transaction manager. - * - * Copyright (C) 2000 Eazel, Inc. - * - * Author: Gene Z. Ragan <[email protected]> - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <config.h> -#include <libcaja-private/caja-undo-manager.h> -#include <libcaja-private/caja-undo-transaction.h> - -#include <eel/eel-gtk-macros.h> -#include <eel/eel-gtk-extensions.h> -#include <gtk/gtk.h> -#include "caja-undo-private.h" - -struct CajaUndoManagerDetails -{ - CajaUndoTransaction *transaction; - - /* These are used to tell undo from redo. */ - gboolean current_transaction_is_redo; - gboolean new_transaction_is_redo; - - /* These are used only so that we can complain if we get more - * than one transaction inside undo. - */ - gboolean undo_in_progress; - int num_transactions_during_undo; -}; - -enum -{ - CHANGED, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL]; - -typedef struct -{ -#ifdef UIH - MateComponentUIHandler *handler; -#endif /* UIH */ - char *path; - char *no_undo_menu_item_label; - char *no_undo_menu_item_hint; -} UndoMenuHandlerConnection; - -G_DEFINE_TYPE (CajaUndoManager, - caja_undo_manager, - G_TYPE_OBJECT) - -static void -release_transaction (CajaUndoManager *manager) -{ - CajaUndoTransaction *transaction; - - transaction = manager->details->transaction; - manager->details->transaction = NULL; - if (transaction != NULL) - { - g_object_unref (transaction); - } -} - -void -caja_undo_manager_append (CajaUndoManager *manager, - CajaUndoTransaction *transaction) -{ - CajaUndoTransaction *duplicate_transaction; - - /* Check, complain, and ignore the passed-in transaction if we - * get more than one within a single undo operation. The single - * transaction we get during the undo operation is supposed to - * be the one for redoing the undo (or re-undoing the redo). - */ - if (manager->details->undo_in_progress) - { - manager->details->num_transactions_during_undo += 1; - g_return_if_fail (manager->details->num_transactions_during_undo == 1); - } - - g_return_if_fail (transaction != NULL); - - /* Keep a copy of this transaction (dump the old one). */ - duplicate_transaction = g_object_ref (transaction); - release_transaction (manager); - manager->details->transaction = duplicate_transaction; - manager->details->current_transaction_is_redo = - manager->details->new_transaction_is_redo; - - /* Fire off signal indicating that the undo state has changed. */ - g_signal_emit (manager, signals[CHANGED], 0); -} - -void -caja_undo_manager_forget (CajaUndoManager *manager, - CajaUndoTransaction *transaction) -{ - /* Nothing to forget unless the item we are passed is the - * transaction we are currently holding. - */ - if (transaction != manager->details->transaction) - { - return; - } - - /* Get rid of the transaction we are holding on to. */ - release_transaction (manager); - - /* Fire off signal indicating that the undo state has changed. */ - g_signal_emit (manager, signals[CHANGED], 0); -} - -CajaUndoManager * -caja_undo_manager_new (void) -{ - return CAJA_UNDO_MANAGER (g_object_new (caja_undo_manager_get_type (), NULL)); -} - -static void -caja_undo_manager_init (CajaUndoManager *manager) -{ - manager->details = g_new0 (CajaUndoManagerDetails, 1); -} - -void -caja_undo_manager_undo (CajaUndoManager *manager) -{ - CajaUndoTransaction *transaction; - - g_return_if_fail (CAJA_IS_UNDO_MANAGER (manager)); - - transaction = manager->details->transaction; - manager->details->transaction = NULL; - if (transaction != NULL) - { - /* Perform the undo. New transactions that come in - * during an undo are redo transactions. New - * transactions that come in during a redo are undo - * transactions. Transactions that come in outside - * are always undo and never redo. - */ - manager->details->new_transaction_is_redo = - !manager->details->current_transaction_is_redo; - manager->details->undo_in_progress = TRUE; - manager->details->num_transactions_during_undo = 0; - caja_undo_transaction_undo (transaction); - manager->details->undo_in_progress = FALSE; - manager->details->new_transaction_is_redo = FALSE; - - /* Let go of the transaction. */ - g_object_unref (transaction); - - /* Fire off signal indicating the undo state has changed. */ - g_signal_emit (manager, signals[CHANGED], 0); - } -} - -static void -finalize (GObject *object) -{ - CajaUndoManager *manager; - - manager = CAJA_UNDO_MANAGER (object); - - release_transaction (manager); - - g_free (manager->details); - - if (G_OBJECT_CLASS (caja_undo_manager_parent_class)->finalize) - { - (* G_OBJECT_CLASS (caja_undo_manager_parent_class)->finalize) (object); - } -} - -void -caja_undo_manager_attach (CajaUndoManager *manager, GObject *target) -{ - g_return_if_fail (CAJA_IS_UNDO_MANAGER (manager)); - g_return_if_fail (G_IS_OBJECT (target)); - - caja_undo_attach_undo_manager (G_OBJECT (target), manager); -} - -#ifdef UIH -static void -update_undo_menu_item (CajaUndoManager *manager, - UndoMenuHandlerConnection *connection) -{ - CORBA_Environment ev; - Caja_Undo_MenuItem *menu_item; - - g_assert (CAJA_IS_UNDO_MANAGER (manager)); - g_assert (connection != NULL); - g_assert (MATECOMPONENT_IS_UI_HANDLER (connection->handler)); - g_assert (connection->path != NULL); - g_assert (connection->no_undo_menu_item_label != NULL); - g_assert (connection->no_undo_menu_item_hint != NULL); - - CORBA_exception_init (&ev); - - if (CORBA_Object_is_nil (manager->details->transaction, &ev)) - { - menu_item = NULL; - } - else - { - if (manager->details->current_transaction_is_redo) - { - menu_item = Caja_Undo_Transaction__get_redo_menu_item - (manager->details->transaction, &ev); - } - else - { - menu_item = Caja_Undo_Transaction__get_undo_menu_item - (manager->details->transaction, &ev); - } - } - - matecomponent_ui_handler_menu_set_sensitivity - (connection->handler, connection->path, - menu_item != NULL); - matecomponent_ui_handler_menu_set_label - (connection->handler, connection->path, - menu_item == NULL - ? connection->no_undo_menu_item_label - : menu_item->label); - matecomponent_ui_handler_menu_set_hint - (connection->handler, connection->path, - menu_item == NULL - ? connection->no_undo_menu_item_hint - : menu_item->hint); - - CORBA_free (menu_item); - - CORBA_exception_free (&ev); -} - -static void -undo_menu_handler_connection_free (UndoMenuHandlerConnection *connection) -{ - g_assert (connection != NULL); - g_assert (MATECOMPONENT_IS_UI_HANDLER (connection->handler)); - g_assert (connection->path != NULL); - g_assert (connection->no_undo_menu_item_label != NULL); - g_assert (connection->no_undo_menu_item_hint != NULL); - - g_free (connection->path); - g_free (connection->no_undo_menu_item_label); - g_free (connection->no_undo_menu_item_hint); - g_free (connection); -} - -static void -undo_menu_handler_connection_free_cover (gpointer data) -{ - undo_menu_handler_connection_free (data); -} - -void -caja_undo_manager_set_up_matecomponent_ui_handler_undo_item (CajaUndoManager *manager, - MateComponentUIHandler *handler, - const char *path, - const char *no_undo_menu_item_label, - const char *no_undo_menu_item_hint) -{ - UndoMenuHandlerConnection *connection; - - connection = g_new (UndoMenuHandlerConnection, 1); - connection->handler = handler; - connection->path = g_strdup (path); - connection->no_undo_menu_item_label = g_strdup (no_undo_menu_item_label); - connection->no_undo_menu_item_hint = g_strdup (no_undo_menu_item_hint); - - /* Set initial state of menu item. */ - update_undo_menu_item (manager, connection); - - /* Update it again whenever the changed signal is emitted. */ - eel_gtk_signal_connect_full_while_alive - (GTK_OBJECT (manager), "changed", - G_CALLBACK (update_undo_menu_item), NULL, - connection, undo_menu_handler_connection_free_cover, - FALSE, FALSE, - GTK_OBJECT (handler)); -} -#endif /* UIH */ - -static void -caja_undo_manager_class_init (CajaUndoManagerClass *class) -{ - G_OBJECT_CLASS (class)->finalize = finalize; - - signals[CHANGED] = g_signal_new - ("changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CajaUndoManagerClass, - changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} diff --git a/libcaja-private/caja-undo-manager.h b/libcaja-private/caja-undo-manager.h deleted file mode 100644 index e6541325..00000000 --- a/libcaja-private/caja-undo-manager.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* CajaUndoManager - Manages undo and redo transactions. - * This is the public interface used by the application. - * - * Copyright (C) 2000 Eazel, Inc. - * - * Author: Gene Z. Ragan <[email protected]> - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef CAJA_UNDO_MANAGER_H -#define CAJA_UNDO_MANAGER_H - -#include <libcaja-private/caja-undo.h> - -#define CAJA_TYPE_UNDO_MANAGER caja_undo_manager_get_type() -#define CAJA_UNDO_MANAGER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_UNDO_MANAGER, CajaUndoManager)) -#define CAJA_UNDO_MANAGER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_UNDO_MANAGER, CajaUndoManagerClass)) -#define CAJA_IS_UNDO_MANAGER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAJA_TYPE_UNDO_MANAGER)) -#define CAJA_IS_UNDO_MANAGER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), CAJA_TYPE_UNDO_MANAGER)) -#define CAJA_UNDO_MANAGER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), CAJA_TYPE_UNDO_MANAGER, CajaUndoManagerClass)) - -typedef struct CajaUndoManagerDetails CajaUndoManagerDetails; - -typedef struct -{ - GObject parent; - CajaUndoManagerDetails *details; -} CajaUndoManager; - -typedef struct -{ - GObjectClass parent_slot; - void (* changed) (GObject *object, gpointer data); -} CajaUndoManagerClass; - -GType caja_undo_manager_get_type (void); -CajaUndoManager *caja_undo_manager_new (void); - -/* Undo operations. */ -void caja_undo_manager_undo (CajaUndoManager *undo_manager); - -#ifdef UIH -/* Connect the manager to a particular menu item. */ -void caja_undo_manager_set_up_matecomponent_ui_handler_undo_item (CajaUndoManager *manager, - MateComponentUIHandler *handler, - const char *path, - const char *no_undo_menu_item_label, - const char *no_undo_menu_item_hint); - -#endif - -/* Attach the undo manager to a Gtk object so that object and the widgets inside it can participate in undo. */ -void caja_undo_manager_attach (CajaUndoManager *manager, - GObject *object); - -void caja_undo_manager_append (CajaUndoManager *manager, - CajaUndoTransaction *transaction); -void caja_undo_manager_forget (CajaUndoManager *manager, - CajaUndoTransaction *transaction); - -#endif /* CAJA_UNDO_MANAGER_H */ diff --git a/libcaja-private/caja-undo-private.h b/libcaja-private/caja-undo-private.h deleted file mode 100644 index c5efbb7c..00000000 --- a/libcaja-private/caja-undo-private.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* xxx - * - * Copyright (C) 2000 Eazel, Inc. - * - * Author: Gene Z. Ragan <[email protected]> - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef CAJA_UNDO_PRIVATE_H -#define CAJA_UNDO_PRIVATE_H - -#include <libcaja-private/caja-undo.h> -#include <libcaja-private/caja-undo-manager.h> -#include <glib-object.h> - -CajaUndoManager * caja_undo_get_undo_manager (GObject *attached_object); -void caja_undo_attach_undo_manager (GObject *object, - CajaUndoManager *manager); - -#endif /* CAJA_UNDO_PRIVATE_H */ diff --git a/libcaja-private/caja-undo-signal-handlers.c b/libcaja-private/caja-undo-signal-handlers.c deleted file mode 100644 index f1dfba3c..00000000 --- a/libcaja-private/caja-undo-signal-handlers.c +++ /dev/null @@ -1,345 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* Signal handlers to enable undo in Gtk Widgets. - * - * Copyright (C) 2000 Eazel, Inc. - * - * Author: Gene Z. Ragan <[email protected]> - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - - -#include <config.h> -#include <gtk/gtk.h> - -#include <glib/gi18n.h> -#include <libcaja-private/caja-undo.h> - -#include <eel/eel-gtk-macros.h> -#include <string.h> - -#include "caja-undo-signal-handlers.h" - - -typedef struct -{ - char *undo_text; - gint position; - guint selection_start; - guint selection_end; -} EditableUndoData; - -typedef struct -{ - gboolean undo_registered; -} EditableUndoObjectData; - - -static void restore_editable_from_undo_snapshot_callback (GObject *target, - gpointer callback_data); -static void editable_register_edit_undo (GtkEditable *editable); -static void free_editable_object_data (gpointer data); - -/* caja_undo_set_up_caja_entry_for_undo - * - * Functions and callback methods to handle undo - * in a CajaEntry - */ - -static void -caja_entry_user_changed_callback (CajaEntry *entry) -{ - /* Register undo transaction */ - editable_register_edit_undo (GTK_EDITABLE (entry)); -} - -void -caja_undo_set_up_caja_entry_for_undo (CajaEntry *entry) -{ - EditableUndoObjectData *data; - - if (!CAJA_IS_ENTRY (entry) ) - { - return; - } - - data = g_new(EditableUndoObjectData, 1); - data->undo_registered = FALSE; - g_object_set_data_full (G_OBJECT (entry), "undo_registered", - data, free_editable_object_data); - - /* Connect to entry signals */ - g_signal_connect (entry, "user_changed", - G_CALLBACK (caja_entry_user_changed_callback), - NULL); -} - -void -caja_undo_tear_down_caja_entry_for_undo (CajaEntry *entry) -{ - if (!CAJA_IS_ENTRY (entry) ) - { - return; - } - - /* Disconnect from entry signals */ - g_signal_handlers_disconnect_by_func - (entry, G_CALLBACK (caja_entry_user_changed_callback), NULL); - -} - -/* caja_undo_set_up_caja_entry_for_undo - * - * Functions and callback methods to handle undo - * in a CajaEntry - */ - -static void -free_editable_undo_data (gpointer data) -{ - EditableUndoData *undo_data; - - undo_data = (EditableUndoData *) data; - - g_free (undo_data->undo_text); - g_free (undo_data); -} - -static void -free_editable_object_data (gpointer data) -{ - g_free (data); -} - - -static void -editable_insert_text_callback (GtkEditable *editable) -{ - /* Register undo transaction */ - editable_register_edit_undo (editable); -} - -static void -editable_delete_text_callback (GtkEditable *editable) -{ - /* Register undo transaction */ - editable_register_edit_undo (editable); -} - -static void -editable_register_edit_undo (GtkEditable *editable) -{ - EditableUndoData *undo_data; - EditableUndoObjectData *undo_info; - gpointer data; - - if (!GTK_IS_EDITABLE (editable) ) - { - return; - } - - /* Check our undo registered flag */ - data = g_object_get_data (G_OBJECT (editable), "undo_registered"); - if (data == NULL) - { - g_warning ("Undo data is NULL"); - return; - } - - undo_info = (EditableUndoObjectData *)data; - if (undo_info->undo_registered) - { - return; - } - - undo_data = g_new0 (EditableUndoData, 1); - undo_data->undo_text = gtk_editable_get_chars (editable, 0, -1); - undo_data->position = gtk_editable_get_position (editable); - gtk_editable_get_selection_bounds (editable, - &undo_data->selection_start, - &undo_data->selection_end); - - caja_undo_register - (G_OBJECT (editable), - restore_editable_from_undo_snapshot_callback, - undo_data, - (GDestroyNotify) free_editable_undo_data, - _("Edit"), - _("Undo Edit"), - _("Undo the edit"), - _("Redo Edit"), - _("Redo the edit")); - - undo_info->undo_registered = TRUE; -} - -void -caja_undo_set_up_editable_for_undo (GtkEditable *editable) -{ - EditableUndoObjectData *data; - - if (!GTK_IS_EDITABLE (editable) ) - { - return; - } - - /* Connect to editable signals */ - g_signal_connect (editable, "insert_text", - G_CALLBACK (editable_insert_text_callback), NULL); - g_signal_connect (editable, "delete_text", - G_CALLBACK (editable_delete_text_callback), NULL); - - - data = g_new (EditableUndoObjectData, 1); - data->undo_registered = FALSE; - g_object_set_data_full (G_OBJECT (editable), "undo_registered", - data, free_editable_object_data); -} - -void -caja_undo_tear_down_editable_for_undo (GtkEditable *editable) -{ - if (!GTK_IS_EDITABLE (editable) ) - { - return; - } - - /* Disconnect from entry signals */ - g_signal_handlers_disconnect_by_func - (editable, G_CALLBACK (editable_insert_text_callback), NULL); - g_signal_handlers_disconnect_by_func - (editable, G_CALLBACK (editable_delete_text_callback), NULL); -} - -/* restore_editable_from_undo_snapshot_callback - * - * Restore edited text. - */ -static void -restore_editable_from_undo_snapshot_callback (GObject *target, gpointer callback_data) -{ - GtkEditable *editable; - GtkWindow *window; - EditableUndoData *undo_data; - EditableUndoObjectData *data; - gint position; - - editable = GTK_EDITABLE (target); - undo_data = (EditableUndoData *) callback_data; - - /* Check our undo registered flag */ - data = g_object_get_data (target, "undo_registered"); - if (data == NULL) - { - g_warning ("Undo regisetred flag not found"); - return; - } - - /* Reset the registered flag so we get a new item for future editing. */ - data->undo_registered = FALSE; - - /* Register a new undo transaction for redo. */ - editable_register_edit_undo (editable); - - /* Restore the text. */ - position = 0; - gtk_editable_delete_text (editable, 0, -1); - gtk_editable_insert_text (editable, undo_data->undo_text, - strlen (undo_data->undo_text), &position); - - /* Set focus to widget */ - window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (target))); - gtk_window_set_focus (window, GTK_WIDGET (editable)); - - /* We have to do this call, because the previous call selects all text */ - gtk_editable_select_region (editable, 0, 0); - - /* Restore selection */ - gtk_editable_select_region (editable, undo_data->selection_start, - undo_data->selection_end); - - /* Set the i-beam to the saved position */ - gtk_editable_set_position (editable, undo_data->position); - - /* Reset the registered flag so we get a new item for future editing. */ - data->undo_registered = FALSE; -} - - -/* editable_set_undo_key - * - * Allow the use of ctrl-z from within widget. - */ - -/* Undo is disabled until we have a better implementation. - * Both here and in caja-shell-ui.xml. - */ - -/* FIXME bugzilla.gnome.org 43515: Undo doesn't work */ -#ifdef UNDO_ENABLED - -static gboolean -editable_key_press_event (GtkEditable *editable, GdkEventKey *event, gpointer user_data) -{ - switch (event->keyval) - { - /* Undo */ - case 'z': - if ((event->state & GDK_CONTROL_MASK) != 0) - { - caja_undo (GTK_OBJECT (editable)); - return TRUE; - } - break; - - default: - break; - } - - return FALSE; -} - -#endif - -/* editable_set_undo_key - * - * Allow the use of ctrl-z from within widget. This should only be - * set if there is no menu bar to use to undo the widget. - */ - -void -caja_undo_editable_set_undo_key (GtkEditable *editable, gboolean value) -{ - /* FIXME bugzilla.gnome.org 43515: Undo doesn't work */ -#ifdef UNDO_ENABLED - if (value) - { - /* Connect to entry signals */ - g_signal_connect (editable, "key_press_event", - G_CALLBACK (editable_key_press_event), NULL); - } - else - { - /* FIXME bugzilla.gnome.org 45092: Warns if the handler - * is not already connected. We could use object data - * to prevent that little problem. - */ - g_signal_disconnect_by_func (editable, - G_CALLBACK (editable_key_press_event), NULL); - } -#endif -} diff --git a/libcaja-private/caja-undo-signal-handlers.h b/libcaja-private/caja-undo-signal-handlers.h deleted file mode 100644 index 47cd4f67..00000000 --- a/libcaja-private/caja-undo-signal-handlers.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* Signal handlers to enable undo in Gtk Widgets. - * - * Copyright (C) 2000 Eazel, Inc. - * - * Author: Gene Z. Ragan <[email protected]> - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef CAJA_UNDO_SIGNAL_HANDLERS_H -#define CAJA_UNDO_SIGNAL_HANDLERS_H - -#include <libcaja-private/caja-entry.h> - -void caja_undo_set_up_caja_entry_for_undo (CajaEntry *entry); -void caja_undo_tear_down_caja_entry_for_undo (CajaEntry *entry); -void caja_undo_set_up_editable_for_undo (GtkEditable *editable); -void caja_undo_tear_down_editable_for_undo (GtkEditable *editable); -void caja_undo_editable_set_undo_key (GtkEditable *editable, - gboolean value); - -#endif /* CAJA_UNDO_SIGNAL_HANDLERS_H */ diff --git a/libcaja-private/caja-undo-transaction.c b/libcaja-private/caja-undo-transaction.c deleted file mode 100644 index ad34bd93..00000000 --- a/libcaja-private/caja-undo-transaction.c +++ /dev/null @@ -1,343 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* CajaUndoTransaction - An object for an undoable transaction. - * Used internally by undo machinery. - * Not public. - * - * Copyright (C) 2000 Eazel, Inc. - * - * Author: Gene Z. Ragan <[email protected]> - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include <config.h> -#include <libcaja-private/caja-undo.h> -#include <libcaja-private/caja-undo-manager.h> -#include <libcaja-private/caja-undo-transaction.h> - -#include "caja-undo-private.h" -#include <gtk/gtk.h> - -#define CAJA_UNDO_TRANSACTION_LIST_DATA "Caja undo transaction list" - -/* undo atoms */ -static void undo_atom_list_free (GList *list); -static void undo_atom_list_undo_and_free (GList *list); - -G_DEFINE_TYPE (CajaUndoTransaction, caja_undo_transaction, - G_TYPE_OBJECT); - -#ifdef UIH -static Caja_Undo_MenuItem * -impl_Caja_Undo_Transaction__get_undo_menu_item (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - CajaUndoTransaction *transaction; - Caja_Undo_MenuItem *item; - - transaction = CAJA_UNDO_TRANSACTION (matecomponent_object_from_servant (servant)); - - item = Caja_Undo_MenuItem__alloc (); - item->label = CORBA_string_dup (transaction->undo_menu_item_label); - item->hint = CORBA_string_dup (transaction->undo_menu_item_hint); - - return item; -} - -static Caja_Undo_MenuItem * -impl_Caja_Undo_Transaction__get_redo_menu_item (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - CajaUndoTransaction *transaction; - Caja_Undo_MenuItem *item; - - transaction = CAJA_UNDO_TRANSACTION (matecomponent_object_from_servant (servant)); - - item = Caja_Undo_MenuItem__alloc (); - item->label = CORBA_string_dup (transaction->redo_menu_item_label); - item->hint = CORBA_string_dup (transaction->redo_menu_item_hint); - - return item; -} - -static CORBA_char * -impl_Caja_Undo_Transaction__get_operation_name (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - CajaUndoTransaction *transaction; - - transaction = CAJA_UNDO_TRANSACTION (matecomponent_object_from_servant (servant)); - return CORBA_string_dup (transaction->operation_name); -} -#endif - - -CajaUndoTransaction * -caja_undo_transaction_new (const char *operation_name, - const char *undo_menu_item_label, - const char *undo_menu_item_hint, - const char *redo_menu_item_label, - const char *redo_menu_item_hint) -{ - CajaUndoTransaction *transaction; - - transaction = CAJA_UNDO_TRANSACTION (g_object_new (caja_undo_transaction_get_type (), NULL)); - - transaction->operation_name = g_strdup (operation_name); - transaction->undo_menu_item_label = g_strdup (undo_menu_item_label); - transaction->undo_menu_item_hint = g_strdup (undo_menu_item_hint); - transaction->redo_menu_item_label = g_strdup (redo_menu_item_label); - transaction->redo_menu_item_hint = g_strdup (redo_menu_item_hint); - - return transaction; -} - -static void -caja_undo_transaction_init (CajaUndoTransaction *transaction) -{ -} - -static void -remove_transaction_from_object (gpointer list_data, gpointer callback_data) -{ - CajaUndoAtom *atom; - CajaUndoTransaction *transaction; - GList *list; - - g_assert (list_data != NULL); - atom = list_data; - transaction = CAJA_UNDO_TRANSACTION (callback_data); - - /* Remove the transaction from the list on the atom. */ - list = g_object_get_data (atom->target, CAJA_UNDO_TRANSACTION_LIST_DATA); - - if (list != NULL) - { - list = g_list_remove (list, transaction); - g_object_set_data (atom->target, CAJA_UNDO_TRANSACTION_LIST_DATA, list); - } -} - -static void -remove_transaction_from_atom_targets (CajaUndoTransaction *transaction) -{ - - g_list_foreach (transaction->atom_list, - remove_transaction_from_object, - transaction); -} - -static void -caja_undo_transaction_finalize (GObject *object) -{ - CajaUndoTransaction *transaction; - - transaction = CAJA_UNDO_TRANSACTION (object); - - remove_transaction_from_atom_targets (transaction); - undo_atom_list_free (transaction->atom_list); - - g_free (transaction->operation_name); - g_free (transaction->undo_menu_item_label); - g_free (transaction->undo_menu_item_hint); - g_free (transaction->redo_menu_item_label); - g_free (transaction->redo_menu_item_hint); - - if (transaction->owner != NULL) - { - g_object_unref (transaction->owner); - } - - G_OBJECT_CLASS (caja_undo_transaction_parent_class)->finalize (object); -} - -void -caja_undo_transaction_add_atom (CajaUndoTransaction *transaction, - const CajaUndoAtom *atom) -{ - GList *list; - - g_return_if_fail (CAJA_IS_UNDO_TRANSACTION (transaction)); - g_return_if_fail (atom != NULL); - g_return_if_fail (GTK_IS_OBJECT (atom->target)); - - /* Add the atom to the atom list in the transaction. */ - transaction->atom_list = g_list_append - (transaction->atom_list, g_memdup (atom, sizeof (*atom))); - - /* Add the transaction to the list on the atoms target object. */ - list = g_object_get_data (atom->target, CAJA_UNDO_TRANSACTION_LIST_DATA); - if (g_list_find (list, transaction) != NULL) - { - return; - } - - /* If it's not already on that atom, this object is new. */ - list = g_list_prepend (list, transaction); - g_object_set_data (atom->target, CAJA_UNDO_TRANSACTION_LIST_DATA, list); - - /* Connect a signal handler to the atom so it will unregister - * itself when it's destroyed. - */ - g_signal_connect (atom->target, "destroy", - G_CALLBACK (caja_undo_transaction_unregister_object), - NULL); -} - -void -caja_undo_transaction_undo (CajaUndoTransaction *transaction) -{ - g_return_if_fail (CAJA_IS_UNDO_TRANSACTION (transaction)); - - remove_transaction_from_atom_targets (transaction); - undo_atom_list_undo_and_free (transaction->atom_list); - - transaction->atom_list = NULL; -} - -void -caja_undo_transaction_add_to_undo_manager (CajaUndoTransaction *transaction, - CajaUndoManager *manager) -{ - g_return_if_fail (CAJA_IS_UNDO_TRANSACTION (transaction)); - g_return_if_fail (transaction->owner == NULL); - - if (manager != NULL) - { - caja_undo_manager_append (manager, transaction); - transaction->owner = g_object_ref (manager); - } -} - -static void -remove_atoms (CajaUndoTransaction *transaction, - GObject *object) -{ - GList *p, *next; - CajaUndoAtom *atom; - - g_assert (CAJA_IS_UNDO_TRANSACTION (transaction)); - g_assert (G_IS_OBJECT (object)); - - /* Destroy any atoms for this object. */ - for (p = transaction->atom_list; p != NULL; p = next) - { - atom = p->data; - next = p->next; - - if (atom->target == object) - { - transaction->atom_list = g_list_remove_link - (transaction->atom_list, p); - undo_atom_list_free (p); - } - } - - /* If all the atoms are gone, forget this transaction. - * This may end up freeing the transaction. - */ - if (transaction->atom_list == NULL) - { - caja_undo_manager_forget ( - transaction->owner, transaction); - } -} - -static void -remove_atoms_cover (gpointer list_data, gpointer callback_data) -{ - if (CAJA_IS_UNDO_TRANSACTION (list_data)) - { - remove_atoms (CAJA_UNDO_TRANSACTION (list_data), G_OBJECT (callback_data)); - } -} - -void -caja_undo_transaction_unregister_object (GObject *object) -{ - GList *list; - - g_return_if_fail (G_IS_OBJECT (object)); - - /* Remove atoms from each transaction on the list. */ - list = g_object_get_data (object, CAJA_UNDO_TRANSACTION_LIST_DATA); - if (list != NULL) - { - g_list_foreach (list, remove_atoms_cover, object); - g_list_free (list); - g_object_set_data (object, CAJA_UNDO_TRANSACTION_LIST_DATA, NULL); - } -} - -static void -undo_atom_free (CajaUndoAtom *atom) -{ - /* Call the destroy-notify function if it's present. */ - if (atom->callback_data_destroy_notify != NULL) - { - (* atom->callback_data_destroy_notify) (atom->callback_data); - } - - /* Free the atom storage. */ - g_free (atom); -} - -static void -undo_atom_undo_and_free (CajaUndoAtom *atom) -{ - /* Call the function that does the actual undo. */ - (* atom->callback) (atom->target, atom->callback_data); - - /* Get rid of the atom now that it's spent. */ - undo_atom_free (atom); -} - -static void -undo_atom_free_cover (gpointer atom, gpointer callback_data) -{ - g_assert (atom != NULL); - g_assert (callback_data == NULL); - undo_atom_free (atom); -} - -static void -undo_atom_undo_and_free_cover (gpointer atom, gpointer callback_data) -{ - g_assert (atom != NULL); - g_assert (callback_data == NULL); - undo_atom_undo_and_free (atom); -} - -static void -undo_atom_list_free (GList *list) -{ - g_list_foreach (list, undo_atom_free_cover, NULL); - g_list_free (list); -} - -static void -undo_atom_list_undo_and_free (GList *list) -{ - g_list_foreach (list, undo_atom_undo_and_free_cover, NULL); - g_list_free (list); -} - -static void -caja_undo_transaction_class_init (CajaUndoTransactionClass *klass) -{ - G_OBJECT_CLASS (klass)->finalize = caja_undo_transaction_finalize; -} diff --git a/libcaja-private/caja-undo-transaction.h b/libcaja-private/caja-undo-transaction.h deleted file mode 100644 index 0d9d8cd6..00000000 --- a/libcaja-private/caja-undo-transaction.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* CajaUndoTransaction - An object for an undoable transaction. - * Used internally by undo machinery. - * Not public. - * - * Copyright (C) 2000 Eazel, Inc. - * - * Author: Gene Z. Ragan <[email protected]> - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef CAJA_UNDO_TRANSACTION_H -#define CAJA_UNDO_TRANSACTION_H - -#include <libcaja-private/caja-undo.h> - -#define CAJA_TYPE_UNDO_TRANSACTION caja_undo_transaction_get_type() -#define CAJA_UNDO_TRANSACTION(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_UNDO_TRANSACTION, CajaUndoTransaction)) -#define CAJA_UNDO_TRANSACTION_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_UNDO_TRANSACTION, CajaUndoTransactionClass)) -#define CAJA_IS_UNDO_TRANSACTION(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAJA_TYPE_UNDO_TRANSACTION)) -#define CAJA_IS_UNDO_TRANSACTION_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), CAJA_TYPE_UNDO_TRANSACTION)) -#define CAJA_UNDO_TRANSACTION_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), CAJA_TYPE_UNDO_TRANSACTION, CajaUndoTransactionClass)) - -/* The typedef for CajaUndoTransaction is in caja-undo.h - to avoid circular deps */ -typedef struct _CajaUndoTransactionClass CajaUndoTransactionClass; - -struct _CajaUndoTransaction -{ - GObject parent_slot; - - char *operation_name; - char *undo_menu_item_label; - char *undo_menu_item_hint; - char *redo_menu_item_label; - char *redo_menu_item_hint; - GList *atom_list; - - CajaUndoManager *owner; -}; - -struct _CajaUndoTransactionClass -{ - GObjectClass parent_slot; -}; - -GType caja_undo_transaction_get_type (void); -CajaUndoTransaction *caja_undo_transaction_new (const char *operation_name, - const char *undo_menu_item_label, - const char *undo_menu_item_hint, - const char *redo_menu_item_label, - const char *redo_menu_item_hint); -void caja_undo_transaction_add_atom (CajaUndoTransaction *transaction, - const CajaUndoAtom *atom); -void caja_undo_transaction_add_to_undo_manager (CajaUndoTransaction *transaction, - CajaUndoManager *manager); -void caja_undo_transaction_unregister_object (GObject *atom_target); -void caja_undo_transaction_undo (CajaUndoTransaction *transaction); - -#endif /* CAJA_UNDO_TRANSACTION_H */ diff --git a/libcaja-private/caja-undo.c b/libcaja-private/caja-undo.c deleted file mode 100644 index ba946a0a..00000000 --- a/libcaja-private/caja-undo.c +++ /dev/null @@ -1,218 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* caja-undo.c - public interface for objects that implement - * undoable actions -- works across components - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: Darin Adler <[email protected]> - */ - -#include <config.h> -#include "caja-undo.h" - -#include "caja-undo-private.h" -#include "caja-undo-transaction.h" -#include <gtk/gtk.h> - -#define CAJA_UNDO_MANAGER_DATA "Caja undo manager" - -/* Register a simple undo action by calling caja_undo_register_full. */ -void -caja_undo_register (GObject *target, - CajaUndoCallback callback, - gpointer callback_data, - GDestroyNotify callback_data_destroy_notify, - const char *operation_name, - const char *undo_menu_item_label, - const char *undo_menu_item_hint, - const char *redo_menu_item_label, - const char *redo_menu_item_hint) -{ - CajaUndoAtom atom; - GList single_atom_list; - - g_return_if_fail (G_IS_OBJECT (target)); - g_return_if_fail (callback != NULL); - - /* Make an atom. */ - atom.target = target; - atom.callback = callback; - atom.callback_data = callback_data; - atom.callback_data_destroy_notify = callback_data_destroy_notify; - - /* Make a single-atom list. */ - single_atom_list.data = &atom; - single_atom_list.next = NULL; - single_atom_list.prev = NULL; - - /* Call the full version of the registration function, - * using the undo target as the place to search for the - * undo manager. - */ - caja_undo_register_full (&single_atom_list, - target, - operation_name, - undo_menu_item_label, - undo_menu_item_hint, - redo_menu_item_label, - redo_menu_item_hint); -} - -/* Register an undo action. */ -void -caja_undo_register_full (GList *atoms, - GObject *undo_manager_search_start_object, - const char *operation_name, - const char *undo_menu_item_label, - const char *undo_menu_item_hint, - const char *redo_menu_item_label, - const char *redo_menu_item_hint) -{ - CajaUndoTransaction *transaction; - GList *p; - - g_return_if_fail (atoms != NULL); - g_return_if_fail (G_IS_OBJECT (undo_manager_search_start_object)); - - /* Create an undo transaction */ - transaction = caja_undo_transaction_new (operation_name, - undo_menu_item_label, - undo_menu_item_hint, - redo_menu_item_label, - redo_menu_item_hint); - for (p = atoms; p != NULL; p = p->next) - { - caja_undo_transaction_add_atom (transaction, p->data); - } - caja_undo_transaction_add_to_undo_manager - (transaction, - caja_undo_get_undo_manager (undo_manager_search_start_object)); - - /* Now we are done with the transaction. - * If the undo manager is holding it, then this will not destroy it. - */ - g_object_unref (transaction); -} - -/* Cover for forgetting about all undo relating to a particular target. */ -void -caja_undo_unregister (GObject *target) -{ - /* Perhaps this should also unregister all children if called on a - * GtkContainer? That might be handy. - */ - caja_undo_transaction_unregister_object (target); -} - -void -caja_undo (GObject *undo_manager_search_start_object) -{ - CajaUndoManager *manager; - - g_return_if_fail (G_IS_OBJECT (undo_manager_search_start_object)); - - manager = caja_undo_get_undo_manager (undo_manager_search_start_object); - if (manager != NULL) - { - caja_undo_manager_undo (manager); - } -} - -CajaUndoManager * -caja_undo_get_undo_manager (GObject *start_object) -{ - CajaUndoManager *manager; - GtkWidget *parent; - GtkWindow *transient_parent; - - if (start_object == NULL) - { - return NULL; - } - - g_return_val_if_fail (G_IS_OBJECT (start_object), NULL); - - /* Check for an undo manager right here. */ - manager = g_object_get_data (start_object, CAJA_UNDO_MANAGER_DATA); - if (manager != NULL) - { - return manager; - } - - /* Check for undo manager up the parent chain. */ - if (GTK_IS_WIDGET (start_object)) - { - parent = gtk_widget_get_parent (GTK_WIDGET (start_object)); - if (parent != NULL) - { - manager = caja_undo_get_undo_manager (G_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_get_transient_for (GTK_WINDOW (start_object)); - if (transient_parent != NULL) - { - manager = caja_undo_get_undo_manager (G_OBJECT (transient_parent)); - if (manager != NULL) - { - return manager; - } - } - } - } - - /* Found nothing. I can live with that. */ - return NULL; -} - -void -caja_undo_attach_undo_manager (GObject *object, - CajaUndoManager *manager) -{ - g_return_if_fail (G_IS_OBJECT (object)); - - if (manager == NULL) - { - g_object_set_data (object, CAJA_UNDO_MANAGER_DATA, NULL); - } - else - { - g_object_ref (manager); - g_object_set_data_full - (object, CAJA_UNDO_MANAGER_DATA, - manager, g_object_unref); - } -} - -/* Copy a reference to the undo manager fromone object to another. */ -void -caja_undo_share_undo_manager (GObject *destination_object, - GObject *source_object) -{ - CajaUndoManager *manager; - - manager = caja_undo_get_undo_manager (source_object); - caja_undo_attach_undo_manager (destination_object, manager); -} diff --git a/libcaja-private/caja-undo.h b/libcaja-private/caja-undo.h deleted file mode 100644 index f68335e1..00000000 --- a/libcaja-private/caja-undo.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* caja-undo.h - public interface for objects that implement - * undoable actions -- works across components - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: Darin Adler <[email protected]> - */ - -#ifndef CAJA_UNDO_H -#define CAJA_UNDO_H - -#include <glib-object.h> - -typedef struct _CajaUndoTransaction CajaUndoTransaction; - - -/* The basic undoable operation. */ -typedef void (* CajaUndoCallback) (GObject *target, gpointer callback_data); - -/* Recipe for undo of a bit of work on an object. - * Create these atoms when you want to register more - * than one as a single undoable operation. - */ -typedef struct -{ - GObject *target; - CajaUndoCallback callback; - gpointer callback_data; - GDestroyNotify callback_data_destroy_notify; -} CajaUndoAtom; - -/* Registering something that can be undone. */ -void caja_undo_register (GObject *target, - CajaUndoCallback callback, - gpointer callback_data, - GDestroyNotify callback_data_destroy_notify, - const char *operation_name, - const char *undo_menu_item_label, - const char *undo_menu_item_hint, - const char *redo_menu_item_label, - const char *redo_menu_item_hint); -void caja_undo_register_full (GList *atoms, - GObject *undo_manager_search_start_object, - const char *operation_name, - const char *undo_menu_item_label, - const char *undo_menu_item_hint, - const char *redo_menu_item_label, - const char *redo_menu_item_hint); -void caja_undo_unregister (GObject *target); - -/* Performing an undo explicitly. Only for use by objects "out in the field". - * The menu bar itself uses a richer API in the undo manager. - */ -void caja_undo (GObject *undo_manager_search_start_object); - -/* Connecting an undo manager. */ -void caja_undo_share_undo_manager (GObject *destination_object, - GObject *source_object); - -#endif /* CAJA_UNDO_H */ diff --git a/po/POTFILES.in b/po/POTFILES.in index 95b00402..8d4ac956 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -44,7 +44,6 @@ libcaja-private/caja-progress-info.c libcaja-private/caja-query.c libcaja-private/caja-search-directory-file.c libcaja-private/caja-tree-view-drag-dest.c -libcaja-private/caja-undo-signal-handlers.c libcaja-private/caja-undostack-manager.c libcaja-private/caja-vfs-file.c data/caja-autorun-software.desktop.in.in diff --git a/src/caja-application.c b/src/caja-application.c index 3c1c3f07..5881facd 100644 --- a/src/caja-application.c +++ b/src/caja-application.c @@ -69,7 +69,6 @@ #include <libcaja-private/caja-file-utilities.h> #include <libcaja-private/caja-global-preferences.h> #include <libcaja-private/caja-module.h> -#include <libcaja-private/caja-undo-manager.h> #include <libcaja-private/caja-desktop-link-monitor.h> #include <libcaja-private/caja-directory-private.h> #include <libcaja-private/caja-signaller.h> @@ -291,9 +290,6 @@ smclient_quit_cb (EggSMClient *client, static void caja_application_init (CajaApplication *application) { - /* Create an undo manager */ - application->undo_manager = caja_undo_manager_new (); - application->unique_app = unique_app_new_with_commands ("org.mate.Caja", NULL, "start_desktop", COMMAND_START_DESKTOP, "stop_desktop", COMMAND_STOP_DESKTOP, @@ -350,8 +346,6 @@ caja_application_finalize (GObject *object) caja_bookmarks_exiting (); - g_object_unref (application->undo_manager); - if (application->volume_monitor) { g_object_unref (application->volume_monitor); diff --git a/src/caja-application.h b/src/caja-application.h index c07cfe0e..5c5b94d0 100644 --- a/src/caja-application.h +++ b/src/caja-application.h @@ -31,7 +31,6 @@ #include <gio/gio.h> #include <unique/unique.h> #include <libegg/eggsmclient.h> -#include <libcaja-private/caja-undo-manager.h> #define CAJA_DESKTOP_ICON_VIEW_IID "OAFIID:Caja_File_Manager_Desktop_Icon_View" @@ -65,7 +64,6 @@ typedef struct GObject parent; UniqueApp* unique_app; EggSMClient* smclient; - CajaUndoManager* undo_manager; GVolumeMonitor* volume_monitor; unsigned int automount_idle_id; GDBusProxy* proxy; diff --git a/src/caja-bookmarks-window.c b/src/caja-bookmarks-window.c index 1a6659c6..49f66850 100644 --- a/src/caja-bookmarks-window.c +++ b/src/caja-bookmarks-window.c @@ -30,11 +30,9 @@ #include "caja-window.h" #include "caja-navigation-window.h" #include "caja-spatial-window.h" -#include <libcaja-private/caja-undo.h> #include <libcaja-private/caja-global-preferences.h> #include <eel/eel-gtk-extensions.h> #include <eel/eel-mate-extensions.h> -#include <libcaja-private/caja-undo-signal-handlers.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> @@ -252,7 +250,7 @@ edit_bookmarks_dialog_reset_signals (gpointer data, * Return value: A pointer to the new window. **/ GtkWindow * -create_bookmarks_window (CajaBookmarkList *list, GObject *undo_manager_source) +create_bookmarks_window (CajaBookmarkList *list, CajaWindow *window_source) { GtkWidget *window; GtkTreeViewColumn *col; @@ -274,9 +272,9 @@ create_bookmarks_window (CajaBookmarkList *list, GObject *undo_manager_source) remove_button = (GtkWidget *)gtk_builder_get_object (builder, "bookmark_delete_button"); jump_button = (GtkWidget *)gtk_builder_get_object (builder, "bookmark_jump_button"); - application = CAJA_WINDOW (undo_manager_source)->application; + application = window_source->application; - if (CAJA_IS_NAVIGATION_WINDOW (undo_manager_source)) + if (CAJA_IS_NAVIGATION_WINDOW (window_source)) { parent_is_browser_window = TRUE; } @@ -286,13 +284,12 @@ create_bookmarks_window (CajaBookmarkList *list, GObject *undo_manager_source) } set_up_close_accelerator (window); - caja_undo_share_undo_manager (G_OBJECT (window), undo_manager_source); gtk_window_set_wmclass (GTK_WINDOW (window), "bookmarks", "Caja"); caja_bookmarks_window_restore_geometry (window); - g_object_weak_ref (G_OBJECT (undo_manager_source), edit_bookmarks_dialog_reset_signals, - undo_manager_source); + g_object_weak_ref (G_OBJECT (window_source), edit_bookmarks_dialog_reset_signals, + window_source); bookmark_list_widget = GTK_TREE_VIEW (gtk_builder_get_object (builder, "bookmark_tree_view")); @@ -336,7 +333,6 @@ create_bookmarks_window (CajaBookmarkList *list, GObject *undo_manager_source) gtk_widget_show (name_field); gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "bookmark_name_placeholder")), name_field, TRUE, TRUE, 0); - caja_undo_editable_set_undo_key (GTK_EDITABLE (name_field), TRUE); gtk_label_set_mnemonic_widget ( GTK_LABEL (gtk_builder_get_object (builder, "bookmark_name_label")), @@ -346,7 +342,6 @@ create_bookmarks_window (CajaBookmarkList *list, GObject *undo_manager_source) gtk_widget_show (uri_field); gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "bookmark_location_placeholder")), uri_field, TRUE, TRUE, 0); - caja_undo_editable_set_undo_key (GTK_EDITABLE (uri_field), TRUE); gtk_label_set_mnemonic_widget ( GTK_LABEL (gtk_builder_get_object (builder, "bookmark_location_label")), @@ -363,7 +358,7 @@ create_bookmarks_window (CajaBookmarkList *list, GObject *undo_manager_source) G_CALLBACK (on_row_deleted), NULL); row_activated_signal_id = g_signal_connect (bookmark_list_widget, "row_activated", - G_CALLBACK (on_row_activated), undo_manager_source); + G_CALLBACK (on_row_activated), window_source); button_pressed_signal_id = g_signal_connect (bookmark_list_widget, "button_press_event", G_CALLBACK (on_button_pressed), NULL); @@ -404,7 +399,7 @@ create_bookmarks_window (CajaBookmarkList *list, GObject *undo_manager_source) G_CALLBACK (on_remove_button_clicked), NULL); jump_button_signal_id = g_signal_connect (jump_button, "clicked", - G_CALLBACK (on_jump_button_clicked), undo_manager_source); + G_CALLBACK (on_jump_button_clicked), window_source); gtk_tree_selection_set_mode (bookmark_selection, GTK_SELECTION_BROWSE); @@ -417,7 +412,7 @@ create_bookmarks_window (CajaBookmarkList *list, GObject *undo_manager_source) } void -edit_bookmarks_dialog_set_signals (GObject *undo_manager_source) +edit_bookmarks_dialog_set_signals (CajaWindow *window) { g_signal_handler_disconnect (GTK_OBJECT (jump_button), @@ -427,13 +422,13 @@ edit_bookmarks_dialog_set_signals (GObject *undo_manager_source) jump_button_signal_id = g_signal_connect (jump_button, "clicked", - G_CALLBACK (on_jump_button_clicked), undo_manager_source); + G_CALLBACK (on_jump_button_clicked), window); row_activated_signal_id = g_signal_connect (bookmark_list_widget, "row_activated", - G_CALLBACK (on_row_activated), undo_manager_source); + G_CALLBACK (on_row_activated), window); - g_object_weak_ref (G_OBJECT (undo_manager_source), edit_bookmarks_dialog_reset_signals, - undo_manager_source); + g_object_weak_ref (G_OBJECT (window), edit_bookmarks_dialog_reset_signals, + window); } static CajaBookmark * @@ -962,10 +957,6 @@ on_window_hide_event (GtkWidget *widget, { caja_bookmarks_window_save_geometry (GTK_WINDOW (widget)); - /* Disable undo for entry widgets */ - caja_undo_unregister (G_OBJECT (name_field)); - caja_undo_unregister (G_OBJECT (uri_field)); - /* restore_geometry only works after window is hidden */ g_idle_add (restore_geometry, widget); } diff --git a/src/caja-bookmarks-window.h b/src/caja-bookmarks-window.h index 20e242c5..135df595 100644 --- a/src/caja-bookmarks-window.h +++ b/src/caja-bookmarks-window.h @@ -30,10 +30,11 @@ #include <gtk/gtk.h> #include "caja-bookmark-list.h" +#include "caja-window.h" GtkWindow *create_bookmarks_window (CajaBookmarkList *bookmarks, - GObject *undo_manager_source); -void caja_bookmarks_window_save_geometry (GtkWindow *window); -void edit_bookmarks_dialog_set_signals (GObject *undo_manager_source); + CajaWindow *window_source); +void caja_bookmarks_window_save_geometry (GtkWindow *window); +void edit_bookmarks_dialog_set_signals (CajaWindow *window); #endif /* CAJA_BOOKMARKS_WINDOW_H */ diff --git a/src/caja-navigation-window-menus.c b/src/caja-navigation-window-menus.c index 69caca50..5cc77308 100644 --- a/src/caja-navigation-window-menus.c +++ b/src/caja-navigation-window-menus.c @@ -54,7 +54,6 @@ #include <libcaja-private/caja-file-utilities.h> #include <libcaja-private/caja-global-preferences.h> #include <libcaja-private/caja-ui-utilities.h> -#include <libcaja-private/caja-undo-manager.h> #include <libcaja-private/caja-search-engine.h> #include <libcaja-private/caja-signaller.h> diff --git a/src/caja-navigation-window.c b/src/caja-navigation-window.c index a3c2ae84..db9cf523 100644 --- a/src/caja-navigation-window.c +++ b/src/caja-navigation-window.c @@ -63,7 +63,6 @@ #include <libcaja-private/caja-sidebar.h> #include <libcaja-private/caja-view-factory.h> #include <libcaja-private/caja-clipboard.h> -#include <libcaja-private/caja-undo.h> #include <libcaja-private/caja-module.h> #include <libcaja-private/caja-sidebar-provider.h> #include <libcaja-private/caja-search-directory.h> diff --git a/src/caja-spatial-window.c b/src/caja-spatial-window.c index db023d0a..c5a1bac4 100644 --- a/src/caja-spatial-window.c +++ b/src/caja-spatial-window.c @@ -60,7 +60,6 @@ #include <libcaja-private/caja-metadata.h> #include <libcaja-private/caja-mime-actions.h> #include <libcaja-private/caja-program-choosing.h> -#include <libcaja-private/caja-undo.h> #include <libcaja-private/caja-search-directory.h> #include <libcaja-private/caja-search-engine.h> #include <libcaja-private/caja-signaller.h> diff --git a/src/caja-window-bookmarks.c b/src/caja-window-bookmarks.c index 02ce3a64..e2b6ec73 100644 --- a/src/caja-window-bookmarks.c +++ b/src/caja-window-bookmarks.c @@ -33,7 +33,6 @@ #include "caja-bookmarks-window.h" #include "caja-window-bookmarks.h" #include "caja-window-private.h" -#include <libcaja-private/caja-undo-manager.h> #include <eel/eel-debug.h> #include <eel/eel-stock-dialogs.h> #include <eel/eel-vfs-extensions.h> @@ -102,18 +101,14 @@ show_bogus_bookmark_window (CajaWindow *window, static GtkWindow * get_or_create_bookmarks_window (CajaWindow *window) { - GObject *undo_manager_source; - - undo_manager_source = G_OBJECT (window); - if (bookmarks_window == NULL) { bookmarks_window = create_bookmarks_window (window->details->bookmark_list, - undo_manager_source); + window); } else { - edit_bookmarks_dialog_set_signals (undo_manager_source); + edit_bookmarks_dialog_set_signals (window); } return bookmarks_window; diff --git a/src/caja-window-menus.c b/src/caja-window-menus.c index ca37ccbb..7608ad3b 100644 --- a/src/caja-window-menus.c +++ b/src/caja-window-menus.c @@ -49,7 +49,6 @@ #include <libcaja-private/caja-icon-names.h> #include <libcaja-private/caja-ui-utilities.h> #include <libcaja-private/caja-module.h> -#include <libcaja-private/caja-undo-manager.h> #include <libcaja-private/caja-search-directory.h> #include <libcaja-private/caja-search-engine.h> #include <libcaja-private/caja-signaller.h> @@ -272,16 +271,6 @@ action_stop_callback (GtkAction *action, caja_window_slot_stop_loading (slot); } -#ifdef TEXT_CHANGE_UNDO -static void -action_undo_callback (GtkAction *action, - gpointer user_data) -{ - caja_undo_manager_undo - (CAJA_WINDOW (user_data)->application->undo_manager); -} -#endif - static void action_home_callback (GtkAction *action, gpointer user_data) @@ -852,12 +841,6 @@ static const GtkActionEntry main_entries[] = NULL, N_("Edit Caja preferences"), G_CALLBACK (action_preferences_callback) }, - #ifdef TEXT_CHANGE_UNDO - /* name, stock id, label */ { "Undo", NULL, N_("_Undo"), - "<control>Z", N_("Undo the last text change"), - G_CALLBACK (action_undo_callback) - }, - #endif /* name, stock id, label */ { "Up", GTK_STOCK_GO_UP, N_("Open _Parent"), "<alt>Up", N_("Open the parent folder"), G_CALLBACK (action_up_callback) diff --git a/src/caja-window.c b/src/caja-window.c index 520787b0..29830511 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -62,7 +62,6 @@ #include <libcaja-private/caja-program-choosing.h> #include <libcaja-private/caja-view-factory.h> #include <libcaja-private/caja-clipboard.h> -#include <libcaja-private/caja-undo.h> #include <libcaja-private/caja-search-directory.h> #include <libcaja-private/caja-signaller.h> #include <math.h> @@ -531,7 +530,6 @@ caja_window_constructed (GObject *self) caja_window_initialize_bookmarks_menu (window); caja_window_set_initial_window_geometry (window); - caja_undo_manager_attach (window->application->undo_manager, G_OBJECT (window)); } static void diff --git a/src/caja-window.h b/src/caja-window.h index 95fecc36..46b0fd44 100644 --- a/src/caja-window.h +++ b/src/caja-window.h @@ -30,6 +30,7 @@ #include <gtk/gtk.h> #include <eel/eel-glib-extensions.h> #include <libcaja-private/caja-bookmark.h> +#include <libcaja-private/caja-entry.h> #include <libcaja-private/caja-window-info.h> #include <libcaja-private/caja-search-directory.h> #include "caja-application.h" diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index 88fc5e0d..7ec253c0 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -55,9 +55,7 @@ #include <libcaja-private/caja-link.h> #include <libcaja-private/caja-metadata.h> #include <libcaja-private/caja-module.h> -#include <libcaja-private/caja-undo-signal-handlers.h> #include <libcaja-private/caja-mime-actions.h> -#include <libcaja-private/caja-undo.h> #include <string.h> #include <sys/stat.h> #include <cairo.h> @@ -616,20 +614,6 @@ set_name_field (FMPropertiesWindow *window, const gchar *original_name, 0, 0); gtk_label_set_mnemonic_widget (GTK_LABEL (window->details->name_label), window->details->name_field); - /* FIXME bugzilla.gnome.org 42151: - * With this (and one place elsewhere in this file, not sure which is the - * trouble-causer) code in place, bug 2151 happens (crash on quit). Since - * we've removed Undo from Caja for now, I'm just ifdeffing out this - * code rather than trying to fix 2151 now. Note that it might be possible - * to fix 2151 without making Undo actually work, it's just not worth the - * trouble. - */ -#ifdef UNDO_ENABLED - /* Set up name field for undo */ - caja_undo_set_up_caja_entry_for_undo ( CAJA_ENTRY (window->details->name_field)); - caja_undo_editable_set_undo_key (GTK_EDITABLE (window->details->name_field), TRUE); -#endif - g_signal_connect_object (window->details->name_field, "focus_out_event", G_CALLBACK (name_field_focus_out), window, 0); g_signal_connect_object (window->details->name_field, "activate", @@ -5384,13 +5368,6 @@ is_directory_ready_callback (CajaFile *file, remove_pending (startup_data, FALSE, TRUE, TRUE); -/* FIXME bugzilla.gnome.org 42151: - * See comment elsewhere in this file about bug 2151. - */ -#ifdef UNDO_ENABLED - caja_undo_share_undo_manager (GTK_OBJECT (new_window), - GTK_OBJECT (callback_data)); -#endif gtk_window_present (GTK_WINDOW (new_window)); } } |