]> www.fi.muni.cz Git - evince.git/commitdiff
Small rework of sidebar pages handling. See bug #164811 for details
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Tue, 19 Apr 2005 08:57:50 +0000 (08:57 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Tue, 19 Apr 2005 08:57:50 +0000 (08:57 +0000)
12 files changed:
ChangeLog
po/POTFILES.in
shell/Makefile.am
shell/ev-sidebar-links.c
shell/ev-sidebar-links.h
shell/ev-sidebar-page.c [new file with mode: 0644]
shell/ev-sidebar-page.h [new file with mode: 0644]
shell/ev-sidebar-thumbnails.c
shell/ev-sidebar-thumbnails.h
shell/ev-sidebar.c
shell/ev-sidebar.h
shell/ev-window.c

index 1555090bac6c4e8cb8b16b8d60a73c2f1ca0b1df..3d59e83398e776358452928c15abc3ca85936bd2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2005-04-19  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
+
+       * po/POTFILES.in:
+       
+       ev-sidebar-thumbnails now has translatable labels
+       
+       * shell/Makefile.am:
+       * shell/ev-sidebar-links.c: (ev_sidebar_links_set_document),
+       (ev_sidebar_links_support_document), (ev_sidebar_links_get_label),
+       (ev_sidebar_links_page_iface_init):
+       * shell/ev-sidebar-links.h:
+       * shell/ev-sidebar-page.c: (ev_sidebar_page_get_type),
+       (ev_sidebar_page_support_document), (ev_sidebar_page_set_document),
+       (ev_sidebar_page_get_label):
+       * shell/ev-sidebar-page.h:
+       * shell/ev-sidebar-thumbnails.c: (ev_sidebar_thumbnails_new),
+       (ev_sidebar_thumbnails_set_document),
+       (ev_sidebar_thumbnails_support_document),
+       (ev_sidebar_thumbnails_get_label),
+       (ev_sidebar_thumbnails_page_iface_init):
+       * shell/ev-sidebar-thumbnails.h:
+       * shell/ev-sidebar.c: (ev_sidebar_init), (ev_sidebar_add_page),
+       (ev_sidebar_set_document):
+       * shell/ev-sidebar.h:
+       * shell/ev-window.c: (ev_window_setup_document), (ev_window_init):
+       
+       Small rework of sidebar code. Now sidebar pages should implement
+       EvSidebarPage interface. That makes page management in EvSidebar
+       easier. See bug #164811 for details
+
 2005-04-19  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
 
        * shell/ev-application.c: (ev_application_open):
index 927b3402b7cdb146258d323e8028e25476bafc0e..74d14b1e28af217ccae7273aa2ac6391287fd444 100644 (file)
@@ -14,6 +14,7 @@ shell/ev-password-view.c
 shell/ev-password.c
 shell/ev-print-job.c
 shell/ev-sidebar-links.c
+shell/ev-sidebar-thumbnails.c
 shell/ev-view.c
 shell/ev-window.c
 shell/main.c
index 95dcf833869452733f22e485a445b35e719f55a1..c7181a5ca16a91a2d1d6606066dc392f33b62c3e 100644 (file)
@@ -75,6 +75,8 @@ evince_SOURCES=                               \
        ev-sidebar.h                    \
        ev-sidebar-links.c              \
        ev-sidebar-links.h              \
+       ev-sidebar-page.c               \
+       ev-sidebar-page.h               \
        ev-sidebar-thumbnails.c         \
        ev-sidebar-thumbnails.h         \
        ev-stock-icons.c                \
index 1a4312f34928b53f286b2f3b9d7c74ff5c9ae6c3..830d6bec95941207a4d2129595f95d591087ce71 100644 (file)
@@ -28,6 +28,7 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
+#include "ev-sidebar-page.h"
 #include "ev-sidebar-links.h"
 #include "ev-job-queue.h"
 #include "ev-document-links.h"
@@ -52,17 +53,30 @@ enum {
 };
 
 
-static void links_page_num_func  (GtkTreeViewColumn *tree_column,
-                                 GtkCellRenderer   *cell,
-                                 GtkTreeModel      *tree_model,
-                                 GtkTreeIter       *iter,
-                                 EvSidebarLinks    *sidebar_links);
-static void update_page_callback (EvPageCache       *page_cache,
-                                 gint               current_page,
-                                 EvSidebarLinks    *sidebar_links);
+static void links_page_num_func                                (GtkTreeViewColumn *tree_column,
+                                                        GtkCellRenderer   *cell,
+                                                        GtkTreeModel      *tree_model,
+                                                        GtkTreeIter       *iter,
+                                                        EvSidebarLinks    *sidebar_links);
+static void update_page_callback                       (EvPageCache       *page_cache,
+                                                        gint               current_page,
+                                                        EvSidebarLinks    *sidebar_links);
+static void ev_sidebar_links_page_iface_init           (EvSidebarPageIface *iface);
+static void ev_sidebar_links_clear_document            (EvSidebarLinks *sidebar_links);
+static void ev_sidebar_links_set_document                      (EvSidebarPage  *sidebar_page,
+                                                        EvDocument     *document);
+static gboolean ev_sidebar_links_support_document      (EvSidebarPage  *sidebar_page,
+                                                        EvDocument     *document);
+static const gchar* ev_sidebar_links_get_label                 (EvSidebarPage *sidebar_page);
 
 
-G_DEFINE_TYPE (EvSidebarLinks, ev_sidebar_links, GTK_TYPE_VBOX)
+G_DEFINE_TYPE_EXTENDED (EvSidebarLinks, 
+                        ev_sidebar_links, 
+                        GTK_TYPE_VBOX,
+                        0, 
+                        G_IMPLEMENT_INTERFACE (EV_TYPE_SIDEBAR_PAGE, 
+                                              ev_sidebar_links_page_iface_init))
+
 
 #define EV_SIDEBAR_LINKS_GET_PRIVATE(object) \
        (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR_LINKS, EvSidebarLinksPrivate))
