blob: e61c0800aa962d94abdabfd624a24b7d0b887ef4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/* Copyright (C) 2004 Michael Zucchi */
/* This file is licensed under the GNU GPL v2 or later */
/* Add 'copy to clipboard' things to various menu's.
Uh, so far only to copy mail addresses from mail content */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib/gi18n-lib.h>
#include <string.h>
#include "mail/em-popup.h"
#include <gtk/gtk.h>
#include "camel/camel-internet-address.h"
#include "camel/camel-url.h"
void org_gnome_copy_tool_copy_address(void *ep, EMPopupTargetURI *t);
void
org_gnome_copy_tool_copy_address(void *ep, EMPopupTargetURI *t)
{
if (t->uri) {
CamelInternetAddress *cia = camel_internet_address_new();
CamelURL *curl;
GtkClipboard *clipboard;
char *addr;
const char *tmp;
curl = camel_url_new(t->uri, NULL);
camel_address_decode((CamelAddress *)cia, curl->path);
/* should it perhaps use address format? */
addr = camel_address_encode((CamelAddress *)cia);
tmp = addr && addr[0] ? addr : t->uri + 7;
clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
gtk_clipboard_set_text (clipboard, tmp, strlen (tmp));
clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clipboard, tmp, strlen (tmp));
g_free(addr);
camel_url_free(curl);
camel_object_unref(cia);
}
}
|