diff options
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 54 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm.c | 4 | ||||
-rw-r--r-- | calendar/gui/alarm.c | 4 | ||||
-rw-r--r-- | calendar/gui/calendar-commands.h | 1 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 254 | ||||
-rw-r--r-- | calendar/gui/e-day-view.h | 18 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 286 | ||||
-rw-r--r-- | calendar/gui/e-week-view.h | 20 | ||||
-rw-r--r-- | calendar/gui/gncal-todo.c | 729 | ||||
-rw-r--r-- | calendar/gui/gncal-todo.h | 38 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 58 |
11 files changed, 413 insertions, 1053 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index ede3b191b7..db73ec8ffb 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,57 @@ +2000-08-29 Federico Mena Quintero <federico@helixcode.com> + + Now the views monitor the client by themselves; it does not make + sense to proxy all notifications through the GnomeCal. The + GnomeCal should just be a meta-widget that holds all the views. + + At some later point we'll want to decouple the views from the + GnomeCal so that they can be embedded anywhere; they should emit + signals to request appropriate actions from the toplevel GUI + instead of calling the GnomeCal directly. + + * gui/e-day-view.c (e_day_view_set_cal_client): New function; now + the day view monitors the client by itself. + (cal_loaded_cb): New callback; moved over from + e_day_view_update_all_events(). + (obj_updated_cb): New callback; moved over from + e_day_view_update_event(). + (obj_removed_cb): New callback; moved over from + e_day_view_remove_event(). + (e_day_view_update_all_events): Removed function. + (e_day_view_update_event): Removed function. + (e_day_view_remove_event): Removed function. + (*): Use the day_view->client directly instead of fetching it from + the GnomeCal. + (e_day_view_destroy): Unref the client. + (e_day_view_reload_events): Check if the client is loaded. + (e_day_view_key_press): Set the vtype of the new component. + + * gui/e-week-view.c (e_week_view_set_cal_client): New function. + (cal_loaded_cb): New callback. + (obj_updated_cb): New callback. + (obj_removed_cb): New callback. + (e_week_view_update_all_events): Removed function. + (e_week_view_update_event): Removed function. + (e_week_view_remove_event): Removed function. + (*): Use the week_view->client directly. + (e_week_view_destroy): Unref the client. + (e_week_view_reload_events): Check if the client is loaded. + + * gui/gnome-cal.c (setup_widgets): Set the cal_client on all the + views. + (gnome_calendar_update_all): Do not update the views, since now + they do it themselves. + (gnome_calendar_object_updated_cb): Likewise. + (gnome_calendar_object_removed_cb): Likewise. + (setup_widgets): Remove all to-do list cruft. + (gnome_calendar_colors_changed): Likewise. + (gnome_calendar_todo_properties_changed): Likewise. + + * gui/calendar-commands.h (todo_style_changed): Removed variable. + + * gui/gncal-todo.c: Removed old clist cruft; just left in the + temporary dialog box for now. + 2000-08-29 Dan Winship <danw@helixcode.com> * cal-client/client-test.c: diff --git a/calendar/gui/alarm-notify/alarm.c b/calendar/gui/alarm-notify/alarm.c index c89b65ff5e..085111498b 100644 --- a/calendar/gui/alarm-notify/alarm.c +++ b/calendar/gui/alarm-notify/alarm.c @@ -139,7 +139,7 @@ alarm_ready (gpointer data, gint fd, GdkInputCondition cond) g_assert (alarms != NULL); ar = pop_alarm (); - g_message ("alarm_ready(): Notifying about alarm on %s", ctime (&ar->trigger)); + g_print ("alarm_ready(): Notifying about alarm on %s\n", ctime (&ar->trigger)); (* ar->alarm_fn) (ar, ar->trigger, ar->data); @@ -226,7 +226,7 @@ alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, ar->data = data; ar->destroy_notify_fn = destroy_notify_fn; - g_message ("alarm_add(): Adding alarm for %s", ctime (&trigger)); + g_print ("alarm_add(): Adding alarm for %s\n", ctime (&trigger)); if (!queue_alarm (now, ar)) { if (ar->destroy_notify_fn) diff --git a/calendar/gui/alarm.c b/calendar/gui/alarm.c index c89b65ff5e..085111498b 100644 --- a/calendar/gui/alarm.c +++ b/calendar/gui/alarm.c @@ -139,7 +139,7 @@ alarm_ready (gpointer data, gint fd, GdkInputCondition cond) g_assert (alarms != NULL); ar = pop_alarm (); - g_message ("alarm_ready(): Notifying about alarm on %s", ctime (&ar->trigger)); + g_print ("alarm_ready(): Notifying about alarm on %s\n", ctime (&ar->trigger)); (* ar->alarm_fn) (ar, ar->trigger, ar->data); @@ -226,7 +226,7 @@ alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, ar->data = data; ar->destroy_notify_fn = destroy_notify_fn; - g_message ("alarm_add(): Adding alarm for %s", ctime (&trigger)); + g_print ("alarm_add(): Adding alarm for %s\n", ctime (&trigger)); if (!queue_alarm (now, ar)) { if (ar->destroy_notify_fn) diff --git a/calendar/gui/calendar-commands.h b/calendar/gui/calendar-commands.h index f48ba333bc..715b44b167 100644 --- a/calendar/gui/calendar-commands.h +++ b/calendar/gui/calendar-commands.h @@ -51,7 +51,6 @@ extern int todo_item_dstatus_highlight_not_due_yet; extern int todo_show_time_remaining; extern int todo_show_priority; extern char *todo_overdue_font_text; -extern gboolean todo_style_changed; extern gint todo_current_sort_column; extern gint todo_current_sort_type; diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index a81a71d603..3649abbfe3 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -442,6 +442,7 @@ e_day_view_init (EDayView *day_view) colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view)); day_view->calendar = NULL; + day_view->client = NULL; day_view->long_events = g_array_new (FALSE, FALSE, sizeof (EDayViewEvent)); @@ -770,7 +771,7 @@ e_day_view_init (EDayView *day_view) "button_press_event", GTK_SIGNAL_FUNC (e_day_view_on_time_canvas_button_press), day_view); - + canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->time_canvas)->root); day_view->time_canvas_item = @@ -850,6 +851,12 @@ e_day_view_destroy (GtkObject *object) day_view = E_DAY_VIEW (object); + if (day_view->client) { + gtk_signal_disconnect_by_data (GTK_OBJECT (day_view->client), day_view); + gtk_object_unref (GTK_OBJECT (day_view->client)); + day_view->client = NULL; + } + e_day_view_stop_auto_scroll (day_view); if (day_view->large_font) @@ -1105,51 +1112,59 @@ e_day_view_set_calendar (EDayView *day_view, } -/* This reloads all calendar events. */ -void -e_day_view_update_all_events (EDayView *day_view) +/* Callback used when the calendar client finishes loading */ +static void +cal_loaded_cb (CalClient *client, CalClientLoadStatus status, gpointer data) { + EDayView *day_view; + + day_view = E_DAY_VIEW (data); + + if (status != CAL_CLIENT_LOAD_SUCCESS) + return; + e_day_view_reload_events (day_view); } - -/* This is called when one event has been added or updated. */ -void -e_day_view_update_event (EDayView *day_view, - const gchar *uid) +/* Callback used when the calendar client tells us that an object changed */ +static void +obj_updated_cb (CalClient *client, const char *uid, gpointer data) { + EDayView *day_view; EDayViewEvent *event; CalComponent *comp; CalClientGetStatus status; gint day, event_num; - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - - g_print ("In e_day_view_update_event day_view:%p uid:%s\n", - day_view, uid); + day_view = E_DAY_VIEW (data); - /* If our calendar or time hasn't been set yet, just return. */ - if (!day_view->calendar - || (day_view->lower == 0 && day_view->upper == 0)) + /* If our time hasn't been set yet, just return. */ + if (day_view->lower == 0 && day_view->upper == 0) return; /* Get the event from the server. */ - status = cal_client_get_object (day_view->calendar->client, uid, &comp); + status = cal_client_get_object (day_view->client, uid, &comp); switch (status) { case CAL_CLIENT_GET_SUCCESS: - /* Do nothing. */ + /* Everything is fine */ break; + case CAL_CLIENT_GET_SYNTAX_ERROR: - g_warning ("syntax error uid=%s\n", uid); + g_message ("obj_updated_cb(): Syntax error when getting object `%s'", uid); return; + case CAL_CLIENT_GET_NOT_FOUND: - g_warning ("obj not found uid=%s\n", uid); + /* The object is no longer in the server, so do nothing */ + return; + + default: + g_assert_not_reached (); return; } /* We only care about events. */ - if (comp && cal_component_get_vtype (comp) != CAL_COMPONENT_EVENT) { + if (cal_component_get_vtype (comp) != CAL_COMPONENT_EVENT) { gtk_object_unref (GTK_OBJECT (comp)); return; } @@ -1187,9 +1202,9 @@ e_day_view_update_event (EDayView *day_view, } /* Add the occurrences of the event. */ - cal_recur_generate_instances (comp, day_view->lower, + cal_recur_generate_instances (comp, day_view->lower, day_view->upper, - e_day_view_add_event, + e_day_view_add_event, day_view); gtk_object_unref (GTK_OBJECT (comp)); @@ -1199,6 +1214,65 @@ e_day_view_update_event (EDayView *day_view, gtk_widget_queue_draw (day_view->main_canvas); } +/* Callback used when the calendar client tells us that an object was removed */ +static void +obj_removed_cb (CalClient *client, const char *uid, gpointer data) +{ + EDayView *day_view; + + day_view = E_DAY_VIEW (data); + + e_day_view_foreach_event_with_uid (day_view, uid, + e_day_view_remove_event_cb, NULL); + + e_day_view_check_layout (day_view); + gtk_widget_queue_draw (day_view->top_canvas); + gtk_widget_queue_draw (day_view->main_canvas); +} + + +/** + * e_day_view_set_cal_client: + * @day_view: A day view. + * @client: A calendar client interface object. + * + * Sets the calendar client interface object that a day view will monitor. + **/ +void +e_day_view_set_cal_client (EDayView *day_view, + CalClient *client) +{ + g_return_if_fail (day_view != NULL); + g_return_if_fail (E_IS_DAY_VIEW (day_view)); + + if (client == day_view->client) + return; + + if (client) + g_return_if_fail (IS_CAL_CLIENT (client)); + + if (client) + gtk_object_ref (GTK_OBJECT (client)); + + if (day_view->client) { + gtk_signal_disconnect_by_data (GTK_OBJECT (day_view->client), day_view); + gtk_object_unref (GTK_OBJECT (day_view->client)); + } + + day_view->client = client; + + if (day_view->client) { + gtk_signal_connect (GTK_OBJECT (day_view->client), "cal_loaded", + GTK_SIGNAL_FUNC (cal_loaded_cb), day_view); + gtk_signal_connect (GTK_OBJECT (day_view->client), "obj_updated", + GTK_SIGNAL_FUNC (obj_updated_cb), day_view); + gtk_signal_connect (GTK_OBJECT (day_view->client), "obj_removed", + GTK_SIGNAL_FUNC (obj_removed_cb), day_view); + } + + e_day_view_reload_events (day_view); +} + #ifndef NO_WARNINGS static gboolean @@ -1260,7 +1334,7 @@ e_day_view_foreach_event_with_uid (EDayView *day_view, EDayViewEvent *event; gint day, event_num; const char *u; - + for (day = 0; day < day_view->days_shown; day++) { for (event_num = day_view->events[day]->len - 1; event_num >= 0; @@ -1293,29 +1367,6 @@ e_day_view_foreach_event_with_uid (EDayView *day_view, } -/* This removes all the events associated with the given uid. Note that for - recurring events there may be more than one. If any events are found and - removed we need to layout the events again. */ -void -e_day_view_remove_event (EDayView *day_view, - const gchar *uid) -{ - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - -#if 1 - g_print ("In e_day_view_remove_event day_view:%p uid:%s\n", - day_view, uid); -#endif - - e_day_view_foreach_event_with_uid (day_view, uid, - e_day_view_remove_event_cb, NULL); - - e_day_view_check_layout (day_view); - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - static gboolean e_day_view_remove_event_cb (EDayView *day_view, gint day, @@ -1369,7 +1420,7 @@ e_day_view_update_event_label (EDayView *day_view, gboolean free_text = FALSE, editing_event = FALSE; gint offset, start_minute, end_minute; CalComponentText summary; - + event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); @@ -1416,7 +1467,7 @@ e_day_view_update_long_event_label (EDayView *day_view, { EDayViewEvent *event; CalComponentText summary; - + event = &g_array_index (day_view->long_events, EDayViewEvent, event_num); @@ -1487,7 +1538,7 @@ e_day_view_find_event_from_uid (EDayView *day_view, EDayViewEvent *event; gint day, event_num; const char *u; - + for (day = 0; day < day_view->days_shown; day++) { for (event_num = 0; event_num < day_view->events[day]->len; event_num++) { @@ -1943,7 +1994,7 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget, return TRUE; } - + /* Convert the coords to the main canvas window, or return if the window is not found. */ if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) event, @@ -2003,16 +2054,16 @@ e_day_view_on_time_canvas_button_press (GtkWidget *widget, if (event->button == 4 || event->button == 5) { GtkAdjustment *adj = GTK_LAYOUT (day_view->main_canvas)->vadjustment; gfloat new_value; - + new_value = adj->value + ((event->button == 4) ? -adj->page_increment / 2: adj->page_increment / 2); new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); gtk_adjustment_set_value (adj, new_value); - + return TRUE; } - + return FALSE; } @@ -2405,13 +2456,13 @@ e_day_view_on_new_appointment (GtkWidget *widget, gpointer data) CalComponentDateTime date; time_t dtstart, dtend; struct icaltimetype itt; - + day_view = E_DAY_VIEW (data); comp = cal_component_new (); cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); e_day_view_get_selected_time_range (day_view, &dtstart, &dtend); - + date.value = &itt; date.tzid = NULL; @@ -2470,7 +2521,7 @@ e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data) cal_component_set_exdate_list (comp, list); cal_component_free_exdate_list (list); - if (!cal_client_update_object (day_view->calendar->client, comp)) + if (!cal_client_update_object (day_view->client, comp)) g_message ("e_day_view_on_delete_occurrence(): Could not update the object!"); gtk_object_unref (GTK_OBJECT (comp)); @@ -2483,7 +2534,7 @@ e_day_view_on_delete_appointment (GtkWidget *widget, gpointer data) EDayView *day_view; EDayViewEvent *event; const char *uid; - + day_view = E_DAY_VIEW (data); event = e_day_view_get_popup_menu_event (day_view); @@ -2494,7 +2545,7 @@ e_day_view_on_delete_appointment (GtkWidget *widget, gpointer data) e_day_view_stop_editing_event (day_view); cal_component_get_uid (event->comp, &uid); - if (!cal_client_remove_object (day_view->calendar->client, uid)) + if (!cal_client_remove_object (day_view->client, uid)) g_message ("e_day_view_on_delete_appointment(): Could not remove the object!"); } @@ -2533,7 +2584,7 @@ e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) cal_component_set_exdate_list (new_comp, NULL); cal_component_set_exrule_list (new_comp, NULL); - date = g_new0 (CalComponentDateTime, 1); + date = g_new0 (CalComponentDateTime, 1); date->value = g_new (struct icaltimetype, 1); *date->value = icaltime_from_timet (event->start, FALSE, TRUE); @@ -2542,16 +2593,16 @@ e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) cal_component_set_dtend (new_comp, date); cal_component_free_datetime (date); - + /* Now update both CalComponents. Note that we do this last since at * present the updates happen synchronously so our event may disappear. */ - if (!cal_client_update_object (day_view->calendar->client, comp)) + if (!cal_client_update_object (day_view->client, comp)) g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!"); gtk_object_unref (GTK_OBJECT (comp)); - if (!cal_client_update_object (day_view->calendar->client, new_comp)) + if (!cal_client_update_object (day_view->client, new_comp)) g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!"); gtk_object_unref (GTK_OBJECT (new_comp)); @@ -2712,8 +2763,8 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget, cursor = day_view->normal_cursor; /* Recurring events can't be resized. */ - if (event && - !(cal_component_has_rrules (event->comp) + if (event && + !(cal_component_has_rrules (event->comp) && cal_component_has_rdates (event->comp))) { switch (pos) { case E_DAY_VIEW_POS_LEFT_EDGE: @@ -2819,7 +2870,7 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget, cursor = day_view->normal_cursor; /* Recurring events can't be resized. */ - if (event && + if (event && !(cal_component_has_rrules (event->comp) && cal_component_has_rdates (event->comp))) { switch (pos) { @@ -3045,7 +3096,7 @@ e_day_view_finish_long_event_resize (EDayView *day_view) CalComponent *comp; CalComponentDateTime date; time_t dt; - + event_num = day_view->resize_event_num; event = &g_array_index (day_view->long_events, EDayViewEvent, event_num); @@ -3066,12 +3117,12 @@ e_day_view_finish_long_event_resize (EDayView *day_view) cal_component_set_dtend (comp, &date); } g_free (date.value); - + gnome_canvas_item_hide (day_view->resize_long_event_rect_item); day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE; - if (!cal_client_update_object (day_view->calendar->client, comp)) + if (!cal_client_update_object (day_view->client, comp)) g_message ("e_day_view_finish_long_event_resize(): Could not update the object!"); gtk_object_unref (GTK_OBJECT (comp)); @@ -3110,7 +3161,7 @@ e_day_view_finish_resize (EDayView *day_view) cal_component_set_dtend (comp, &date); } g_free (date.value); - + gnome_canvas_item_hide (day_view->resize_rect_item); gnome_canvas_item_hide (day_view->resize_bar_item); @@ -3122,7 +3173,7 @@ e_day_view_finish_resize (EDayView *day_view) day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE; - if (!cal_client_update_object (day_view->calendar->client, comp)) + if (!cal_client_update_object (day_view->client, comp)) g_message ("e_day_view_finish_resize(): Could not update the object!"); gtk_object_unref (GTK_OBJECT (comp)); @@ -3179,16 +3230,19 @@ e_day_view_reload_events (EDayView *day_view) day_view->pressed_event_day = -1; day_view->drag_event_day = -1; + if (!(day_view->client && cal_client_is_loaded (day_view->client))) + return; + /* If both lower & upper are 0, then the time range hasn't been set, so we don't try to load any events. */ if (day_view->calendar && (day_view->lower != 0 || day_view->upper != 0)) { - cal_client_generate_instances (day_view->calendar->client, + cal_client_generate_instances (day_view->client, CALOBJ_TYPE_EVENT, day_view->lower, day_view->upper, e_day_view_add_event, - day_view); + day_view); } /* We need to do this to make sure the top canvas is resized. */ @@ -4020,7 +4074,7 @@ e_day_view_key_press (GtkWidget *widget, GdkEventKey *event) gboolean stop_emission; time_t dtstart, dtend; const char *uid; - + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (E_IS_DAY_VIEW (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); @@ -4104,6 +4158,7 @@ e_day_view_key_press (GtkWidget *widget, GdkEventKey *event) /* Add a new event covering the selected range. Note that user_name is a global variable. */ comp = cal_component_new (); + cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); e_day_view_get_selected_time_range (day_view, &dtstart, &dtend); @@ -4125,7 +4180,7 @@ e_day_view_key_press (GtkWidget *widget, GdkEventKey *event) g_warning ("Couldn't find event to start editing.\n"); } - if (!cal_client_update_object (day_view->calendar->client, comp)) + if (!cal_client_update_object (day_view->client, comp)) g_message ("e_day_view_key_press(): Could not update the object!"); gtk_object_unref (GTK_OBJECT (comp)); @@ -4556,7 +4611,7 @@ e_day_view_on_editing_stopped (EDayView *day_view, gchar *text = NULL; CalComponentText summary; const char *uid; - + /* Note: the item we are passed here isn't reliable, so we just stop the edit of whatever item was being edited. We also receive this event twice for some reason. */ @@ -4614,8 +4669,8 @@ e_day_view_on_editing_stopped (EDayView *day_view, cal_component_set_summary (event->comp, &summary); g_free (text); - - if (!cal_client_update_object (day_view->calendar->client, event->comp)) + + if (!cal_client_update_object (day_view->client, event->comp)) g_message ("e_day_view_on_editing_stopped(): Could not update the object!"); } @@ -5202,15 +5257,15 @@ e_day_view_update_top_canvas_drag (EDayView *day_view, if (!(day_view->drag_long_event_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { CalComponentText summary; - + cal_component_get_summary (event->comp, &summary); if (event) { cal_component_get_summary (event->comp, &summary); text = g_strdup (summary.value); - } else { + } else { text = NULL; } - + gnome_canvas_item_set (day_view->drag_long_event_item, "text", text ? text : "", NULL); @@ -5364,14 +5419,14 @@ e_day_view_update_main_canvas_drag (EDayView *day_view, set the text then. */ if (!(day_view->drag_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { CalComponentText summary; - + if (event) { cal_component_get_summary (event->comp, &summary); text = g_strdup (summary.value); - } else { + } else { text = NULL; } - + gnome_canvas_item_set (day_view->drag_item, "text", text ? text : "", NULL); @@ -5507,7 +5562,7 @@ e_day_view_on_drag_data_get (GtkWidget *widget, event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); - + cal_component_get_uid (event->comp, &event_uid); g_return_if_fail (event_uid != NULL); @@ -5537,7 +5592,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, CalComponent *comp; CalComponentDateTime date; time_t dt; - + if ((data->length >= 0) && (data->format == 8)) { pos = e_day_view_convert_position_in_top_canvas (day_view, x, y, &day, @@ -5547,7 +5602,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, num_days = 1; start_offset = 0; end_offset = -1; - + if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) { event = &g_array_index (day_view->long_events, EDayViewEvent, day_view->drag_event_num); @@ -5573,7 +5628,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, event_uid = data->data; cal_component_get_uid (event->comp, &uid); - + if (!event_uid || !uid || strcmp (event_uid, uid)) g_warning ("Unexpected event UID"); @@ -5581,7 +5636,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, don't want to change the original comp here. Otherwise we would not detect that the event's time had changed in the "update_event" callback. */ - + comp = cal_component_clone (event->comp); date.value = g_new (struct icaltimetype, 1); @@ -5595,7 +5650,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, *date.value = icaltime_from_timet (dt, FALSE, TRUE); cal_component_set_dtend (comp, &date); g_free (date.value); - + gtk_drag_finish (context, TRUE, TRUE, time); /* Reset this since it will be invalid. */ @@ -5606,12 +5661,12 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, if (event->canvas_item) gnome_canvas_item_show (event->canvas_item); - if (!cal_client_update_object (day_view->calendar->client, comp)) + if (!cal_client_update_object (day_view->client, comp)) g_message ("e_day_view_on_top_canvas_drag_data_received(): Could " "not update the object!"); gtk_object_unref (GTK_OBJECT (comp)); - + return; } } @@ -5638,7 +5693,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, CalComponent *comp; CalComponentDateTime date; time_t dt; - + gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), &scroll_x, &scroll_y); x += scroll_x; @@ -5653,7 +5708,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, num_rows = 1; start_offset = 0; end_offset = 0; - + if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) { event = &g_array_index (day_view->long_events, EDayViewEvent, day_view->drag_event_num); @@ -5694,7 +5749,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, *date.value = icaltime_from_timet (dt, FALSE, TRUE); cal_component_set_dtend (comp, &date); g_free (date.value); - + gtk_drag_finish (context, TRUE, TRUE, time); /* Reset this since it will be invalid. */ @@ -5705,20 +5760,15 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, if (event->canvas_item) gnome_canvas_item_show (event->canvas_item); - if (!cal_client_update_object (day_view->calendar->client, comp)) + if (!cal_client_update_object (day_view->client, comp)) g_message ("e_day_view_on_main_canvas_drag_data_received(): " "Could not update the object!"); gtk_object_unref (GTK_OBJECT (comp)); - + return; } } gtk_drag_finish (context, FALSE, FALSE, time); } - - - - - diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h index 955ef0541c..379699accd 100644 --- a/calendar/gui/e-day-view.h +++ b/calendar/gui/e-day-view.h @@ -188,6 +188,9 @@ struct _EDayView /* The calendar we are associated with. */ GnomeCalendar *calendar; + /* Calendar client object we are monitoring */ + CalClient *client; + /* The start and end of the day shown. */ time_t lower; time_t upper; @@ -414,6 +417,9 @@ GtkWidget* e_day_view_new (void); void e_day_view_set_calendar (EDayView *day_view, GnomeCalendar *calendar); +void e_day_view_set_cal_client (EDayView *day_view, + CalClient *client); + /* This sets the selected time range. The EDayView will show the day or week corresponding to the start time. If the start_time & end_time are not equal and are both visible in the view, then the selection is set to those times, @@ -427,18 +433,6 @@ void e_day_view_get_selected_time_range (EDayView *day_view, time_t *start_time, time_t *end_time); -/* This reloads all calendar events. */ -void e_day_view_update_all_events (EDayView *day_view); - -/* This is called when one event has been added or updated. */ -void e_day_view_update_event (EDayView *day_view, - const gchar *uid); - -/* This removes all the events associated with the given uid. Note that for - recurring events there may be more than one. If any events are found and - removed we need to layout the events again. */ -void e_day_view_remove_event (EDayView *day_view, - const gchar *uid); /* The number of days shown in the EDayView, from 1 to 7. This is normally either 1 or 5 (for the Work-Week view). */ diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index ffaaddb3e5..12d0051e2a 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -242,6 +242,7 @@ e_week_view_init (EWeekView *week_view) colormap = gtk_widget_get_colormap (GTK_WIDGET (week_view)); week_view->calendar = NULL; + week_view->client = NULL; week_view->events = g_array_new (FALSE, FALSE, sizeof (EWeekViewEvent)); @@ -415,6 +416,12 @@ e_week_view_destroy (GtkObject *object) week_view = E_WEEK_VIEW (object); + if (week_view->client) { + gtk_signal_disconnect_by_data (GTK_OBJECT (week_view->client), week_view); + gtk_object_unref (GTK_OBJECT (week_view->client)); + week_view->client = NULL; + } + /* FIXME: free the colors. In EDayView as well. */ /* FIXME: free the events and the spans. In EDayView as well? */ @@ -781,6 +788,159 @@ e_week_view_set_calendar (EWeekView *week_view, } +/* Callback used when the calendar client finishes loading */ +static void +cal_loaded_cb (CalClient *client, CalClientLoadStatus status, gpointer data) +{ + EWeekView *week_view; + + week_view = E_WEEK_VIEW (data); + + if (status != CAL_CLIENT_LOAD_SUCCESS) + return; + + e_week_view_reload_events (week_view); +} + +/* Callback used when the calendar client tells us that an object changed */ +static void +obj_updated_cb (CalClient *client, const char *uid, gpointer data) +{ + EWeekView *week_view; + gint event_num, num_days; + CalComponent *comp; + CalClientGetStatus status; + + week_view = E_WEEK_VIEW (data); + + /* If we don't have a valid date set yet, just return. */ + if (!g_date_valid (&week_view->first_day_shown)) + return; + + /* Get the event from the server. */ + status = cal_client_get_object (week_view->client, uid, &comp); + + switch (status) { + case CAL_CLIENT_GET_SUCCESS: + /* Everything is fine */ + break; + + case CAL_CLIENT_GET_SYNTAX_ERROR: + g_message ("obj_updated_cb(): Syntax error when getting object `%s'", uid); + return; + + case CAL_CLIENT_GET_NOT_FOUND: + /* The object is no longer in the server, so do nothing */ + return; + } + + /* We only care about events. */ + if (cal_component_get_vtype (comp) != CAL_COMPONENT_EVENT) { + gtk_object_unref (GTK_OBJECT (comp)); + return; + } + + /* If the event already exists and the dates didn't change, we can + update the event fairly easily without changing the events arrays + or computing a new layout. */ + if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) { +#ifndef NO_WARNINGS +#warning "FIX ME" +#endif + /* Do this the long way every time for now */ +#if 0 + event = &g_array_index (week_view->events, EWeekViewEvent, + event_num); + + if (ical_object_compare_dates (event->ico, ico)) { + e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_update_event_cb, comp); + gtk_object_unref (GTK_OBJECT (comp)); + gtk_widget_queue_draw (week_view->main_canvas); + return; + } +#endif + /* The dates have changed, so we need to remove the + old occurrrences before adding the new ones. */ + e_week_view_foreach_event_with_uid (week_view, uid, + e_week_view_remove_event_cb, + NULL); + } + + /* Add the occurrences of the event. */ + num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; + + cal_recur_generate_instances (comp, + week_view->day_starts[0], + week_view->day_starts[num_days], + e_week_view_add_event, + week_view); + + gtk_object_unref (GTK_OBJECT (comp)); + + e_week_view_check_layout (week_view); + + gtk_widget_queue_draw (week_view->main_canvas); +} + +/* Callback used when the calendar client tells us that an object was removed */ +static void +obj_removed_cb (CalClient *client, const char *uid, gpointer data) +{ + EWeekView *week_view; + + week_view = E_WEEK_VIEW (data); + + e_week_view_foreach_event_with_uid (week_view, uid, + e_week_view_remove_event_cb, NULL); + + e_week_view_check_layout (week_view); + gtk_widget_queue_draw (week_view->main_canvas); +} + + +/** + * e_week_view_set_cal_client: + * @week_view: A week view. + * @client: A calendar client interface object. + * + * Sets the calendar client interface object that a week view will monitor. + **/ +void +e_week_view_set_cal_client (EWeekView *week_view, + CalClient *client) +{ + g_return_if_fail (week_view != NULL); + g_return_if_fail (E_IS_WEEK_VIEW (week_view)); + + if (client == week_view->client) + return; + + if (client) + g_return_if_fail (IS_CAL_CLIENT (client)); + + if (client) + gtk_object_ref (GTK_OBJECT (client)); + + if (week_view->client) { + gtk_signal_disconnect_by_data (GTK_OBJECT (week_view->client), week_view); + gtk_object_unref (GTK_OBJECT (week_view->client)); + } + + week_view->client = client; + + if (week_view->client) { + gtk_signal_connect (GTK_OBJECT (week_view->client), "cal_loaded", + GTK_SIGNAL_FUNC (cal_loaded_cb), week_view); + gtk_signal_connect (GTK_OBJECT (week_view->client), "obj_updated", + GTK_SIGNAL_FUNC (obj_updated_cb), week_view); + gtk_signal_connect (GTK_OBJECT (week_view->client), "obj_removed", + GTK_SIGNAL_FUNC (obj_removed_cb), week_view); + } + + e_week_view_reload_events (week_view); +} + + /* This sets the selected time range. The EWeekView will show the corresponding month and the days between start_time and end_time will be selected. To select a single day, use the same value for start_time & end_time. */ @@ -986,98 +1146,6 @@ e_week_view_set_compress_weekend (EWeekView *week_view, } -/* This reloads all calendar events. */ -void -e_week_view_update_all_events (EWeekView *week_view) -{ - e_week_view_reload_events (week_view); -} - - -/* This is called when one event has been added or updated. */ -void -e_week_view_update_event (EWeekView *week_view, - const gchar *uid) -{ - gint event_num, num_days; - CalComponent *comp; - CalClientGetStatus status; - - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - -#if 0 - g_print ("In e_week_view_update_event\n"); -#endif - - /* If we don't have a calendar or valid date set yet, just return. */ - if (!week_view->calendar - || !g_date_valid (&week_view->first_day_shown)) - return; - - /* Get the event from the server. */ - status = cal_client_get_object (week_view->calendar->client, uid, &comp); - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - /* Do nothing. */ - break; - case CAL_CLIENT_GET_SYNTAX_ERROR: - g_warning ("syntax error uid=%s\n", uid); - return; - case CAL_CLIENT_GET_NOT_FOUND: - g_warning ("obj not found uid=%s\n", uid); - return; - } - - /* We only care about events. */ - if (comp && cal_component_get_vtype (comp) != CAL_COMPONENT_EVENT) { - gtk_object_unref (GTK_OBJECT (comp)); - return; - } - - /* If the event already exists and the dates didn't change, we can - update the event fairly easily without changing the events arrays - or computing a new layout. */ - if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) { -#ifndef NO_WARNINGS -#warning "FIX ME" -#endif - /* Do this the long way every time for now */ -#if 0 - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - - if (ical_object_compare_dates (event->ico, ico)) { - e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_update_event_cb, comp); - gtk_object_unref (GTK_OBJECT (comp)); - gtk_widget_queue_draw (week_view->main_canvas); - return; - } -#endif - /* The dates have changed, so we need to remove the - old occurrrences before adding the new ones. */ - e_week_view_foreach_event_with_uid (week_view, uid, - e_week_view_remove_event_cb, - NULL); - } - - /* Add the occurrences of the event. */ - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - - cal_recur_generate_instances (comp, - week_view->day_starts[0], - week_view->day_starts[num_days], - e_week_view_add_event, - week_view); - - gtk_object_unref (GTK_OBJECT (comp)); - - e_week_view_check_layout (week_view); - - gtk_widget_queue_draw (week_view->main_canvas); -} - - #ifndef NO_WARNINGS static gboolean e_week_view_update_event_cb (EWeekView *week_view, @@ -1157,23 +1225,6 @@ e_week_view_foreach_event_with_uid (EWeekView *week_view, } -/* This removes all the events associated with the given uid. Note that for - recurring events there may be more than one. If any events are found and - removed we need to layout the events again. */ -void -e_week_view_remove_event (EWeekView *week_view, - const gchar *uid) -{ - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - e_week_view_foreach_event_with_uid (week_view, uid, - e_week_view_remove_event_cb, NULL); - - e_week_view_check_layout (week_view); - gtk_widget_queue_draw (week_view->main_canvas); -} - - static gboolean e_week_view_remove_event_cb (EWeekView *week_view, gint event_num, @@ -1572,12 +1623,15 @@ e_week_view_reload_events (EWeekView *week_view) e_week_view_free_events (week_view); + if (!(week_view->client && cal_client_is_loaded (week_view->client))) + return; + if (week_view->calendar && g_date_valid (&week_view->first_day_shown)) { num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - cal_client_generate_instances (week_view->calendar->client, + cal_client_generate_instances (week_view->client, CALOBJ_TYPE_EVENT, week_view->day_starts[0], week_view->day_starts[num_days], @@ -2492,7 +2546,7 @@ e_week_view_on_editing_stopped (EWeekView *week_view, cal_component_set_summary (event->comp, &summary); g_free (text); - if (!cal_client_update_object (week_view->calendar->client, event->comp)) + if (!cal_client_update_object (week_view->client, event->comp)) g_message ("e_week_view_on_editing_stopped(): Could not update the object!"); } @@ -2659,7 +2713,7 @@ e_week_view_key_press (GtkWidget *widget, GdkEventKey *event) g_warning ("Couldn't find event to start editing.\n"); } - if (!cal_client_update_object (week_view->calendar->client, comp)) + if (!cal_client_update_object (week_view->client, comp)) g_message ("e_week_view_key_press(): Could not update the object!"); gtk_object_unref (GTK_OBJECT (comp)); @@ -2818,7 +2872,7 @@ e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data) cal_component_set_exdate_list (comp, list); cal_component_free_exdate_list (list); - if (!cal_client_update_object (week_view->calendar->client, comp)) + if (!cal_client_update_object (week_view->client, comp)) g_message ("e_week_view_on_delete_occurrence(): Could not update the object!"); gtk_object_unref (GTK_OBJECT (comp)); @@ -2841,7 +2895,7 @@ e_week_view_on_delete_appointment (GtkWidget *widget, gpointer data) week_view->popup_event_num); cal_component_get_uid (event->comp, &uid); - if (!cal_client_remove_object (week_view->calendar->client, uid)) + if (!cal_client_remove_object (week_view->client, uid)) g_message ("e_week_view_on_delete_appointment(): Could not remove the object!"); } @@ -2896,12 +2950,12 @@ e_week_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) /* Now update both CalComponents. Note that we do this last since at present the updates happen synchronously so our event may disappear. */ - if (!cal_client_update_object (week_view->calendar->client, comp)) + if (!cal_client_update_object (week_view->client, comp)) g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!"); gtk_object_unref (GTK_OBJECT (comp)); - if (!cal_client_update_object (week_view->calendar->client, new_comp)) + if (!cal_client_update_object (week_view->client, new_comp)) g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!"); gtk_object_unref (GTK_OBJECT (new_comp)); diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index dc2b01e4ff..f27b5db336 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -168,6 +168,9 @@ struct _EWeekView /* The calendar we are associated with. */ GnomeCalendar *calendar; + /* Calendar client object we are monitoring */ + CalClient *client; + /* The array of EWeekViewEvent elements. */ GArray *events; gboolean events_sorted; @@ -309,6 +312,9 @@ GtkWidget* e_week_view_new (void); void e_week_view_set_calendar (EWeekView *week_view, GnomeCalendar *calendar); +void e_week_view_set_cal_client (EWeekView *week_view, + CalClient *client); + /* This sets the selected time range. The EWeekView will show the corresponding month and the days between start_time and end_time will be selected. To select a single day, use the same value for start_time & end_time. */ @@ -332,20 +338,6 @@ gboolean e_week_view_get_compress_weekend (EWeekView *week_view); void e_week_view_set_compress_weekend (EWeekView *week_view, gboolean compress); -/* This reloads all calendar events. */ -void e_week_view_update_all_events (EWeekView *week_view); - -/* This is called when one event has been added or updated. */ -void e_week_view_update_event (EWeekView *week_view, - const gchar *uid); - -/* This removes all the events associated with the given uid. Note that for - recurring events there may be more than one. If any events are found and - removed we need to layout the events again. */ -void e_week_view_remove_event (EWeekView *week_view, - const gchar *uid); - - /* * Internal functions called by the associated canvas items. */ diff --git a/calendar/gui/gncal-todo.c b/calendar/gui/gncal-todo.c index 3bd6839962..8f39c09411 100644 --- a/calendar/gui/gncal-todo.c +++ b/calendar/gui/gncal-todo.c @@ -1,20 +1,14 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* To-do widget for gncal * - * Copyright (C) 1998 The Free Software Foundation + * Copyright (C) 2000 The Free Software Foundation * - * Author: Federico Mena <quartic@gimp.org> + * Author: Federico Mena <federico@helixcode.com> */ #include <config.h> -#include <string.h> #include <gnome.h> -#include <cal-client/cal-client.h> -#include <cal-util/timeutil.h> #include "event-editor.h" #include "gncal-todo.h" -#include "calendar-commands.h" -#include "popup-menu.h" int todo_show_due_date = 0; int todo_show_priority = 0; @@ -32,31 +26,8 @@ gint todo_current_sort_type = GTK_SORT_ASCENDING; gboolean todo_style_changed =0; gboolean todo_list_autoresize = 1; gboolean todo_list_redraw_in_progess = 0; -static void gncal_todo_init (GncalTodo *todo); -guint -gncal_todo_get_type (void) -{ - static guint todo_type = 0; - - if (!todo_type) { - GtkTypeInfo todo_info = { - "GncalTodo", - sizeof (GncalTodo), - sizeof (GncalTodoClass), - (GtkClassInitFunc) NULL, - (GtkObjectInitFunc) gncal_todo_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - todo_type = gtk_type_unique (gtk_vbox_get_type (), &todo_info); - } - - return todo_type; -} - static void ok_button (GtkWidget *widget, GnomeDialog *dialog) { @@ -72,7 +43,7 @@ ok_button (GtkWidget *widget, GnomeDialog *dialog) gchar *t; time_t d; int p; - + comp = gtk_object_get_user_data (GTK_OBJECT (dialog)); cal_client = (CalClient*) (gtk_object_get_data (GTK_OBJECT (dialog), "cal_client")); @@ -83,9 +54,9 @@ ok_button (GtkWidget *widget, GnomeDialog *dialog) date.value = g_new0 (struct icaltimetype, 1); *date.value = icaltime_from_timet (d, 1, TRUE); cal_component_set_dtend (comp, &date); - + /* Summary */ - entry = GTK_EDITABLE (gtk_object_get_data (GTK_OBJECT (dialog), "summary_entry")); + entry = GTK_EDITABLE (gtk_object_get_data (GTK_OBJECT (dialog), "summary_entry")); t = gtk_editable_get_chars (entry, 0, -1); text->value = t; cal_component_set_summary (comp, text); @@ -104,7 +75,7 @@ ok_button (GtkWidget *widget, GnomeDialog *dialog) l = g_slist_append (l, text); cal_component_set_comment_list (comp, l); cal_component_free_text_list (l); - + if (!cal_client_update_object (cal_client, comp)) g_message ("ok_button(): Could not update the object!"); @@ -121,7 +92,7 @@ cancel_button (GtkWidget *widget, GnomeDialog *dialog) comp = gtk_object_get_user_data (GTK_OBJECT (dialog)); gtk_object_unref (GTK_OBJECT (comp)); - + gtk_widget_destroy (GTK_WIDGET (dialog)); } @@ -159,7 +130,7 @@ gncal_todo_edit (CalClient *client, CalComponent *comp) GSList *l; time_t d; gint *p; - + new = (CAL_COMPONENT_NO_TYPE == cal_component_get_vtype (comp)); if (new) cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); @@ -188,7 +159,7 @@ gncal_todo_edit (CalClient *client, CalComponent *comp) gtk_container_border_width (GTK_CONTAINER (pri_box), 4); gtk_box_pack_start(GTK_BOX (GNOME_DIALOG (dialog)->vbox), pri_box, FALSE, FALSE, 0); gtk_widget_show (pri_box); - + comment_box = gtk_hbox_new (FALSE, 4); gtk_container_border_width (GTK_CONTAINER (comment_box), 4); gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), comment_box, FALSE, FALSE, 0); @@ -235,7 +206,7 @@ gncal_todo_edit (CalClient *client, CalComponent *comp) gtk_spin_button_set_value (GTK_SPIN_BUTTON (pri_spin), (gfloat) *p); gtk_box_pack_start (GTK_BOX (pri_box), pri_spin, FALSE, FALSE, 0); gtk_widget_show (pri_spin); - + comment_sep = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX (comment_box), comment_sep, FALSE, FALSE, 0); gtk_widget_show(comment_sep); @@ -256,8 +227,8 @@ gncal_todo_edit (CalClient *client, CalComponent *comp) cal_component_get_comment_list (comp, &l); if (l) { CalComponentText text = *(CalComponentText*)l->data; - - gtk_text_insert(GTK_TEXT(comment_text), NULL, NULL, NULL, + + gtk_text_insert(GTK_TEXT(comment_text), NULL, NULL, NULL, text.value, strlen(text.value)); } cal_component_free_text_list (l); @@ -273,7 +244,7 @@ gncal_todo_edit (CalClient *client, CalComponent *comp) gtk_object_set_data (GTK_OBJECT (dialog), "due_date", due_entry); gtk_object_set_data (GTK_OBJECT (dialog), "priority", pri_spin); gtk_object_set_data (GTK_OBJECT (dialog), "comment", comment_text); - + gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0, (GtkSignalFunc) ok_button, dialog); gnome_dialog_button_connect (GNOME_DIALOG (dialog), 1, (GtkSignalFunc) cancel_button, dialog); @@ -288,677 +259,3 @@ gncal_todo_edit (CalClient *client, CalComponent *comp) gtk_widget_show (dialog); gtk_widget_grab_focus (entry); } - -static CalComponent * -get_clist_selected_comp (GtkCList *clist) -{ - gint sel; - - if (!clist->selection) - return NULL; - - sel = GPOINTER_TO_INT(clist->selection->data); - - return gtk_clist_get_row_data (clist, sel); -} - -static void -add_todo (GncalTodo *todo) -{ - CalComponent *comp; - - comp = cal_component_new (); - -#if 0 - gncal_todo_edit (todo, comp); -#endif - gtk_object_unref (GTK_OBJECT (comp)); -} - -static void -edit_todo (GncalTodo *todo) -{ - CalComponent *comp; - - comp = get_clist_selected_comp (todo->clist); - -#if 0 - gncal_todo_edit (todo, comp); -#endif -} - -static void -delete_todo (GncalTodo *todo) -{ - CalComponent *comp; - const char *uid; - - comp = get_clist_selected_comp (todo->clist); - cal_component_get_uid (comp, &uid); - - if (!cal_client_remove_object (todo->calendar->client, uid)) - g_message ("delete_todo(): Could not remove the object!"); -} - -static void -add_activated (GtkWidget *widget, GncalTodo *todo) -{ - GtkWidget *w; - - while ((w = gtk_grab_get_current ()) != NULL) - gtk_grab_remove (w); - - add_todo (todo); -} - -static void -edit_activated (GtkWidget *widget, GncalTodo *todo) -{ - GtkWidget *w; - - while ((w = gtk_grab_get_current ()) != NULL) - gtk_grab_remove (w); - - edit_todo (todo); -} - -static void -delete_activated (GtkWidget *widget, GncalTodo *todo) -{ - delete_todo (todo); -} - - -static void -clist_row_selected (GtkCList *clist, gint row, gint column, GdkEventButton *event, GncalTodo *todo) -{ - static struct menu_item items[] = { - { N_("Add to-do item..."), (GtkSignalFunc) add_activated, NULL, TRUE }, - { N_("Edit this item..."), (GtkSignalFunc) edit_activated, NULL, TRUE }, - { N_("Delete this item"), (GtkSignalFunc) delete_activated, NULL, TRUE } - }; - - int i; - - gtk_widget_set_sensitive (todo->edit_button, (todo->clist->selection != NULL)); - gtk_widget_set_sensitive (todo->delete_button, (todo->clist->selection != NULL)); - - if (!event) - return; - - switch (event->button) { - case 1: - if (event->type == GDK_2BUTTON_PRESS) - edit_todo (todo); - break; - - case 3: - for (i = 0; i < (sizeof (items) / sizeof (items[0])); i++) - items[i].data = todo; - - popup_menu (items, sizeof (items) / sizeof (items[0]), event); - break; - - default: - break; - } -} - -/* - * once we get a call back stating that a column - * has been resized never ever automatically resize again - */ -static void -column_resized (GtkWidget *widget, GncalTodo *todo) -{ - /* disabling autoresize of columns */ - if (todo_list_autoresize && !todo_list_redraw_in_progess){ - todo_list_autoresize = 0; - } -} - -/* - * restore the previously set settings for sorting the - * todo list - */ -static void -init_column_sorting (GtkCList *clist) -{ - - /* due date isn't shown so we can't sort by it */ - if (todo_current_sort_column == 1 && ! todo_show_due_date) - todo_current_sort_column = 0; - - clist->sort_type = todo_current_sort_type; - clist->sort_column = todo_current_sort_column; - - gtk_clist_set_sort_column (clist, todo_current_sort_column); - gtk_clist_sort (clist); -} - -static void -todo_click_column (GtkCList *clist, gint column, gpointer data) -{ - if (column == clist->sort_column) - { - if (clist->sort_type == GTK_SORT_ASCENDING) { - clist->sort_type = GTK_SORT_DESCENDING; - todo_current_sort_type = GTK_SORT_DESCENDING; - } else { - clist->sort_type = GTK_SORT_ASCENDING; - todo_current_sort_type = GTK_SORT_ASCENDING; - } - } - else { - gtk_clist_set_sort_column (clist, column); - todo_current_sort_column = column; - } - - gtk_clist_sort (clist); - - /* - * save the sorting preferences cause I hate to have the user - * click twice - */ - - gnome_config_set_int("/calendar/Todo/sort_column", todo_current_sort_column); - gnome_config_set_int("/calendar/Todo/sort_type", todo_current_sort_type); - gnome_config_sync(); -} - -static void -gncal_todo_init (GncalTodo *todo) -{ - GtkWidget *w; - GtkWidget *sw; - GtkWidget *hbox; - gchar *titles[4] = { - N_("Summary"), - N_("Due Date"), - N_("Priority"), - N_("Time Left") - }; - char *tmp[4]; - tmp[0] = _(titles[0]); - tmp[1] = _(titles[1]); - tmp[2] = _(titles[2]); - tmp[3] = _(titles[3]); - - gtk_box_set_spacing (GTK_BOX (todo), 4); - - /* Label */ - - w = gtk_label_new (_("To-do list")); - gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (todo), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Clist */ - - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start (GTK_BOX (todo), sw, TRUE, TRUE, 0); - gtk_widget_show (sw); - - - w = gtk_clist_new_with_titles(4, tmp); - - todo->clist = GTK_CLIST (w); - gtk_clist_set_selection_mode (todo->clist, GTK_SELECTION_BROWSE); - - gtk_signal_connect (GTK_OBJECT (todo->clist), "select_row", - (GtkSignalFunc) clist_row_selected, - todo); - gtk_clist_set_button_actions (todo->clist, 2, GTK_BUTTON_SELECTS); - gtk_signal_connect (GTK_OBJECT (todo->clist), "resize_column", - (GtkSignalFunc) column_resized, - todo); - gtk_signal_connect (GTK_OBJECT (todo->clist), "click_column", - (GtkSignalFunc) todo_click_column, NULL); - - gtk_container_add (GTK_CONTAINER (sw), w); - gtk_widget_show (w); - - /* Box for buttons */ - - hbox = gtk_hbox_new (TRUE, 4); - gtk_box_pack_start (GTK_BOX (todo), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - /* Add */ - - w = gtk_button_new_with_label (_("Add...")); - gtk_signal_connect (GTK_OBJECT (w), "clicked", - (GtkSignalFunc) add_activated, - todo); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); - gtk_widget_show (w); - - /* Edit */ - - w = gtk_button_new_with_label (_("Edit...")); - todo->edit_button = w; - gtk_widget_set_sensitive (w, FALSE); - gtk_signal_connect (GTK_OBJECT (w), "clicked", - (GtkSignalFunc) edit_activated, - todo); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); - gtk_widget_show (w); - - /* Delete */ - - w = gtk_button_new_with_label (_("Delete")); - todo->delete_button = w; - gtk_widget_set_sensitive (w, FALSE); - gtk_signal_connect (GTK_OBJECT (w), "clicked", - (GtkSignalFunc) delete_activated, - todo); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); - gtk_widget_show (w); -} - -GtkWidget * -gncal_todo_new (GnomeCalendar *calendar) -{ - GncalTodo *todo; - - g_return_val_if_fail (calendar != NULL, NULL); - - todo = gtk_type_new (gncal_todo_get_type ()); - - todo->calendar = calendar; - - gncal_todo_update (todo, NULL, 0); - - return GTK_WIDGET (todo); -} - -static char * -convert_time_t_to_char (time_t t) -{ - char buf[100]; - struct tm tm; - - tm = *localtime (&t); - strftime(buf, sizeof (buf), "%m/%d/%Y", &tm); - - return g_strdup (buf); -} - - -enum todo_styles { - TODO_STYLE_OVERDUE, - TODO_STYLE_DUE_TODAY, - TODO_STYLE_NOT_DUE -}; - - -enum todo_status { - TODO_ITEM_DSTATUS_NOT_DUE_YET, - TODO_ITEM_DSTATUS_DUE_TODAY, - TODO_ITEM_DSTATUS_OVERDUE, - TODO_ITEM_DSTATUS_LAST_DUE_STATUS -}; -typedef enum todo_status todo_status; - -static GtkStyle * -make_todo_style(GncalTodo *todo, todo_status style_type) -{ - GtkStyle *style = NULL; - GdkColor style_color; - int color_prop = 0; - switch(style_type) { - case TODO_ITEM_DSTATUS_NOT_DUE_YET: - color_prop = COLOR_PROP_TODO_NOT_DUE_YET; - break; - case TODO_ITEM_DSTATUS_DUE_TODAY: - color_prop = COLOR_PROP_TODO_DUE_TODAY; - break; - case TODO_ITEM_DSTATUS_OVERDUE: - color_prop = COLOR_PROP_TODO_OVERDUE; - break; - case TODO_ITEM_DSTATUS_LAST_DUE_STATUS: - } - - style_color.red = color_props[color_prop].r; - style_color.green = color_props[color_prop].g; - style_color.blue = color_props[color_prop].b; - - style = gtk_style_copy (GTK_WIDGET (todo->clist)->style); - style->base[GTK_STATE_NORMAL] = style_color; - return style; -} - - -static -todo_status todo_item_due_status(time_t *todo_due_time) { - struct tm due_tm_time; - struct tm current_time; - struct tm *temp_tm; - time_t current_time_val = time(NULL); - temp_tm = localtime(todo_due_time); - /* make a copy so it dosen't get over written */ - memcpy(&due_tm_time, temp_tm, sizeof(struct tm)); - - - temp_tm = localtime(¤t_time_val); - memcpy(¤t_time, temp_tm, sizeof(struct tm)); - - if(due_tm_time.tm_mon == current_time.tm_mon && - due_tm_time.tm_mday == current_time.tm_mday && - due_tm_time.tm_year == current_time.tm_year) { - return TODO_ITEM_DSTATUS_DUE_TODAY; - } - - if((*todo_due_time) < current_time_val) { - return TODO_ITEM_DSTATUS_OVERDUE; - } - - return TODO_ITEM_DSTATUS_NOT_DUE_YET; -} - - -enum todo_remaining_time_form { - TODO_ITEM_REMAINING_WEEKS, - TODO_ITEM_REMAINING_DAYS, - TODO_ITEM_REMAINING_HOURS, - TODO_ITEM_REMAINING_MINUTES, - TODO_ITEM_REMAINING_SECONDS -}; -typedef enum todo_remaining_time_form todo_remaining_time_form; - - -static void -insert_in_clist (GncalTodo *todo, CalComponent *comp) -{ - int i; - CalComponentText t; - CalComponentDateTime date; - char *text[4]; - char time_remaining_buffer[100]; - time_t time_remain; - todo_remaining_time_form time_remaining_form; - int sec_in_week = 3600*7*24; - int sec_in_day = 3600*24; - int sec_in_hour = 3600; - int sec_in_minute = 60; - int weeks = 0; - int days = 0; - int hours = 0; - int minutes = 0; - int seconds = 0; - int *p; - time_t d; - - /* an array for the styles of items */ - static GtkStyle *dstatus_styles[TODO_ITEM_DSTATUS_LAST_DUE_STATUS]; - /* we want to remake the styles when the status is changed, - also we need to check for the null value in the pointer so we init them - at startup */ - if (todo_style_changed || !dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]) { - g_free(dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]); - g_free(dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE]); - g_free(dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY]); - - dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET] = make_todo_style(todo, TODO_ITEM_DSTATUS_NOT_DUE_YET); - dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE] = make_todo_style(todo, TODO_ITEM_DSTATUS_OVERDUE); - dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY] = make_todo_style(todo, TODO_ITEM_DSTATUS_DUE_TODAY); - - todo_style_changed = 0; - } - - cal_component_get_summary (comp, &t); - text[0] = g_strdup (t.value); - - if(todo_show_time_remaining) { - memset(time_remaining_buffer, 0, 100); - /* we need to make a string that represents the amount of time remaining - before this task is due */ - - /* for right now all I'll do is up to the hours. */ - cal_component_get_dtend (comp, &date); - time_remain = icaltime_as_timet (*date.value) - time (NULL); - if(time_remain < 0) { - text[3] = "Overdue!"; - } - else { - - /* lets determine a decent denomination to display */ - if(time_remain / (sec_in_week)) - { - /* we have weeks available */ - time_remaining_form = TODO_ITEM_REMAINING_WEEKS; - weeks = time_remain / sec_in_week; - days = (time_remain % (sec_in_week))/sec_in_day; - } - else if(time_remain / (sec_in_day)) - { - /* we have days available */ - time_remaining_form = TODO_ITEM_REMAINING_DAYS; - days = time_remain / sec_in_day; - hours = (time_remain % sec_in_day)/sec_in_hour; - } - else if(time_remain / (sec_in_hour)) - { - /* we have hours available */ - time_remaining_form = TODO_ITEM_REMAINING_HOURS; - hours = time_remain /sec_in_hour; - minutes = (time_remain % sec_in_hour) / sec_in_minute; - } - else if(time_remain / sec_in_minute) - { - time_remaining_form = TODO_ITEM_REMAINING_MINUTES; - minutes = time_remain / sec_in_minute; - seconds = time_remain % sec_in_minute; - } - else - { - time_remaining_form = TODO_ITEM_REMAINING_SECONDS; - seconds = time_remain; - } - - switch(time_remaining_form) - { - case TODO_ITEM_REMAINING_WEEKS: - snprintf(time_remaining_buffer, 100, "%d %s %d %s", weeks, - (weeks > 1) ? _("Weeks") : _("Week"), - days, (days > 1) ? _("Days") : _("Day")); - break; - case TODO_ITEM_REMAINING_DAYS: - snprintf(time_remaining_buffer, 100, "%d %s %d %s", days, - (days > 1) ? _("Days") : _("Day"), - hours, (hours > 1) ? _("Hours") : _("Hour")); - break; - case TODO_ITEM_REMAINING_HOURS: - snprintf(time_remaining_buffer, 100, "%d %s %d %s", hours, - (hours > 1) ? _("Hours") : _("Hour"), - minutes, (minutes > 1) ? _("Minutes") : _("Minute")); - break; - case TODO_ITEM_REMAINING_MINUTES: - snprintf(time_remaining_buffer, 100, "%d %s %d %s", minutes, - (minutes > 1) ? _("Minutes") : _("Minute"), - seconds, (seconds > 1) ? _("Seconds") : _("Second")); - break; - case TODO_ITEM_REMAINING_SECONDS: - snprintf(time_remaining_buffer, 100, "%d %s", seconds, - (seconds > 1) ? _("Seconds") : _("Second")); - break; - } - text[3] = g_strdup(time_remaining_buffer); - todo->data_ptrs = g_slist_append(todo->data_ptrs, text[3]); - } - - } - else { - text[3] = "Loose penguini!"; - } - /* - * right now column 0 will be the summary - * and column 1 will be the due date. - * WISH: this should be able to be changed on the fly - */ - - cal_component_get_dtend (comp, &date); - d = icaltime_as_timet (*date.value); - if(todo_show_due_date) - { - text[1] = convert_time_t_to_char (d); - /* Append the data's pointer so later it can be properly freed */ - todo->data_ptrs = g_slist_append (todo->data_ptrs, text[1]); - } - else - text[1] = NULL; - - cal_component_get_priority (comp, &p); - if(p && todo_show_priority) - { - text[2] = g_strdup_printf ("%d", *p); - todo->data_ptrs = g_slist_append (todo->data_ptrs, text[2]); - } - else - text[2] = NULL; - - i = gtk_clist_append (todo->clist, text); - - gtk_clist_set_row_data_full (todo->clist, i, comp, - (GtkDestroyNotify) gtk_object_ref); - gtk_object_ref (GTK_OBJECT (comp)); - - /* - * determine if the task is overdue.. - * if so mark with the apropriate style - */ - - switch(todo_item_due_status(&d)) { - case TODO_ITEM_DSTATUS_NOT_DUE_YET: - if(todo_item_dstatus_highlight_not_due_yet) - { - gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]); - } - break; - case TODO_ITEM_DSTATUS_DUE_TODAY: - if(todo_item_dstatus_highlight_due_today) - { - gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY]); - } - break; - case TODO_ITEM_DSTATUS_OVERDUE: - if(todo_item_dstatus_highlight_overdue) - { - gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE]); - } - break; - case TODO_ITEM_DSTATUS_LAST_DUE_STATUS: - } - - /* keep the list in order */ - gtk_clist_sort (todo->clist); -} - - -void -gncal_todo_update (GncalTodo *todo, CalComponent *comp, int flags) -{ - GSList *current_list; - CalClientGetStatus status; - GList *l, *uids; - - g_return_if_fail (todo != NULL); - g_return_if_fail (GNCAL_IS_TODO (todo)); - - /* - * shut down the resize handler cause we are playing with the list. - * In otherwords turn off the event handler - */ - todo_list_redraw_in_progess =1; - - /* freeze the list */ - gtk_clist_freeze (todo->clist); - init_column_sorting (todo->clist); - - /* - * before here we have to free some of the memory that - * stores the due date, or else we have a memory leak. - * luckily all of the pointers are stored in todo->data_ptrs; - */ - - /* check on the columns that we should display */ - /* check for due date */ - - if(todo_show_due_date) { - gtk_clist_set_column_visibility (todo->clist, 1, 1); - } - else { - gtk_clist_set_column_visibility (todo->clist, 1, 0); - } - - if(todo_show_time_remaining) { - gtk_clist_set_column_visibility (todo->clist, 3, 1); - } - else { - gtk_clist_set_column_visibility (todo->clist, 3, 0); - } - - - if(todo_show_priority) - gtk_clist_set_column_visibility (todo->clist, 2, 1); - else - gtk_clist_set_column_visibility (todo->clist, 2, 0); - - /* free the memory locations that were used in the previous display */ - for (current_list = todo->data_ptrs; - current_list != NULL; - current_list = g_slist_next(current_list)){ - g_free(current_list->data); - } - - /* free the list and clear out the pointer */ - g_slist_free(todo->data_ptrs); - todo->data_ptrs = NULL; - - gtk_clist_clear (todo->clist); - - - uids = cal_client_get_uids (todo->calendar->client, CAL_COMPONENT_TODO); - for (l = uids; l; l = l->next){ - char *uid = l->data; - CalComponent *comp; - - status = cal_client_get_object (todo->calendar->client, uid, - &comp); - - if (status == CAL_CLIENT_GET_SUCCESS) { - insert_in_clist (todo, comp); - gtk_object_unref (GTK_OBJECT (comp)); - } -#ifndef NO_WARNINGS -#warning "FIX ME" -#endif - /* else? */ - g_free (uid); - } - g_list_free (uids); - - /* if we are autoresizing then do it now */ - if(todo_list_autoresize && todo->clist->rows != 0) - gtk_clist_columns_autosize (todo->clist); - - gtk_clist_thaw (todo->clist); - - gtk_widget_set_sensitive (todo->edit_button, - (todo->clist->selection != NULL)); - gtk_widget_set_sensitive (todo->delete_button, - (todo->clist->selection != NULL)); - todo_list_redraw_in_progess = 0; -} - - - - - - - - - - - diff --git a/calendar/gui/gncal-todo.h b/calendar/gui/gncal-todo.h index 1102e32d77..a48f8ce47d 100644 --- a/calendar/gui/gncal-todo.h +++ b/calendar/gui/gncal-todo.h @@ -1,53 +1,21 @@ /* To-do widget for gncal * - * Copyright (C) 1998 The Free Software Foundation + * Copyright (C) 2000 The Free Software Foundation * - * Author: Federico Mena <quartic@gimp.org> + * Author: Federico Mena <federico@helixcode.com> */ #ifndef GNCAL_TODO_H #define GNCAL_TODO_H -#include <gtk/gtkclist.h> -#include <gtk/gtkvbox.h> #include <libgnome/gnome-defs.h> #include "gnome-cal.h" - BEGIN_GNOME_DECLS -#define GNCAL_TODO(obj) GTK_CHECK_CAST (obj, gncal_todo_get_type (), GncalTodo) -#define GNCAL_TODO_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_todo_get_type (), GncalTodoClass) -#define GNCAL_IS_TODO(obj) GTK_CHECK_TYPE (obj, gncal_todo_get_type ()) - - -typedef struct _GncalTodo GncalTodo; -typedef struct _GncalTodoClass GncalTodoClass; - -struct _GncalTodo { - GtkVBox vbox; - - GnomeCalendar *calendar; /* the calendar we are associated to */ - - GtkCList *clist; - - GtkWidget *edit_button; - GtkWidget *delete_button; - GSList *data_ptrs; -}; - -struct _GncalTodoClass { - GtkVBoxClass parent_class; -}; - - -guint gncal_todo_get_type (void); -GtkWidget *gncal_todo_new (GnomeCalendar *calendar); - -void gncal_todo_update (GncalTodo *todo, CalComponent *comp, int flags); +void gncal_todo_edit (CalClient *client, CalComponent *comp); -void gncal_todo_edit (CalClient *client, CalComponent *comp); END_GNOME_DECLS diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index c767ae59eb..ea61dafabc 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -204,11 +204,6 @@ setup_widgets (GnomeCalendar *gcal) gcal); /* The ToDo list. */ -#if 0 - gcal->todo = gncal_todo_new (gcal); - e_paned_pack2 (E_PANED (vpane), gcal->todo, TRUE, TRUE); - gtk_widget_show (gcal->todo); -#endif gcal->todo = e_calendar_table_new (); e_paned_pack2 (E_PANED (vpane), gcal->todo, TRUE, TRUE); @@ -220,6 +215,7 @@ setup_widgets (GnomeCalendar *gcal) /* The Day View. */ gcal->day_view = e_day_view_new (); e_day_view_set_calendar (E_DAY_VIEW (gcal->day_view), gcal); + e_day_view_set_cal_client (E_DAY_VIEW (gcal->day_view), gcal->client); gtk_widget_show (gcal->day_view); gtk_notebook_append_page (GTK_NOTEBOOK (gcal->sub_notebook), gcal->day_view, gtk_label_new ("")); @@ -228,6 +224,7 @@ setup_widgets (GnomeCalendar *gcal) gcal->work_week_view = e_day_view_new (); e_day_view_set_days_shown (E_DAY_VIEW (gcal->work_week_view), 5); e_day_view_set_calendar (E_DAY_VIEW (gcal->work_week_view), gcal); + e_day_view_set_cal_client (E_DAY_VIEW (gcal->work_week_view), gcal->client); gtk_widget_show (gcal->work_week_view); gtk_notebook_append_page (GTK_NOTEBOOK (gcal->sub_notebook), gcal->work_week_view, gtk_label_new ("")); @@ -235,6 +232,7 @@ setup_widgets (GnomeCalendar *gcal) /* The Week View. */ gcal->week_view = e_week_view_new (); e_week_view_set_calendar (E_WEEK_VIEW (gcal->week_view), gcal); + e_week_view_set_cal_client (E_WEEK_VIEW (gcal->week_view), gcal->client); gtk_widget_show (gcal->week_view); gtk_notebook_append_page (GTK_NOTEBOOK (gcal->sub_notebook), gcal->week_view, gtk_label_new ("")); @@ -242,6 +240,7 @@ setup_widgets (GnomeCalendar *gcal) /* The Month View. */ gcal->month_view = e_week_view_new (); e_week_view_set_calendar (E_WEEK_VIEW (gcal->month_view), gcal); + e_week_view_set_cal_client (E_WEEK_VIEW (gcal->month_view), gcal->client); e_week_view_set_display_month (E_WEEK_VIEW (gcal->month_view), TRUE); gtk_widget_show (gcal->month_view); gtk_notebook_append_page (GTK_NOTEBOOK (gcal->main_notebook), @@ -812,15 +811,6 @@ static void gnome_calendar_update_all (GnomeCalendar *cal) { load_alarms (cal); - - e_day_view_update_all_events (E_DAY_VIEW (cal->day_view)); - e_day_view_update_all_events (E_DAY_VIEW (cal->work_week_view)); - e_week_view_update_all_events (E_WEEK_VIEW (cal->week_view)); - e_week_view_update_all_events (E_WEEK_VIEW (cal->month_view)); - -#if 0 - gncal_todo_update (GNCAL_TODO (cal->todo), NULL, TRUE); -#endif gnome_calendar_tag_calendar (cal, cal->gtk_calendar); } @@ -880,23 +870,9 @@ gnome_calendar_object_updated_cb (GtkWidget *cal_client, const char *uid, GnomeCalendar *gcal) { - g_message ("gnome-cal: got object changed_cb, uid='%s'", - uid?uid:"<NULL>"); - remove_alarms_for_object (gcal, uid); add_alarms_for_object (gcal, uid); - /* FIXME: do we really want each view to reload the event itself? - Maybe we should keep track of events globally, maybe with ref - counts. We also need to sort out where they get freed. */ - e_day_view_update_event (E_DAY_VIEW (gcal->day_view), uid); - e_day_view_update_event (E_DAY_VIEW (gcal->work_week_view), uid); - e_week_view_update_event (E_WEEK_VIEW (gcal->week_view), uid); - e_week_view_update_event (E_WEEK_VIEW (gcal->month_view), uid); - -#if 0 - gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, TRUE); -#endif gnome_calendar_tag_calendar (gcal, gcal->gtk_calendar); } @@ -906,19 +882,8 @@ gnome_calendar_object_removed_cb (GtkWidget *cal_client, const char *uid, GnomeCalendar *gcal) { - g_message ("gnome-cal: got object removed _cb, uid='%s'", - uid?uid:"<NULL>"); - remove_alarms_for_object (gcal, uid); - e_day_view_remove_event (E_DAY_VIEW (gcal->day_view), uid); - e_day_view_remove_event (E_DAY_VIEW (gcal->work_week_view), uid); - e_week_view_remove_event (E_WEEK_VIEW (gcal->week_view), uid); - e_week_view_remove_event (E_WEEK_VIEW (gcal->month_view), uid); - -#if 0 - gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, CHANGE_ALL); -#endif gnome_calendar_tag_calendar (gcal, gcal->gtk_calendar); } @@ -969,13 +934,10 @@ gnome_calendar_load_cb (CalClient *cal_client, switch (status) { case CAL_CLIENT_LOAD_SUCCESS: gnome_calendar_update_all (locd->gcal); - g_message ("gnome_calendar_load_cb: success"); break; case CAL_CLIENT_LOAD_ERROR: - g_message ("gnome_calendar_load_cb: load error"); if (locd->gcom == CALENDAR_OPEN_OR_CREATE) { - g_message ("gnome_calendar_load_cb: trying create..."); /* FIXME: connect to the cal_loaded signal of the * CalClient and get theasynchronous notification * properly! */ @@ -1033,7 +995,7 @@ gnome_calendar_open (GnomeCalendar *gcal, gnome_calendar_load_cb, locd); - if (cal_client_load_calendar (gcal->client, file) == FALSE){ + if (cal_client_load_calendar (gcal->client, file) == FALSE) { g_message ("Error loading calendar: %s", file); return 0; } @@ -1281,11 +1243,6 @@ gnome_calendar_colors_changed (GnomeCalendar *gcal) { g_return_if_fail (gcal != NULL); g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - todo_style_changed = 1; -#if 0 - gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, 0); -#endif } void @@ -1293,11 +1250,6 @@ gnome_calendar_todo_properties_changed (GnomeCalendar *gcal) { g_return_if_fail (gcal != NULL); g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - todo_style_changed = 1; -#if 0 - gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, 0); -#endif } |