annotate console/libgnt/gntmain.c @ 15025:c039c920e11c

[gaim-migrate @ 17807] Thanks to everyone who worked on OpenQ! Please let me know if I left anything/anyone out. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Wed, 22 Nov 2006 15:29:57 +0000
parents 1c0772f7260b
children acc8a838ad94
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
1 #define _GNU_SOURCE
14738
e1cfdb131c62 [gaim-migrate @ 17494]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14737
diff changeset
2 #if defined(__APPLE__)
e1cfdb131c62 [gaim-migrate @ 17494]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14737
diff changeset
3 #define _XOPEN_SOURCE_EXTENDED
e1cfdb131c62 [gaim-migrate @ 17494]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14737
diff changeset
4 #endif
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
5
14421
553bbd68387e [gaim-migrate @ 17129]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14415
diff changeset
6 #include "config.h"
553bbd68387e [gaim-migrate @ 17129]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14415
diff changeset
7
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
8 #include <gmodule.h>
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
9
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 #include "gnt.h"
13888
9d66969a2e32 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
11 #include "gntbox.h"
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
12 #include "gntcolors.h"
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 #include "gntkeys.h"
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
14 #include "gntmenu.h"
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
15 #include "gntstyle.h"
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
16 #include "gnttree.h"
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
17 #include "gntutils.h"
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
18 #include "gntwm.h"
13888
9d66969a2e32 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
19
14431
0ed8b285a44b [gaim-migrate @ 17145]
Mark Doliner <mark@kingant.net>
parents: 14428
diff changeset
20 #include <panel.h>
0ed8b285a44b [gaim-migrate @ 17145]
Mark Doliner <mark@kingant.net>
parents: 14428
diff changeset
21
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 #include <stdio.h>
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 #include <stdlib.h>
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 #include <locale.h>
13888
9d66969a2e32 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
25 #include <unistd.h>
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
26 #include <signal.h>
13888
9d66969a2e32 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
27 #include <string.h>
14220
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
28 #include <ctype.h>
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
29 #include <errno.h>
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
30
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
31 #include <sys/types.h>
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
32 #include <sys/wait.h>
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
34 /**
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
35 * Notes: Interesting functions to look at:
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
36 * scr_dump, scr_init, scr_restore: for workspaces
14131
db2311999862 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14125
diff changeset
37 *
db2311999862 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14125
diff changeset
38 * Need to wattrset for colors to use with PDCurses.
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
39 */
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
40
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
41 static GIOChannel *channel = NULL;
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
42
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
43 static gboolean ascii_only;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
44 static gboolean mouse_enabled;
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
45
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
46 static void setup_io();
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
47
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
48 static gboolean refresh_screen();
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
49
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
50 GntWM *wm;
14245
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
51
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
52 /**
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
53 * Mouse support:
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
54 * - bring a window on top if you click on its taskbar
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
55 * - click on the top-bar of the active window and drag+drop to move a window
14325
985e5e3f6f2c [gaim-migrate @ 17020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14317
diff changeset
56 * - click on a window to bring it to focus
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
57 * - allow scrolling in tree/textview on wheel-scroll event
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
58 * - click to activate button or select a row in tree
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
59 * wishlist:
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
60 * - have a little [X] on the windows, and clicking it will close that window.
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
61 */
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
62 static gboolean
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
63 detect_mouse_action(const char *buffer)
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
64 {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
65 int x, y;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
66 static enum {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
67 MOUSE_NONE,
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
68 MOUSE_LEFT,
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
69 MOUSE_RIGHT,
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
70 MOUSE_MIDDLE
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
71 } button = MOUSE_NONE;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
72 static GntWidget *remember = NULL;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
73 static int offset = 0;
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
74 GntMouseEvent event;
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
75 GntWidget *widget = NULL;
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
76 PANEL *p = NULL;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
77
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
78 if (!wm->ordered || buffer[0] != 27)
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
79 return FALSE;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
80
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
81 buffer++;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
82 if (strlen(buffer) < 5)
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
83 return FALSE;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
84
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
85 x = buffer[3];
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
86 y = buffer[4];
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
87 if (x < 0) x += 256;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
88 if (y < 0) y += 256;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
89 x -= 33;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
90 y -= 33;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
91
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
92 while ((p = panel_below(p)) != NULL) {
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
93 const GntNode *node = panel_userptr(p);
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
94 GntWidget *wid;
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
95 if (!node)
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
96 continue;
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
97 wid = node->me;
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
98 if (x >= wid->priv.x && x < wid->priv.x + wid->priv.width) {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
99 if (y >= wid->priv.y && y < wid->priv.y + wid->priv.height) {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
100 widget = wid;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
101 break;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
102 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
103 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
104 }
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
105
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
106 if (strncmp(buffer, "[M ", 3) == 0) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
107 /* left button down */
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
108 /* Bring the window you clicked on to front */
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
109 /* If you click on the topbar, then you can drag to move the window */
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
110 event = GNT_LEFT_MOUSE_DOWN;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
111 } else if (strncmp(buffer, "[M\"", 3) == 0) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
112 /* right button down */
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
113 event = GNT_RIGHT_MOUSE_DOWN;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
114 } else if (strncmp(buffer, "[M!", 3) == 0) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
115 /* middle button down */
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
116 event = GNT_MIDDLE_MOUSE_DOWN;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
117 } else if (strncmp(buffer, "[M`", 3) == 0) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
118 /* wheel up*/
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
119 event = GNT_MOUSE_SCROLL_UP;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
120 } else if (strncmp(buffer, "[Ma", 3) == 0) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
121 /* wheel down */
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
122 event = GNT_MOUSE_SCROLL_DOWN;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
123 } else if (strncmp(buffer, "[M#", 3) == 0) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
124 /* button up */
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
125 event = GNT_MOUSE_UP;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
126 } else
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
127 return FALSE;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
128
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
129 if (gnt_wm_process_click(wm, event, x, y, widget))
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
130 return TRUE;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
131
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
132 if (event == GNT_LEFT_MOUSE_DOWN && widget && widget != wm->_list.window &&
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
133 !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
134 if (widget != wm->ordered->data) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
135 gnt_wm_raise_window(wm, 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 if (y == widget->priv.y) {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
138 offset = x - widget->priv.x;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
139 remember = widget;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
140 button = MOUSE_LEFT;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
141 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
142 } else if (event == GNT_MOUSE_UP) {
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
143 if (button == MOUSE_NONE && y == getmaxy(stdscr) - 1) {
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
144 /* Clicked on the taskbar */
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
145 int n = g_list_length(wm->list);
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
146 if (n) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
147 int width = getmaxx(stdscr) / n;
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
148 gnt_bindable_perform_action_named(GNT_BINDABLE(wm), "switch-window-n", x/width, NULL);
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
149 }
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
150 } else if (button == MOUSE_LEFT && remember) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
151 x -= offset;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
152 if (x < 0) x = 0;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
153 if (y < 0) y = 0;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
154 gnt_screen_move_widget(remember, x, y);
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
155 }
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
156 button = MOUSE_NONE;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
157 remember = NULL;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
158 offset = 0;
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
159 }
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
160
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
161 gnt_widget_clicked(widget, event, x, y);
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
162 return TRUE;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
163 }
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
164
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
165 static gboolean
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
166 io_invoke_error(GIOChannel *source, GIOCondition cond, gpointer data)
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
167 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
168 int id = GPOINTER_TO_INT(data);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
169 g_source_remove(id);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
170 g_io_channel_unref(source);
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
171
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
172 channel = NULL;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
173 setup_io();
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
174 return TRUE;
14415
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
175 }
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
176
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 static gboolean
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 {
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
180 char keys[256];
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
181 int rd = read(STDIN_FILENO, keys, sizeof(keys) - 1);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 if (rd < 0)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 {
14881
5228f8cf2a6a [gaim-migrate @ 17650]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14876
diff changeset
184 int ch = getch(); /* This should return ERR, but let's see what it really returns */
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 endwin();
14680
fa285d018c71 [gaim-migrate @ 17432]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14627
diff changeset
186 printf("ERROR: %s\n", strerror(errno));
14881
5228f8cf2a6a [gaim-migrate @ 17650]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14876
diff changeset
187 printf("File descriptor is: %d\n\nGIOChannel is: %p\ngetch() = %d\n", STDIN_FILENO, source, ch);
5228f8cf2a6a [gaim-migrate @ 17650]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14876
diff changeset
188 raise(SIGABRT);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190 else if (rd == 0)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 endwin();
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193 printf("EOF\n");
14881
5228f8cf2a6a [gaim-migrate @ 17650]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14876
diff changeset
194 raise(SIGABRT);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
197 keys[rd] = 0;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
198 gnt_keys_refine(keys);
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
199
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
200 if (mouse_enabled && detect_mouse_action(keys))
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
201 return TRUE;
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
202
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
203 gnt_wm_process_input(wm, keys);
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
204
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
205 return TRUE;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
206 }
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
207
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
208 static void
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
209 setup_io()
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
210 {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
211 int result;
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
212 channel = g_io_channel_unix_new(STDIN_FILENO);
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
213
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
214 g_io_channel_set_encoding(channel, NULL, NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
215 g_io_channel_set_buffered(channel, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
216 #if 0
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
217 g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL );
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
218 #endif
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
219
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
220 result = g_io_add_watch_full(channel, G_PRIORITY_HIGH,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
221 (G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
222 io_invoke, NULL, NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
223
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
224 g_io_add_watch_full(channel, G_PRIORITY_HIGH,
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
225 (G_IO_NVAL),
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
226 io_invoke_error, GINT_TO_POINTER(result), NULL);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
227
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
228 g_io_channel_unref(channel); /* Apparently this caused crashes for some people.
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
229 But irssi does this, so I am going to assume the
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
230 crashes were caused by some other stuff. */
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
231
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
232 g_printerr("gntmain: setting up IO\n");
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
233 }
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
234
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
235 static gboolean
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
236 refresh_screen()
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
237 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
238 gnt_bindable_perform_action_named(GNT_BINDABLE(wm), "refresh-screen", NULL);
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
239 return FALSE;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
242 /* Xerox */
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
243 static void
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
244 clean_pid(void)
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
245 {
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
246 int status;
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
247 pid_t pid;
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
248
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
249 do {
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
250 pid = waitpid(-1, &status, WNOHANG);
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
251 } while (pid != 0 && pid != (pid_t)-1);
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
252
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
253 if ((pid == (pid_t) - 1) && (errno != ECHILD)) {
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
254 char errmsg[BUFSIZ];
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
255 g_snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid);
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
256 perror(errmsg);
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
257 }
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
258 }
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
259
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
260 static void
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
261 sighandler(int sig)
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
262 {
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
263 switch (sig) {
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
264 #ifdef SIGWINCH
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
265 case SIGWINCH:
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
266 werase(stdscr);
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
267 wrefresh(stdscr);
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
268 g_idle_add(refresh_screen, NULL);
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
269 signal(SIGWINCH, sighandler);
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
270 break;
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
271 #endif
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
272 case SIGCHLD:
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
273 clean_pid();
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
274 signal(SIGCHLD, sighandler);
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
275 break;
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
276 }
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
277 }
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
278
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
279 static void
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
280 init_wm()
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
281 {
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
282 const char *name = gnt_style_get(GNT_STYLE_WM);
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
283 gpointer handle;
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
284
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
285 if (name && *name) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
286 handle = g_module_open(name, G_MODULE_BIND_LAZY);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
287 if (handle) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
288 gboolean (*init)(GntWM **);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
289 if (g_module_symbol(handle, "gntwm_init", (gpointer)&init)) {
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
290 init(&wm);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
291 }
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
292 }
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
293 }
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
294 if (wm == NULL)
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
295 wm = g_object_new(GNT_TYPE_WM, NULL);
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
296 }
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
297
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
298 void gnt_init()
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299 {
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
300 char *filename;
14202
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
301 const char *locale;
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
302
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
303 if (channel)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
304 return;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
305
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
306 setup_io();
14202
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
307
14881
5228f8cf2a6a [gaim-migrate @ 17650]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14876
diff changeset
308 locale = setlocale(LC_ALL, "");
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
309
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
310 if (locale && (strstr(locale, "UTF") || strstr(locale, "utf")))
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
311 ascii_only = FALSE;
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
312 else
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
313 ascii_only = TRUE;
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
314
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315 initscr();
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
316 typeahead(-1);
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
317 noecho();
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
318 curs_set(0);
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
319
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14004
diff changeset
320 gnt_init_styles();
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
321
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
322 filename = g_build_filename(g_get_home_dir(), ".gntrc", NULL);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
323 gnt_style_read_configure_file(filename);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
324 g_free(filename);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
325
14299
ea5193c23171 [gaim-migrate @ 16989]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14292
diff changeset
326 gnt_init_colors();
14976
1c0772f7260b [gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14906
diff changeset
327 gnt_init_keys();
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
328
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
329 wbkgdset(stdscr, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL));
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
330 refresh();
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
331
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
332 #ifdef ALL_MOUSE_EVENTS
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
333 if ((mouse_enabled = gnt_style_get_bool(GNT_STYLE_MOUSE, FALSE)))
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
334 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
14314
8b8188fa98f4 [gaim-migrate @ 17007]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14310
diff changeset
335 #endif
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
336
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
337 wbkgdset(stdscr, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL));
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
338 werase(stdscr);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
339 wrefresh(stdscr);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
340
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
341 #ifdef SIGWINCH
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
342 signal(SIGWINCH, sighandler);
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
343 #endif
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
344 signal(SIGCHLD, sighandler);
14737
87fe294744aa [gaim-migrate @ 17493]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14680
diff changeset
345 signal(SIGPIPE, SIG_IGN);
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
346
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
347 g_type_init();
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
348
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
349 init_wm();
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
350 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
351
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
352 void gnt_main()
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
353 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
354 wm->loop = g_main_loop_new(NULL, FALSE);
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
355 g_main_loop_run(wm->loop);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
356 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
357
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
358 /*********************************
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
359 * Stuff for 'window management' *
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
360 *********************************/
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
361
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
362 void gnt_screen_occupy(GntWidget *widget)
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
363 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
364 gnt_wm_new_window(wm, widget);
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
365 }
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
366
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
367 void gnt_screen_release(GntWidget *widget)
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
368 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
369 gnt_wm_window_close(wm, widget);
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
370 }
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
371
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
372 void gnt_screen_update(GntWidget *widget)
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
373 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
374 gnt_wm_update_window(wm, widget);
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
375 }
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
376
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
377 gboolean gnt_widget_has_focus(GntWidget *widget)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
378 {
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
379 GntWidget *w;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
380 if (!widget)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
381 return FALSE;
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
382
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
383 if (GNT_IS_MENU(widget))
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
384 return TRUE;
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
385
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
386 w = widget;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
387
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
388 while (widget->parent)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
389 widget = widget->parent;
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
390
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
391 if (widget == wm->_list.window)
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
392 return TRUE;
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
393 if (wm->ordered && wm->ordered->data == widget) {
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
394 if (GNT_IS_BOX(widget) &&
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
395 (GNT_BOX(widget)->active == w || widget == w))
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
396 return TRUE;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
397 }
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
398 return FALSE;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
399 }
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
400
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
401 void gnt_widget_set_urgent(GntWidget *widget)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
402 {
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
403 while (widget->parent)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
404 widget = widget->parent;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
405
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
406 if (wm->ordered && wm->ordered->data == widget)
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
407 return;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
408
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
409 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_URGENT);
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
410
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
411 gnt_wm_update_window(wm, widget);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
412 }
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
413
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
414 void gnt_quit()
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
415 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
416 g_hash_table_destroy(wm->nodes); /* XXX: */
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
417 update_panels();
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
418 doupdate();
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13957
diff changeset
419 gnt_uninit_colors();
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14004
diff changeset
420 gnt_uninit_styles();
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
421 endwin();
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
422 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
423
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
424 gboolean gnt_ascii_only()
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
425 {
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
426 return ascii_only;
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
427 }
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
428
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
429 void gnt_screen_resize_widget(GntWidget *widget, int width, int height)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
430 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
431 gnt_wm_resize_window(wm, widget, width, height);
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
432 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
433
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
434 void gnt_screen_move_widget(GntWidget *widget, int x, int y)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
435 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
436 gnt_wm_move_window(wm, widget, x, y);
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
437 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
438
14388
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
439 void gnt_screen_rename_widget(GntWidget *widget, const char *text)
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
440 {
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
441 gnt_box_set_title(GNT_BOX(widget), text);
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
442 gnt_widget_draw(widget);
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
443 gnt_wm_update_window(wm, widget);
14388
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
444 }
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
445
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
446 void gnt_register_action(const char *label, void (*callback)())
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
447 {
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
448 GntAction *action = g_new0(GntAction, 1);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
449 action->label = g_strdup(label);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
450 action->callback = callback;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
451
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
452 wm->acts = g_list_append(wm->acts, action);
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
453 }
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
454
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
455 static void
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
456 reset_menu(GntWidget *widget, gpointer null)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
457 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
458 wm->menu = NULL;
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
459 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
460
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
461 gboolean gnt_screen_menu_show(gpointer newmenu)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
462 {
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
463 if (wm->menu) {
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
464 /* For now, if a menu is being displayed, then another menu
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
465 * can NOT take over. */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
466 return FALSE;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
467 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
468
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
469 wm->menu = newmenu;
14906
1bd0456fe1c3 [gaim-migrate @ 17678]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14900
diff changeset
470 GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(wm->menu), GNT_WIDGET_INVISIBLE);
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
471 gnt_widget_draw(GNT_WIDGET(wm->menu));
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
472
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14881
diff changeset
473 g_signal_connect(G_OBJECT(wm->menu), "hide", G_CALLBACK(reset_menu), NULL);
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
474
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
475 return TRUE;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
476 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14544
diff changeset
477