diff options
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/gui/minicard/e-minicard-label.c | 114 | ||||
-rw-r--r-- | addressbook/gui/minicard/e-minicard-label.h | 4 | ||||
-rw-r--r-- | addressbook/gui/minicard/e-minicard.c | 208 | ||||
-rw-r--r-- | addressbook/gui/minicard/e-minicard.h | 28 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-label.c | 114 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-label.h | 4 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard.c | 208 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard.h | 28 |
8 files changed, 492 insertions, 216 deletions
diff --git a/addressbook/gui/minicard/e-minicard-label.c b/addressbook/gui/minicard/e-minicard-label.c index 0b6db4115a..9efdd0ba65 100644 --- a/addressbook/gui/minicard/e-minicard-label.c +++ b/addressbook/gui/minicard/e-minicard-label.c @@ -22,6 +22,7 @@ #include <gnome.h> #include "e-minicard-label.h" +#include "e-text.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); @@ -31,9 +32,17 @@ static void e_minicard_label_realize (GnomeCanvasItem *item); static void e_minicard_label_unrealize (GnomeCanvasItem *item); static void _update_label( EMinicardLabel *minicard_label ); +static void _resize( GtkObject *object, gpointer data ); static GnomeCanvasGroupClass *parent_class = NULL; +enum { + E_MINICARD_LABEL_RESIZE, + E_MINICARD_LABEL_LAST_SIGNAL +}; + +static guint e_minicard_label_signals[E_MINICARD_LABEL_LAST_SIGNAL] = { 0 }; + /* The arguments we take */ enum { ARG_0, @@ -79,14 +88,27 @@ e_minicard_label_class_init (EMinicardLabelClass *klass) parent_class = gtk_type_class (gnome_canvas_group_get_type ()); + e_minicard_label_signals[E_MINICARD_LABEL_RESIZE] = + gtk_signal_new ("resize", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EMinicardLabelClass, resize), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + + + gtk_object_class_add_signals (object_class, e_minicard_label_signals, E_MINICARD_LABEL_LAST_SIGNAL); + 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_ARG_READABLE, 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); + + klass->resize = NULL; object_class->set_arg = e_minicard_label_set_arg; object_class->get_arg = e_minicard_label_get_arg; @@ -126,11 +148,6 @@ e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) _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 ); @@ -214,7 +231,7 @@ e_minicard_label_realize (GnomeCanvasItem *item) "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_height", (double) 1, "clip", TRUE, "use_ellipsis", TRUE, "font", "lucidasans-10", @@ -227,6 +244,11 @@ e_minicard_label_realize (GnomeCanvasItem *item) NULL ); g_free( e_minicard_label->fieldname_text ); } + gtk_signal_connect(GTK_OBJECT(e_minicard_label->fieldname), + "resize", + GTK_SIGNAL_FUNC(_resize), + (gpointer) e_minicard_label); + e_minicard_label->field = gnome_canvas_item_new( group, e_text_get_type(), @@ -234,14 +256,13 @@ e_minicard_label_realize (GnomeCanvasItem *item) "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_height", (double) 1, "clip", TRUE, "use_ellipsis", TRUE, "font", "lucidasans-10", "fill_color", "black", "editable", TRUE, NULL ); - if ( e_minicard_label->field_text ) { gnome_canvas_item_set( e_minicard_label->field, @@ -249,6 +270,14 @@ e_minicard_label_realize (GnomeCanvasItem *item) NULL ); g_free( e_minicard_label->field_text ); } + + gtk_signal_connect(GTK_OBJECT(e_minicard_label->field), + "resize", + GTK_SIGNAL_FUNC(_resize), + (gpointer) e_minicard_label); + + _update_label (e_minicard_label); + if (!item->canvas->aa) { } @@ -309,24 +338,57 @@ e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event) } static void -_update_label( EMinicardLabel *minicard_label ) +_update_label( EMinicardLabel *e_minicard_label ) { - if ( GTK_OBJECT_FLAGS( minicard_label ) & GNOME_CANVAS_ITEM_REALIZED ) + if ( GTK_OBJECT_FLAGS( e_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 ); + gint old_height; + gdouble text_height; + old_height = e_minicard_label->height; + + gtk_object_get(GTK_OBJECT(e_minicard_label->fieldname), + "text_height", &text_height, + NULL); + gnome_canvas_item_set(e_minicard_label->fieldname, + "clip_height", (double) text_height, + NULL); + + e_minicard_label->height = text_height; + + + gtk_object_get(GTK_OBJECT(e_minicard_label->field), + "text_height", &text_height, + NULL); + gnome_canvas_item_set(e_minicard_label->field, + "clip_height", (double) text_height, + NULL); + + if (e_minicard_label->height < text_height) + e_minicard_label->height = text_height; + e_minicard_label->height += 3; + + gnome_canvas_item_set( e_minicard_label->rect, + "x2", (double) e_minicard_label->width - 1, + "y2", (double) e_minicard_label->height - 1, + NULL ); + gnome_canvas_item_set( e_minicard_label->fieldname, + "clip_width", (double) ( e_minicard_label->width / 2 - 4 ), + NULL ); + gnome_canvas_item_set( e_minicard_label->field, + "x", (double) ( e_minicard_label->width / 2 + 2 ), + "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ), + NULL ); + + if (old_height != e_minicard_label->height) + gtk_signal_emit_by_name (GTK_OBJECT (e_minicard_label), "resize"); + } } + + + +static void +_resize( GtkObject *object, gpointer data ) +{ + _update_label(E_MINICARD_LABEL(data)); +} diff --git a/addressbook/gui/minicard/e-minicard-label.h b/addressbook/gui/minicard/e-minicard-label.h index dbf9c3944a..bbaca884ac 100644 --- a/addressbook/gui/minicard/e-minicard-label.h +++ b/addressbook/gui/minicard/e-minicard-label.h @@ -66,7 +66,9 @@ struct _EMinicardLabel struct _EMinicardLabelClass { - GnomeCanvasGroupClass parent_class; + GnomeCanvasGroupClass parent_class; + + void (* resize) (EMinicardLabel *text); }; diff --git a/addressbook/gui/minicard/e-minicard.c b/addressbook/gui/minicard/e-minicard.c index a5602baef4..01c326d568 100644 --- a/addressbook/gui/minicard/e-minicard.c +++ b/addressbook/gui/minicard/e-minicard.c @@ -23,6 +23,7 @@ #include <gnome.h> #include "e-minicard.h" #include "e-minicard-label.h" +#include "e-text.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); @@ -32,9 +33,17 @@ static void e_minicard_realize (GnomeCanvasItem *item); static void e_minicard_unrealize (GnomeCanvasItem *item); static void _update_card ( EMinicard *minicard ); +static void _resize( GtkObject *object, gpointer data ); static GnomeCanvasGroupClass *parent_class = NULL; +enum { + E_MINICARD_RESIZE, + E_MINICARD_LAST_SIGNAL +}; + +static guint e_minicard_signals[E_MINICARD_LAST_SIGNAL] = { 0 }; + /* The arguments we take */ enum { ARG_0, @@ -79,6 +88,17 @@ e_minicard_class_init (EMinicardClass *klass) parent_class = gtk_type_class (gnome_canvas_group_get_type ()); + e_minicard_signals[E_MINICARD_RESIZE] = + gtk_signal_new ("resize", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EMinicardClass, resize), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + + + gtk_object_class_add_signals (object_class, e_minicard_signals, E_MINICARD_LAST_SIGNAL); + 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, @@ -155,9 +175,9 @@ e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) static void e_minicard_realize (GnomeCanvasItem *item) { - double text_height; EMinicard *e_minicard; GnomeCanvasGroup *group; + GnomeCanvasItem *new_item; e_minicard = E_MINICARD (item); group = GNOME_CANVAS_GROUP( item ); @@ -199,54 +219,45 @@ e_minicard_realize (GnomeCanvasItem *item) "text", "Chris Lahey", NULL ); - gtk_object_get( GTK_OBJECT( e_minicard->header_text ), - "text_height", &text_height, - NULL ); + gtk_signal_connect(GTK_OBJECT(e_minicard->header_text), + "resize", + GTK_SIGNAL_FUNC(_resize), + (gpointer) e_minicard); - 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) - { - } + new_item = gnome_canvas_item_new( group, + e_minicard_label_get_type(), + "x", (double) 2, + "y", e_minicard->height, + "width", e_minicard->width - 4, + "fieldname", "Full Name:", + "field", "Christopher James Lahey", + NULL ); + e_minicard->fields = g_list_append( e_minicard->fields, new_item); + + gtk_signal_connect(GTK_OBJECT(new_item), + "resize", + GTK_SIGNAL_FUNC(_resize), + (gpointer) e_minicard); + + new_item = gnome_canvas_item_new( group, + e_minicard_label_get_type(), + "x", (double) 2, + "y", e_minicard->height, + "width", e_minicard->width - 4.0, + "fieldname", "Email:", + "field", "clahey@helixcode.com", + NULL ); + e_minicard->fields = g_list_append( e_minicard->fields, new_item); + + gtk_signal_connect(GTK_OBJECT(new_item), + "resize", + GTK_SIGNAL_FUNC(_resize), + (gpointer) e_minicard); + + _update_card( e_minicard ); + + if (!item->canvas->aa) { + } } static void @@ -302,6 +313,26 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) } } break; + case GDK_KEY_PRESS: + if (event->key.length == 1 && event->key.string[0] == '\t') { + GList *list; + for (list = e_minicard->fields; list; list = list->next) { + EMinicardLabel *label = E_MINICARD_LABEL (list->data); + if (label->field == label->field->canvas->focused_item) { + if (event->key.state & GDK_SHIFT_MASK) + list = list->prev; + else + list = list->next; + if (list) { + label = E_MINICARD_LABEL (list->data); + gnome_canvas_item_grab_focus(label->field); + return 1; + } else { + return 0; + } + } + } + } default: break; } @@ -313,26 +344,67 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) } static void -_update_card( EMinicard *minicard ) +_update_card( EMinicard *e_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 ); - } + if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) { + GList *list; + gdouble text_height; + gint old_height; + + old_height = e_minicard->height; + + 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", (double)text_height, + NULL ); + + for(list = e_minicard->fields; list; list = g_list_next(list)) { + gtk_object_get (GTK_OBJECT(list->data), + "height", &text_height, + NULL); + gnome_canvas_item_set(GNOME_CANVAS_ITEM(list->data), + "y", (double) e_minicard->height, + NULL); + e_minicard->height += text_height; + } + e_minicard->height += 2; + + gnome_canvas_item_set( e_minicard->rect, + "y2", (double) e_minicard->height - 1, + NULL ); + + gnome_canvas_item_set( e_minicard->rect, + "x2", (double) e_minicard->width - 1.0, + "y2", (double) e_minicard->height - 1.0, + NULL ); + gnome_canvas_item_set( e_minicard->header_rect, + "x2", (double) e_minicard->width - 4.0, + NULL ); + gnome_canvas_item_set( e_minicard->header_text, + "clip_width", (double) e_minicard->width - 12, + NULL ); + for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { + gnome_canvas_item_set( GNOME_CANVAS_ITEM( list->data ), + "width", (double) e_minicard->width - 4.0, + NULL ); + + if (old_height != e_minicard->height) + gtk_signal_emit_by_name (GTK_OBJECT (e_minicard), "resize"); + } } } + +static void +_resize( GtkObject *object, gpointer data ) +{ + _update_card(E_MINICARD(data)); +} diff --git a/addressbook/gui/minicard/e-minicard.h b/addressbook/gui/minicard/e-minicard.h index 759cc4ffb7..43e7d8307f 100644 --- a/addressbook/gui/minicard/e-minicard.h +++ b/addressbook/gui/minicard/e-minicard.h @@ -51,23 +51,25 @@ 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; + 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; + GnomeCanvasGroupClass parent_class; + + void (* resize) (EMinicard *text); }; diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c index 0b6db4115a..9efdd0ba65 100644 --- a/addressbook/gui/widgets/e-minicard-label.c +++ b/addressbook/gui/widgets/e-minicard-label.c @@ -22,6 +22,7 @@ #include <gnome.h> #include "e-minicard-label.h" +#include "e-text.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); @@ -31,9 +32,17 @@ static void e_minicard_label_realize (GnomeCanvasItem *item); static void e_minicard_label_unrealize (GnomeCanvasItem *item); static void _update_label( EMinicardLabel *minicard_label ); +static void _resize( GtkObject *object, gpointer data ); static GnomeCanvasGroupClass *parent_class = NULL; +enum { + E_MINICARD_LABEL_RESIZE, + E_MINICARD_LABEL_LAST_SIGNAL +}; + +static guint e_minicard_label_signals[E_MINICARD_LABEL_LAST_SIGNAL] = { 0 }; + /* The arguments we take */ enum { ARG_0, @@ -79,14 +88,27 @@ e_minicard_label_class_init (EMinicardLabelClass *klass) parent_class = gtk_type_class (gnome_canvas_group_get_type ()); + e_minicard_label_signals[E_MINICARD_LABEL_RESIZE] = + gtk_signal_new ("resize", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EMinicardLabelClass, resize), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + + + gtk_object_class_add_signals (object_class, e_minicard_label_signals, E_MINICARD_LABEL_LAST_SIGNAL); + 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_ARG_READABLE, 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); + + klass->resize = NULL; object_class->set_arg = e_minicard_label_set_arg; object_class->get_arg = e_minicard_label_get_arg; @@ -126,11 +148,6 @@ e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) _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 ); @@ -214,7 +231,7 @@ e_minicard_label_realize (GnomeCanvasItem *item) "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_height", (double) 1, "clip", TRUE, "use_ellipsis", TRUE, "font", "lucidasans-10", @@ -227,6 +244,11 @@ e_minicard_label_realize (GnomeCanvasItem *item) NULL ); g_free( e_minicard_label->fieldname_text ); } + gtk_signal_connect(GTK_OBJECT(e_minicard_label->fieldname), + "resize", + GTK_SIGNAL_FUNC(_resize), + (gpointer) e_minicard_label); + e_minicard_label->field = gnome_canvas_item_new( group, e_text_get_type(), @@ -234,14 +256,13 @@ e_minicard_label_realize (GnomeCanvasItem *item) "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_height", (double) 1, "clip", TRUE, "use_ellipsis", TRUE, "font", "lucidasans-10", "fill_color", "black", "editable", TRUE, NULL ); - if ( e_minicard_label->field_text ) { gnome_canvas_item_set( e_minicard_label->field, @@ -249,6 +270,14 @@ e_minicard_label_realize (GnomeCanvasItem *item) NULL ); g_free( e_minicard_label->field_text ); } + + gtk_signal_connect(GTK_OBJECT(e_minicard_label->field), + "resize", + GTK_SIGNAL_FUNC(_resize), + (gpointer) e_minicard_label); + + _update_label (e_minicard_label); + if (!item->canvas->aa) { } @@ -309,24 +338,57 @@ e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event) } static void -_update_label( EMinicardLabel *minicard_label ) +_update_label( EMinicardLabel *e_minicard_label ) { - if ( GTK_OBJECT_FLAGS( minicard_label ) & GNOME_CANVAS_ITEM_REALIZED ) + if ( GTK_OBJECT_FLAGS( e_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 ); + gint old_height; + gdouble text_height; + old_height = e_minicard_label->height; + + gtk_object_get(GTK_OBJECT(e_minicard_label->fieldname), + "text_height", &text_height, + NULL); + gnome_canvas_item_set(e_minicard_label->fieldname, + "clip_height", (double) text_height, + NULL); + + e_minicard_label->height = text_height; + + + gtk_object_get(GTK_OBJECT(e_minicard_label->field), + "text_height", &text_height, + NULL); + gnome_canvas_item_set(e_minicard_label->field, + "clip_height", (double) text_height, + NULL); + + if (e_minicard_label->height < text_height) + e_minicard_label->height = text_height; + e_minicard_label->height += 3; + + gnome_canvas_item_set( e_minicard_label->rect, + "x2", (double) e_minicard_label->width - 1, + "y2", (double) e_minicard_label->height - 1, + NULL ); + gnome_canvas_item_set( e_minicard_label->fieldname, + "clip_width", (double) ( e_minicard_label->width / 2 - 4 ), + NULL ); + gnome_canvas_item_set( e_minicard_label->field, + "x", (double) ( e_minicard_label->width / 2 + 2 ), + "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ), + NULL ); + + if (old_height != e_minicard_label->height) + gtk_signal_emit_by_name (GTK_OBJECT (e_minicard_label), "resize"); + } } + + + +static void +_resize( GtkObject *object, gpointer data ) +{ + _update_label(E_MINICARD_LABEL(data)); +} diff --git a/addressbook/gui/widgets/e-minicard-label.h b/addressbook/gui/widgets/e-minicard-label.h index dbf9c3944a..bbaca884ac 100644 --- a/addressbook/gui/widgets/e-minicard-label.h +++ b/addressbook/gui/widgets/e-minicard-label.h @@ -66,7 +66,9 @@ struct _EMinicardLabel struct _EMinicardLabelClass { - GnomeCanvasGroupClass parent_class; + GnomeCanvasGroupClass parent_class; + + void (* resize) (EMinicardLabel *text); }; diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index a5602baef4..01c326d568 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -23,6 +23,7 @@ #include <gnome.h> #include "e-minicard.h" #include "e-minicard-label.h" +#include "e-text.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); @@ -32,9 +33,17 @@ static void e_minicard_realize (GnomeCanvasItem *item); static void e_minicard_unrealize (GnomeCanvasItem *item); static void _update_card ( EMinicard *minicard ); +static void _resize( GtkObject *object, gpointer data ); static GnomeCanvasGroupClass *parent_class = NULL; +enum { + E_MINICARD_RESIZE, + E_MINICARD_LAST_SIGNAL +}; + +static guint e_minicard_signals[E_MINICARD_LAST_SIGNAL] = { 0 }; + /* The arguments we take */ enum { ARG_0, @@ -79,6 +88,17 @@ e_minicard_class_init (EMinicardClass *klass) parent_class = gtk_type_class (gnome_canvas_group_get_type ()); + e_minicard_signals[E_MINICARD_RESIZE] = + gtk_signal_new ("resize", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EMinicardClass, resize), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + + + gtk_object_class_add_signals (object_class, e_minicard_signals, E_MINICARD_LAST_SIGNAL); + 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, @@ -155,9 +175,9 @@ e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) static void e_minicard_realize (GnomeCanvasItem *item) { - double text_height; EMinicard *e_minicard; GnomeCanvasGroup *group; + GnomeCanvasItem *new_item; e_minicard = E_MINICARD (item); group = GNOME_CANVAS_GROUP( item ); @@ -199,54 +219,45 @@ e_minicard_realize (GnomeCanvasItem *item) "text", "Chris Lahey", NULL ); - gtk_object_get( GTK_OBJECT( e_minicard->header_text ), - "text_height", &text_height, - NULL ); + gtk_signal_connect(GTK_OBJECT(e_minicard->header_text), + "resize", + GTK_SIGNAL_FUNC(_resize), + (gpointer) e_minicard); - 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) - { - } + new_item = gnome_canvas_item_new( group, + e_minicard_label_get_type(), + "x", (double) 2, + "y", e_minicard->height, + "width", e_minicard->width - 4, + "fieldname", "Full Name:", + "field", "Christopher James Lahey", + NULL ); + e_minicard->fields = g_list_append( e_minicard->fields, new_item); + + gtk_signal_connect(GTK_OBJECT(new_item), + "resize", + GTK_SIGNAL_FUNC(_resize), + (gpointer) e_minicard); + + new_item = gnome_canvas_item_new( group, + e_minicard_label_get_type(), + "x", (double) 2, + "y", e_minicard->height, + "width", e_minicard->width - 4.0, + "fieldname", "Email:", + "field", "clahey@helixcode.com", + NULL ); + e_minicard->fields = g_list_append( e_minicard->fields, new_item); + + gtk_signal_connect(GTK_OBJECT(new_item), + "resize", + GTK_SIGNAL_FUNC(_resize), + (gpointer) e_minicard); + + _update_card( e_minicard ); + + if (!item->canvas->aa) { + } } static void @@ -302,6 +313,26 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) } } break; + case GDK_KEY_PRESS: + if (event->key.length == 1 && event->key.string[0] == '\t') { + GList *list; + for (list = e_minicard->fields; list; list = list->next) { + EMinicardLabel *label = E_MINICARD_LABEL (list->data); + if (label->field == label->field->canvas->focused_item) { + if (event->key.state & GDK_SHIFT_MASK) + list = list->prev; + else + list = list->next; + if (list) { + label = E_MINICARD_LABEL (list->data); + gnome_canvas_item_grab_focus(label->field); + return 1; + } else { + return 0; + } + } + } + } default: break; } @@ -313,26 +344,67 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) } static void -_update_card( EMinicard *minicard ) +_update_card( EMinicard *e_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 ); - } + if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) { + GList *list; + gdouble text_height; + gint old_height; + + old_height = e_minicard->height; + + 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", (double)text_height, + NULL ); + + for(list = e_minicard->fields; list; list = g_list_next(list)) { + gtk_object_get (GTK_OBJECT(list->data), + "height", &text_height, + NULL); + gnome_canvas_item_set(GNOME_CANVAS_ITEM(list->data), + "y", (double) e_minicard->height, + NULL); + e_minicard->height += text_height; + } + e_minicard->height += 2; + + gnome_canvas_item_set( e_minicard->rect, + "y2", (double) e_minicard->height - 1, + NULL ); + + gnome_canvas_item_set( e_minicard->rect, + "x2", (double) e_minicard->width - 1.0, + "y2", (double) e_minicard->height - 1.0, + NULL ); + gnome_canvas_item_set( e_minicard->header_rect, + "x2", (double) e_minicard->width - 4.0, + NULL ); + gnome_canvas_item_set( e_minicard->header_text, + "clip_width", (double) e_minicard->width - 12, + NULL ); + for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { + gnome_canvas_item_set( GNOME_CANVAS_ITEM( list->data ), + "width", (double) e_minicard->width - 4.0, + NULL ); + + if (old_height != e_minicard->height) + gtk_signal_emit_by_name (GTK_OBJECT (e_minicard), "resize"); + } } } + +static void +_resize( GtkObject *object, gpointer data ) +{ + _update_card(E_MINICARD(data)); +} diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h index 759cc4ffb7..43e7d8307f 100644 --- a/addressbook/gui/widgets/e-minicard.h +++ b/addressbook/gui/widgets/e-minicard.h @@ -51,23 +51,25 @@ 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; + 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; + GnomeCanvasGroupClass parent_class; + + void (* resize) (EMinicard *text); }; |