[gnome-documents] all: add GdMainView/GdMainIconView/GdMainListView



commit 62301d4c73b38e87ddf2b3fe13fd56f73200ef8b
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Dec 5 18:32:53 2011 -0500

    all: add GdMainView/GdMainIconView/GdMainListView
    
    Instead of implementing the view classes in JS, for the sake of sharing
    them with other Findind and Reminding applications, split the main view
    into an interface (GdMainView) with two concrete implementations for
    Icon/List views.
    An additional GdMainViewWidget will eventually take the place of the
    View JS base class.

 src/Makefile-lib.am            |    8 +
 src/lib/gd-main-icon-view.c    |  181 +++++++++++++++++
 src/lib/gd-main-icon-view.h    |   74 +++++++
 src/lib/gd-main-list-view.c    |  215 ++++++++++++++++++++
 src/lib/gd-main-list-view.h    |   80 ++++++++
 src/lib/gd-main-view-generic.c |  144 ++++++++++++++
 src/lib/gd-main-view-generic.h |  105 ++++++++++
 src/lib/gd-main-view.c         |  419 ++++++++++++++++++++++++++++++++++++++++
 src/lib/gd-main-view.h         |  100 ++++++++++
 9 files changed, 1326 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile-lib.am b/src/Makefile-lib.am
index 52b01a6..9012e88 100644
--- a/src/Makefile-lib.am
+++ b/src/Makefile-lib.am
@@ -12,6 +12,10 @@ gdprivate_source_h = \
     lib/gd-gdata-goa-authorizer.h \
     lib/gd-utils.h \
     lib/gd-main-toolbar.h \
+    lib/gd-main-view-generic.h \
+    lib/gd-main-icon-view.h \
+    lib/gd-main-list-view.h \
+    lib/gd-main-view.h \
     lib/gd-margin-container.h \
     lib/gd-pdf-loader.h \
     lib/gd-tagged-entry.h \
@@ -21,6 +25,10 @@ gdprivate_source_h = \
 gdprivate_source_c = \
     lib/gd-utils.c \
     lib/gd-main-toolbar.c \
+    lib/gd-main-view-generic.c \
+    lib/gd-main-icon-view.c \
+    lib/gd-main-list-view.c \
+    lib/gd-main-view.c \
     lib/gd-margin-container.c \
     lib/gd-pdf-loader.c \
     lib/gd-tagged-entry.c \