@@ -313,7 +327,7 @@ ev_sidebar_links_new (void)
        return ev_sidebar_links;
 }
 
-void
+static void
 ev_sidebar_links_clear_document (EvSidebarLinks *sidebar_links)
 {
        EvSidebarLinksPrivate *priv;
@@ -428,14 +442,17 @@ job_finished_cb (EvJobLinks     *job,
 
 }
 
-void
-ev_sidebar_links_set_document (EvSidebarLinks *sidebar_links,
+static void
+ev_sidebar_links_set_document (EvSidebarPage  *sidebar_page,
                               EvDocument     *document)
 {
+       EvSidebarLinks *sidebar_links;
        EvSidebarLinksPrivate *priv;
 
-       g_return_if_fail (EV_IS_SIDEBAR_LINKS (sidebar_links));
+       g_return_if_fail (EV_IS_SIDEBAR_PAGE (sidebar_page));
        g_return_if_fail (EV_IS_DOCUMENT (document));
+       
+       sidebar_links = EV_SIDEBAR_LINKS (sidebar_page);
 
        priv = sidebar_links->priv;
 
@@ -454,3 +471,25 @@ ev_sidebar_links_set_document (EvSidebarLinks *sidebar_links,
 
 }
 
+static gboolean
+ev_sidebar_links_support_document (EvSidebarPage  *sidebar_page,
+                                  EvDocument *document)
+{
+       return (EV_IS_DOCUMENT_LINKS (document) &&
+                   ev_document_links_has_document_links (EV_DOCUMENT_LINKS (document)));
+}
+
+static const gchar*
+ev_sidebar_links_get_label (EvSidebarPage *sidebar_page)
+{
+    return _("Index");
+}
+
+static void
+ev_sidebar_links_page_iface_init (EvSidebarPageIface *iface)
+{
+       iface->support_document = ev_sidebar_links_support_document;
+       iface->set_document = ev_sidebar_links_set_document;
+       iface->get_label = ev_sidebar_links_get_label;
+}
+
index 59af8bbd5ae2f79985761599a3e15fd53cb73078..b9691e35a6bcf566ecf4136fd73de24990636d30 100644 (file)
@@ -52,9 +52,6 @@ struct _EvSidebarLinksClass {
 
 GType      ev_sidebar_links_get_type       (void);
 GtkWidget *ev_sidebar_links_new            (void);
-void       ev_sidebar_links_set_document   (EvSidebarLinks *ev_sidebar_links,
-                                           EvDocument         *document);
-void       ev_sidebar_links_clear_document (EvSidebarLinks *sidebar_links);
 
 G_END_DECLS
 
diff --git a/shell/ev-sidebar-page.c b/shell/ev-sidebar-page.c
new file mode 100644 (file)
index 0000000..dfd21d3
--- /dev/null
@@ -0,0 +1,98 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ *  Copyright (C) 2005 Marco Pesenti Gritti
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ev-sidebar-page.h"
+
+GType
+ev_sidebar_page_get_type (void)
+{
+       static GType type = 0;
+
+       if (G_UNLIKELY (type == 0))
+       {
+               static const GTypeInfo sidebar_page_info =
+               {
+                       sizeof (EvDocumentIface),
+                       NULL,
+                       NULL,
+                       NULL
+               };
+
+               type = g_type_register_static (G_TYPE_INTERFACE,
+                                              "EvSidebarPage",
+                                              &sidebar_page_info, (GTypeFlags)0);
+       }
+
+       return type;
+}
+
+
+gboolean 
+ev_sidebar_page_support_document  (EvSidebarPage    *sidebar_page,
+                                  EvDocument *document)
+{
+        EvSidebarPageIface *iface;
+
+       g_return_val_if_fail (EV_IS_SIDEBAR_PAGE (sidebar_page), FALSE);
+        g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
+
+       iface = EV_SIDEBAR_PAGE_GET_IFACE (sidebar_page);
+
+        g_return_val_if_fail (iface->set_document, FALSE);
+       
+        return iface->support_document (sidebar_page, document);    
+}
+
+void 
+ev_sidebar_page_set_document      (EvSidebarPage    *sidebar_page,
+                                  EvDocument *document)
+{
+       EvSidebarPageIface *iface;
+
+        g_return_if_fail (EV_IS_SIDEBAR_PAGE (sidebar_page));
+       g_return_if_fail (EV_IS_DOCUMENT (document));
+
+       iface = EV_SIDEBAR_PAGE_GET_IFACE (sidebar_page);
+
+       g_return_if_fail (iface->set_document);
+       
+       iface->set_document (sidebar_page, document);
+       
+       return;
+}
+
+const gchar*
+ev_sidebar_page_get_label (EvSidebarPage    *sidebar_page)
+{
+       EvSidebarPageIface *iface;
+
+        g_return_val_if_fail (EV_IS_SIDEBAR_PAGE (sidebar_page), NULL);
+
+       iface = EV_SIDEBAR_PAGE_GET_IFACE (sidebar_page);
+
+       g_return_val_if_fail (iface->get_label, NULL);
+       
+       return iface->get_label (sidebar_page);
+}
+
diff --git a/shell/ev-sidebar-page.h b/shell/ev-sidebar-page.h
new file mode 100644 (file)
index 0000000..e4d19eb
--- /dev/null
@@ -0,0 +1,63 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ *  Copyright (C) 2005 Marco Pesenti Gritti
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef EV_SIDEBAR_PAGE_H
+#define EV_SIDEBAR_PAGE_H
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include "ev-document.h"
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_SIDEBAR_PAGE           (ev_sidebar_page_get_type ())
+#define EV_SIDEBAR_PAGE(o)             (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_SIDEBAR_PAGE, EvSidebarPage))
+#define EV_SIDEBAR_PAGE_IFACE(k)       (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_SIDEBAR_PAGE, EvSidebarPageIface))
+#define EV_IS_SIDEBAR_PAGE(o)          (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_SIDEBAR_PAGE))
+#define EV_IS_SIDEBAR_PAGE_IFACE(k)    (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_SIDEBAR_PAGE))
+#define EV_SIDEBAR_PAGE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_SIDEBAR_PAGE, EvSidebarPageIface))
+
+typedef struct _EvSidebarPage    EvSidebarPage;
+typedef struct _EvSidebarPageIface   EvSidebarPageIface;
+
+struct _EvSidebarPageIface
+{
+       GTypeInterface base_iface;
+
+       /* Methods  */
+       gboolean    (* support_document)  (EvSidebarPage   *sidebar_page,
+                                          EvDocument *document);
+       void        (* set_document)      (EvSidebarPage   *sidebar_page,
+                                          EvDocument *document);
+       const gchar* (* get_label)        (EvSidebarPage   *sidebar_page);
+};
+
+GType         ev_sidebar_page_get_type          (void);
+gboolean      ev_sidebar_page_support_document  (EvSidebarPage    *sidebar_page,
+                                                EvDocument *document);
+void          ev_sidebar_page_set_document      (EvSidebarPage    *sidebar_page,
+                                                EvDocument *document);
+const gchar*  ev_sidebar_page_get_label         (EvSidebarPage *page);
+
+
+G_END_DECLS
+
+#endif /* EV_SIDEBAR_PAGE */
index b2734cb2dc1a63ac22c89e1e40b838bc91c4404f..a22d70ebd70dd8717a91462e45eec03f66f88862 100644 (file)
@@ -28,7 +28,9 @@
 
 #include <string.h>
 #include <gtk/gtk.h>
+#include <glib/gi18n.h>
 
+#include "ev-sidebar-page.h"
 #include "ev-sidebar-thumbnails.h"
 #include "ev-document-thumbnails.h"
 #include "ev-document-misc.h"
@@ -58,13 +60,24 @@ enum {
        NUM_COLUMNS
 };
 
-G_DEFINE_TYPE (EvSidebarThumbnails, ev_sidebar_thumbnails, GTK_TYPE_VBOX);
+static void     ev_sidebar_thumbnails_clear_model              (EvSidebarThumbnails *sidebar);
+static gboolean ev_sidebar_thumbnails_support_document         (EvSidebarPage   *sidebar_page,
+                                                                EvDocument *document);
+static void     ev_sidebar_thumbnails_page_iface_init          (EvSidebarPageIface *iface);
+static void    ev_sidebar_thumbnails_set_document              (EvSidebarPage  *sidebar_page,
+                                                                EvDocument          *document);
+static const gchar* ev_sidebar_thumbnails_get_label            (EvSidebarPage *sidebar_page);
+
+G_DEFINE_TYPE_EXTENDED (EvSidebarThumbnails, 
+                        ev_sidebar_thumbnails, 
+                        GTK_TYPE_VBOX,
+                        0, 
+                        G_IMPLEMENT_INTERFACE (EV_TYPE_SIDEBAR_PAGE, 
+                                              ev_sidebar_thumbnails_page_iface_init))
 
 #define EV_SIDEBAR_THUMBNAILS_GET_PRIVATE(object) \
        (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR_THUMBNAILS, EvSidebarThumbnailsPrivate));
 
-static void 
-ev_sidebar_thumbnails_clear_model (EvSidebarThumbnails *sidebar);
 
 static void
 ev_sidebar_thumbnails_dispose (GObject *object)
@@ -90,6 +103,16 @@ ev_sidebar_thumbnails_class_init (EvSidebarThumbnailsClass *ev_sidebar_thumbnail
        g_type_class_add_private (g_object_class, sizeof (EvSidebarThumbnailsPrivate));
 }
 
+GtkWidget *
+ev_sidebar_thumbnails_new (void)
+{
+       GtkWidget *ev_sidebar_thumbnails;
+
+       ev_sidebar_thumbnails = g_object_new (EV_TYPE_SIDEBAR_THUMBNAILS, NULL);
+
+       return ev_sidebar_thumbnails;
+}
+
 static void
 adjustment_changed_cb (GtkAdjustment       *adjustment,
                       EvSidebarThumbnails *ev_sidebar_thumbnails)
@@ -186,16 +209,6 @@ ev_sidebar_thumbnails_init (EvSidebarThumbnails *ev_sidebar_thumbnails)
        gtk_widget_show_all (swindow);
 }
 
-GtkWidget *
-ev_sidebar_thumbnails_new (void)
-{
-       GtkWidget *ev_sidebar_thumbnails;
-
-       ev_sidebar_thumbnails = g_object_new (EV_TYPE_SIDEBAR_THUMBNAILS, NULL);
-
-       return ev_sidebar_thumbnails;
-}
-
 static void
 page_changed_cb (EvPageCache         *page_cache,
                 int                  page,
@@ -230,10 +243,11 @@ thumbnail_job_completed_callback (EvJobThumbnail      *job,
                            -1);
 }
 
-void
-ev_sidebar_thumbnails_set_document (EvSidebarThumbnails *sidebar_thumbnails,
+static void
+ev_sidebar_thumbnails_set_document (EvSidebarPage      *sidebar_page,
                                    EvDocument          *document)
 {
+       EvSidebarThumbnails *sidebar_thumbnails = EV_SIDEBAR_THUMBNAILS (sidebar_page);
        GdkPixbuf *loading_icon;
        gint i, n_pages;
        GtkTreeIter iter;
@@ -324,4 +338,25 @@ ev_sidebar_thumbnails_clear_model (EvSidebarThumbnails *sidebar_thumbnails)
     gtk_list_store_clear (priv->list_store);
 }
 
+static gboolean
+ev_sidebar_thumbnails_support_document (EvSidebarPage   *sidebar_page,
+                                       EvDocument *document)
+{
+       return (EV_IS_DOCUMENT_THUMBNAILS (document) &&
+                   (ev_document_get_n_pages (document) > 1));
+}
+
+static const gchar*
+ev_sidebar_thumbnails_get_label (EvSidebarPage *sidebar_page)
+{
+    return _("Thumbnails");
+}
+
+static void
+ev_sidebar_thumbnails_page_iface_init (EvSidebarPageIface *iface)
+{
+       iface->support_document = ev_sidebar_thumbnails_support_document;
+       iface->set_document = ev_sidebar_thumbnails_set_document;
+       iface->get_label = ev_sidebar_thumbnails_get_label;
+}
 
index 45f68fce2c69a3504ca33bae4293930d8c3ac2d3..ccfc09b98d0733d87028c1691226e6980e10d94b 100644 (file)
@@ -54,9 +54,6 @@ struct _EvSidebarThumbnailsClass {
 GType      ev_sidebar_thumbnails_get_type (void);
 GtkWidget *ev_sidebar_thumbnails_new      (void);
 
-void ev_sidebar_thumbnails_set_document (EvSidebarThumbnails *sidebar_thumbnails,
-                                        EvDocument          *document);
-
 G_END_DECLS
 
 #endif /* __EV_SIDEBAR_THUMBNAILS_H__ */
index b1454d93e4af06245e645c71efa5d1ee197192a4..3f296075a84c7e9fb9e382da0cbb4da6c1346de8 100644 (file)
 #include <gdk/gdkkeysyms.h>
 
 #include "ev-sidebar.h"
+#include "ev-sidebar-page.h"
 #include "ev-document-thumbnails.h"
 #include "ev-document-links.h"
-#include "ev-sidebar-links.h"
-#include "ev-sidebar-thumbnails.h"
-
-typedef struct
-{
-       char *id;
-       char *title;
-       GtkWidget *main_widget;
-} EvSidebarPage;
 
 enum
 {
-       PAGE_COLUMN_ID,
        PAGE_COLUMN_TITLE,
        PAGE_COLUMN_MENU_ITEM,
        PAGE_COLUMN_MAIN_WIDGET,
@@ -237,7 +228,6 @@ ev_sidebar_init (EvSidebar *ev_sidebar)
        /* data model */
        ev_sidebar->priv->page_model = (GtkTreeModel *)
                        gtk_list_store_new (PAGE_COLUMN_NUM_COLS,
-                                           G_TYPE_STRING,
                                            G_TYPE_STRING,
                                            GTK_TYPE_WIDGET,
                                            GTK_TYPE_WIDGET,
@@ -310,6 +300,8 @@ ev_sidebar_init (EvSidebar *ev_sidebar)
        gtk_box_pack_start (GTK_BOX (ev_sidebar), ev_sidebar->priv->notebook,
                            TRUE, TRUE, 0);
        gtk_widget_show (ev_sidebar->priv->notebook);
+
+       gtk_widget_set_sensitive (GTK_WIDGET (ev_sidebar), FALSE);
 }
 
 /* Public functions */
@@ -326,19 +318,19 @@ ev_sidebar_new (void)
 
 void
 ev_sidebar_add_page (EvSidebar   *ev_sidebar,
-                    const gchar *page_id,
-                    const gchar *title,
                     GtkWidget   *main_widget)
 {
        GtkTreeIter iter;
        GtkWidget *menu_item;
        gchar *label_title;
+       const gchar *title;
        int index;
           
        g_return_if_fail (EV_IS_SIDEBAR (ev_sidebar));
-       g_return_if_fail (page_id != NULL);
-       g_return_if_fail (title != NULL);
+       g_return_if_fail (EV_IS_SIDEBAR_PAGE (main_widget));
        g_return_if_fail (GTK_IS_WIDGET (main_widget));
+       
+       title = ev_sidebar_page_get_label (EV_SIDEBAR_PAGE (main_widget));
           
        index = gtk_notebook_append_page (GTK_NOTEBOOK (ev_sidebar->priv->notebook),
                                          main_widget, NULL);
@@ -353,7 +345,6 @@ ev_sidebar_add_page (EvSidebar   *ev_sidebar,
           
        gtk_list_store_insert_with_values (GTK_LIST_STORE (ev_sidebar->priv->page_model),
                                           &iter, 0,
-                                          PAGE_COLUMN_ID, page_id,
                                           PAGE_COLUMN_TITLE, title,
                                           PAGE_COLUMN_MENU_ITEM, menu_item,
                                           PAGE_COLUMN_MAIN_WIDGET, main_widget,
@@ -380,19 +371,19 @@ ev_sidebar_set_document (EvSidebar   *sidebar,
 {
        EvSidebarPrivate *priv;
        GtkTreeIter iter;
-       gboolean result;
+       gboolean valid;
+       gboolean has_pages;
           
        g_return_if_fail (EV_IS_SIDEBAR (sidebar));
        g_return_if_fail (EV_IS_DOCUMENT (document));
           
        priv = sidebar->priv;
        
-       /* FIXME: We should prolly make sidebars have an interface.  For now, we        
-        * do this bad hack (TM)        
-        */
-       for (result = gtk_tree_model_get_iter_first (priv->page_model, &iter);
-            result;
-            result = gtk_tree_model_iter_next (priv->page_model, &iter)) {
+       has_pages = FALSE;
+       
+       for (valid = gtk_tree_model_get_iter_first (priv->page_model, &iter);
+            valid;
+            valid = gtk_tree_model_iter_next (priv->page_model, &iter)) {
                GtkWidget *widget;
                GtkWidget *menu_widget;
 
@@ -402,40 +393,18 @@ ev_sidebar_set_document (EvSidebar   *sidebar,
                                    -1);
                         
 
-               if (EV_IS_SIDEBAR_LINKS (widget)) {
-                       if (EV_IS_DOCUMENT_LINKS (document) &&
-                               ev_document_links_has_document_links (EV_DOCUMENT_LINKS (document))) {
-                               ev_sidebar_links_set_document (EV_SIDEBAR_LINKS (widget), document);
-                               continue;
-                       } else {
-                               gtk_widget_set_sensitive (menu_widget, FALSE);
-                       }
-               }
-               
-               if (EV_IS_SIDEBAR_THUMBNAILS (widget)) {
-                       if (EV_IS_DOCUMENT_THUMBNAILS (document) &&
-                           (ev_document_get_n_pages (document) > 1)) {
-                               ev_sidebar_thumbnails_set_document (EV_SIDEBAR_THUMBNAILS (widget), document);
-                               continue;
-                       } else {
+               if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (widget), document)) {
+                               ev_sidebar_page_set_document (EV_SIDEBAR_PAGE (widget), document);
+                               has_pages = TRUE;
+               } else {
                                gtk_widget_set_sensitive (menu_widget, FALSE);
-                       }
                }
        }
+       
+       if (!has_pages) {
+               gtk_widget_hide (GTK_WIDGET (sidebar));
+       } else {
+               gtk_widget_set_sensitive (GTK_WIDGET (sidebar), TRUE);
+       }
 }
 
-gboolean   
-ev_sidebar_supports_document (EvSidebar   *ev_sidebar,
-                             EvDocument  *document)
-{
-    gboolean need_thumbnails;
-    gboolean need_index;
-    
-    need_thumbnails = EV_IS_DOCUMENT_THUMBNAILS (document) && (ev_document_get_n_pages (document) > 1);
-    need_index = (EV_IS_DOCUMENT_LINKS (document));
-    
-    return need_thumbnails || need_index;
-}
-
-
-
index 551f35fe80e68fb33f30a6c5d6dc599988fa1c32..d599fff6caa818aeb3632d90bbe6df5176e173ec 100644 (file)
@@ -53,13 +53,9 @@ struct _EvSidebarClass {
 GType      ev_sidebar_get_type            (void);
 GtkWidget *ev_sidebar_new                 (void);
 void       ev_sidebar_add_page            (EvSidebar   *ev_sidebar,
-                                           const gchar *page_id,
-                                           const gchar *title,
                                            GtkWidget   *main_widget);
 void       ev_sidebar_set_document        (EvSidebar   *ev_sidebar,
                                            EvDocument  *document);
-gboolean   ev_sidebar_supports_document           (EvSidebar   *ev_sidebar,
-                                           EvDocument  *document);
 
 G_END_DECLS
 
index 635605625772f274063976b5b8501fcf5940a351..6aabf14b730bea8608f2d5847b0ced865c03c9f1 100644 (file)
@@ -92,7 +92,6 @@ struct _EvWindowPrivate {
        GtkWidget *toolbar;
        GtkWidget *hpaned;
        GtkWidget *sidebar;
-       GtkWidget *thumbs_sidebar;
        GtkWidget *find_bar;
        GtkWidget *scrolled_window;
        GtkWidget *view;
@@ -448,21 +447,6 @@ update_window_title (EvDocument *document, GParamSpec *pspec, EvWindow *ev_windo
        g_free (title);
 }
 
-static void
-hide_sidebar_and_actions (EvWindow *ev_window)
-{
-       GtkAction *action;
-       /* Alsthough we update the hiddenness of the sidebar, we don't want to
-        * store the value */
-       g_signal_handlers_disconnect_by_func (ev_window->priv->sidebar,
-                                             ev_window_sidebar_visibility_changed_cb,
-                                             ev_window);
-       gtk_widget_hide (ev_window->priv->sidebar);
-       action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
-       gtk_action_set_sensitive (action, FALSE);
-
-}
-
 static void
 find_changed_cb (EvDocument *document, int page, EvWindow *ev_window)
 {
@@ -502,10 +486,7 @@ ev_window_setup_document (EvWindow *ev_window)
 
        ev_window_set_page_mode (ev_window, PAGE_MODE_SINGLE_PAGE);
 
-       if (ev_sidebar_supports_document (sidebar, document)) 
-               ev_sidebar_set_document (sidebar, document);
-       else
-               hide_sidebar_and_actions (ev_window);
+       ev_sidebar_set_document (sidebar, document);
 
        if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
                ev_view_set_document (view, document);
@@ -2400,16 +2381,12 @@ ev_window_init (EvWindow *ev_window)
                          ev_window);
        gtk_widget_show (sidebar_widget);
        ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
-                            "index",
-                            _("Index"),
                             sidebar_widget);
 
-       ev_window->priv->thumbs_sidebar = ev_sidebar_thumbnails_new ();
-       gtk_widget_show (ev_window->priv->thumbs_sidebar);
+       sidebar_widget = ev_sidebar_thumbnails_new ();
+       gtk_widget_show (sidebar_widget);
        ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
-                            "thumbnails",
-                            _("Thumbnails"),
-                            ev_window->priv->thumbs_sidebar);
+                            sidebar_widget);
 
        ev_window->priv->scrolled_window =
                GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,