From be1cbc01a75326490e0bec28c8c89bba070fe487 Mon Sep 17 00:00:00 2001 From: Jesse Pavel Date: Fri, 13 Oct 2000 22:40:49 +0000 Subject: *** empty log message *** svn path=/trunk/; revision=5905 --- calendar/ChangeLog | 5 + calendar/gui/e-itip-control.c | 137 ++++++++++++++++- calendar/gui/e-itip-control.glade | 311 +++++++++++++++++++++++++++++++++++++- 3 files changed, 440 insertions(+), 13 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index ded6e7dddd..81554efd26 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,8 @@ +2000-10-12 Jesse Pavel + + * gui/e-itip-control.{c,glade}: Made the control much more + relavent to the function at hand. + 2000-10-12 Damon Chaplin * gui/e-calendar-table.c (E_CALENDAR_TABLE_SPEC): set the 2 icon diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index 670cfed67f..463941e6c2 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -14,12 +14,14 @@ #include #include #include +#include #include "e-itip-control.h" +#include -#define DEFAULT_WIDTH 300 -#define DEFAULT_HEIGHT 200 +#define DEFAULT_WIDTH 500 +#define DEFAULT_HEIGHT 400 typedef struct _EItipControlPrivate EItipControlPrivate; @@ -28,11 +30,28 @@ struct _EItipControlPrivate { GladeXML *xml; GtkWidget *main_frame; GtkWidget *text_box; + GtkWidget *organizer_entry, *dtstart_label, *dtend_label; + GtkWidget *summary_entry, *description_box; - icalcomponent *main_comp; + icalcomponent *main_comp, *comp; + CalComponent *cal_comp; }; +#if 0 +static icalparameter * +get_icalparam_by_type (icalproperty *prop, icalparameter_kind kind) +{ + icalparameter *param; + + for (param = icalproperty_get_first_parameter (prop, ICAL_ANY_PARAMETER); + param != NULL && icalparameter_isa (param) != kind; + param = icalproperty_get_next_parameter (prop, ICAL_ANY_PARAMETER) ); + + return param; +} +#endif + static void itip_control_destroy_cb (GtkObject *object, gpointer data) @@ -40,6 +59,10 @@ itip_control_destroy_cb (GtkObject *object, EItipControlPrivate *priv = data; gtk_object_unref (GTK_OBJECT (priv->xml)); + if (priv->main_comp != NULL) { + icalcomponent_free (priv->main_comp); + } + g_free (priv); } @@ -111,7 +134,7 @@ pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream, { EItipControlPrivate *priv = data; gchar *vcalendar; - gint pos, length; + gint pos, length, length2; if (type && g_strcasecmp (type, "text/calendar") != 0 && g_strcasecmp (type, "text/x-calendar") != 0) { @@ -129,9 +152,106 @@ pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream, /* Do something with the data, here. */ pos = 0; length = strlen (vcalendar); + length2 = strlen (gtk_editable_get_chars (GTK_EDITABLE (priv->text_box), 0, -1)); + + + if (length2 > 0) + gtk_editable_delete_text (GTK_EDITABLE (priv->text_box), 0, length2); + + gtk_editable_insert_text (GTK_EDITABLE (priv->text_box), + vcalendar, + length, + &pos); + + priv->main_comp = icalparser_parse_string (vcalendar); + if (priv->main_comp == NULL) { + g_printerr ("e-itip-control.c: the iCalendar data was invalid!\n"); + return; + } + + priv->comp = icalcomponent_get_first_component (priv->main_comp, + ICAL_ANY_COMPONENT); + if (priv->comp == NULL) { + g_printerr ("e-itip-control.c: I could not extract a proper component from\n" + " the vCalendar data.\n"); + icalcomponent_free (priv->main_comp); + return; + } + +#if 0 + priv->cal_comp = cal_component_new (); + if (cal_component_set_icalcomponent (priv->cal_comp, priv->comp) == FALSE)) { + gtk_object_destroy (GTK_OBJECT (priv->cal_comp)); + icalcomponent_free (main_comp); + } +#endif + + /* Okay, good then; now I will pick apart the CalComponent to get + all the things I'll show in my control. */ + { + icalproperty *prop; + gchar *new_text; + gchar *organizer, *description, *summary; + struct icaltimetype dtstart, dtend; + time_t tstart, tend; + + prop = icalcomponent_get_first_property (priv->comp, ICAL_ORGANIZER_PROPERTY); + if (prop) { + organizer = icalproperty_get_organizer (prop); + + /* Here I strip off the "MAILTO:" if it is present. */ + new_text = strchr (organizer, ':'); + if (new_text != NULL) + new_text++; + else + new_text = organizer; + + gtk_entry_set_text (GTK_ENTRY (priv->organizer_entry), new_text); + } + + prop = icalcomponent_get_first_property (priv->comp, ICAL_SUMMARY_PROPERTY); + if (prop) { + summary = icalproperty_get_summary (prop); + gtk_entry_set_text (GTK_ENTRY (priv->summary_entry), summary); + } + + prop = icalcomponent_get_first_property (priv->comp, ICAL_DESCRIPTION_PROPERTY); + if (prop) { + description = icalproperty_get_summary (prop); + + pos = 0; + length = strlen (description); + length2 = strlen (gtk_editable_get_chars + (GTK_EDITABLE (priv->description_box), 0, -1)); + + if (length2 > 0) + gtk_editable_delete_text (GTK_EDITABLE (priv->description_box), 0, length2); + + gtk_editable_insert_text (GTK_EDITABLE (priv->description_box), + description, + length, + &pos); + } + + prop = icalcomponent_get_first_property (priv->comp, ICAL_DTSTART_PROPERTY); + dtstart = icalproperty_get_dtstart (prop); + prop = icalcomponent_get_first_property (priv->comp, ICAL_DTEND_PROPERTY); + dtend = icalproperty_get_dtend (prop); + + tstart = icaltime_as_timet (dtstart); + tend = icaltime_as_timet (dtend); + + gtk_label_set_text (GTK_LABEL (priv->dtstart_label), ctime (&tstart)); + gtk_label_set_text (GTK_LABEL (priv->dtend_label), ctime (&tend)); + } + + pos = 0; + length = strlen (vcalendar); + length2 = strlen (gtk_editable_get_chars (GTK_EDITABLE (priv->text_box), 0, -1)); + - if (length > 0) - gtk_editable_delete_text (GTK_EDITABLE (priv->text_box), 0, length); + if (length2 > 0) + gtk_editable_delete_text (GTK_EDITABLE (priv->text_box), 0, length2); gtk_editable_insert_text (GTK_EDITABLE (priv->text_box), vcalendar, @@ -203,6 +323,11 @@ e_itip_control_factory (BonoboGenericFactory *Factory, void *closure) /* Create the control. */ priv->main_frame = glade_xml_get_widget (priv->xml, "main_frame"); priv->text_box = glade_xml_get_widget (priv->xml, "text_box"); + priv->organizer_entry = glade_xml_get_widget (priv->xml, "organizer_entry"); + priv->dtstart_label = glade_xml_get_widget (priv->xml, "dtstart_label"); + priv->dtend_label = glade_xml_get_widget (priv->xml, "dtend_label"); + priv->summary_entry = glade_xml_get_widget (priv->xml, "summary_entry"); + priv->description_box = glade_xml_get_widget (priv->xml, "description_box"); gtk_text_set_editable (GTK_TEXT (priv->text_box), FALSE); gtk_signal_connect (GTK_OBJECT (priv->main_frame), "destroy", diff --git a/calendar/gui/e-itip-control.glade b/calendar/gui/e-itip-control.glade index 4f40977c90..7fc075b943 100644 --- a/calendar/gui/e-itip-control.glade +++ b/calendar/gui/e-itip-control.glade @@ -28,7 +28,7 @@ GtkFrame main_frame 4 - + 0.11 GTK_SHADOW_ETCHED_IN @@ -36,16 +36,313 @@ GtkScrolledWindow scrolledwindow1 GTK_POLICY_NEVER - GTK_POLICY_ALWAYS + GTK_POLICY_NEVER GTK_UPDATE_CONTINUOUS GTK_UPDATE_CONTINUOUS - GtkText - text_box - True - False - + GtkViewport + viewport1 + GTK_SHADOW_IN + + + GtkVBox + vbox1 + False + 0 + + + GtkTable + table1 + 4 + 2 + False + 0 + 9 + + 6 + True + True + + + + GtkEntry + organizer_entry + True + False + True + 0 + + + 1 + 2 + 0 + 1 + 0 + 0 + True + False + False + False + True + False + + + + + GtkEntry + summary_entry + True + True + True + 0 + + + 1 + 2 + 2 + 3 + 0 + 0 + True + False + False + False + True + False + + + + + GtkScrolledWindow + scrolledwindow2 + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 1 + 2 + 3 + 4 + 0 + 0 + False + False + False + False + True + True + + + + GtkText + description_box + True + False + + + + + + GtkLabel + label7 + + GTK_JUSTIFY_RIGHT + False + 1 + 0 + 0 + 0 + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + True + True + + + + + GtkLabel + label6 + + GTK_JUSTIFY_RIGHT + False + 1 + 0.5 + 0 + 0 + + 0 + 1 + 0 + 1 + 0 + 0 + False + False + False + False + True + True + + + + + GtkLabel + label8 + + GTK_JUSTIFY_RIGHT + False + 1 + 0.5 + 0 + 0 + + 0 + 1 + 2 + 3 + 0 + 0 + False + False + False + False + True + True + + + + + GtkLabel + label9 + + GTK_JUSTIFY_RIGHT + False + 1 + 0 + 0 + 0 + + 0 + 1 + 3 + 4 + 0 + 0 + False + False + False + False + True + True + + + + + GtkAlignment + alignment1 + 0 + 0 + 1 + 1 + + 1 + 2 + 1 + 2 + 0 + 0 + True + False + False + False + True + True + + + + GtkHBox + hbox1 + False + 0 + + + GtkLabel + dtstart_label + + GTK_JUSTIFY_CENTER + False + 0.5 + 0 + 0 + 0 + + 0 + False + False + + + + + GtkLabel + label3 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 19 + 0 + + 0 + False + False + + + + + GtkLabel + dtend_label + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + + + + GtkText + text_box + True + False + + + 0 + True + True + + + -- cgit v1.2.3