aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-06-17 20:36:20 +0800
committerChris Lahey <clahey@src.gnome.org>2000-06-17 20:36:20 +0800
commitdd121f1314510e318e657dfdbffc1ebcc45b9c55 (patch)
tree1c5c0c3f8b6147bb45fb27f9498d37054a854ced /addressbook/gui
parent2b8fb337a57a257e299f5f0c0824975a0f5f6272 (diff)
downloadgsoc2013-evolution-dd121f1314510e318e657dfdbffc1ebcc45b9c55.tar.gz
gsoc2013-evolution-dd121f1314510e318e657dfdbffc1ebcc45b9c55.tar.zst
gsoc2013-evolution-dd121f1314510e318e657dfdbffc1ebcc45b9c55.zip
Made the left column of minicards not get any wider than the widest
2000-06-17 Christopher James Lahey <clahey@helixcode.com> * gui/minicard/e-minicard-label.c, gui/minicard/e-minicard-label.h, gui/minicard/e-minicard.c: Made the left column of minicards not get any wider than the widest possible name. svn path=/trunk/; revision=3608
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/minicard/e-minicard-label.c37
-rw-r--r--addressbook/gui/minicard/e-minicard-label.h1
-rw-r--r--addressbook/gui/minicard/e-minicard.c36
-rw-r--r--addressbook/gui/widgets/e-minicard-label.c37
-rw-r--r--addressbook/gui/widgets/e-minicard-label.h1
-rw-r--r--addressbook/gui/widgets/e-minicard.c36
6 files changed, 130 insertions, 18 deletions
diff --git a/addressbook/gui/minicard/e-minicard-label.c b/addressbook/gui/minicard/e-minicard-label.c
index e0e5c98118..e765a89f21 100644
--- a/addressbook/gui/minicard/e-minicard-label.c
+++ b/addressbook/gui/minicard/e-minicard-label.c
@@ -49,7 +49,8 @@ enum {
ARG_HAS_FOCUS,
ARG_FIELD,
ARG_FIELDNAME,
- ARG_TEXT_MODEL
+ ARG_TEXT_MODEL,
+ ARG_MAX_FIELD_NAME_WIDTH,
};
GtkType
@@ -100,6 +101,8 @@ e_minicard_label_class_init (EMinicardLabelClass *klass)
GTK_ARG_READWRITE, ARG_FIELDNAME);
gtk_object_add_arg_type ("EMinicardLabel::text_model", GTK_TYPE_OBJECT,
GTK_ARG_READWRITE, ARG_TEXT_MODEL);
+ gtk_object_add_arg_type ("EMinicardLabel::max_field_name_length", GTK_TYPE_DOUBLE,
+ GTK_ARG_READWRITE, ARG_MAX_FIELD_NAME_WIDTH);
object_class->set_arg = e_minicard_label_set_arg;
object_class->get_arg = e_minicard_label_get_arg;
@@ -120,6 +123,8 @@ e_minicard_label_init (EMinicardLabel *minicard_label)
minicard_label->fieldname = NULL;
minicard_label->field = NULL;
+ minicard_label->max_field_name_length = -1;
+
e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard_label), e_minicard_label_reflow);
}
@@ -151,6 +156,9 @@ e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_TEXT_MODEL:
gnome_canvas_item_set( e_minicard_label->field, "model", GTK_VALUE_OBJECT (*arg), NULL);
break;
+ case ARG_MAX_FIELD_NAME_WIDTH:
+ e_minicard_label->max_field_name_length = GTK_VALUE_DOUBLE (*arg);
+ break;
}
}
@@ -185,6 +193,9 @@ e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "model", &tempmodel, NULL );
GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(tempmodel);
break;
+ case ARG_MAX_FIELD_NAME_WIDTH:
+ GTK_VALUE_DOUBLE (*arg) = e_minicard_label->max_field_name_length;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -210,8 +221,8 @@ e_minicard_label_construct (GnomeCanvasItem *item)
EMinicardLabel *e_minicard_label;
GnomeCanvasGroup *group;
static GdkFont *font = NULL;
-
- if ( font == NULL ) {
+
+ if (font == NULL) {
font = gdk_font_load("lucidasans-10");
}
@@ -369,11 +380,17 @@ e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event)
static void
e_minicard_label_resize_children(EMinicardLabel *e_minicard_label)
{
+ double left_width;
+ if (e_minicard_label->max_field_name_length != -1 && ((e_minicard_label->width / 2) - 4 > e_minicard_label->max_field_name_length))
+ left_width = e_minicard_label->max_field_name_length;
+ else
+ left_width = e_minicard_label->width / 2 - 4;
+
gnome_canvas_item_set( e_minicard_label->fieldname,
- "clip_width", (double) ( e_minicard_label->width / 2 - 4 ),
+ "clip_width", (double) ( left_width ),
NULL );
gnome_canvas_item_set( e_minicard_label->field,
- "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ),
+ "clip_width", (double) ( e_minicard_label->width - 8 - left_width ),
NULL );
}
@@ -384,6 +401,8 @@ e_minicard_label_reflow(GnomeCanvasItem *item, int flags)
gint old_height;
gdouble text_height;
+ gdouble left_width;
+
old_height = e_minicard_label->height;
gtk_object_get(GTK_OBJECT(e_minicard_label->fieldname),
@@ -405,7 +424,13 @@ e_minicard_label_reflow(GnomeCanvasItem *item, int flags)
"x2", (double) e_minicard_label->width - 1,
"y2", (double) e_minicard_label->height - 1,
NULL );
- e_canvas_item_move_absolute(e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1);
+
+ if (e_minicard_label->max_field_name_length != -1 && ((e_minicard_label->width / 2) - 4 > e_minicard_label->max_field_name_length))
+ left_width = e_minicard_label->max_field_name_length;
+ else
+ left_width = e_minicard_label->width / 2 - 4;
+
+ e_canvas_item_move_absolute(e_minicard_label->field, left_width + 6, 1);
if (old_height != e_minicard_label->height)
e_canvas_item_request_parent_reflow(item);
diff --git a/addressbook/gui/minicard/e-minicard-label.h b/addressbook/gui/minicard/e-minicard-label.h
index 1790414a54..08eb51ee53 100644
--- a/addressbook/gui/minicard/e-minicard-label.h
+++ b/addressbook/gui/minicard/e-minicard-label.h
@@ -57,6 +57,7 @@ struct _EMinicardLabel
/* item specific fields */
double width;
double height;
+ double max_field_name_length;
GnomeCanvasItem *fieldname;
GnomeCanvasItem *field;
GnomeCanvasItem *rect;
diff --git a/addressbook/gui/minicard/e-minicard.c b/addressbook/gui/minicard/e-minicard.c
index 4b7942a9f4..4a73fc8eb4 100644
--- a/addressbook/gui/minicard/e-minicard.c
+++ b/addressbook/gui/minicard/e-minicard.c
@@ -513,7 +513,7 @@ field_changed (EText *text, EMinicard *e_minicard)
}
static void
-add_field (EMinicard *e_minicard, ECardSimpleField field)
+add_field (EMinicard *e_minicard, ECardSimpleField field, gdouble left_width)
{
GnomeCanvasItem *new_item;
GnomeCanvasGroup *group;
@@ -521,7 +521,7 @@ add_field (EMinicard *e_minicard, ECardSimpleField field)
EMinicardField *minicard_field;
char *name;
char *string;
-
+
group = GNOME_CANVAS_GROUP( e_minicard );
type = e_card_simple_type(e_minicard->simple, field);
@@ -533,6 +533,7 @@ add_field (EMinicard *e_minicard, ECardSimpleField field)
"width", e_minicard->width - 4.0,
"fieldname", name,
"field", string,
+ "max_field_name_length", left_width,
NULL );
gtk_signal_connect(GTK_OBJECT(E_MINICARD_LABEL(new_item)->field),
"changed", GTK_SIGNAL_FUNC(field_changed), e_minicard);
@@ -550,6 +551,29 @@ add_field (EMinicard *e_minicard, ECardSimpleField field)
g_free(string);
}
+static gdouble
+get_left_width(EMinicard *e_minicard)
+{
+ gchar *name;
+ ECardSimpleField field;
+ gdouble width = -1;
+ static GdkFont *font = NULL;
+
+ if (font == NULL) {
+ font = gdk_font_load("lucidasans-10");
+ }
+
+ for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST; field++) {
+ gdouble this_width;
+ name = g_strdup_printf("%s:", e_card_simple_get_name(e_minicard->simple, field));
+ this_width = gdk_text_width(font, name, strlen(name));
+ if (width < this_width)
+ width = this_width;
+ g_free(name);
+ }
+ return width;
+}
+
static void
remodel( EMinicard *e_minicard )
{
@@ -558,6 +582,7 @@ remodel( EMinicard *e_minicard )
ECardSimpleField field;
GList *list;
char *file_as;
+ gdouble left_width = -1;
if (e_minicard->header_text) {
file_as = e_card_simple_get(e_minicard->simple, E_CARD_SIMPLE_FIELD_FILE_AS);
@@ -572,6 +597,7 @@ remodel( EMinicard *e_minicard )
for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST && count < 5; field++) {
EMinicardField *minicard_field = NULL;
+
if (list)
minicard_field = list->data;
if (minicard_field && minicard_field->field == field) {
@@ -593,9 +619,13 @@ remodel( EMinicard *e_minicard )
g_free(string);
} else {
char *string;
+ if (left_width == -1) {
+ left_width = get_left_width(e_minicard);
+ }
+
string = e_card_simple_get(e_minicard->simple, field);
if (string && *string) {
- add_field(e_minicard, field);
+ add_field(e_minicard, field, left_width);
count++;
}
g_free(string);
diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c
index e0e5c98118..e765a89f21 100644
--- a/addressbook/gui/widgets/e-minicard-label.c
+++ b/addressbook/gui/widgets/e-minicard-label.c
@@ -49,7 +49,8 @@ enum {
ARG_HAS_FOCUS,
ARG_FIELD,
ARG_FIELDNAME,
- ARG_TEXT_MODEL
+ ARG_TEXT_MODEL,
+ ARG_MAX_FIELD_NAME_WIDTH,
};
GtkType
@@ -100,6 +101,8 @@ e_minicard_label_class_init (EMinicardLabelClass *klass)
GTK_ARG_READWRITE, ARG_FIELDNAME);
gtk_object_add_arg_type ("EMinicardLabel::text_model", GTK_TYPE_OBJECT,
GTK_ARG_READWRITE, ARG_TEXT_MODEL);
+ gtk_object_add_arg_type ("EMinicardLabel::max_field_name_length", GTK_TYPE_DOUBLE,
+ GTK_ARG_READWRITE, ARG_MAX_FIELD_NAME_WIDTH);
object_class->set_arg = e_minicard_label_set_arg;
object_class->get_arg = e_minicard_label_get_arg;
@@ -120,6 +123,8 @@ e_minicard_label_init (EMinicardLabel *minicard_label)
minicard_label->fieldname = NULL;
minicard_label->field = NULL;
+ minicard_label->max_field_name_length = -1;
+
e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard_label), e_minicard_label_reflow);
}
@@ -151,6 +156,9 @@ e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_TEXT_MODEL:
gnome_canvas_item_set( e_minicard_label->field, "model", GTK_VALUE_OBJECT (*arg), NULL);
break;
+ case ARG_MAX_FIELD_NAME_WIDTH:
+ e_minicard_label->max_field_name_length = GTK_VALUE_DOUBLE (*arg);
+ break;
}
}
@@ -185,6 +193,9 @@ e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "model", &tempmodel, NULL );
GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(tempmodel);
break;
+ case ARG_MAX_FIELD_NAME_WIDTH:
+ GTK_VALUE_DOUBLE (*arg) = e_minicard_label->max_field_name_length;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -210,8 +221,8 @@ e_minicard_label_construct (GnomeCanvasItem *item)
EMinicardLabel *e_minicard_label;
GnomeCanvasGroup *group;
static GdkFont *font = NULL;
-
- if ( font == NULL ) {
+
+ if (font == NULL) {
font = gdk_font_load("lucidasans-10");
}
@@ -369,11 +380,17 @@ e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event)
static void
e_minicard_label_resize_children(EMinicardLabel *e_minicard_label)
{
+ double left_width;
+ if (e_minicard_label->max_field_name_length != -1 && ((e_minicard_label->width / 2) - 4 > e_minicard_label->max_field_name_length))
+ left_width = e_minicard_label->max_field_name_length;
+ else
+ left_width = e_minicard_label->width / 2 - 4;
+
gnome_canvas_item_set( e_minicard_label->fieldname,
- "clip_width", (double) ( e_minicard_label->width / 2 - 4 ),
+ "clip_width", (double) ( left_width ),
NULL );
gnome_canvas_item_set( e_minicard_label->field,
- "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ),
+ "clip_width", (double) ( e_minicard_label->width - 8 - left_width ),
NULL );
}
@@ -384,6 +401,8 @@ e_minicard_label_reflow(GnomeCanvasItem *item, int flags)
gint old_height;
gdouble text_height;
+ gdouble left_width;
+
old_height = e_minicard_label->height;
gtk_object_get(GTK_OBJECT(e_minicard_label->fieldname),
@@ -405,7 +424,13 @@ e_minicard_label_reflow(GnomeCanvasItem *item, int flags)
"x2", (double) e_minicard_label->width - 1,
"y2", (double) e_minicard_label->height - 1,
NULL );
- e_canvas_item_move_absolute(e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1);
+
+ if (e_minicard_label->max_field_name_length != -1 && ((e_minicard_label->width / 2) - 4 > e_minicard_label->max_field_name_length))
+ left_width = e_minicard_label->max_field_name_length;
+ else
+ left_width = e_minicard_label->width / 2 - 4;
+
+ e_canvas_item_move_absolute(e_minicard_label->field, left_width + 6, 1);
if (old_height != e_minicard_label->height)
e_canvas_item_request_parent_reflow(item);
diff --git a/addressbook/gui/widgets/e-minicard-label.h b/addressbook/gui/widgets/e-minicard-label.h
index 1790414a54..08eb51ee53 100644
--- a/addressbook/gui/widgets/e-minicard-label.h
+++ b/addressbook/gui/widgets/e-minicard-label.h
@@ -57,6 +57,7 @@ struct _EMinicardLabel
/* item specific fields */
double width;
double height;
+ double max_field_name_length;
GnomeCanvasItem *fieldname;
GnomeCanvasItem *field;
GnomeCanvasItem *rect;
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index 4b7942a9f4..4a73fc8eb4 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -513,7 +513,7 @@ field_changed (EText *text, EMinicard *e_minicard)
}
static void
-add_field (EMinicard *e_minicard, ECardSimpleField field)
+add_field (EMinicard *e_minicard, ECardSimpleField field, gdouble left_width)
{
GnomeCanvasItem *new_item;
GnomeCanvasGroup *group;
@@ -521,7 +521,7 @@ add_field (EMinicard *e_minicard, ECardSimpleField field)
EMinicardField *minicard_field;
char *name;
char *string;
-
+
group = GNOME_CANVAS_GROUP( e_minicard );
type = e_card_simple_type(e_minicard->simple, field);
@@ -533,6 +533,7 @@ add_field (EMinicard *e_minicard, ECardSimpleField field)
"width", e_minicard->width - 4.0,
"fieldname", name,
"field", string,
+ "max_field_name_length", left_width,
NULL );
gtk_signal_connect(GTK_OBJECT(E_MINICARD_LABEL(new_item)->field),
"changed", GTK_SIGNAL_FUNC(field_changed), e_minicard);
@@ -550,6 +551,29 @@ add_field (EMinicard *e_minicard, ECardSimpleField field)
g_free(string);
}
+static gdouble
+get_left_width(EMinicard *e_minicard)
+{
+ gchar *name;
+ ECardSimpleField field;
+ gdouble width = -1;
+ static GdkFont *font = NULL;
+
+ if (font == NULL) {
+ font = gdk_font_load("lucidasans-10");
+ }
+
+ for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST; field++) {
+ gdouble this_width;
+ name = g_strdup_printf("%s:", e_card_simple_get_name(e_minicard->simple, field));
+ this_width = gdk_text_width(font, name, strlen(name));
+ if (width < this_width)
+ width = this_width;
+ g_free(name);
+ }
+ return width;
+}
+
static void
remodel( EMinicard *e_minicard )
{
@@ -558,6 +582,7 @@ remodel( EMinicard *e_minicard )
ECardSimpleField field;
GList *list;
char *file_as;
+ gdouble left_width = -1;
if (e_minicard->header_text) {
file_as = e_card_simple_get(e_minicard->simple, E_CARD_SIMPLE_FIELD_FILE_AS);
@@ -572,6 +597,7 @@ remodel( EMinicard *e_minicard )
for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST && count < 5; field++) {
EMinicardField *minicard_field = NULL;
+
if (list)
minicard_field = list->data;
if (minicard_field && minicard_field->field == field) {
@@ -593,9 +619,13 @@ remodel( EMinicard *e_minicard )
g_free(string);
} else {
char *string;
+ if (left_width == -1) {
+ left_width = get_left_width(e_minicard);
+ }
+
string = e_card_simple_get(e_minicard->simple, field);
if (string && *string) {
- add_field(e_minicard, field);
+ add_field(e_minicard, field, left_width);
count++;
}
g_free(string);