[Xfce4-commits] [xfce/thunar] 01/04: Implement functions for copying the history of a view

noreply at xfce.org noreply at xfce.org
Thu Apr 9 11:12:28 CEST 2015


This is an automated email from the git hooks/post-receive script.

hjudt pushed a commit to branch master
in repository xfce/thunar.

commit b6ace36ceb84c9a1e8b4c616ae65862c50854e6e
Author: Harald Judt <h.judt at gmx.at>
Date:   Wed Apr 8 17:04:15 2015 +0200

    Implement functions for copying the history of a view
    
    These functions are needed for keeping the history when a view changes,
    or when a new window or tab is opened that should inherit the history
    of the origin view.
---
 thunar/thunar-history.c       |   38 ++++++++++++++++++++++++++++++++++++++
 thunar/thunar-history.h       |    3 +++
 thunar/thunar-standard-view.c |   31 +++++++++++++++++++++++++++++++
 thunar/thunar-standard-view.h |    7 +++++++
 4 files changed, 79 insertions(+)

diff --git a/thunar/thunar-history.c b/thunar/thunar-history.c
index c6dbb82..d397a22 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 9c91139..efef8ec 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 ce9d3d9..5a24e67 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 b125748..5a73402 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__ */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list