diff --git a/thunar/thunar-job-operation-history.c b/thunar/thunar-job-operation-history.c index 24a003927652580febba29b9d2cc3f958f1d10b7..a7f4d39d681524b9650dc4f74ecad6f1bbf38acc 100644 --- a/thunar/thunar-job-operation-history.c +++ b/thunar/thunar-job-operation-history.c @@ -32,7 +32,20 @@ * 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 */ -static void thunar_job_operation_history_finalize (GObject *object); +/* 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); @@ -63,7 +76,24 @@ 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)); } @@ -98,6 +128,30 @@ thunar_job_operation_history_finalize (GObject *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: * @@ -175,6 +229,9 @@ thunar_job_operation_history_commit (ThunarJobOperation *job_operation) job_operation_history->job_operation_list = g_list_remove_link (job_operation_history->job_operation_list, first); g_list_free_full (first, g_object_unref); } + + g_object_notify (G_OBJECT (job_operation_history), "can-undo"); + g_object_notify (G_OBJECT (job_operation_history), "can-redo"); } @@ -289,6 +346,9 @@ thunar_job_operation_history_undo (void) if (err == NULL) thunar_notify_undo (operation_marker); + + g_object_notify (G_OBJECT (job_operation_history), "can-undo"); + g_object_notify (G_OBJECT (job_operation_history), "can-redo"); } @@ -363,6 +423,9 @@ thunar_job_operation_history_redo (void) if (err == NULL) thunar_notify_redo (operation_marker); + + g_object_notify (G_OBJECT (job_operation_history), "can-undo"); + g_object_notify (G_OBJECT (job_operation_history), "can-redo"); } diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c index 6f6c4be74935e2bc68d317ede57450923aad7991..d754d16db31ed7e038f01c43997947d3bd826f04 100644 --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -995,6 +995,9 @@ thunar_window_init (ThunarWindow *window) /* add first notebook and select it*/ window->notebook_selected = thunar_window_paned_notebooks_add(window); + /* get a reference of the global job operation history */ + window->job_operation_history = thunar_job_operation_history_get_default (); + window->location_toolbar = NULL; thunar_window_location_toolbar_create (window); @@ -1082,9 +1085,6 @@ thunar_window_init (ThunarWindow *window) window->search_query = NULL; window->reset_view_type_idle_id = 0; - - /* get a reference of the global job operation history */ - window->job_operation_history = thunar_job_operation_history_get_default (); } @@ -6070,6 +6070,9 @@ thunar_window_location_toolbar_create (ThunarWindow *window) g_signal_connect (G_OBJECT (window), "button-press-event", G_CALLBACK (thunar_window_button_press_event), G_OBJECT (window)); window->signal_handler_id_history_changed = 0; + g_object_bind_property (G_OBJECT (window->job_operation_history), "can-undo", G_OBJECT (window->location_toolbar_item_undo), "sensitive", G_BINDING_SYNC_CREATE); + g_object_bind_property (G_OBJECT (window->job_operation_history), "can-redo", G_OBJECT (window->location_toolbar_item_redo), "sensitive", G_BINDING_SYNC_CREATE); + /* The UCA shortcuts need to be checked 'by hand', since we dont want to permanently keep menu items for them */ g_signal_connect (window, "key-press-event", G_CALLBACK (thunar_window_check_uca_key_activation), NULL);