Commit 45abf6a7 authored by Nelson Benítez León's avatar Nelson Benítez León Committed by Germán Poo-Caamaño

sidebar outline: close auto-expanded rows and remember state

This commit adds the following features:

- Remember and restore state for rows that were manually
  collapsed and expanded by the user. To save that information
  we use two new metadata keys 'index-expand' and 'index-collapse'.

  Metadata key 'index-expand' is a string containing the GtkTreePath's
  that the user has explicitly expanded, except those already marked
  expanded by the pdf producer data. The string format is
  "|path1|path2|path3|" (starting and ending in pipe). A case with
  only one element would be "|path1|". A case with no elements would be
  the empty string "". This is to facilitate the search of the paths.

  Metadata key 'index-collapse' is a string containing the GtkTreePath's
  that the pdf producer data had them marked as expanded but the user
  has explicitly collapsed them. The string format is the same as in
  'index_expand'.

- When scrolling through document, take the chance to collapse rows
  that have been automatically expanded previously. This avoids
  cluttering the tree view with too many entries when navigating
  documents that have heavily indexed outlines.

Issue #85
parent 9c4dc4cd
This diff is collapsed.
......@@ -364,3 +364,34 @@ get_gdk_pixbuf_format_by_extension (const gchar *uri)
g_slist_free (pixbuf_formats);
return NULL;
}
/*
* Replace all occurences of substr in str with repl
*
* @param str a string
* @param substr some string to replace
* @param repl a replacement string
*
* @return a newly allocated string with the substr replaced by repl; free with g_free
*/
gchar*
ev_str_replace (const char *str, const char *substr, const char *repl)
{
GString *gstr;
const char *cur;
if (str == NULL || substr == NULL || repl == NULL)
return NULL;
gstr = g_string_sized_new (2 * strlen (str));
for (cur = str; *cur; ++cur) {
if (g_str_has_prefix (cur, substr)) {
g_string_append (gstr, repl);
cur += strlen (substr) - 1;
} else
g_string_append_c (gstr, *cur);
}
return g_string_free (gstr, FALSE);
}
......@@ -39,6 +39,7 @@ void ev_gui_menu_position_tree_selection (GtkMenu *menu,
void file_chooser_dialog_add_writable_pixbuf_formats (GtkFileChooser *chooser);
GdkPixbufFormat* get_gdk_pixbuf_format_by_extension (const gchar *uri);
gchar* ev_str_replace (const char *str, const char *substr, const char *repl);
G_END_DECLS
......
......@@ -7557,3 +7557,11 @@ ev_window_focus_view (EvWindow *ev_window)
gtk_widget_grab_focus (ev_window->priv->view);
}
EvMetadata *
ev_window_get_metadata (EvWindow *ev_window)
{
g_return_val_if_fail (EV_WINDOW (ev_window), NULL);
return ev_window->priv->metadata;
}
......@@ -29,6 +29,7 @@
#include "ev-link.h"
#include "ev-history.h"
#include "ev-document-model.h"
#include "ev-metadata.h"
G_BEGIN_DECLS
......@@ -96,6 +97,7 @@ void ev_window_focus_view (EvWindow *ev_win
GtkWidget *ev_window_get_toolbar (EvWindow *ev_window);
void ev_window_handle_annot_popup (EvWindow *ev_window,
EvAnnotation *annot);
EvMetadata *ev_window_get_metadata (EvWindow *ev_window);
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment