aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-04-09 06:18:26 +0800
committerChris Lahey <clahey@src.gnome.org>2000-04-09 06:18:26 +0800
commita09c52cdf9328ff9ddb64f727a06fe5d92d37b46 (patch)
tree4493d993c17b8bc6c792e24345e7bbe7e14ce84e /addressbook/gui
parent58e7df4e0376d1248ced78659d27d61adc1434b9 (diff)
downloadgsoc2013-evolution-a09c52cdf9328ff9ddb64f727a06fe5d92d37b46.tar
gsoc2013-evolution-a09c52cdf9328ff9ddb64f727a06fe5d92d37b46.tar.gz
gsoc2013-evolution-a09c52cdf9328ff9ddb64f727a06fe5d92d37b46.tar.bz2
gsoc2013-evolution-a09c52cdf9328ff9ddb64f727a06fe5d92d37b46.tar.lz
gsoc2013-evolution-a09c52cdf9328ff9ddb64f727a06fe5d92d37b46.tar.xz
gsoc2013-evolution-a09c52cdf9328ff9ddb64f727a06fe5d92d37b46.tar.zst
gsoc2013-evolution-a09c52cdf9328ff9ddb64f727a06fe5d92d37b46.zip
CVS move mistake. Fixed the correct changes in the correct places.
2000-04-08 Christopher James Lahey <clahey@helixcode.com> * addressbook/gui/minicard/.cvsignore, addressbook/gui/minicard/Makefile.am, addressbook/gui/minicard/e-minicard-view.c, addressbook/gui/minicard/e-minicard-view.h, addressbook/gui/minicard/e-minicard.c, addressbook/gui/minicard/e-minicard.h, addressbook/gui/minicard/e-reflow-sorted.c, addressbook/gui/minicard/e-reflow-sorted.h, addressbook/gui/minicard/e-reflow.c, addressbook/gui/minicard/e-reflow.h, addressbook/gui/minicard/test-minicard-view.c, addressbook/gui/minicard/test-reflow.c, widgets/e-minicard/.cvsignore, widgets/e-minicard/Makefile.am, widgets/e-minicard/e-minicard-label.c, widgets/e-minicard/e-minicard-label.h, widgets/e-minicard/e-minicard-view.c, widgets/e-minicard/e-minicard-view.h, widgets/e-minicard/e-minicard.c, widgets/e-minicard/e-minicard.h, widgets/e-minicard/e-reflow-sorted.c, widgets/e-minicard/e-reflow-sorted.h, widgets/e-minicard/e-reflow.c, widgets/e-minicard/e-reflow.h, widgets/e-minicard/test-minicard-label.c, widgets/e-minicard/test-minicard-view.c, widgets/e-minicard/test-minicard.c, widgets/e-minicard/test-reflow.c: CVS move mistake. Fixed the correct changes in the correct places. svn path=/trunk/; revision=2344
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/minicard/.cvsignore1
-rw-r--r--addressbook/gui/minicard/Makefile.am41
-rw-r--r--addressbook/gui/minicard/e-minicard-view.c239
-rw-r--r--addressbook/gui/minicard/e-minicard-view.h79
-rw-r--r--addressbook/gui/minicard/e-minicard.c216
-rw-r--r--addressbook/gui/minicard/e-minicard.h13
-rw-r--r--addressbook/gui/minicard/e-reflow-sorted.c185
-rw-r--r--addressbook/gui/minicard/e-reflow-sorted.h87
-rw-r--r--addressbook/gui/minicard/e-reflow.c36
-rw-r--r--addressbook/gui/minicard/e-reflow.h16
-rw-r--r--addressbook/gui/minicard/test-minicard-view.c206
-rw-r--r--addressbook/gui/minicard/test-reflow.c28
-rw-r--r--addressbook/gui/widgets/Makefile.am41
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c239
-rw-r--r--addressbook/gui/widgets/e-minicard-view.h79
-rw-r--r--addressbook/gui/widgets/e-minicard.c216
-rw-r--r--addressbook/gui/widgets/e-minicard.h13
-rw-r--r--addressbook/gui/widgets/test-minicard-view.c206
-rw-r--r--addressbook/gui/widgets/test-reflow.c28
19 files changed, 1742 insertions, 227 deletions
diff --git a/addressbook/gui/minicard/.cvsignore b/addressbook/gui/minicard/.cvsignore
index 4af6725b43..1c59f4a4ec 100644
--- a/addressbook/gui/minicard/.cvsignore
+++ b/addressbook/gui/minicard/.cvsignore
@@ -6,4 +6,5 @@ Makefile.in
*.la
minicard-label-test
minicard-test
+minicard-view-test
reflow-test \ No newline at end of file
diff --git a/addressbook/gui/minicard/Makefile.am b/addressbook/gui/minicard/Makefile.am
index e1b130bc2a..3534e9cb69 100644
--- a/addressbook/gui/minicard/Makefile.am
+++ b/addressbook/gui/minicard/Makefile.am
@@ -1,7 +1,7 @@
INCLUDES = \
+ -I$(top_srcdir)/addressbook/backend/ebook \
-I$(top_srcdir)/widgets/e-text \
-I$(top_srcdir)/e-util \
- -I$(top_srcdir)/widgets/e-table \
$(GNOME_INCLUDEDIR)
noinst_LIBRARIES = \
@@ -12,40 +12,65 @@ libeminicard_a_SOURCES = \
e-minicard.h \
e-minicard-label.c \
e-minicard-label.h \
+ e-minicard-view.c \
+ e-minicard-view.h \
+ e-reflow-sorted.c \
+ e-reflow-sorted.h \
e-reflow.c \
e-reflow.h
noinst_PROGRAMS = \
minicard-label-test \
minicard-test \
- reflow-test
+ reflow-test \
+ minicard-view-test
minicard_label_test_SOURCES = \
test-minicard-label.c
minicard_label_test_LDADD = \
$(EXTRA_GNOME_LIBS) \
+ $(GNOMEGNORBA_LIBS) \
libeminicard.a \
+ -lbonobo \
$(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/widgets/e-text/libetext.a \
- $(top_builddir)/widgets/e-table/libetable.a
+ $(top_builddir)/widgets/e-text/libetext.a
minicard_test_SOURCES = \
test-minicard.c
minicard_test_LDADD = \
$(EXTRA_GNOME_LIBS) \
+ $(GNOMEGNORBA_LIBS) \
libeminicard.a \
+ -lbonobo \
$(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/widgets/e-text/libetext.a \
- $(top_builddir)/widgets/e-table/libetable.a
+ $(top_builddir)/addressbook/backend/ebook/libebook.la \
+ $(top_builddir)/libversit/libversit.la \
+ $(top_builddir)/widgets/e-text/libetext.a
reflow_test_SOURCES = \
test-reflow.c
reflow_test_LDADD = \
$(EXTRA_GNOME_LIBS) \
+ $(GNOMEGNORBA_LIBS) \
libeminicard.a \
+ -lbonobo \
$(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/widgets/e-text/libetext.a \
- $(top_builddir)/widgets/e-table/libetable.a
+ $(top_builddir)/addressbook/backend/ebook/libebook.la \
+ $(top_builddir)/libversit/libversit.la \
+ $(top_builddir)/widgets/e-text/libetext.a
+
+minicard_view_test_SOURCES = \
+ test-minicard-view.c
+
+minicard_view_test_LDADD = \
+ $(EXTRA_GNOME_LIBS) \
+ $(GNOMEGNORBA_LIBS) \
+ libeminicard.a \
+ -lbonobo \
+ $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/addressbook/backend/ebook/libebook.la \
+ $(top_builddir)/libversit/libversit.la \
+ $(top_builddir)/widgets/e-text/libetext.a
diff --git a/addressbook/gui/minicard/e-minicard-view.c b/addressbook/gui/minicard/e-minicard-view.c
new file mode 100644
index 0000000000..6e7b432a8e
--- /dev/null
+++ b/addressbook/gui/minicard/e-minicard-view.c
@@ -0,0 +1,239 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-minicard-view.c
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Author: Chris Lahey <clahey@helixcode.com>
+ *
+ * This library 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.
+ *
+ * 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <gnome.h>
+#include "e-minicard-view.h"
+#include "e-minicard.h"
+static void e_minicard_view_init (EMinicardView *reflow);
+static void e_minicard_view_class_init (EMinicardViewClass *klass);
+static void e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
+static void e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
+static void e_minicard_view_destroy (GtkObject *object);
+
+#define E_MINICARD_VIEW_DIVIDER_WIDTH 2
+#define E_MINICARD_VIEW_BORDER_WIDTH 7
+#define E_MINICARD_VIEW_FULL_GUTTER (E_MINICARD_VIEW_DIVIDER_WIDTH + E_MINICARD_VIEW_BORDER_WIDTH * 2)
+
+static EReflowSortedClass *parent_class = NULL;
+
+/* The arguments we take */
+enum {
+ ARG_0,
+ ARG_BOOK
+};
+
+GtkType
+e_minicard_view_get_type (void)
+{
+ static GtkType reflow_type = 0;
+
+ if (!reflow_type)
+ {
+ static const GtkTypeInfo reflow_info =
+ {
+ "EMinicardView",
+ sizeof (EMinicardView),
+ sizeof (EMinicardViewClass),
+ (GtkClassInitFunc) e_minicard_view_class_init,
+ (GtkObjectInitFunc) e_minicard_view_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ reflow_type = gtk_type_unique (e_reflow_sorted_get_type (), &reflow_info);
+ }
+
+ return reflow_type;
+}
+
+static void
+e_minicard_view_class_init (EMinicardViewClass *klass)
+{
+ GtkObjectClass *object_class;
+ GnomeCanvasItemClass *item_class;
+
+ object_class = (GtkObjectClass*) klass;
+ item_class = (GnomeCanvasItemClass *) klass;
+
+ parent_class = gtk_type_class (e_reflow_sorted_get_type ());
+
+gtk_object_add_arg_type ("EMinicardView::book", GTK_TYPE_OBJECT,
+ GTK_ARG_READWRITE, ARG_BOOK);
+
+ object_class->set_arg = e_minicard_view_set_arg;
+ object_class->get_arg = e_minicard_view_get_arg;
+ object_class->destroy = e_minicard_view_destroy;
+
+ /* GnomeCanvasItem method overrides */
+}
+
+static void
+e_minicard_view_init (EMinicardView *view)
+{
+ view->book = NULL;
+ view->book_view = NULL;
+ view->get_view_idle = 0;
+ view->create_card_id = 0;
+ view->remove_card_id = 0;
+ view->modify_card_id = 0;
+
+ E_REFLOW_SORTED(view)->compare_func = (GCompareFunc) e_minicard_compare;
+ E_REFLOW_SORTED(view)->string_func = (EReflowStringFunc) e_minicard_get_card_id;
+}
+
+static void
+create_card(EBookView *book_view, const GList *cards, EMinicardView *view)
+{
+ for (; cards; cards = g_list_next(cards)) {
+ GnomeCanvasItem *item = gnome_canvas_item_new(GNOME_CANVAS_GROUP(view),
+ e_minicard_get_type(),
+ "card", cards->data,
+ NULL);
+ e_reflow_add_item(E_REFLOW(view), item);
+ }
+}
+
+static void
+modify_card(EBookView *book_view, const GList *cards, EMinicardView *view)
+{
+ for (; cards; cards = g_list_next(cards)) {
+ GnomeCanvasItem *item = gnome_canvas_item_new(GNOME_CANVAS_GROUP(view),
+ e_minicard_get_type(),
+ "card", cards->data,
+ NULL);
+ e_reflow_sorted_replace_item(E_REFLOW_SORTED(view), item);
+ }
+}
+
+static void
+remove_card(EBookView *book_view, const char *id, EMinicardView *view)
+{
+ e_reflow_sorted_remove_item(E_REFLOW_SORTED(view), id);
+}
+
+static void
+book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure)
+{
+ EMinicardView *view = closure;
+ if (view->book_view && view->create_card_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->create_card_id);
+ if (view->book_view && view->remove_card_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->remove_card_id);
+ if (view->book_view && view->modify_card_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->modify_card_id);
+ if (view->book_view)
+ gtk_object_unref(GTK_OBJECT(view->book_view));
+ view->book_view = book_view;
+ if (view->book_view)
+ gtk_object_ref(GTK_OBJECT(view->book_view));
+ view->create_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view),
+ "card_added",
+ GTK_SIGNAL_FUNC(create_card),
+ view);
+ view->remove_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view),
+ "card_removed",
+ GTK_SIGNAL_FUNC(remove_card),
+ view);
+ view->modify_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view),
+ "card_changed",
+ GTK_SIGNAL_FUNC(modify_card),
+ view);
+ g_list_foreach(E_REFLOW(view)->items, (GFunc) gtk_object_destroy, NULL);
+ g_list_free(E_REFLOW(view)->items);
+}
+
+static gboolean
+get_view(EMinicardView *view)
+{
+ E_REFLOW(view)->items = NULL;
+ e_book_get_book_view(view->book, "", book_view_loaded, view);
+
+ view->get_view_idle = 0;
+ return FALSE;
+}
+
+static void
+e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
+{
+ GnomeCanvasItem *item;
+ EMinicardView *view;
+
+ item = GNOME_CANVAS_ITEM (o);
+ view = E_MINICARD_VIEW (o);
+
+ switch (arg_id){
+ case ARG_BOOK:
+ if (view->book)
+ gtk_object_unref(GTK_OBJECT(view->book));
+ view->book = E_BOOK(GTK_VALUE_OBJECT (*arg));
+ if (view->book) {
+ gtk_object_ref(GTK_OBJECT(view->book));
+ if (view->get_view_idle == 0)
+ g_idle_add((GSourceFunc)get_view, view);
+ }
+ break;
+ }
+}
+
+static void
+e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+{
+ EMinicardView *e_minicard_view;
+
+ e_minicard_view = E_MINICARD_VIEW (object);
+
+ switch (arg_id) {
+ case ARG_BOOK:
+ GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard_view->book);
+ break;
+ default:
+ arg->type = GTK_TYPE_INVALID;
+ break;
+ }
+}
+
+static void
+e_minicard_view_destroy (GtkObject *object)
+{
+ EMinicardView *view = E_MINICARD_VIEW(object);
+
+ if (view->get_view_idle)
+ g_source_remove(view->get_view_idle);
+ if (view->book)
+ gtk_object_unref(GTK_OBJECT(view->book));
+ if (view->book_view && view->create_card_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->create_card_id);
+ if (view->book_view && view->remove_card_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->remove_card_id);
+ if (view->book_view && view->modify_card_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->modify_card_id);
+ if (view->book_view)
+ gtk_object_unref(GTK_OBJECT(view->book_view));
+}
diff --git a/addressbook/gui/minicard/e-minicard-view.h b/addressbook/gui/minicard/e-minicard-view.h
new file mode 100644
index 0000000000..a88e6c7dcb
--- /dev/null
+++ b/addressbook/gui/minicard/e-minicard-view.h
@@ -0,0 +1,79 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* e-minicard-view.h
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Author: Chris Lahey <clahey@helixcode.com>
+ *
+ * This library 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.
+ *
+ * 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __E_MINICARD_VIEW_H__
+#define __E_MINICARD_VIEW_H__
+
+#include <gnome.h>
+#include "e-reflow-sorted.h"
+#include "e-book.h"
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+/* EMinicardView - A canvas item container.
+ *
+ * The following arguments are available:
+ *
+ * name type read/write description
+ * --------------------------------------------------------------------------------
+ * minimum_width double RW minimum width of the reflow. width >= minimum_width
+ * width double R width of the reflow
+ * height double RW height of the reflow
+ */
+
+#define E_MINICARD_VIEW_TYPE (e_minicard_view_get_type ())
+#define E_MINICARD_VIEW(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_VIEW_TYPE, EMinicardView))
+#define E_MINICARD_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_VIEW_TYPE, EMinicardViewClass))
+#define E_IS_MINICARD_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_VIEW_TYPE))
+#define E_IS_MINICARD_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_VIEW_TYPE))
+
+
+typedef struct _EMinicardView EMinicardView;
+typedef struct _EMinicardViewClass EMinicardViewClass;
+
+struct _EMinicardView
+{
+ EReflowSorted parent;
+
+ /* item specific fields */
+ EBook *book;
+ EBookView *book_view;
+
+ int get_view_idle;
+
+ int create_card_id, remove_card_id, modify_card_id;
+};
+
+struct _EMinicardViewClass
+{
+ EReflowSortedClass parent_class;
+};
+
+GtkType e_minicard_view_get_type (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __E_MINICARD_VIEW_H__ */
diff --git a/addressbook/gui/minicard/e-minicard.c b/addressbook/gui/minicard/e-minicard.c
index 2a98a574c7..02c7670df9 100644
--- a/addressbook/gui/minicard/e-minicard.c
+++ b/addressbook/gui/minicard/e-minicard.c
@@ -24,7 +24,7 @@
#include "e-minicard.h"
#include "e-minicard-label.h"
#include "e-text.h"
-#include "e-table-text-model.h"
+#include "e-book.h"
#include "e-canvas.h"
#include "e-util.h"
#include "e-canvas-utils.h"
@@ -49,9 +49,7 @@ enum {
ARG_WIDTH,
ARG_HEIGHT,
ARG_HAS_FOCUS,
- ARG_CARD,
- ARG_MODEL,
- ARG_ROW
+ ARG_CARD
};
GtkType
@@ -98,10 +96,6 @@ e_minicard_class_init (EMinicardClass *klass)
GTK_ARG_READWRITE, ARG_HAS_FOCUS);
gtk_object_add_arg_type ("EMinicard::card", GTK_TYPE_OBJECT,
GTK_ARG_READWRITE, ARG_CARD);
- gtk_object_add_arg_type ("EMinicard::model", GTK_TYPE_OBJECT,
- GTK_ARG_READWRITE, ARG_MODEL);
- gtk_object_add_arg_type ("EMinicard::row", GTK_TYPE_INT,
- GTK_ARG_READWRITE, ARG_ROW);
object_class->set_arg = e_minicard_set_arg;
object_class->get_arg = e_minicard_get_arg;
@@ -123,8 +117,7 @@ e_minicard_init (EMinicard *minicard)
minicard->height = 10;
minicard->has_focus = FALSE;
- minicard->model = NULL;
- minicard->row = 0;
+ minicard->card = NULL;
e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard), e_minicard_reflow);
}
@@ -164,21 +157,11 @@ e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
e_canvas_item_grab_focus(item);
break;
case ARG_CARD:
- /* e_minicard->card = GTK_VALUE_OBJECT (*arg);
- _update_card(e_minicard);
- gnome_canvas_item_request_update (item);*/
- break;
- case ARG_MODEL:
- if (e_minicard->model)
- gtk_object_unref (e_minicard->model);
- e_minicard->model = E_TABLE_MODEL(GTK_VALUE_OBJECT (*arg));
- if (e_minicard->model)
- gtk_object_ref (e_minicard->model);
- remodel(e_minicard);
- e_canvas_item_request_reflow(item);
- break;
- case ARG_ROW:
- e_minicard->row = GTK_VALUE_INT (*arg);
+ if (e_minicard->card)
+ gtk_object_unref (GTK_OBJECT(e_minicard->card));
+ e_minicard->card = E_CARD(GTK_VALUE_OBJECT (*arg));
+ if (e_minicard->card)
+ gtk_object_ref (GTK_OBJECT(e_minicard->card));
remodel(e_minicard);
e_canvas_item_request_reflow(item);
break;
@@ -203,13 +186,7 @@ e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_ENUM (*arg) = e_minicard->has_focus ? E_FOCUS_CURRENT : E_FOCUS_NONE;
break;
case ARG_CARD:
- /* GTK_VALUE_OBJECT (*arg) = e_minicard->card; */
- break;
- case ARG_MODEL:
- GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard->model);
- break;
- case ARG_ROW:
- GTK_VALUE_INT (*arg) = e_minicard->row;
+ GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard->card);
break;
default:
arg->type = GTK_TYPE_INVALID;
@@ -227,8 +204,8 @@ e_minicard_destroy (GtkObject *object)
e_minicard = E_MINICARD (object);
- if (e_minicard->model)
- gtk_object_unref (e_minicard->model);
+ if (e_minicard->card)
+ gtk_object_unref (GTK_OBJECT(e_minicard->card));
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
@@ -239,7 +216,6 @@ e_minicard_realize (GnomeCanvasItem *item)
{
EMinicard *e_minicard;
GnomeCanvasGroup *group;
- GnomeCanvasItem *new_item;
e_minicard = E_MINICARD (item);
group = GNOME_CANVAS_GROUP( item );
@@ -276,46 +252,10 @@ e_minicard_realize (GnomeCanvasItem *item)
"use_ellipsis", TRUE,
"font", "lucidasans-bold-10",
"fill_color", "black",
- "text", "Chris Lahey",
+ "text", "",
NULL );
e_canvas_item_move_absolute(e_minicard->header_text, 6, 6);
- new_item = e_minicard_label_new(group);
- gnome_canvas_item_set( new_item,
- "width", e_minicard->width - 4.0,
- "fieldname", "Email:",
- "field", "clahey@address.com",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
- e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
-
- new_item = e_minicard_label_new(group);
- gnome_canvas_item_set( new_item,
- "width", e_minicard->width - 4,
- "fieldname", "Full Name:",
- "field", "Christopher James Lahey",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
- e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
-
- new_item = e_minicard_label_new(group);
- gnome_canvas_item_set( new_item,
- "width", e_minicard->width - 4,
- "fieldname", "Street Address:",
- "field", "100 Main St\nHome town, USA",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
- e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
-
- new_item = e_minicard_label_new(group);
- gnome_canvas_item_set( new_item,
- "width", e_minicard->width - 4,
- "fieldname", "Phone:",
- "field", "000-0000",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
- e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
-
remodel(e_minicard);
e_canvas_item_request_reflow(item);
@@ -439,31 +379,92 @@ e_minicard_resize_children( EMinicard *e_minicard )
}
static void
-remodel( EMinicard *e_minicard )
+add_field (EMinicard *e_minicard, char *fieldname, char* field)
{
+ GnomeCanvasItem *new_item;
GnomeCanvasGroup *group;
group = GNOME_CANVAS_GROUP( e_minicard );
- if ( e_minicard->model ) {
- gint column = 0;
- GList *list = e_minicard->fields;
- ETableTextModel *model;
- for ( ; list; list = list->next, column++ ) {
- ETableTextModel *model = e_table_text_model_new(e_minicard->model, e_minicard->row, column);
- gnome_canvas_item_set(GNOME_CANVAS_ITEM(list->data),
- "text_model", model,
- NULL);
- gtk_object_sink(GTK_OBJECT(model));
+ new_item = e_minicard_label_new(group);
+ gnome_canvas_item_set( new_item,
+ "width", e_minicard->width - 4.0,
+ "fieldname", fieldname,
+ "field", field,
+ NULL );
+ e_minicard->fields = g_list_append( e_minicard->fields, new_item);
+ e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
+}
+
+
+static void
+remodel( EMinicard *e_minicard )
+{
+ if (e_minicard->card) {
+ char *fname;
+ ECardList *address_list;
+ ECardList *phone_list;
+ ECardList *email_list;
+
+ ECardIterator *iterator;
+
+ GList *list;
+
+ for ( list = e_minicard->fields; list; list = g_list_next( list ) ) {
+ gtk_object_destroy( GTK_OBJECT( list->data ) );
}
- if ( e_minicard->header_text ) {
- model = e_table_text_model_new(e_minicard->model, e_minicard->row, 1);
- gnome_canvas_item_set(GNOME_CANVAS_ITEM(e_minicard->header_text),
- "model", model,
- NULL);
- gtk_object_sink(GTK_OBJECT(model));
+ g_list_free(e_minicard->fields);
+ e_minicard->fields = NULL;
+
+ gtk_object_get(GTK_OBJECT(e_minicard->card),
+ "full_name", &fname,
+ "address", &address_list,
+ "phone", &phone_list,
+ "email", &email_list,
+ NULL);
+
+ if (fname) {
+ add_field(e_minicard, "Name:", fname);
+ if (e_minicard->header_text)
+ gnome_canvas_item_set(e_minicard->header_text,
+ "text", fname,
+ NULL);
+ } else
+ if (e_minicard->header_text)
+ gnome_canvas_item_set(e_minicard->header_text,
+ "text", "",
+ NULL);
+ if (address_list) {
+ for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
+ const ECardDeliveryAddress *address = e_card_iterator_get(iterator);
+ if (address->flags & ADDR_WORK) {
+ add_field(e_minicard, "Work Address:", address->city);
+ } else if (address->flags & ADDR_HOME) {
+ add_field(e_minicard, "Home Address:", address->city);
+ } else {
+ add_field(e_minicard, "Address:", address->city);
+ }
+ }
+ }
+ if (phone_list) {
+ for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
+ const ECardPhone *phone = e_card_iterator_get(iterator);
+ if (phone->flags & E_CARD_PHONE_WORK) {
+ add_field(e_minicard, "Work Phone:", phone->number);
+ } else if (phone->flags & E_CARD_PHONE_HOME) {
+ add_field(e_minicard, "Home Phone:", phone->number);
+ } else if (phone->flags & E_CARD_PHONE_CELL) {
+ add_field(e_minicard, "Mobile Phone:", phone->number);
+ } else {
+ add_field(e_minicard, "Phone:", phone->number);
+ }
+ }
+ }
+ if (email_list) {
+ for (iterator = e_card_list_get_iterator(email_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
+ add_field(e_minicard, "Email:", (char *) e_card_iterator_get(iterator));
+ }
}
-
}
}
@@ -513,3 +514,38 @@ e_minicard_reflow( GnomeCanvasItem *item, int flags )
e_canvas_item_request_parent_reflow(item);
}
}
+
+char *
+e_minicard_get_card_id (EMinicard *minicard)
+{
+ g_return_val_if_fail(minicard != NULL, NULL);
+ g_return_val_if_fail(E_IS_MINICARD(minicard), NULL);
+
+ if (minicard->card) {
+ return e_card_get_id(minicard->card);
+ } else {
+ return NULL;
+ }
+}
+
+int
+e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2)
+{
+ g_return_val_if_fail(minicard1 != NULL, 0);
+ g_return_val_if_fail(E_IS_MINICARD(minicard1), 0);
+ g_return_val_if_fail(minicard2 != NULL, 0);
+ g_return_val_if_fail(E_IS_MINICARD(minicard2), 0);
+
+ if (minicard1->card && minicard2->card) {
+ char *fname1, *fname2;
+ gtk_object_get(GTK_OBJECT(minicard1->card),
+ "full_name", &fname1,
+ NULL);
+ gtk_object_get(GTK_OBJECT(minicard2->card),
+ "full_name", &fname2,
+ NULL);
+ return strcmp(fname1, fname2);
+ } else {
+ return 0;
+ }
+}
diff --git a/addressbook/gui/minicard/e-minicard.h b/addressbook/gui/minicard/e-minicard.h
index 05d95a743e..85481d586e 100644
--- a/addressbook/gui/minicard/e-minicard.h
+++ b/addressbook/gui/minicard/e-minicard.h
@@ -22,7 +22,7 @@
#define __E_MINICARD_H__
#include <gnome.h>
-#include "e-table-model.h"
+#include "e-card.h"
#ifdef __cplusplus
extern "C" {
@@ -37,10 +37,6 @@ extern "C" {
* --------------------------------------------------------------------------------
* width double RW width of the card
* height double R height of the card
- * model ETableModel RW model to read from
- * row int RW ETableModel row to read from
- *
- * Later:
* card ECard* RW Pointer to the ECard
*/
@@ -72,8 +68,7 @@ struct _EMinicard
GnomeCanvasItem *header_text;
GList *fields; /* Of type GnomeCanvasItem. */
- ETableModel *model;
- int row;
+ ECard *card;
guint needs_remodeling : 1;
gboolean has_focus;
@@ -90,7 +85,9 @@ struct _EMinicardClass
};
-GtkType e_minicard_get_type (void);
+GtkType e_minicard_get_type (void);
+char *e_minicard_get_card_id (EMinicard *minicard);
+int e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2);
#ifdef __cplusplus
}
diff --git a/addressbook/gui/minicard/e-reflow-sorted.c b/addressbook/gui/minicard/e-reflow-sorted.c
new file mode 100644
index 0000000000..696efe454a
--- /dev/null
+++ b/addressbook/gui/minicard/e-reflow-sorted.c
@@ -0,0 +1,185 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-reflow-sorted.c
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Author: Chris Lahey <clahey@helixcode.com>
+ *
+ * This library 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.
+ *
+ * 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gnome.h>
+#include <math.h>
+#include "e-reflow-sorted.h"
+#include "e-canvas-utils.h"
+#include "e-canvas.h"
+#include "e-util.h"
+#include <glib.h>
+static void e_reflow_sorted_init (EReflowSorted *card);
+static void e_reflow_sorted_class_init (EReflowSortedClass *klass);
+static void e_reflow_sorted_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
+static void e_reflow_sorted_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
+static void e_reflow_sorted_add_item(EReflow *e_reflow, GnomeCanvasItem *item);
+
+static EReflowClass *parent_class = NULL;
+
+/* The arguments we take */
+enum {
+ ARG_0,
+ ARG_COMPARE_FUNC,
+ ARG_STRING_FUNC
+};
+
+GtkType
+e_reflow_sorted_get_type (void)
+{
+ static GtkType reflow_type = 0;
+
+ if (!reflow_type)
+ {
+ static const GtkTypeInfo reflow_info =
+ {
+ "EReflowSorted",
+ sizeof (EReflowSorted),
+ sizeof (EReflowSortedClass),
+ (GtkClassInitFunc) e_reflow_sorted_class_init,
+ (GtkObjectInitFunc) e_reflow_sorted_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ reflow_type = gtk_type_unique (e_reflow_get_type (), &reflow_info);
+ }
+
+ return reflow_type;
+}
+
+static void
+e_reflow_sorted_class_init (EReflowSortedClass *klass)
+{
+ GtkObjectClass *object_class;
+ EReflowClass *reflow_class;
+
+ object_class = (GtkObjectClass*) klass;
+ reflow_class = E_REFLOW_CLASS (klass);
+
+ parent_class = gtk_type_class (e_reflow_get_type ());
+
+ gtk_object_add_arg_type ("EReflowSorted::compare_func", GTK_TYPE_POINTER,
+ GTK_ARG_READWRITE, ARG_COMPARE_FUNC);
+ gtk_object_add_arg_type ("EReflowSorted::string_func", GTK_TYPE_POINTER,
+ GTK_ARG_READWRITE, ARG_STRING_FUNC);
+
+ reflow_class->add_item = e_reflow_sorted_add_item;
+
+ object_class->set_arg = e_reflow_sorted_set_arg;
+ object_class->get_arg = e_reflow_sorted_get_arg;
+}
+
+static void
+e_reflow_sorted_init (EReflowSorted *reflow)
+{
+ reflow->compare_func = NULL;
+ reflow->string_func = NULL;
+}
+
+static void
+e_reflow_sorted_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
+{
+ GnomeCanvasItem *item;
+ EReflowSorted *e_reflow_sorted;
+
+ item = GNOME_CANVAS_ITEM (o);
+ e_reflow_sorted = E_REFLOW_SORTED (o);
+
+ switch (arg_id){
+ case ARG_COMPARE_FUNC:
+ e_reflow_sorted->compare_func = GTK_VALUE_POINTER (*arg);
+ break;
+ case ARG_STRING_FUNC:
+ e_reflow_sorted->string_func = GTK_VALUE_POINTER (*arg);
+ break;
+ }
+}
+
+static void
+e_reflow_sorted_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+{
+ EReflowSorted *e_reflow_sorted;
+
+ e_reflow_sorted = E_REFLOW_SORTED (object);
+
+ switch (arg_id) {
+ case ARG_COMPARE_FUNC:
+ GTK_VALUE_POINTER (*arg) = e_reflow_sorted->compare_func;
+ break;
+ case ARG_STRING_FUNC:
+ GTK_VALUE_POINTER (*arg) = e_reflow_sorted->string_func;
+ break;
+ default:
+ arg->type = GTK_TYPE_INVALID;
+ break;
+ }
+}
+
+void
+e_reflow_sorted_remove_item(EReflowSorted *e_reflow_sorted, const gchar *id)
+{
+ if (e_reflow_sorted->string_func) {
+ EReflow *reflow = E_REFLOW(e_reflow_sorted);
+ GList *list;
+ for (list = reflow->items; list; list = g_list_next(list)) {
+ GnomeCanvasItem *item = list->data;
+ char *string = e_reflow_sorted->string_func (item);
+ if (string && !strcmp(string, id)) {
+ reflow->items = g_list_remove_link(reflow->items, list);
+ g_list_free_1(list);
+ gtk_object_destroy(GTK_OBJECT(item));
+ if ( GTK_OBJECT_FLAGS( e_reflow_sorted ) & GNOME_CANVAS_ITEM_REALIZED ) {
+ e_canvas_item_request_reflow(item);
+ }
+ return;
+ }
+ }
+ }
+}
+
+void
+e_reflow_sorted_replace_item(EReflowSorted *e_reflow_sorted, GnomeCanvasItem *item)
+{
+ if (e_reflow_sorted->string_func) {
+ char *string = e_reflow_sorted->string_func (item);
+ e_reflow_sorted_remove_item(e_reflow_sorted, string);
+ e_reflow_sorted_add_item(E_REFLOW(e_reflow_sorted), item);
+ }
+}
+
+
+static void
+e_reflow_sorted_add_item(EReflow *reflow, GnomeCanvasItem *item)
+{
+ EReflowSorted *e_reflow_sorted = E_REFLOW_SORTED(reflow);
+ if ( e_reflow_sorted->compare_func ) {
+ reflow->items = g_list_insert_sorted(reflow->items, item, e_reflow_sorted->compare_func);
+
+ if ( GTK_OBJECT_FLAGS( e_reflow_sorted ) & GNOME_CANVAS_ITEM_REALIZED ) {
+ gnome_canvas_item_set(item,
+ "width", (double) reflow->column_width,
+ NULL);
+ e_canvas_item_request_reflow(item);
+ }
+ }
+}
diff --git a/addressbook/gui/minicard/e-reflow-sorted.h b/addressbook/gui/minicard/e-reflow-sorted.h
new file mode 100644
index 0000000000..4ffec7579b
--- /dev/null
+++ b/addressbook/gui/minicard/e-reflow-sorted.h
@@ -0,0 +1,87 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* e-reflow-sorted.h
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Author: Chris Lahey <clahey@helixcode.com>
+ *
+ * This library 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.
+ *
+ * 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __E_REFLOW_SORTED_H__
+#define __E_REFLOW_SORTED_H__
+
+#include <e-reflow.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+/* EReflowSorted - A canvas item container.
+ *
+ * The following arguments are available:
+ *
+ * name type read/write description
+ * --------------------------------------------------------------------------------
+ * compare_func GCompareFunc RW compare function
+ * string_func EReflowStringFunc RW string function
+ *
+ * From EReflow:
+ * minimum_width double RW minimum width of the reflow. width >= minimum_width
+ * width double R width of the reflow
+ * height double RW height of the reflow
+ */
+
+#define E_REFLOW_SORTED_TYPE (e_reflow_sorted_get_type ())
+#define E_REFLOW_SORTED(obj) (GTK_CHECK_CAST ((obj), E_REFLOW_SORTED_TYPE, EReflowSorted))
+#define E_REFLOW_SORTED_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_REFLOW_SORTED_TYPE, EReflowSortedClass))
+#define E_IS_REFLOW_SORTED(obj) (GTK_CHECK_TYPE ((obj), E_REFLOW_SORTED_TYPE))
+#define E_IS_REFLOW_SORTED_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_REFLOW_SORTED_TYPE))
+
+typedef char * (* EReflowStringFunc) (GnomeCanvasItem *);
+
+typedef struct _EReflowSorted EReflowSorted;
+typedef struct _EReflowSortedClass EReflowSortedClass;
+
+/* FIXME: Try reimplementing this as a hash table with key as string
+ and change EReflow to use a GTree. */
+struct _EReflowSorted
+{
+ EReflow parent;
+
+ /* item specific fields */
+ GCompareFunc compare_func;
+ EReflowStringFunc string_func;
+};
+
+struct _EReflowSortedClass
+{
+ EReflowClass parent_class;
+};
+
+/*
+ * To be added to a reflow, an item must have the argument "width" as
+ * a Read/Write argument and "height" as a Read Only argument. It
+ * should also do an ECanvas parent reflow request if its size
+ * changes.
+ */
+void e_reflow_sorted_remove_item (EReflowSorted *sorted, const char *id);
+void e_reflow_sorted_replace_item (EReflowSorted *sorted, GnomeCanvasItem *item);
+GtkType e_reflow_sorted_get_type (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __E_REFLOW_SORTED_H__ */
diff --git a/addressbook/gui/minicard/e-reflow.c b/addressbook/gui/minicard/e-reflow.c
index 4af46bd4a4..0ff8c0f4ea 100644
--- a/addressbook/gui/minicard/e-reflow.c
+++ b/addressbook/gui/minicard/e-reflow.c
@@ -26,10 +26,11 @@
#include "e-canvas-utils.h"
#include "e-canvas.h"
#include "e-util.h"
-static void e_reflow_init (EReflow *card);
+static void e_reflow_init (EReflow *reflow);
static void e_reflow_class_init (EReflowClass *klass);
static void e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
static void e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
+static void e_reflow_destroy (GtkObject *object);
static gboolean e_reflow_event (GnomeCanvasItem *item, GdkEvent *event);
static void e_reflow_realize (GnomeCanvasItem *item);
static void e_reflow_unrealize (GnomeCanvasItem *item);
@@ -38,6 +39,7 @@ static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
static void e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags);
static double e_reflow_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item);
static void e_reflow_reflow (GnomeCanvasItem *item, int flags);
+static void e_reflow_real_add_item(EReflow *e_reflow, GnomeCanvasItem *item);
static void e_reflow_resize_children (GnomeCanvasItem *item);
@@ -97,10 +99,12 @@ e_reflow_class_init (EReflowClass *klass)
GTK_ARG_READABLE, ARG_WIDTH);
gtk_object_add_arg_type ("EReflow::height", GTK_TYPE_DOUBLE,
GTK_ARG_READWRITE, ARG_HEIGHT);
+
+ klass->add_item = e_reflow_real_add_item;
- object_class->set_arg = e_reflow_set_arg;
- object_class->get_arg = e_reflow_get_arg;
- /* object_class->destroy = e_reflow_destroy; */
+ object_class->set_arg = e_reflow_set_arg;
+ object_class->get_arg = e_reflow_get_arg;
+ object_class->destroy = e_reflow_destroy;
/* GnomeCanvasItem method overrides */
item_class->event = e_reflow_event;
@@ -114,7 +118,6 @@ e_reflow_class_init (EReflowClass *klass)
static void
e_reflow_init (EReflow *reflow)
{
- /* reflow->card = NULL;*/
reflow->items = NULL;
reflow->columns = NULL;
reflow->column_width = 150;
@@ -181,6 +184,14 @@ e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
static void
+e_reflow_destroy (GtkObject *object)
+{
+ EReflow *reflow = E_REFLOW(object);
+
+ g_list_free(reflow->items);
+}
+
+static void
e_reflow_realize (GnomeCanvasItem *item)
{
EReflow *e_reflow;
@@ -228,9 +239,11 @@ e_reflow_unrealize (GnomeCanvasItem *item)
gdk_cursor_destroy (e_reflow->arrow_cursor);
gdk_cursor_destroy (e_reflow->default_cursor);
+ e_reflow->arrow_cursor = NULL;
+ e_reflow->default_cursor = NULL;
- g_list_free (e_reflow->items);
g_list_free (e_reflow->columns);
+ e_reflow->columns = NULL;
if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize)
(* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item);
@@ -428,8 +441,8 @@ e_reflow_event (GnomeCanvasItem *item, GdkEvent *event)
return 0;
}
-void
-e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item)
+static void
+e_reflow_real_add_item(EReflow *e_reflow, GnomeCanvasItem *item)
{
e_reflow->items = g_list_append(e_reflow->items, item);
if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) {
@@ -747,3 +760,10 @@ e_reflow_reflow( GnomeCanvasItem *item, int flags )
e_canvas_item_request_parent_reflow(item);
}
}
+
+void
+e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item)
+{
+ if (E_REFLOW_CLASS(GTK_OBJECT(e_reflow)->klass)->add_item)
+ (E_REFLOW_CLASS(GTK_OBJECT(e_reflow)->klass)->add_item) (e_reflow, item);
+}
diff --git a/addressbook/gui/minicard/e-reflow.h b/addressbook/gui/minicard/e-reflow.h
index 3a731474cb..54de59ba55 100644
--- a/addressbook/gui/minicard/e-reflow.h
+++ b/addressbook/gui/minicard/e-reflow.h
@@ -54,10 +54,8 @@ struct _EReflow
GnomeCanvasGroup parent;
/* item specific fields */
- /* EBook *book; */
-
GList *items; /* Of type GnomeCanvasItem */
- GList *columns; /* Of type GList pointing to type GnomeCanvasItem (points into items) */
+ GList *columns; /* Of type GList of type GnomeCanvasItem (points into items) */
gint column_count; /* Number of columnns */
double minimum_width;
@@ -87,12 +85,16 @@ struct _EReflowClass
{
GnomeCanvasGroupClass parent_class;
- void (* resize) (EReflow *reflow);
+ /* Virtual methods. */
+ void (* add_item) (EReflow *reflow, GnomeCanvasItem *item);
};
-/* To be added to a reflow, an item must have the arguments "x", "y",
- and "width" as Read/Write arguments and "height" as a Read Only
- argument. It must also have a "resize" signal. */
+/*
+ * To be added to a reflow, an item must have the argument "width" as
+ * a Read/Write argument and "height" as a Read Only argument. It
+ * should also do an ECanvas parent reflow request if its size
+ * changes.
+ */
void e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item);
GtkType e_reflow_get_type (void);
diff --git a/addressbook/gui/minicard/test-minicard-view.c b/addressbook/gui/minicard/test-minicard-view.c
new file mode 100644
index 0000000000..d3ceff228e
--- /dev/null
+++ b/addressbook/gui/minicard/test-minicard-view.c
@@ -0,0 +1,206 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* test-reflow.c
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Author: Chris Lahey <clahey@helixcode.com>
+ *
+ * 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.
+ */
+
+#include "config.h"
+
+#include <gnome.h>
+#include <libgnorba/gnorba.h>
+#include <bonobo.h>
+#include "e-canvas.h"
+#include "e-minicard-view.h"
+
+/* This is a horrible thing to do, but it is just a test. */
+GnomeCanvasItem *reflow;
+GnomeCanvasItem *rect;
+GtkAllocation last_alloc;
+
+CORBA_Environment ev;
+CORBA_ORB orb;
+
+static void
+init_bonobo (int argc, char **argv)
+{
+
+ gnome_CORBA_init_with_popt_table (
+ "Reflow Test", VERSION,
+ &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev);
+
+ orb = gnome_CORBA_ORB ();
+
+ if (bonobo_init (orb, NULL, NULL) == FALSE)
+ g_error (_("Could not initialize Bonobo"));
+
+}
+
+static void destroy_callback(GtkWidget *app, gpointer data)
+{
+ exit(0);
+}
+
+static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
+{
+ double width;
+ last_alloc = *allocation;
+ gnome_canvas_item_set( reflow,
+ "height", (double) allocation->height,
+ NULL );
+ gnome_canvas_item_set( reflow,
+ "minimum_width", (double) allocation->width,
+ NULL );
+ gtk_object_get(GTK_OBJECT(reflow),
+ "width", &width,
+ NULL);
+ width = MAX(width, allocation->width);
+ gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, width, allocation->height );
+ gnome_canvas_item_set( rect,
+ "x2", (double) width,
+ "y2", (double) allocation->height,
+ NULL );
+}
+
+static void resize(GnomeCanvas *canvas, gpointer data)
+{
+ double width;
+ gtk_object_get(GTK_OBJECT(reflow),
+ "width", &width,
+ NULL);
+ width = MAX(width, last_alloc.width);
+ gnome_canvas_set_scroll_region(canvas , 0, 0, width, last_alloc.height );
+ gnome_canvas_item_set( rect,
+ "x2", (double) width,
+ "y2", (double) last_alloc.height,
+ NULL );
+}
+
+#if 0
+static void about_callback( GtkWidget *widget, gpointer data )
+{
+
+ const gchar *authors[] =
+ {
+ "Christopher James Lahey <clahey@umich.edu>",
+ NULL
+ };
+
+ GtkWidget *about =
+ gnome_about_new ( _( "Reflow Test" ), VERSION,
+ _( "Copyright (C) 2000, Helix Code, Inc." ),
+ authors,
+ _( "This should test the reflow canvas item" ),
+ NULL);
+ gtk_widget_show (about);
+}
+#endif
+
+static void
+book_open_cb (EBook *book, EBookStatus status, gpointer closure)
+{
+ if (status == E_BOOK_STATUS_SUCCESS)
+ gnome_canvas_item_set(reflow,
+ "book", book,
+ NULL);
+}
+
+static guint
+ebook_create (void)
+{
+ EBook *book;
+
+ book = e_book_new ();
+
+ if (!book) {
+ printf ("%s: %s(): Couldn't create EBook, bailing.\n",
+ __FILE__,
+ __FUNCTION__);
+ return FALSE;
+ }
+
+
+ if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL)) {
+ printf ("error calling load_uri!\n");
+ }
+
+
+ return FALSE;
+}
+
+int main( int argc, char *argv[] )
+{
+ GtkWidget *app;
+ GtkWidget *canvas;
+ GtkWidget *vbox;
+ GtkWidget *scrollbar;
+
+ /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
+ textdomain (PACKAGE);*/
+
+ CORBA_exception_init (&ev);
+ init_bonobo (argc, argv);
+
+ app = gnome_app_new("Reflow Test", NULL);
+
+ vbox = gtk_vbox_new(FALSE, 0);
+
+ canvas = e_canvas_new();
+ rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
+ gnome_canvas_rect_get_type(),
+ "x1", (double) 0,
+ "y1", (double) 0,
+ "x2", (double) 100,
+ "y2", (double) 100,
+ "fill_color", "white",
+ NULL );
+ reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
+ e_minicard_view_get_type(),
+ "height", (double) 100,
+ "minimum_width", (double) 100,
+ NULL );
+ gtk_signal_connect( GTK_OBJECT( canvas ), "reflow",
+ GTK_SIGNAL_FUNC( resize ),
+ ( gpointer ) app);
+
+ gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
+ 0, 0,
+ 100, 100 );
+
+ gtk_box_pack_start(GTK_BOX(vbox), canvas, TRUE, TRUE, 0);
+
+ scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(canvas)));
+
+ gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0);
+
+ gnome_app_set_contents( GNOME_APP( app ), vbox );
+
+ /* Connect the signals */
+ gtk_signal_connect( GTK_OBJECT( app ), "destroy",
+ GTK_SIGNAL_FUNC( destroy_callback ),
+ ( gpointer ) app );
+
+ gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate",
+ GTK_SIGNAL_FUNC( allocate_callback ),
+ ( gpointer ) app );
+
+ gtk_widget_show_all( app );
+ gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE);
+
+ gtk_idle_add ((GtkFunction) ebook_create, NULL);
+
+ bonobo_main ();
+
+ /* Not reached. */
+ return 0;
+}
diff --git a/addressbook/gui/minicard/test-reflow.c b/addressbook/gui/minicard/test-reflow.c
index 8cedbaac28..64c2b89a37 100644
--- a/addressbook/gui/minicard/test-reflow.c
+++ b/addressbook/gui/minicard/test-reflow.c
@@ -16,6 +16,32 @@
*/
+#define TEST_VCARD \
+"BEGIN:VCARD
+" \
+"FN:Nat
+" \
+"N:Friedman;Nat;D;Mr.
+" \
+"BDAY:1977-08-06
+" \
+"TEL;WORK:617 679 1984
+" \
+"TEL;CELL:123 456 7890
+" \
+"EMAIL;INTERNET:nat@nat.org
+" \
+"EMAIL;INTERNET:nat@helixcode.com
+" \
+"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234;
+" \
+"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA
+" \
+"END:VCARD
+" \
+"
+"
+
#include "config.h"
@@ -127,8 +153,10 @@ int main( int argc, char *argv[] )
for ( i = 0; i < 200; i++ )
{
GnomeCanvasItem *item;
+ ECard *card = e_card_new (TEST_VCARD);
item = gnome_canvas_item_new( GNOME_CANVAS_GROUP(reflow),
e_minicard_get_type(),
+ "card", card,
NULL);
e_reflow_add_item(E_REFLOW(reflow), item);
}
diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am
index e1b130bc2a..3534e9cb69 100644
--- a/addressbook/gui/widgets/Makefile.am
+++ b/addressbook/gui/widgets/Makefile.am
@@ -1,7 +1,7 @@
INCLUDES = \
+ -I$(top_srcdir)/addressbook/backend/ebook \
-I$(top_srcdir)/widgets/e-text \
-I$(top_srcdir)/e-util \
- -I$(top_srcdir)/widgets/e-table \
$(GNOME_INCLUDEDIR)
noinst_LIBRARIES = \
@@ -12,40 +12,65 @@ libeminicard_a_SOURCES = \
e-minicard.h \
e-minicard-label.c \
e-minicard-label.h \
+ e-minicard-view.c \
+ e-minicard-view.h \
+ e-reflow-sorted.c \
+ e-reflow-sorted.h \
e-reflow.c \
e-reflow.h
noinst_PROGRAMS = \
minicard-label-test \
minicard-test \
- reflow-test
+ reflow-test \
+ minicard-view-test
minicard_label_test_SOURCES = \
test-minicard-label.c
minicard_label_test_LDADD = \
$(EXTRA_GNOME_LIBS) \
+ $(GNOMEGNORBA_LIBS) \
libeminicard.a \
+ -lbonobo \
$(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/widgets/e-text/libetext.a \
- $(top_builddir)/widgets/e-table/libetable.a
+ $(top_builddir)/widgets/e-text/libetext.a
minicard_test_SOURCES = \
test-minicard.c
minicard_test_LDADD = \
$(EXTRA_GNOME_LIBS) \
+ $(GNOMEGNORBA_LIBS) \
libeminicard.a \
+ -lbonobo \
$(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/widgets/e-text/libetext.a \
- $(top_builddir)/widgets/e-table/libetable.a
+ $(top_builddir)/addressbook/backend/ebook/libebook.la \
+ $(top_builddir)/libversit/libversit.la \
+ $(top_builddir)/widgets/e-text/libetext.a
reflow_test_SOURCES = \
test-reflow.c
reflow_test_LDADD = \
$(EXTRA_GNOME_LIBS) \
+ $(GNOMEGNORBA_LIBS) \
libeminicard.a \
+ -lbonobo \
$(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/widgets/e-text/libetext.a \
- $(top_builddir)/widgets/e-table/libetable.a
+ $(top_builddir)/addressbook/backend/ebook/libebook.la \
+ $(top_builddir)/libversit/libversit.la \
+ $(top_builddir)/widgets/e-text/libetext.a
+
+minicard_view_test_SOURCES = \
+ test-minicard-view.c
+
+minicard_view_test_LDADD = \
+ $(EXTRA_GNOME_LIBS) \
+ $(GNOMEGNORBA_LIBS) \
+ libeminicard.a \
+ -lbonobo \
+ $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/addressbook/backend/ebook/libebook.la \
+ $(top_builddir)/libversit/libversit.la \
+ $(top_builddir)/widgets/e-text/libetext.a
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
new file mode 100644
index 0000000000..6e7b432a8e
--- /dev/null
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -0,0 +1,239 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-minicard-view.c
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Author: Chris Lahey <clahey@helixcode.com>
+ *
+ * This library 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.
+ *
+ * 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <gnome.h>
+#include "e-minicard-view.h"
+#include "e-minicard.h"
+static void e_minicard_view_init (EMinicardView *reflow);
+static void e_minicard_view_class_init (EMinicardViewClass *klass);
+static void e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
+static void e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
+static void e_minicard_view_destroy (GtkObject *object);
+
+#define E_MINICARD_VIEW_DIVIDER_WIDTH 2
+#define E_MINICARD_VIEW_BORDER_WIDTH 7
+#define E_MINICARD_VIEW_FULL_GUTTER (E_MINICARD_VIEW_DIVIDER_WIDTH + E_MINICARD_VIEW_BORDER_WIDTH * 2)
+
+static EReflowSortedClass *parent_class = NULL;
+
+/* The arguments we take */
+enum {
+ ARG_0,
+ ARG_BOOK
+};
+
+GtkType
+e_minicard_view_get_type (void)
+{
+ static GtkType reflow_type = 0;
+
+ if (!reflow_type)
+ {
+ static const GtkTypeInfo reflow_info =
+ {
+ "EMinicardView",
+ sizeof (EMinicardView),
+ sizeof (EMinicardViewClass),
+ (GtkClassInitFunc) e_minicard_view_class_init,
+ (GtkObjectInitFunc) e_minicard_view_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ reflow_type = gtk_type_unique (e_reflow_sorted_get_type (), &reflow_info);
+ }
+
+ return reflow_type;
+}
+
+static void
+e_minicard_view_class_init (EMinicardViewClass *klass)
+{
+ GtkObjectClass *object_class;
+ GnomeCanvasItemClass *item_class;
+
+ object_class = (GtkObjectClass*) klass;
+ item_class = (GnomeCanvasItemClass *) klass;
+
+ parent_class = gtk_type_class (e_reflow_sorted_get_type ());
+
+gtk_object_add_arg_type ("EMinicardView::book", GTK_TYPE_OBJECT,
+ GTK_ARG_READWRITE, ARG_BOOK);
+
+ object_class->set_arg = e_minicard_view_set_arg;
+ object_class->get_arg = e_minicard_view_get_arg;
+ object_class->destroy = e_minicard_view_destroy;
+
+ /* GnomeCanvasItem method overrides */
+}
+
+static void
+e_minicard_view_init (EMinicardView *view)
+{
+ view->book = NULL;
+ view->book_view = NULL;
+ view->get_view_idle = 0;
+ view->create_card_id = 0;
+ view->remove_card_id = 0;
+ view->modify_card_id = 0;
+
+ E_REFLOW_SORTED(view)->compare_func = (GCompareFunc) e_minicard_compare;
+ E_REFLOW_SORTED(view)->string_func = (EReflowStringFunc) e_minicard_get_card_id;
+}
+
+static void
+create_card(EBookView *book_view, const GList *cards, EMinicardView *view)
+{
+ for (; cards; cards = g_list_next(cards)) {
+ GnomeCanvasItem *item = gnome_canvas_item_new(GNOME_CANVAS_GROUP(view),
+ e_minicard_get_type(),
+ "card", cards->data,
+ NULL);
+ e_reflow_add_item(E_REFLOW(view), item);
+ }
+}
+
+static void
+modify_card(EBookView *book_view, const GList *cards, EMinicardView *view)
+{
+ for (; cards; cards = g_list_next(cards)) {
+ GnomeCanvasItem *item = gnome_canvas_item_new(GNOME_CANVAS_GROUP(view),
+ e_minicard_get_type(),
+ "card", cards->data,
+ NULL);
+ e_reflow_sorted_replace_item(E_REFLOW_SORTED(view), item);
+ }
+}
+
+static void
+remove_card(EBookView *book_view, const char *id, EMinicardView *view)
+{
+ e_reflow_sorted_remove_item(E_REFLOW_SORTED(view), id);
+}
+
+static void
+book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure)
+{
+ EMinicardView *view = closure;
+ if (view->book_view && view->create_card_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->create_card_id);
+ if (view->book_view && view->remove_card_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->remove_card_id);
+ if (view->book_view && view->modify_card_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->modify_card_id);
+ if (view->book_view)
+ gtk_object_unref(GTK_OBJECT(view->book_view));
+ view->book_view = book_view;
+ if (view->book_view)
+ gtk_object_ref(GTK_OBJECT(view->book_view));
+ view->create_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view),
+ "card_added",
+ GTK_SIGNAL_FUNC(create_card),
+ view);
+ view->remove_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view),
+ "card_removed",
+ GTK_SIGNAL_FUNC(remove_card),
+ view);
+ view->modify_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view),
+ "card_changed",
+ GTK_SIGNAL_FUNC(modify_card),
+ view);
+ g_list_foreach(E_REFLOW(view)->items, (GFunc) gtk_object_destroy, NULL);
+ g_list_free(E_REFLOW(view)->items);
+}
+
+static gboolean
+get_view(EMinicardView *view)
+{
+ E_REFLOW(view)->items = NULL;
+ e_book_get_book_view(view->book, "", book_view_loaded, view);
+
+ view->get_view_idle = 0;
+ return FALSE;
+}
+
+static void
+e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
+{
+ GnomeCanvasItem *item;
+ EMinicardView *view;
+
+ item = GNOME_CANVAS_ITEM (o);
+ view = E_MINICARD_VIEW (o);
+
+ switch (arg_id){
+ case ARG_BOOK:
+ if (view->book)
+ gtk_object_unref(GTK_OBJECT(view->book));
+ view->book = E_BOOK(GTK_VALUE_OBJECT (*arg));
+ if (view->book) {
+ gtk_object_ref(GTK_OBJECT(view->book));
+ if (view->get_view_idle == 0)
+ g_idle_add((GSourceFunc)get_view, view);
+ }
+ break;
+ }
+}
+
+static void
+e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+{
+ EMinicardView *e_minicard_view;
+
+ e_minicard_view = E_MINICARD_VIEW (object);
+
+ switch (arg_id) {
+ case ARG_BOOK:
+ GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard_view->book);
+ break;
+ default:
+ arg->type = GTK_TYPE_INVALID;
+ break;
+ }
+}
+
+static void
+e_minicard_view_destroy (GtkObject *object)
+{
+ EMinicardView *view = E_MINICARD_VIEW(object);
+
+ if (view->get_view_idle)
+ g_source_remove(view->get_view_idle);
+ if (view->book)
+ gtk_object_unref(GTK_OBJECT(view->book));
+ if (view->book_view && view->create_card_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->create_card_id);
+ if (view->book_view && view->remove_card_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->remove_card_id);
+ if (view->book_view && view->modify_card_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->modify_card_id);
+ if (view->book_view)
+ gtk_object_unref(GTK_OBJECT(view->book_view));
+}
diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h
new file mode 100644
index 0000000000..a88e6c7dcb
--- /dev/null
+++ b/addressbook/gui/widgets/e-minicard-view.h
@@ -0,0 +1,79 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* e-minicard-view.h
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Author: Chris Lahey <clahey@helixcode.com>
+ *
+ * This library 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.
+ *
+ * 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __E_MINICARD_VIEW_H__
+#define __E_MINICARD_VIEW_H__
+
+#include <gnome.h>
+#include "e-reflow-sorted.h"
+#include "e-book.h"
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+/* EMinicardView - A canvas item container.
+ *
+ * The following arguments are available:
+ *
+ * name type read/write description
+ * --------------------------------------------------------------------------------
+ * minimum_width double RW minimum width of the reflow. width >= minimum_width
+ * width double R width of the reflow
+ * height double RW height of the reflow
+ */
+
+#define E_MINICARD_VIEW_TYPE (e_minicard_view_get_type ())
+#define E_MINICARD_VIEW(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_VIEW_TYPE, EMinicardView))
+#define E_MINICARD_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_VIEW_TYPE, EMinicardViewClass))
+#define E_IS_MINICARD_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_VIEW_TYPE))
+#define E_IS_MINICARD_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_VIEW_TYPE))
+
+
+typedef struct _EMinicardView EMinicardView;
+typedef struct _EMinicardViewClass EMinicardViewClass;
+
+struct _EMinicardView
+{
+ EReflowSorted parent;
+
+ /* item specific fields */
+ EBook *book;
+ EBookView *book_view;
+
+ int get_view_idle;
+
+ int create_card_id, remove_card_id, modify_card_id;
+};
+
+struct _EMinicardViewClass
+{
+ EReflowSortedClass parent_class;
+};
+
+GtkType e_minicard_view_get_type (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __E_MINICARD_VIEW_H__ */
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index 2a98a574c7..02c7670df9 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -24,7 +24,7 @@
#include "e-minicard.h"
#include "e-minicard-label.h"
#include "e-text.h"
-#include "e-table-text-model.h"
+#include "e-book.h"
#include "e-canvas.h"
#include "e-util.h"
#include "e-canvas-utils.h"
@@ -49,9 +49,7 @@ enum {
ARG_WIDTH,
ARG_HEIGHT,
ARG_HAS_FOCUS,
- ARG_CARD,
- ARG_MODEL,
- ARG_ROW
+ ARG_CARD
};
GtkType
@@ -98,10 +96,6 @@ e_minicard_class_init (EMinicardClass *klass)
GTK_ARG_READWRITE, ARG_HAS_FOCUS);
gtk_object_add_arg_type ("EMinicard::card", GTK_TYPE_OBJECT,
GTK_ARG_READWRITE, ARG_CARD);
- gtk_object_add_arg_type ("EMinicard::model", GTK_TYPE_OBJECT,
- GTK_ARG_READWRITE, ARG_MODEL);
- gtk_object_add_arg_type ("EMinicard::row", GTK_TYPE_INT,
- GTK_ARG_READWRITE, ARG_ROW);
object_class->set_arg = e_minicard_set_arg;
object_class->get_arg = e_minicard_get_arg;
@@ -123,8 +117,7 @@ e_minicard_init (EMinicard *minicard)
minicard->height = 10;
minicard->has_focus = FALSE;
- minicard->model = NULL;
- minicard->row = 0;
+ minicard->card = NULL;
e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard), e_minicard_reflow);
}
@@ -164,21 +157,11 @@ e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
e_canvas_item_grab_focus(item);
break;
case ARG_CARD:
- /* e_minicard->card = GTK_VALUE_OBJECT (*arg);
- _update_card(e_minicard);
- gnome_canvas_item_request_update (item);*/
- break;
- case ARG_MODEL:
- if (e_minicard->model)
- gtk_object_unref (e_minicard->model);
- e_minicard->model = E_TABLE_MODEL(GTK_VALUE_OBJECT (*arg));
- if (e_minicard->model)
- gtk_object_ref (e_minicard->model);
- remodel(e_minicard);
- e_canvas_item_request_reflow(item);
- break;
- case ARG_ROW:
- e_minicard->row = GTK_VALUE_INT (*arg);
+ if (e_minicard->card)
+ gtk_object_unref (GTK_OBJECT(e_minicard->card));
+ e_minicard->card = E_CARD(GTK_VALUE_OBJECT (*arg));
+ if (e_minicard->card)
+ gtk_object_ref (GTK_OBJECT(e_minicard->card));
remodel(e_minicard);
e_canvas_item_request_reflow(item);
break;
@@ -203,13 +186,7 @@ e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_ENUM (*arg) = e_minicard->has_focus ? E_FOCUS_CURRENT : E_FOCUS_NONE;
break;
case ARG_CARD:
- /* GTK_VALUE_OBJECT (*arg) = e_minicard->card; */
- break;
- case ARG_MODEL:
- GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard->model);
- break;
- case ARG_ROW:
- GTK_VALUE_INT (*arg) = e_minicard->row;
+ GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard->card);
break;
default:
arg->type = GTK_TYPE_INVALID;
@@ -227,8 +204,8 @@ e_minicard_destroy (GtkObject *object)
e_minicard = E_MINICARD (object);
- if (e_minicard->model)
- gtk_object_unref (e_minicard->model);
+ if (e_minicard->card)
+ gtk_object_unref (GTK_OBJECT(e_minicard->card));
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
@@ -239,7 +216,6 @@ e_minicard_realize (GnomeCanvasItem *item)
{
EMinicard *e_minicard;
GnomeCanvasGroup *group;
- GnomeCanvasItem *new_item;
e_minicard = E_MINICARD (item);
group = GNOME_CANVAS_GROUP( item );
@@ -276,46 +252,10 @@ e_minicard_realize (GnomeCanvasItem *item)
"use_ellipsis", TRUE,
"font", "lucidasans-bold-10",
"fill_color", "black",
- "text", "Chris Lahey",
+ "text", "",
NULL );
e_canvas_item_move_absolute(e_minicard->header_text, 6, 6);
- new_item = e_minicard_label_new(group);
- gnome_canvas_item_set( new_item,
- "width", e_minicard->width - 4.0,
- "fieldname", "Email:",
- "field", "clahey@address.com",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
- e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
-
- new_item = e_minicard_label_new(group);
- gnome_canvas_item_set( new_item,
- "width", e_minicard->width - 4,
- "fieldname", "Full Name:",
- "field", "Christopher James Lahey",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
- e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
-
- new_item = e_minicard_label_new(group);
- gnome_canvas_item_set( new_item,
- "width", e_minicard->width - 4,
- "fieldname", "Street Address:",
- "field", "100 Main St\nHome town, USA",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
- e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
-
- new_item = e_minicard_label_new(group);
- gnome_canvas_item_set( new_item,
- "width", e_minicard->width - 4,
- "fieldname", "Phone:",
- "field", "000-0000",
- NULL );
- e_minicard->fields = g_list_append( e_minicard->fields, new_item);
- e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
-
remodel(e_minicard);
e_canvas_item_request_reflow(item);
@@ -439,31 +379,92 @@ e_minicard_resize_children( EMinicard *e_minicard )
}
static void
-remodel( EMinicard *e_minicard )
+add_field (EMinicard *e_minicard, char *fieldname, char* field)
{
+ GnomeCanvasItem *new_item;
GnomeCanvasGroup *group;
group = GNOME_CANVAS_GROUP( e_minicard );
- if ( e_minicard->model ) {
- gint column = 0;
- GList *list = e_minicard->fields;
- ETableTextModel *model;
- for ( ; list; list = list->next, column++ ) {
- ETableTextModel *model = e_table_text_model_new(e_minicard->model, e_minicard->row, column);
- gnome_canvas_item_set(GNOME_CANVAS_ITEM(list->data),
- "text_model", model,
- NULL);
- gtk_object_sink(GTK_OBJECT(model));
+ new_item = e_minicard_label_new(group);
+ gnome_canvas_item_set( new_item,
+ "width", e_minicard->width - 4.0,
+ "fieldname", fieldname,
+ "field", field,
+ NULL );
+ e_minicard->fields = g_list_append( e_minicard->fields, new_item);
+ e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
+}
+
+
+static void
+remodel( EMinicard *e_minicard )
+{
+ if (e_minicard->card) {
+ char *fname;
+ ECardList *address_list;
+ ECardList *phone_list;
+ ECardList *email_list;
+
+ ECardIterator *iterator;
+
+ GList *list;
+
+ for ( list = e_minicard->fields; list; list = g_list_next( list ) ) {
+ gtk_object_destroy( GTK_OBJECT( list->data ) );
}
- if ( e_minicard->header_text ) {
- model = e_table_text_model_new(e_minicard->model, e_minicard->row, 1);
- gnome_canvas_item_set(GNOME_CANVAS_ITEM(e_minicard->header_text),
- "model", model,
- NULL);
- gtk_object_sink(GTK_OBJECT(model));
+ g_list_free(e_minicard->fields);
+ e_minicard->fields = NULL;
+
+ gtk_object_get(GTK_OBJECT(e_minicard->card),
+ "full_name", &fname,
+ "address", &address_list,
+ "phone", &phone_list,
+ "email", &email_list,
+ NULL);
+
+ if (fname) {
+ add_field(e_minicard, "Name:", fname);
+ if (e_minicard->header_text)
+ gnome_canvas_item_set(e_minicard->header_text,
+ "text", fname,
+ NULL);
+ } else
+ if (e_minicard->header_text)
+ gnome_canvas_item_set(e_minicard->header_text,
+ "text", "",
+ NULL);
+ if (address_list) {
+ for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
+ const ECardDeliveryAddress *address = e_card_iterator_get(iterator);
+ if (address->flags & ADDR_WORK) {
+ add_field(e_minicard, "Work Address:", address->city);
+ } else if (address->flags & ADDR_HOME) {
+ add_field(e_minicard, "Home Address:", address->city);
+ } else {
+ add_field(e_minicard, "Address:", address->city);
+ }
+ }
+ }
+ if (phone_list) {
+ for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
+ const ECardPhone *phone = e_card_iterator_get(iterator);
+ if (phone->flags & E_CARD_PHONE_WORK) {
+ add_field(e_minicard, "Work Phone:", phone->number);
+ } else if (phone->flags & E_CARD_PHONE_HOME) {
+ add_field(e_minicard, "Home Phone:", phone->number);
+ } else if (phone->flags & E_CARD_PHONE_CELL) {
+ add_field(e_minicard, "Mobile Phone:", phone->number);
+ } else {
+ add_field(e_minicard, "Phone:", phone->number);
+ }
+ }
+ }
+ if (email_list) {
+ for (iterator = e_card_list_get_iterator(email_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
+ add_field(e_minicard, "Email:", (char *) e_card_iterator_get(iterator));
+ }
}
-
}
}
@@ -513,3 +514,38 @@ e_minicard_reflow( GnomeCanvasItem *item, int flags )
e_canvas_item_request_parent_reflow(item);
}
}
+
+char *
+e_minicard_get_card_id (EMinicard *minicard)
+{
+ g_return_val_if_fail(minicard != NULL, NULL);
+ g_return_val_if_fail(E_IS_MINICARD(minicard), NULL);
+
+ if (minicard->card) {
+ return e_card_get_id(minicard->card);
+ } else {
+ return NULL;
+ }
+}
+
+int
+e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2)
+{
+ g_return_val_if_fail(minicard1 != NULL, 0);
+ g_return_val_if_fail(E_IS_MINICARD(minicard1), 0);
+ g_return_val_if_fail(minicard2 != NULL, 0);
+ g_return_val_if_fail(E_IS_MINICARD(minicard2), 0);
+
+ if (minicard1->card && minicard2->card) {
+ char *fname1, *fname2;
+ gtk_object_get(GTK_OBJECT(minicard1->card),
+ "full_name", &fname1,
+ NULL);
+ gtk_object_get(GTK_OBJECT(minicard2->card),
+ "full_name", &fname2,
+ NULL);
+ return strcmp(fname1, fname2);
+ } else {
+ return 0;
+ }
+}
diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h
index 05d95a743e..85481d586e 100644
--- a/addressbook/gui/widgets/e-minicard.h
+++ b/addressbook/gui/widgets/e-minicard.h
@@ -22,7 +22,7 @@
#define __E_MINICARD_H__
#include <gnome.h>
-#include "e-table-model.h"
+#include "e-card.h"
#ifdef __cplusplus
extern "C" {
@@ -37,10 +37,6 @@ extern "C" {
* --------------------------------------------------------------------------------
* width double RW width of the card
* height double R height of the card
- * model ETableModel RW model to read from
- * row int RW ETableModel row to read from
- *
- * Later:
* card ECard* RW Pointer to the ECard
*/
@@ -72,8 +68,7 @@ struct _EMinicard
GnomeCanvasItem *header_text;
GList *fields; /* Of type GnomeCanvasItem. */
- ETableModel *model;
- int row;
+ ECard *card;
guint needs_remodeling : 1;
gboolean has_focus;
@@ -90,7 +85,9 @@ struct _EMinicardClass
};
-GtkType e_minicard_get_type (void);
+GtkType e_minicard_get_type (void);
+char *e_minicard_get_card_id (EMinicard *minicard);
+int e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2);
#ifdef __cplusplus
}
diff --git a/addressbook/gui/widgets/test-minicard-view.c b/addressbook/gui/widgets/test-minicard-view.c
new file mode 100644
index 0000000000..d3ceff228e
--- /dev/null
+++ b/addressbook/gui/widgets/test-minicard-view.c
@@ -0,0 +1,206 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* test-reflow.c
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Author: Chris Lahey <clahey@helixcode.com>
+ *
+ * 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.
+ */
+
+#include "config.h"
+
+#include <gnome.h>
+#include <libgnorba/gnorba.h>
+#include <bonobo.h>
+#include "e-canvas.h"
+#include "e-minicard-view.h"
+
+/* This is a horrible thing to do, but it is just a test. */
+GnomeCanvasItem *reflow;
+GnomeCanvasItem *rect;
+GtkAllocation last_alloc;
+
+CORBA_Environment ev;
+CORBA_ORB orb;
+
+static void
+init_bonobo (int argc, char **argv)
+{
+
+ gnome_CORBA_init_with_popt_table (
+ "Reflow Test", VERSION,
+ &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev);
+
+ orb = gnome_CORBA_ORB ();
+
+ if (bonobo_init (orb, NULL, NULL) == FALSE)
+ g_error (_("Could not initialize Bonobo"));
+
+}
+
+static void destroy_callback(GtkWidget *app, gpointer data)
+{
+ exit(0);
+}
+
+static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
+{
+ double width;
+ last_alloc = *allocation;
+ gnome_canvas_item_set( reflow,
+ "height", (double) allocation->height,
+ NULL );
+ gnome_canvas_item_set( reflow,
+ "minimum_width", (double) allocation->width,
+ NULL );
+ gtk_object_get(GTK_OBJECT(reflow),
+ "width", &width,
+ NULL);
+ width = MAX(width, allocation->width);
+ gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, width, allocation->height );
+ gnome_canvas_item_set( rect,
+ "x2", (double) width,
+ "y2", (double) allocation->height,
+ NULL );
+}
+
+static void resize(GnomeCanvas *canvas, gpointer data)
+{
+ double width;
+ gtk_object_get(GTK_OBJECT(reflow),
+ "width", &width,
+ NULL);
+ width = MAX(width, last_alloc.width);
+ gnome_canvas_set_scroll_region(canvas , 0, 0, width, last_alloc.height );
+ gnome_canvas_item_set( rect,
+ "x2", (double) width,
+ "y2", (double) last_alloc.height,
+ NULL );
+}
+
+#if 0
+static void about_callback( GtkWidget *widget, gpointer data )
+{
+
+ const gchar *authors[] =
+ {
+ "Christopher James Lahey <clahey@umich.edu>",
+ NULL
+ };
+
+ GtkWidget *about =
+ gnome_about_new ( _( "Reflow Test" ), VERSION,
+ _( "Copyright (C) 2000, Helix Code, Inc." ),
+ authors,
+ _( "This should test the reflow canvas item" ),
+ NULL);
+ gtk_widget_show (about);
+}
+#endif
+
+static void
+book_open_cb (EBook *book, EBookStatus status, gpointer closure)
+{
+ if (status == E_BOOK_STATUS_SUCCESS)
+ gnome_canvas_item_set(reflow,
+ "book", book,
+ NULL);
+}
+
+static guint
+ebook_create (void)
+{
+ EBook *book;
+
+ book = e_book_new ();
+
+ if (!book) {
+ printf ("%s: %s(): Couldn't create EBook, bailing.\n",
+ __FILE__,
+ __FUNCTION__);
+ return FALSE;
+ }
+
+
+ if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL)) {
+ printf ("error calling load_uri!\n");
+ }
+
+
+ return FALSE;
+}
+
+int main( int argc, char *argv[] )
+{
+ GtkWidget *app;
+ GtkWidget *canvas;
+ GtkWidget *vbox;
+ GtkWidget *scrollbar;
+
+ /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
+ textdomain (PACKAGE);*/
+
+ CORBA_exception_init (&ev);
+ init_bonobo (argc, argv);
+
+ app = gnome_app_new("Reflow Test", NULL);
+
+ vbox = gtk_vbox_new(FALSE, 0);
+
+ canvas = e_canvas_new();
+ rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
+ gnome_canvas_rect_get_type(),
+ "x1", (double) 0,
+ "y1", (double) 0,
+ "x2", (double) 100,
+ "y2", (double) 100,
+ "fill_color", "white",
+ NULL );
+ reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
+ e_minicard_view_get_type(),
+ "height", (double) 100,
+ "minimum_width", (double) 100,
+ NULL );
+ gtk_signal_connect( GTK_OBJECT( canvas ), "reflow",
+ GTK_SIGNAL_FUNC( resize ),
+ ( gpointer ) app);
+
+ gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
+ 0, 0,
+ 100, 100 );
+
+ gtk_box_pack_start(GTK_BOX(vbox), canvas, TRUE, TRUE, 0);
+
+ scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(canvas)));
+
+ gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0);
+
+ gnome_app_set_contents( GNOME_APP( app ), vbox );
+
+ /* Connect the signals */
+ gtk_signal_connect( GTK_OBJECT( app ), "destroy",
+ GTK_SIGNAL_FUNC( destroy_callback ),
+ ( gpointer ) app );
+
+ gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate",
+ GTK_SIGNAL_FUNC( allocate_callback ),
+ ( gpointer ) app );
+
+ gtk_widget_show_all( app );
+ gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE);
+
+ gtk_idle_add ((GtkFunction) ebook_create, NULL);
+
+ bonobo_main ();
+
+ /* Not reached. */
+ return 0;
+}
diff --git a/addressbook/gui/widgets/test-reflow.c b/addressbook/gui/widgets/test-reflow.c
index 8cedbaac28..64c2b89a37 100644
--- a/addressbook/gui/widgets/test-reflow.c
+++ b/addressbook/gui/widgets/test-reflow.c
@@ -16,6 +16,32 @@
*/
+#define TEST_VCARD \
+"BEGIN:VCARD
+" \
+"FN:Nat
+" \
+"N:Friedman;Nat;D;Mr.
+" \
+"BDAY:1977-08-06
+" \
+"TEL;WORK:617 679 1984
+" \
+"TEL;CELL:123 456 7890
+" \
+"EMAIL;INTERNET:nat@nat.org
+" \
+"EMAIL;INTERNET:nat@helixcode.com
+" \
+"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234;
+" \
+"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA
+" \
+"END:VCARD
+" \
+"
+"
+
#include "config.h"
@@ -127,8 +153,10 @@ int main( int argc, char *argv[] )
for ( i = 0; i < 200; i++ )
{
GnomeCanvasItem *item;
+ ECard *card = e_card_new (TEST_VCARD);
item = gnome_canvas_item_new( GNOME_CANVAS_GROUP(reflow),
e_minicard_get_type(),
+ "card", card,
NULL);
e_reflow_add_item(E_REFLOW(reflow), item);
}