From b768174bd9f5dda7e22412b7f90e40b712c647d1 Mon Sep 17 00:00:00 2001 From: Jesse Pavel Date: Tue, 10 Oct 2000 23:05:47 +0000 Subject: *** empty log message *** svn path=/trunk/; revision=5825 --- calendar/gui/GNOME_Evolution_Calendar.oaf.in | 34 +++ calendar/gui/GNOME_Evolution_Calendar.oafinfo | 34 +++ .../gui/GNOME_Evolution_Calendar_gnomecal.oaf.in | 34 +++ .../gui/GNOME_Evolution_Calendar_gnomecal.oafinfo | 34 +++ calendar/gui/Makefile.am | 7 +- calendar/gui/e-itip-control.c | 236 +++++++++++++++++++++ calendar/gui/e-itip-control.glade | 54 +++++ calendar/gui/e-itip-control.h | 8 + calendar/gui/e-meeting-edit.c | 56 +---- calendar/gui/evolution-calendar.oafinfo | 34 +++ calendar/gui/main.c | 3 +- 11 files changed, 480 insertions(+), 54 deletions(-) create mode 100644 calendar/gui/e-itip-control.c create mode 100644 calendar/gui/e-itip-control.glade create mode 100644 calendar/gui/e-itip-control.h diff --git a/calendar/gui/GNOME_Evolution_Calendar.oaf.in b/calendar/gui/GNOME_Evolution_Calendar.oaf.in index 25279ccaeb..a772bca77b 100644 --- a/calendar/gui/GNOME_Evolution_Calendar.oaf.in +++ b/calendar/gui/GNOME_Evolution_Calendar.oaf.in @@ -1,5 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/calendar/gui/GNOME_Evolution_Calendar.oafinfo b/calendar/gui/GNOME_Evolution_Calendar.oafinfo index 25279ccaeb..a772bca77b 100644 --- a/calendar/gui/GNOME_Evolution_Calendar.oafinfo +++ b/calendar/gui/GNOME_Evolution_Calendar.oafinfo @@ -1,5 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in b/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in index 25279ccaeb..a772bca77b 100644 --- a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in +++ b/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in @@ -1,5 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo b/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo index 25279ccaeb..a772bca77b 100644 --- a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo +++ b/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo @@ -1,5 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 9731104200..bd32e28ef3 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -40,7 +40,8 @@ gladedir = $(datadir)/evolution/glade glade_DATA = \ event-editor-dialog.glade \ - e-meeting-dialog.glade + e-meeting-dialog.glade \ + e-itip-control.glade glade_messages = event-editor-dialog.glade.h @@ -77,6 +78,8 @@ evolution_calendar_SOURCES = \ e-week-view.h \ e-meeting-edit.h \ e-meeting-edit.c \ + e-itip-control.h \ + e-itip-control.c \ event-editor.c \ event-editor.h \ getdate.y \ @@ -106,7 +109,7 @@ evolution_calendar_LDADD = \ evolution_calendar_LDFLAGS = `gnome-config --libs gdk_pixbuf` oafdir = $(datadir)/oaf -oaf_DATA = calendar-control.oafinfo evolution-calendar.oafinfo +oaf_DATA = calendar-control.oafinfo evolution-calendar.oafinfo EXTRA_DIST = \ $(glade_DATA) \ diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c new file mode 100644 index 0000000000..7c4dc22a4b --- /dev/null +++ b/calendar/gui/e-itip-control.c @@ -0,0 +1,236 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * e-itip-control.c + * + * Authors: + * Jesse Pavel + * + * Copyright 2000, Helix Code, Inc. + */ + +#include +#include +#include +#include +#include +#include + +#include "e-itip-control.h" + +/* + * Bonobo::PersistStream + * + * These two functions implement the Bonobo::PersistStream load and + * save methods which allow data to be loaded into and out of the + * BonoboObject. + */ + +typedef struct _EItipControlPrivate EItipControlPrivate; + +struct _EItipControlPrivate { + GladeXML *xml; + GtkWidget *main_frame; + GtkWidget *text_box; + + icalcomponent *main_comp; +}; + + +static void +control_destroy_cb (GtkObject *object, + gpointer data) +{ + EItipControlPrivate *priv = data; + + gtk_object_unref (GTK_OBJECT (priv->xml)); + g_free (priv); +} + + +static char * +stream_read (Bonobo_Stream stream) +{ + Bonobo_Stream_iobuf *buffer; + CORBA_Environment ev; + gchar *data = NULL; + gint length = 0; + + CORBA_exception_init (&ev); + do { +#define READ_CHUNK_SIZE 65536 + Bonobo_Stream_read (stream, READ_CHUNK_SIZE, + &buffer, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + CORBA_exception_free (&ev); + return NULL; + } + + if (buffer->_length <= 0) + break; + + data = g_realloc (data, + length + buffer->_length); + + memcpy (data + length, + buffer->_buffer, buffer->_length); + + length += buffer->_length; + + CORBA_free (buffer); + } while (1); + + CORBA_free (buffer); + CORBA_exception_free (&ev); + + if (data == NULL) + data = g_strdup(""); + + return data; +} /* stream_read */ + +/* + * This function implements the Bonobo::PersistStream:load method. + */ +static void +pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream, + Bonobo_Persist_ContentType type, void *data, + CORBA_Environment *ev) +{ + EItipControlPrivate *priv = data; + gchar *vcalendar; + gint pos, length; + + if (type && g_strcasecmp (type, "text/calendar") != 0 && + g_strcasecmp (type, "text/x-calendar") != 0) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Bonobo_Persist_WrongDataType, NULL); + return; + } + + if ((vcalendar = stream_read (stream)) == NULL) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Bonobo_Persist_FileNotFound, NULL); + return; + } + + /* Do something with the data, here. */ + pos = 0; + length = strlen (vcalendar); + + if (length > 0) + gtk_editable_delete_text (GTK_EDITABLE (priv->text_box), 0, length); + + gtk_editable_insert_text (GTK_EDITABLE (priv->text_box), + vcalendar, + length, + &pos); + + + g_free (vcalendar); + +} /* pstream_load */ + +/* + * This function implements the Bonobo::PersistStream:save method. + */ +static void +pstream_save (BonoboPersistStream *ps, const Bonobo_Stream stream, + Bonobo_Persist_ContentType type, void *data, + CORBA_Environment *ev) +{ + EItipControlPrivate *priv = data; + gchar *vcalendar; + int length; + + if (type && g_strcasecmp (type, "text/calendar") != 0 && + g_strcasecmp (type, "text/x-calendar") != 0) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Bonobo_Persist_WrongDataType, NULL); + return; + } + + /* Put something into vcalendar here. */ + length = gtk_text_get_length (GTK_TEXT (priv->text_box)); + vcalendar = gtk_editable_get_chars (GTK_EDITABLE (priv->text_box), 0, -1); + + bonobo_stream_client_write (stream, vcalendar, length, ev); + g_free (vcalendar); +} /* pstream_save */ + +static CORBA_long +pstream_get_max_size (BonoboPersistStream *ps, void *data, + CORBA_Environment *ev) +{ + EItipControlPrivate *priv = data; + gint length; + + length = gtk_text_get_length (GTK_TEXT (priv->text_box)); + + return length; +} + +static Bonobo_Persist_ContentTypeList * +pstream_get_content_types (BonoboPersistStream *ps, void *closure, + CORBA_Environment *ev) +{ + return bonobo_persist_generate_content_types (2, "text/calendar", "text/x-calendar"); +} + +static BonoboObject * +e_itip_control_factory (BonoboGenericFactory *Factory, void *closure) +{ + BonoboControl *control; + BonoboPersistStream *stream; + EItipControlPrivate *priv; + + priv = g_new0 (EItipControlPrivate, 1); + + priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/" "e-itip-control.glade", "main_frame"); + + /* 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"); + gtk_text_set_editable (GTK_TEXT (priv->text_box), FALSE); + + gtk_signal_connect (GTK_OBJECT (priv->main_frame), "destroy", + GTK_SIGNAL_FUNC (control_destroy_cb), priv); + + gtk_widget_show (priv->text_box); + gtk_widget_show (priv->main_frame); + + control = bonobo_control_new (priv->main_frame); + + stream = bonobo_persist_stream_new (pstream_load, pstream_save, + pstream_get_max_size, + pstream_get_content_types, + priv); + + if (stream == NULL) { + bonobo_object_unref (BONOBO_OBJECT (control)); + return NULL; + } + + bonobo_object_add_interface (BONOBO_OBJECT (control), + BONOBO_OBJECT (stream)); + + return BONOBO_OBJECT (control); +} + +void +e_itip_control_factory_init (void) +{ + static BonoboGenericFactory *factory = NULL; + + if (factory != NULL) + return; + + factory = + bonobo_generic_factory_new ( + "OAFIID:control-factory:e_itipview:10441fcf-9a4f-4bf9-a026-d50b5462d45a", + e_itip_control_factory, NULL); + + if (factory == NULL) + g_error ("I could not register an iTip control factory."); +} + diff --git a/calendar/gui/e-itip-control.glade b/calendar/gui/e-itip-control.glade new file mode 100644 index 0000000000..4f40977c90 --- /dev/null +++ b/calendar/gui/e-itip-control.glade @@ -0,0 +1,54 @@ + + + + + e-itip-control + e-itip-control + + src + pixmaps + C + True + True + + + + GtkWindow + window1 + False + window1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + + + GtkFrame + main_frame + 4 + + 0.11 + GTK_SHADOW_ETCHED_IN + + + GtkScrolledWindow + scrolledwindow1 + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkText + text_box + True + False + + + + + + + diff --git a/calendar/gui/e-itip-control.h b/calendar/gui/e-itip-control.h new file mode 100644 index 0000000000..467f0578ef --- /dev/null +++ b/calendar/gui/e-itip-control.h @@ -0,0 +1,8 @@ +#ifndef __E_ITIP_CONTROL_H__ +#define __E_ITIP_CONTROL_H__ + +#include + +void e_itip_control_factory_init (void); + +#endif /* __E_ITIP_CONTROL_H__ */ diff --git a/calendar/gui/e-meeting-edit.c b/calendar/gui/e-meeting-edit.c index d8df270eff..6ae266174d 100644 --- a/calendar/gui/e-meeting-edit.c +++ b/calendar/gui/e-meeting-edit.c @@ -28,7 +28,6 @@ #define E_MEETING_GLADE_XML "e-meeting-dialog.glade" -#define E_MEETING_DEBUG typedef struct _EMeetingEditorPrivate EMeetingEditorPrivate; @@ -105,10 +104,6 @@ window_delete_cb (GtkWidget *widget, priv = (EMeetingEditorPrivate *) ((EMeetingEditor *)data)->priv; -#ifdef E_MEETING_DEBUG - g_printerr ("e-meeting-edit.c: The main window received a delete event.\n"); -#endif - if (priv->dirty == TRUE) { /* FIXME: notify the event editor that our data has changed. For now, I'll just display a dialog box. */ @@ -121,9 +116,6 @@ window_delete_cb (GtkWidget *widget, prop = icalcomponent_get_first_property (priv->vevent, ICAL_ORGANIZER_PROPERTY); text = gtk_entry_get_text (GTK_ENTRY (priv->organizer_entry)); -#ifdef E_MEETING_DEBUG - g_print ("e-meeting-edit.c: The organizer entry is %s.\n", text); -#endif if (strlen (text) > 0) { gchar buffer[200]; g_snprintf (buffer, 190, "MAILTO:%s", text); @@ -155,10 +147,6 @@ window_destroy_cb (GtkWidget *widget, { EMeetingEditorPrivate *priv; -#ifdef E_MEETING_DEBUG - g_printerr ("e-meeting-edit.c: The main window received a destroy event.\n"); -#endif - priv = (EMeetingEditorPrivate *) ((EMeetingEditor *)data)->priv; gtk_main_quit (); @@ -202,9 +190,6 @@ put_property_in_list (icalproperty *prop, gint rownum, gpointer data) param = get_icalparam_by_type (prop, ICAL_ROLE_PARAMETER); if (param == NULL) { -#ifdef E_MEETING_DEBUG - g_print ("e-meeting-edit.c: within put_param...(), param is NULL.\n"); -#endif param = icalparameter_new_role (ICAL_ROLE_REQPARTICIPANT); icalproperty_add_parameter (prop, param); } @@ -212,9 +197,6 @@ put_property_in_list (icalproperty *prop, gint rownum, gpointer data) enumval = icalparameter_get_role (param); if (enumval < 0 || enumval > 4) enumval = 4; -#ifdef E_MEETING_DEBUG - g_print ("e-meeting-edit.c: the role value is %d.\n", enumval); -#endif row_text[ROLE_COL] = role_values [enumval]; @@ -229,11 +211,6 @@ put_property_in_list (icalproperty *prop, gint rownum, gpointer data) else row_text[RSVP_COL] = "N"; -#ifdef E_MEETING_DEBUG - g_print ("e-meeting-edit.c: the RSVP is %c.\n", row_text[RSVP_COL][0]); -#endif - - param = get_icalparam_by_type (prop, ICAL_PARTSTAT_PARAMETER); if (param == NULL) { param = icalparameter_new_partstat (ICAL_PARTSTAT_NEEDSACTION); @@ -354,9 +331,6 @@ edit_attendee (icalproperty *prop, gpointer data) param = NULL; text = gtk_entry_get_text (GTK_ENTRY(priv->role_entry)); -#ifdef E_MEETING_DEBUG - g_print ("e-meeting-edit.c: the role entry text is %s.\n", text); -#endif for (cntr = 0; cntr < 5; cntr++) { if (strncmp (text, role_values[cntr], 3) == 0) { @@ -396,10 +370,6 @@ add_button_clicked_cb (GtkWidget *widget, gpointer data) icalproperty *prop; icalparameter *param; -#ifdef E_MEETING_DEBUG - g_printerr ("e-meeting-edit.c: the add button was clicked.\n"); -#endif - priv = (EMeetingEditorPrivate *) ((EMeetingEditor *)data)->priv; prop = icalproperty_new (ICAL_ATTENDEE_PROPERTY); @@ -411,20 +381,12 @@ add_button_clicked_cb (GtkWidget *widget, gpointer data) icalproperty_add_parameter (prop, param); if (edit_attendee (prop, data) == TRUE) { -#ifdef E_MEETING_DEBUG - g_print ("e-meeting-edit.c: After edit_attendee()"); -#endif - /* Let's add this property to our component and to the CList. */ icalcomponent_add_property (priv->vevent, prop); /* The -1 indicates that we should add a new row. */ put_property_in_list (prop, -1, data); -#ifdef E_MEETING_DEBUG - g_print ("e-meeting-edit.c: After put_property_in_list()"); -#endif - priv->dirty = TRUE; } else { @@ -498,6 +460,11 @@ edit_button_clicked_cb (GtkWidget *widget, gpointer data) icalproperty_remove_parameter (prop, ICAL_ROLE_PARAMETER); icalproperty_remove_parameter (prop, ICAL_RSVP_PARAMETER); + + param = get_icalparam_by_type (prop, ICAL_ROLE_PARAMETER); + if (param != NULL) + g_print ("e-meeting-edit.c: param should be NULL, but it isn't.\n"); + icalproperty_remove_parameter (prop, ICAL_PARTSTAT_PARAMETER); param = icalparameter_new_clone (get_icalparam_by_type (new_prop, ICAL_ROLE_PARAMETER)); @@ -652,10 +619,6 @@ e_meeting_edit (EMeetingEditor *editor) if (prop != NULL) { gchar *buffer; -#ifdef E_MEETING_DEBUG - g_print ("e-meeting-edit.c: The organizer property is not null.\n"); -#endif - value = icalproperty_get_value (prop); buffer = g_strdup (icalvalue_as_ical_string (value)); if (buffer != NULL) { @@ -671,11 +634,6 @@ e_meeting_edit (EMeetingEditor *editor) } } -#ifdef E_MEETING_DEBUG - else { - g_print ("e-meeting-edit.c: the organizer property was NULL.\n"); - } -#endif priv->changed_signal_id = gtk_signal_connect (GTK_OBJECT (priv->organizer_entry), "changed", GTK_SIGNAL_FUNC (organizer_changed_cb), editor); @@ -695,10 +653,6 @@ e_meeting_edit (EMeetingEditor *editor) gtk_main (); -#ifdef E_MEETING_DEBUG - g_printerr ("e-meeting-edit.c: We've terminated the subsidiary gtk_main().\n"); -#endif - if (priv->meeting_window != NULL) gtk_widget_destroy (priv->meeting_window); diff --git a/calendar/gui/evolution-calendar.oafinfo b/calendar/gui/evolution-calendar.oafinfo index 25279ccaeb..a772bca77b 100644 --- a/calendar/gui/evolution-calendar.oafinfo +++ b/calendar/gui/evolution-calendar.oafinfo @@ -1,5 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/calendar/gui/main.c b/calendar/gui/main.c index 4474a64d8b..3016d9cb70 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -40,7 +40,7 @@ #include #include "component-factory.h" #include "control-factory.h" - +#include "e-itip-control.h" static void init_bonobo (int *argc, char **argv) @@ -75,6 +75,7 @@ main (int argc, char **argv) control_factory_init (); component_factory_init (); + e_itip_control_factory_init (); bonobo_main (); fprintf (stderr, "main(): Out of bonobo_main(), we are dying cleanly. Have a nice day.\n"); -- cgit v1.2.3