1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
|
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* gui-gtk-bar.c: bar functions for Gtk GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include "../../core/weechat.h"
#include "../../core/wee-log.h"
#include "../gui-bar.h"
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-window.h"
#include "gui-gtk.h"
/*
* gui_bar_window_search_bar: search a reference to a bar in a window
*/
struct t_gui_bar_window *
gui_bar_window_search_bar (struct t_gui_window *window, struct t_gui_bar *bar)
{
struct t_gui_bar_window *ptr_bar_win;
for (ptr_bar_win = GUI_GTK(window)->bar_windows; ptr_bar_win;
ptr_bar_win = ptr_bar_win->next_bar_window)
{
if (ptr_bar_win->bar == bar)
return ptr_bar_win;
}
/* bar window not found for window */
return NULL;
}
/*
* gui_bar_window_get_size: get total bar size (window bars) for a position
* bar is optional, if not NULL, size is computed
* from bar 1 to bar # - 1
*/
int
gui_bar_window_get_size (struct t_gui_bar *bar, struct t_gui_window *window,
enum t_gui_bar_position position)
{
(void) bar;
(void) window;
(void) position;
/* TODO: write this function for Gtk */
return 0;
}
/*
* gui_bar_check_size_add: check if "add_size" is ok for bar
* return 1 if new size is ok
* 0 if new size is too big
*/
int
gui_bar_check_size_add (struct t_gui_bar *bar, int add_size)
{
(void) bar;
(void) add_size;
/* TODO: write this function for Gtk */
return 1;
}
/*
* gui_bar_window_calculate_pos_size: calculate position and size of a bar
*/
void
gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window,
struct t_gui_window *window)
{
(void) bar_window;
(void) window;
/* TODO: write this function for Gtk */
}
/*
* gui_bar_window_create_win: create curses window for bar
*/
void
gui_bar_window_create_win (struct t_gui_bar_window *bar_window)
{
(void) bar_window;
/* TODO: write this function for Gtk */
}
/*
* gui_bar_window_find_pos: find position for bar window (keeping list sorted
* by bar number)
*/
struct t_gui_bar_window *
gui_bar_window_find_pos (struct t_gui_bar *bar, struct t_gui_window *window)
{
struct t_gui_bar_window *ptr_bar_window;
for (ptr_bar_window = GUI_GTK(window)->bar_windows; ptr_bar_window;
ptr_bar_window = ptr_bar_window->next_bar_window)
{
if (ptr_bar_window->bar->number > bar->number)
return ptr_bar_window;
}
/* position not found, best position is at the end */
return NULL;
}
/*
* gui_bar_window_new: create a new "window bar" for a bar, in screen or a window
* if window is not NULL, bar window will be in this window
*/
int
gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
{
(void) bar;
(void) window;
/* TODO: write this function for Gtk */
return 0;
}
/*
* gui_bar_window_free: free a bar window
*/
void
gui_bar_window_free (struct t_gui_bar_window *bar_window,
struct t_gui_window *window)
{
(void) bar_window;
(void) window;
/* TODO: write this function for Gtk */
}
/*
* gui_bar_free_bar_windows: free bar windows for a bar
*/
void
gui_bar_free_bar_windows (struct t_gui_bar *bar)
{
struct t_gui_window *ptr_win;
struct t_gui_bar_window *ptr_bar_win, *next_bar_win;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
ptr_bar_win = GUI_GTK(gui_windows)->bar_windows;
while (ptr_bar_win)
{
next_bar_win = ptr_bar_win->next_bar_window;
if (ptr_bar_win->bar == bar)
gui_bar_window_free (ptr_bar_win, ptr_win);
ptr_bar_win = next_bar_win;
}
}
}
/*
* gui_bar_window_remove_unused_bars: remove unused bars for a window
* return 1 if at least one bar was removed
* 0 if no bar was removed
*/
int
gui_bar_window_remove_unused_bars (struct t_gui_window *window)
{
int rc;
struct t_gui_bar_window *ptr_bar_win, *next_bar_win;
rc = 0;
ptr_bar_win = GUI_GTK(window)->bar_windows;
while (ptr_bar_win)
{
next_bar_win = ptr_bar_win->next_bar_window;
if (((ptr_bar_win->bar->type == GUI_BAR_TYPE_WINDOW_ACTIVE)
&& (window != gui_current_window))
|| ((ptr_bar_win->bar->type == GUI_BAR_TYPE_WINDOW_INACTIVE)
&& (window == gui_current_window)))
{
gui_bar_window_free (ptr_bar_win, window);
rc = 1;
}
ptr_bar_win = next_bar_win;
}
return rc;
}
/*
* gui_bar_window_add_missing_bars: add missing bars for a window
* return 1 if at least one bar was created
* 0 if no bar was created
*/
int
gui_bar_window_add_missing_bars (struct t_gui_window *window)
{
int rc;
struct t_gui_bar *ptr_bar;
rc = 0;
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
if (((ptr_bar->type == GUI_BAR_TYPE_WINDOW_ACTIVE)
&& (window == gui_current_window))
|| ((ptr_bar->type == GUI_BAR_TYPE_WINDOW_INACTIVE)
&& (window != gui_current_window)))
{
if (!gui_bar_window_search_bar (window, ptr_bar))
{
gui_bar_window_new (ptr_bar, window);
rc = 1;
}
}
}
return rc;
}
/*
* gui_bar_window_print_string: print a string text on a bar window
* return number of chars displayed on screen
*/
int
gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
char *string, int max_chars)
{
(void) bar_window;
(void) string;
(void) max_chars;
/* TODO: write this function for Gtk */
return 0;
}
/*
* gui_bar_window_draw: draw a bar for a window
*/
void
gui_bar_window_draw (struct t_gui_bar_window *bar_window,
struct t_gui_window *window)
{
(void) bar_window;
(void) window;
/* TODO: write this function for Gtk */
}
/*
* gui_bar_draw: draw a bar
*/
void
gui_bar_draw (struct t_gui_bar *bar)
{
(void) bar;
/* TODO: write this function for Gtk */
}
/*
* gui_bar_window_print_log: print bar window infos in log (usually for crash dump)
*/
void
gui_bar_window_print_log (struct t_gui_bar_window *bar_window)
{
log_printf ("");
log_printf (" [window bar (addr:0x%x)]", bar_window);
log_printf (" bar . . . . . . . : 0x%x", bar_window->bar);
log_printf (" x . . . . . . . . : %d", bar_window->x);
log_printf (" y . . . . . . . . : %d", bar_window->y);
log_printf (" width . . . . . . : %d", bar_window->width);
log_printf (" height. . . . . . : %d", bar_window->height);
log_printf (" prev_bar_window . : 0x%x", bar_window->prev_bar_window);
log_printf (" next_bar_window . : 0x%x", bar_window->next_bar_window);
}
|