aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets
diff options
context:
space:
mode:
authorChris Lahey <clahey@src.gnome.org>2000-01-10 12:55:48 +0800
committerChris Lahey <clahey@src.gnome.org>2000-01-10 12:55:48 +0800
commitb2a25c6add10c40eb6d369fdf504f2e7d13d2c97 (patch)
tree4b51232a7a23da925a858c7f52cac5d6d977e309 /addressbook/gui/widgets
parent380e084b6b0f856ae70751238fae86fafc9ffdb8 (diff)
downloadgsoc2013-evolution-b2a25c6add10c40eb6d369fdf504f2e7d13d2c97.tar
gsoc2013-evolution-b2a25c6add10c40eb6d369fdf504f2e7d13d2c97.tar.gz
gsoc2013-evolution-b2a25c6add10c40eb6d369fdf504f2e7d13d2c97.tar.bz2
gsoc2013-evolution-b2a25c6add10c40eb6d369fdf504f2e7d13d2c97.tar.lz
gsoc2013-evolution-b2a25c6add10c40eb6d369fdf504f2e7d13d2c97.tar.xz
gsoc2013-evolution-b2a25c6add10c40eb6d369fdf504f2e7d13d2c97.tar.zst
gsoc2013-evolution-b2a25c6add10c40eb6d369fdf504f2e7d13d2c97.zip
Added minicard and text stuff.
* widgets/Makefile.am: Added minicard and text stuff. * widgets/e-minicard.c, widgets/e-minicard.h, widgets/e-minicard-label.c, widgets/e-minicard-label.h: Added canvas items for the minicard view in the contact manager. * widgets/test-minicard.c, widgets/test-minicard-label.c: Tests for the minicard items. * widgets/e-text.h, widgets/e-text.c: New canvas item. Based on GnomeCanvasText. Adds ellipsis capabilities. Used in e-minicard*.[ch]. * widgets/.cvsignore: Added minicard-test and minicard-label-test. svn path=/trunk/; revision=1552
Diffstat (limited to 'addressbook/gui/widgets')
-rw-r--r--addressbook/gui/widgets/e-minicard-label.c331
-rw-r--r--addressbook/gui/widgets/e-minicard-label.h80
-rw-r--r--addressbook/gui/widgets/e-minicard.c338
-rw-r--r--addressbook/gui/widgets/e-minicard.h81
-rw-r--r--addressbook/gui/widgets/test-minicard-label.c125
-rw-r--r--addressbook/gui/widgets/test-minicard.c125
6 files changed, 1080 insertions, 0 deletions
diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c
new file mode 100644
index 0000000000..e3c61ff9bf
--- /dev/null
+++ b/addressbook/gui/widgets/e-minicard-label.c
@@ -0,0 +1,331 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-minicard-label.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 "e-minicard-label.h"
+static void e_minicard_label_init (EMinicardLabel *card);
+static void e_minicard_label_class_init (EMinicardLabelClass *klass);
+static void e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
+static void e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
+static gboolean e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event);
+static void e_minicard_label_realize (GnomeCanvasItem *item);
+static void e_minicard_label_unrealize (GnomeCanvasItem *item);
+
+static void _update_label( EMinicardLabel *minicard_label );
+
+static GnomeCanvasGroupClass *parent_class = NULL;
+
+/* The arguments we take */
+enum {
+ ARG_0,
+ ARG_WIDTH,
+ ARG_HEIGHT,
+ ARG_FIELD,
+ ARG_FIELDNAME
+};
+
+GtkType
+e_minicard_label_get_type (void)
+{
+ static GtkType minicard_label_type = 0;
+
+ if (!minicard_label_type)
+ {
+ static const GtkTypeInfo minicard_label_info =
+ {
+ "EMinicardLabel",
+ sizeof (EMinicardLabel),
+ sizeof (EMinicardLabelClass),
+ (GtkClassInitFunc) e_minicard_label_class_init,
+ (GtkObjectInitFunc) e_minicard_label_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ minicard_label_type = gtk_type_unique (gnome_canvas_group_get_type (), &minicard_label_info);
+ }
+
+ return minicard_label_type;
+}
+
+static void
+e_minicard_label_class_init (EMinicardLabelClass *klass)
+{
+ GtkObjectClass *object_class;
+ GnomeCanvasItemClass *item_class;
+
+ object_class = (GtkObjectClass*) klass;
+ item_class = (GnomeCanvasItemClass *) klass;
+
+ parent_class = gtk_type_class (gnome_canvas_group_get_type ());
+
+ gtk_object_add_arg_type ("EMinicardLabel::width", GTK_TYPE_DOUBLE,
+ GTK_ARG_READWRITE, ARG_WIDTH);
+ gtk_object_add_arg_type ("EMinicardLabel::height", GTK_TYPE_DOUBLE,
+ GTK_ARG_READWRITE, ARG_HEIGHT);
+ gtk_object_add_arg_type ("EMinicardLabel::field", GTK_TYPE_STRING,
+ GTK_ARG_READWRITE, ARG_FIELD);
+ gtk_object_add_arg_type ("EMinicardLabel::fieldname", GTK_TYPE_STRING,
+ GTK_ARG_READWRITE, ARG_FIELDNAME);
+
+ object_class->set_arg = e_minicard_label_set_arg;
+ object_class->get_arg = e_minicard_label_get_arg;
+ /* object_class->destroy = e_minicard_label_destroy; */
+
+ /* GnomeCanvasItem method overrides */
+ item_class->realize = e_minicard_label_realize;
+ item_class->unrealize = e_minicard_label_unrealize;
+ item_class->event = e_minicard_label_event;
+}
+
+static void
+e_minicard_label_init (EMinicardLabel *minicard_label)
+{
+ GnomeCanvasGroup *group = GNOME_CANVAS_GROUP( minicard_label );
+ minicard_label->width = 10;
+ minicard_label->height = 10;
+ minicard_label->rect = NULL;
+ minicard_label->fieldname = NULL;
+ minicard_label->field = NULL;
+ minicard_label->fieldname_text = NULL;
+ minicard_label->field_text = NULL;
+}
+
+static void
+e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
+{
+ GnomeCanvasItem *item;
+ EMinicardLabel *e_minicard_label;
+
+ item = GNOME_CANVAS_ITEM (o);
+ e_minicard_label = E_MINICARD_LABEL (o);
+
+ switch (arg_id){
+ case ARG_WIDTH:
+ e_minicard_label->width = GTK_VALUE_DOUBLE (*arg);
+ _update_label( e_minicard_label );
+ gnome_canvas_item_request_update (item);
+ break;
+ case ARG_HEIGHT:
+ e_minicard_label->height = GTK_VALUE_DOUBLE (*arg);
+ _update_label( e_minicard_label );
+ gnome_canvas_item_request_update (item);
+ break;
+ case ARG_FIELD:
+ if ( e_minicard_label->field )
+ gnome_canvas_item_set( e_minicard_label->field, "text", GTK_VALUE_STRING (*arg), NULL );
+ else
+ e_minicard_label->field_text = g_strdup( GTK_VALUE_STRING (*arg) );
+ break;
+ case ARG_FIELDNAME:
+ if ( e_minicard_label->fieldname )
+ gnome_canvas_item_set( e_minicard_label->fieldname, "text", GTK_VALUE_STRING (*arg), NULL );
+ else
+ e_minicard_label->fieldname_text = g_strdup( GTK_VALUE_STRING (*arg) );
+ break;
+ }
+}
+
+static void
+e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+{
+ EMinicardLabel *e_minicard_label;
+ char *temp;
+
+ e_minicard_label = E_MINICARD_LABEL (object);
+
+ switch (arg_id) {
+ case ARG_WIDTH:
+ GTK_VALUE_DOUBLE (*arg) = e_minicard_label->width;
+ break;
+ case ARG_HEIGHT:
+ GTK_VALUE_DOUBLE (*arg) = e_minicard_label->height;
+ break;
+ case ARG_FIELD:
+ if ( e_minicard_label->field )
+ {
+ gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "text", &temp, NULL );
+ GTK_VALUE_STRING (*arg) = temp;
+ }
+ else
+ GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->field_text );
+ break;
+ case ARG_FIELDNAME:
+ if ( e_minicard_label->fieldname )
+ {
+ gtk_object_get( GTK_OBJECT( e_minicard_label->fieldname ), "text", &temp, NULL );
+ GTK_VALUE_STRING (*arg) = temp;
+ }
+ else
+ GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->fieldname_text );
+ break;
+ default:
+ arg->type = GTK_TYPE_INVALID;
+ break;
+ }
+}
+
+static void
+e_minicard_label_realize (GnomeCanvasItem *item)
+{
+ double ascent, descent;
+ EMinicardLabel *e_minicard_label;
+ GnomeCanvasGroup *group;
+
+ e_minicard_label = E_MINICARD_LABEL (item);
+ group = GNOME_CANVAS_GROUP( item );
+
+ if (GNOME_CANVAS_ITEM_CLASS( parent_class )->realize)
+ (* GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) (item);
+
+ e_minicard_label->rect =
+ gnome_canvas_item_new( group,
+ gnome_canvas_rect_get_type(),
+ "x1", (double) 0,
+ "y1", (double) 0,
+ "x2", (double) e_minicard_label->width - 1,
+ "y2", (double) e_minicard_label->height - 1,
+ "outline_color", NULL,
+ NULL );
+ e_minicard_label->fieldname =
+ gnome_canvas_item_new( group,
+ e_text_get_type(),
+ "x", (double) 2,
+ "y", (double) 1,
+ "anchor", GTK_ANCHOR_NW,
+ "clip_width", (double) ( e_minicard_label->width / 2 - 4 ),
+ "clip_height", (double) ( e_minicard_label->height - 3 ),
+ "clip", TRUE,
+ "use_ellipsis", TRUE,
+ "font", "lucidasans-10",
+ "fill_color", "black",
+ NULL );
+ if ( e_minicard_label->fieldname_text )
+ {
+ gnome_canvas_item_set( e_minicard_label->fieldname,
+ "text", e_minicard_label->fieldname_text,
+ NULL );
+ g_free( e_minicard_label->fieldname_text );
+ }
+ e_minicard_label->field =
+ gnome_canvas_item_new( group,
+ e_text_get_type(),
+ "x", (double) ( e_minicard_label->width / 2 + 2 ),
+ "y", (double) 1,
+ "anchor", GTK_ANCHOR_NW,
+ "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ),
+ "clip_height", (double) ( e_minicard_label->height - 3 ),
+ "clip", TRUE,
+ "use_ellipsis", TRUE,
+ "font", "lucidasans-10",
+ "fill_color", "black",
+ NULL );
+
+ if ( e_minicard_label->field_text )
+ {
+ gnome_canvas_item_set( e_minicard_label->field,
+ "text", e_minicard_label->field_text,
+ NULL );
+ g_free( e_minicard_label->field_text );
+ }
+ if (!item->canvas->aa)
+ {
+ }
+
+}
+
+static void
+e_minicard_label_unrealize (GnomeCanvasItem *item)
+{
+ EMinicardLabel *e_minicard_label;
+
+ e_minicard_label = E_MINICARD_LABEL (item);
+
+ if (!item->canvas->aa)
+ {
+ }
+
+ if (GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize)
+ (* GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) (item);
+}
+
+static gboolean
+e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event)
+{
+ EMinicardLabel *e_minicard_label;
+
+ e_minicard_label = E_MINICARD_LABEL (item);
+
+ switch( event->type )
+ {
+ case GDK_FOCUS_CHANGE:
+ {
+ GdkEventFocus *focus_event = (GdkEventFocus *) event;
+ if ( focus_event->in )
+ {
+ gnome_canvas_item_set( e_minicard_label->rect,
+ "outline_color", "grey50",
+ "fill_color", "grey90",
+ NULL );
+ }
+ else
+ {
+ gnome_canvas_item_set( e_minicard_label->rect,
+ "outline_color", NULL,
+ "fill_color", NULL,
+ NULL );
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event)
+ return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event);
+ else
+ return 0;
+}
+
+static void
+_update_label( EMinicardLabel *minicard_label )
+{
+ if ( GTK_OBJECT_FLAGS( minicard_label ) & GNOME_CANVAS_ITEM_REALIZED )
+ {
+ gnome_canvas_item_set( minicard_label->rect,
+ "x2", (double) minicard_label->width - 1,
+ "y2", (double) minicard_label->height - 1,
+ NULL );
+ gnome_canvas_item_set( minicard_label->fieldname,
+ "clip_width", (double) ( minicard_label->width / 2 - 4 ),
+ "clip_height", (double) ( minicard_label->height - 3 ),
+ "fill_color", "black",
+ NULL );
+ gnome_canvas_item_set( minicard_label->field,
+ "x", (double) ( minicard_label->width / 2 + 2 ),
+ "clip_width", (double) ( ( minicard_label->width + 1 ) / 2 - 4 ),
+ "clip_height", (double) ( minicard_label->height - 3 ),
+ "fill_color", "black",
+ NULL );
+ }
+}
diff --git a/addressbook/gui/widgets/e-minicard-label.h b/addressbook/gui/widgets/e-minicard-label.h
new file mode 100644
index 0000000000..dbf9c3944a
--- /dev/null
+++ b/addressbook/gui/widgets/e-minicard-label.h
@@ -0,0 +1,80 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* e-minicard-label.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_LABEL_H__
+#define __E_MINICARD_LABEL_H__
+
+#include <gnome.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+/* EMinicardLabel - A label doing focus with non-marching ants.
+ *
+ * The following arguments are available:
+ *
+ * name type read/write description
+ * --------------------------------------------------------------------------------
+ * width double RW width of the label
+ * height double R height of the label
+ * field string RW text in the field label
+ * fieldname string RW text in the fieldname label
+ */
+
+#define E_MINICARD_LABEL_TYPE (e_minicard_label_get_type ())
+#define E_MINICARD_LABEL(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_LABEL_TYPE, EMinicardLabel))
+#define E_MINICARD_LABEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_LABEL_TYPE, EMiniCardLabelClass))
+#define E_IS_MINICARD_LABEL(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_LABEL_TYPE))
+#define E_IS_MINICARD_LABEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_LABEL_TYPE))
+
+
+typedef struct _EMinicardLabel EMinicardLabel;
+typedef struct _EMinicardLabelClass EMinicardLabelClass;
+
+struct _EMinicardLabel
+{
+ GnomeCanvasGroup parent;
+
+ /* item specific fields */
+ double width;
+ double height;
+ GnomeCanvasItem *fieldname;
+ GnomeCanvasItem *field;
+ GnomeCanvasItem *rect;
+ char *fieldname_text;
+ char *field_text;
+};
+
+struct _EMinicardLabelClass
+{
+ GnomeCanvasGroupClass parent_class;
+};
+
+
+GtkType e_minicard_label_get_type (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __E_MINICARD_LABEL_H__ */
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
new file mode 100644
index 0000000000..a5602baef4
--- /dev/null
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -0,0 +1,338 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-minicard.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 "e-minicard.h"
+#include "e-minicard-label.h"
+static void e_minicard_init (EMinicard *card);
+static void e_minicard_class_init (EMinicardClass *klass);
+static void e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
+static void e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
+static gboolean e_minicard_event (GnomeCanvasItem *item, GdkEvent *event);
+static void e_minicard_realize (GnomeCanvasItem *item);
+static void e_minicard_unrealize (GnomeCanvasItem *item);
+
+static void _update_card ( EMinicard *minicard );
+
+static GnomeCanvasGroupClass *parent_class = NULL;
+
+/* The arguments we take */
+enum {
+ ARG_0,
+ ARG_WIDTH,
+ ARG_HEIGHT,
+ ARG_CARD
+};
+
+GtkType
+e_minicard_get_type (void)
+{
+ static GtkType minicard_type = 0;
+
+ if (!minicard_type)
+ {
+ static const GtkTypeInfo minicard_info =
+ {
+ "EMinicard",
+ sizeof (EMinicard),
+ sizeof (EMinicardClass),
+ (GtkClassInitFunc) e_minicard_class_init,
+ (GtkObjectInitFunc) e_minicard_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ minicard_type = gtk_type_unique (gnome_canvas_group_get_type (), &minicard_info);
+ }
+
+ return minicard_type;
+}
+
+static void
+e_minicard_class_init (EMinicardClass *klass)
+{
+ GtkObjectClass *object_class;
+ GnomeCanvasItemClass *item_class;
+
+ object_class = (GtkObjectClass*) klass;
+ item_class = (GnomeCanvasItemClass *) klass;
+
+ parent_class = gtk_type_class (gnome_canvas_group_get_type ());
+
+ gtk_object_add_arg_type ("EMinicard::width", GTK_TYPE_DOUBLE,
+ GTK_ARG_READWRITE, ARG_WIDTH);
+ gtk_object_add_arg_type ("EMinicard::height", GTK_TYPE_DOUBLE,
+ GTK_ARG_READABLE, ARG_HEIGHT);
+ gtk_object_add_arg_type ("EMinicard::card", GTK_TYPE_OBJECT,
+ GTK_ARG_READWRITE, ARG_CARD);
+
+ object_class->set_arg = e_minicard_set_arg;
+ object_class->get_arg = e_minicard_get_arg;
+ /* object_class->destroy = e_minicard_destroy; */
+
+ /* GnomeCanvasItem method overrides */
+ item_class->realize = e_minicard_realize;
+ item_class->unrealize = e_minicard_unrealize;
+ item_class->event = e_minicard_event;
+}
+
+static void
+e_minicard_init (EMinicard *minicard)
+{
+ /* minicard->card = NULL;*/
+ minicard->rect = NULL;
+ minicard->fields = NULL;
+ minicard->width = 10;
+ minicard->height = 10;
+}
+
+static void
+e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
+{
+ GnomeCanvasItem *item;
+ EMinicard *e_minicard;
+
+ item = GNOME_CANVAS_ITEM (o);
+ e_minicard = E_MINICARD (o);
+
+ switch (arg_id){
+ case ARG_WIDTH:
+ e_minicard->width = GTK_VALUE_DOUBLE (*arg);
+ _update_card(e_minicard);
+ gnome_canvas_item_request_update (item);
+ break;
+ case ARG_CARD:
+ /* e_minicard->card = GTK_VALUE_POINTER (*arg);
+ _update_card(e_minicard);
+ gnome_canvas_item_request_update (item);*/
+ break;
+ }
+}
+
+static void
+e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+{
+ EMinicard *e_minicard;
+
+ e_minicard = E_MINICARD (object);
+
+ switch (arg_id) {
+ case ARG_WIDTH:
+ GTK_VALUE_DOUBLE (*arg) = e_minicard->width;
+ break;
+ case ARG_HEIGHT:
+ GTK_VALUE_DOUBLE (*arg) = e_minicard->height;
+ break;
+ case ARG_CARD:
+ /* GTK_VALUE_POINTER (*arg) = e_minicard->card; */
+ break;
+ default:
+ arg->type = GTK_TYPE_INVALID;
+ break;
+ }
+}
+
+static void
+e_minicard_realize (GnomeCanvasItem *item)
+{
+ double text_height;
+ EMinicard *e_minicard;
+ GnomeCanvasGroup *group;
+
+ e_minicard = E_MINICARD (item);
+ group = GNOME_CANVAS_GROUP( item );
+
+ if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize)
+ (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item);
+
+ e_minicard->rect =
+ gnome_canvas_item_new( group,
+ gnome_canvas_rect_get_type(),
+ "x1", (double) 0,
+ "y1", (double) 0,
+ "x2", (double) e_minicard->width - 1,
+ "y2", (double) e_minicard->height - 1,
+ "outline_color", NULL,
+ NULL );
+
+ e_minicard->header_rect =
+ gnome_canvas_item_new( group,
+ gnome_canvas_rect_get_type(),
+ "x1", (double) 2,
+ "y1", (double) 2,
+ "x2", (double) e_minicard->width - 3,
+ "y2", (double) e_minicard->height - 3,
+ "fill_color", "grey70",
+ NULL );
+
+ e_minicard->header_text =
+ gnome_canvas_item_new( group,
+ e_text_get_type(),
+ "x", (double) 6,
+ "y", (double) 6,
+ "anchor", GTK_ANCHOR_NW,
+ "clip_width", (double) ( e_minicard->width - 12 ),
+ "clip", TRUE,
+ "use_ellipsis", TRUE,
+ "font", "lucidasans-bold-10",
+ "fill_color", "black",
+ "text", "Chris Lahey",
+ NULL );
+
+ gtk_object_get( GTK_OBJECT( e_minicard->header_text ),
+ "text_height", &text_height,
+ NULL );
+
+ e_minicard->height = text_height + 12.0;
+
+ gnome_canvas_item_set( e_minicard->header_rect,
+ "y2", text_height + 9.0,
+ NULL );
+
+ gnome_canvas_item_set( e_minicard->header_text,
+ "clip_height", text_height,
+ NULL );
+
+ e_minicard->fields =
+ g_list_append( e_minicard->fields,
+ gnome_canvas_item_new( group,
+ e_minicard_label_get_type(),
+ "x", (double) 2,
+ "y", e_minicard->height,
+ "width", e_minicard->width - 4,
+ "height", text_height + 3,
+ "fieldname", "Full Name:",
+ "field", "Christopher James Lahey",
+ NULL ) );
+ e_minicard->height += text_height + 3;
+
+ e_minicard->fields =
+ g_list_append( e_minicard->fields,
+ gnome_canvas_item_new( group,
+ e_minicard_label_get_type(),
+ "x", (double) 2,
+ "y", e_minicard->height,
+ "width", e_minicard->width - 4.0,
+ "height", text_height + 3.0,
+ "fieldname", "Email:",
+ "field", "clahey@helixcode.com",
+ NULL ) );
+ e_minicard->height += text_height + 3;
+ e_minicard->height += 2;
+
+ gnome_canvas_item_set( e_minicard->rect,
+ "y2", e_minicard->height - 1,
+ NULL );
+
+ if (!item->canvas->aa)
+ {
+ }
+}
+
+static void
+e_minicard_unrealize (GnomeCanvasItem *item)
+{
+ EMinicard *e_minicard;
+
+ e_minicard = E_MINICARD (item);
+
+ if (!item->canvas->aa)
+ {
+ }
+
+ if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize)
+ (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item);
+}
+
+static gboolean
+e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
+{
+ EMinicard *e_minicard;
+
+ e_minicard = E_MINICARD (item);
+
+ switch( event->type )
+ {
+ case GDK_FOCUS_CHANGE:
+ {
+ GdkEventFocus *focus_event = (GdkEventFocus *) event;
+ if ( focus_event->in )
+ {
+ gnome_canvas_item_set( e_minicard->rect,
+ "outline_color", "grey50",
+ NULL );
+ gnome_canvas_item_set( e_minicard->header_rect,
+ "fill_color", "darkblue",
+ NULL );
+ gnome_canvas_item_set( e_minicard->header_text,
+ "fill_color", "white",
+ NULL );
+ }
+ else
+ {
+ gnome_canvas_item_set( e_minicard->rect,
+ "outline_color", NULL,
+ NULL );
+ gnome_canvas_item_set( e_minicard->header_rect,
+ "fill_color", "grey50",
+ NULL );
+ gnome_canvas_item_set( e_minicard->header_text,
+ "fill_color", "black",
+ NULL );
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event)
+ return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event);
+ else
+ return 0;
+}
+
+static void
+_update_card( EMinicard *minicard )
+{
+ if ( GTK_OBJECT_FLAGS( minicard ) & GNOME_CANVAS_ITEM_REALIZED )
+ {
+ GList *field;
+ gnome_canvas_item_set( minicard->rect,
+ "x2", (double) minicard->width - 1.0,
+ "y2", (double) minicard->height - 1.0,
+ NULL );
+ gnome_canvas_item_set( minicard->header_rect,
+ "x2", (double) minicard->width - 4.0,
+ NULL );
+ gnome_canvas_item_set( minicard->header_text,
+ "clip_width", (double) minicard->width - 12,
+ NULL );
+ for ( field = minicard->fields; field; field = g_list_next( field ) )
+ {
+ gnome_canvas_item_set( GNOME_CANVAS_ITEM( field->data ),
+ "width", minicard->width - 4.0,
+ NULL );
+ }
+ }
+}
diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h
new file mode 100644
index 0000000000..759cc4ffb7
--- /dev/null
+++ b/addressbook/gui/widgets/e-minicard.h
@@ -0,0 +1,81 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* e-minicard.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_H__
+#define __E_MINICARD_H__
+
+#include <gnome.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+/* EMinicard - A small card displaying information about a contact.
+ *
+ * The following arguments are available:
+ *
+ * name type read/write description
+ * --------------------------------------------------------------------------------
+ * width double RW width of the card
+ * height double R height of the card
+ * card ECard* RW Pointer to the ECard
+ */
+
+#define E_MINICARD_TYPE (e_minicard_get_type ())
+#define E_MINICARD(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_TYPE, EMinicard))
+#define E_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_TYPE, EMinicardClass))
+#define E_IS_MINICARD(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_TYPE))
+#define E_IS_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_TYPE))
+
+
+typedef struct _EMinicard EMinicard;
+typedef struct _EMinicardClass EMinicardClass;
+
+struct _EMinicard
+{
+ GnomeCanvasGroup parent;
+
+ /* item specific fields */
+ /* ECard *card; */
+
+ GnomeCanvasItem *rect;
+ GnomeCanvasItem *header_rect;
+ GnomeCanvasItem *header_text;
+ GList *fields; /* Of type GnomeCanvasItem. */
+
+ double width;
+ double height;
+};
+
+struct _EMinicardClass
+{
+ GnomeCanvasGroupClass parent_class;
+};
+
+
+GtkType e_minicard_get_type (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __E_MINICARD_H__ */
diff --git a/addressbook/gui/widgets/test-minicard-label.c b/addressbook/gui/widgets/test-minicard-label.c
new file mode 100644
index 0000000000..67c17a0ace
--- /dev/null
+++ b/addressbook/gui/widgets/test-minicard-label.c
@@ -0,0 +1,125 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* test-minicard-label.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 "e-minicard-label.h"
+
+/* This is a horrible thing to do, but it is just a test. */
+GnomeCanvasItem *label;
+GnomeCanvasItem *rect;
+
+static void destroy_callback(GtkWidget *app, gpointer data)
+{
+ exit(0);
+}
+
+static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
+{
+ gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height );
+ gnome_canvas_item_set( label,
+ "width", (double) allocation->width,
+ "height", (double) allocation->height,
+ NULL );
+ gnome_canvas_item_set( rect,
+ "x2", (double) allocation->width,
+ "y2", (double) allocation->height,
+ NULL );
+}
+
+static void about_callback( GtkWidget *widget, gpointer data )
+{
+
+ const gchar *authors[] =
+ {
+ "Christopher James Lahey <clahey@umich.edu>",
+ NULL
+ };
+
+ GtkWidget *about =
+ gnome_about_new ( _( "Minicard Label Test" ), VERSION,
+ _( "Copyright (C) 2000, Helix Code, Inc." ),
+ authors,
+ _( "This should test the minicard label canvas item" ),
+ NULL);
+ gtk_widget_show (about);
+}
+
+static void button_press_callback( GtkWidget *widget, gpointer data )
+{
+ gnome_canvas_item_grab_focus( label );
+}
+
+int main( int argc, char *argv[] )
+{
+ GtkWidget *app;
+ GtkWidget *canvas;
+
+ /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
+ textdomain (PACKAGE);*/
+
+ gnome_init( "Minicard Label Test", VERSION, argc, argv);
+ app = gnome_app_new("Minicard Label Test", NULL);
+
+ canvas = gnome_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 );
+ label = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
+ e_minicard_label_get_type(),
+ "x", (double) 0,
+ "y", (double) 0,
+ "width", (double) 100,
+ "height", (double) 100,
+ "fieldname", "Full Name:",
+ "field", "Christopher James Lahey",
+ NULL );
+ gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
+ 0, 0,
+ 100, 100 );
+
+ gnome_app_set_contents( GNOME_APP( app ), canvas );
+
+
+ /* 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_signal_connect( GTK_OBJECT( canvas ), "button_press_event",
+ GTK_SIGNAL_FUNC( button_press_callback ),
+ ( gpointer ) app );
+
+ gtk_widget_show_all( app );
+
+ gtk_main();
+
+ /* Not reached. */
+ return 0;
+}
diff --git a/addressbook/gui/widgets/test-minicard.c b/addressbook/gui/widgets/test-minicard.c
new file mode 100644
index 0000000000..4f56fbe936
--- /dev/null
+++ b/addressbook/gui/widgets/test-minicard.c
@@ -0,0 +1,125 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* test-minicard.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 "e-minicard.h"
+
+/* This is a horrible thing to do, but it is just a test. */
+GnomeCanvasItem *card;
+GnomeCanvasItem *rect;
+
+static void destroy_callback(GtkWidget *app, gpointer data)
+{
+ exit(0);
+}
+
+static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
+{
+ gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height );
+ gnome_canvas_item_set( card,
+ "width", (double) allocation->width,
+ NULL );
+ gnome_canvas_item_set( rect,
+ "x2", (double) allocation->width,
+ "y2", (double) allocation->height,
+ NULL );
+}
+
+static void about_callback( GtkWidget *widget, gpointer data )
+{
+
+ const gchar *authors[] =
+ {
+ "Christopher James Lahey <clahey@umich.edu>",
+ NULL
+ };
+
+ GtkWidget *about =
+ gnome_about_new ( _( "Minicard Test" ), VERSION,
+ _( "Copyright (C) 2000, Helix Code, Inc." ),
+ authors,
+ _( "This should test the minicard canvas item" ),
+ NULL);
+ gtk_widget_show (about);
+}
+
+static void button_press_callback( GtkWidget *widget, gpointer data )
+{
+ gnome_canvas_item_grab_focus( card );
+}
+
+int main( int argc, char *argv[] )
+{
+ GtkWidget *app;
+ GtkWidget *canvas;
+ int i;
+
+ /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
+ textdomain (PACKAGE);*/
+
+ gnome_init( "Minicard Test", VERSION, argc, argv);
+ app = gnome_app_new("Minicard Test", NULL);
+
+ canvas = gnome_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 );
+ for ( i = 0; i < 1; i++ )
+ {
+ card = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
+ e_minicard_get_type(),
+ "x", (double) 0,
+ "y", (double) 0,
+ "width", (double) 100,
+ NULL );
+ }
+ gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
+ 0, 0,
+ 100, 100 );
+
+ gnome_app_set_contents( GNOME_APP( app ), canvas );
+
+
+ /* 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_signal_connect( GTK_OBJECT( canvas ), "button_press_event",
+ GTK_SIGNAL_FUNC( button_press_callback ),
+ ( gpointer ) app );
+
+ gtk_widget_show_all( app );
+
+ gtk_main();
+
+ /* Not reached. */
+ return 0;
+}