aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/widgets')
-rw-r--r--addressbook/gui/widgets/e-minicard-label.c86
-rw-r--r--addressbook/gui/widgets/e-minicard-label.h2
-rw-r--r--addressbook/gui/widgets/e-minicard.c93
-rw-r--r--addressbook/gui/widgets/test-reflow.c8
4 files changed, 59 insertions, 130 deletions
diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c
index 3f6a80a890..25f7f939fc 100644
--- a/addressbook/gui/widgets/e-minicard-label.c
+++ b/addressbook/gui/widgets/e-minicard-label.c
@@ -33,19 +33,12 @@ static void e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_
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 e_minicard_label_reflow(GnomeCanvasItem *item, int flags);
-static void update_label( EMinicardLabel *minicard_label );
-static void resize( GtkObject *object, gpointer data );
+static void e_minicard_label_resize_children( EMinicardLabel *e_minicard_label );
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,
@@ -92,17 +85,6 @@ 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,
@@ -113,8 +95,6 @@ e_minicard_label_class_init (EMinicardLabelClass *klass)
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;
@@ -136,6 +116,8 @@ e_minicard_label_init (EMinicardLabel *minicard_label)
minicard_label->field = NULL;
minicard_label->fieldname_text = NULL;
minicard_label->field_text = NULL;
+
+ e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard_label), e_minicard_label_reflow);
}
static void
@@ -150,8 +132,8 @@ e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
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);
+ e_minicard_label_resize_children(e_minicard_label);
+ e_canvas_item_request_reflow (item);
break;
case ARG_HAS_FOCUS:
if (e_minicard_label->field && (GTK_VALUE_ENUM(*arg) != E_FOCUS_NONE))
@@ -241,7 +223,6 @@ e_minicard_label_realize (GnomeCanvasItem *item)
e_text_get_type(),
"anchor", GTK_ANCHOR_NW,
"clip_width", (double) ( e_minicard_label->width / 2 - 4 ),
- "clip_height", (double) 1,
"clip", TRUE,
"use_ellipsis", TRUE,
"font_gdk", font,
@@ -255,17 +236,12 @@ 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(),
"anchor", GTK_ANCHOR_NW,
"clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ),
- "clip_height", (double) 1,
"clip", TRUE,
"use_ellipsis", TRUE,
"font_gdk", font,
@@ -281,12 +257,7 @@ e_minicard_label_realize (GnomeCanvasItem *item)
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);
+ e_canvas_item_request_reflow(item);
if (!item->canvas->aa)
{
@@ -344,10 +315,11 @@ e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event)
case GDK_MOTION_NOTIFY:
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY: {
+ gboolean return_val;
+#if 0
GnomeCanvasItem *field;
ArtPoint p;
double inv[6], affine[6];
- gboolean return_val;
field = e_minicard_label->field;
art_affine_identity (affine);
@@ -389,7 +361,7 @@ e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event)
default:
break;
}
-
+#endif
gtk_signal_emit_by_name(GTK_OBJECT(e_minicard_label->field), "event", event, &return_val);
return return_val;
break;
@@ -405,8 +377,22 @@ e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event)
}
static void
-update_label( EMinicardLabel *e_minicard_label )
+e_minicard_label_resize_children(EMinicardLabel *e_minicard_label)
{
+ if ( GTK_OBJECT_FLAGS( e_minicard_label ) & GNOME_CANVAS_ITEM_REALIZED ) {
+ 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,
+ "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ),
+ NULL );
+ }
+}
+
+static void
+e_minicard_label_reflow(GnomeCanvasItem *item, int flags)
+{
+ EMinicardLabel *e_minicard_label = E_MINICARD_LABEL(item);
if ( GTK_OBJECT_FLAGS( e_minicard_label ) & GNOME_CANVAS_ITEM_REALIZED )
{
gint old_height;
@@ -416,9 +402,6 @@ update_label( EMinicardLabel *e_minicard_label )
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;
@@ -426,9 +409,6 @@ update_label( EMinicardLabel *e_minicard_label )
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;
@@ -438,24 +418,10 @@ update_label( EMinicardLabel *e_minicard_label )
"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,
- "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ),
- NULL );
e_canvas_item_move_absolute(e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1);
if (old_height != e_minicard_label->height)
- gtk_signal_emit_by_name (GTK_OBJECT (e_minicard_label), "resize");
+ e_canvas_item_request_parent_reflow(item);
}
}
-
-
-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 3311e3c9af..b439c53f9d 100644
--- a/addressbook/gui/widgets/e-minicard-label.h
+++ b/addressbook/gui/widgets/e-minicard-label.h
@@ -69,8 +69,6 @@ struct _EMinicardLabel
struct _EMinicardLabelClass
{
GnomeCanvasGroupClass parent_class;
-
- void (* resize) (EMinicardLabel *text);
};
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index b8d25f5dc6..79668b6507 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -34,19 +34,12 @@ 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 e_minicard_reflow ( GnomeCanvasItem *item, int flags );
-static void _update_card ( EMinicard *minicard );
-static void _resize( GtkObject *object, gpointer data );
+static void e_minicard_resize_children( EMinicard *e_minicard );
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,
@@ -92,17 +85,6 @@ 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,
@@ -131,6 +113,8 @@ e_minicard_init (EMinicard *minicard)
minicard->width = 10;
minicard->height = 10;
minicard->has_focus = FALSE;
+
+ e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard), e_minicard_reflow);
}
static void
@@ -146,8 +130,8 @@ e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_WIDTH:
if (e_minicard->width != GTK_VALUE_DOUBLE (*arg)) {
e_minicard->width = GTK_VALUE_DOUBLE (*arg);
- _update_card(e_minicard);
- gnome_canvas_item_request_update (item);
+ e_minicard_resize_children(e_minicard);
+ e_canvas_item_request_reflow(item);
}
break;
case ARG_HAS_FOCUS:
@@ -237,7 +221,7 @@ e_minicard_realize (GnomeCanvasItem *item)
gnome_canvas_item_new( group,
e_text_get_type(),
"anchor", GTK_ANCHOR_NW,
- "clip_width", (double) ( e_minicard->width - 12 ),
+ "width", (double) ( e_minicard->width - 12 ),
"clip", TRUE,
"use_ellipsis", TRUE,
"font", "lucidasans-bold-10",
@@ -246,10 +230,6 @@ e_minicard_realize (GnomeCanvasItem *item)
NULL );
e_canvas_item_move_absolute(e_minicard->header_text, 6, 6);
- gtk_signal_connect(GTK_OBJECT(e_minicard->header_text),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard);
if ( rand() % 2 ) {
new_item = gnome_canvas_item_new( group,
e_minicard_label_get_type(),
@@ -259,11 +239,6 @@ e_minicard_realize (GnomeCanvasItem *item)
NULL );
e_minicard->fields = g_list_append( e_minicard->fields, new_item);
e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
-
- gtk_signal_connect(GTK_OBJECT(new_item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard);
}
if (rand() % 2) {
@@ -275,11 +250,6 @@ e_minicard_realize (GnomeCanvasItem *item)
NULL );
e_minicard->fields = g_list_append( e_minicard->fields, new_item);
e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
-
- gtk_signal_connect(GTK_OBJECT(new_item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard);
}
if (rand() % 2) {
@@ -291,13 +261,8 @@ e_minicard_realize (GnomeCanvasItem *item)
NULL );
e_minicard->fields = g_list_append( e_minicard->fields, new_item);
e_canvas_item_move_absolute(new_item, 2, e_minicard->height);
-
- gtk_signal_connect(GTK_OBJECT(new_item),
- "resize",
- GTK_SIGNAL_FUNC(_resize),
- (gpointer) e_minicard);
}
- _update_card( e_minicard );
+ e_canvas_item_request_reflow(item);
if (!item->canvas->aa) {
}
@@ -402,8 +367,26 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
}
static void
-_update_card( EMinicard *e_minicard )
+e_minicard_resize_children( EMinicard *e_minicard )
+{
+ if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) {
+ GList *list;
+
+ gnome_canvas_item_set( e_minicard->header_text,
+ "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 );
+ }
+ }
+}
+
+static void
+e_minicard_reflow( GnomeCanvasItem *item, int flags )
{
+ EMinicard *e_minicard = E_MINICARD(item);
if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) {
GList *list;
gdouble text_height;
@@ -421,10 +404,6 @@ _update_card( EMinicard *e_minicard )
"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,
@@ -445,22 +424,8 @@ _update_card( EMinicard *e_minicard )
gnome_canvas_item_set( e_minicard->header_rect,
"x2", (double) e_minicard->width - 3.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));
+ e_canvas_item_request_parent_reflow(item);
+ }
}
diff --git a/addressbook/gui/widgets/test-reflow.c b/addressbook/gui/widgets/test-reflow.c
index 319a3f5626..8cedbaac28 100644
--- a/addressbook/gui/widgets/test-reflow.c
+++ b/addressbook/gui/widgets/test-reflow.c
@@ -55,14 +55,14 @@ static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpoi
NULL );
}
-static void resize(GnomeCanvasItem *item, gpointer data)
+static void resize(GnomeCanvas *canvas, gpointer data)
{
double width;
gtk_object_get(GTK_OBJECT(reflow),
- "width", &width,
+ "width", &width,
NULL);
width = MAX(width, last_alloc.width);
- gnome_canvas_set_scroll_region(item->canvas , 0, 0, width, last_alloc.height );
+ 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,
@@ -121,7 +121,7 @@ int main( int argc, char *argv[] )
"height", (double) 100,
"minimum_width", (double) 100,
NULL );
- gtk_signal_connect( GTK_OBJECT( reflow ), "resize",
+ gtk_signal_connect( GTK_OBJECT( canvas ), "reflow",
GTK_SIGNAL_FUNC( resize ),
( gpointer ) app);
for ( i = 0; i < 200; i++ )