diff options
-rw-r--r-- | thunar/thunar-history.c | 38 | ||||
-rw-r--r-- | thunar/thunar-history.h | 3 | ||||
-rw-r--r-- | thunar/thunar-standard-view.c | 31 | ||||
-rw-r--r-- | thunar/thunar-standard-view.h | 7 |
4 files changed, 79 insertions, 0 deletions
diff --git a/thunar/thunar-history.c b/thunar/thunar-history.c index c6dbb82e..d397a224 100644 --- a/thunar/thunar-history.c +++ b/thunar/thunar-history.c @@ -740,6 +740,44 @@ thunar_history_set_action_group (ThunarHistory *history, +ThunarHistory * +thunar_history_copy (ThunarHistory *history, + GtkActionGroup *action_group) +{ + ThunarHistory *copy; + GSList *lp; + + _thunar_return_val_if_fail (history == NULL || THUNAR_IS_HISTORY (history), NULL); + _thunar_return_val_if_fail (action_group == NULL || GTK_IS_ACTION_GROUP (action_group), NULL); + + if (G_UNLIKELY (history == NULL)) + return NULL; + + copy = g_object_new (THUNAR_TYPE_HISTORY, NULL); + + /* take a ref on the current directory */ + copy->current_directory = g_object_ref (history->current_directory); + + /* set the action group */ + thunar_history_set_action_group (copy, action_group); + + /* copy the back list */ + for (lp = history->back_list; lp != NULL; lp = lp->next) + copy->back_list = g_slist_append (copy->back_list, g_object_ref (G_OBJECT (lp->data))); + + /* copy the forward list */ + for (lp = history->forward_list; lp != NULL; lp = lp->next) + copy->forward_list = g_slist_append (copy->forward_list, g_object_ref (G_OBJECT (lp->data))); + + /* update the sensitivity of the actions */ + gtk_action_set_sensitive (copy->action_back, (copy->back_list != NULL)); + gtk_action_set_sensitive (copy->action_forward, (copy->forward_list != NULL)); + + return copy; +} + + + /** * thunar_file_history_peek_back: * @history : a #ThunarHistory. diff --git a/thunar/thunar-history.h b/thunar/thunar-history.h index 9c91139a..efef8ec1 100644 --- a/thunar/thunar-history.h +++ b/thunar/thunar-history.h @@ -36,6 +36,9 @@ typedef struct _ThunarHistory ThunarHistory; GType thunar_history_get_type (void) G_GNUC_CONST; +ThunarHistory *thunar_history_copy (ThunarHistory *history, + GtkActionGroup *action_group); + ThunarFile *thunar_history_peek_back (ThunarHistory *history); ThunarFile *thunar_history_peek_forward (ThunarHistory *history); diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c index ce9d3d99..5a24e67a 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -4406,3 +4406,34 @@ thunar_standard_view_selection_changed (ThunarStandardView *standard_view) g_object_notify_by_pspec (G_OBJECT (standard_view), standard_view_props[PROP_SELECTED_FILES]); } + + +void +thunar_standard_view_set_history (ThunarStandardView *standard_view, + ThunarHistory *history) +{ + ThunarFile *file; + + _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view)); + _thunar_return_if_fail (history == NULL || THUNAR_IS_HISTORY (history)); + + /* set the new history */ + g_object_unref (standard_view->priv->history); + standard_view->priv->history = history; + + /* connect callback */ + g_signal_connect_swapped (G_OBJECT (history), "change-directory", G_CALLBACK (thunar_navigator_change_directory), standard_view); + + /* make the history use the action group of this view */ + g_object_set (G_OBJECT (history), "action-group", standard_view->action_group, NULL); +} + + + +ThunarHistory * +thunar_standard_view_copy_history (ThunarStandardView *standard_view) +{ + _thunar_return_val_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view), NULL); + + return thunar_history_copy (standard_view->priv->history, NULL); +} diff --git a/thunar/thunar-standard-view.h b/thunar/thunar-standard-view.h index b125748e..5a734025 100644 --- a/thunar/thunar-standard-view.h +++ b/thunar/thunar-standard-view.h @@ -21,6 +21,7 @@ #define __THUNAR_STANDARD_VIEW_H__ #include <thunar/thunar-clipboard-manager.h> +#include <thunar/thunar-history.h> #include <thunar/thunar-icon-factory.h> #include <thunar/thunar-list-model.h> #include <thunar/thunar-preferences.h> @@ -152,6 +153,12 @@ void thunar_standard_view_queue_popup (ThunarStandardView *standard_view void thunar_standard_view_selection_changed (ThunarStandardView *standard_view); + +void thunar_standard_view_set_history (ThunarStandardView *standard_view, + ThunarHistory *history); + +ThunarHistory *thunar_standard_view_copy_history (ThunarStandardView *standard_view); + G_END_DECLS; #endif /* !__THUNAR_STANDARD_VIEW_H__ */ |