diff options
Diffstat (limited to 'addressbook/backend/ebook/e-card-simple.c')
-rw-r--r-- | addressbook/backend/ebook/e-card-simple.c | 311 |
1 files changed, 136 insertions, 175 deletions
diff --git a/addressbook/backend/ebook/e-card-simple.c b/addressbook/backend/ebook/e-card-simple.c index db008011cd..daab2f211c 100644 --- a/addressbook/backend/ebook/e-card-simple.c +++ b/addressbook/backend/ebook/e-card-simple.c @@ -13,19 +13,19 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <bonobo/bonobo-i18n.h> +#include <gtk/gtkobject.h> +#include <gal/util/e-unicode-i18n.h> #include <gal/util/e-util.h> #include <libversit/vcc.h> #include "e-card-simple.h" -/* Object property IDs */ +/* Object argument IDs */ enum { - PROP_0, - PROP_CARD, + ARG_0, + ARG_CARD, }; -static GObjectClass *parent_class; typedef enum _ECardSimpleInternalType ECardSimpleInternalType; typedef struct _ECardSimpleFieldData ECardSimpleFieldData; @@ -115,9 +115,9 @@ static int field_data_count = sizeof (field_data) / sizeof (field_data[0]); static void e_card_simple_init (ECardSimple *simple); static void e_card_simple_class_init (ECardSimpleClass *klass); -static void e_card_simple_dispose (GObject *object); -static void e_card_simple_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_card_simple_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void e_card_simple_destroy (GtkObject *object); +static void e_card_simple_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); +static void e_card_simple_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); static void fill_in_info(ECardSimple *simple); @@ -208,25 +208,24 @@ char *address_names[] = { * * Return value: The type ID of the &ECardSimple class. **/ -GType +GtkType e_card_simple_get_type (void) { - static GType simple_type = 0; + static GtkType simple_type = 0; if (!simple_type) { - static const GTypeInfo simple_info = { - sizeof (ECardSimpleClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_card_simple_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ + GtkTypeInfo simple_info = { + "ECardSimple", sizeof (ECardSimple), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_card_simple_init, + sizeof (ECardSimpleClass), + (GtkClassInitFunc) e_card_simple_class_init, + (GtkObjectInitFunc) e_card_simple_init, + NULL, /* reserved_1 */ + NULL, /* reserved_2 */ + (GtkClassInitFunc) NULL }; - simple_type = g_type_register_static (G_TYPE_OBJECT, "ECardSimple", &simple_info, 0); + simple_type = gtk_type_unique (gtk_object_get_type (), &simple_info); } return simple_type; @@ -241,10 +240,10 @@ e_card_simple_get_type (void) ECardSimple * e_card_simple_new (ECard *card) { - ECardSimple *simple = g_object_new (E_TYPE_CARD_SIMPLE, NULL); - g_object_set(simple, - "card", card, - NULL); + ECardSimple *simple = E_CARD_SIMPLE(gtk_type_new(e_card_simple_get_type())); + gtk_object_set(GTK_OBJECT(simple), + "card", card, + NULL); return simple; } @@ -320,22 +319,16 @@ e_card_simple_get_vcard_assume_utf8 (ECardSimple *simple) static void e_card_simple_class_init (ECardSimpleClass *klass) { - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS(klass); + GtkObjectClass *object_class; - parent_class = g_type_class_ref (G_TYPE_OBJECT); + object_class = GTK_OBJECT_CLASS(klass); - object_class->dispose = e_card_simple_dispose; - object_class->get_property = e_card_simple_get_property; - object_class->set_property = e_card_simple_set_property; + gtk_object_add_arg_type ("ECardSimple::card", + GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_CARD); - g_object_class_install_property (object_class, PROP_CARD, - g_param_spec_object ("card", - _("ECard"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_CARD, - G_PARAM_READWRITE)); + object_class->destroy = e_card_simple_destroy; + object_class->get_arg = e_card_simple_get_arg; + object_class->set_arg = e_card_simple_set_arg; } /* @@ -343,103 +336,73 @@ e_card_simple_class_init (ECardSimpleClass *klass) */ static void -e_card_simple_dispose (GObject *object) +e_card_simple_destroy (GtkObject *object) { ECardSimple *simple; int i; simple = E_CARD_SIMPLE (object); - if (simple->card) { - g_object_unref(simple->card); - simple->card = NULL; - } - if (simple->temp_fields) { - g_list_foreach(simple->temp_fields, (GFunc) g_free, NULL); - g_list_free(simple->temp_fields); - simple->temp_fields = NULL; - } - - for(i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++) { - if (simple->phone[i]) { - e_card_phone_unref (simple->phone[i]); - simple->phone[i] = NULL; - } - } - for(i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++) { - if (simple->email[i]) { - g_free(simple->email[i]); - simple->email[i] = NULL; - } - } - for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) { - if (simple->address[i]) { - e_card_address_label_unref(simple->address[i]); - simple->address[i] = NULL; - } - } - for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) { - if (simple->delivery[i]) { - e_card_delivery_address_unref(simple->delivery[i]); - simple->delivery[i] = NULL; - } - } + if (simple->card) + gtk_object_unref(GTK_OBJECT(simple->card)); + g_list_foreach(simple->temp_fields, (GFunc) g_free, NULL); + g_list_free(simple->temp_fields); + simple->temp_fields = NULL; - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); + for(i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++) + e_card_phone_unref (simple->phone[i]); + for(i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++) + g_free(simple->email[i]); + for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) + e_card_address_label_unref(simple->address[i]); + for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) + e_card_delivery_address_unref(simple->delivery[i]); } /* Set_arg handler for the simple */ static void -e_card_simple_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +e_card_simple_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) { ECardSimple *simple; simple = E_CARD_SIMPLE (object); - switch (prop_id) { - case PROP_CARD: + switch (arg_id) { + case ARG_CARD: if (simple->card) - g_object_unref(simple->card); + gtk_object_unref(GTK_OBJECT(simple->card)); g_list_foreach(simple->temp_fields, (GFunc) g_free, NULL); g_list_free(simple->temp_fields); simple->temp_fields = NULL; - if (g_value_get_object (value)) - simple->card = E_CARD(g_value_get_object (value)); + if (GTK_VALUE_OBJECT(*arg)) + simple->card = E_CARD(GTK_VALUE_OBJECT(*arg)); else simple->card = NULL; if(simple->card) - g_object_ref(simple->card); + gtk_object_ref(GTK_OBJECT(simple->card)); fill_in_info(simple); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; + return; } } /* Get_arg handler for the simple */ static void -e_card_simple_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +e_card_simple_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) { ECardSimple *simple; simple = E_CARD_SIMPLE (object); - switch (prop_id) { - case PROP_CARD: + switch (arg_id) { + case ARG_CARD: e_card_simple_sync_card(simple); - g_value_set_object (value, simple->card); + GTK_VALUE_OBJECT (*arg) = (GtkObject *) simple->card; break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + arg->type = GTK_TYPE_INVALID; break; } } @@ -481,12 +444,12 @@ fill_in_info(ECardSimple *simple) EIterator *iterator; - g_object_get(card, - "address_label", &address_list, - "address", &delivery_list, - "phone", &phone_list, - "email", &email_list, - NULL); + gtk_object_get(GTK_OBJECT(card), + "address_label", &address_list, + "address", &delivery_list, + "phone", &phone_list, + "email", &email_list, + NULL); for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++) { e_card_phone_unref(simple->phone[i]); simple->phone[i] = NULL; @@ -510,7 +473,7 @@ fill_in_info(ECardSimple *simple) } } } - g_object_unref(iterator); + gtk_object_unref(GTK_OBJECT(iterator)); for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++) { g_free(simple->email[i]); @@ -525,7 +488,7 @@ fill_in_info(ECardSimple *simple) } } } - g_object_unref(iterator); + gtk_object_unref(GTK_OBJECT(iterator)); for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) { e_card_address_label_unref(simple->address[i]); @@ -540,7 +503,7 @@ fill_in_info(ECardSimple *simple) } } } - g_object_unref(iterator); + gtk_object_unref(GTK_OBJECT(iterator)); for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) { e_card_delivery_address_unref(simple->delivery[i]); @@ -555,7 +518,7 @@ fill_in_info(ECardSimple *simple) } } } - g_object_unref(iterator); + gtk_object_unref(GTK_OBJECT(iterator)); e_card_free_empty_lists (card); } } @@ -577,12 +540,12 @@ e_card_simple_sync_card(ECardSimple *simple) EIterator *iterator; - g_object_get(card, - "address_label", &address_list, - "address", &delivery_list, - "phone", &phone_list, - "email", &email_list, - NULL); + gtk_object_get(GTK_OBJECT(card), + "address_label", &address_list, + "address", &delivery_list, + "phone", &phone_list, + "email", &email_list, + NULL); for (iterator = e_list_get_iterator(phone_list); e_iterator_is_valid(iterator); e_iterator_next(iterator) ) { int i; @@ -622,7 +585,7 @@ e_card_simple_sync_card(ECardSimple *simple) } } } - g_object_unref(iterator); + gtk_object_unref(GTK_OBJECT(iterator)); for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++) { if (simple->phone[i]) { simple->phone[i]->flags = phone_correspondences[i]; @@ -648,7 +611,7 @@ e_card_simple_sync_card(ECardSimple *simple) } } } - g_object_unref(iterator); + gtk_object_unref(GTK_OBJECT(iterator)); for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i ++) { if (simple->email[i]) { e_list_append(email_list, simple->email[i]); @@ -677,7 +640,7 @@ e_card_simple_sync_card(ECardSimple *simple) } } } - g_object_unref(iterator); + gtk_object_unref(GTK_OBJECT(iterator)); for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) { if (simple->address[i]) { simple->address[i]->flags &= ~E_CARD_ADDR_MASK; @@ -708,7 +671,7 @@ e_card_simple_sync_card(ECardSimple *simple) } } } - g_object_unref(iterator); + gtk_object_unref(GTK_OBJECT(iterator)); for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) { if (simple->delivery[i]) { simple->delivery[i]->flags &= ~E_CARD_ADDR_MASK; @@ -783,8 +746,6 @@ void e_card_simple_set_delivery_address (ECardSimple *simple { e_card_delivery_address_unref(simple->delivery[id]); simple->delivery[id] = e_card_delivery_address_ref(delivery); - e_card_address_label_unref(simple->address[id]); - simple->address[id] = e_card_delivery_address_to_label(simple->delivery[id]); simple->changed = TRUE; } @@ -809,17 +770,17 @@ char *e_card_simple_get (ECardSimple *simple, switch(type) { case E_CARD_SIMPLE_INTERNAL_TYPE_STRING: if (simple->card) { - g_object_get(simple->card, - field_data[field].ecard_field, &string, - NULL); + gtk_object_get(GTK_OBJECT(simple->card), + field_data[field].ecard_field, &string, + NULL); return g_strdup(string); } else return NULL; case E_CARD_SIMPLE_INTERNAL_TYPE_DATE: if (simple->card) { - g_object_get(simple->card, - field_data[field].ecard_field, &date, - NULL); + gtk_object_get(GTK_OBJECT(simple->card), + field_data[field].ecard_field, &date, + NULL); if (date != NULL) { char buf[26]; struct tm then; @@ -857,9 +818,9 @@ char *e_card_simple_get (ECardSimple *simple, case E_CARD_SIMPLE_INTERNAL_TYPE_BOOL: if (simple->card) { gboolean boole; - g_object_get (simple->card, - field_data[field].ecard_field, &boole, - NULL); + gtk_object_get (GTK_OBJECT (simple->card), + field_data[field].ecard_field, &boole, + NULL); if (boole) return g_strdup("true"); else @@ -873,19 +834,19 @@ char *e_card_simple_get (ECardSimple *simple, if (simple->card) { gboolean is_list; - g_object_get(simple->card, - "file_as", &string, - NULL); + gtk_object_get(GTK_OBJECT(simple->card), + "file_as", &string, + NULL); if (string && *string) return g_strdup(string); - g_object_get(simple->card, - "full_name", &string, - NULL); + gtk_object_get(GTK_OBJECT(simple->card), + "full_name", &string, + NULL); if (string && *string) return g_strdup(string); - g_object_get(simple->card, - "org", &string, - NULL); + gtk_object_get(GTK_OBJECT(simple->card), + "org", &string, + NULL); if (string && *string) return g_strdup(string); is_list = e_card_evolution_list (simple->card); @@ -899,33 +860,33 @@ char *e_card_simple_get (ECardSimple *simple, return NULL; case E_CARD_SIMPLE_FIELD_FAMILY_NAME: if (simple->card) { - g_object_get (simple->card, - "name", &name, - NULL); + gtk_object_get (GTK_OBJECT(simple->card), + "name", &name, + NULL); return g_strdup (name->family); } else return NULL; case E_CARD_SIMPLE_FIELD_GIVEN_NAME: if (simple->card) { - g_object_get (simple->card, - "name", &name, - NULL); + gtk_object_get (GTK_OBJECT(simple->card), + "name", &name, + NULL); return g_strdup (name->given); } else return NULL; case E_CARD_SIMPLE_FIELD_ADDITIONAL_NAME: if (simple->card) { - g_object_get (simple->card, - "name", &name, - NULL); + gtk_object_get (GTK_OBJECT(simple->card), + "name", &name, + NULL); return g_strdup (name->additional); } else return NULL; case E_CARD_SIMPLE_FIELD_NAME_SUFFIX: if (simple->card) { - g_object_get (simple->card, - "name", &name, - NULL); + gtk_object_get (GTK_OBJECT(simple->card), + "name", &name, + NULL); return g_strdup (name->suffix); } else return NULL; @@ -1001,9 +962,9 @@ file_as_get_style (ECardSimple *simple) if (!company) company = g_strdup(""); if (filestring) { - g_object_get (simple->card, - "name", &name, - NULL); + gtk_object_get (GTK_OBJECT (simple->card), + "name", &name, + NULL); if (!name) { goto end; @@ -1039,9 +1000,9 @@ file_as_set_style(ECardSimple *simple, int style) if (!company) company = g_strdup(""); - g_object_get (simple->card, - "name", &name, - NULL); + gtk_object_get (GTK_OBJECT (simple->card), + "name", &name, + NULL); if (name) { string = name_to_style(name, company, style); e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_FILE_AS, string); @@ -1064,17 +1025,17 @@ void e_card_simple_set (ECardSimple *simple, case E_CARD_SIMPLE_FIELD_FULL_NAME: case E_CARD_SIMPLE_FIELD_ORG: style = file_as_get_style(simple); - g_object_set(simple->card, - field_data[field].ecard_field, data, - NULL); + gtk_object_set(GTK_OBJECT(simple->card), + field_data[field].ecard_field, data, + NULL); file_as_set_style(simple, style); break; default: switch(type) { case E_CARD_SIMPLE_INTERNAL_TYPE_STRING: - g_object_set(simple->card, - field_data[field].ecard_field, data, - NULL); + gtk_object_set(GTK_OBJECT(simple->card), + field_data[field].ecard_field, data, + NULL); break; case E_CARD_SIMPLE_INTERNAL_TYPE_DATE: break; /* FIXME!!!! */ @@ -1108,9 +1069,9 @@ void e_card_simple_set (ECardSimple *simple, boole = FALSE; else if (!strcasecmp (data, "false")) boole = FALSE; - g_object_set (simple->card, - field_data[field].ecard_field, boole, - NULL); + gtk_object_set (GTK_OBJECT (simple->card), + field_data[field].ecard_field, boole, + NULL); } break; } @@ -1150,7 +1111,7 @@ const char *e_card_simple_get_ecard_field (ECardSimple *simple, const char *e_card_simple_get_name (ECardSimple *simple, ECardSimpleField field) { - return _(field_data[field].name); + return U_(field_data[field].name); } gboolean @@ -1181,7 +1142,7 @@ e_card_simple_get_allow_newlines (ECardSimple *simple, const char *e_card_simple_get_short_name (ECardSimple *simple, ECardSimpleField field) { - return _(field_data[field].short_name); + return U_(field_data[field].short_name); } void e_card_simple_arbitrary_foreach (ECardSimple *simple, @@ -1191,9 +1152,9 @@ void e_card_simple_arbitrary_foreach (ECardSimple if (simple->card) { EList *list; EIterator *iterator; - g_object_get(simple->card, - "arbitrary", &list, - NULL); + gtk_object_get(GTK_OBJECT(simple->card), + "arbitrary", &list, + NULL); for (iterator = e_list_get_iterator(list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) { const ECardArbitrary *arbitrary = e_iterator_get(iterator); if (callback) @@ -1209,9 +1170,9 @@ const ECardArbitrary *e_card_simple_get_arbitrary (ECardSimple *sim if (simple->card) { EList *list; EIterator *iterator; - g_object_get(simple->card, - "arbitrary", &list, - NULL); + gtk_object_get(GTK_OBJECT(simple->card), + "arbitrary", &list, + NULL); for (iterator = e_list_get_iterator(list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) { const ECardArbitrary *arbitrary = e_iterator_get(iterator); if (!strcasecmp(arbitrary->key, key)) @@ -1234,9 +1195,9 @@ void e_card_simple_set_arbitrary (ECardSimple *sim EIterator *iterator; simple->changed = TRUE; - g_object_get(simple->card, - "arbitrary", &list, - NULL); + gtk_object_get(GTK_OBJECT(simple->card), + "arbitrary", &list, + NULL); for (iterator = e_list_get_iterator(list); e_iterator_is_valid(iterator); e_iterator_next(iterator)) { const ECardArbitrary *arbitrary = e_iterator_get(iterator); if (!strcasecmp(arbitrary->key, key)) { @@ -1263,9 +1224,9 @@ e_card_simple_set_name (ECardSimple *simple, ECardName *name) { int style; style = file_as_get_style(simple); - g_object_set (simple->card, - "name", name, - NULL); + gtk_object_set (GTK_OBJECT (simple->card), + "name", name, + NULL); file_as_set_style(simple, style); } |