aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-week-view.c
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2003-10-22 02:49:34 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2003-10-22 02:49:34 +0800
commit653cfffc0e00dfb59b36813c1b45c53d3f773c65 (patch)
tree9b486d5e383ec1391d60973d9cc548be0ef6d9d5 /calendar/gui/e-week-view.c
parent0fb08f3ff81575a4749d851404233f34252dd2f2 (diff)
downloadgsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.gz
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.bz2
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.lz
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.xz
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.zst
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.zip
Merge new-ui-branch to the trunk.
svn path=/trunk/; revision=22965
Diffstat (limited to 'calendar/gui/e-week-view.c')
-rw-r--r--calendar/gui/e-week-view.c173
1 files changed, 46 insertions, 127 deletions
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 8028bf13e6..1be94fc1de 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -62,6 +62,7 @@
#include "calendar-config.h"
#include "print.h"
#include "goto.h"
+#include "e-cal-model-calendar.h"
#include "e-week-view-event-item.h"
#include "e-week-view-layout.h"
#include "e-week-view-main-item.h"
@@ -312,8 +313,6 @@ e_week_view_init (EWeekView *week_view)
week_view->main_gc = NULL;
- week_view->default_category = NULL;
-
/* Create the small font. */
week_view->use_small_font = TRUE;
@@ -423,8 +422,11 @@ GtkWidget *
e_week_view_new (void)
{
GtkWidget *week_view;
+ ECalModel *model;
+
+ model = E_CAL_MODEL (e_cal_model_calendar_new ());
- week_view = GTK_WIDGET (g_object_new (e_week_view_get_type (), NULL));
+ week_view = GTK_WIDGET (g_object_new (e_week_view_get_type (), "model", model, NULL));
return week_view;
}
@@ -457,11 +459,6 @@ e_week_view_destroy (GtkObject *object)
week_view->small_font_desc = NULL;
}
- if (week_view->default_category) {
- g_free (week_view->default_category);
- week_view->default_category = NULL;
- }
-
if (week_view->normal_cursor) {
gdk_cursor_unref (week_view->normal_cursor);
week_view->normal_cursor = NULL;
@@ -1149,7 +1146,7 @@ process_component (EWeekView *week_view, ECalModelComponent *comp_data)
g_object_unref (tmp_comp);
}
- /* Add the occurrences of the event. */
+ /* Add the occurrences of the event */
num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
add_event_data.week_view = week_view;
@@ -1158,8 +1155,7 @@ process_component (EWeekView *week_view, ECalModelComponent *comp_data)
week_view->day_starts[0],
week_view->day_starts[num_days],
e_week_view_add_event, &add_event_data,
- cal_client_resolve_tzid_cb,
- comp_data->client,
+ cal_client_resolve_tzid_cb, comp_data->client,
e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
g_object_unref (comp);
@@ -1178,8 +1174,6 @@ e_week_view_update_query (ECalView *cal_view)
e_week_view_free_events (week_view);
e_week_view_queue_layout (week_view);
- e_cal_view_set_status_message (E_CAL_VIEW (week_view), _("Searching"));
-
rows = e_table_model_row_count (E_TABLE_MODEL (e_cal_view_get_model (E_CAL_VIEW (week_view))));
for (r = 0; r < rows; r++) {
ECalModelComponent *comp_data;
@@ -1188,8 +1182,6 @@ e_week_view_update_query (ECalView *cal_view)
g_assert (comp_data != NULL);
process_component (week_view, comp_data);
}
-
- e_cal_view_set_status_message (E_CAL_VIEW (week_view), NULL);
}
static void
@@ -1217,27 +1209,6 @@ e_week_view_draw_shadow (EWeekView *week_view)
gdk_draw_line (window, light_gc, x1, y2, x2, y2);
}
-/**
- * e_week_view_set_default_category:
- * @week_view: A week view.
- * @category: Default category name or NULL for no category.
- *
- * Sets the default category that will be used when creating new calendar
- * components from the week view.
- **/
-void
-e_week_view_set_default_category (EWeekView *week_view, const char *category)
-{
- g_return_if_fail (week_view != NULL);
- g_return_if_fail (E_IS_WEEK_VIEW (week_view));
-
- if (week_view->default_category)
- g_free (week_view->default_category);
-
- week_view->default_category = g_strdup (category);
-}
-
-
/* 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. */
@@ -2015,7 +1986,7 @@ e_week_view_on_button_press (GtkWidget *widget,
return FALSE;
if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) {
- gnome_calendar_new_appointment (e_cal_view_get_calendar (E_CAL_VIEW (week_view)));
+ e_cal_view_new_appointment (E_CAL_VIEW (week_view));
return TRUE;
}
@@ -2876,14 +2847,11 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item,
{
EWeekViewEvent *event;
gint event_num, span_num;
- GnomeCalendar *calendar;
#if 0
g_print ("In e_week_view_on_text_item_event\n");
#endif
- calendar = e_cal_view_get_calendar (E_CAL_VIEW (week_view));
-
switch (gdkevent->type) {
case GDK_KEY_PRESS:
if (gdkevent && gdkevent->key.keyval == GDK_Return) {
@@ -2912,10 +2880,9 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item,
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
- if (calendar)
- gnome_calendar_edit_object (calendar, event->comp_data->client, event->comp_data->icalcomp, FALSE);
- else
- g_warning ("Calendar not set");
+ e_cal_view_edit_appointment (E_CAL_VIEW (week_view),
+ event->comp_data->client,
+ event->comp_data->icalcomp, FALSE);
gtk_signal_emit_stop_by_name (GTK_OBJECT (item), "event");
return TRUE;
@@ -3049,7 +3016,8 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
CalComponent *comp;
CalComponentText summary;
const char *uid;
-
+ gboolean on_server;
+
/* 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. */
@@ -3079,8 +3047,9 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
comp = cal_component_new ();
cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
- if (string_is_empty (text) &&
- !cal_comp_is_on_server (comp, event->comp_data->client)) {
+ on_server = cal_comp_is_on_server (comp, event->comp_data->client);
+
+ if (string_is_empty (text) && !on_server) {
const char *uid;
cal_component_get_uid (comp, &uid);
@@ -3099,33 +3068,33 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
e_week_view_reshape_event_span (week_view, event_num,
span_num);
} else if (summary.value || !string_is_empty (text)) {
+ icalcomponent *icalcomp = cal_component_get_icalcomponent (comp);
+
summary.value = text;
summary.altrep = NULL;
cal_component_set_summary (comp, &summary);
-
- if (cal_component_is_instance (comp)) {
- CalObjModType mod;
-
- if (recur_component_dialog (comp, &mod, NULL)) {
- if (cal_client_update_object_with_mod (event->comp_data->client, comp, mod)
- == CAL_CLIENT_RESULT_SUCCESS) {
- if (itip_organizer_is_user (comp, event->comp_data->client)
- && send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (week_view)),
- event->comp_data->client, comp, FALSE))
- itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
- event->comp_data->client, NULL);
- } else {
- g_message ("e_week_view_on_editing_stopped(): Could not update the object!");
+
+ if (!on_server) {
+ if (!cal_client_create_object (event->comp_data->client, icalcomp, NULL, NULL))
+ g_message (G_STRLOC ": Could not create the object!");
+ } else {
+ CalObjModType mod = CALOBJ_MOD_ALL;
+ GtkWindow *toplevel;
+
+ if (cal_component_has_recurrences (comp)) {
+ if (!recur_component_dialog (comp, &mod, NULL)) {
+ goto out;
}
}
- } else if (cal_client_update_object (event->comp_data->client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
- if (itip_organizer_is_user (comp, event->comp_data->client) &&
- send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (week_view)),
- event->comp_data->client, comp, FALSE))
- itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
- event->comp_data->client, NULL);
- } else {
- g_message ("e_week_view_on_editing_stopped(): Could not update the object!");
+
+ /* FIXME When sending here, what exactly should we send? */
+ toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (week_view)));
+ if (cal_client_modify_object (event->comp_data->client, icalcomp, mod, NULL)) {
+ if (itip_organizer_is_user (comp, event->comp_data->client)
+ && send_component_dialog (toplevel, event->comp_data->client, comp, FALSE))
+ itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
+ event->comp_data->client, NULL);
+ }
}
}
@@ -3182,6 +3151,10 @@ e_week_view_find_event_from_uid (EWeekView *week_view,
EWeekViewEvent *event;
gint event_num, num_events;
+ *event_num_return = -1;
+ if (!uid)
+ return FALSE;
+
num_events = week_view->events->len;
for (event_num = 0; event_num < num_events; event_num++) {
const char *u;
@@ -3291,6 +3264,8 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
/* Add a new event covering the selected range. */
icalcomp = e_cal_model_create_component_with_defaults (e_cal_view_get_model (E_CAL_VIEW (week_view)));
+ if (!icalcomp)
+ return FALSE;
uid = icalcomponent_get_uid (icalcomp);
comp = cal_component_new ();
@@ -3313,7 +3288,8 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
cal_component_set_dtend (comp, &date);
- cal_component_set_categories (comp, week_view->default_category);
+ cal_component_set_categories (
+ comp, e_cal_view_get_default_category (E_CAL_VIEW (week_view)));
/* We add the event locally and start editing it. We don't send it
to the server until the user finishes editing it. */
@@ -3546,63 +3522,6 @@ e_week_view_popup_menu (GtkWidget *widget)
}
void
-e_week_view_unrecur_appointment (EWeekView *week_view)
-{
- EWeekViewEvent *event;
- CalComponent *comp, *new_comp;
- CalComponentDateTime date;
- struct icaltimetype itt;
-
- if (week_view->popup_event_num == -1)
- return;
-
- event = &g_array_index (week_view->events, EWeekViewEvent,
- week_view->popup_event_num);
-
- /* For the recurring object, we add a exception to get rid of the
- instance. */
- comp = cal_component_new ();
- cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
- cal_comp_util_add_exdate (comp, event->start, e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
-
- /* For the unrecurred instance we duplicate the original object,
- create a new uid for it, get rid of the recurrence rules, and set
- the start & end times to the instances times. */
- new_comp = cal_component_new ();
- cal_component_set_icalcomponent (new_comp, icalcomponent_new_clone (event->comp_data->icalcomp));
- cal_component_set_uid (new_comp, cal_component_gen_uid ());
- cal_component_set_rdate_list (new_comp, NULL);
- cal_component_set_rrule_list (new_comp, NULL);
- cal_component_set_exdate_list (new_comp, NULL);
- cal_component_set_exrule_list (new_comp, NULL);
-
- date.value = &itt;
- date.tzid = icaltimezone_get_tzid (e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
-
- *date.value = icaltime_from_timet_with_zone (event->start, FALSE,
- e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
- cal_component_set_dtstart (new_comp, &date);
- *date.value = icaltime_from_timet_with_zone (event->end, FALSE,
- e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
- cal_component_set_dtend (new_comp, &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 (event->comp_data->client, comp)
- != CAL_CLIENT_RESULT_SUCCESS)
- g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!");
-
- g_object_unref (comp);
-
- if (cal_client_update_object (event->comp_data->client, new_comp)
- != CAL_CLIENT_RESULT_SUCCESS)
- g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!");
-
- g_object_unref (new_comp);
-}
-
-void
e_week_view_jump_to_button_item (EWeekView *week_view, GnomeCanvasItem *item)
{
gint day;