diff --git a/src/lib/gd-main-icon-view.c b/src/lib/gd-main-icon-view.c
new file mode 100644
index 0000000..77c1352
--- /dev/null
+++ b/src/lib/gd-main-icon-view.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Gnome Documents 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 of the License, or (at your
+ * option) any later version.
+ *
+ * Gnome Documents 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 Gnome Documents; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Cosimo Cecchi <cosimoc redhat com>
+ *
+ */
+
+#include "gd-main-icon-view.h"
+#include "gd-main-view.h"
+#include "gd-main-view-generic.h"
+#include "gd-two-lines-renderer.h"
+
+#include <math.h>
+#include <glib/gi18n.h>
+
+#define VIEW_ITEM_WIDTH 140
+#define VIEW_ITEM_WRAP_WIDTH 128
+#define VIEW_COLUMN_SPACING 20
+#define VIEW_MARGIN 16
+
+static void gd_main_view_generic_iface_init (GdMainViewGenericIface *iface);
+G_DEFINE_TYPE_WITH_CODE (GdMainIconView, gd_main_icon_view, GTK_TYPE_ICON_VIEW,
+                         G_IMPLEMENT_INTERFACE (GD_TYPE_MAIN_VIEW_GENERIC,
+                                                gd_main_view_generic_iface_init))
+
+static void
+on_icon_selection_changed (GtkIconView *iv,
+                           gpointer user_data)
+{
+  GdMainIconView *self = user_data;
+  g_signal_emit_by_name (self, "view-selection-changed");
+}
+
+static void
+gd_main_icon_view_constructed (GObject *obj)
+{
+  GdMainIconView *self = GD_MAIN_ICON_VIEW (obj);
+  GtkCellRenderer *cell;
+
+  G_OBJECT_CLASS (gd_main_icon_view_parent_class)->constructed (obj);
+
+  gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE);
+  gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE);
+
+  g_object_set (self,
+                "item-width", VIEW_ITEM_WIDTH,
+                "column-spacing", VIEW_COLUMN_SPACING,
+                "margin", VIEW_MARGIN,
+                NULL);
+
+  g_signal_connect (self, "selection-changed",
+                    G_CALLBACK (on_icon_selection_changed), self);
+
+  cell = gtk_cell_renderer_pixbuf_new ();
+  g_object_set (cell,
+                "xalign", 0.5,
+                "yalign", 0.5,
+                NULL);
+
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self), cell, FALSE);
+  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (self), cell,
+                                 "pixbuf", GD_MAIN_COLUMN_ICON);
+
+  cell = gd_two_lines_renderer_new ();
+  g_object_set (cell,
+                "alignment", PANGO_ALIGN_CENTER,
+                "wrap-mode", PANGO_WRAP_WORD_CHAR,
+                "wrap-width", VIEW_ITEM_WRAP_WIDTH,
+                "text-lines", 3,
+                NULL);
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self), cell, FALSE);
+  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (self), cell,
+                                 "text", GD_MAIN_COLUMN_TITLE);
+  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (self), cell,
+                                 "line-two", GD_MAIN_COLUMN_AUTHOR);
+}
+
+static void
+gd_main_icon_view_class_init (GdMainIconViewClass *klass)
+{
+  GObjectClass *oclass = G_OBJECT_CLASS (klass);
+
+  oclass->constructed = gd_main_icon_view_constructed;
+}
+
+static void
+gd_main_icon_view_init (GdMainIconView *self)
+{
+  /* nothing */
+}
+
+static GList *
+gd_main_icon_view_get_selection (GdMainViewGeneric *mv)
+{
+  GtkIconView *iv = GTK_ICON_VIEW (mv);
+
+  return gtk_icon_view_get_selected_items (iv);
+}
+
+static GtkTreePath *
+gd_main_icon_view_get_path_at_pos (GdMainViewGeneric *mv,
+                                   gint x,
+                                   gint y)
+{
+  return gtk_icon_view_get_path_at_pos (GTK_ICON_VIEW (mv), x, y);
+}
+
+static void
+gd_main_icon_view_set_selection_mode (GdMainViewGeneric *mv,
+                                      GtkSelectionMode mode)
+{
+  gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (mv), mode);
+}
+
+static void
+gd_main_icon_view_scroll_to_path (GdMainViewGeneric *mv,
+                                  GtkTreePath *path)
+{
+  gtk_icon_view_scroll_to_path (GTK_ICON_VIEW (mv), path, TRUE, 0.5, 0.5);
+}
+
+static gboolean
+gd_main_icon_view_path_is_selected (GdMainViewGeneric *mv,
+                                    GtkTreePath *path)
+{
+  return gtk_icon_view_path_is_selected (GTK_ICON_VIEW (mv), path);
+}
+
+static void
+gd_main_icon_view_select_path (GdMainViewGeneric *mv,
+                               GtkTreePath *path)
+{
+  gtk_icon_view_select_path (GTK_ICON_VIEW (mv), path);
+}
+
+static void
+gd_main_icon_view_unselect_path (GdMainViewGeneric *mv,
+                                 GtkTreePath *path)
+{
+  gtk_icon_view_unselect_path (GTK_ICON_VIEW (mv), path);
+}
+
+static void
+gd_main_icon_view_set_model (GdMainViewGeneric *mv,
+                             GtkTreeModel *model)
+{
+  gtk_icon_view_set_model (GTK_ICON_VIEW (mv), model);
+}
+
+static void
+gd_main_view_generic_iface_init (GdMainViewGenericIface *iface)
+{
+  iface->set_model = gd_main_icon_view_set_model;
+  iface->get_selection = gd_main_icon_view_get_selection;
+  iface->get_path_at_pos = gd_main_icon_view_get_path_at_pos;
+  iface->scroll_to_path = gd_main_icon_view_scroll_to_path;
+  iface->set_selection_mode = gd_main_icon_view_set_selection_mode;
+  iface->path_is_selected = gd_main_icon_view_path_is_selected;
+  iface->select_path = gd_main_icon_view_select_path;
+  iface->unselect_path = gd_main_icon_view_unselect_path;
+}
+
+GtkWidget *
+gd_main_icon_view_new (void)
+{
+  return g_object_new (GD_TYPE_MAIN_ICON_VIEW, NULL);
+}
diff --git a/src/lib/gd-main-icon-view.h b/src/lib/gd-main-icon-view.h
new file mode 100644
index 0000000..8b89f80
--- /dev/null
+++ b/src/lib/gd-main-icon-view.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Gnome Documents 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 of the License, or (at your
+ * option) any later version.
+ *
+ * Gnome Documents 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 Gnome Documents; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Cosimo Cecchi <cosimoc redhat com>
+ *
+ */
+
+#ifndef __GD_MAIN_ICON_VIEW_H__
+#define __GD_MAIN_ICON_VIEW_H__
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GD_TYPE_MAIN_ICON_VIEW gd_main_icon_view_get_type()
+
+#define GD_MAIN_ICON_VIEW(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   GD_TYPE_MAIN_ICON_VIEW, GdMainIconView))
+
+#define GD_MAIN_ICON_VIEW_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+   GD_TYPE_MAIN_ICON_VIEW, GdMainIconViewClass))
+
+#define GD_IS_MAIN_ICON_VIEW(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   GD_TYPE_MAIN_ICON_VIEW))
+
+#define GD_IS_MAIN_ICON_VIEW_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+   GD_TYPE_MAIN_ICON_VIEW))
+
+#define GD_MAIN_ICON_VIEW_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+   GD_TYPE_MAIN_ICON_VIEW, GdMainIconViewClass))
+
+typedef struct _GdMainIconView GdMainIconView;
+typedef struct _GdMainIconViewClass GdMainIconViewClass;
+typedef struct _GdMainIconViewPrivate GdMainIconViewPrivate;
+
+struct _GdMainIconView
+{
+  GtkIconView parent;
+
+  GdMainIconViewPrivate *priv;
+};
+
+struct _GdMainIconViewClass
+{
+  GtkIconViewClass parent_class;
+};
+
+GType gd_main_icon_view_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gd_main_icon_view_new (void);
+
+G_END_DECLS
+
+#endif /* __GD_MAIN_ICON_VIEW_H__ */
diff --git a/src/lib/gd-main-list-view.c b/src/lib/gd-main-list-view.c
new file mode 100644
index 0000000..c5d4c0d
--- /dev/null
+++ b/src/lib/gd-main-list-view.c
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Gnome Documents 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 of the License, or (at your
+ * option) any later version.
+ *
+ * Gnome Documents 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 Gnome Documents; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Cosimo Cecchi <cosimoc redhat com>
+ *
+ */
+
+#include "gd-main-list-view.h"
+#include "gd-main-view.h"
+#include "gd-main-view-generic.h"
+#include "gd-two-lines-renderer.h"
+
+#include <glib/gi18n.h>
+
+struct _GdMainListViewPrivate {
+  GtkTreeViewColumn *tree_col;
+};
+
+static void gd_main_view_generic_iface_init (GdMainViewGenericIface *iface);
+G_DEFINE_TYPE_WITH_CODE (GdMainListView, gd_main_list_view, GTK_TYPE_TREE_VIEW,
+                         G_IMPLEMENT_INTERFACE (GD_TYPE_MAIN_VIEW_GENERIC,
+                                                gd_main_view_generic_iface_init))
+
+static void
+on_tree_selection_changed (GtkTreeSelection *selection,
+                           gpointer user_data)
+{
+  GdMainListView *self = user_data;
+  g_signal_emit_by_name (self, "view-selection-changed");
+}
+
+static void
+gd_main_list_view_constructed (GObject *obj)
+{
+  GdMainListView *self = GD_MAIN_LIST_VIEW (obj);
+  GtkTreeViewColumn *col;
+  GtkCellRenderer *cell;
+  GtkTreeSelection *selection;
+
+  G_OBJECT_CLASS (gd_main_list_view_parent_class)->constructed (obj);
+
+  gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE);
+  gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE);
+
+  g_object_set (self,
+                "headers-visible", FALSE,
+                "enable-search", FALSE,
+                NULL);
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self));
+  g_signal_connect (selection, "changed",
+                    G_CALLBACK (on_tree_selection_changed), self);
+
+  self->priv->tree_col = gtk_tree_view_column_new ();
+  gtk_tree_view_append_column (GTK_TREE_VIEW (self), self->priv->tree_col);
+
+  cell = gtk_cell_renderer_pixbuf_new ();
+  g_object_set (cell,
+                "xalign", 0.5,
+                "yalign", 0.5,
+                NULL);
+  gtk_tree_view_column_pack_start (self->priv->tree_col, cell, FALSE);
+  gtk_tree_view_column_add_attribute (self->priv->tree_col, cell,
+                                      "pixbuf", GD_MAIN_COLUMN_ICON);
+
+  cell = gd_two_lines_renderer_new ();
+  g_object_set (cell,
+                "alignment", PANGO_ALIGN_LEFT,
+                "wrap-mode", PANGO_WRAP_WORD_CHAR,
+                "xpad", 12,
+                "text-lines", 2,
+                NULL);
+  gtk_tree_view_column_pack_start (self->priv->tree_col, cell, FALSE);
+  gtk_tree_view_column_add_attribute (self->priv->tree_col, cell,
+                                      "text", GD_MAIN_COLUMN_TITLE);
+  gtk_tree_view_column_add_attribute (self->priv->tree_col, cell,
+                                      "line-two", GD_MAIN_COLUMN_AUTHOR);
+}
+
+static void
+gd_main_list_view_class_init (GdMainListViewClass *klass)
+{
+  GObjectClass *oclass = G_OBJECT_CLASS (klass);
+
+  oclass->constructed = gd_main_list_view_constructed;
+
+  g_type_class_add_private (klass, sizeof (GdMainListViewPrivate));
+}
+
+static void
+gd_main_list_view_init (GdMainListView *self)
+{
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GD_TYPE_MAIN_LIST_VIEW, GdMainListViewPrivate);
+}
+
+static GList *
+gd_main_list_view_get_selection (GdMainViewGeneric *mv)
+{
+  GtkTreeSelection *selection;
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (mv));
+  return gtk_tree_selection_get_selected_rows (selection, NULL);
+}
+
+static GtkTreePath *
+gd_main_list_view_get_path_at_pos (GdMainViewGeneric *mv,
+                                   gint x,
+                                   gint y)
+{
+  GtkTreePath *path = NULL;
+
+  gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (mv), x, y, &path,
+                                 NULL, NULL, NULL);
+
+  return path;
+}
+
+static void
+gd_main_list_view_set_selection_mode (GdMainViewGeneric *mv,
+                                      GtkSelectionMode mode)
+{
+  GtkTreeSelection *selection;
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (mv));
+  gtk_tree_selection_set_mode (selection, mode);
+}
+
+static void
+gd_main_list_view_scroll_to_path (GdMainViewGeneric *mv,
+                                  GtkTreePath *path)
+{
+  gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (mv), path, NULL, TRUE, 0.5, 0.5);
+}
+
+static gboolean
+gd_main_list_view_path_is_selected (GdMainViewGeneric *mv,
+                                    GtkTreePath *path)
+{
+  GtkTreeSelection *selection;
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (mv));
+  return gtk_tree_selection_path_is_selected (selection, path);
+}
+
+static void
+gd_main_list_view_select_path (GdMainViewGeneric *mv,
+                               GtkTreePath *path)
+{
+  GtkTreeSelection *selection;
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (mv));
+  gtk_tree_selection_select_path (selection, path);
+}
+
+static void
+gd_main_list_view_unselect_path (GdMainViewGeneric *mv,
+                                 GtkTreePath *path)
+{
+  GtkTreeSelection *selection;
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (mv));
+  gtk_tree_selection_unselect_path (selection, path);
+}
+
+static void
+gd_main_list_view_set_model (GdMainViewGeneric *mv,
+                             GtkTreeModel *model)
+{
+  gtk_tree_view_set_model (GTK_TREE_VIEW (mv), model);
+}
+
+static void
+gd_main_view_generic_iface_init (GdMainViewGenericIface *iface)
+{
+  iface->set_model = gd_main_list_view_set_model;
+  iface->get_selection = gd_main_list_view_get_selection;
+  iface->get_path_at_pos = gd_main_list_view_get_path_at_pos;
+  iface->scroll_to_path = gd_main_list_view_scroll_to_path;
+  iface->set_selection_mode = gd_main_list_view_set_selection_mode;
+  iface->select_path = gd_main_list_view_select_path;
+  iface->unselect_path = gd_main_list_view_unselect_path;
+  iface->path_is_selected = gd_main_list_view_path_is_selected;
+}
+
+void
+gd_main_list_view_add_renderer (GdMainListView *self,
+                                GtkCellRenderer *renderer,
+                                GtkTreeCellDataFunc func,
+                                gpointer user_data,
+                                GDestroyNotify destroy)
+{
+  gtk_tree_view_column_pack_start (self->priv->tree_col, renderer, FALSE);
+  gtk_tree_view_column_set_cell_data_func (self->priv->tree_col, renderer,
+                                           func, user_data, destroy);
+}
+
+GtkWidget *
+gd_main_list_view_new (void)
+{
+  return g_object_new (GD_TYPE_MAIN_LIST_VIEW, NULL);
+}
diff --git a/src/lib/gd-main-list-view.h b/src/lib/gd-main-list-view.h
new file mode 100644
index 0000000..eb9cece
--- /dev/null
+++ b/src/lib/gd-main-list-view.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Gnome Documents 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 of the License, or (at your
+ * option) any later version.
+ *
+ * Gnome Documents 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 Gnome Documents; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Cosimo Cecchi <cosimoc redhat com>
+ *
+ */
+
+#ifndef __GD_MAIN_LIST_VIEW_H__
+#define __GD_MAIN_LIST_VIEW_H__
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GD_TYPE_MAIN_LIST_VIEW gd_main_list_view_get_type()
+
+#define GD_MAIN_LIST_VIEW(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   GD_TYPE_MAIN_LIST_VIEW, GdMainListView))
+
+#define GD_MAIN_LIST_VIEW_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+   GD_TYPE_MAIN_LIST_VIEW, GdMainListViewClass))
+
+#define GD_IS_MAIN_LIST_VIEW(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   GD_TYPE_MAIN_LIST_VIEW))
+
+#define GD_IS_MAIN_LIST_VIEW_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+   GD_TYPE_MAIN_LIST_VIEW))
+
+#define GD_MAIN_LIST_VIEW_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+   GD_TYPE_MAIN_LIST_VIEW, GdMainListViewClass))
+
+typedef struct _GdMainListView GdMainListView;
+typedef struct _GdMainListViewClass GdMainListViewClass;
+typedef struct _GdMainListViewPrivate GdMainListViewPrivate;
+
+struct _GdMainListView
+{
+  GtkTreeView parent;
+
+  GdMainListViewPrivate *priv;
+};
+
+struct _GdMainListViewClass
+{
+  GtkTreeViewClass parent_class;
+};
+
+GType gd_main_list_view_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gd_main_list_view_new (void);
+
+void gd_main_list_view_add_renderer (GdMainListView *self,
+                                     GtkCellRenderer *renderer,
+                                     GtkTreeCellDataFunc func,
+                                     gpointer user_data,
+                                     GDestroyNotify destroy);
+
+G_END_DECLS
+
+#endif /* __GD_MAIN_LIST_VIEW_H__ */
diff --git a/src/lib/gd-main-view-generic.c b/src/lib/gd-main-view-generic.c
new file mode 100644
index 0000000..254dd51
--- /dev/null
+++ b/src/lib/gd-main-view-generic.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Gnome Documents 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 of the License, or (at your
+ * option) any later version.
+ *
+ * Gnome Documents 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 Gnome Documents; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Cosimo Cecchi <cosimoc redhat com>
+ *
+ */
+
+#include "gd-main-view-generic.h"
+
+enum {
+  VIEW_SELECTION_CHANGED = 1,
+  NUM_SIGNALS
+};
+
+static guint signals[NUM_SIGNALS] = { 0, };
+
+typedef GdMainViewGenericIface GdMainViewGenericInterface;
+G_DEFINE_INTERFACE (GdMainViewGeneric, gd_main_view_generic, GTK_TYPE_WIDGET)
+
+static void
+gd_main_view_generic_default_init (GdMainViewGenericInterface *iface)
+{
+  signals[VIEW_SELECTION_CHANGED] = 
+    g_signal_new ("view-selection-changed",
+                  GD_TYPE_MAIN_VIEW_GENERIC,
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GdMainViewGenericIface, selection_changed),
+                  NULL, NULL, NULL,
+                  G_TYPE_NONE, 0);
+}
+
+/**
+ * gd_main_view_generic_set_model:
+ * @self:
+ * @model: (allow-none):
+ *
+ */
+void
+gd_main_view_generic_set_model (GdMainViewGeneric *self,
+                        GtkTreeModel *model)
+{
+  GdMainViewGenericInterface *iface;
+
+  iface = GD_MAIN_VIEW_GENERIC_GET_IFACE (self);
+
+  (* iface->set_model) (self, model);
+}
+
+/**
+ * gd_main_view_generic_get_selection:
+ * @self:
+ *
+ * Returns: (element-type GtkTreePath) (transfer full):
+ */
+GList *
+gd_main_view_generic_get_selection (GdMainViewGeneric *self)
+{
+  GdMainViewGenericInterface *iface;
+
+  iface = GD_MAIN_VIEW_GENERIC_GET_IFACE (self);
+
+  return (* iface->get_selection) (self);
+}
+
+GtkTreePath *
+gd_main_view_generic_get_path_at_pos (GdMainViewGeneric *self,
+                                      gint x,
+                                      gint y)
+{
+  GdMainViewGenericInterface *iface;
+
+  iface = GD_MAIN_VIEW_GENERIC_GET_IFACE (self);
+
+  return (* iface->get_path_at_pos) (self, x, y);
+}
+
+void
+gd_main_view_generic_set_selection_mode (GdMainViewGeneric *self,
+                                         GtkSelectionMode mode)
+{
+  GdMainViewGenericInterface *iface;
+
+  iface = GD_MAIN_VIEW_GENERIC_GET_IFACE (self);
+
+  (* iface->set_selection_mode) (self, mode);
+}
+
+void
+gd_main_view_generic_scroll_to_path (GdMainViewGeneric *self,
+                                     GtkTreePath *path)
+{
+  GdMainViewGenericInterface *iface;
+
+  iface = GD_MAIN_VIEW_GENERIC_GET_IFACE (self);
+
+  (* iface->scroll_to_path) (self, path);
+}
+
+gboolean
+gd_main_view_generic_path_is_selected (GdMainViewGeneric *self,
+                                       GtkTreePath *path)
+{
+  GdMainViewGenericInterface *iface;
+
+  iface = GD_MAIN_VIEW_GENERIC_GET_IFACE (self);
+
+  return (* iface->path_is_selected) (self, path);
+}
+
+void
+gd_main_view_generic_select_path (GdMainViewGeneric *self,
+                                  GtkTreePath *path)
+{
+  GdMainViewGenericInterface *iface;
+
+  iface = GD_MAIN_VIEW_GENERIC_GET_IFACE (self);
+
+  (* iface->select_path) (self, path);
+}
+
+void
+gd_main_view_generic_unselect_path (GdMainViewGeneric *self,
+                                    GtkTreePath *path)
+{
+  GdMainViewGenericInterface *iface;
+
+  iface = GD_MAIN_VIEW_GENERIC_GET_IFACE (self);
+
+  (* iface->unselect_path) (self, path);
+}
diff --git a/src/lib/gd-main-view-generic.h b/src/lib/gd-main-view-generic.h
new file mode 100644
index 0000000..4a13e2c
--- /dev/null
+++ b/src/lib/gd-main-view-generic.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Gnome Documents 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 of the License, or (at your
+ * option) any later version.
+ *
+ * Gnome Documents 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 Gnome Documents; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Cosimo Cecchi <cosimoc redhat com>
+ *
+ */
+
+#ifndef __GD_MAIN_VIEW_GENERIC_H__
+#define __GD_MAIN_VIEW_GENERIC_H__
+
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GD_TYPE_MAIN_VIEW_GENERIC gd_main_view_generic_get_type()
+
+#define GD_MAIN_VIEW_GENERIC(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   GD_TYPE_MAIN_VIEW_GENERIC, GdMainViewGeneric))
+
+#define GD_MAIN_VIEW_GENERIC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+   GD_TYPE_MAIN_VIEW_GENERIC, GdMainViewGenericIface))
+
+#define GD_IS_MAIN_VIEW_GENERIC(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   GD_TYPE_MAIN_VIEW_GENERIC))
+
+#define GD_IS_MAIN_VIEW_GENERIC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+   GD_TYPE_MAIN_VIEW_GENERIC))
+
+#define GD_MAIN_VIEW_GENERIC_GET_IFACE(obj) \
+  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), \
+   GD_TYPE_MAIN_VIEW_GENERIC, GdMainViewGenericIface))
+
+typedef struct _GdMainViewGeneric GdMainViewGeneric;
+typedef struct _GdMainViewGenericIface GdMainViewGenericIface;
+
+struct _GdMainViewGenericIface
+{
+  GTypeInterface base_iface;
+
+  /* signals */
+  void          (* selection_changed)    (GdMainViewGeneric  *view);
+
+  /* vtable */
+  void          (* set_model)            (GdMainViewGeneric  *view,
+                                          GtkTreeModel       *model);
+
+  GtkTreePath * (* get_path_at_pos)      (GdMainViewGeneric *view,
+                                          gint               x, 
+                                          gint               y);
+  void          (* scroll_to_path)       (GdMainViewGeneric *view,
+                                          GtkTreePath       *path);
+  void          (* set_selection_mode)   (GdMainViewGeneric *view,
+                                          GtkSelectionMode   selection_mode);
+  GList *       (* get_selection)        (GdMainViewGeneric *view);
+  gboolean      (* path_is_selected)     (GdMainViewGeneric *view,
+                                          GtkTreePath       *path);
+  void          (* select_path)          (GdMainViewGeneric *view,
+                                          GtkTreePath       *path);
+  void          (* unselect_path)        (GdMainViewGeneric *view,
+                                          GtkTreePath       *path);
+};
+
+GType gd_main_view_generic_get_type (void) G_GNUC_CONST;
+
+void gd_main_view_generic_set_model (GdMainViewGeneric *self,
+                                     GtkTreeModel *model);
+
+void gd_main_view_generic_scroll_to_path (GdMainViewGeneric *self,
+                                          GtkTreePath *path);
+void gd_main_view_generic_set_selection_mode (GdMainViewGeneric *self,
+                                              GtkSelectionMode mode);
+GtkTreePath * gd_main_view_generic_get_path_at_pos (GdMainViewGeneric *self,
+                                                    gint x,
+                                                    gint y);
+GList * gd_main_view_generic_get_selection (GdMainViewGeneric *self);
+gboolean gd_main_view_generic_path_is_selected (GdMainViewGeneric *self,
+                                                GtkTreePath *path);
+void gd_main_view_generic_select_path (GdMainViewGeneric *self,
+                                       GtkTreePath *path);
+void gd_main_view_generic_unselect_path (GdMainViewGeneric *self,
+                                         GtkTreePath *path);
+
+G_END_DECLS
+
+#endif /* __GD_MAIN_VIEW_GENERIC_H__ */
diff --git a/src/lib/gd-main-view.c b/src/lib/gd-main-view.c
new file mode 100644
index 0000000..055a764
--- /dev/null
+++ b/src/lib/gd-main-view.c
@@ -0,0 +1,419 @@
+/*
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Gnome Documents 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 of the License, or (at your
+ * option) any later version.
+ *
+ * Gnome Documents 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 Gnome Documents; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Cosimo Cecchi <cosimoc redhat com>
+ *
+ */
+
+#include "gd-main-view.h"
+
+#include "gd-main-view-generic.h"
+#include "gd-main-icon-view.h"
+#include "gd-main-list-view.h"
+
+struct _GdMainViewPrivate {
+  GdMainViewType current_type;
+  gboolean selection_mode;
+
+  GtkWidget *current_view;
+  GtkTreeModel *model;
+};
+
+enum {
+  PROP_VIEW_TYPE = 1,
+  PROP_SELECTION_MODE,
+  PROP_MODEL,
+  NUM_PROPERTIES
+};
+
+enum {
+  ITEM_ACTIVATED = 1,
+  SELECTION_MODE_REQUEST,
+  NUM_SIGNALS
+};
+
+static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
+static guint signals[NUM_SIGNALS] = { 0, };
+
+G_DEFINE_TYPE (GdMainView, gd_main_view, GTK_TYPE_SCROLLED_WINDOW)
+
+static void
+gd_main_view_init (GdMainView *self)
+{
+  GtkStyleContext *context;
+
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GD_TYPE_MAIN_VIEW, GdMainViewPrivate);
+  self->priv->current_type = GD_MAIN_VIEW_NONE;
+
+  gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE);
+  gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (self), GTK_SHADOW_IN);
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (self));
+  gtk_style_context_add_class (context, "documents-scrolledwin");
+}
+
+static void
+gd_main_view_get_property (GObject    *object,
+                           guint       property_id,
+                           GValue     *value,
+                           GParamSpec *pspec)
+{
+  GdMainView *self = GD_MAIN_VIEW (object);
+
+  switch (property_id)
+    {
+    case PROP_VIEW_TYPE:
+      g_value_set_int (value, gd_main_view_get_view_type (self));
+      break;
+    case PROP_SELECTION_MODE:
+      g_value_set_boolean (value, gd_main_view_get_selection_mode (self));
+      break;
+    case PROP_MODEL:
+      g_value_set_object (value, gd_main_view_get_model (self));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+static void
+gd_main_view_set_property (GObject    *object,
+                           guint       property_id,
+                           const GValue *value,
+                           GParamSpec *pspec)
+{
+  GdMainView *self = GD_MAIN_VIEW (object);
+
+  switch (property_id)
+    {
+    case PROP_VIEW_TYPE:
+      gd_main_view_set_view_type (self, g_value_get_int (value));
+      break;
+    case PROP_SELECTION_MODE:
+      gd_main_view_set_selection_mode (self, g_value_get_boolean (value));
+      break;
+    case PROP_MODEL:
+      gd_main_view_set_model (self, g_value_get_object (value));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+static void
+gd_main_view_class_init (GdMainViewClass *klass)
+{
+  GObjectClass *oclass = G_OBJECT_CLASS (klass);
+
+  oclass->get_property = gd_main_view_get_property;
+  oclass->set_property = gd_main_view_set_property;
+
+  properties[PROP_VIEW_TYPE] =
+    g_param_spec_int ("view-type",
+                      "View type",
+                      "View type",
+                      GD_MAIN_VIEW_NONE,
+                      GD_MAIN_VIEW_LIST,
+                      GD_MAIN_VIEW_NONE,
+                      G_PARAM_READWRITE |
+                      G_PARAM_STATIC_STRINGS);
+
+  properties[PROP_SELECTION_MODE] =
+    g_param_spec_boolean ("selection-mode",
+                          "Selection mode",
+                          "Whether the view is in selection mode",
+                          FALSE,
+                          G_PARAM_READWRITE |
+                          G_PARAM_CONSTRUCT |
+                          G_PARAM_STATIC_STRINGS);
+
+  properties[PROP_MODEL] =
+    g_param_spec_object ("model",
+                         "Model",
+                         "The GtkTreeModel",
+                         GTK_TYPE_TREE_MODEL,
+                         G_PARAM_READWRITE |
+                         G_PARAM_CONSTRUCT |
+                         G_PARAM_STATIC_STRINGS);
+
+  signals[ITEM_ACTIVATED] =
+    g_signal_new ("item-activated",
+                  GD_TYPE_MAIN_VIEW,
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL, NULL,
+                  G_TYPE_NONE, 1,
+                  G_TYPE_STRING);
+
+  signals[SELECTION_MODE_REQUEST] =
+    g_signal_new ("selection-mode-request",
+                  GD_TYPE_MAIN_VIEW,
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL, NULL,
+                  G_TYPE_NONE, 0);
+
+  g_type_class_add_private (klass, sizeof (GdMainViewPrivate));
+  g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
+}
+
+static GdMainViewGeneric *
+get_generic (GdMainView *self)
+{
+  if (self->priv->current_view != NULL)
+    return GD_MAIN_VIEW_GENERIC (self->priv->current_view);
+
+  return NULL;
+}
+
+static gboolean
+on_button_release_selection_mode (GdMainView *self,
+                                  GdkEventButton *event,
+                                  gboolean entered_mode,
+                                  GtkTreePath *path)
+{
+  GdMainViewGeneric *generic = get_generic (self);
+  gboolean selected;
+
+  selected = gd_main_view_generic_path_is_selected (generic, path);
+
+  if (selected && !entered_mode)
+    gd_main_view_generic_unselect_path (generic, path);
+  else if (!selected)
+    gd_main_view_generic_select_path (generic, path);
+
+  return TRUE;
+}
+
+static gboolean
+on_button_release_view_mode (GdMainView *self,
+                             GdkEventButton *event,
+                             GtkTreePath *path)
+{
+  GtkTreeIter iter;
+  gchar *id;
+
+  if (self->priv->model == NULL)
+    return FALSE;
+
+  gtk_tree_model_get_iter (self->priv->model, &iter, path);
+  gtk_tree_model_get (self->priv->model, &iter,
+                      GD_MAIN_COLUMN_ID, &id,
+                      -1);
+
+  g_signal_emit (self, signals[ITEM_ACTIVATED], 0, id);
+  g_free (id);
+
+  return TRUE;
+}
+
+static gboolean
+on_button_release_event (GtkWidget *view,
+                         GdkEventButton *event,
+                         gpointer user_data)
+{
+  GdMainView *self = user_data;
+  GdMainViewGeneric *generic = get_generic (self);
+  GtkTreePath *path;
+  gboolean entered_mode = FALSE, selection_mode;
+  gboolean res;
+
+  /* eat double/triple click events */
+  if (event->type != GDK_BUTTON_RELEASE)
+    return TRUE;
+
+  path = gd_main_view_generic_get_path_at_pos (generic, event->x, event->y);
+
+  if (path == NULL)
+    return FALSE;
+
+  selection_mode = self->priv->selection_mode;
+
+  if (!selection_mode)
+    {
+      if ((event->button == 3) ||
+          (event->button == 1) && (event->state & GDK_CONTROL_MASK))
+        {
+          g_signal_emit (self, signals[SELECTION_MODE_REQUEST], 0);
+          selection_mode = TRUE;
+          entered_mode = TRUE;
+        }
+    }
+
+  if (selection_mode)
+    res = on_button_release_selection_mode (self, event, entered_mode, path);
+  else
+    res = on_button_release_view_mode (self, event, path);
+
+  gtk_tree_path_free (path);
+  return res;
+}
+
+static gboolean
+on_button_press_event (GtkWidget *view,
+                       GdkEventButton *event_button,
+                       gpointer user_data)
+{
+  /* TODO: eat button press events for now; in the future we might want
+   * to add support for DnD.
+   */
+  return TRUE;
+}
+
+static void
+gd_main_view_apply_model (GdMainView *self)
+{
+  GdMainViewGeneric *generic = get_generic (self);
+  gd_main_view_generic_set_model (generic, self->priv->model);
+}
+
+static void
+gd_main_view_apply_selection_mode (GdMainView *self)
+{
+  GdMainViewGeneric *generic = get_generic (self);
+
+  if (self->priv->selection_mode)
+    gd_main_view_generic_set_selection_mode (generic, GTK_SELECTION_MULTIPLE);
+  else
+    gd_main_view_generic_set_selection_mode (generic, GTK_SELECTION_NONE);
+}
+
+static void
+gd_main_view_rebuild (GdMainView *self)
+{
+  GtkStyleContext *context;
+
+  if (self->priv->current_type == GD_MAIN_VIEW_NONE)
+    return;
+
+  if (self->priv->current_view != NULL)
+    gtk_widget_destroy (self->priv->current_view);
+
+  if (self->priv->current_type == GD_MAIN_VIEW_ICON)
+    self->priv->current_view = gd_main_icon_view_new ();
+  else
+    self->priv->current_view = gd_main_list_view_new ();
+
+  context = gtk_widget_get_style_context (self->priv->current_view);
+  gtk_style_context_add_class (context, "documents-main-view");
+
+  gtk_container_add (GTK_CONTAINER (self), self->priv->current_view);
+
+  g_signal_connect (self->priv->current_view, "button-press-event",
+                    G_CALLBACK (on_button_press_event), self);
+  g_signal_connect (self->priv->current_view, "button-release-event",
+                    G_CALLBACK (on_button_release_event), self);
+
+  gd_main_view_apply_selection_mode (self);
+  gd_main_view_apply_model (self);
+
+  gtk_widget_show_all (GTK_WIDGET (self));
+}
+
+GdMainView *
+gd_main_view_new (GdMainViewType type)
+{
+  return g_object_new (GD_TYPE_MAIN_VIEW,
+                       "view-type", type,
+                       NULL);
+}
+
+void
+gd_main_view_set_view_type (GdMainView *self,
+                            GdMainViewType type)
+{
+  if (type != self->priv->current_type)
+    {
+      self->priv->current_type = type;
+      gd_main_view_rebuild (self);
+
+      g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VIEW_TYPE]);
+    }
+}
+
+GdMainViewType
+gd_main_view_get_view_type (GdMainView *self)
+{
+  return self->priv->current_type;
+}
+
+void
+gd_main_view_set_selection_mode (GdMainView *self,
+                                 gboolean selection_mode)
+{
+  if (selection_mode != self->priv->selection_mode)
+    {
+      self->priv->selection_mode = selection_mode;
+      gd_main_view_apply_selection_mode (self);
+      g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTION_MODE]);
+    }
+}
+
+GdMainViewType
+gd_main_view_get_selection_mode (GdMainView *self)
+{
+  return self->priv->selection_mode;
+}
+
+/**
+ * gd_main_view_set_model:
+ * @self:
+ * @model: (allow-none):
+ *
+ */
+void
+gd_main_view_set_model (GdMainView *self,
+                        GtkTreeModel *model)
+{
+  if (model != self->priv->model)
+    {
+      g_clear_object (&self->priv->model);
+
+      if (model)
+        self->priv->model = g_object_ref (model);
+      else
+        self->priv->model = NULL;
+
+      gd_main_view_apply_model (self);
+      g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODEL]);
+    }
+}
+
+/**
+ * gd_main_view_get_model:
+ * @self:
+ *
+ * Returns: (transfer none):
+ */
+GtkTreeModel *
+gd_main_view_get_model (GdMainView *self)
+{
+  return self->priv->model;
+}
+
+/**
+ * gd_main_view_get_generic_view:
+ * @self:
+ *
+ * Returns: (transfer none):
+ */
+GtkWidget *
+gd_main_view_get_generic_view (GdMainView *self)
+{
+  return self->priv->current_view;
+}
diff --git a/src/lib/gd-main-view.h b/src/lib/gd-main-view.h
new file mode 100644
index 0000000..e1014d2
--- /dev/null
+++ b/src/lib/gd-main-view.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Gnome Documents 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 of the License, or (at your
+ * option) any later version.
+ *
+ * Gnome Documents 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 Gnome Documents; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Cosimo Cecchi <cosimoc redhat com>
+ *
+ */
+
+#ifndef __GD_MAIN_VIEW_H__
+#define __GD_MAIN_VIEW_H__
+
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GD_TYPE_MAIN_VIEW gd_main_view_get_type()
+
+#define GD_MAIN_VIEW(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   GD_TYPE_MAIN_VIEW, GdMainView))
+
+#define GD_MAIN_VIEW_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+   GD_TYPE_MAIN_VIEW, GdMainViewIface))
+
+#define GD_IS_MAIN_VIEW(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   GD_TYPE_MAIN_VIEW))
+
+#define GD_IS_MAIN_VIEW_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+   GD_TYPE_MAIN_VIEW))
+
+#define GD_MAIN_VIEW_GET_IFACE(obj) \
+  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), \
+   GD_TYPE_MAIN_VIEW, GdMainViewIface))
+
+typedef struct _GdMainView GdMainView;
+typedef struct _GdMainViewClass GdMainViewClass;
+typedef struct _GdMainViewPrivate GdMainViewPrivate;
+
+typedef enum {
+  GD_MAIN_COLUMN_ID,
+  GD_MAIN_COLUMN_TITLE,
+  GD_MAIN_COLUMN_AUTHOR,
+  GD_MAIN_COLUMN_ICON,
+  GD_MAIN_COLUMN_MTIME
+} GdMainColumns;
+
+typedef enum {
+  GD_MAIN_VIEW_NONE,
+  GD_MAIN_VIEW_ICON,
+  GD_MAIN_VIEW_LIST
+} GdMainViewType;
+
+struct _GdMainView {
+  GtkScrolledWindow parent;
+
+  GdMainViewPrivate *priv;
+};
+
+struct _GdMainViewClass {
+  GtkScrolledWindowClass parent_class;
+};
+
+GType gd_main_view_get_type (void) G_GNUC_CONST;
+
+GdMainView * gd_main_view_new (GdMainViewType type);
+void         gd_main_view_set_view_type (GdMainView *self,
+                                         GdMainViewType type);
+GdMainViewType gd_main_view_get_view_type (GdMainView *self);
+
+void gd_main_view_set_selection_mode (GdMainView *self,
+                                      gboolean selection_mode);
+GdMainViewType gd_main_view_get_selection_mode (GdMainView *self);
+
+GtkTreeModel * gd_main_view_get_model (GdMainView *self);
+void gd_main_view_set_model (GdMainView *self,
+                             GtkTreeModel *model);
+
+GtkWidget * gd_main_view_get_generic_view (GdMainView *self);
+
+G_END_DECLS
+
+#endif /* __GD_MAIN_VIEW_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]