Mercurial > pidgin
annotate console/libgnt/wms/s.c @ 15302:70ffa34b4143
[gaim-migrate @ 18093]
I think this is better.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 09 Jan 2007 00:24:55 +0000 |
parents | d08d7b7375c7 |
children | 0eb7846f9e7e |
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 |
15302
70ffa34b4143
[gaim-migrate @ 18093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15067
diff
changeset
|
7 #include "blist.h" |
14343
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 (!GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_TRANSIENT)) { |
15067
d08d7b7375c7
[gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14931
diff
changeset
|
101 const char *title = GNT_BOX(win)->title; |
d08d7b7375c7
[gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14931
diff
changeset
|
102 if (title == NULL || !g_hash_table_lookup(wm->positions, title)) { |
d08d7b7375c7
[gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14931
diff
changeset
|
103 /* In the middle of the screen */ |
d08d7b7375c7
[gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14931
diff
changeset
|
104 x = (maxx - w) / 2; |
d08d7b7375c7
[gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14931
diff
changeset
|
105 y = (maxy - h) / 2; |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
106 |
15067
d08d7b7375c7
[gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14931
diff
changeset
|
107 gnt_widget_set_position(win, x, y); |
d08d7b7375c7
[gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14931
diff
changeset
|
108 mvwin(win->window, y, x); |
d08d7b7375c7
[gaim-migrate @ 17851]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14931
diff
changeset
|
109 } |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
110 } |
14335
b1b76fb9c739
[gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 } |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
112 org_new_window(wm, win); |
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 if (blist) |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
115 gnt_wm_raise_window(wm, win); |
14335
b1b76fb9c739
[gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 } |
b1b76fb9c739
[gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
117 |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
118 static GntWidget * |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
119 find_widget(GntWM *wm, const char *wname) |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
120 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
121 const GList *iter = wm->list; |
14343
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
122 for (; iter; iter = iter->next) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
123 GntWidget *widget = iter->data; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
124 const char *name = gnt_widget_get_name(widget); |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
125 if (name && strcmp(name, wname) == 0) { |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
126 return widget; |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
127 } |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
128 } |
0387a167f342
[gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14335
diff
changeset
|
129 return NULL; |
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 |
14362
665b814f8fd7
[gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
132 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
133 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
|
134 { |
665b814f8fd7
[gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
135 int x, y, w, h; |
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 if (!widget) |
14931
d7732681329b
[gaim-migrate @ 17703]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14900
diff
changeset
|
138 return FALSE; |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
139 /* 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
|
140 |
665b814f8fd7
[gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
141 if (event != GNT_LEFT_MOUSE_DOWN || |
665b814f8fd7
[gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
142 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
|
143 return FALSE; |
14362
665b814f8fd7
[gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
144 |
665b814f8fd7
[gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
145 gnt_widget_get_position(widget, &x, &y); |
665b814f8fd7
[gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
146 gnt_widget_get_size(widget, &w, &h); |
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 if (cy == y && cx == x + w - 3) { |
665b814f8fd7
[gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
149 gnt_widget_destroy(widget); |
665b814f8fd7
[gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
150 return TRUE; |
665b814f8fd7
[gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
151 } |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
152 |
14931
d7732681329b
[gaim-migrate @ 17703]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14900
diff
changeset
|
153 return FALSE; |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
154 } |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
155 |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
156 static gboolean |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
157 toggle_buddylist(GntBindable *bindable, GList *null) |
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 GntWM *wm = GNT_WM(bindable); |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
160 GntWidget *blist = find_widget(wm, "buddylist"); |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
161 if (blist) |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
162 gnt_widget_destroy(blist); |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
163 else |
15302
70ffa34b4143
[gaim-migrate @ 18093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15067
diff
changeset
|
164 gaim_blist_show(); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
165 return TRUE; |
14362
665b814f8fd7
[gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
166 } |
665b814f8fd7
[gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14343
diff
changeset
|
167 |
14390
d4a26ada1971
[gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14362
diff
changeset
|
168 static void |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
169 s_class_init(SClass *klass) |
14390
d4a26ada1971
[gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14362
diff
changeset
|
170 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
171 GntWMClass *pclass = GNT_WM_CLASS(klass); |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
172 |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
173 org_new_window = pclass->new_window; |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
174 |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
175 pclass->new_window = s_new_window; |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
176 pclass->decorate_window = s_decorate_window; |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
177 pclass->window_update = s_window_update; |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
178 pclass->mouse_clicked = s_mouse_clicked; |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
179 |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
180 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
|
181 toggle_buddylist, "\033" "b", NULL); |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
182 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
|
183 GNTDEBUG; |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
184 } |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
185 |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
186 void gntwm_init(GntWM **wm) |
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 *wm = g_object_new(TYPE_S, NULL); |
14390
d4a26ada1971
[gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14362
diff
changeset
|
189 } |
d4a26ada1971
[gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14362
diff
changeset
|
190 |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
191 GType s_get_gtype(void) |
14335
b1b76fb9c739
[gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
192 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
193 static GType type = 0; |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
194 |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
195 if(type == 0) { |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
196 static const GTypeInfo info = { |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
197 sizeof(SClass), |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
198 NULL, /* base_init */ |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
199 NULL, /* base_finalize */ |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
200 (GClassInitFunc)s_class_init, |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
201 NULL, |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
202 NULL, /* class_data */ |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
203 sizeof(S), |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
204 0, /* n_preallocs */ |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
205 NULL, /* instance_init */ |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
206 NULL |
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 |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
209 type = g_type_register_static(GNT_TYPE_WM, |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
210 "GntS", |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
211 &info, 0); |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
212 } |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
213 |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14847
diff
changeset
|
214 return type; |
14335
b1b76fb9c739
[gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
215 } |
b1b76fb9c739
[gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
216 |