annotate console/libgnt/gntbox.c @ 14286:a0394e417fab

[gaim-migrate @ 16972] iirc, you shouldn't call the functions in prefix.h directly as they might not exist. also add DATADIR to Makefile.am so EvilDennisR can find something else to complain about. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Tue, 22 Aug 2006 05:52:03 +0000
parents 27182f83b79b
children 1a500db56415
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 #include "gntbox.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2
13888
9d66969a2e32 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13882
diff changeset
3 #include <string.h>
9d66969a2e32 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13882
diff changeset
4
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 enum
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 SIGS = 1,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 };
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 static GntWidgetClass *parent_class = NULL;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 static guint signals[SIGS] = { 0 };
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
13 static GntWidget * find_focusable_widget(GntBox *box);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
14
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 static void
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
16 add_to_focus(gpointer value, gpointer data)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
17 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
18 GntBox *box = GNT_BOX(data);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
19 GntWidget *w = GNT_WIDGET(value);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
20
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
21 if (GNT_IS_BOX(w))
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
22 g_list_foreach(GNT_BOX(w)->list, add_to_focus, box);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
23 else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_CAN_TAKE_FOCUS))
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
24 box->focus = g_list_append(box->focus, w);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
25 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
26
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
27 static void
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 gnt_box_draw(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 GntBox *box = GNT_BOX(widget);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
32 if (box->focus == NULL && widget->parent == NULL)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
33 g_list_foreach(box->list, add_to_focus, box);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
34
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
35 g_list_foreach(box->list, (GFunc)gnt_widget_draw, NULL);
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
36
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
37 gnt_box_sync_children(box);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 if (box->title)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 gchar *title = g_strdup(box->title);
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
42 int pos = g_utf8_strlen(title, -1), right;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
44 if (pos >= widget->priv.width - 4)
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 {
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
46 g_utf8_strncpy(title, box->title, widget->priv.width - 4);
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
47 pos = 2;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
48 right = pos + g_utf8_strlen(title, -1);
13850
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 else
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 {
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
52 /* XXX: Position of the title might be configurable */
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
53 right = pos;
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
54 pos = (widget->priv.width - pos) / 2;
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
55 right += pos;
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: 13888
diff changeset
57
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
58 if (gnt_widget_has_focus(widget))
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
59 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_TITLE));
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
60 else
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
61 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_TITLE_D));
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
62 mvwaddch(widget->window, 0, pos-1, ACS_RTEE | COLOR_PAIR(GNT_COLOR_NORMAL));
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 mvwprintw(widget->window, 0, pos, title);
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
64 mvwaddch(widget->window, 0, right, ACS_LTEE | COLOR_PAIR(GNT_COLOR_NORMAL));
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65 g_free(title);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 DEBUG;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 reposition_children(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 GList *iter;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 GntBox *box = GNT_BOX(widget);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76 int w, h, curx, cury, max;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 gboolean has_border = FALSE;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79 w = h = 0;
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
80 max = 0;
13855
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13854
diff changeset
81 curx = widget->priv.x;
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13854
diff changeset
82 cury = widget->priv.y;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 if (!(GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_NO_BORDER))
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 has_border = TRUE;
13855
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13854
diff changeset
86 curx += 1;
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13854
diff changeset
87 cury += 1;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 for (iter = box->list; iter; iter = iter->next)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 {
13980
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
92 if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(iter->data), GNT_WIDGET_INVISIBLE))
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
93 continue;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 gnt_widget_set_position(GNT_WIDGET(iter->data), curx, cury);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 gnt_widget_get_size(GNT_WIDGET(iter->data), &w, &h);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 if (box->vertical)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 {
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
98 if (h)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
99 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
100 cury += h + box->pad;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
101 if (max < w)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
102 max = w;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
103 }
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 else
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 {
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
107 if (w)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
108 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
109 curx += w + box->pad;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
110 if (max < h)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
111 max = h;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
112 }
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 }
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
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116 if (has_border)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 {
13855
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13854
diff changeset
118 curx += 1;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 cury += 1;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 max += 2;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
123 if (box->list)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
124 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
125 if (box->vertical)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
126 cury -= box->pad;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
127 else
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
128 curx -= box->pad;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
129 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
130
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131 if (box->vertical)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
133 widget->priv.width = max;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
134 widget->priv.height = cury - widget->priv.y;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136 else
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 widget->priv.width = curx - widget->priv.x;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 widget->priv.height = max;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140 }
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 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 gnt_box_set_position(GntWidget *widget, int x, int y)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145 {
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
146 GList *iter;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
147 int changex, changey;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
148
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
149 changex = widget->priv.x - x;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
150 changey = widget->priv.y - y;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
151
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
152 for (iter = GNT_BOX(widget)->list; iter; iter = iter->next)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
153 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
154 GntWidget *w = GNT_WIDGET(iter->data);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
155 gnt_widget_set_position(w, w->priv.x - changex,
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
156 w->priv.y - changey);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
157 }
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
158 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 gnt_box_size_request(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 GntBox *box = GNT_BOX(widget);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 GList *iter;
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
165 int maxw = 0, maxh = 0;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 g_list_foreach(box->list, (GFunc)gnt_widget_size_request, NULL);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
169 for (iter = box->list; iter; iter = iter->next)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
170 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
171 int w, h;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
172 gnt_widget_get_size(GNT_WIDGET(iter->data), &w, &h);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
173 if (maxh < h)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
174 maxh = h;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
175 if (maxw < w)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
176 maxw = w;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
177 }
13953
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
178
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
179 for (iter = box->list; iter; iter = iter->next)
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 {
13953
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
181 int w, h;
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
182 GntWidget *wid = GNT_WIDGET(iter->data);
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
183
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
184 gnt_widget_get_size(wid, &w, &h);
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
185
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
186 if (box->homogeneous)
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187 {
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
188 if (box->vertical)
13953
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
189 h = maxh;
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
190 else
13953
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
191 w = maxw;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 }
13953
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
193 if (box->fill)
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
194 {
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
195 if (box->vertical)
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
196 w = maxw;
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
197 else
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
198 h = maxh;
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
199 }
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
200
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
201 gnt_widget_set_size(wid, w, h);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 reposition_children(widget);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 gnt_box_map(GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 if (widget->priv.width == 0 || widget->priv.height == 0)
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
211 {
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 gnt_widget_size_request(widget);
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
213 find_focusable_widget(GNT_BOX(widget));
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
214 }
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215 DEBUG;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
216 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217
13855
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13854
diff changeset
218 /* Ensures that the current widget can take focus */
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
219 static GntWidget *
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
220 find_focusable_widget(GntBox *box)
13855
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13854
diff changeset
221 {
13980
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
222 /* XXX: Make sure the widget is visible? */
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
223 if (box->focus == NULL && GNT_WIDGET(box)->parent == NULL)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
224 g_list_foreach(box->list, add_to_focus, box);
13855
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13854
diff changeset
225
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
226 if (box->active == NULL && box->focus)
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
227 box->active = box->focus->data;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
228
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
229 return box->active;
13855
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13854
diff changeset
230 }
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13854
diff changeset
231
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
232 static void
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
233 find_next_focus(GntBox *box)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
234 {
13980
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
235 gpointer last = box->active;
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
236 do
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
237 {
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
238 GList *iter = g_list_find(box->focus, box->active);
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
239 if (iter && iter->next)
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
240 box->active = iter->next->data;
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
241 else if (box->focus)
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
242 box->active = box->focus->data;
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
243 if (!GNT_WIDGET_IS_FLAG_SET(box->active, GNT_WIDGET_INVISIBLE))
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
244 break;
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
245 } while (box->active != last);
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
246 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
247
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
248 static void
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
249 find_prev_focus(GntBox *box)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
250 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
251 gpointer last = box->active;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
252
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
253 if (!box->focus)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
254 return;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
255
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
256 do
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
257 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
258 GList *iter = g_list_find(box->focus, box->active);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
259 if (!iter)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
260 box->active = box->focus->data;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
261 else if (!iter->prev)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
262 box->active = g_list_last(box->focus)->data;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
263 else
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
264 box->active = iter->prev->data;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
265 if (!GNT_WIDGET_IS_FLAG_SET(box->active, GNT_WIDGET_INVISIBLE))
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
266 break;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
267 } while (box->active != last);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
268 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
269
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
270 static gboolean
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
271 gnt_box_key_pressed(GntWidget *widget, const char *text)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
272 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273 GntBox *box = GNT_BOX(widget);
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
274 GntWidget *now;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
276 if (box->active == NULL && !find_focusable_widget(box))
13855
5b288502a382 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13854
diff changeset
277 return FALSE;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
278
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
279 if (gnt_widget_key_pressed(box->active, text))
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
280 return TRUE;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
281
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
282 now = box->active;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
283
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
284 if (text[0] == 27)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
285 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
286 if (strcmp(text+1, GNT_KEY_LEFT) == 0)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
287 {
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
288 find_prev_focus(box);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
289 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
290 else if (strcmp(text+1, GNT_KEY_RIGHT) == 0)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
291 {
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
292 find_next_focus(box);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
293 }
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
294 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
295 else if (text[0] == '\t')
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
296 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
297 find_next_focus(box);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
298 }
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
300 if (now && now != box->active)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
301 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
302 gnt_widget_set_focus(now, FALSE);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
303 gnt_widget_set_focus(box->active, TRUE);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
304 return TRUE;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
306
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
307 return FALSE;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
308 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
309
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
310 static void
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
311 gnt_box_lost_focus(GntWidget *widget)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
312 {
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
313 GntWidget *w = GNT_BOX(widget)->active;
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
314 if (w)
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
315 gnt_widget_set_focus(w, FALSE);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
316 gnt_widget_draw(widget);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
317 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
318
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
319 static void
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
320 gnt_box_gained_focus(GntWidget *widget)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
321 {
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
322 GntWidget *w = GNT_BOX(widget)->active;
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
323 if (w)
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
324 gnt_widget_set_focus(w, TRUE);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
325 gnt_widget_draw(widget);
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
326 }
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
327
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
328 static void
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
329 gnt_box_destroy(GntWidget *w)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
330 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
331 GntBox *box = GNT_BOX(w);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
332
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
333 gnt_box_remove_all(box);
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13866
diff changeset
334 gnt_screen_release(w);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
335 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
336
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
337 static void
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13866
diff changeset
338 gnt_box_expose(GntWidget *widget, int x, int y, int width, int height)
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13866
diff changeset
339 {
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13866
diff changeset
340 WINDOW *win = newwin(height, width, widget->priv.y + y, widget->priv.x + x);
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13866
diff changeset
341 copywin(widget->window, win, y, x, 0, 0, height - 1, width - 1, FALSE);
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13866
diff changeset
342 wrefresh(win);
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13866
diff changeset
343 delwin(win);
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13866
diff changeset
344 }
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13866
diff changeset
345
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
346 static gboolean
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
347 gnt_box_confirm_size(GntWidget *widget, int width, int height)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
348 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
349 GList *iter;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
350 GntBox *box = GNT_BOX(widget);
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
351 int wchange, hchange;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
352
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
353 if (widget->priv.width != width && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_X))
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
354 return FALSE;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
355 if (widget->priv.height != height && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_Y))
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
356 return FALSE;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
357
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
358 if (!box->list)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
359 return TRUE;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
360
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
361 wchange = widget->priv.width - width;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
362 hchange = widget->priv.height - height;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
363
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
364 if (wchange == 0 && hchange == 0)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
365 return TRUE; /* Quit playing games */
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
366
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
367 /* XXX: Right now, I am trying to just apply all the changes to
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
368 * just one widget. It should be possible to distribute the
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
369 * changes to all the widgets in the box. */
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
370 for (iter = box->list; iter; iter = iter->next)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
371 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
372 GntWidget *wid = iter->data;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
373 int w, h;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
374
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
375 gnt_widget_get_size(wid, &w, &h);
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
376
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
377 if (gnt_widget_confirm_size(wid, w - wchange, h - hchange))
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
378 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
379 GList *i;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
380
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
381 for (i = box->list; i; i = i->next)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
382 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
383 int tw, th;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
384 if (i == iter) continue;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
385 gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
386 if (box->vertical)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
387 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
388 if (!gnt_widget_confirm_size(i->data, tw - wchange, th))
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
389 return FALSE;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
390 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
391 else
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
392 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
393 if (!gnt_widget_confirm_size(i->data, tw, th - hchange))
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
394 return FALSE;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
395 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
396 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
397 #if 0
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
398 gnt_widget_set_size(wid, w - wchange, h - hchange);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
399 if (box->vertical)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
400 hchange = 0;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
401 else
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
402 wchange = 0;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
403
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
404 for (i = box->list; i; i = i->next)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
405 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
406 int tw, th;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
407 if (i == iter) continue;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
408 gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
409 gnt_widget_set_size(i->data, tw - wchange, th - hchange);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
410 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
411 #endif
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
412 g_object_set_data(G_OBJECT(box), "size-queued", wid);
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
413 return TRUE;
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
414 }
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
415 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
416
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
417 return FALSE;
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
418 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
419
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13866
diff changeset
420 static void
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
421 gnt_box_size_changed(GntWidget *widget, int oldw, int oldh)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
422 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
423 int wchange, hchange;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
424 GList *i;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
425 GntBox *box = GNT_BOX(widget);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
426 GntWidget *wid;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
427 int tw, th;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
428
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
429 wchange = widget->priv.width - oldw;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
430 hchange = widget->priv.height - oldh;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
431
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
432 wid = g_object_get_data(G_OBJECT(box), "size-queued");
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
433 if (wid)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
434 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
435 gnt_widget_get_size(wid, &tw, &th);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
436 gnt_widget_set_size(wid, tw + wchange, th + hchange);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
437 g_object_set_data(G_OBJECT(box), "size-queued", NULL);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
438 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
439
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
440 if (box->vertical)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
441 hchange = 0;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
442 else
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
443 wchange = 0;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
444
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
445 for (i = box->list; i; i = i->next)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
446 {
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
447 if (wid != i->data)
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
448 {
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
449 gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th);
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
450 gnt_widget_set_size(i->data, tw + wchange, th + hchange);
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13980
diff changeset
451 }
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
452 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
453
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
454 reposition_children(widget);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
455 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
456
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
457 static void
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13855
diff changeset
458 gnt_box_class_init(GntBoxClass *klass)
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
459 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
460 parent_class = GNT_WIDGET_CLASS(klass);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
461 parent_class->destroy = gnt_box_destroy;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
462 parent_class->draw = gnt_box_draw;
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13866
diff changeset
463 parent_class->expose = gnt_box_expose;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
464 parent_class->map = gnt_box_map;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
465 parent_class->size_request = gnt_box_size_request;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
466 parent_class->set_position = gnt_box_set_position;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
467 parent_class->key_pressed = gnt_box_key_pressed;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
468 parent_class->lost_focus = gnt_box_lost_focus;
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13888
diff changeset
469 parent_class->gained_focus = gnt_box_gained_focus;
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
470 parent_class->confirm_size = gnt_box_confirm_size;
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
471 parent_class->size_changed = gnt_box_size_changed;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
472
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
473 DEBUG;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
474 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
475
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
476 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
477 gnt_box_init(GTypeInstance *instance, gpointer class)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
478 {
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
479 /* Initially make both the height and width resizable.
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
480 * Update the flags as necessary when widgets are added to it. */
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
481 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(instance), GNT_WIDGET_GROW_X | GNT_WIDGET_GROW_Y);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
482 DEBUG;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
483 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
484
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
485 /******************************************************************************
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
486 * GntBox API
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
487 *****************************************************************************/
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
488 GType
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
489 gnt_box_get_gtype(void)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
490 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
491 static GType type = 0;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
492
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
493 if(type == 0)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
494 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
495 static const GTypeInfo info = {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
496 sizeof(GntBoxClass),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
497 NULL, /* base_init */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
498 NULL, /* base_finalize */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
499 (GClassInitFunc)gnt_box_class_init,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
500 NULL, /* class_finalize */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
501 NULL, /* class_data */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
502 sizeof(GntBox),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
503 0, /* n_preallocs */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
504 gnt_box_init, /* instance_init */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
505 };
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
506
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
507 type = g_type_register_static(GNT_TYPE_WIDGET,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
508 "GntBox",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
509 &info, 0);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
510 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
511
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
512 return type;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
513 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
514
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
515 GntWidget *gnt_box_new(gboolean homo, gboolean vert)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
516 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
517 GntWidget *widget = g_object_new(GNT_TYPE_BOX, NULL);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
518 GntBox *box = GNT_BOX(widget);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
519
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
520 box->homogeneous = homo;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
521 box->vertical = vert;
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
522 box->pad = 1;
13953
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
523 box->fill = TRUE;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
524 gnt_widget_set_take_focus(widget, TRUE);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
525 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
526 if (vert)
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
527 box->alignment = GNT_ALIGN_LEFT;
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
528 else
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
529 box->alignment = GNT_ALIGN_MID;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
530
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
531 return widget;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
532 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
533
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
534 void gnt_box_add_widget(GntBox *b, GntWidget *widget)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
535 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
536 b->list = g_list_append(b->list, widget);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
537 widget->parent = GNT_WIDGET(b);
13930
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
538
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
539 if (b->vertical)
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
540 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
541 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_X))
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
542 GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(b), GNT_WIDGET_GROW_X);
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
543 }
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
544 else
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
545 {
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
546 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_Y))
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
547 GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(b), GNT_WIDGET_GROW_Y);
3dbcbc5e57e1 [gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
548 }
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
549 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
550
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
551 void gnt_box_set_title(GntBox *b, const char *title)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
552 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
553 g_free(b->title);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
554 b->title = g_strdup(title);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
555 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
556
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
557 void gnt_box_set_pad(GntBox *box, int pad)
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
558 {
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
559 box->pad = pad;
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
560 /* XXX: Perhaps redraw if already showing? */
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
561 }
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
562
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13855
diff changeset
563 void gnt_box_set_toplevel(GntBox *box, gboolean set)
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13855
diff changeset
564 {
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13855
diff changeset
565 GntWidget *widget = GNT_WIDGET(box);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13855
diff changeset
566 if (set)
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
567 {
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13855
diff changeset
568 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
569 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
570 }
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13855
diff changeset
571 else
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
572 {
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13855
diff changeset
573 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
574 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
575 }
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13855
diff changeset
576 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13855
diff changeset
577
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
578 void gnt_box_sync_children(GntBox *box)
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
579 {
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
580 GList *iter;
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
581 GntWidget *widget = GNT_WIDGET(box);
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
582 int pos = 1;
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
583
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
584 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER))
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
585 pos = 0;
13882
5c750626eaa5 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13878
diff changeset
586
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
587 for (iter = box->list; iter; iter = iter->next)
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
588 {
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
589 GntWidget *w = GNT_WIDGET(iter->data);
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
590 int height, width;
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
591 int x, y;
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
592
13980
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
593 if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_INVISIBLE))
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
594 continue;
c9509bd42d7a [gaim-migrate @ 16542]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13953
diff changeset
595
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
596 if (GNT_IS_BOX(w))
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
597 gnt_box_sync_children(GNT_BOX(w));
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
598
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
599 gnt_widget_get_size(w, &width, &height);
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
600
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
601 x = w->priv.x - widget->priv.x;
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
602 y = w->priv.y - widget->priv.y;
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
603
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
604 if (box->vertical)
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
605 {
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
606 if (box->alignment == GNT_ALIGN_RIGHT)
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
607 x += widget->priv.width - width;
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
608 else if (box->alignment == GNT_ALIGN_MID)
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
609 x += (widget->priv.width - width)/2;
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
610 if (x + width > widget->priv.width - pos)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
611 x -= x + width - (widget->priv.width - pos);
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
612 }
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
613 else
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
614 {
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
615 if (box->alignment == GNT_ALIGN_BOTTOM)
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
616 y += widget->priv.height - height;
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
617 else if (box->alignment == GNT_ALIGN_MID)
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
618 y += (widget->priv.height - height)/2;
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
619 if (y + height >= widget->priv.height - pos)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
620 y = widget->priv.height - height - pos;
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
621 }
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
622
13882
5c750626eaa5 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13878
diff changeset
623 copywin(w->window, widget->window, 0, 0,
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
624 y, x, y + height - 1, x + width - 1, FALSE);
13878
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
625 }
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
626 }
0d0ab1e39d0a [gaim-migrate @ 16355]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
627
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
628 void gnt_box_set_alignment(GntBox *box, GntAlignment alignment)
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
629 {
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
630 box->alignment = alignment;
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
631 }
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
632
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
633 void gnt_box_remove(GntBox *box, GntWidget *widget)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
634 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
635 box->list = g_list_remove(box->list, widget);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
636 if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
637 && GNT_WIDGET(box)->parent == NULL && box->focus)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
638 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
639 if (widget == box->active)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
640 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
641 find_next_focus(box);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
642 if (box->active == widget) /* There's only one widget */
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
643 box->active = NULL;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
644 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
645 box->focus = g_list_remove(box->focus, widget);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
646 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
647
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
648 if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(box), GNT_WIDGET_MAPPED))
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
649 gnt_widget_draw(GNT_WIDGET(box));
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
650 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
651
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
652 void gnt_box_remove_all(GntBox *box)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
653 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
654 g_list_foreach(box->list, (GFunc)gnt_widget_destroy, NULL);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
655 g_list_free(box->list);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
656 g_list_free(box->focus);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
657 box->list = NULL;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
658 box->focus = NULL;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
659 GNT_WIDGET(box)->priv.width = 0;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
660 GNT_WIDGET(box)->priv.height = 0;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
661 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
662
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
663 void gnt_box_readjust(GntBox *box)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
664 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
665 GList *iter;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
666 GntWidget *wid;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
667 int width, height;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
668
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
669 g_return_if_fail(GNT_WIDGET(box)->parent == NULL);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
670
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
671 for (iter = box->list; iter; iter = iter->next)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
672 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
673 GntWidget *w = iter->data;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
674 if (GNT_IS_BOX(w))
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
675 gnt_box_readjust(GNT_BOX(w));
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
676 else
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
677 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
678 GNT_WIDGET_UNSET_FLAGS(w, GNT_WIDGET_MAPPED);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
679 w->priv.width = 0;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
680 w->priv.height = 0;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
681 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
682 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
683
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
684 wid = GNT_WIDGET(box);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
685 GNT_WIDGET_UNSET_FLAGS(wid, GNT_WIDGET_MAPPED);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
686 wid->priv.width = 0;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
687 wid->priv.height = 0;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
688
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
689 if (wid->parent == NULL)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
690 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
691 g_list_free(box->focus);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
692 box->focus = NULL;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
693 box->active = NULL;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
694 gnt_widget_size_request(wid);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
695 gnt_widget_get_size(wid, &width, &height);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
696 gnt_screen_resize_widget(wid, width, height);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
697 find_focusable_widget(box);
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
698 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
699 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
700
13953
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
701 void gnt_box_set_fill(GntBox *box, gboolean fill)
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
702 {
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
703 box->fill = fill;
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
704 }
8b2306c64efa [gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
705
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
706 void gnt_box_move_focus(GntBox *box, int dir)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
707 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
708 GntWidget *now;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
709
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
710 if (box->active == NULL)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
711 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
712 find_focusable_widget(box);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
713 return;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
714 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
715
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
716 now = box->active;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
717
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
718 if (dir == 1)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
719 find_next_focus(box);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
720 else if (dir == -1)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
721 find_prev_focus(box);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
722
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
723 if (now && now != box->active)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
724 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
725 gnt_widget_set_focus(now, FALSE);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
726 gnt_widget_set_focus(box->active, TRUE);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
727 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
728
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
729 if (GNT_WIDGET(box)->window)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
730 gnt_widget_draw(GNT_WIDGET(box));
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
731 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
732
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
733 void gnt_box_give_focus_to_child(GntBox *box, GntWidget *widget)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
734 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
735 GList *find = g_list_find(box->focus, widget);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
736 gpointer now = box->active;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
737 if (find)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
738 box->active = widget;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
739 if (now && now != box->active)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
740 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
741 gnt_widget_set_focus(now, FALSE);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
742 gnt_widget_set_focus(box->active, TRUE);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
743 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
744
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
745 if (GNT_WIDGET(box)->window)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
746 gnt_widget_draw(GNT_WIDGET(box));
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
747 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
748