annotate console/libgnt/wms/s.c @ 14931:d7732681329b

[gaim-migrate @ 17703] There's no default mouse-click handler in GntWM. So let's not crash trying to call that. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 08 Nov 2006 05:19:21 +0000
parents 065e7ac30338
children d08d7b7375c7
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"
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
7 #include "gntblist.h"
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
8
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 #include <string.h>
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
11 #define TYPE_S (s_get_gtype())
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
12
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
13 typedef struct _S
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 GntWM inherit;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
16 } S;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
17
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
18 typedef struct _SClass
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 GntWMClass inherit;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
21 } SClass;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
22
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
23 GType s_get_gtype(void);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
24 void gntwm_init(GntWM **wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
25
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
26 static void (*org_new_window)(GntWM *wm, GntWidget *win);
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
27
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
28 static void
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
29 envelope_buddylist(GntWidget *win)
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
30 {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
31 int w, h;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
32 gnt_widget_get_size(win, &w, &h);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
33 wresize(win->window, h, w + 1);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
34 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
35 touchwin(win->window);
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
36 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
37
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
38 static void
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
39 envelope_normal_window(GntWidget *win)
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
40 {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
41 int w, h;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
42
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
43 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
44 return;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
45
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
46 gnt_widget_get_size(win, &w, &h);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
47 wbkgdset(win->window, ' ' | COLOR_PAIR(GNT_COLOR_NORMAL));
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
48 mvwprintw(win->window, 0, w - 4, "[X]");
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
49 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
50
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
51 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
52 s_decorate_window(GntWM *wm, GntWidget *win)
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
53 {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
54 const char *name;
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 name = gnt_widget_get_name(win);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
57 if (name && strcmp(name, "buddylist") == 0) {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
58 envelope_buddylist(win);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
59 } else {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
60 envelope_normal_window(win);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
61 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
62 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
63
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
64 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
65 s_window_update(GntWM *wm, GntNode *node)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
66 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
67 s_decorate_window(wm, node->me);
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
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
70 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
71 s_new_window(GntWM *wm, GntWidget *win)
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 {
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 int x, y, w, h;
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 int maxx, maxy;
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 const char *name;
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
76 gboolean blist = FALSE;
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
78 if (!GNT_IS_MENU(win)) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
79 getmaxyx(stdscr, maxy, maxx);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
81 gnt_widget_get_position(win, &x, &y);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
82 gnt_widget_get_size(win, &w, &h);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
84 name = gnt_widget_get_name(win);
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 if (name && strcmp(name, "buddylist") == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
87 /* The buddylist doesn't have no border nor nothing! */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
88 x = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
89 y = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
90 h = maxy - 1;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
91 blist = TRUE;
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
93 gnt_box_set_toplevel(GNT_BOX(win), FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
94 GNT_WIDGET_SET_FLAGS(win, GNT_WIDGET_CAN_TAKE_FOCUS);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
96 gnt_widget_set_position(win, x, y);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
97 mvwin(win->window, y, x);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
99 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
100 } else if (name && strcmp(name, "conversation-window") == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
101 /* Put the conversation windows to the far-right */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
102 x = maxx - w;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
103 y = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
104 gnt_widget_set_position(win, x, y);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
105 mvwin(win->window, y, x);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
106 } else if (!GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_TRANSIENT)) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
107 /* In the middle of the screen */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
108 x = (maxx - w) / 2;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
109 y = (maxy - h) / 2;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
110
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
111 gnt_widget_set_position(win, x, y);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
112 mvwin(win->window, y, x);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
113 }
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114 }
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
115 org_new_window(wm, win);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
117 if (blist)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
118 gnt_wm_raise_window(wm, win);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 }
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
121 static GntWidget *
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
122 find_widget(GntWM *wm, const char *wname)
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
123 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
124 const GList *iter = wm->list;
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
125 for (; iter; iter = iter->next) {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
126 GntWidget *widget = iter->data;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
127 const char *name = gnt_widget_get_name(widget);
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
128 if (name && strcmp(name, wname) == 0) {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
129 return widget;
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 }
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
132 return NULL;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
133 }
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
134
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
135 static gboolean
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
136 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
137 {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
138 int x, y, w, h;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
139
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
140 if (!widget)
14931
d7732681329b [gaim-migrate @ 17703]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14900
diff changeset
141 return FALSE;
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
142 /* 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
143
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
144 if (event != GNT_LEFT_MOUSE_DOWN ||
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
145 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
146 return FALSE;
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
147
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
148 gnt_widget_get_position(widget, &x, &y);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
149 gnt_widget_get_size(widget, &w, &h);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
150
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
151 if (cy == y && cx == x + w - 3) {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
152 gnt_widget_destroy(widget);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
153 return TRUE;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
154 }
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
155
14931
d7732681329b [gaim-migrate @ 17703]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14900
diff changeset
156 return FALSE;
14900
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
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
159 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
160 toggle_buddylist(GntBindable *bindable, GList *null)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
161 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
162 GntWM *wm = GNT_WM(bindable);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
163 GntWidget *blist = find_widget(wm, "buddylist");
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
164 if (blist)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
165 gnt_widget_destroy(blist);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
166 else
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
167 gg_blist_show();
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
168 return TRUE;
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
169 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
170
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
171 static void
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
172 s_class_init(SClass *klass)
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
173 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
174 GntWMClass *pclass = GNT_WM_CLASS(klass);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
175
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
176 org_new_window = pclass->new_window;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
177
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
178 pclass->new_window = s_new_window;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
179 pclass->decorate_window = s_decorate_window;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
180 pclass->window_update = s_window_update;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
181 pclass->mouse_clicked = s_mouse_clicked;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
182
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
183 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
184 toggle_buddylist, "\033" "b", NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
185 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
186 GNTDEBUG;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
187 }
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
188
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
189 void gntwm_init(GntWM **wm)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
190 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
191 *wm = g_object_new(TYPE_S, NULL);
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
192 }
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
193
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
194 GType s_get_gtype(void)
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
196 static GType type = 0;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
197
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
198 if(type == 0) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
199 static const GTypeInfo info = {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
200 sizeof(SClass),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
201 NULL, /* base_init */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
202 NULL, /* base_finalize */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
203 (GClassInitFunc)s_class_init,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
204 NULL,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
205 NULL, /* class_data */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
206 sizeof(S),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
207 0, /* n_preallocs */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
208 NULL, /* instance_init */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
209 NULL
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
210 };
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
211
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
212 type = g_type_register_static(GNT_TYPE_WM,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
213 "GntS",
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
214 &info, 0);
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
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14847
diff changeset
217 return type;
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218 }
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219