Wed, 02 Oct 2019 02:34:03 -0400
finch: Fix incorrect call to fork.
|
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 | * 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
|
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 | * 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
|
5 | * 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
|
6 | * 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
|
7 | * (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
|
8 | * |
|
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 | * 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
|
10 | * 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
|
11 | * 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
|
12 | * 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
|
13 | * |
|
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 | * 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
|
15 | * 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
|
16 | * 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
|
17 | */ |
|
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
|
18 | |
|
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 | #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
|
20 | #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
|
21 | |
|
36751
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
22 | #define PLUGIN_ID "gntclipboard" |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
23 | #define PLUGIN_DOMAIN (g_quark_from_static_string(PLUGIN_ID)) |
|
36754
8250d6be8c02
Started refactoring pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36751
diff
changeset
|
24 | #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
|
25 | |
|
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 | #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
|
27 | #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
|
28 | #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
|
29 | #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
|
30 | #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
|
31 | |
| 15843 | 32 | #include <sys/types.h> |
| 33 | #include <signal.h> | |
| 34 | ||
|
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
|
35 | #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
|
36 | |
| 36382 | 37 | #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
|
38 | #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
|
39 | #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
|
40 | #include <notify.h> |
|
35877
6c3ab2fd4412
cross-win32: fix finch build
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34449
diff
changeset
|
41 | #include <gnt.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 | 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 | 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 | 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 | 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 | 69 | while (TRUE) { |
| 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 | 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 | 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 | 99 | if (child) { |
| 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 | } |
|
39906
79a00e51853d
finch: Fix incorrect call to fork.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39886
diff
changeset
|
102 | if ((child = fork()) == 0) { |
| 15843 | 103 | set_clip(string); |
| 104 | _exit(0); | |
| 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 | |
|
36751
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
109 | static FinchPluginInfo * |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
110 | plugin_query(GError **error) |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
111 | { |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
112 | const gchar * const authors[] = { |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
113 | "Richard Nelson <wabz@whatsbeef.net>", |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
114 | NULL |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
115 | }; |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
116 | |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
117 | return finch_plugin_info_new( |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
118 | "id", PLUGIN_ID, |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
119 | "name", N_("GntClipboard"), |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
120 | "version", DISPLAY_VERSION, |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
121 | "category", N_("Utility"), |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
122 | "summary", N_("Clipboard plugin"), |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
123 | "description", N_("When the gnt clipboard contents change, the " |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
124 | "contents are made available to X, if possible."), |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
125 | "authors", authors, |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
126 | "website", PURPLE_WEBSITE, |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
127 | "abi-version", PURPLE_ABI_VERSION, |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
128 | NULL |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
129 | ); |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
130 | } |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
131 | |
|
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 | static gboolean |
|
36751
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
133 | plugin_load(PurplePlugin *plugin, GError **error) |
|
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
|
134 | { |
|
15954
f59ab2031ceb
Build gntclipboard plugin by default. If we don't want this, at least
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15924
diff
changeset
|
135 | #ifdef HAVE_X11 |
| 15843 | 136 | if (!XOpenDisplay(NULL)) { |
| 15884 | 137 | 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
|
138 | purple_notify_error(NULL, _("Error"), _("Error loading the plugin."), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
25633
diff
changeset
|
139 | _("Couldn't find X display"), NULL); |
| 15843 | 140 | return FALSE; |
| 141 | } | |
| 142 | if (!getenv("WINDOWID")) { | |
| 15884 | 143 | 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
|
144 | purple_notify_error(NULL, _("Error"), _("Error loading the plugin."), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
25633
diff
changeset
|
145 | _("Couldn't find window"), NULL); |
| 15843 | 146 | return FALSE; |
| 147 | } | |
|
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 | 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
|
149 | 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
|
150 | #else |
|
36751
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
151 | g_set_error(error, PLUGIN_DOMAIN, 0, _("This plugin cannot be loaded " |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
152 | "because it was not built with X11 support.")); |
|
19750
67bbae7ab8fc
Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16748
diff
changeset
|
153 | return FALSE; |
|
67bbae7ab8fc
Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16748
diff
changeset
|
154 | #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
|
155 | } |
|
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
|
156 | |
|
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 | static gboolean |
|
36751
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
158 | plugin_unload(PurplePlugin *plugin, GError **error) |
|
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
|
159 | { |
|
19750
67bbae7ab8fc
Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16748
diff
changeset
|
160 | #ifdef HAVE_X11 |
| 15843 | 161 | if (child) { |
| 162 | kill(child, SIGTERM); | |
| 163 | child = 0; | |
| 164 | } | |
|
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 | 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
|
166 | #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
|
167 | 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
|
168 | } |
|
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 | |
|
36751
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
170 | PURPLE_PLUGIN_INIT(PLUGIN_STATIC_NAME, plugin_query, plugin_load, plugin_unload); |