Skip to content
Snippets Groups Projects
Commit 70f0ddef authored by Jannis Pohlmann's avatar Jannis Pohlmann
Browse files

Add thunar_history_peek_back() and thunar_history_peek_forward().

These functions allow it to lookup the previous or next file from the
history and can later be used to auto-select subdirectories when walking
back and forth through the history.
parent 3a01c1e7
No related branches found
No related tags found
No related merge requests found
......@@ -565,3 +565,57 @@ thunar_history_set_action_group (ThunarHistory *history,
g_object_notify (G_OBJECT (history), "action-group");
}
/**
* thunar_file_history_peek_back:
* @history : a #ThunarHistory.
*
* Returns the previous directory in the history.
*
* The returned #ThunarFile is owned by the #ThunarHistory and must
* not be released by the caller.
*
* Return value: the previous #ThunarFile in the history.
**/
ThunarFile *
thunar_history_peek_back (ThunarHistory *history)
{
ThunarFile *result = NULL;
_thunar_return_val_if_fail (THUNAR_IS_HISTORY (history), NULL);
/* pick the first (conceptually the last) file in the back list, if there are any */
if (history->back_list != NULL)
result = history->back_list->data;
return result;
}
/**
* thunar_file_history_peek_forward:
* @history : a #ThunarHistory.
*
* Returns the next directory in the history. This often but not always
* refers to a child of the current directory.
*
* The returned #ThunarFile is owned by the #ThunarHistory and must
* not be released by the caller.
*
* Return value: the next #ThunarFile in the history.
**/
ThunarFile *
thunar_history_peek_forward (ThunarHistory *history)
{
ThunarFile *result = NULL;
_thunar_return_val_if_fail (THUNAR_IS_HISTORY (history), NULL);
/* pick the first file in the forward list, if there are any */
if (history->forward_list != NULL)
result = history->forward_list->data;
return result;
}
......@@ -20,7 +20,7 @@
#ifndef __THUNAR_HISTORY_H__
#define __THUNAR_HISTORY_H__
#include <gtk/gtk.h>
#include <thunar/thunar-file.h>
G_BEGIN_DECLS;
......@@ -41,6 +41,8 @@ ThunarHistory *thunar_history_new (void) G_GNUC_MALLOC;
GtkActionGroup *thunar_history_get_action_group (const ThunarHistory *history);
void thunar_history_set_action_group (ThunarHistory *history,
GtkActionGroup *action_group);
ThunarFile *thunar_history_peek_back (ThunarHistory *history);
ThunarFile *thunar_history_peek_forward (ThunarHistory *history);
G_END_DECLS;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment