annotate console/libgnt/gntmain.c @ 14477:ca36763497d9

[gaim-migrate @ 17195] Build libgnt with ncurses if ncursesw is not found. I uninstalled ncursesw and it's still working for me .. of course, with no wide-character support. Improve the mouse support a bit. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 09 Sep 2006 02:19:16 +0000
parents 0ed8b285a44b
children 5ac8f22e7b08
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
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
2
14421
553bbd68387e [gaim-migrate @ 17129]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14415
diff changeset
3 #include "config.h"
553bbd68387e [gaim-migrate @ 17129]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14415
diff changeset
4
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
5 #include <gmodule.h>
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
6
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 #include "gnt.h"
13888
9d66969a2e32 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
8 #include "gntbox.h"
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
9 #include "gntcolors.h"
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 #include "gntkeys.h"
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
11 #include "gntstyle.h"
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
12 #include "gnttree.h"
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
13 #include "gntutils.h"
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
14 #include "gntwm.h"
13888
9d66969a2e32 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
15
14431
0ed8b285a44b [gaim-migrate @ 17145]
Mark Doliner <mark@kingant.net>
parents: 14428
diff changeset
16 #include <panel.h>
0ed8b285a44b [gaim-migrate @ 17145]
Mark Doliner <mark@kingant.net>
parents: 14428
diff changeset
17
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 #include <stdio.h>
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 #include <stdlib.h>
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 #include <locale.h>
13888
9d66969a2e32 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
21 #include <unistd.h>
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
22 #include <signal.h>
13888
9d66969a2e32 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
23 #include <string.h>
14220
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
24 #include <ctype.h>
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
25 #include <errno.h>
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
26
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
27 #include <sys/types.h>
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
28 #include <sys/wait.h>
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
30 /**
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
31 * Notes: Interesting functions to look at:
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
32 * scr_dump, scr_init, scr_restore: for workspaces
14131
db2311999862 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14125
diff changeset
33 *
db2311999862 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14125
diff changeset
34 * Need to wattrset for colors to use with PDCurses.
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
35 */
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
36
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
37 static int lock_focus_list;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 static GList *focus_list;
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
39 static GList *ordered;
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
40
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
41 static int X_MIN;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
42 static int X_MAX;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
43 static int Y_MIN;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
44 static int Y_MAX;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
45
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
46 static gboolean ascii_only;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
47 static gboolean mouse_enabled;
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
48
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
49 static GMainLoop *loop;
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
50
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
51 static struct
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
52 {
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
53 GntWidget *window;
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
54 GntWidget *tree;
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
55 } _list, *window_list, *action_list;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
57 typedef struct
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
58 {
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
59 GntWidget *me;
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
60
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
61 PANEL *panel;
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
62 } GntNode;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
63
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
64 typedef enum
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
65 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
66 GNT_KP_MODE_NORMAL,
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
67 GNT_KP_MODE_RESIZE,
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
68 GNT_KP_MODE_MOVE,
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
69 GNT_KP_MODE_MENU,
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
70 GNT_KP_MODE_WINDOW_LIST
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
71 } GntKeyPressMode;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
72
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
73 static GHashTable *nodes;
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
74
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
75 static void free_node(gpointer data);
14245
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
76 static void draw_taskbar(gboolean reposition);
13919
0febf380b473 [gaim-migrate @ 16430]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13917
diff changeset
77 static void bring_on_top(GntWidget *widget);
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
78
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
79 static gboolean refresh_screen();
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
80 static const GList *list_all_windows();
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
81
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
82 static void show_actions_list();
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
83
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
84 static GntWM wm =
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
85 {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
86 NULL, /* new_window */
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
87 NULL, /* close_window */
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
88 NULL, /* window_resize_confirm */
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
89 NULL, /* window_resized */
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
90 NULL, /* window_move_confirm */
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
91 NULL, /* window_moved */
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
92 NULL, /* window_update */
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
93 NULL, /* key_pressed */
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
94 NULL, /* mouse clicked */
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
95 bring_on_top, /* give_focus */
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
96 NULL, /* uninit */
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
97 list_all_windows, /* window_list */
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
98 };
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
99
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
100 static const GList *list_all_windows()
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
101 {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
102 return focus_list;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
103 }
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
104
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
105 static GList *
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
106 g_list_bring_to_front(GList *list, gpointer data)
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
107 {
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
108 list = g_list_remove(list, data);
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
109 list = g_list_prepend(list, data);
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
110 return list;
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
111 }
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
112
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
113 static gboolean
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
114 update_screen(gpointer null)
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
115 {
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
116 update_panels();
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
117 doupdate();
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
118 return TRUE;
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
119 }
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
120
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 void gnt_screen_take_focus(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122 {
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
123 GntWidget *w = NULL;
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
124
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
125 if (lock_focus_list)
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
126 return;
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
127 if (g_list_find(focus_list, widget))
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
128 return;
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
129
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
130 if (ordered)
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
131 w = ordered->data;
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
132
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
133 focus_list = g_list_append(focus_list, widget);
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
134
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
135 ordered = g_list_append(ordered, widget);
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
136
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
137 gnt_widget_set_focus(widget, TRUE);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
138 if (w)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
139 gnt_widget_set_focus(w, FALSE);
14245
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
140 draw_taskbar(FALSE);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
141 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143 void gnt_screen_remove_widget(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 {
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
145 int pos = g_list_index(focus_list, widget);
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
146
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
147 if (lock_focus_list)
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
148 return;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
149
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
150 if (pos == -1)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
151 return;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
152
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 focus_list = g_list_remove(focus_list, widget);
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
154 ordered = g_list_remove(ordered, widget);
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
155
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
156 if (ordered)
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
157 {
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
158 wm.give_focus(ordered->data);
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
159 }
14245
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
160 draw_taskbar(FALSE);
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
161 }
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
162
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
163 static void
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
164 bring_on_top(GntWidget *widget)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
165 {
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
166 GntNode *node = g_hash_table_lookup(nodes, widget);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
167
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
168 if (!node)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
169 return;
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
170
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
171 if (ordered->data != widget) {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
172 GntWidget *w = ordered->data;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
173 ordered = g_list_bring_to_front(ordered, widget);
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
174 gnt_widget_set_focus(w, FALSE);
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
175 }
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
176
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
177 gnt_widget_set_focus(widget, TRUE);
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
178 gnt_widget_draw(widget);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
179 top_panel(node->panel);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
180
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
181 if (_list.window)
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
182 {
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
183 GntNode *nd = g_hash_table_lookup(nodes, _list.window);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
184 top_panel(nd->panel);
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
185 }
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
186 update_screen(NULL);
14245
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
187 draw_taskbar(FALSE);
13934
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
188 }
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
189
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
190 static void
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
191 update_window_in_list(GntWidget *wid)
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
192 {
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
193 GntTextFormatFlags flag = 0;
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
194
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
195 if (window_list == NULL)
13934
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
196 return;
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
197
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
198 if (wid == ordered->data)
13934
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
199 flag |= GNT_TEXT_FLAG_DIM;
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
200 else if (GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_URGENT))
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
201 flag |= GNT_TEXT_FLAG_BOLD;
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
202
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
203 gnt_tree_set_row_flags(GNT_TREE(window_list->tree), wid, flag);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
206 static void
14245
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
207 draw_taskbar(gboolean reposition)
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
208 {
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
209 static WINDOW *taskbar = NULL;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
210 GList *iter;
13919
0febf380b473 [gaim-migrate @ 16430]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13917
diff changeset
211 int n, width = 0;
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
212 int i;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
213
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
214 if (taskbar == NULL)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
215 {
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
216 taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0);
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
217 }
14245
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
218 else if (reposition)
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
219 {
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
220 mvwin(taskbar, Y_MAX, 0);
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
221 }
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
222
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
223 wbkgdset(taskbar, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL));
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
224 werase(taskbar);
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
225
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
226 n = g_list_length(focus_list);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
227 if (n)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
228 width = getmaxx(stdscr) / n;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
229
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
230 for (i = 0, iter = focus_list; iter; iter = iter->next, i++)
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
231 {
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
232 GntWidget *w = iter->data;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
233 int color;
14131
db2311999862 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14125
diff changeset
234 const char *title;
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
235
14387
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14381
diff changeset
236 if (w == ordered->data) {
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
237 /* This is the current window in focus */
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
238 color = GNT_COLOR_TITLE;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
239 GNT_WIDGET_UNSET_FLAGS(w, GNT_WIDGET_URGENT);
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
240 if (wm.window_update) {
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
241 GntNode *node = g_hash_table_lookup(nodes, w);
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
242 wm.window_update(node->panel, w);
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
243 }
14387
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14381
diff changeset
244 } else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_URGENT)) {
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
245 /* This is a window with the URGENT hint set */
14387
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14381
diff changeset
246 color = GNT_COLOR_URGENT;
39b0124a455d [gaim-migrate @ 17093]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14381
diff changeset
247 } else {
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
248 color = GNT_COLOR_NORMAL;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
249 }
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
250 wbkgdset(taskbar, '\0' | COLOR_PAIR(color));
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
251 mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), width);
14131
db2311999862 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14125
diff changeset
252 title = GNT_BOX(w)->title;
db2311999862 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14125
diff changeset
253 mvwprintw(taskbar, 0, width * i, "%s", title ? title : "<gnt>");
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
254 if (i)
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
255 mvwaddch(taskbar, 0, width *i - 1, ACS_VLINE | A_STANDOUT | COLOR_PAIR(GNT_COLOR_NORMAL));
13934
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
256
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
257 update_window_in_list(w);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
258 }
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
259
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
260 wrefresh(taskbar);
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
261 }
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
262
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
263 static void
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
264 switch_window(int direction)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
265 {
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
266 GntWidget *w = NULL, *wid = NULL;
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
267 int pos;
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
268
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
269 if (!ordered || !ordered->next)
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
270 return;
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
271
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
272 w = ordered->data;
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
273 pos = g_list_index(focus_list, w);
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
274 pos += direction;
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
275
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
276 if (pos < 0)
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
277 wid = g_list_last(focus_list)->data;
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
278 else if (pos >= g_list_length(focus_list))
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
279 wid = focus_list->data;
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
280 else if (pos >= 0)
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
281 wid = g_list_nth_data(focus_list, pos);
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
282
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
283 ordered = g_list_bring_to_front(ordered, wid);
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
284
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
285 wm.give_focus(ordered->data);
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
286
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
287 if (w != wid)
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
288 {
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
289 gnt_widget_set_focus(w, FALSE);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
290 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
291 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
292
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
293 static void
14220
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
294 switch_window_n(int n)
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
295 {
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
296 GntWidget *w = NULL;
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
297 GList *l;
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
298
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
299 if (!ordered)
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
300 return;
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
301
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
302 w = ordered->data;
14220
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
303
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
304 if ((l = g_list_nth(focus_list, n)) != NULL)
14220
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
305 {
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
306 ordered = g_list_bring_to_front(ordered, l->data);
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
307 wm.give_focus(ordered->data);
14220
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
308 }
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
309
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
310 if (l && w != l->data)
14220
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
311 {
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
312 gnt_widget_set_focus(w, FALSE);
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
313 }
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
314 }
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
315
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
316 static void
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
317 window_list_activate(GntTree *tree, gpointer null)
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
318 {
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
319 GntWidget *widget = gnt_tree_get_selection_data(GNT_TREE(tree));
13919
0febf380b473 [gaim-migrate @ 16430]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13917
diff changeset
320 GntWidget *old = NULL;
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
321
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
322 if (!ordered || !widget)
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
323 return;
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
324
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
325 old = ordered->data;
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
326 ordered = g_list_bring_to_front(ordered, widget);
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
327 wm.give_focus(widget);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
328
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
329 if (old != widget)
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
330 {
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
331 gnt_widget_set_focus(old, FALSE);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
332 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
333 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
334
13919
0febf380b473 [gaim-migrate @ 16430]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13917
diff changeset
335 static void
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
336 setup__list()
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
337 {
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
338 GntWidget *tree, *win;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
339 win = _list.window = gnt_box_new(FALSE, FALSE);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
340 gnt_box_set_toplevel(GNT_BOX(win), TRUE);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
341 gnt_box_set_pad(GNT_BOX(win), 0);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
342
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
343 tree = _list.tree = gnt_tree_new();
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
344 gnt_box_add_widget(GNT_BOX(win), tree);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
345 }
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
346
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
347 static void
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
348 show_window_list()
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
349 {
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
350 GntWidget *tree, *win;
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
351 GList *iter;
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
352
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
353 if (window_list)
13919
0febf380b473 [gaim-migrate @ 16430]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13917
diff changeset
354 return;
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
355
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
356 setup__list();
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
357
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
358 window_list = &_list;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
359
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
360 win = window_list->window;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
361 tree = window_list->tree;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
362
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
363 gnt_box_set_title(GNT_BOX(win), "Window List");
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
364
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
365 for (iter = focus_list; iter; iter = iter->next)
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
366 {
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
367 GntBox *box = GNT_BOX(iter->data);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
368
14125
7dfa024c1a4a [gaim-migrate @ 16763]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14123
diff changeset
369 gnt_tree_add_row_last(GNT_TREE(tree), box,
7dfa024c1a4a [gaim-migrate @ 16763]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14123
diff changeset
370 gnt_tree_create_row(GNT_TREE(tree), box->title), NULL);
13934
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
371 update_window_in_list(GNT_WIDGET(box));
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
372 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
373
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
374 gnt_tree_set_selected(GNT_TREE(tree), ordered->data);
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
375 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), NULL);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
376
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13957
diff changeset
377 gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13957
diff changeset
378 gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
379 gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
380
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
381 lock_focus_list = 1;
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
382 gnt_widget_show(win);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
383 lock_focus_list = 0;
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
384 }
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
385
13957
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
386 static void
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
387 shift_window(GntWidget *widget, int dir)
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
388 {
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
389 GList *all = focus_list;
13957
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
390 GList *list = g_list_find(all, widget);
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
391 int length, pos;
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
392 if (!list)
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
393 return;
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
394
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
395 length = g_list_length(all);
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
396 pos = g_list_position(all, list);
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
397
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
398 pos += dir;
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
399 if (dir > 0)
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
400 pos++;
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
401
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
402 if (pos < 0)
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
403 pos = length;
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
404 else if (pos > length)
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
405 pos = 0;
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
406
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
407 all = g_list_insert(all, widget, pos);
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
408 all = g_list_delete_link(all, list);
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
409 focus_list = all;
14245
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
410 draw_taskbar(FALSE);
13957
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
411 }
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
412
14029
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
413 static void
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
414 dump_screen()
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
415 {
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
416 int x, y;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
417 chtype old = 0, now = 0;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
418 FILE *file = fopen("dump.html", "w");
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
419
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
420 fprintf(file, "<pre>");
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
421 for (y = 0; y < getmaxy(stdscr); y++)
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
422 {
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
423 for (x = 0; x < getmaxx(stdscr); x++)
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
424 {
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
425 char ch;
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
426 now = mvwinch(curscr, y, x);
14029
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
427 ch = now & A_CHARTEXT;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
428 now ^= ch;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
429
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
430 #define CHECK(attr, start, end) \
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
431 do \
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
432 { \
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
433 if (now & attr) \
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
434 { \
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
435 if (!(old & attr)) \
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
436 fprintf(file, start); \
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
437 } \
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
438 else if (old & attr) \
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
439 { \
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
440 fprintf(file, end); \
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
441 } \
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
442 } while (0)
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
443
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
444 CHECK(A_BOLD, "<b>", "</b>");
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
445 CHECK(A_UNDERLINE, "<u>", "</u>");
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
446 CHECK(A_BLINK, "<blink>", "</blink>");
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
447
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
448 if ((now & A_COLOR) != (old & A_COLOR))
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
449 {
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
450 int ret;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
451 short fgp, bgp, r, g, b;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
452 struct
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
453 {
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
454 int r, g, b;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
455 } fg, bg;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
456
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
457 ret = pair_content(PAIR_NUMBER(now & A_COLOR), &fgp, &bgp);
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
458 ret = color_content(fgp, &r, &g, &b);
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
459 fg.r = r; fg.b = b; fg.g = g;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
460 ret = color_content(bgp, &r, &g, &b);
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
461 bg.r = r; bg.b = b; bg.g = g;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
462 #define ADJUST(x) (x = x * 255 / 1000)
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
463 ADJUST(fg.r);
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
464 ADJUST(fg.g);
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
465 ADJUST(fg.b);
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
466 ADJUST(bg.r);
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
467 ADJUST(bg.b);
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
468 ADJUST(bg.g);
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
469
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
470 if (x) fprintf(file, "</span>");
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
471 fprintf(file, "<span style=\"background:#%02x%02x%02x;color:#%02x%02x%02x\">",
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
472 bg.r, bg.g, bg.b, fg.r, fg.g, fg.b);
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
473 }
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
474 if (now & A_ALTCHARSET)
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
475 {
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
476 switch (ch)
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
477 {
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
478 case 'q':
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
479 ch = '-'; break;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
480 case 't':
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
481 case 'u':
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
482 case 'x':
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
483 ch = '|'; break;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
484 case 'v':
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
485 case 'w':
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
486 case 'l':
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
487 case 'm':
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
488 case 'k':
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
489 case 'j':
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
490 case 'n':
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
491 ch = '+'; break;
14107
c0ee28af3ca2 [gaim-migrate @ 16741]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
492 case '-':
c0ee28af3ca2 [gaim-migrate @ 16741]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
493 ch = '^'; break;
c0ee28af3ca2 [gaim-migrate @ 16741]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
494 case '.':
c0ee28af3ca2 [gaim-migrate @ 16741]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14091
diff changeset
495 ch = 'v'; break;
14123
f8ab496671fa [gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14107
diff changeset
496 case 'a':
f8ab496671fa [gaim-migrate @ 16761]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14107
diff changeset
497 ch = '#'; break;
14029
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
498 default:
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
499 ch = ' '; break;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
500 }
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
501 }
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
502 if (ch == '&')
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
503 fprintf(file, "&amp;");
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
504 else if (ch == '<')
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
505 fprintf(file, "&lt;");
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
506 else if (ch == '>')
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
507 fprintf(file, "&gt;");
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
508 else
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
509 fprintf(file, "%c", ch);
14029
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
510 old = now;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
511 }
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
512 fprintf(file, "</span>\n");
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
513 old = 0;
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
514 }
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
515 fprintf(file, "</pre>");
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
516 fclose(file);
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
517 }
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
518
14245
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
519 static void
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
520 refresh_node(GntWidget *widget, GntNode *node, gpointer null)
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
521 {
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
522 int x, y, w, h;
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
523 int nw, nh;
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
524
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
525 gnt_widget_get_position(widget, &x, &y);
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
526 gnt_widget_get_size(widget, &w, &h);
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
527
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
528 if (x + w >= X_MAX)
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
529 x = MAX(0, X_MAX - w);
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
530 if (y + h >= Y_MAX)
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
531 y = MAX(0, Y_MAX - h);
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
532 gnt_screen_move_widget(widget, x, y);
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
533
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
534 nw = MIN(w, X_MAX);
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
535 nh = MIN(h, Y_MAX);
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
536 if (nw != w || nh != h)
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
537 gnt_screen_resize_widget(widget, nw, nh);
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
538 }
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
539
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
540 /**
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
541 * Mouse support:
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
542 * - 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
543 * - 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
544 * - click on a window to bring it to focus
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
545 * - allow scrolling in tree/textview on wheel-scroll event
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
546 * - 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
547 * wishlist:
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
548 * - 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
549 */
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
550 static gboolean
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
551 detect_mouse_action(const char *buffer)
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
552 {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
553 int x, y;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
554 static enum {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
555 MOUSE_NONE,
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
556 MOUSE_LEFT,
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
557 MOUSE_RIGHT,
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
558 MOUSE_MIDDLE
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
559 } button = MOUSE_NONE;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
560 static GntWidget *remember = NULL;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
561 static int offset = 0;
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
562 GntMouseEvent event;
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
563 GntWidget *widget = NULL;
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
564 PANEL *p = NULL;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
565
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
566 if (!ordered || buffer[0] != 27)
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
567 return FALSE;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
568
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
569 buffer++;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
570 if (strlen(buffer) < 5)
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
571 return FALSE;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
572
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
573 x = buffer[3];
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
574 y = buffer[4];
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
575 if (x < 0) x += 256;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
576 if (y < 0) y += 256;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
577 x -= 33;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
578 y -= 33;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
579
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
580 /* It might be a better idea to use panel_below. That would allow mouse-clicks
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
581 * to be operated on transient windows, which would be cool.*/
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
582 while ((p = panel_below(p)) != NULL) {
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
583 const GntNode *node = panel_userptr(p);
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
584 GntWidget *wid;
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
585 if (!node)
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
586 continue;
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
587 wid = node->me;
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
588 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
589 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
590 widget = wid;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
591 break;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
592 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
593 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
594 }
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
595
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
596 if (strncmp(buffer, "[M ", 3) == 0) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
597 /* left button down */
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
598 /* Bring the window you clicked on to front */
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
599 /* 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
600 event = GNT_LEFT_MOUSE_DOWN;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
601 } else if (strncmp(buffer, "[M\"", 3) == 0) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
602 /* right button down */
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
603 event = GNT_RIGHT_MOUSE_DOWN;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
604 } else if (strncmp(buffer, "[M!", 3) == 0) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
605 /* middle button down */
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
606 event = GNT_MIDDLE_MOUSE_DOWN;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
607 } else if (strncmp(buffer, "[M`", 3) == 0) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
608 /* wheel up*/
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
609 event = GNT_MOUSE_SCROLL_UP;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
610 } else if (strncmp(buffer, "[Ma", 3) == 0) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
611 /* wheel down */
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
612 event = GNT_MOUSE_SCROLL_DOWN;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
613 } else if (strncmp(buffer, "[M#", 3) == 0) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
614 /* button up */
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
615 event = GNT_MOUSE_UP;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
616 } else
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
617 return FALSE;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
618
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
619 if (wm.mouse_clicked && wm.mouse_clicked(event, x, y, widget))
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
620 return TRUE;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
621
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
622 if (event == GNT_LEFT_MOUSE_DOWN && widget && widget != _list.window &&
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
623 !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) {
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
624 if (widget != ordered->data) {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
625 GntWidget *w = ordered->data;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
626 ordered = g_list_bring_to_front(ordered, widget);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
627 wm.give_focus(ordered->data);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
628 gnt_widget_set_focus(w, FALSE);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
629 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
630 if (y == widget->priv.y) {
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
631 offset = x - widget->priv.x;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
632 remember = widget;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
633 button = MOUSE_LEFT;
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
634 }
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
635 } else if (event == GNT_MOUSE_UP) {
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
636 if (button == MOUSE_NONE && y == getmaxy(stdscr) - 1) {
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
637 /* Clicked on the taskbar */
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
638 int n = g_list_length(focus_list);
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
639 if (n) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
640 int width = getmaxx(stdscr) / n;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
641 switch_window_n(x / width);
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
642 }
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
643 } else if (button == MOUSE_LEFT && remember) {
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
644 x -= offset;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
645 if (x < 0) x = 0;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
646 if (y < 0) y = 0;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
647 gnt_screen_move_widget(remember, x, y);
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
648 refresh_node(remember, NULL, NULL);
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
649 }
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
650 button = MOUSE_NONE;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
651 remember = NULL;
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
652 offset = 0;
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
653 }
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
654
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
655 gnt_widget_clicked(widget, event, x, y);
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
656 return TRUE; /* XXX: this should be TRUE */
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
657 }
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
658
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
659 #ifndef NO_WIDECHAR
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
660 static int
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
661 widestringwidth(wchar_t *wide)
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
662 {
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
663 int len, ret;
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
664 char *string;
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
665
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
666 len = wcstombs(NULL, wide, 0) + 1;
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
667 string = g_new0(char, len);
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
668 wcstombs(string, wide, len);
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
669 ret = gnt_util_onscreen_width(string, NULL);
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
670 g_free(string);
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
671 return ret;
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
672 }
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
673 #endif
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
674
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
675 /* Returns the onscreen width of the character at the position */
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
676 static int
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
677 reverse_char(WINDOW *d, int y, int x, gboolean set)
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
678 {
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
679 #define DECIDE(ch) (set ? ((ch) | WA_REVERSE) : ((ch) & ~WA_REVERSE))
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
680
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
681 #ifdef NO_WIDECHAR
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
682 chtype ch;
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
683 ch = mvwinch(d, y, x);
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
684 mvwaddch(d, y, x, DECIDE(ch));
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
685 return 1;
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
686 #else
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
687 cchar_t ch;
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
688 int wc = 1;
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
689 if (mvwin_wch(d, y, x, &ch) == OK) {
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
690 wc = widestringwidth(ch.chars);
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
691 ch.attr = DECIDE(ch.attr);
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
692 ch.attr &= WA_ATTRIBUTES; /* XXX: This is a workaround for a bug */
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
693 mvwadd_wch(d, y, x, &ch);
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
694 }
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
695
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
696 return wc;
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
697 #endif
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
698 }
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
699
14415
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
700 static void
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
701 window_reverse(GntWidget *win, gboolean set)
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
702 {
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
703 int i;
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
704 int w, h;
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
705 WINDOW *d;
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
706
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
707 if (GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_NO_BORDER))
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
708 return;
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
709
14421
553bbd68387e [gaim-migrate @ 17129]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14415
diff changeset
710 d = win->window;
14415
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
711 gnt_widget_get_size(win, &w, &h);
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
712
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
713 /* the top and bottom */
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
714 for (i = 0; i < w; i += reverse_char(d, 0, i, set));
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
715 for (i = 0; i < w; i += reverse_char(d, h-1, i, set));
14415
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
716
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
717 /* the left and right */
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
718 for (i = 0; i < h; i += reverse_char(d, i, 0, set));
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
719 for (i = 0; i < h; i += reverse_char(d, i, w-1, set));
14415
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
720
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
721 wrefresh(win->window);
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
722 }
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
723
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
724 static gboolean
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
725 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
726 {
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
727 char keys[256];
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
728 gboolean ret = FALSE;
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
729 static GntKeyPressMode mode = GNT_KP_MODE_NORMAL;
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
730 const char *buffer;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
731
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
732 int rd = read(STDIN_FILENO, keys, sizeof(keys) - 1);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
733 if (rd < 0)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
734 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
735 endwin();
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
736 printf("ERROR!\n");
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
737 exit(1);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
738 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
739 else if (rd == 0)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
740 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
741 endwin();
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
742 printf("EOF\n");
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
743 exit(1);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
744 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
745
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
746 keys[rd] = 0;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
747
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
748 if (keys[0] == 27 && keys[1] == 'd' && keys[2] == 0)
14029
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
749 {
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
750 /* This dumps the screen contents in an html file */
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
751 dump_screen();
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
752 }
d63f59ee6c98 [gaim-migrate @ 16631]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
753
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
754 gnt_keys_refine(keys);
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
755
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
756 if (mouse_enabled && detect_mouse_action(keys))
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
757 return TRUE;
14343
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
758
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
759 if (wm.key_pressed) {
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
760 buffer = wm.key_pressed(keys);
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
761 if (buffer == NULL)
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
762 return TRUE;
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
763 } else
0387a167f342 [gaim-migrate @ 17044]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14335
diff changeset
764 buffer = keys;
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
765
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
766 if (mode == GNT_KP_MODE_NORMAL)
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
767 {
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
768 if (ordered)
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
769 {
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
770 ret = gnt_widget_key_pressed(ordered->data, buffer);
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
771 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
772
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
773 if (!ret)
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
774 {
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
775 if (buffer[0] == 27)
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13878
diff changeset
776 {
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
777 /* Some special key has been pressed */
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
778 if (strcmp(buffer+1, GNT_KEY_POPUP) == 0)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
779 {}
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
780 else if (strcmp(buffer + 1, "c") == 0)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
781 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
782 /* Alt + c was pressed. I am going to use it to close a window. */
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
783 if (ordered)
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
784 {
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
785 gnt_widget_destroy(ordered->data);
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
786 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
787 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
788 else if (strcmp(buffer + 1, "q") == 0)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
789 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
790 /* I am going to use Alt + q to quit. */
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
791 g_main_loop_quit(loop);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
792 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
793 else if (strcmp(buffer + 1, "n") == 0)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
794 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
795 /* Alt + n to go to the next window */
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
796 switch_window(1);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
797 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
798 else if (strcmp(buffer + 1, "p") == 0)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
799 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
800 /* Alt + p to go to the previous window */
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
801 switch_window(-1);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
802 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
803 else if (strcmp(buffer + 1, "m") == 0 && focus_list)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
804 {
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
805 /* Move a window */
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
806 mode = GNT_KP_MODE_MOVE;
14415
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
807 window_reverse(ordered->data, TRUE);
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
808 }
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
809 else if (strcmp(buffer + 1, "w") == 0 && focus_list)
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
810 {
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
811 /* Window list */
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
812 mode = GNT_KP_MODE_WINDOW_LIST;
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
813 show_window_list();
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
814 }
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
815 else if (strcmp(buffer + 1, "a") == 0)
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
816 {
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
817 mode = GNT_KP_MODE_WINDOW_LIST;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
818 show_actions_list();
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
819 }
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
820 else if (strcmp(buffer + 1, "r") == 0 && focus_list)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
821 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
822 /* Resize window */
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
823 mode = GNT_KP_MODE_RESIZE;
14415
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
824 window_reverse(ordered->data, TRUE);
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
825 }
13957
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
826 else if (strcmp(buffer + 1, ",") == 0 && focus_list)
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
827 {
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
828 /* Re-order the list of windows */
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
829 shift_window(ordered->data, -1);
13957
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
830 }
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
831 else if (strcmp(buffer + 1, ".") == 0 && focus_list)
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
832 {
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
833 shift_window(ordered->data, 1);
13957
421259b9e06d [gaim-migrate @ 16508]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
834 }
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
835 else if (strcmp(buffer + 1, "l") == 0)
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
836 {
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
837 refresh_screen();
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
838 }
14220
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
839 else if (strlen(buffer) == 2 && isdigit(*(buffer + 1)))
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
840 {
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
841 int n = *(buffer + 1) - '0';
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
842
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
843 if (n == 0)
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
844 n = 10;
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
845
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
846 switch_window_n(n - 1);
1d793e808e5b [gaim-migrate @ 16901]
Ethan Blanton <elb@pidgin.im>
parents: 14216
diff changeset
847 }
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13878
diff changeset
848 }
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
849 }
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
850 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
851 else if (mode == GNT_KP_MODE_MOVE && focus_list)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
852 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
853 if (buffer[0] == 27)
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13878
diff changeset
854 {
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
855 gboolean changed = FALSE;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
856 int x, y, w, h;
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
857 GntWidget *widget = GNT_WIDGET(ordered->data);
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
858
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
859 gnt_widget_get_position(widget, &x, &y);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
860 gnt_widget_get_size(widget, &w, &h);
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
861
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
862 if (strcmp(buffer + 1, GNT_KEY_LEFT) == 0)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
863 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
864 if (x > X_MIN)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
865 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
866 x--;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
867 changed = TRUE;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
868 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
869 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
870 else if (strcmp(buffer + 1, GNT_KEY_RIGHT) == 0)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
871 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
872 if (x + w < X_MAX)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
873 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
874 x++;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
875 changed = TRUE;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
876 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
877 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
878 else if (strcmp(buffer + 1, GNT_KEY_UP) == 0)
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13878
diff changeset
879 {
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
880 if (y > Y_MIN)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
881 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
882 y--;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
883 changed = TRUE;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
884 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
885 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
886 else if (strcmp(buffer + 1, GNT_KEY_DOWN) == 0)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
887 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
888 if (y + h < Y_MAX)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
889 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
890 y++;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
891 changed = TRUE;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
892 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
893 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
894 else if (buffer[1] == 0)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
895 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
896 mode = GNT_KP_MODE_NORMAL;
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
897 window_reverse(widget, FALSE);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13878
diff changeset
898 }
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
899
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
900 if (changed)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
901 {
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
902 gnt_screen_move_widget(widget, x, y);
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
903 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
904 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
905 else if (*buffer == '\r')
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
906 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
907 mode = GNT_KP_MODE_NORMAL;
14415
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
908 window_reverse(ordered->data, FALSE);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13878
diff changeset
909 }
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
910 }
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
911 else if (mode == GNT_KP_MODE_WINDOW_LIST && _list.window)
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
912 {
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
913 gnt_widget_key_pressed(_list.window, buffer);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
914
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
915 if (buffer[0] == '\r' || (buffer[0] == 27 && buffer[1] == 0))
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
916 {
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
917 mode = GNT_KP_MODE_NORMAL;
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
918 lock_focus_list = 1;
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
919 gnt_widget_destroy(_list.window);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
920 _list.window = NULL;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
921 _list.tree = NULL;
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
922 lock_focus_list = 0;
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
923 window_list = NULL;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
924 action_list = NULL;
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
925 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
926 }
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
927 else if (mode == GNT_KP_MODE_RESIZE)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
928 {
14415
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
929 if (buffer[0] == '\r' || (buffer[0] == 27 && buffer[1] == 0)) {
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
930 mode = GNT_KP_MODE_NORMAL;
14415
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
931 window_reverse(ordered->data, FALSE);
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
932 } else if (buffer[0] == 27) {
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
933 GntWidget *widget = ordered->data;
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
934 gboolean changed = FALSE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
935 int width, height;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
936
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
937 gnt_widget_get_size(widget, &width, &height);
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
938
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
939 if (strcmp(buffer + 1, GNT_KEY_DOWN) == 0)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
940 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
941 if (widget->priv.y + height < Y_MAX)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
942 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
943 height++;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
944 changed = TRUE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
945 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
946 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
947 else if (strcmp(buffer + 1, GNT_KEY_UP) == 0)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
948 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
949 height--;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
950 changed = TRUE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
951 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
952 else if (strcmp(buffer + 1, GNT_KEY_LEFT) == 0)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
953 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
954 width--;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
955 changed = TRUE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
956 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
957 else if (strcmp(buffer + 1, GNT_KEY_RIGHT) == 0)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
958 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
959 if (widget->priv.x + width < X_MAX)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
960 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
961 width++;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
962 changed = TRUE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
963 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
964 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
965
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
966 if (changed)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
967 {
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
968 gnt_screen_resize_widget(widget, width, height);
14415
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
969 window_reverse(widget, TRUE);
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
970 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
971 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
972 }
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
973
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
974 return TRUE;
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
975 }
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
976
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
977 static gboolean
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
978 refresh_screen()
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
979 {
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
980 endwin();
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
981 refresh();
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
982
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
983 X_MAX = getmaxx(stdscr);
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
984 Y_MAX = getmaxy(stdscr) - 1;
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
985
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
986 g_hash_table_foreach(nodes, (GHFunc)refresh_node, NULL);
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
987 update_screen(NULL);
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
988 draw_taskbar(TRUE);
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
989
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
990 return FALSE;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
991 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
992
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
993 /* Xerox */
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
994 static void
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
995 clean_pid(void)
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
996 {
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
997 int status;
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
998 pid_t pid;
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
999
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1000 do {
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1001 pid = waitpid(-1, &status, WNOHANG);
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1002 } while (pid != 0 && pid != (pid_t)-1);
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1003
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1004 if ((pid == (pid_t) - 1) && (errno != ECHILD)) {
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1005 char errmsg[BUFSIZ];
14425
3a91ef295cbb [gaim-migrate @ 17133]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14421
diff changeset
1006 g_snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid);
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1007 perror(errmsg);
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1008 }
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1009 }
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1010
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1011 static void
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1012 sighandler(int sig)
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1013 {
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1014 switch (sig) {
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1015 #ifdef SIGWINCH
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1016 case SIGWINCH:
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1017 werase(stdscr);
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1018 wrefresh(stdscr);
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1019 g_idle_add(refresh_screen, NULL);
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1020 signal(SIGWINCH, sighandler);
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1021 break;
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1022 #endif
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1023 case SIGCHLD:
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1024 clean_pid();
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1025 signal(SIGCHLD, sighandler);
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1026 break;
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1027 }
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1028 }
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1029
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1030 static void
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1031 init_wm()
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1032 {
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1033 const char *name = gnt_style_get(GNT_STYLE_WM);
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1034 gpointer handle;
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1035
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1036 if (!name || !*name)
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1037 return;
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1038
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1039 handle = g_module_open(name, G_MODULE_BIND_LAZY);
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1040 if (handle) {
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1041 gboolean (*init)(GntWM *);
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1042 if (g_module_symbol(handle, "gntwm_init", (gpointer)&init)) {
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1043 init(&wm);
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1044 }
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1045 }
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1046 }
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1047
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1048 void gnt_init()
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1049 {
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1050 static GIOChannel *channel = NULL;
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
1051 char *filename;
14202
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
1052 int result;
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
1053 const char *locale;
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
1054
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1055 if (channel)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1056 return;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1057
14202
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
1058 channel = g_io_channel_unix_new(STDIN_FILENO);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1059
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1060 g_io_channel_set_encoding(channel, NULL, NULL);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1061 g_io_channel_set_buffered(channel, FALSE);
14283
22ad3b783bbe [gaim-migrate @ 16969]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14273
diff changeset
1062 #if 0
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1063 g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL );
14283
22ad3b783bbe [gaim-migrate @ 16969]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14273
diff changeset
1064 #endif
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1065
14202
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
1066 result = g_io_add_watch_full(channel, G_PRIORITY_HIGH,
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
1067 (G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI | G_IO_NVAL),
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
1068 io_invoke, NULL, NULL);
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
1069
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
1070 locale = setlocale(LC_ALL, "");
c3f5ac1f57a9 [gaim-migrate @ 16875]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
1071
14216
e9dd2f76e61b [gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14209
diff changeset
1072 #if 0
e9dd2f76e61b [gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14209
diff changeset
1073 g_io_channel_unref(channel); /* Apparently this causes crash for some people */
e9dd2f76e61b [gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14209
diff changeset
1074 #endif
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1075
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
1076 if (locale && (strstr(locale, "UTF") || strstr(locale, "utf")))
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
1077 ascii_only = FALSE;
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
1078 else
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
1079 ascii_only = TRUE;
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
1080
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1081 initscr();
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
1082 typeahead(-1);
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
1083 noecho();
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
1084 curs_set(0);
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
1085
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14004
diff changeset
1086 gnt_init_styles();
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1087
14004
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
1088 filename = g_build_filename(g_get_home_dir(), ".gntrc", NULL);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
1089 gnt_style_read_configure_file(filename);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
1090 g_free(filename);
06f75fb84a78 [gaim-migrate @ 16589]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
1091
14299
ea5193c23171 [gaim-migrate @ 16989]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14292
diff changeset
1092 gnt_init_colors();
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1093 X_MIN = 0;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1094 Y_MIN = 0;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1095 X_MAX = getmaxx(stdscr);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1096 Y_MAX = getmaxy(stdscr) - 1;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1097
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1098 nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node);
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1099
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1100 wbkgdset(stdscr, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL));
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1101 refresh();
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
1102
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
1103 #ifdef ALL_MOUSE_EVENTS
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
1104 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
1105 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
14314
8b8188fa98f4 [gaim-migrate @ 17007]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14310
diff changeset
1106 #endif
14310
a766441af5ea [gaim-migrate @ 17000]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14299
diff changeset
1107
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1108 wbkgdset(stdscr, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL));
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1109 werase(stdscr);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1110 wrefresh(stdscr);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1111
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1112 #ifdef SIGWINCH
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1113 signal(SIGWINCH, sighandler);
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1114 #endif
14381
3bfea4c4ce33 [gaim-migrate @ 17087]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14362
diff changeset
1115 signal(SIGCHLD, sighandler);
14273
2f82c2494f3f [gaim-migrate @ 16958]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14256
diff changeset
1116
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1117 g_type_init();
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1118
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1119 init_wm();
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1120 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1121
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1122 void gnt_main()
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1123 {
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1124 loop = g_main_loop_new(NULL, FALSE);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1125 g_main_loop_run(loop);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1126 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1127
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1128 /*********************************
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1129 * Stuff for 'window management' *
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1130 *********************************/
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1131
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1132 static void
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1133 free_node(gpointer data)
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1134 {
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1135 GntNode *node = data;
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
1136 hide_panel(node->panel);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1137 del_panel(node->panel);
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1138 g_free(node);
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1139 }
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1140
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1141 void gnt_screen_occupy(GntWidget *widget)
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1142 {
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1143 GntNode *node;
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1144
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1145 while (widget->parent)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1146 widget = widget->parent;
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1147
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1148 if (g_hash_table_lookup(nodes, widget))
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1149 return; /* XXX: perhaps _update instead? */
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1150
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1151 node = g_new0(GntNode, 1);
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1152 node->me = widget;
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1153
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1154 g_hash_table_replace(nodes, widget, node);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1155
14292
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14283
diff changeset
1156 refresh_node(widget, node, NULL);
c111a7e718d0 [gaim-migrate @ 16982]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14283
diff changeset
1157
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1158 if (window_list)
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1159 {
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1160 if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && window_list->window != widget
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1161 && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS))
13934
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
1162 {
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1163 gnt_tree_add_row_last(GNT_TREE(window_list->tree), widget,
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1164 gnt_tree_create_row(GNT_TREE(window_list->tree), GNT_BOX(widget)->title),
14125
7dfa024c1a4a [gaim-migrate @ 16763]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14123
diff changeset
1165 NULL);
13934
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
1166 update_window_in_list(widget);
ef0d515b9f97 [gaim-migrate @ 16462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13930
diff changeset
1167 }
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1168 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1169
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
1170 update_screen(NULL);
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1171 }
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1172
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1173 void gnt_screen_release(GntWidget *widget)
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1174 {
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1175 GntNode *node;
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1176
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1177 gnt_screen_remove_widget(widget);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1178 node = g_hash_table_lookup(nodes, widget);
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1179
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13878
diff changeset
1180 if (node == NULL) /* Yay! Nothing to do. */
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1181 return;
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1182
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1183 g_hash_table_remove(nodes, widget);
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1184
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1185 if (window_list)
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1186 {
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1187 gnt_tree_remove(GNT_TREE(window_list->tree), widget);
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1188 }
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1189
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
1190 update_screen(NULL);
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1191 }
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
1192
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1193 void gnt_screen_update(GntWidget *widget)
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1194 {
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1195 GntNode *node;
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1196
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1197 while (widget->parent)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1198 widget = widget->parent;
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1199
13888
9d66969a2e32 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
1200 gnt_box_sync_children(GNT_BOX(widget));
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1201 node = g_hash_table_lookup(nodes, widget);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1202 if (node && !node->panel)
14042
143474e2b1cb [gaim-migrate @ 16648]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14029
diff changeset
1203 {
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1204 if (wm.new_window && node->me != _list.window)
14335
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1205 node->panel = wm.new_window(node->me);
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1206 else
b1b76fb9c739 [gaim-migrate @ 17031]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14325
diff changeset
1207 node->panel = new_panel(node->me->window);
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14431
diff changeset
1208 set_panel_userptr(node->panel, node);
14042
143474e2b1cb [gaim-migrate @ 16648]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14029
diff changeset
1209 if (!GNT_WIDGET_IS_FLAG_SET(node->me, GNT_WIDGET_TRANSIENT))
143474e2b1cb [gaim-migrate @ 16648]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14029
diff changeset
1210 {
143474e2b1cb [gaim-migrate @ 16648]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14029
diff changeset
1211 bottom_panel(node->panel); /* New windows should not grab focus */
143474e2b1cb [gaim-migrate @ 16648]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14029
diff changeset
1212 gnt_widget_set_urgent(node->me);
143474e2b1cb [gaim-migrate @ 16648]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14029
diff changeset
1213 }
143474e2b1cb [gaim-migrate @ 16648]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14029
diff changeset
1214 }
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1215
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1216 if (_list.window)
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1217 {
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1218 GntNode *nd = g_hash_table_lookup(nodes, _list.window);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
1219 top_panel(nd->panel);
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1220 }
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1221
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
1222 update_screen(NULL);
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1223 }
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1224
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1225 gboolean gnt_widget_has_focus(GntWidget *widget)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1226 {
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1227 GntWidget *w;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1228 if (!widget)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1229 return FALSE;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1230
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1231 w = widget;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1232
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1233 while (widget->parent)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1234 widget = widget->parent;
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1235
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1236 if (widget == _list.window)
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1237 return TRUE;
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1238
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
1239 if (ordered && ordered->data == widget)
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1240 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1241 if (GNT_IS_BOX(widget) &&
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1242 (GNT_BOX(widget)->active == w || widget == w))
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1243 return TRUE;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1244 }
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1245
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1246 return FALSE;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1247 }
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13893
diff changeset
1248
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
1249 void gnt_widget_set_urgent(GntWidget *widget)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
1250 {
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
1251 while (widget->parent)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
1252 widget = widget->parent;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
1253
14317
c8ddda5d8ec8 [gaim-migrate @ 17010]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14314
diff changeset
1254 if (ordered && ordered->data == widget)
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
1255 return;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
1256
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
1257 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_URGENT);
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1258
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1259 if (wm.window_update) {
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1260 GntNode *node = g_hash_table_lookup(nodes, widget);
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1261 wm.window_update(node->panel, widget);
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1262 }
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1263
14245
f64ff0c57457 [gaim-migrate @ 16927]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14220
diff changeset
1264 draw_taskbar(FALSE);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
1265 }
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
1266
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1267 void gnt_quit()
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1268 {
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13957
diff changeset
1269 gnt_uninit_colors();
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14004
diff changeset
1270 gnt_uninit_styles();
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1271 endwin();
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1272 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1273
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
1274 gboolean gnt_ascii_only()
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
1275 {
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
1276 return ascii_only;
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
1277 }
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13919
diff changeset
1278
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1279 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
1280 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1281 if (widget->parent == NULL)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1282 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1283 GntNode *node = g_hash_table_lookup(nodes, widget);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1284 if (!node)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1285 return;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1286
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1287 if (wm.window_resize_confirm && !wm.window_resize_confirm(widget, &width, &height))
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1288 return;
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1289
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1290 hide_panel(node->panel);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1291 gnt_widget_set_size(widget, width, height);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1292 gnt_widget_draw(widget);
14362
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
1293 if (wm.window_resized)
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
1294 node->panel = wm.window_resized(node->panel, widget);
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
1295 else
665b814f8fd7 [gaim-migrate @ 17068]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14343
diff changeset
1296 replace_panel(node->panel, widget->window);
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1297 show_panel(node->panel);
14091
ae4cbed1b309 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
1298 update_screen(NULL);
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1299 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1300 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13934
diff changeset
1301
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1302 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
1303 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1304 GntNode *node = g_hash_table_lookup(nodes, widget);
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1305
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1306 if (wm.window_move_confirm && !wm.window_move_confirm(widget, &x, &y))
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1307 return;
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1308
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1309 gnt_widget_set_position(widget, x, y);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1310 move_panel(node->panel, y, x);
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1311
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1312 if (wm.window_moved)
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1313 wm.window_moved(node->panel, widget);
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1314
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1315 update_screen(NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1316 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1317
14388
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
1318 void gnt_screen_rename_widget(GntWidget *widget, const char *text)
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
1319 {
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
1320 gnt_box_set_title(GNT_BOX(widget), text);
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
1321 gnt_widget_draw(widget);
14390
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1322
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1323 if (wm.window_update) {
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1324 GntNode *node = g_hash_table_lookup(nodes, widget);
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1325 wm.window_update(node->panel, widget);
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1326 }
d4a26ada1971 [gaim-migrate @ 17096]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14388
diff changeset
1327
14388
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
1328 draw_taskbar(FALSE);
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
1329 }
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14387
diff changeset
1330
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1331 /**
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1332 * An application can register actions which will show up in a 'start-menu' like popup
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1333 */
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1334 typedef struct _GnAction
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1335 {
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1336 const char *label;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1337 void (*callback)();
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1338 } GntAction;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1339
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1340 static GList *actions;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1341
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1342 void gnt_register_action(const char *label, void (*callback)())
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1343 {
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1344 GntAction *action = g_new0(GntAction, 1);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1345 action->label = g_strdup(label);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1346 action->callback = callback;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1347
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1348 actions = g_list_append(actions, action);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1349 }
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1350
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1351 static void
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1352 action_list_activate(GntTree *tree, gpointer null)
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1353 {
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1354 GntAction *action = gnt_tree_get_selection_data(tree);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1355 action->callback();
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1356 }
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1357
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1358 static int
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1359 compare_action(gconstpointer p1, gconstpointer p2)
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1360 {
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1361 const GntAction *a1 = p1;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1362 const GntAction *a2 = p2;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1363
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1364 return g_utf8_collate(a1->label, a2->label);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1365 }
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1366
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1367 static void
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1368 show_actions_list()
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1369 {
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1370 GntWidget *tree, *win;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1371 GList *iter;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1372 int h;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1373
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1374 if (action_list)
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1375 return;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1376
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1377 setup__list();
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1378 action_list = &_list;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1379 win = action_list->window;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1380 tree = action_list->tree;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1381
14415
76d345643ba4 [gaim-migrate @ 17123]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
1382 gnt_box_set_title(GNT_BOX(win), "Actions");
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1383 GNT_WIDGET_SET_FLAGS(tree, GNT_WIDGET_NO_BORDER);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1384 /* XXX: Do we really want this? */
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1385 gnt_tree_set_compare_func(GNT_TREE(tree), compare_action);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1386
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1387 for (iter = actions; iter; iter = iter->next) {
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1388 GntAction *action = iter->data;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1389 gnt_tree_add_row_last(GNT_TREE(tree), action,
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1390 gnt_tree_create_row(GNT_TREE(tree), action->label), NULL);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1391 }
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1392 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(action_list_activate), NULL);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1393 gnt_widget_set_size(tree, 0, g_list_length(actions));
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1394 gnt_widget_get_size(win, NULL, &h);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1395 gnt_widget_set_position(win, 0, getmaxy(stdscr) - 1 - h);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1396
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1397 lock_focus_list = 1;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1398 gnt_widget_show(win);
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1399 lock_focus_list = 0;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1400 }
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14390
diff changeset
1401