aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2001-06-13 23:22:25 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2001-06-13 23:22:25 +0800
commit3dc527df6627d11b8a7ed176092d70ee80b9e9a6 (patch)
treecda854a84304ff893524f74f98b4ac814358a59e
parent3a0539c91a4c302f9f254e0a05ea26be42caae5f (diff)
downloadgsoc2013-evolution-3dc527df6627d11b8a7ed176092d70ee80b9e9a6.tar.gz
gsoc2013-evolution-3dc527df6627d11b8a7ed176092d70ee80b9e9a6.tar.zst
gsoc2013-evolution-3dc527df6627d11b8a7ed176092d70ee80b9e9a6.zip
added cut&paste support, by using a GtkInvisible widget to manage the
2001-06-11 Rodrigo Moya <rodrigo@ximian.com> * gui/e-day-view.[ch]: added cut&paste support, by using a GtkInvisible widget to manage the clipboard selections. * gui/e-week-view.[ch]: ditto svn path=/trunk/; revision=10207
-rw-r--r--calendar/ChangeLog7
-rw-r--r--calendar/gui/e-day-view.c99
-rw-r--r--calendar/gui/e-day-view.h4
-rw-r--r--calendar/gui/e-week-view.c98
-rw-r--r--calendar/gui/e-week-view.h4
5 files changed, 211 insertions, 1 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 15bf30af5a..411108f923 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,10 @@
+2001-06-11 Rodrigo Moya <rodrigo@ximian.com>
+
+ * gui/e-day-view.[ch]: added cut&paste support, by using a GtkInvisible
+ widget to manage the clipboard selections.
+
+ * gui/e-week-view.[ch]: ditto
+
2001-06-08 Iain Holmes <iain@ximian.com>
* gui/component-factory.c: Removed the executive-summary includes.
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index b08ed848d8..cd3f08aa77 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -1,8 +1,9 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Author :
+ * Authors :
* Damon Chaplin <damon@helixcode.com>
+ * Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 1999, Helix Code, Inc.
*
@@ -404,8 +405,23 @@ static gboolean e_day_view_set_event_font_cb (EDayView *day_view,
gint event_num,
gpointer data);
+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 invisible_destroyed (GtkWidget *invisible, EDayView *day_view);
+
static GtkTableClass *parent_class;
+static GdkAtom clipboard_atom = GDK_NONE;
GtkType
@@ -453,6 +469,10 @@ e_day_view_class_init (EDayViewClass *class)
widget_class->focus_in_event = e_day_view_focus_in;
widget_class->focus_out_event = e_day_view_focus_out;
widget_class->key_press_event = e_day_view_key_press;
+
+ /* clipboard atom */
+ if (!clipboard_atom)
+ clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
}
@@ -789,6 +809,30 @@ e_day_view_init (EDayView *day_view)
GTK_DEST_DEFAULT_ALL,
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);
+ gtk_signal_connect (GTK_OBJECT (day_view->invisible),
+ "selection_get",
+ GTK_SIGNAL_FUNC (selection_get),
+ (gpointer) day_view);
+ gtk_signal_connect (GTK_OBJECT (day_view->invisible),
+ "selection_clear_event",
+ GTK_SIGNAL_FUNC (selection_clear_event),
+ (gpointer) day_view);
+ gtk_signal_connect (GTK_OBJECT (day_view->invisible),
+ "selection_received",
+ GTK_SIGNAL_FUNC (selection_received),
+ (gpointer) day_view);
+ gtk_signal_connect (GTK_OBJECT (day_view->invisible),
+ "destroy",
+ GTK_SIGNAL_FUNC (invisible_destroyed),
+ (gpointer) day_view);
+ day_view->clipboard_selection = NULL;
}
@@ -860,6 +904,11 @@ e_day_view_destroy (GtkObject *object)
for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++)
g_array_free (day_view->events[day], TRUE);
+ if (day_view->invisible)
+ gtk_widget_destroy (day_view->invisible);
+ if (day_view->clipboard_selection)
+ g_free (day_view->clipboard_selection);
+
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@@ -6370,3 +6419,51 @@ e_day_view_get_time_string_width (EDayView *day_view)
return time_width;
}
+
+static void
+invisible_destroyed (GtkWidget *invisible, EDayView *day_view)
+{
+ day_view->invisible = NULL;
+}
+
+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)
+{
+ if (selection_data->length < 0 ||
+ selection_data->type != GDK_SELECTION_TYPE_STRING) {
+ return;
+ }
+
+ if (day_view->clipboard_selection != NULL)
+ g_free (day_view->clipboard_selection);
+ day_view->clipboard_selection = g_strdup ((gchar *) selection_data->data);
+}
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index 9eb247a59f..f5e2087ad9 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -472,6 +472,10 @@ struct _EDayView
gchar *pm_string;
gint am_string_width;
gint pm_string_width;
+
+ /* the invisible widget to manage the clipboard selections */
+ GtkWidget *invisible;
+ gchar *clipboard_selection;
};
struct _EDayViewClass
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index adadd5d42a..ca1f05faec 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -33,6 +33,8 @@
#include <math.h>
#include <gdk/gdkkeysyms.h>
+#include <gtk/gtkinvisible.h>
+#include <gtk/gtkselection.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkvscrollbar.h>
#include <gtk/gtkwindow.h>
@@ -173,7 +175,22 @@ static gboolean e_week_view_remove_event_cb (EWeekView *week_view,
gpointer data);
static gboolean e_week_view_recalc_display_start_day (EWeekView *week_view);
+static void invisible_destroyed (GtkWidget *invisible, 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 GtkTableClass *parent_class;
+static GdkAtom clipboard_atom = GDK_NONE;
GtkType
@@ -223,6 +240,10 @@ e_week_view_class_init (EWeekViewClass *class)
widget_class->key_press_event = e_week_view_key_press;
widget_class->expose_event = e_week_view_expose_event;
widget_class->draw = e_week_view_draw;
+
+ /* clipboard atom */
+ if (!clipboard_atom)
+ clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
}
@@ -368,6 +389,30 @@ e_week_view_init (EWeekView *week_view)
week_view->move_cursor = gdk_cursor_new (GDK_FLEUR);
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);
+ gtk_signal_connect (GTK_OBJECT (week_view->invisible),
+ "selection_get",
+ GTK_SIGNAL_FUNC (selection_get),
+ (gpointer) week_view);
+ gtk_signal_connect (GTK_OBJECT (week_view->invisible),
+ "selection_clear_event",
+ GTK_SIGNAL_FUNC (selection_clear_event),
+ (gpointer) week_view);
+ gtk_signal_connect (GTK_OBJECT (week_view->invisible),
+ "selection_received",
+ GTK_SIGNAL_FUNC (selection_received),
+ (gpointer) week_view);
+ gtk_signal_connect (GTK_OBJECT (week_view->invisible),
+ "destroy",
+ GTK_SIGNAL_FUNC (invisible_destroyed),
+ (gpointer) week_view);
+ week_view->clipboard_selection = NULL;
}
@@ -421,6 +466,11 @@ e_week_view_destroy (GtkObject *object)
gdk_cursor_destroy (week_view->move_cursor);
gdk_cursor_destroy (week_view->resize_width_cursor);
+ if (week_view->invisible)
+ gtk_widget_destroy (week_view->invisible);
+ if (week_view->clipboard_selection)
+ g_free (week_view->clipboard_selection);
+
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@@ -3315,3 +3365,51 @@ e_week_view_get_time_string_width (EWeekView *week_view)
return time_width;
}
+
+static void
+invisible_destroyed (GtkWidget *invisible, EWeekView *week_view)
+{
+ week_view->invisible = NULL;
+}
+
+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)
+{
+ if (selection_data->length < 0 ||
+ selection_data->type != GDK_SELECTION_TYPE_STRING) {
+ return;
+ }
+
+ if (week_view->clipboard_selection != NULL)
+ g_free (week_view->clipboard_selection);
+ week_view->clipboard_selection = g_strdup ((gchar *) selection_data->data);
+}
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index 7fde751b3f..549a8f789c 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -344,6 +344,10 @@ struct _EWeekView
gchar *pm_string;
gint am_string_width;
gint pm_string_width;
+
+ /* the invisible widget to manage the clipboard selections */
+ GtkWidget *invisible;
+ gchar *clipboard_selection;
};
struct _EWeekViewClass