Mercurial > pidgin
annotate console/libgnt/gntmain.c @ 13895:8f910263b4bb
[gaim-migrate @ 16380]
Merge SVN revision #16379 from v2_0_0 to trunk
Original commit message (by LSchiere):
iwkse in #gaim brought it to my attention that the example code in the C Plugin
Howto won't compile. It won't compile because GAIM_WEBSITE is defined in internal.h, which we don't want plugin authors including, and which isn't included in
the sample code.
I decided it would be a good thing if the example code compiled, so I changed it.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 30 Jun 2006 16:23:56 +0000 |
parents | ab671b76fb96 |
children | a621329e8c85 |
rev | line source |
---|---|
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #include "gnt.h" |
13888
9d66969a2e32
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13885
diff
changeset
|
2 #include "gntbox.h" |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 #include "gntkeys.h" |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 #include "gntcolors.h" |
13888
9d66969a2e32
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13885
diff
changeset
|
5 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 #include <stdio.h> |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
7 #include <stdlib.h> |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 #include <locale.h> |
13888
9d66969a2e32
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13885
diff
changeset
|
9 #include <unistd.h> |
9d66969a2e32
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13885
diff
changeset
|
10 #include <string.h> |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 static GList *focus_list; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 static int max_x; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 static int max_y; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
16 static GHashTable *nodes; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
17 |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
18 static void free_node(gpointer data); |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
19 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 void gnt_screen_take_focus(GntWidget *widget) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
21 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 focus_list = g_list_prepend(focus_list, widget); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
24 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 void gnt_screen_remove_widget(GntWidget *widget) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 focus_list = g_list_remove(focus_list, widget); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
28 if (focus_list) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
29 gnt_widget_draw(focus_list->data); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
30 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 static gboolean |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 char buffer[256]; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 int rd = read(0, buffer, sizeof(buffer) - 1); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 if (rd < 0) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40 endwin(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 printf("ERROR!\n"); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 exit(1); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
44 else if (rd == 0) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 endwin(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
47 printf("EOF\n"); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
48 exit(1); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
49 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
50 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
51 buffer[rd] = 0; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
52 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
53 if (focus_list) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
54 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
55 gboolean ret = FALSE; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 ret = gnt_widget_key_pressed(focus_list->data, buffer); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
58 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
59 if (buffer[0] == 27) |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
60 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
61 /* Some special key has been pressed */ |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 if (strcmp(buffer+1, GNT_KEY_POPUP) == 0) |
13885
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
63 {} |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
64 else if (strcmp(buffer + 1, "c") == 0) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
65 { |
13885
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
66 /* Alt + c was pressed. I am going to use it to close a window. */ |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
67 if (focus_list) |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
68 { |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
69 gnt_widget_destroy(focus_list->data); |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
70 gnt_screen_remove_widget(focus_list->data); |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
71 } |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
72 } |
13885
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
73 else if (strcmp(buffer + 1, "q") == 0) |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
74 { |
13885
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
75 /* I am going to use Alt + q to quit. */ |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
76 endwin(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
77 exit(1); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78 } |
13885
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
79 else if (strcmp(buffer + 1, "n") == 0) |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
80 { |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
81 /* Alt + n to go to the next window */ |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
82 if (focus_list && focus_list->next) |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
83 focus_list = focus_list->next; |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
84 else |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
85 focus_list = g_list_first(focus_list); |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
86 if (focus_list) |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
87 { |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
88 /* XXX: Need a way to bring it on top */ |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
89 gnt_widget_draw(focus_list->data); |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
90 } |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
91 } |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
92 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
93 refresh(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
94 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
95 return TRUE; |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
96 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
97 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
98 void gnt_init() |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
99 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
100 GIOChannel *channel = g_io_channel_unix_new(0); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
101 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
102 g_io_channel_set_encoding(channel, NULL, NULL); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
103 g_io_channel_set_buffered(channel, FALSE); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL ); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
105 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
106 int result = g_io_add_watch(channel, |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
107 (G_IO_IN | G_IO_HUP | G_IO_ERR), |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
108 io_invoke, NULL); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
110 setlocale(LC_ALL, ""); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 initscr(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 start_color(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
113 gnt_init_colors(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
115 max_x = getmaxx(stdscr); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 max_y = getmaxy(stdscr); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
117 |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
118 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
|
119 |
13850
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
120 wbkgdset(stdscr, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 noecho(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 refresh(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
123 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
124 g_type_init(); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
125 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
127 void gnt_main() |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
128 { |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 GMainLoop *loop = g_main_new(FALSE); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 g_main_run(loop); |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 } |
0e1e59770cb0
[gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
133 /********************************* |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
134 * Stuff for 'window management' * |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
135 *********************************/ |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
136 |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
137 typedef struct |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
138 { |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
139 GntWidget *me; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
140 GList *below; /* List of widgets below me */ |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
141 GList *above; /* List of widgets above me */ |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
142 } GntNode; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
143 |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
144 static void |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
145 free_node(gpointer data) |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
146 { |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
147 GntNode *node = data; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
148 g_list_free(node->below); |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
149 g_list_free(node->above); |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
150 g_free(node); |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
151 } |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
152 |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
153 static void |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
154 check_intersection(gpointer key, gpointer value, gpointer data) |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
155 { |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
156 GntNode *n = value; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
157 GntNode *nu = data; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
158 |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
159 if (value == NULL) |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
160 return; |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
161 if (n->me == nu->me) |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
162 return; |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
163 |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
164 if (n->me->priv.x + n->me->priv.width < nu->me->priv.x) |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
165 return; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
166 if (nu->me->priv.x + nu->me->priv.width < n->me->priv.x) |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
167 return; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
168 |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
169 if (n->me->priv.y + n->me->priv.height < nu->me->priv.y) |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
170 return; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
171 if (nu->me->priv.y + nu->me->priv.height < n->me->priv.y) |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
172 return; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
173 |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
174 n->above = g_list_prepend(n->above, nu); |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
175 nu->below = g_list_prepend(nu->below, n); |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
176 } |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
177 |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
178 void gnt_screen_occupy(GntWidget *widget) |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
179 { |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
180 GntNode *node; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
181 |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
182 if (widget->parent) |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
183 { |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
184 while (widget->parent) |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
185 widget = widget->parent; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
186 } |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
187 |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
188 if (g_hash_table_lookup(nodes, widget)) |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
189 return; /* XXX: perhaps _update instead? */ |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
190 |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
191 node = g_new0(GntNode, 1); |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
192 node->me = widget; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
193 |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
194 g_hash_table_foreach(nodes, check_intersection, node); |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
195 g_hash_table_replace(nodes, widget, node); |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
196 } |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
197 |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
198 void gnt_screen_release(GntWidget *widget) |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
199 { |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
200 WINDOW *win; |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
201 GList *iter; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
202 GntNode *node = g_hash_table_lookup(nodes, widget); |
13885
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
203 if (node == NULL) /* Yay! Nothing to do. */ |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
204 return; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
205 |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
206 win = dupwin(widget->window); |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
207 werase(win); |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
208 |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
209 /* XXX: This is not going to work. |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
210 * It will be necessary to build a topology and go from there. */ |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
211 for (iter = node->below; iter; iter = iter->next) |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
212 { |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
213 GntNode *n = iter->data; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
214 GntWidget *w = n->me; |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
215 int left, right, top, bottom; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
216 |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
217 left = MAX(widget->priv.x, w->priv.x) - w->priv.x; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
218 right = MIN(widget->priv.x + widget->priv.width, w->priv.x + w->priv.width) - w->priv.x; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
219 |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
220 top = MAX(widget->priv.y, w->priv.y) - w->priv.y; |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
221 bottom = MIN(widget->priv.y + widget->priv.height, w->priv.y + w->priv.height) - w->priv.y; |
13893
ab671b76fb96
[gaim-migrate @ 16376]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
222 |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
223 copywin(w->window, win, top, left, |
13893
ab671b76fb96
[gaim-migrate @ 16376]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
224 w->priv.y - widget->priv.y + top, |
ab671b76fb96
[gaim-migrate @ 16376]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
225 w->priv.x - widget->priv.x + left, |
ab671b76fb96
[gaim-migrate @ 16376]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
226 w->priv.y - widget->priv.y + bottom - 1, |
ab671b76fb96
[gaim-migrate @ 16376]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
227 w->priv.x - widget->priv.x + right - 1, FALSE); |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
228 n->above = g_list_remove(n->above, node); |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
229 } |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
230 |
13885
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
231 for (iter = node->above; iter; iter = iter->next) |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
232 { |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
233 GntNode *n = iter->data; |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
234 n->below = g_list_remove(n->below, node); |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
235 } |
582aaa4e287e
[gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
236 |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
237 wrefresh(win); |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
238 delwin(win); |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
239 |
13869
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
240 g_hash_table_remove(nodes, widget); |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
241 } |
5642f4658b59
[gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13860
diff
changeset
|
242 |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
243 void gnt_screen_update(GntWidget *widget) |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
244 { |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
245 GList *iter; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
246 WINDOW *win; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
247 GntNode *node; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
248 |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
249 if (widget->parent) |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
250 { |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
251 while (widget->parent) |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
252 widget = widget->parent; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
253 } |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
254 |
13888
9d66969a2e32
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13885
diff
changeset
|
255 gnt_box_sync_children(GNT_BOX(widget)); |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
256 node = g_hash_table_lookup(nodes, widget); |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
257 |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
258 win = dupwin(widget->window); |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
259 |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
260 if (node && node->above) |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
261 { |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
262 /* XXX: Same here: need to build a topology first. */ |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
263 for (iter = node->above; iter; iter = iter->next) |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
264 { |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
265 GntNode *n = iter->data; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
266 GntWidget *w = n->me; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
267 int left, right, top, bottom; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
268 |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
269 left = MAX(widget->priv.x, w->priv.x) - w->priv.x; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
270 right = MIN(widget->priv.x + widget->priv.width, w->priv.x + w->priv.width) - w->priv.x; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
271 |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
272 top = MAX(widget->priv.y, w->priv.y) - w->priv.y; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
273 bottom = MIN(widget->priv.y + widget->priv.height, w->priv.y + w->priv.height) - w->priv.y; |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
274 |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
275 copywin(w->window, win, top, left, |
13893
ab671b76fb96
[gaim-migrate @ 16376]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
276 w->priv.y - widget->priv.y + top, |
ab671b76fb96
[gaim-migrate @ 16376]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
277 w->priv.x - widget->priv.x + left, |
ab671b76fb96
[gaim-migrate @ 16376]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
278 w->priv.y - widget->priv.y + bottom - 1, |
ab671b76fb96
[gaim-migrate @ 16376]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
279 w->priv.x - widget->priv.x + right - 1, FALSE); |
13878
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
280 } |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
281 } |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
282 |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
283 wrefresh(win); |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
284 delwin(win); |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
285 } |
0d0ab1e39d0a
[gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13869
diff
changeset
|
286 |