annotate console/libgnt/gntbox.c @ 14824:6ec7e963d186

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