[evolution-patches] patch for #43556 (1.4 branch)
- From: Rodrigo Moya <rodrigo ximian com>
- To: Evolution Patches <evolution-patches ximian com>
- Subject: [evolution-patches] patch for #43556 (1.4 branch)
- Date: Fri, 21 Nov 2003 17:40:05 +0100
This patch makes the calendar views use the GtkClipboard class, thus
fixing all UTF8-related problems, since GtkClipboard should manage it
all.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.1802.2.39
diff -u -p -r1.1802.2.39 ChangeLog
--- ChangeLog 19 Nov 2003 05:53:26 -0000 1.1802.2.39
+++ ChangeLog 21 Nov 2003 16:36:21 -0000
@@ -1,3 +1,11 @@
+2003-11-21 Rodrigo Moya <rodrigo ximian com>
+
+ Fixes #43556
+
+ * gui/e-day-view.[ch]:
+ * gui/e-week-view.[ch]: use GtkClipboard instead of using GtkInvisible's
+ for the Cut/Copy/Paste operations.
+
2003-11-19 Jack Jia <jack jia sun com>
Fix for #51052.
Index: gui/e-day-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
retrieving revision 1.198.2.5
diff -u -p -r1.198.2.5 e-day-view.c
--- gui/e-day-view.c 12 Aug 2003 03:14:21 -0000 1.198.2.5
+++ gui/e-day-view.c 21 Nov 2003 16:36:33 -0000
@@ -34,8 +34,8 @@
#include <time.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
+#include <gtk/gtkclipboard.h>
#include <gtk/gtkdnd.h>
-#include <gtk/gtkinvisible.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkvscrollbar.h>
@@ -478,19 +478,6 @@ static time_t e_day_view_find_work_week_
static void e_day_view_recalc_work_week (EDayView *day_view);
static void e_day_view_recalc_work_week_days_shown (EDayView *day_view);
-static void selection_clear_event (GtkWidget *invisible,
- GdkEventSelection *event,
- EDayView *day_view);
-static void selection_received (GtkWidget *invisible,
- GtkSelectionData *selection_data,
- guint time,
- EDayView *day_view);
-static void selection_get (GtkWidget *invisible,
- GtkSelectionData *selection_data,
- guint info,
- guint time_stamp,
- EDayView *day_view);
-
static void e_day_view_queue_layout (EDayView *day_view);
static void e_day_view_cancel_layout (EDayView *day_view);
static gboolean e_day_view_layout_timeout_cb (gpointer data);
@@ -861,19 +848,6 @@ e_day_view_init (EDayView *day_view)
target_table, n_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
- /* Set up the invisible widget for the clipboard selections */
- day_view->invisible = gtk_invisible_new ();
- gtk_selection_add_target (day_view->invisible,
- clipboard_atom,
- GDK_SELECTION_TYPE_STRING,
- 0);
- g_signal_connect (day_view->invisible, "selection_get",
- G_CALLBACK (selection_get), (gpointer) day_view);
- g_signal_connect (day_view->invisible, "selection_clear_event",
- G_CALLBACK (selection_clear_event), (gpointer) day_view);
- g_signal_connect (day_view->invisible, "selection_received",
- G_CALLBACK (selection_received), (gpointer) day_view);
-
day_view->clipboard_selection = NULL;
day_view->activity = NULL;
@@ -979,10 +953,6 @@ e_day_view_destroy (GtkObject *object)
}
}
- if (day_view->invisible) {
- gtk_widget_destroy (day_view->invisible);
- day_view->invisible = NULL;
- }
if (day_view->clipboard_selection) {
g_free (day_view->clipboard_selection);
day_view->clipboard_selection = NULL;
@@ -2900,21 +2870,118 @@ e_day_view_copy_clipboard (EDayView *day
if (day_view->clipboard_selection != NULL)
g_free (day_view->clipboard_selection);
day_view->clipboard_selection = g_strdup (comp_str);
- gtk_selection_owner_set (day_view->invisible, clipboard_atom, GDK_CURRENT_TIME);
+ gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (day_view), clipboard_atom),
+ (const gchar *) comp_str,
+ g_utf8_strlen (comp_str, -1));
/* free memory */
icalcomponent_free (vcal_comp);
}
+static void
+clipboard_get_text_cb (GtkClipboard *clipboard, const gchar *text, EDayView *day_view)
+{
+ char *comp_str;
+ icalcomponent *icalcomp;
+ time_t dtstart, dtend;
+ struct icaltimetype itime;
+ icalcomponent_kind kind;
+ CalComponent *comp;
+ char *uid;
+ time_t tt_start, tt_end;
+ struct icaldurationtype ic_dur;
+
+ g_return_if_fail (E_IS_DAY_VIEW (day_view));
+
+ comp_str = (char *) text;
+ icalcomp = icalparser_parse_string ((const char *) comp_str);
+ if (!icalcomp)
+ return;
+
+ /* check the type of the component */
+ kind = icalcomponent_isa (icalcomp);
+ if (kind != ICAL_VCALENDAR_COMPONENT &&
+ kind != ICAL_VEVENT_COMPONENT &&
+ kind != ICAL_VTODO_COMPONENT &&
+ kind != ICAL_VJOURNAL_COMPONENT) {
+ return;
+ }
+
+ e_day_view_set_status_message (day_view, _("Updating objects"));
+ e_day_view_get_selected_time_range (day_view, &dtstart, &dtend);
+
+ if (kind == ICAL_VCALENDAR_COMPONENT) {
+ icalcomponent_kind child_kind;
+ icalcomponent *subcomp;
+
+ subcomp = icalcomponent_get_first_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ while (subcomp) {
+ child_kind = icalcomponent_isa (subcomp);
+ if (child_kind == ICAL_VEVENT_COMPONENT ||
+ child_kind == ICAL_VTODO_COMPONENT ||
+ child_kind == ICAL_VJOURNAL_COMPONENT) {
+ tt_start = icaltime_as_timet (icalcomponent_get_dtstart (subcomp));
+ tt_end = icaltime_as_timet (icalcomponent_get_dtend (subcomp));
+ ic_dur = icaldurationtype_from_int (tt_end - tt_start);
+ itime = icaltime_from_timet_with_zone (dtstart, FALSE, day_view->zone);
+
+ icalcomponent_set_dtstart (subcomp, itime);
+ itime = icaltime_add (itime, ic_dur);
+ icalcomponent_set_dtend (subcomp, itime);
+
+ uid = cal_component_gen_uid ();
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (
+ comp, icalcomponent_new_clone (subcomp));
+ cal_component_set_uid (comp, uid);
+
+ cal_client_update_object (day_view->client, comp);
+
+ free (uid);
+ g_object_unref (comp);
+
+ }
+ subcomp = icalcomponent_get_next_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ }
+ }
+ else {
+ tt_start = icaltime_as_timet (icalcomponent_get_dtstart (icalcomp));
+ tt_end = icaltime_as_timet (icalcomponent_get_dtend (icalcomp));
+ ic_dur = icaldurationtype_from_int (tt_end - tt_start);
+ itime = icaltime_from_timet_with_zone (dtstart, FALSE, day_view->zone);
+
+ icalcomponent_set_dtstart (icalcomp, itime);
+ itime = icaltime_add (itime, ic_dur);
+ icalcomponent_set_dtend (icalcomp, itime);
+
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomp);
+
+ uid = cal_component_gen_uid ();
+ cal_component_set_uid (comp, (const char *) uid);
+ free (uid);
+
+ cal_client_update_object (day_view->client, comp);
+
+ if (itip_organizer_is_user (comp, day_view->client) &&
+ send_component_dialog (gtk_widget_get_toplevel (day_view), day_view->client, comp, TRUE))
+ itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, day_view->client, NULL);
+
+ g_object_unref (comp);
+ }
+
+ e_day_view_set_status_message (day_view, NULL);
+}
+
void
e_day_view_paste_clipboard (EDayView *day_view)
{
g_return_if_fail (E_IS_DAY_VIEW (day_view));
- gtk_selection_convert (day_view->invisible,
- clipboard_atom,
- GDK_SELECTION_TYPE_STRING,
- GDK_CURRENT_TIME);
+ gtk_clipboard_request_text (gtk_widget_get_clipboard (GTK_WIDGET (day_view), clipboard_atom),
+ (GtkClipboardTextReceivedFunc) clipboard_get_text_cb, day_view);
}
static void
@@ -4313,8 +4380,9 @@ e_day_view_on_copy (GtkWidget *widget, g
if (day_view->clipboard_selection)
g_free (day_view->clipboard_selection);
day_view->clipboard_selection = g_strdup (comp_str);
-
- gtk_selection_owner_set (day_view->invisible, clipboard_atom, GDK_CURRENT_TIME);
+ gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (day_view), clipboard_atom),
+ (const gchar *) comp_str,
+ g_utf8_strlen (comp_str, -1));
/* free memory */
icalcomponent_free (vcal_comp);
@@ -4325,10 +4393,7 @@ e_day_view_on_paste (GtkWidget *widget,
{
EDayView *day_view = E_DAY_VIEW (data);
- gtk_selection_convert (day_view->invisible,
- clipboard_atom,
- GDK_SELECTION_TYPE_STRING,
- GDK_CURRENT_TIME);
+ e_day_view_paste_clipboard (day_view);
}
static void
@@ -7954,139 +8019,6 @@ e_day_view_get_time_string_width (EDayVi
return time_width;
}
-
-static void
-selection_get (GtkWidget *invisible,
- GtkSelectionData *selection_data,
- guint info,
- guint time_stamp,
- EDayView *day_view)
-{
- if (day_view->clipboard_selection != NULL) {
- gtk_selection_data_set (selection_data,
- GDK_SELECTION_TYPE_STRING,
- 8,
- day_view->clipboard_selection,
- strlen (day_view->clipboard_selection));
- }
-}
-
-static void
-selection_clear_event (GtkWidget *invisible,
- GdkEventSelection *event,
- EDayView *day_view)
-{
- if (day_view->clipboard_selection != NULL) {
- g_free (day_view->clipboard_selection);
- day_view->clipboard_selection = NULL;
- }
-}
-
-static void
-selection_received (GtkWidget *invisible,
- GtkSelectionData *selection_data,
- guint time,
- EDayView *day_view)
-{
- char *comp_str;
- icalcomponent *icalcomp;
- time_t dtstart, dtend;
- struct icaltimetype itime;
- icalcomponent_kind kind;
- CalComponent *comp;
- char *uid;
- time_t tt_start, tt_end;
- struct icaldurationtype ic_dur;
-
- g_return_if_fail (E_IS_DAY_VIEW (day_view));
-
- if (selection_data->length < 0 ||
- selection_data->type != GDK_SELECTION_TYPE_STRING) {
- return;
- }
-
- comp_str = (char *) selection_data->data;
- icalcomp = icalparser_parse_string ((const char *) comp_str);
- if (!icalcomp)
- return;
-
- /* check the type of the component */
- kind = icalcomponent_isa (icalcomp);
- if (kind != ICAL_VCALENDAR_COMPONENT &&
- kind != ICAL_VEVENT_COMPONENT &&
- kind != ICAL_VTODO_COMPONENT &&
- kind != ICAL_VJOURNAL_COMPONENT) {
- return;
- }
-
- e_day_view_set_status_message (day_view, _("Updating objects"));
- e_day_view_get_selected_time_range (day_view, &dtstart, &dtend);
-
- if (kind == ICAL_VCALENDAR_COMPONENT) {
- icalcomponent_kind child_kind;
- icalcomponent *subcomp;
-
- subcomp = icalcomponent_get_first_component (
- icalcomp, ICAL_ANY_COMPONENT);
- while (subcomp) {
- child_kind = icalcomponent_isa (subcomp);
- if (child_kind == ICAL_VEVENT_COMPONENT ||
- child_kind == ICAL_VTODO_COMPONENT ||
- child_kind == ICAL_VJOURNAL_COMPONENT) {
- tt_start = icaltime_as_timet (icalcomponent_get_dtstart (subcomp));
- tt_end = icaltime_as_timet (icalcomponent_get_dtend (subcomp));
- ic_dur = icaldurationtype_from_int (tt_end - tt_start);
- itime = icaltime_from_timet_with_zone (dtstart, FALSE, day_view->zone);
-
- icalcomponent_set_dtstart (subcomp, itime);
- itime = icaltime_add (itime, ic_dur);
- icalcomponent_set_dtend (subcomp, itime);
-
- uid = cal_component_gen_uid ();
- comp = cal_component_new ();
- cal_component_set_icalcomponent (
- comp, icalcomponent_new_clone (subcomp));
- cal_component_set_uid (comp, uid);
-
- cal_client_update_object (day_view->client, comp);
-
- free (uid);
- g_object_unref (comp);
-
- }
- subcomp = icalcomponent_get_next_component (
- icalcomp, ICAL_ANY_COMPONENT);
- }
- }
- else {
- tt_start = icaltime_as_timet (icalcomponent_get_dtstart (icalcomp));
- tt_end = icaltime_as_timet (icalcomponent_get_dtend (icalcomp));
- ic_dur = icaldurationtype_from_int (tt_end - tt_start);
- itime = icaltime_from_timet_with_zone (dtstart, FALSE, day_view->zone);
-
- icalcomponent_set_dtstart (icalcomp, itime);
- itime = icaltime_add (itime, ic_dur);
- icalcomponent_set_dtend (icalcomp, itime);
-
- comp = cal_component_new ();
- cal_component_set_icalcomponent (comp, icalcomp);
-
- uid = cal_component_gen_uid ();
- cal_component_set_uid (comp, (const char *) uid);
- free (uid);
-
- cal_client_update_object (day_view->client, comp);
-
- if (itip_organizer_is_user (comp, day_view->client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view), day_view->client, comp, TRUE))
- itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, day_view->client, NULL);
-
- g_object_unref (comp);
- }
-
- e_day_view_set_status_message (day_view, NULL);
-}
-
/* Gets the visible time range. Returns FALSE if no time range has been set. */
gboolean
Index: gui/e-week-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.c,v
retrieving revision 1.165.2.4
diff -u -p -r1.165.2.4 e-week-view.c
--- gui/e-week-view.c 12 Aug 2003 03:14:21 -0000 1.165.2.4
+++ gui/e-week-view.c 21 Nov 2003 16:36:37 -0000
@@ -33,7 +33,7 @@
#include <math.h>
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkinvisible.h>
+#include <gtk/gtkclipboard.h>
#include <gtk/gtkselection.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkvscrollbar.h>
@@ -234,19 +234,6 @@ static gboolean e_week_view_remove_event
gpointer data);
static gboolean e_week_view_recalc_display_start_day (EWeekView *week_view);
-static void selection_get (GtkWidget *invisible,
- GtkSelectionData *selection_data,
- guint info,
- guint time_stamp,
- EWeekView *week_view);
-static void selection_clear_event (GtkWidget *invisible,
- GdkEventSelection *event,
- EWeekView *week_view);
-static void selection_received (GtkWidget *invisible,
- GtkSelectionData *selection_data,
- guint time,
- EWeekView *week_view);
-
static void e_week_view_queue_layout (EWeekView *week_view);
static void e_week_view_cancel_layout (EWeekView *week_view);
static gboolean e_week_view_layout_timeout_cb (gpointer data);
@@ -439,20 +426,6 @@ e_week_view_init (EWeekView *week_view)
week_view->resize_width_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
week_view->last_cursor_set = NULL;
- /* Set up the inivisible widget for the clipboard selections */
- week_view->invisible = gtk_invisible_new ();
- gtk_selection_add_target (week_view->invisible,
- clipboard_atom,
- GDK_SELECTION_TYPE_STRING,
- 0);
-
- g_signal_connect (week_view->invisible, "selection_get",
- G_CALLBACK (selection_get), (gpointer) week_view);
- g_signal_connect (week_view->invisible, "selection_clear_event",
- G_CALLBACK (selection_clear_event), (gpointer) week_view);
- g_signal_connect (week_view->invisible, "selection_received",
- G_CALLBACK (selection_received), (gpointer) week_view);
-
week_view->clipboard_selection = NULL;
week_view->activity = NULL;
@@ -532,10 +505,6 @@ e_week_view_destroy (GtkObject *object)
week_view->resize_width_cursor = NULL;
}
- if (week_view->invisible) {
- gtk_widget_destroy (week_view->invisible);
- week_view->invisible = NULL;
- }
if (week_view->clipboard_selection) {
g_free (week_view->clipboard_selection);
week_view->clipboard_selection = NULL;
@@ -2054,24 +2023,151 @@ e_week_view_copy_clipboard (EWeekView *w
if (week_view->clipboard_selection != NULL)
g_free (week_view->clipboard_selection);
week_view->clipboard_selection = g_strdup (comp_str);
- gtk_selection_owner_set (week_view->invisible, clipboard_atom, GDK_CURRENT_TIME);
+ gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (week_view), clipboard_atom),
+ (const gchar *) comp_str,
+ g_utf8_strlen (comp_str, -1));
/* free memory */
icalcomponent_free (vcal_comp);
}
+static void
+clipboard_get_text_cb (GtkClipboard *clipboard, const gchar *text, EWeekView *week_view)
+{
+ char *comp_str;
+ icalcomponent *icalcomp;
+ icalcomponent_kind kind;
+ CalComponent *comp;
+ time_t selected_time;
+ struct icaltimetype itime;
+ struct icaltimetype tmp_itime;
+ time_t tt_start, tt_end;
+ struct icaldurationtype ic_dur;
+ char *uid;
+ CalComponentDateTime ccdt;
+
+ g_return_if_fail (E_IS_WEEK_VIEW (week_view));
+
+ comp_str = (char *) text;
+ icalcomp = icalparser_parse_string ((const char *) comp_str);
+ if (!icalcomp)
+ return;
+
+ /* check the type of the component */
+ kind = icalcomponent_isa (icalcomp);
+ if (kind != ICAL_VCALENDAR_COMPONENT &&
+ kind != ICAL_VEVENT_COMPONENT &&
+ kind != ICAL_VTODO_COMPONENT &&
+ kind != ICAL_VJOURNAL_COMPONENT) {
+ return;
+ }
+
+ e_week_view_set_status_message (week_view, _("Updating objects"));
+ selected_time = week_view->day_starts[week_view->selection_start_day];
+
+ if (kind == ICAL_VCALENDAR_COMPONENT) {
+ icalcomponent_kind child_kind;
+ icalcomponent *subcomp;
+
+ subcomp = icalcomponent_get_first_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ while (subcomp) {
+ child_kind = icalcomponent_isa (subcomp);
+ if (child_kind == ICAL_VEVENT_COMPONENT ||
+ child_kind == ICAL_VTODO_COMPONENT ||
+ child_kind == ICAL_VJOURNAL_COMPONENT) {
+ icalcomponent *new_icalcomp;
+
+ new_icalcomp = icalcomponent_new_clone (subcomp);
+ comp = cal_component_new ();
+
+ /* change the day for the event */
+ tt_start = icaltime_as_timet (
+ icalcomponent_get_dtstart (new_icalcomp));
+ tt_end = icaltime_as_timet (
+ icalcomponent_get_dtend (new_icalcomp));
+ ic_dur = icaldurationtype_from_int (tt_end - tt_start);
+
+ tmp_itime = icaltime_from_timet_with_zone (
+ selected_time, FALSE, week_view->zone);
+ itime = icalcomponent_get_dtstart (new_icalcomp);
+ itime.year = tmp_itime.year;
+ itime.month = tmp_itime.month;
+ itime.day = tmp_itime.day;
+
+ cal_component_set_icalcomponent (comp, new_icalcomp);
+ ccdt.value = &itime;
+ ccdt.tzid = icaltimezone_get_tzid (week_view->zone);
+ cal_component_set_dtstart (comp, &ccdt);
+
+ itime = icaltime_add (itime, ic_dur);
+ ccdt.value = &itime;
+ cal_component_set_dtend (comp, &ccdt);
+
+ uid = cal_component_gen_uid ();
+ cal_component_set_uid (comp, uid);
+
+ cal_client_update_object (week_view->client, comp);
+
+ g_free (uid);
+ g_object_unref (comp);
+ }
+ subcomp = icalcomponent_get_next_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ }
+
+ icalcomponent_free (icalcomp);
+
+ }
+ else {
+ comp = cal_component_new ();
+
+ /* change the day for the event */
+ tt_start = icaltime_as_timet (icalcomponent_get_dtstart (icalcomp));
+ tt_end = icaltime_as_timet (icalcomponent_get_dtend (icalcomp));
+ ic_dur = icaldurationtype_from_int (tt_end - tt_start);
+
+ tmp_itime = icaltime_from_timet_with_zone (
+ selected_time, FALSE, week_view->zone);
+ itime = icalcomponent_get_dtstart (icalcomp);
+ itime.year = tmp_itime.year;
+ itime.month = tmp_itime.month;
+ itime.day = tmp_itime.day;
+
+ cal_component_set_icalcomponent (comp, icalcomp);
+ ccdt.value = &itime;
+ ccdt.tzid = icaltimezone_get_tzid (week_view->zone);
+ cal_component_set_dtstart (comp, &ccdt);
+
+ itime = icaltime_add (itime, ic_dur);
+ ccdt.value = &itime;
+ cal_component_set_dtend (comp, &ccdt);
+
+ uid = cal_component_gen_uid ();
+ cal_component_set_uid (comp, (const char *) uid);
+
+ cal_client_update_object (week_view->client, comp);
+
+ if (itip_organizer_is_user (comp, week_view->client) &&
+ send_component_dialog (gtk_widget_get_toplevel (week_view), week_view->client, comp, TRUE))
+ itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, week_view->client, NULL);
+
+ g_free (uid);
+ g_object_unref (comp);
+ }
+
+ e_week_view_set_status_message (week_view, NULL);
+}
+
void
e_week_view_paste_clipboard (EWeekView *week_view)
{
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
- gtk_selection_convert (week_view->invisible,
- clipboard_atom,
- GDK_SELECTION_TYPE_STRING,
- GDK_CURRENT_TIME);
+ gtk_clipboard_request_text (gtk_widget_get_clipboard (GTK_WIDGET (week_view), clipboard_atom),
+ (GtkClipboardTextReceivedFunc) clipboard_get_text_cb, week_view);
}
-
static gboolean
e_week_view_recalc_display_start_day (EWeekView *week_view)
{
@@ -4226,8 +4322,9 @@ e_week_view_on_copy (GtkWidget *widget,
if (week_view->clipboard_selection)
g_free (week_view->clipboard_selection);
week_view->clipboard_selection = g_strdup (comp_str);
-
- gtk_selection_owner_set (week_view->invisible, clipboard_atom, GDK_CURRENT_TIME);
+ gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (week_view), clipboard_atom),
+ (const gchar *) comp_str,
+ g_utf8_strlen (comp_str, -1));
/* free memory */
icalcomponent_free (vcal_comp);
@@ -4238,10 +4335,7 @@ e_week_view_on_paste (GtkWidget *widget,
{
EWeekView *week_view = E_WEEK_VIEW (data);
- gtk_selection_convert (week_view->invisible,
- clipboard_atom,
- GDK_SELECTION_TYPE_STRING,
- GDK_CURRENT_TIME);
+ e_week_view_paste_clipboard (week_view);
}
static void
@@ -4377,170 +4471,6 @@ e_week_view_get_time_string_width (EWeek
return time_width;
}
-
-static void
-selection_get (GtkWidget *invisible,
- GtkSelectionData *selection_data,
- guint info,
- guint time_stamp,
- EWeekView *week_view)
-{
- if (week_view->clipboard_selection != NULL) {
- gtk_selection_data_set (selection_data,
- GDK_SELECTION_TYPE_STRING,
- 8,
- week_view->clipboard_selection,
- strlen (week_view->clipboard_selection));
- }
-}
-
-static void
-selection_clear_event (GtkWidget *invisible,
- GdkEventSelection *event,
- EWeekView *week_view)
-{
- if (week_view->clipboard_selection != NULL) {
- g_free (week_view->clipboard_selection);
- week_view->clipboard_selection = NULL;
- }
-}
-
-static void
-selection_received (GtkWidget *invisible,
- GtkSelectionData *selection_data,
- guint time,
- EWeekView *week_view)
-{
- char *comp_str;
- icalcomponent *icalcomp;
- icalcomponent_kind kind;
- CalComponent *comp;
- time_t selected_time;
- struct icaltimetype itime;
- struct icaltimetype tmp_itime;
- time_t tt_start, tt_end;
- struct icaldurationtype ic_dur;
- char *uid;
- CalComponentDateTime ccdt;
-
- g_return_if_fail (E_IS_WEEK_VIEW (week_view));
-
- if (selection_data->length < 0 ||
- selection_data->type != GDK_SELECTION_TYPE_STRING) {
- return;
- }
-
- comp_str = (char *) selection_data->data;
- icalcomp = icalparser_parse_string ((const char *) comp_str);
- if (!icalcomp)
- return;
-
- /* check the type of the component */
- kind = icalcomponent_isa (icalcomp);
- if (kind != ICAL_VCALENDAR_COMPONENT &&
- kind != ICAL_VEVENT_COMPONENT &&
- kind != ICAL_VTODO_COMPONENT &&
- kind != ICAL_VJOURNAL_COMPONENT) {
- return;
- }
-
- e_week_view_set_status_message (week_view, _("Updating objects"));
- selected_time = week_view->day_starts[week_view->selection_start_day];
-
- if (kind == ICAL_VCALENDAR_COMPONENT) {
- icalcomponent_kind child_kind;
- icalcomponent *subcomp;
-
- subcomp = icalcomponent_get_first_component (
- icalcomp, ICAL_ANY_COMPONENT);
- while (subcomp) {
- child_kind = icalcomponent_isa (subcomp);
- if (child_kind == ICAL_VEVENT_COMPONENT ||
- child_kind == ICAL_VTODO_COMPONENT ||
- child_kind == ICAL_VJOURNAL_COMPONENT) {
- icalcomponent *new_icalcomp;
-
- new_icalcomp = icalcomponent_new_clone (subcomp);
- comp = cal_component_new ();
-
- /* change the day for the event */
- tt_start = icaltime_as_timet (
- icalcomponent_get_dtstart (new_icalcomp));
- tt_end = icaltime_as_timet (
- icalcomponent_get_dtend (new_icalcomp));
- ic_dur = icaldurationtype_from_int (tt_end - tt_start);
-
- tmp_itime = icaltime_from_timet_with_zone (
- selected_time, FALSE, week_view->zone);
- itime = icalcomponent_get_dtstart (new_icalcomp);
- itime.year = tmp_itime.year;
- itime.month = tmp_itime.month;
- itime.day = tmp_itime.day;
-
- cal_component_set_icalcomponent (comp, new_icalcomp);
- ccdt.value = &itime;
- ccdt.tzid = icaltimezone_get_tzid (week_view->zone);
- cal_component_set_dtstart (comp, &ccdt);
-
- itime = icaltime_add (itime, ic_dur);
- ccdt.value = &itime;
- cal_component_set_dtend (comp, &ccdt);
-
- uid = cal_component_gen_uid ();
- cal_component_set_uid (comp, uid);
-
- cal_client_update_object (week_view->client, comp);
-
- g_free (uid);
- g_object_unref (comp);
- }
- subcomp = icalcomponent_get_next_component (
- icalcomp, ICAL_ANY_COMPONENT);
- }
-
- icalcomponent_free (icalcomp);
-
- }
- else {
- comp = cal_component_new ();
-
- /* change the day for the event */
- tt_start = icaltime_as_timet (icalcomponent_get_dtstart (icalcomp));
- tt_end = icaltime_as_timet (icalcomponent_get_dtend (icalcomp));
- ic_dur = icaldurationtype_from_int (tt_end - tt_start);
-
- tmp_itime = icaltime_from_timet_with_zone (
- selected_time, FALSE, week_view->zone);
- itime = icalcomponent_get_dtstart (icalcomp);
- itime.year = tmp_itime.year;
- itime.month = tmp_itime.month;
- itime.day = tmp_itime.day;
-
- cal_component_set_icalcomponent (comp, icalcomp);
- ccdt.value = &itime;
- ccdt.tzid = icaltimezone_get_tzid (week_view->zone);
- cal_component_set_dtstart (comp, &ccdt);
-
- itime = icaltime_add (itime, ic_dur);
- ccdt.value = &itime;
- cal_component_set_dtend (comp, &ccdt);
-
- uid = cal_component_gen_uid ();
- cal_component_set_uid (comp, (const char *) uid);
-
- cal_client_update_object (week_view->client, comp);
-
- if (itip_organizer_is_user (comp, week_view->client) &&
- send_component_dialog (gtk_widget_get_toplevel (week_view), week_view->client, comp, TRUE))
- itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, week_view->client, NULL);
-
- g_free (uid);
- g_object_unref (comp);
- }
-
- e_week_view_set_status_message (week_view, NULL);
-}
-
/* Gets the visible time range. Returns FALSE if no time range has been set. */
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]