finch/plugins/gntclipboard.c

Mon, 29 Jul 2013 11:52:27 +0530

author
Ankit Vani <a@nevitus.org>
date
Mon, 29 Jul 2013 11:52:27 +0530
branch
soc.2013.gobjectification.plugins
changeset 36367
891eea799578
parent 25633
feee0c7e503f
child 36382
d3dafd8ef4df
permissions
-rw-r--r--

Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.

15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
1 /**
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
2 * @file gntclipboard.c
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
3 *
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2007 Richard Nelson <wabz@whatsbeef.net>
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
5 *
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
10 *
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
15 *
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19750
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
19 */
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
20
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
21
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
22 #include "internal.h"
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
23 #include <glib.h>
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
24
25633
feee0c7e503f Fix some more mis-identified plugins, like 3b3526a0...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 20288
diff changeset
25 #define PLUGIN_STATIC_NAME GntClipboard
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
26
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
27 #ifdef HAVE_X11
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
28 #include <X11/Xlib.h>
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
29 #include <X11/Xutil.h>
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
30 #include <X11/Xatom.h>
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
31 #endif
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
32
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
33 #include <sys/types.h>
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
34 #include <signal.h>
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
35
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
36 #include <glib.h>
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
37
36367
891eea799578 Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents: 25633
diff changeset
38 #include <<plugins.h>>
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
39 #include <version.h>
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
40 #include <debug.h>
19750
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
41 #include <notify.h>
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
42 #include <gntwm.h>
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
43
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
44 #include <gntplugin.h>
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
45
19750
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
46 #ifdef HAVE_X11
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
47 static pid_t child = 0;
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
48
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
49 static gulong sig_handle;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
50
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
51 static void
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
52 set_clip(gchar *string)
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
53 {
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
54 Window w;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
55 XEvent e, respond;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
56 XSelectionRequestEvent *req;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
57 const char *ids;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
58 Display *dpy = XOpenDisplay(NULL);
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
59
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
60 if (!dpy)
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
61 return;
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
62 ids = getenv("WINDOWID");
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
63 if (ids == NULL)
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
64 return;
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
65 w = atoi(ids);
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
66 XSetSelectionOwner(dpy, XA_PRIMARY, w, CurrentTime);
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
67 XFlush(dpy);
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
68 XSelectInput(dpy, w, StructureNotifyMask);
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
69 while (TRUE) {
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
70 XNextEvent(dpy, &e); /* this blocks. */
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
71 req = &e.xselectionrequest;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
72 if (e.type == SelectionRequest) {
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
73 XChangeProperty(dpy,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
74 req->requestor,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
75 req->property,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
76 XA_STRING,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
77 8, PropModeReplace,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
78 (unsigned char *)string,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
79 strlen(string));
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
80 respond.xselection.property = req->property;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
81 respond.xselection.type = SelectionNotify;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
82 respond.xselection.display = req->display;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
83 respond.xselection.requestor = req->requestor;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
84 respond.xselection.selection = req->selection;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
85 respond.xselection.target= req->target;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
86 respond.xselection.time = req->time;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
87 XSendEvent(dpy, req->requestor, 0, 0, &respond);
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
88 XFlush (dpy);
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
89 } else if (e.type == SelectionClear) {
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
90 return;
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
91 }
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
92 }
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
93 return;
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
94 }
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
95
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
96 static void
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
97 clipboard_changed(GntWM *wm, gchar *string)
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
98 {
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
99 if (child) {
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
100 kill(child, SIGTERM);
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
101 }
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
102 if ((child = fork() == 0)) {
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
103 set_clip(string);
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
104 _exit(0);
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
105 }
19750
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
106 }
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
107 #endif
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
108
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
109 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
110 plugin_load(PurplePlugin *plugin)
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
111 {
15954
f59ab2031ceb Build gntclipboard plugin by default. If we don't want this, at least
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15924
diff changeset
112 #ifdef HAVE_X11
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
113 if (!XOpenDisplay(NULL)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
114 purple_debug_warning("gntclipboard", "Couldn't find X display\n");
19750
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
115 purple_notify_error(NULL, _("Error"), _("Error loading the plugin."),
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
116 _("Couldn't find X display"));
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
117 return FALSE;
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
118 }
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
119 if (!getenv("WINDOWID")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
120 purple_debug_warning("gntclipboard", "Couldn't find window\n");
19750
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
121 purple_notify_error(NULL, _("Error"), _("Error loading the plugin."),
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
122 _("Couldn't find window"));
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
123 return FALSE;
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
124 }
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
125 sig_handle = g_signal_connect(G_OBJECT(gnt_get_clipboard()), "clipboard_changed", G_CALLBACK(clipboard_changed), NULL);
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
126 return TRUE;
19750
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
127 #else
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
128 purple_notify_error(NULL, _("Error"), _("Error loading the plugin."),
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
129 _("This plugin cannot be loaded because it was not built with X11 support."));
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
130 return FALSE;
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
131 #endif
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
132 }
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
133
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
134 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
135 plugin_unload(PurplePlugin *plugin)
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
136 {
19750
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
137 #ifdef HAVE_X11
15843
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
138 if (child) {
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
139 kill(child, SIGTERM);
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
140 child = 0;
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15814
diff changeset
141 }
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
142 g_signal_handler_disconnect(G_OBJECT(gnt_get_clipboard()), sig_handle);
19750
67bbae7ab8fc Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16748
diff changeset
143 #endif
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
144 return TRUE;
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
145 }
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
146
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
147 static PurplePluginInfo info =
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
148 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
149 PURPLE_PLUGIN_MAGIC,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
150 PURPLE_MAJOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
151 PURPLE_MINOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
152 PURPLE_PLUGIN_STANDARD,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
153 FINCH_PLUGIN_TYPE,
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
154 0,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
155 NULL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
156 PURPLE_PRIORITY_DEFAULT,
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
157 "gntclipboard",
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
158 N_("GntClipboard"),
20288
5ca925a094e2 applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
159 DISPLAY_VERSION,
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
160 N_("Clipboard plugin"),
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
161 N_("When the gnt clipboard contents change, "
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
162 "the contents are made available to X, if possible."),
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
163 "Richard Nelson <wabz@whatsbeef.net>",
15924
1e6022a75ba9 Use PURPLE_WEBSITE instead of listing the website directly (which was wrong because of the sed).
Richard Laager <rlaager@pidgin.im>
parents: 15906
diff changeset
164 PURPLE_WEBSITE,
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
165 plugin_load,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
166 plugin_unload,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
167 NULL,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
168 NULL,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
169 NULL,
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
170 NULL,
16748
f8e1573bfde0 And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 15954
diff changeset
171 NULL,
f8e1573bfde0 And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 15954
diff changeset
172
f8e1573bfde0 And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 15954
diff changeset
173 /* padding */
f8e1573bfde0 And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 15954
diff changeset
174 NULL,
f8e1573bfde0 And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 15954
diff changeset
175 NULL,
f8e1573bfde0 And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 15954
diff changeset
176 NULL,
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
177 NULL
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
178 };
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
179
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
180 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
181 init_plugin(PurplePlugin *plugin)
15814
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
182 {
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
183 }
2db42c6a13fa Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
diff changeset
184
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
185 PURPLE_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info)

mercurial