aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-06-23 20:25:17 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-06-23 20:35:45 +0800
commit0fbc7299d9f5c3ef7a27775e2a6414a3eb5253b7 (patch)
treea5af62a2f76ebeed7848aabd58c893bfdf57a7ea /addressbook
parent30104e56e241d5eeef5fd091937043b2db5d20b1 (diff)
downloadgsoc2013-evolution-0fbc7299d9f5c3ef7a27775e2a6414a3eb5253b7.tar
gsoc2013-evolution-0fbc7299d9f5c3ef7a27775e2a6414a3eb5253b7.tar.gz
gsoc2013-evolution-0fbc7299d9f5c3ef7a27775e2a6414a3eb5253b7.tar.bz2
gsoc2013-evolution-0fbc7299d9f5c3ef7a27775e2a6414a3eb5253b7.tar.lz
gsoc2013-evolution-0fbc7299d9f5c3ef7a27775e2a6414a3eb5253b7.tar.xz
gsoc2013-evolution-0fbc7299d9f5c3ef7a27775e2a6414a3eb5253b7.tar.zst
gsoc2013-evolution-0fbc7299d9f5c3ef7a27775e2a6414a3eb5253b7.zip
Bug 331305 - Can't drag email addresses to Contact List Editor
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/gui/contact-list-editor/Makefile.am6
-rw-r--r--addressbook/gui/contact-list-editor/contact-list-editor.ui2
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c88
3 files changed, 40 insertions, 56 deletions
diff --git a/addressbook/gui/contact-list-editor/Makefile.am b/addressbook/gui/contact-list-editor/Makefile.am
index 28015dfe4b..657bbf1da9 100644
--- a/addressbook/gui/contact-list-editor/Makefile.am
+++ b/addressbook/gui/contact-list-editor/Makefile.am
@@ -11,7 +11,8 @@ libecontactlisteditor_la_CPPFLAGS = \
-DEVOLUTION_UIDIR=\""$(uidir)"\" \
-DG_LOG_DOMAIN=\"contact-list-editor\" \
$(GNOME_PLATFORM_CFLAGS) \
- $(EVOLUTION_ADDRESSBOOK_CFLAGS)
+ $(EVOLUTION_ADDRESSBOOK_CFLAGS) \
+ $(CAMEL_CFLAGS)
libecontactlisteditor_la_SOURCES = \
e-contact-list-editor.c \
@@ -29,7 +30,8 @@ libecontactlisteditor_la_LIBADD = \
$(top_builddir)/e-util/libeutil.la \
$(top_builddir)/shell/libeshell.la \
$(EVOLUTION_ADDRESSBOOK_LIBS) \
- $(GNOME_PLATFORM_LIBS)
+ $(GNOME_PLATFORM_LIBS) \
+ $(CAMEL_LIBS)
ui_DATA = contact-list-editor.ui
diff --git a/addressbook/gui/contact-list-editor/contact-list-editor.ui b/addressbook/gui/contact-list-editor/contact-list-editor.ui
index 0c1e21cf68..956bd50fdf 100644
--- a/addressbook/gui/contact-list-editor/contact-list-editor.ui
+++ b/addressbook/gui/contact-list-editor/contact-list-editor.ui
@@ -172,10 +172,8 @@
<property name="visible">True</property>
<property name="headers_visible">False</property>
<property name="search_column">0</property>
- <signal handler="contact_list_editor_drag_motion_cb" name="drag_motion"/>
<signal handler="contact_list_editor_tree_view_key_press_event_cb" name="key_press_event"/>
<signal handler="contact_list_editor_drag_data_received_cb" name="drag_data_received"/>
- <signal handler="contact_list_editor_drag_drop_cb" name="drag_drop"/>
</object>
</child>
</object>
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index 99ebfddc01..81bf3a4e47 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -35,6 +35,7 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
+#include <camel/camel.h>
#include <libedataserverui/e-source-combo-box.h>
#include "e-util/e-util.h"
@@ -438,6 +439,7 @@ contact_list_editor_drag_data_received_cb (GtkWidget *widget,
guint info,
guint time)
{
+ CamelInternetAddress *address;
EContactListEditor *editor;
EContactListModel *model;
gboolean changed = FALSE;
@@ -445,13 +447,19 @@ contact_list_editor_drag_data_received_cb (GtkWidget *widget,
const guchar *data;
GList *list, *iter;
GdkAtom target;
+ gint n_addresses = 0;
+ gchar *text;
editor = contact_list_editor_extract (widget);
-
model = E_CONTACT_LIST_MODEL (editor->priv->model);
- /* Sanity check the selection target. */
target = gtk_selection_data_get_target (selection_data);
+
+ /* Sanity check the selection target. */
+
+ if (gtk_targets_include_text (&target, 1))
+ goto handle_text;
+
if (!e_targets_include_directory (&target, 1))
goto exit;
@@ -493,66 +501,41 @@ contact_list_editor_drag_data_received_cb (GtkWidget *widget,
contact_list_editor_update (editor);
}
-exit:
- gtk_drag_finish (context, handled, FALSE, time);
-}
+ goto exit;
-gboolean
-contact_list_editor_drag_drop_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x, gint y,
- guint time);
-
-gboolean
-contact_list_editor_drag_drop_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x, gint y,
- guint time)
-{
- GList *targets;
- GList *iter;
+handle_text:
- targets = gdk_drag_context_list_targets (context);
+ address = camel_internet_address_new ();
+ text = (gchar *) gtk_selection_data_get_text (selection_data);
- for (iter = targets; iter != NULL; iter = iter->next) {
- GdkAtom target = GDK_POINTER_TO_ATOM (iter->data);
-
- if (e_targets_include_directory (&target, 1)) {
- gtk_drag_get_data (widget, context, target, time);
- return TRUE;
- }
+ /* See if Camel can parse a valid email address from the text. */
+ if (text != NULL && *text != '\0') {
+ camel_url_decode (text);
+ if (g_ascii_strncasecmp (text, "mailto:", 7) == 0)
+ n_addresses = camel_address_decode (
+ CAMEL_ADDRESS (address), text + 7);
+ else
+ n_addresses = camel_address_decode (
+ CAMEL_ADDRESS (address), text);
}
- return FALSE;
-}
+ if (n_addresses == 1) {
+ g_free (text);
-gboolean
-contact_list_editor_drag_motion_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x, gint y,
- guint time);
-
-gboolean
-contact_list_editor_drag_motion_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x, gint y,
- guint time)
-{
- GList *targets;
- GList *iter;
-
- targets = gdk_drag_context_list_targets (context);
+ text = camel_address_format (CAMEL_ADDRESS (address));
+ e_contact_list_model_add_email (model, text);
- for (iter = targets; iter != NULL; iter = iter->next) {
- GdkAtom target = GDK_POINTER_TO_ATOM (iter->data);
+ contact_list_editor_scroll_to_end (editor);
+ editor->priv->changed = TRUE;
- if (e_targets_include_directory (&target, 1)) {
- gdk_drag_status (context, GDK_ACTION_LINK, time);
- return TRUE;
- }
+ contact_list_editor_update (editor);
+ handled = TRUE;
}
- return FALSE;
+ g_free (text);
+
+exit:
+ gtk_drag_finish (context, handled, FALSE, time);
}
void
@@ -1315,6 +1298,7 @@ contact_list_editor_init (EContactListEditor *editor)
gtk_tree_view_enable_model_drag_dest (view, NULL, 0, GDK_ACTION_LINK);
e_drag_dest_add_directory_targets (WIDGET (TREE_VIEW));
+ gtk_drag_dest_add_text_targets (WIDGET (TREE_VIEW));
g_signal_connect (
priv->model, "row-deleted",