comparison console/libgnt/wms/s.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 70ffa34b4143
children f1e4121dcb1e
comparison
equal deleted inserted replaced
15749:f403bc58ba07 15750:0eb7846f9e7e
1 #include "gnt.h" 1 #include "gnt.h"
2 #include "gntbox.h" 2 #include "gntbox.h"
3 #include "gntmenu.h" 3 #include "gntmenu.h"
4 #include "gntstyle.h" 4 #include "gntstyle.h"
5 #include "gntwm.h" 5 #include "gntwm.h"
6 #include "gntwindow.h"
7 #include "gntlabel.h"
6 8
7 #include "blist.h" 9 #include "blist.h"
8 10
9 #include <string.h> 11 #include <string.h>
10 12
163 else 165 else
164 gaim_blist_show(); 166 gaim_blist_show();
165 return TRUE; 167 return TRUE;
166 } 168 }
167 169
170 static gboolean
171 toggle_clipboard(GntBindable *bindable, GList *n)
172 {
173 static GntWidget *clip;
174 gchar *text;
175 int maxx, maxy;
176 if (clip) {
177 gnt_widget_destroy(clip);
178 clip = NULL;
179 return TRUE;
180 }
181 getmaxyx(stdscr, maxy, maxx);
182 text = gnt_get_clipboard_string();
183 clip = gnt_hwindow_new(FALSE);
184 GNT_WIDGET_SET_FLAGS(clip, GNT_WIDGET_TRANSIENT);
185 GNT_WIDGET_UNSET_FLAGS(clip, GNT_WIDGET_NO_BORDER);
186 gnt_box_set_pad(GNT_BOX(clip), 0);
187 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" "));
188 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(text));
189 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" "));
190 gnt_widget_set_position(clip, 0, 0);
191 gnt_widget_draw(clip);
192 g_free(text);
193 return TRUE;
194 }
195
168 static void 196 static void
169 s_class_init(SClass *klass) 197 s_class_init(SClass *klass)
170 { 198 {
171 GntWMClass *pclass = GNT_WM_CLASS(klass); 199 GntWMClass *pclass = GNT_WM_CLASS(klass);
172 200
177 pclass->window_update = s_window_update; 205 pclass->window_update = s_window_update;
178 pclass->mouse_clicked = s_mouse_clicked; 206 pclass->mouse_clicked = s_mouse_clicked;
179 207
180 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-buddylist", 208 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-buddylist",
181 toggle_buddylist, "\033" "b", NULL); 209 toggle_buddylist, "\033" "b", NULL);
210 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-clipboard",
211 toggle_clipboard, "\033" "C", NULL);
182 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); 212 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass));
183 GNTDEBUG; 213 GNTDEBUG;
184 } 214 }
185 215
186 void gntwm_init(GntWM **wm) 216 void gntwm_init(GntWM **wm)