diff options
This commit was manufactured by cvs2svn to create tagEVOLUTION_1_2_4
'EVOLUTION_1_2_4'.
svn path=/tags/EVOLUTION_1_2_4/; revision=20614
Diffstat (limited to 'calendar/gui/calendar-model.c')
-rw-r--r-- | calendar/gui/calendar-model.c | 135 |
1 files changed, 81 insertions, 54 deletions
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c index d4b5185351..910d72fa17 100644 --- a/calendar/gui/calendar-model.c +++ b/calendar/gui/calendar-model.c @@ -29,7 +29,7 @@ #include <ctype.h> #include <libgnomeui/gnome-messagebox.h> -#include <libgnomeui/gnome-stock-icons.h> +#include <libgnomeui/gnome-stock.h> #include <libgnome/gnome-i18n.h> #include <gal/widgets/e-unicode.h> #include <e-util/e-time-utils.h> @@ -97,7 +97,7 @@ struct _CalendarModelPrivate { gchar *default_category; /* Addresses for determining icons */ - EAccountList *accounts; + GList *addresses; /* The current timezone. */ icaltimezone *zone; @@ -113,7 +113,7 @@ struct _CalendarModelPrivate { static void calendar_model_class_init (CalendarModelClass *class); static void calendar_model_init (CalendarModel *model); -static void calendar_model_finalize (GObject *object); +static void calendar_model_destroy (GtkObject *object); static int calendar_model_column_count (ETableModel *etm); static int calendar_model_row_count (ETableModel *etm); @@ -144,23 +144,42 @@ static ETableModelClass *parent_class; * * Return value: The type ID of the #CalendarModel class. **/ +GtkType +calendar_model_get_type (void) +{ + static GtkType calendar_model_type = 0; + + if (!calendar_model_type) { + static GtkTypeInfo calendar_model_info = { + "CalendarModel", + sizeof (CalendarModel), + sizeof (CalendarModelClass), + (GtkClassInitFunc) calendar_model_class_init, + (GtkObjectInitFunc) calendar_model_init, + NULL, /* reserved_1 */ + NULL, /* reserved_2 */ + (GtkClassInitFunc) NULL + }; + + calendar_model_type = gtk_type_unique (E_TABLE_MODEL_TYPE, &calendar_model_info); + } -E_MAKE_TYPE (calendar_model, "CalendarModel", CalendarModel, calendar_model_class_init, - calendar_model_init, E_TABLE_MODEL_TYPE); + return calendar_model_type; +} /* Class initialization function for the calendar table model */ static void calendar_model_class_init (CalendarModelClass *class) { - GObjectClass *object_class; + GtkObjectClass *object_class; ETableModelClass *etm_class; - object_class = (GObjectClass *) class; + object_class = (GtkObjectClass *) class; etm_class = (ETableModelClass *) class; - parent_class = g_type_class_peek_parent (class); + parent_class = gtk_type_class (E_TABLE_MODEL_TYPE); - object_class->finalize = calendar_model_finalize; + object_class->destroy = calendar_model_destroy; etm_class->column_count = calendar_model_column_count; etm_class->row_count = calendar_model_row_count; @@ -215,7 +234,7 @@ calendar_model_init (CalendarModel *model) priv->timeout_id = g_timeout_add (CALENDAR_MODEL_REFRESH_TIMEOUT, calendar_model_timeout_cb, model); - priv->accounts = itip_addresses_get (); + priv->addresses = itip_addresses_get (); priv->zone = NULL; @@ -276,7 +295,7 @@ free_objects (CalendarModel *model) comp = g_array_index (priv->objects, CalComponent *, i); g_assert (comp != NULL); - g_object_unref (comp); + gtk_object_unref (GTK_OBJECT (comp)); object_data = &g_array_index (priv->objects_data, CalendarModelObjectData, i); @@ -289,7 +308,7 @@ free_objects (CalendarModel *model) /* Destroy handler for the calendar table model */ static void -calendar_model_finalize (GObject *object) +calendar_model_destroy (GtkObject *object) { CalendarModel *model; CalendarModelPrivate *priv; @@ -308,8 +327,8 @@ calendar_model_finalize (GObject *object) /* Free the calendar client interface object */ if (priv->client) { - g_signal_handlers_disconnect_matched (priv->client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, model); - g_object_unref (priv->client); + gtk_signal_disconnect_by_data (GTK_OBJECT (priv->client), model); + gtk_object_unref (GTK_OBJECT (priv->client)); priv->client = NULL; } @@ -319,9 +338,8 @@ calendar_model_finalize (GObject *object) } if (priv->query) { - g_signal_handlers_disconnect_matched (priv->query, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, model); - g_object_unref (priv->query); + gtk_signal_disconnect_by_data (GTK_OBJECT (priv->query), model); + gtk_object_unref (GTK_OBJECT (priv->query)); priv->query = NULL; } @@ -340,8 +358,10 @@ calendar_model_finalize (GObject *object) g_free (priv->default_category); + itip_addresses_free (priv->addresses); + if (priv->activity) { - g_object_unref (priv->activity); + gtk_object_unref (GTK_OBJECT (priv->activity)); priv->activity = NULL; } @@ -350,8 +370,8 @@ calendar_model_finalize (GObject *object) g_free (priv); model->priv = NULL; - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -826,6 +846,7 @@ calendar_model_value_at (ETableModel *etm, int col, int row) case CAL_COMPONENT_FIELD_ICON: { + ItipAddress *ia; GSList *attendees = NULL, *sl; gint retval = 0; @@ -839,17 +860,23 @@ calendar_model_value_at (ETableModel *etm, int col, int row) for (sl = attendees; sl != NULL; sl = sl->next) { CalComponentAttendee *ca = sl->data; const char *text; + GList *l; text = itip_strip_mailto (ca->value); - if (e_account_list_find(priv->accounts, E_ACCOUNT_FIND_ID_ADDRESS, text) != NULL) { - if (ca->delto != NULL) - retval = 3; - else - retval = 2; - break; + for (l = priv->addresses; l != NULL; l = l->next) { + ia = l->data; + + if (!strcmp (text, ia->address)) { + if (ca->delto != NULL) + retval = 3; + else + retval = 2; + goto cleanup; + } } } + cleanup: cal_component_free_attendee_list (attendees); return GINT_TO_POINTER (retval); break; @@ -1394,7 +1421,7 @@ calendar_model_append_row (ETableModel *etm, ETableModel *source, gint row) g_message ("calendar_model_append_row(): Could not add new object!"); } - g_object_unref (comp); + gtk_object_unref (GTK_OBJECT (comp)); } /* Duplicates a string value */ @@ -1460,7 +1487,7 @@ calendar_model_duplicate_value (ETableModel *etm, int col, const void *value) CalComponent *comp; comp = CAL_COMPONENT (value); - g_object_ref (comp); + gtk_object_ref (GTK_OBJECT (comp)); return comp; } @@ -1516,7 +1543,7 @@ calendar_model_free_value (ETableModel *etm, int col, void *value) case CAL_COMPONENT_FIELD_COMPONENT: if (value) - g_object_unref (value); + gtk_object_unref (GTK_OBJECT (value)); break; default: @@ -1670,7 +1697,7 @@ date_value_to_string (ETableModel *etm, const void *value) e_time_format_date_and_time (&tmp_tm, priv->use_24_hour_format, TRUE, FALSE, buffer, sizeof (buffer)); - return g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL); + return e_utf8_from_locale_string (buffer); } @@ -1698,17 +1725,17 @@ calendar_model_value_to_string (ETableModel *etm, int col, const void *value) case CAL_COMPONENT_FIELD_ICON: if (GPOINTER_TO_INT (value) == 0) - return g_locale_to_utf8 (_("Normal"), -1, NULL, NULL, NULL); + return e_utf8_from_locale_string (_("Normal")); else if (GPOINTER_TO_INT (value) == 1) - return g_locale_to_utf8 (_("Recurring"), -1, NULL, NULL, NULL); + return e_utf8_from_locale_string (_("Recurring")); else - return g_locale_to_utf8 (_("Assigned"), -1, NULL, NULL, NULL); + return e_utf8_from_locale_string (_("Assigned")); case CAL_COMPONENT_FIELD_HAS_ALARMS: case CAL_COMPONENT_FIELD_COMPLETE: case CAL_COMPONENT_FIELD_RECURRING: case CAL_COMPONENT_FIELD_OVERDUE: - return g_locale_to_utf8 (value ? _("Yes") : _("No"), -1, NULL, NULL, NULL); + return e_utf8_from_locale_string (value ? _("Yes") : _("No")); case CAL_COMPONENT_FIELD_COLOR: return NULL; @@ -1741,7 +1768,7 @@ calendar_model_value_to_string (ETableModel *etm, int col, const void *value) CalendarModel * calendar_model_new (void) { - return CALENDAR_MODEL (g_object_new (TYPE_CALENDAR_MODEL, NULL)); + return CALENDAR_MODEL (gtk_type_new (TYPE_CALENDAR_MODEL)); } @@ -1964,9 +1991,8 @@ update_query (CalendarModel *model) priv->query = NULL; if (old_query) { - g_signal_handlers_disconnect_matched (old_query, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, model); - g_object_unref (old_query); + gtk_signal_disconnect_by_data (GTK_OBJECT (old_query), model); + gtk_object_unref (GTK_OBJECT (old_query)); } g_assert (priv->sexp != NULL); @@ -1982,14 +2008,14 @@ update_query (CalendarModel *model) return; } - g_signal_connect (priv->query, "obj_updated", - G_CALLBACK (query_obj_updated_cb), model); - g_signal_connect (priv->query, "obj_removed", - G_CALLBACK (query_obj_removed_cb), model); - g_signal_connect (priv->query, "query_done", - G_CALLBACK (query_query_done_cb), model); - g_signal_connect (priv->query, "eval_error", - G_CALLBACK (query_eval_error_cb), model); + gtk_signal_connect (GTK_OBJECT (priv->query), "obj_updated", + GTK_SIGNAL_FUNC (query_obj_updated_cb), model); + gtk_signal_connect (GTK_OBJECT (priv->query), "obj_removed", + GTK_SIGNAL_FUNC (query_obj_removed_cb), model); + gtk_signal_connect (GTK_OBJECT (priv->query), "query_done", + GTK_SIGNAL_FUNC (query_query_done_cb), model); + gtk_signal_connect (GTK_OBJECT (priv->query), "eval_error", + GTK_SIGNAL_FUNC (query_eval_error_cb), model); } /* Callback used when a calendar is opened into the server */ @@ -2061,7 +2087,7 @@ remove_object (CalendarModel *model, const char *uid) calendar_model_free_object_data (model, object_data); g_array_remove_index (priv->objects_data, *idx); - g_object_unref (orig_comp); + gtk_object_unref (GTK_OBJECT (orig_comp)); n = *idx; g_free (idx); @@ -2085,7 +2111,7 @@ calendar_model_set_status_message (CalendarModel *model, const char *message) if (!message || !*message) { if (priv->activity) { - g_object_unref (priv->activity); + gtk_object_unref (GTK_OBJECT (priv->activity)); priv->activity = NULL; } } @@ -2094,7 +2120,7 @@ calendar_model_set_status_message (CalendarModel *model, const char *message) char *client_id = g_strdup_printf ("%p", model); if (progress_icon[0] == NULL) - progress_icon[0] = gdk_pixbuf_new_from_file (EVOLUTION_IMAGESDIR "/" EVOLUTION_TASKS_PROGRESS_IMAGE, NULL); + progress_icon[0] = gdk_pixbuf_new_from_file (EVOLUTION_IMAGESDIR "/" EVOLUTION_TASKS_PROGRESS_IMAGE); priv->activity = evolution_activity_client_new ( global_shell_client, client_id, progress_icon, message, TRUE, &display); @@ -2153,11 +2179,11 @@ calendar_model_set_cal_client (CalendarModel *model, CalClient *client, CalObjTy return; if (client) - g_object_ref (client); + gtk_object_ref (GTK_OBJECT (client)); if (priv->client) { - g_signal_handlers_disconnect_matched (priv->client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, model); - g_object_unref (priv->client); + gtk_signal_disconnect_by_data (GTK_OBJECT (priv->client), model); + gtk_object_unref (GTK_OBJECT (priv->client)); } priv->client = client; @@ -2167,7 +2193,8 @@ calendar_model_set_cal_client (CalendarModel *model, CalClient *client, CalObjTy if (cal_client_get_load_state (priv->client) == CAL_CLIENT_LOAD_LOADED) update_query (model); else - g_signal_connect (priv->client, "cal_opened", G_CALLBACK (cal_opened_cb), model); + gtk_signal_connect (GTK_OBJECT (priv->client), "cal_opened", + GTK_SIGNAL_FUNC (cal_opened_cb), model); } } @@ -2276,7 +2303,7 @@ calendar_model_mark_task_complete (CalendarModel *model, **/ CalComponent * calendar_model_get_component (CalendarModel *model, - gint row) + gint row) { CalendarModelPrivate *priv; |