Mercurial > pidgin
comparison console/libgnt/gntclipboard.c @ 15750:0eb7846f9e7e
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
If you use the s.so WM, pressing alt-shift-c ("toggle-clipboard") will toggle display of the clipboard contents in a possibly easy-to-copy-with-the-x-mouse window.
This includes a plugin which interacts with the X selection, which is not built by default.
author | Richard Nelson <wabz@pidgin.im> |
---|---|
date | Fri, 02 Mar 2007 01:48:11 +0000 |
parents | |
children | 1c8f1dc50685 |
comparison
equal
deleted
inserted
replaced
15749:f403bc58ba07 | 15750:0eb7846f9e7e |
---|---|
1 #include "gntclipboard.h" | |
2 | |
3 gchar *string; | |
4 | |
5 enum { | |
6 SIG_CLIPBOARD = 0, | |
7 SIGS | |
8 }; | |
9 | |
10 static guint signals[SIGS] = { 0 }; | |
11 | |
12 static void | |
13 gnt_clipboard_class_init(GntClipboardClass *klass) | |
14 { | |
15 signals[SIG_CLIPBOARD] = | |
16 g_signal_new("clipboard_changed", | |
17 G_TYPE_FROM_CLASS(klass), | |
18 G_SIGNAL_RUN_LAST, | |
19 0, | |
20 NULL, NULL, | |
21 g_cclosure_marshal_VOID__POINTER, | |
22 G_TYPE_NONE, 1, G_TYPE_POINTER); | |
23 | |
24 } | |
25 | |
26 static GObjectClass *parent_class = NULL; | |
27 /****************************************************************************** | |
28 * GntClipboard API | |
29 *****************************************************************************/ | |
30 | |
31 void | |
32 gnt_clipboard_set_string(GntClipboard *clipboard, gchar *string) | |
33 { | |
34 g_free(clipboard->string); | |
35 clipboard->string = g_strdup(string); | |
36 g_signal_emit(clipboard, signals[SIG_CLIPBOARD], 0, clipboard->string); | |
37 } | |
38 | |
39 gchar * | |
40 gnt_clipboard_get_string(GntClipboard *clipboard) | |
41 { | |
42 return g_strdup(clipboard->string); | |
43 } | |
44 | |
45 static void gnt_clipboard_init(GTypeInstance *instance, gpointer class) { | |
46 GntClipboard *clipboard = GNT_CLIPBOARD(instance); | |
47 clipboard->string = g_strdup(""); | |
48 } | |
49 | |
50 GType | |
51 gnt_clipboard_get_gtype(void) | |
52 { | |
53 static GType type = 0; | |
54 | |
55 if (type == 0) { | |
56 static const GTypeInfo info = { | |
57 sizeof(GntClipboardClass), | |
58 NULL, /* base_init */ | |
59 NULL, /* base_finalize */ | |
60 (GClassInitFunc)gnt_clipboard_class_init, | |
61 NULL, | |
62 NULL, /* class_data */ | |
63 sizeof(GntClipboard), | |
64 0, /* n_preallocs */ | |
65 gnt_clipboard_init, /* instance_init */ | |
66 }; | |
67 | |
68 type = g_type_register_static(G_TYPE_OBJECT, | |
69 "GntClipboard", | |
70 &info, 0); | |
71 } | |
72 | |
73 return type; | |
74 } |