annotate console/libgnt/wms/s.c @ 15765:f1e4121dcb1e

Fix a crash when selecting text in an empty TV.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 05 Mar 2007 01:26:31 +0000
parents 0eb7846f9e7e
children 94867b2f38f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14422
diff changeset
1 #include "gnt.h"
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 #include "gntbox.h"
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14422
diff changeset
3 #include "gntmenu.h"
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
4 #include "gntstyle.h"
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 #include "gntwm.h"
15751
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
6 #include "gntwindow.h"
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
7 #include "gntlabel.h"
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8
15303
70ffa34b4143 [gaim-migrate @ 18093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15068
diff changeset
9 #include "blist.h"
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
10
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 #include <string.h>
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
13 #define TYPE_S (s_get_gtype())
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
14
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
15 typedef struct _S
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
16 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
17 GntWM inherit;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
18 } S;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
19
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
20 typedef struct _SClass
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
21 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
22 GntWMClass inherit;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
23 } SClass;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
24
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
25 GType s_get_gtype(void);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
26 void gntwm_init(GntWM **wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
27
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
28 static void (*org_new_window)(GntWM *wm, GntWidget *win);
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
29
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
30 static void
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
31 envelope_buddylist(GntWidget *win)
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
32 {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
33 int w, h;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
34 gnt_widget_get_size(win, &w, &h);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
35 wresize(win->window, h, w + 1);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
36 mvwvline(win->window, 0, w, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL), h);
14422
84a480acb6ad [gaim-migrate @ 17130]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
37 touchwin(win->window);
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
38 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
39
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
40 static void
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
41 envelope_normal_window(GntWidget *win)
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
42 {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
43 int w, h;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
44
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
45 if (GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_NO_BORDER | GNT_WIDGET_TRANSIENT))
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
46 return;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
47
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
48 gnt_widget_get_size(win, &w, &h);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
49 wbkgdset(win->window, ' ' | COLOR_PAIR(GNT_COLOR_NORMAL));
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
50 mvwprintw(win->window, 0, w - 4, "[X]");
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
51 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
52
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
53 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
54 s_decorate_window(GntWM *wm, GntWidget *win)
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
55 {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
56 const char *name;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
57
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
58 name = gnt_widget_get_name(win);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
59 if (name && strcmp(name, "buddylist") == 0) {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
60 envelope_buddylist(win);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
61 } else {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
62 envelope_normal_window(win);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
63 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
64 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
65
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
66 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
67 s_window_update(GntWM *wm, GntNode *node)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
68 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
69 s_decorate_window(wm, node->me);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
70 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
71
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
72 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
73 s_new_window(GntWM *wm, GntWidget *win)
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 {
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 int x, y, w, h;
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76 int maxx, maxy;
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 const char *name;
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
78 gboolean blist = FALSE;
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
80 if (!GNT_IS_MENU(win)) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
81 getmaxyx(stdscr, maxy, maxx);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
83 gnt_widget_get_position(win, &x, &y);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
84 gnt_widget_get_size(win, &w, &h);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
86 name = gnt_widget_get_name(win);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
88 if (name && strcmp(name, "buddylist") == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
89 /* The buddylist doesn't have no border nor nothing! */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
90 x = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
91 y = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
92 h = maxy - 1;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
93 blist = TRUE;
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
95 gnt_box_set_toplevel(GNT_BOX(win), FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
96 GNT_WIDGET_SET_FLAGS(win, GNT_WIDGET_CAN_TAKE_FOCUS);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
98 gnt_widget_set_position(win, x, y);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
99 mvwin(win->window, y, x);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
101 gnt_widget_set_size(win, -1, h + 2); /* XXX: Why is the +2 needed here? -- sadrul */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
102 } else if (!GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_TRANSIENT)) {
15068
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14931
diff changeset
103 const char *title = GNT_BOX(win)->title;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14931
diff changeset
104 if (title == NULL || !g_hash_table_lookup(wm->positions, title)) {
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14931
diff changeset
105 /* In the middle of the screen */
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14931
diff changeset
106 x = (maxx - w) / 2;
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14931
diff changeset
107 y = (maxy - h) / 2;
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
108
15068
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14931
diff changeset
109 gnt_widget_set_position(win, x, y);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14931
diff changeset
110 mvwin(win->window, y, x);
d08d7b7375c7 [gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14931
diff changeset
111 }
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
112 }
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 }
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
114 org_new_window(wm, win);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
116 if (blist)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
117 gnt_wm_raise_window(wm, win);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 }
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
120 static GntWidget *
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
121 find_widget(GntWM *wm, const char *wname)
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
122 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
123 const GList *iter = wm->list;
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
124 for (; iter; iter = iter->next) {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
125 GntWidget *widget = iter->data;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
126 const char *name = gnt_widget_get_name(widget);
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
127 if (name && strcmp(name, wname) == 0) {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
128 return widget;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
129 }
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
130 }
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
131 return NULL;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
132 }
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
133
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
134 static gboolean
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
135 s_mouse_clicked(GntWM *wm, GntMouseEvent event, int cx, int cy, GntWidget *widget)
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
136 {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
137 int x, y, w, h;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
138
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
139 if (!widget)
14931
d7732681329b [gaim-migrate @ 17703]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14900
diff changeset
140 return FALSE;
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
141 /* This might be a place to bring up a context menu */
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
142
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
143 if (event != GNT_LEFT_MOUSE_DOWN ||
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
144 GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER))
14931
d7732681329b [gaim-migrate @ 17703]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14900
diff changeset
145 return FALSE;
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
146
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
147 gnt_widget_get_position(widget, &x, &y);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
148 gnt_widget_get_size(widget, &w, &h);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
149
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
150 if (cy == y && cx == x + w - 3) {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
151 gnt_widget_destroy(widget);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
152 return TRUE;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
153 }
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
154
14931
d7732681329b [gaim-migrate @ 17703]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14900
diff changeset
155 return FALSE;
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
156 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
157
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
158 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
159 toggle_buddylist(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
160 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
161 GntWM *wm = GNT_WM(bindable);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
162 GntWidget *blist = find_widget(wm, "buddylist");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
163 if (blist)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
164 gnt_widget_destroy(blist);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
165 else
15303
70ffa34b4143 [gaim-migrate @ 18093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15068
diff changeset
166 gaim_blist_show();
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
167 return TRUE;
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
168 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
169
15751
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
170 static gboolean
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
171 toggle_clipboard(GntBindable *bindable, GList *n)
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
172 {
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
173 static GntWidget *clip;
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
174 gchar *text;
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
175 int maxx, maxy;
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
176 if (clip) {
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
177 gnt_widget_destroy(clip);
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
178 clip = NULL;
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
179 return TRUE;
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
180 }
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
181 getmaxyx(stdscr, maxy, maxx);
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
182 text = gnt_get_clipboard_string();
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
183 clip = gnt_hwindow_new(FALSE);
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
184 GNT_WIDGET_SET_FLAGS(clip, GNT_WIDGET_TRANSIENT);
15765
f1e4121dcb1e Fix a crash when selecting text in an empty TV.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15751
diff changeset
185 GNT_WIDGET_SET_FLAGS(clip, GNT_WIDGET_NO_BORDER);
15751
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
186 gnt_box_set_pad(GNT_BOX(clip), 0);
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
187 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" "));
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
188 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(text));
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
189 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" "));
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
190 gnt_widget_set_position(clip, 0, 0);
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
191 gnt_widget_draw(clip);
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
192 g_free(text);
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
193 return TRUE;
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
194 }
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
195
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
196 static void
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
197 s_class_init(SClass *klass)
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
198 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
199 GntWMClass *pclass = GNT_WM_CLASS(klass);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
200
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
201 org_new_window = pclass->new_window;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
202
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
203 pclass->new_window = s_new_window;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
204 pclass->decorate_window = s_decorate_window;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
205 pclass->window_update = s_window_update;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
206 pclass->mouse_clicked = s_mouse_clicked;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
207
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
208 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-buddylist",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
209 toggle_buddylist, "\033" "b", NULL);
15751
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
210 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-clipboard",
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).
Richard Nelson <wabz@pidgin.im>
parents: 15303
diff changeset
211 toggle_clipboard, "\033" "C", NULL);
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
212 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass));
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
213 GNTDEBUG;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
214 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
215
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
216 void gntwm_init(GntWM **wm)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
217 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
218 *wm = g_object_new(TYPE_S, NULL);
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
219 }
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
220
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
221 GType s_get_gtype(void)
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
223 static GType type = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
224
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
225 if(type == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
226 static const GTypeInfo info = {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
227 sizeof(SClass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
228 NULL, /* base_init */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
229 NULL, /* base_finalize */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
230 (GClassInitFunc)s_class_init,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
231 NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
232 NULL, /* class_data */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
233 sizeof(S),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
234 0, /* n_preallocs */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
235 NULL, /* instance_init */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
236 NULL
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
237 };
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
238
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
239 type = g_type_register_static(GNT_TYPE_WM,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
240 "GntS",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
241 &info, 0);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
242 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
243
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
244 return type;
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245 }
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
246