annotate src/bw.c @ 2102:e1973d1962c5

rm comment warning about (left|right)-tab
author corvid <corvid@lavabit.com>
date Tue, 21 Jun 2011 00:15:55 +0000
parents be3365808be1
children
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 * File: bw.c
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3 *
35
d9e7b35430de Updated copyright lines
jcid
parents: 19
diff changeset
4 * Copyright (C) 2006-2007 Jorge Arellano Cid <jcid@dillo.org>
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8 * the Free Software Foundation; either version 3 of the License, or
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 * (at your option) any later version.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
12 /* Data structures for each browser window */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
15 #include "bw.h"
926
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
16 #include "msg.h"
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
17 #include "list.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
18 #include "capi.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
19 #include "uicmd.hh"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
20
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
21
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
22 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
23 * Local Data
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
24 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
25 /* A list of working browser windows */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
26 static BrowserWindow **bws;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27 static int num_bws, num_bws_max;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
30 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
31 * Initialize global data
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
33 void a_Bw_init(void)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35 num_bws = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 num_bws_max = 16;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37 bws = NULL;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
38 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
39
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
40 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41 * Create a new browser window and return it.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
42 * (the new window is stored in browser_window[])
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
43 */
335
4a6db4341660 - Made several cleanups according to compiler warnings with "-W -Wall".
jcid
parents: 171
diff changeset
44 BrowserWindow *a_Bw_new()
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
45 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
46 BrowserWindow *bw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
47
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
48 /* We use dNew0() to zero the memory */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
49 bw = dNew0(BrowserWindow, 1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
50 a_List_add(bws, num_bws, num_bws_max);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
51 bws[num_bws++] = bw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53 /* Initialize nav_stack */
19
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 0
diff changeset
54 bw->nav_stack = dList_new(8);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
55 bw->nav_stack_ptr = -1;
19
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 0
diff changeset
56
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 0
diff changeset
57 /* Init expect */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
58 bw->nav_expecting = FALSE;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
59 bw->nav_expect_url = NULL;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
60
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
61 bw->redirect_level = 0;
1037
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 926
diff changeset
62 bw->meta_refresh_status = 0;
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 926
diff changeset
63 bw->meta_refresh_url = NULL;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
64
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
65 bw->RootClients = dList_new(8);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
66 bw->ImageClients = dList_new(8);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
67 bw->NumImages = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
68 bw->NumImagesGot = 0;
698
602ab87f6cd2 Patch for CSS stylesheet loading part#2
Jorge Arellano Cid <jcid@dillo.org>
parents: 372
diff changeset
69 bw->NumPendingStyleSheets = 0;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
70 bw->PageUrls = dList_new(8);
48
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
71 bw->Docs = dList_new(8);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
72
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
73 bw->num_page_bugs = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
74 bw->page_bugs = dStr_new("");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
75
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
76 /* now that the bw is made, let's customize it.. */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
77 //Interface_browser_window_customize(bw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
78
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
79 return bw;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
80 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
81
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
82 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
83 * Free resources associated to a bw.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
84 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
85 void a_Bw_free(BrowserWindow *bw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
86 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
87 int i, j;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
88
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
89 for (i = 0; i < num_bws; i++) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
90 if (bws[i] == bw) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
91 a_List_remove(bws, i, num_bws);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
92
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
93 dList_free(bw->RootClients);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
94 dList_free(bw->ImageClients);
48
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
95 dList_free(bw->Docs);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
96
337
47c57c73dd2c - minor mem leak fix.
jcid
parents: 335
diff changeset
97 a_Url_free(bw->nav_expect_url);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
98 for (j = 0; j < dList_length(bw->PageUrls); ++j)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
99 a_Url_free(dList_nth_data(bw->PageUrls, j));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
100 dList_free(bw->PageUrls);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
101
19
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 0
diff changeset
102 for (j = 0; j < dList_length(bw->nav_stack); ++j)
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 0
diff changeset
103 dFree(dList_nth_data(bw->nav_stack, j));
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 0
diff changeset
104 dList_free(bw->nav_stack);
145bd87089e7 Implemented a new scheme of scroll-position remembering. This is one per
jcid
parents: 0
diff changeset
105
1037
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 926
diff changeset
106 a_Url_free(bw->meta_refresh_url);
a72e5506e280 Implemented Instant client-side redirects (META refresh with delay=0)
Jorge Arellano Cid <jcid@dillo.org>
parents: 926
diff changeset
107
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
108 dStr_free(bw->page_bugs, 1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
109 dFree(bw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
110 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
111 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
112 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
113 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
114
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
115 /*- Clients ----------------------------------------------------------------*/
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
116 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
117 * Add a reference to a cache-client. It is kept int this bw's list.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
118 * This helps us keep track of which are active in the window so that it's
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
119 * possible to abort/stop them.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
120 * (Root: Flag, whether a Root URL or not)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
121 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
122 * TODO: Make NumImages count different images.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
123 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
124 void a_Bw_add_client(BrowserWindow *bw, int Key, int Root)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
125 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
126 dReturn_if_fail ( bw != NULL );
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
127
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
128 if (Root) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
129 dList_append(bw->RootClients, INT2VOIDP(Key));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
130 } else {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
131 dList_append(bw->ImageClients, INT2VOIDP(Key));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
132 bw->NumImages++;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
133 /* --Images progress-bar stuff-- */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
134 a_UIcmd_set_img_prog(bw, bw->NumImagesGot, bw->NumImages, 1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
135 }
70
c326d9730628 Made the stop button sensitive when loading an image.
jcid
parents: 48
diff changeset
136 if (dList_length(bw->RootClients) + dList_length(bw->ImageClients) == 1)
c326d9730628 Made the stop button sensitive when loading an image.
jcid
parents: 48
diff changeset
137 a_UIcmd_set_buttons_sens(bw);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
138 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
139
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
140 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
141 * Remove the cache-client from the bw's list
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
142 * (client can be a image or a html page)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
143 * Return: 0 if found, 1 otherwise.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
144 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
145 int a_Bw_remove_client(BrowserWindow *bw, int ClientKey)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
146 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
147 void *data;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
148
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
149 if ((data = dList_find(bw->RootClients, INT2VOIDP(ClientKey)))) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
150 dList_remove_fast(bw->RootClients, data);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
151 } else if ((data = dList_find(bw->ImageClients, INT2VOIDP(ClientKey)))) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
152 dList_remove_fast(bw->ImageClients, data);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
153 ++bw->NumImagesGot;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
154 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
155 return data ? 0 : 1;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
156 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
157
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
158 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
159 * Close a cache-client upon successful retrieval.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
160 * Remove the cache-client from the bw list and update the meters.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
161 * (client can be a image or a html page)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
162 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
163 void a_Bw_close_client(BrowserWindow *bw, int ClientKey)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
164 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
165 if (a_Bw_remove_client(bw, ClientKey) == 0) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
166 a_UIcmd_set_img_prog(bw, bw->NumImagesGot, bw->NumImages, 1);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
167 if (bw->NumImagesGot == bw->NumImages)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
168 a_UIcmd_set_img_prog(bw, 0, 0, 0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
169 if (dList_length(bw->RootClients) == 0)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
170 a_UIcmd_set_buttons_sens(bw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
171 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
172 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
173
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
174 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
175 * Stop the active clients of this bw's top page.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
176 * Note: rendering stops, but the cache continues to be fed.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
177 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
178 void a_Bw_stop_clients(BrowserWindow *bw, int flags)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
179 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
180 void *data;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
181
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
182 if (flags & BW_Root) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
183 /* Remove root clients */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
184 while ((data = dList_nth_data(bw->RootClients, 0))) {
1275
be3365808be1 s/Bw_Force/BW_Force/g
Jorge Arellano Cid <jcid@dillo.org>
parents: 1037
diff changeset
185 a_Capi_stop_client(VOIDP2INT(data), (flags & BW_Force));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
186 dList_remove_fast(bw->RootClients, data);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
187 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
188 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
189
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
190 if (flags & BW_Img) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
191 /* Remove image clients */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
192 while ((data = dList_nth_data(bw->ImageClients, 0))) {
1275
be3365808be1 s/Bw_Force/BW_Force/g
Jorge Arellano Cid <jcid@dillo.org>
parents: 1037
diff changeset
193 a_Capi_stop_client(VOIDP2INT(data), (flags & BW_Force));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
194 dList_remove_fast(bw->ImageClients, data);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
195 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
196 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
197 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
198
48
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
199 /*- Page -------------------------------------------------------------------*/
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
200 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
201 * Add an URL to the browser window's list.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
202 * This helps us keep track of page-requested URLs so that it's
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
203 * possible to stop, abort and reload them.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
204 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
205 void a_Bw_add_url(BrowserWindow *bw, const DilloUrl *Url)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
206 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
207 dReturn_if_fail ( bw != NULL && Url != NULL );
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
208
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
209 if (!dList_find_custom(bw->PageUrls, Url, (dCompareFunc)a_Url_cmp)) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
210 dList_append(bw->PageUrls, a_Url_dup(Url));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
211 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
212 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
213
48
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
214 /*
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
215 * Add a document to the browser window's list.
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
216 */
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
217 void a_Bw_add_doc(BrowserWindow *bw, void *vdoc)
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
218 {
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
219 dReturn_if_fail ( bw != NULL && vdoc != NULL);
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
220
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
221 dList_append(bw->Docs, vdoc);
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
222 }
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
223
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
224 /*
926
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
225 * Get current document.
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
226 */
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
227 void *a_Bw_get_current_doc(BrowserWindow *bw)
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
228 {
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
229 void *doc = NULL;
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
230 int len = dList_length(bw->Docs);
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
231
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
232 if (len == 1)
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
233 doc = dList_nth_data(bw->Docs, 0);
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
234 else if (len > 1)
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
235 MSG("a_Bw_get_current_doc() multiple docs not implemented\n");
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
236
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
237 return doc;
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
238 }
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
239
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
240 /*
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
241 * Get document by URL.
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
242 *
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
243 * This is currently used by popup menus that need to ensure that the
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
244 * page has not changed while the menu was popped up.
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
245 */
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
246 void *a_Bw_get_url_doc(BrowserWindow *bw, const DilloUrl *url)
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
247 {
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
248 void *doc = NULL;
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
249
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
250 if (url && dList_find_custom(bw->PageUrls, url, (dCompareFunc)a_Url_cmp)) {
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
251 doc = a_Bw_get_current_doc(bw);
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
252 }
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
253 return doc;
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
254 }
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
255
caf45b6c8535 Fixed the load image popup option. Also cleaned up the API a bit.
corvid <corvid@lavabit.com>
parents: 698
diff changeset
256 /*
48
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
257 * Remove a document from the bw's list
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
258 */
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
259 void a_Bw_remove_doc(BrowserWindow *bw, void *vdoc)
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
260 {
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
261 void *data;
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
262
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
263 if ((data = dList_find(bw->Docs, vdoc))) {
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
264 dList_remove_fast(bw->Docs, data);
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
265 }
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
266 }
224c9f547b39 Implemented "Load Images" in the page menu and cleaned up html.hh.
jcid
parents: 35
diff changeset
267
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
268 /*- Cleanup ----------------------------------------------------------------*/
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
269 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
270 * Empty RootClients, ImageClients and PageUrls lists and
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
271 * reset progress bar data.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
272 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
273 void a_Bw_cleanup(BrowserWindow *bw)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
274 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
275 void *data;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
276
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
277 /* Remove root clients */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
278 while ((data = dList_nth_data(bw->RootClients, 0))) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
279 dList_remove_fast(bw->RootClients, data);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
280 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
281 /* Remove image clients */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
282 while ((data = dList_nth_data(bw->ImageClients, 0))) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
283 dList_remove_fast(bw->ImageClients, data);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
284 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
285 /* Remove PageUrls */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
286 while ((data = dList_nth_data(bw->PageUrls, 0))) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
287 a_Url_free(data);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
288 dList_remove_fast(bw->PageUrls, data);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
289 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
290
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
291 /* Zero image-progress data */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
292 bw->NumImages = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
293 bw->NumImagesGot = 0;
698
602ab87f6cd2 Patch for CSS stylesheet loading part#2
Jorge Arellano Cid <jcid@dillo.org>
parents: 372
diff changeset
294
602ab87f6cd2 Patch for CSS stylesheet loading part#2
Jorge Arellano Cid <jcid@dillo.org>
parents: 372
diff changeset
295 /* Zero stylesheet counter */
602ab87f6cd2 Patch for CSS stylesheet loading part#2
Jorge Arellano Cid <jcid@dillo.org>
parents: 372
diff changeset
296 bw->NumPendingStyleSheets = 0;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
297 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
298
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
299 /*--------------------------------------------------------------------------*/
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
300
367
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 337
diff changeset
301 int a_Bw_num()
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 337
diff changeset
302 {
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 337
diff changeset
303 return num_bws;
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 337
diff changeset
304 }
898d503db27b - Added a confirmation dialog for closing with Windows/Tabs > 1
jcid
parents: 337
diff changeset
305
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
306 /*
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
307 * Return a bw by index
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
308 */
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
309 BrowserWindow *a_Bw_get(int i)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
310 {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
311 if (i >= 0 && i < num_bws)
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 371
diff changeset
312 return bws[i];
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
313 return NULL;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
314 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
315