Tue, 22 Apr 2014 13:18:02 +0530
Merged default branch
|
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 | |
|
36751
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
25 | #define PLUGIN_ID "gntclipboard" |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
26 | #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
|
27 | #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
|
28 | |
|
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 | #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
|
30 | #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
|
31 | #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
|
32 | #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
|
33 | #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
|
34 | |
| 15843 | 35 | #include <sys/types.h> |
| 36 | #include <signal.h> | |
| 37 | ||
|
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 <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
|
39 | |
| 36382 | 40 | #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
|
41 | #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
|
42 | #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
|
43 | #include <notify.h> |
|
35877
6c3ab2fd4412
cross-win32: fix finch build
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34449
diff
changeset
|
44 | #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
|
45 | #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
|
46 | |
|
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
|
47 | #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
|
48 | |
|
19750
67bbae7ab8fc
Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16748
diff
changeset
|
49 | #ifdef HAVE_X11 |
| 15843 | 50 | 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
|
51 | |
|
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 | 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
|
53 | |
| 15843 | 54 | 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
|
55 | 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
|
56 | { |
|
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 | 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
|
58 | 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
|
59 | 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
|
60 | 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
|
61 | 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
|
62 | |
|
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 (!dpy) |
| 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 | 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
|
66 | if (ids == NULL) |
| 15843 | 67 | 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
|
68 | 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
|
69 | 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
|
70 | 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
|
71 | XSelectInput(dpy, w, StructureNotifyMask); |
| 15843 | 72 | while (TRUE) { |
| 73 | 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
|
74 | 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
|
75 | 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
|
76 | 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
|
77 | 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
|
78 | 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
|
79 | 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
|
80 | 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
|
81 | (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
|
82 | 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
|
83 | 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
|
84 | 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
|
85 | 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
|
86 | 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
|
87 | 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
|
88 | 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
|
89 | 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
|
90 | 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
|
91 | 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
|
92 | } else if (e.type == SelectionClear) { |
| 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 | } |
| 15843 | 96 | 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
|
97 | } |
|
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 | |
|
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
|
99 | 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
|
100 | 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
|
101 | { |
| 15843 | 102 | if (child) { |
| 103 | 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
|
104 | } |
| 15843 | 105 | if ((child = fork() == 0)) { |
| 106 | set_clip(string); | |
| 107 | _exit(0); | |
| 108 | } | |
|
19750
67bbae7ab8fc
Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16748
diff
changeset
|
109 | } |
|
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
|
110 | #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
|
111 | |
|
36751
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
112 | static FinchPluginInfo * |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
113 | plugin_query(GError **error) |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
114 | { |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
115 | const gchar * const authors[] = { |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
116 | "Richard Nelson <wabz@whatsbeef.net>", |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
117 | NULL |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
118 | }; |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
119 | |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
120 | return finch_plugin_info_new( |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
121 | "id", PLUGIN_ID, |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
122 | "name", N_("GntClipboard"), |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
123 | "version", DISPLAY_VERSION, |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
124 | "category", N_("Utility"), |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
125 | "summary", N_("Clipboard plugin"), |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
126 | "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
|
127 | "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
|
128 | "authors", authors, |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
129 | "website", PURPLE_WEBSITE, |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
130 | "abi-version", PURPLE_ABI_VERSION, |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
131 | NULL |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
132 | ); |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
133 | } |
|
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
134 | |
|
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
|
135 | static gboolean |
|
36751
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
136 | 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
|
137 | { |
|
15954
f59ab2031ceb
Build gntclipboard plugin by default. If we don't want this, at least
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15924
diff
changeset
|
138 | #ifdef HAVE_X11 |
| 15843 | 139 | if (!XOpenDisplay(NULL)) { |
| 15884 | 140 | 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
|
141 | 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
|
142 | _("Couldn't find X display"), NULL); |
| 15843 | 143 | return FALSE; |
| 144 | } | |
| 145 | if (!getenv("WINDOWID")) { | |
| 15884 | 146 | 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
|
147 | 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
|
148 | _("Couldn't find window"), NULL); |
| 15843 | 149 | return FALSE; |
| 150 | } | |
|
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
|
151 | 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
|
152 | 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
|
153 | #else |
|
36751
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
154 | 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
|
155 | "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
|
156 | return FALSE; |
|
67bbae7ab8fc
Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16748
diff
changeset
|
157 | #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
|
158 | } |
|
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 | |
|
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 | static gboolean |
|
36751
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
161 | 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
|
162 | { |
|
19750
67bbae7ab8fc
Show a helpful error message when the plugin fails to load.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16748
diff
changeset
|
163 | #ifdef HAVE_X11 |
| 15843 | 164 | if (child) { |
| 165 | kill(child, SIGTERM); | |
| 166 | child = 0; | |
| 167 | } | |
|
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
|
168 | 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
|
169 | #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
|
170 | 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
|
171 | } |
|
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
|
172 | |
|
36751
a9f6ae7c308e
Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36382
diff
changeset
|
173 | PURPLE_PLUGIN_INIT(PLUGIN_STATIC_NAME, plugin_query, plugin_load, plugin_unload); |