From 558571a562252639558836b9aa816020981e5d2f Mon Sep 17 00:00:00 2001 From: Jesse Pavel Date: Mon, 16 Oct 2000 22:30:36 +0000 Subject: *** empty log message *** svn path=/trunk/; revision=5950 --- calendar/ChangeLog | 8 +++ calendar/gui/e-itip-control.c | 89 +++++++++++++++++++++++++++++--- calendar/gui/e-itip-control.glade | 104 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+), 7 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 073eb638df..9bb02b4b5d 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,11 @@ +2000-10-16 Jesse Pavel + + * gui/e-itip-control.c: You can now add incoming iTip + messages to your calendar store. + + * gui/e-itip-control.glade: added a progress bar dialog + in case the calendar loading takes a long time. + 2000-10-16 JP Rosevear * cal-client/cal-client.h: Remove pilot cruft. All pilot stuff diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index 463941e6c2..28071be091 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -18,11 +18,13 @@ #include "e-itip-control.h" #include +#include #define DEFAULT_WIDTH 500 #define DEFAULT_HEIGHT 400 +extern gchar *evolution_dir; typedef struct _EItipControlPrivate EItipControlPrivate; @@ -32,6 +34,9 @@ struct _EItipControlPrivate { GtkWidget *text_box; GtkWidget *organizer_entry, *dtstart_label, *dtend_label; GtkWidget *summary_entry, *description_box; + GtkWidget *add_button; + GtkWidget *loading_window; + GtkWidget *loading_progress; icalcomponent *main_comp, *comp; CalComponent *cal_comp; @@ -63,6 +68,9 @@ itip_control_destroy_cb (GtkObject *object, icalcomponent_free (priv->main_comp); } + if (priv->cal_comp != NULL) { + gtk_object_unref (GTK_OBJECT (priv->cal_comp)); + } g_free (priv); } @@ -73,6 +81,69 @@ itip_control_size_request_cb (GtkWidget *widget, GtkRequisition *requisition) requisition->height = DEFAULT_HEIGHT; } +static void +cal_loaded_cb (GtkObject *object, CalClientGetStatus status, gpointer data) +{ + CalClient *client = CAL_CLIENT (object); + EItipControlPrivate *priv = data; + + gtk_widget_hide (priv->loading_progress); + + if (status == CAL_CLIENT_GET_SUCCESS) { + if (cal_client_update_object (client, priv->cal_comp) == FALSE) { + GtkWidget *dialog; + + dialog = gnome_warning_dialog("I couldn't update your calendar file!\n"); + gnome_dialog_run (GNOME_DIALOG(dialog)); + } + else { + /* We have success. */ + GtkWidget *dialog; + + dialog = gnome_ok_dialog("Component successfully added."); + gnome_dialog_run (GNOME_DIALOG(dialog)); + } + } + else { + GtkWidget *dialog; + + dialog = gnome_ok_dialog("There was an error loading the calendar file."); + gnome_dialog_run (GNOME_DIALOG(dialog)); + } + + gtk_object_unref (GTK_OBJECT (client)); + return; +} + +static void +add_button_clicked_cb (GtkWidget *widget, gpointer data) +{ + EItipControlPrivate *priv = data; + gchar cal_uri[255]; + CalClient *client; + + sprintf (cal_uri, "%s/local/Calendar/calendar.ics", evolution_dir); + + client = cal_client_new (); + if (cal_client_load_calendar (client, cal_uri) == FALSE) { + GtkWidget *dialog; + + dialog = gnome_warning_dialog("I couldn't open your calendar file!\n"); + gnome_dialog_run (GNOME_DIALOG(dialog)); + gtk_object_unref (GTK_OBJECT (client)); + + return; + } + + gtk_signal_connect (GTK_OBJECT (client), "cal_loaded", + GTK_SIGNAL_FUNC (cal_loaded_cb), priv); + + gtk_progress_bar_update (GTK_PROGRESS_BAR (priv->loading_progress), 0.5); + gtk_widget_show (priv->loading_progress); + + return; +} + /* * Bonobo::PersistStream @@ -178,15 +249,13 @@ pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream, 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); + if (cal_component_set_icalcomponent (priv->cal_comp, priv->comp) == FALSE) { + g_printerr ("e-itip-control.c: I couldn't create a CalComponent from the iTip data.\n"); + gtk_object_unref (GTK_OBJECT (priv->cal_comp)); } -#endif - /* Okay, good then; now I will pick apart the CalComponent to get + /* Okay, good then; now I will pick apart the component to get all the things I'll show in my control. */ { icalproperty *prop; @@ -328,12 +397,18 @@ e_itip_control_factory (BonoboGenericFactory *Factory, void *closure) 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); + priv->add_button = glade_xml_get_widget (priv->xml, "add_button"); + priv->loading_progress = glade_xml_get_widget (priv->xml, "loading_progress"); + priv->loading_window = glade_xml_get_widget (priv->xml, "loading_window"); + gtk_text_set_editable (GTK_TEXT (priv->text_box), FALSE); + gtk_signal_connect (GTK_OBJECT (priv->main_frame), "destroy", GTK_SIGNAL_FUNC (itip_control_destroy_cb), priv); gtk_signal_connect (GTK_OBJECT (priv->main_frame), "size_request", GTK_SIGNAL_FUNC (itip_control_size_request_cb), priv); + gtk_signal_connect (GTK_OBJECT (priv->add_button), "clicked", + GTK_SIGNAL_FUNC (add_button_clicked_cb), priv); gtk_widget_show (priv->text_box); gtk_widget_show (priv->main_frame); diff --git a/calendar/gui/e-itip-control.glade b/calendar/gui/e-itip-control.glade index da2e1dcdae..8a683f72aa 100644 --- a/calendar/gui/e-itip-control.glade +++ b/calendar/gui/e-itip-control.glade @@ -330,6 +330,30 @@ + + GtkHButtonBox + hbuttonbox1 + GTK_BUTTONBOX_DEFAULT_STYLE + 30 + 85 + 27 + 7 + 0 + + 0 + True + True + + + + GtkButton + add_button + True + True + + + + GtkText text_box @@ -348,4 +372,84 @@ + + GtkWindow + loading_window + False + Loading Calendar + GTK_WINDOW_DIALOG + GTK_WIN_POS_CENTER + False + False + True + False + + + GtkFrame + frame1 + 4 + + 0 + GTK_SHADOW_ETCHED_OUT + + + GtkVBox + vbox2 + 7 + False + 1 + + + GtkHBox + hbox2 + 6 + False + 9 + + 0 + False + False + + + + GtkLabel + label10 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkProgressBar + progressbar1 + 0 + 0 + 100 + GTK_PROGRESS_CONTINUOUS + GTK_PROGRESS_LEFT_TO_RIGHT + False + False + %P %% + 0.5 + 0.5 + + 0 + False + False + + + + + + + -- cgit v1.2.3