X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-sidebar-links.c;h=84b49dd292b47175aa5c0ac03df28e149082aba5;hb=0b77ab6efe83e32698b0f1390916c1a7d7738261;hp=688200732fc77c742f2d68c8f0b1b470856a2957;hpb=2380ada377881c8e6bf00368f713ebd72e355dda;p=evince.git diff --git a/shell/ev-sidebar-links.c b/shell/ev-sidebar-links.c index 68820073..84b49dd2 100644 --- a/shell/ev-sidebar-links.c +++ b/shell/ev-sidebar-links.c @@ -52,6 +52,7 @@ struct _EvSidebarLinksPrivate { enum { PROP_0, PROP_MODEL, + PROP_WIDGET, }; @@ -128,6 +129,9 @@ ev_sidebar_links_get_property (GObject *object, case PROP_MODEL: g_value_set_object (value, ev_sidebar_links->priv->model); break; + case PROP_WIDGET: + g_value_set_object (value, ev_sidebar_links->priv->tree_view); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -174,6 +178,9 @@ ev_sidebar_links_class_init (EvSidebarLinksClass *ev_sidebar_links_class) "Current Model", GTK_TYPE_TREE_MODEL, G_PARAM_READWRITE)); + g_object_class_override_property (g_object_class, + PROP_WIDGET, + "main-widget"); g_type_class_add_private (g_object_class, sizeof (EvSidebarLinksPrivate)); } @@ -220,12 +227,14 @@ create_loading_model (void) /* Creates a fake model to indicate that we're loading */ retval = (GtkTreeModel *)gtk_list_store_new (EV_DOCUMENT_LINKS_COLUMN_NUM_COLUMNS, G_TYPE_STRING, - G_TYPE_OBJECT); + G_TYPE_OBJECT, + G_TYPE_BOOLEAN); gtk_list_store_append (GTK_LIST_STORE (retval), &iter); markup = g_strdup_printf ("%s", _("Loading...")); gtk_list_store_set (GTK_LIST_STORE (retval), &iter, EV_DOCUMENT_LINKS_COLUMN_MARKUP, markup, + EV_DOCUMENT_LINKS_COLUMN_EXPAND, FALSE, EV_DOCUMENT_LINKS_COLUMN_LINK, NULL, -1); g_free (markup); @@ -515,16 +524,39 @@ row_activated_callback (GtkTreeView *treeview, return; } - + +static void +expand_open_links (GtkTreeView *tree_view, GtkTreeModel *model, GtkTreeIter *parent) +{ + GtkTreeIter iter; + EvLink *link; + gboolean expand; + + if (gtk_tree_model_iter_children (model, &iter, parent)) { + do { + gtk_tree_model_get (model, &iter, + EV_DOCUMENT_LINKS_COLUMN_LINK, &link, + EV_DOCUMENT_LINKS_COLUMN_EXPAND, &expand, + -1); + if (expand) { + GtkTreePath *path; + + path = gtk_tree_model_get_path (model, &iter); + gtk_tree_view_expand_row (tree_view, path, FALSE); + gtk_tree_path_free (path); + } + + expand_open_links (tree_view, model, &iter); + } while (gtk_tree_model_iter_next (model, &iter)); + } +} + static void job_finished_callback (EvJobLinks *job, EvSidebarLinks *sidebar_links) { EvSidebarLinksPrivate *priv; GtkTreeSelection *selection; - GtkTreeIter iter; - GtkTreePath *path; - gboolean result; priv = sidebar_links->priv; @@ -535,16 +567,8 @@ job_finished_callback (EvJobLinks *job, g_object_unref (job); priv->job = NULL; - /* Expand one level of the tree */ - path = gtk_tree_path_new_first (); - for (result = gtk_tree_model_get_iter_first (priv->model, &iter); - result; - result = gtk_tree_model_iter_next (priv->model, &iter)) { - gtk_tree_view_expand_row (GTK_TREE_VIEW (priv->tree_view), path, FALSE); - gtk_tree_path_next (path); - } - gtk_tree_path_free (path); - + expand_open_links (GTK_TREE_VIEW (priv->tree_view), priv->model, NULL); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view)); gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); priv->selection_id = g_signal_connect (selection, "changed", @@ -581,7 +605,7 @@ ev_sidebar_links_set_document (EvSidebarPage *sidebar_page, } priv->document = g_object_ref (document); - priv->page_cache = ev_document_get_page_cache (document); + priv->page_cache = ev_page_cache_get (document); if (priv->job) { g_signal_handlers_disconnect_by_func (priv->job, @@ -613,12 +637,6 @@ ev_sidebar_links_get_label (EvSidebarPage *sidebar_page) return _("Index"); } -GtkWidget * -ev_sidebar_links_get_treeview (EvSidebarLinks *sidebar) -{ - return sidebar->priv->tree_view; -} - static void ev_sidebar_links_page_iface_init (EvSidebarPageIface *iface) {