## ThunarJobOperationHistory ThunarJobOperationHistory — Manages the logging of job operations (copy, move etc.) and undoing and redoing them |

## Functions

ThunarJobOperationHistory * | thunar_job_operation_history_get_default ()
void | thunar_job_operation_history_commit ()
void | thunar_job_operation_history_update_trash_timestamps ()
void | thunar_job_operation_history_undo ()
void | thunar_job_operation_history_redo ()
gboolean | thunar_job_operation_history_can_undo ()
gboolean | thunar_job_operation_history_can_redo ()
gchar * | thunar_job_operation_history_get_undo_text ()
gchar * | thunar_job_operation_history_get_redo_text ()

## Properties

gboolean | can-redo | Read
gboolean | can-undo | Read

## Types and Values

#define | THUNAR_TYPE_JOB_OPERATION_HISTORY
| ThunarJobOperationHistory

## Object Hierarchy

        GObject
        ╰── ThunarJobOperationHistory

## Description

The single ThunarJobOperationHistory instance stores all job operations in a GList and manages tools to manage the list and the next/previous operations which can be undone/redone */

/* property identifiers */ enum { PROP_0, PROP_CAN_UNDO, PROP_CAN_REDO, };

static void thunar_job_operation_history_finalize (GObject *object); static void thunar_job_operation_history_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);

struct _ThunarJobOperationHistory { GObject __parent__;

/* List of job operations which were logged */ GList *job_operation_list; gint job_operation_list_max_size;

/* since the job operation list, lp_undo and lp_redo all refer to the same memory locations, which may be accessed by different threads, we need to protect this memory with a mutex */ GMutex job_operation_list_mutex;

/* List pointer to the operation which can be undone */ GList *lp_undo;

/* List pointer to the operation which can be redone */ GList *lp_redo; };

static ThunarJobOperationHistory *job_operation_history;

G_DEFINE_TYPE (ThunarJobOperationHistory, thunar_job_operation_history, G_TYPE_OBJECT)

static void thunar_job_operation_history_class_init (ThunarJobOperationHistoryClass *klass) { GObjectClass *gobject_class;

gobject_class = G_OBJECT_CLASS (klass); gobject_class->get_property = thunar_job_operation_history_get_property; gobject_class->finalize = thunar_job_operation_history_finalize;

g_object_class_install_property (gobject_class, PROP_CAN_UNDO, g_param_spec_boolean ("can-undo", "can-undo", "can-undo", FALSE, EXO_PARAM_READABLE));

g_object_class_install_property (gobject_class, PROP_CAN_REDO, g_param_spec_boolean ("can-redo", "can-redo", "can-redo", FALSE, EXO_PARAM_READABLE)); }

static void thunar_job_operation_history_init (ThunarJobOperationHistory *self) { ThunarPreferences *preferences;

self->job_operation_list = NULL; self->lp_undo = NULL; self->lp_redo = NULL;

preferences = `thunar_preferences_get()`; g_object_get (G_OBJECT (preferences), "misc-undo-redo-history-size", &(self->job_operation_list_max_size), NULL); g_object_unref (preferences);

g_mutex_init (&self->job_operation_list_mutex); }

static void thunar_job_operation_history_finalize (GObject *object) { ThunarJobOperationHistory *history = THUNAR_JOB_OPERATION_HISTORY (object);

_thunar_return_if_fail (THUNAR_IS_JOB_OPERATION_HISTORY (history));

g_list_free_full (history->job_operation_list, g_object_unref);

g_mutex_clear (&history->job_operation_list_mutex);

(*G_OBJECT_CLASS (thunar_job_operation_history_parent_class)->finalize) (object); }

static void thunar_job_operation_history_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { switch (prop_id) { case PROP_CAN_UNDO: g_value_set_boolean (value, `thunar_job_operation_history_can_undo()`); break;

case PROP_CAN_REDO: g_value_set_boolean (value, `thunar_job_operation_history_can_redo()`); break;

default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }

/** thunar_job_operation_history_get_default:

Returns a reference to the default ThunarJobOperationHistory instance.

The caller is responsible to free the returned instance using `g_object_unref()` when no longer needed.

## Functions

### thunar_job_operation_history_get_default ()

    ThunarJobOperationHistory *
    thunar_job_operation_history_get_default
                                   (void);

### thunar_job_operation_history_commit ()

    void
    thunar_job_operation_history_commit (ThunarJobOperation *job_operation);

Commits, or registers, the given thunar_job_operation, adding the job operation to the job operation list.

#### Parameters

job_operation | a ThunarJobOperation |

### thunar_job_operation_history_update_trash_timestamps ()

    void
    thunar_job_operation_history_update_trash_timestamps
                                   (ThunarJobOperation *job_operation);

Only updates the timestamps of the latest trash operation That is needed after 'redo' of a 'trash' operation, since it requires to set new timestamps (otherwise 'undo' of that operation wont work afterwards)

#### Parameters

job_operation | a ThunarJobOperation |

### thunar_job_operation_history_undo ()

    void
    thunar_job_operation_history_undo (GtkWindow *parent);

Undoes the latest job operation, by executing its inverse

#### Parameters

parent | the parent GtkWindow |

### thunar_job_operation_history_redo ()

    void
    thunar_job_operation_history_redo (GtkWindow *parent);

Redoes the last job operation which had been undone (if any)

#### Parameters

parent | the parent GtkWindow |

### thunar_job_operation_history_can_undo ()

    gboolean
    thunar_job_operation_history_can_undo (void);

### thunar_job_operation_history_can_redo ()

    gboolean
    thunar_job_operation_history_can_redo (void);

### thunar_job_operation_history_get_undo_text ()

    gchar *
    thunar_job_operation_history_get_undo_text
                                   (void);

Returns the description of the undo action The returned string should be freed with `g_free()` when no longer needed.

#### Returns

a newly-allocated string holding the text

### thunar_job_operation_history_get_redo_text ()

    gchar *
    thunar_job_operation_history_get_redo_text
                                   (void);

Returns the description of the redo action. The returned string should be freed with `g_free()` when no longer needed.

#### Returns

a newly-allocated string holding the text

## Types and Values

### THUNAR_TYPE_JOB_OPERATION_HISTORY

    #define THUNAR_TYPE_JOB_OPERATION_HISTORY (thunar_job_operation_history_get_type ())

### ThunarJobOperationHistory

    typedef struct _ThunarJobOperationHistory ThunarJobOperationHistory;

## Property Details

### The `“can-redo”` property

      “can-redo”                 gboolean

can-redo.

Owner: ThunarJobOperationHistory

Flags: Read

Default value: FALSE

### The `“can-undo”` property

      “can-undo”                 gboolean

can-undo.

Owner: ThunarJobOperationHistory

Flags: Read

Default value: FALSE