aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-11-12 12:52:08 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-11-12 23:44:52 +0800
commitc12e485e47f5ac99f0ddd7f7e90b9ab28b077c3d (patch)
tree4cbdb439735c9a1406e9294a152996e7c10cf49c /calendar/gui
parent7a2a0d05a9ba46c1d6c6f43f1a2d00c0ad93479a (diff)
downloadgsoc2013-evolution-c12e485e47f5ac99f0ddd7f7e90b9ab28b077c3d.tar.gz
gsoc2013-evolution-c12e485e47f5ac99f0ddd7f7e90b9ab28b077c3d.tar.zst
gsoc2013-evolution-c12e485e47f5ac99f0ddd7f7e90b9ab28b077c3d.zip
Simplify clipboard handling in addressbook.
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/Makefile.am3
-rw-r--r--calendar/gui/e-cal-selection.c323
-rw-r--r--calendar/gui/e-cal-selection.h75
-rw-r--r--calendar/gui/e-calendar-table.c2
-rw-r--r--calendar/gui/e-calendar-view.c2
-rw-r--r--calendar/gui/e-memo-table.c2
6 files changed, 3 insertions, 404 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index fc9c91047a..dd1357c6c5 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -18,7 +18,6 @@ ecalendarinclude_HEADERS = \
e-cal-event.h \
e-cal-model-calendar.h \
e-cal-model.h \
- e-cal-selection.h \
e-calendar-view.h \
e-cell-date-edit-text.h \
e-date-time-list.h \
@@ -113,8 +112,6 @@ libevolution_calendar_la_SOURCES = \
e-cal-model-memos.h \
e-cal-model-tasks.c \
e-cal-model-tasks.h \
- e-cal-selection.c \
- e-cal-selection.h \
e-calendar-selector.c \
e-calendar-selector.h \
e-calendar-table.c \
diff --git a/calendar/gui/e-cal-selection.c b/calendar/gui/e-cal-selection.c
deleted file mode 100644
index 27da752c98..0000000000
--- a/calendar/gui/e-cal-selection.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * e-cal-selection.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include "e-cal-selection.h"
-
-#include <string.h>
-
-typedef struct _RequestCalendarInfo RequestCalendarInfo;
-typedef struct _WaitForDataResults WaitForDataResults;
-
-struct _RequestCalendarInfo {
- GtkClipboardTextReceivedFunc callback;
- gpointer user_data;
-};
-
-struct _WaitForDataResults {
- GMainLoop *loop;
- gpointer data;
-};
-
-enum {
- ATOM_CALENDAR,
- ATOM_X_CALENDAR,
- ATOM_X_VCALENDAR,
- NUM_CALENDAR_ATOMS
-};
-
-static GdkAtom calendar_atoms[NUM_CALENDAR_ATOMS];
-
-static void
-init_atoms (void)
-{
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
-
- calendar_atoms[ATOM_CALENDAR] =
- gdk_atom_intern_static_string ("text/calendar");
-
- calendar_atoms[ATOM_X_CALENDAR] =
- gdk_atom_intern_static_string ("text/x-calendar");
-
- calendar_atoms[ATOM_X_VCALENDAR] =
- gdk_atom_intern_static_string ("text/x-vcalendar");
-
- initialized = TRUE;
-}
-
-void
-e_target_list_add_calendar_targets (GtkTargetList *list,
- guint info)
-{
- gint ii;
-
- g_return_if_fail (list != NULL);
-
- init_atoms ();
-
- for (ii = 0; ii < NUM_CALENDAR_ATOMS; ii++)
- gtk_target_list_add (list, calendar_atoms[ii], 0, info);
-}
-
-gboolean
-e_selection_data_set_calendar (GtkSelectionData *selection_data,
- const gchar *source,
- gint length)
-{
- GdkAtom atom;
- gint ii;
-
- g_return_val_if_fail (selection_data != NULL, FALSE);
-
- if (length < 0)
- length = strlen (source);
-
- init_atoms ();
-
- atom = gtk_selection_data_get_target (selection_data);
-
- /* All calendar atoms are treated the same. */
- for (ii = 0; ii < NUM_CALENDAR_ATOMS; ii++) {
- if (atom == calendar_atoms[ii]) {
- gtk_selection_data_set (
- selection_data, atom, 8,
- (guchar *) source, length);
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-gchar *
-e_selection_data_get_calendar (GtkSelectionData *selection_data)
-{
- GdkAtom data_type;
- const guchar *data = NULL;
- gint ii;
-
- /* XXX May need to do encoding and line ending conversions
- * here. Not worrying about it for now. */
-
- g_return_val_if_fail (selection_data != NULL, NULL);
-
- data = gtk_selection_data_get_data (selection_data);
- data_type = gtk_selection_data_get_data_type (selection_data);
-
- /* All calendar atoms are treated the same. */
- for (ii = 0; ii < NUM_CALENDAR_ATOMS; ii++)
- if (data_type == calendar_atoms[ii])
- return g_strdup ((gchar *) data);
-
- return NULL;
-}
-
-gboolean
-e_selection_data_targets_include_calendar (GtkSelectionData *selection_data)
-{
- GdkAtom *targets;
- gint n_targets;
- gboolean result = FALSE;
-
- g_return_val_if_fail (selection_data != NULL, FALSE);
-
- if (gtk_selection_data_get_targets (selection_data, &targets, &n_targets)) {
- result = e_targets_include_calendar (targets, n_targets);
- g_free (targets);
- }
-
- return result;
-}
-
-gboolean
-e_targets_include_calendar (GdkAtom *targets,
- gint n_targets)
-{
- gint ii, jj;
-
- g_return_val_if_fail (targets != NULL || n_targets == 0, FALSE);
-
- init_atoms ();
-
- for (ii = 0; ii < n_targets; ii++)
- for (jj = 0; jj < NUM_CALENDAR_ATOMS; jj++)
- if (targets[ii] == calendar_atoms[jj])
- return TRUE;
-
- return FALSE;
-}
-
-static void
-clipboard_get_calendar (GtkClipboard *clipboard,
- GtkSelectionData *selection_data,
- guint info,
- gchar *source)
-{
- e_selection_data_set_calendar (selection_data, source, -1);
-}
-
-static void
-clipboard_clear_calendar (GtkClipboard *clipboard,
- gchar *source)
-{
- g_free (source);
-}
-
-void
-e_clipboard_set_calendar (GtkClipboard *clipboard,
- const gchar *source,
- gint length)
-{
- GtkTargetList *list;
- GtkTargetEntry *targets;
- gint n_targets;
-
- g_return_if_fail (clipboard != NULL);
- g_return_if_fail (source != NULL);
-
- list = gtk_target_list_new (NULL, 0);
- e_target_list_add_calendar_targets (list, 0);
-
- targets = gtk_target_table_new_from_list (list, &n_targets);
-
- if (length < 0)
- length = strlen (source);
-
- gtk_clipboard_set_with_data (
- clipboard, targets, n_targets,
- (GtkClipboardGetFunc) clipboard_get_calendar,
- (GtkClipboardClearFunc) clipboard_clear_calendar,
- g_strndup (source, length));
-
- gtk_clipboard_set_can_store (clipboard, NULL, 0);
-
- gtk_target_table_free (targets, n_targets);
- gtk_target_list_unref (list);
-}
-
-static void
-clipboard_request_calendar_cb (GtkClipboard *clipboard,
- GtkSelectionData *selection_data,
- RequestCalendarInfo *info)
-{
- gchar *source;
-
- source = e_selection_data_get_calendar (selection_data);
- info->callback (clipboard, source, info->user_data);
- g_free (source);
-
- g_slice_free (RequestCalendarInfo, info);
-}
-
-void
-e_clipboard_request_calendar (GtkClipboard *clipboard,
- GtkClipboardTextReceivedFunc callback,
- gpointer user_data)
-{
- RequestCalendarInfo *info;
-
- g_return_if_fail (clipboard != NULL);
- g_return_if_fail (callback != NULL);
-
- info = g_slice_new (RequestCalendarInfo);
- info->callback = callback;
- info->user_data = user_data;
-
- gtk_clipboard_request_contents (
- clipboard, calendar_atoms[ATOM_CALENDAR],
- (GtkClipboardReceivedFunc)
- clipboard_request_calendar_cb, info);
-}
-
-static void
-clipboard_wait_for_calendar_cb (GtkClipboard *clipboard,
- const gchar *source,
- WaitForDataResults *results)
-{
- results->data = g_strdup (source);
- g_main_loop_quit (results->loop);
-}
-
-gchar *
-e_clipboard_wait_for_calendar (GtkClipboard *clipboard)
-{
- WaitForDataResults results;
-
- g_return_val_if_fail (clipboard != NULL, NULL);
-
- results.data = NULL;
- results.loop = g_main_loop_new (NULL, TRUE);
-
- e_clipboard_request_calendar (
- clipboard, (GtkClipboardTextReceivedFunc)
- clipboard_wait_for_calendar_cb, &results);
-
- if (g_main_loop_is_running (results.loop)) {
- GDK_THREADS_LEAVE ();
- g_main_loop_run (results.loop);
- GDK_THREADS_ENTER ();
- }
-
- g_main_loop_unref (results.loop);
-
- return results.data;
-}
-
-gboolean
-e_clipboard_wait_is_calendar_available (GtkClipboard *clipboard)
-{
- GdkAtom *targets;
- gint n_targets;
- gboolean result = FALSE;
-
- if (gtk_clipboard_wait_for_targets (clipboard, &targets, &n_targets)) {
- result = e_targets_include_calendar (targets, n_targets);
- g_free (targets);
- }
-
- return result;
-}
-
-void
-e_clipboard_print_targets (GtkClipboard *clipboard)
-{
- GdkAtom *targets;
- gchar *target_name;
- gint n_targets, ii;
-
- g_return_if_fail (clipboard != NULL);
-
- gtk_clipboard_wait_for_targets (clipboard, &targets, &n_targets);
-
- g_print ("Clipboard Targets:\n");
-
- if (n_targets == 0)
- g_print (" (none)\n");
- else for (ii = 0; ii < n_targets; ii++) {
- target_name = gdk_atom_name (targets[ii]);
- g_print (" %s\n", target_name);
- g_free (target_name);
- }
-
- g_free (targets);
-}
diff --git a/calendar/gui/e-cal-selection.h b/calendar/gui/e-cal-selection.h
deleted file mode 100644
index c79f1d608d..0000000000
--- a/calendar/gui/e-cal-selection.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * e-cal-selection.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-/**
- * SECTION: e-cal-selection
- * @short_description: calendar selection utilities
- * @include: calendar/gui/e-cal-selection.h
- **/
-
-#ifndef E_CAL_SELECTION_H
-#define E_CAL_SELECTION_H
-
-#include <gtk/gtk.h>
-
-/* This API mimics GTK's API for dealing with text, image and URI data. */
-
-G_BEGIN_DECLS
-
-/* Selection Functions */
-
-void e_target_list_add_calendar_targets
- (GtkTargetList *list,
- guint info);
-gboolean e_selection_data_set_calendar
- (GtkSelectionData *selection_data,
- const gchar *source,
- gint length);
-gchar * e_selection_data_get_calendar
- (GtkSelectionData *selection_data);
-gboolean e_selection_data_targets_include_calendar
- (GtkSelectionData *selection_data);
-gboolean e_targets_include_calendar
- (GdkAtom *targets,
- gint n_targets);
-
-/* Clipboard Functions */
-
-void e_clipboard_set_calendar(GtkClipboard *clipboard,
- const gchar *source,
- gint length);
-void e_clipboard_request_calendar
- (GtkClipboard *clipboard,
- GtkClipboardTextReceivedFunc callback,
- gpointer user_data);
-gchar * e_clipboard_wait_for_calendar
- (GtkClipboard *clipboard);
-gboolean e_clipboard_wait_is_calendar_available
- (GtkClipboard *clipboard);
-
-/* Debugging Functions */
-
-void e_clipboard_print_targets
- (GtkClipboard *clipboard);
-
-G_END_DECLS
-
-#endif /* E_CAL_SELECTION_H */
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index 3903c58888..4ea57c2abb 100644
--- a/calendar/gui/e-calendar-table.c
+++ b/calendar/gui/e-calendar-table.c
@@ -43,6 +43,7 @@
#include <table/e-cell-combo.h>
#include <table/e-cell-date.h>
#include <e-util/e-binding.h>
+#include <e-util/e-selection.h>
#include <e-util/e-dialog-utils.h>
#include <e-util/e-util-private.h>
#include <table/e-cell-date-edit.h>
@@ -55,7 +56,6 @@
#include "dialogs/delete-error.h"
#include "dialogs/task-editor.h"
#include "e-cal-model-tasks.h"
-#include "e-cal-selection.h"
#include "e-calendar-table.h"
#include "e-calendar-view.h"
#include "e-cell-date-edit-text.h"
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 0ea84e1268..84812d60c5 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -33,6 +33,7 @@
#include <libedataserver/e-time-utils.h>
#include <e-util/e-util.h>
#include <e-util/e-error.h>
+#include <e-util/e-selection.h>
#include <e-util/e-datetime-format.h>
#include <e-util/e-dialog-utils.h>
#include <e-util/e-icon-factory.h>
@@ -45,7 +46,6 @@
#include "comp-util.h"
#include "ea-calendar.h"
#include "e-cal-model-calendar.h"
-#include "e-cal-selection.h"
#include "e-calendar-view.h"
#include "itip-utils.h"
#include "dialogs/comp-editor-util.h"
diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c
index c111bd668d..fc4b2c82ce 100644
--- a/calendar/gui/e-memo-table.c
+++ b/calendar/gui/e-memo-table.c
@@ -42,6 +42,7 @@
#include <table/e-cell-text.h>
#include <table/e-cell-combo.h>
#include <table/e-cell-date.h>
+#include <e-util/e-selection.h>
#include <e-util/e-dialog-utils.h>
#include <e-util/e-util-private.h>
#include <table/e-cell-date-edit.h>
@@ -53,7 +54,6 @@
#include "dialogs/delete-error.h"
#include "dialogs/memo-editor.h"
#include "e-cal-model-memos.h"
-#include "e-cal-selection.h"
#include "e-memo-table.h"
#include "e-calendar-view.h"
#include "e-cell-date-edit-text.h"