r8932 jmb - /trunk/netsurfbuild/autobuild.pl
by netsurf@semichrome.net
Author: jmb
Date: Fri Jul 31 18:26:24 2009
New Revision: 8932
URL: http://source.netsurf-browser.org?rev=8932&view=rev
Log:
Hack around core buildsystem include mess.
Build libcss with NDEBUG undefined for the moment -- I want assertion failures rather than unpredictable behaviour.
Modified:
trunk/netsurfbuild/autobuild.pl
Modified: trunk/netsurfbuild/autobuild.pl
URL: http://source.netsurf-browser.org/trunk/netsurfbuild/autobuild.pl?rev=893...
==============================================================================
--- trunk/netsurfbuild/autobuild.pl (original)
+++ trunk/netsurfbuild/autobuild.pl Fri Jul 31 18:26:24 2009
@@ -87,26 +87,32 @@
chdir "$root/libparserutils";
command("svn update --non-interactive");
+command("make TARGET=riscos uninstall");
command("make TARGET=riscos install");
chdir "$root/libwapcaplet";
command("svn update --non-interactive");
+command("make TARGET=riscos uninstall");
command("make TARGET=riscos install");
chdir "$root/hubbub";
command("svn update --non-interactive");
+command("make TARGET=riscos uninstall");
command("make TARGET=riscos install");
chdir "$root/libcss";
command("svn update --non-interactive");
-command("make TARGET=riscos install");
+command("make TARGET=riscos uninstall");
+command("make TARGET=riscos OPTCFLAGS=-O2 install");
chdir "$root/libnsbmp";
command("svn update --non-interactive");
+command("make TARGET=riscos uninstall");
command("make TARGET=riscos install");
chdir "$root/libnsgif";
command("svn update --non-interactive");
+command("make TARGET=riscos uninstall");
command("make TARGET=riscos install");
# build RISC OS version
14 years, 1 month
r8931 jmb - in /trunk/libcss: src/parse/parse.c test/data/parse2/eof.dat
by netsurf@semichrome.net
Author: jmb
Date: Fri Jul 31 18:19:21 2009
New Revision: 8931
URL: http://source.netsurf-browser.org?rev=8931&view=rev
Log:
More rigorous handling of EOF.
Expand test data for this.
Modified:
trunk/libcss/src/parse/parse.c
trunk/libcss/test/data/parse2/eof.dat
Modified: trunk/libcss/src/parse/parse.c
URL: http://source.netsurf-browser.org/trunk/libcss/src/parse/parse.c?rev=8931...
==============================================================================
--- trunk/libcss/src/parse/parse.c (original)
+++ trunk/libcss/src/parse/parse.c Fri Jul 31 18:19:21 2009
@@ -934,6 +934,14 @@
if (error != CSS_OK)
return error;
+ if (token->type == CSS_TOKEN_EOF) {
+ error = pushBack(parser, token);
+ if (error != CSS_OK)
+ return error;
+
+ return done(parser);
+ }
+
if (token->type != CSS_TOKEN_CHAR ||
lwc_string_length(token->idata) != 1 ||
lwc_string_data(token->idata)[0] != '{') {
@@ -976,6 +984,9 @@
error = pushBack(parser, token);
if (error != CSS_OK)
return error;
+
+ if (token->type == CSS_TOKEN_EOF)
+ return done(parser);
/* If this can't possibly be the start of a decl-list, then
* attempt to parse a declaration. This will catch any invalid
@@ -1005,8 +1016,13 @@
if (error != CSS_OK)
return error;
- if (token->type == CSS_TOKEN_EOF)
- break;
+ if (token->type == CSS_TOKEN_EOF) {
+ error = pushBack(parser, token);
+ if (error != CSS_OK)
+ return error;
+
+ return done(parser);
+ }
if (token->type != CSS_TOKEN_CHAR ||
lwc_string_length(token->idata) != 1 ||
@@ -1139,6 +1155,14 @@
if (error != CSS_OK)
return error;
+ if (token->type == CSS_TOKEN_EOF) {
+ error = pushBack(parser, token);
+ if (error != CSS_OK)
+ return error;
+
+ return done(parser);
+ }
+
if (token->type != CSS_TOKEN_CHAR ||
lwc_string_length(token->idata) != 1) {
/* Should never happen FOLLOW(at-rule) == '{', ';'*/
@@ -1235,8 +1259,13 @@
if (error != CSS_OK)
return error;
- if (token->type == CSS_TOKEN_EOF)
- break;
+ if (token->type == CSS_TOKEN_EOF) {
+ error = pushBack(parser, token);
+ if (error != CSS_OK)
+ return error;
+
+ return done(parser);
+ }
if (token->type != CSS_TOKEN_CHAR ||
lwc_string_length(token->idata) != 1 ||
@@ -1316,6 +1345,11 @@
parser->event_pw);
}
+ unref_interned_strings_in_tokens(
+ parser);
+ parserutils_vector_clear(
+ parser->tokens);
+
return transition(parser, to,
subsequent);
} else if (lwc_string_length(
@@ -1368,6 +1402,11 @@
parser->event_pw);
}
+ unref_interned_strings_in_tokens(
+ parser);
+ parserutils_vector_clear(
+ parser->tokens);
+
return done(parser);
}
} else if (token->type == CSS_TOKEN_EOF) {
@@ -1385,6 +1424,9 @@
parser->event_pw);
}
+ unref_interned_strings_in_tokens(parser);
+ parserutils_vector_clear(parser->tokens);
+
return done(parser);
}
@@ -1468,6 +1510,14 @@
error = getToken(parser, &token);
if (error != CSS_OK)
return error;
+
+ if (token->type == CSS_TOKEN_EOF) {
+ error = pushBack(parser, token);
+ if (error != CSS_OK)
+ return error;
+
+ return done(parser);
+ }
if (token->type != CSS_TOKEN_CHAR ||
lwc_string_length(token->idata) != 1 ||
@@ -1535,8 +1585,13 @@
if (error != CSS_OK)
return error;
- if (token->type == CSS_TOKEN_EOF)
+ if (token->type == CSS_TOKEN_EOF) {
+ error = pushBack(parser, token);
+ if (error != CSS_OK)
+ return error;
+
return done(parser);
+ }
if (token->type != CSS_TOKEN_CHAR ||
lwc_string_length(token->idata) != 1 ||
@@ -1629,6 +1684,14 @@
error = getToken(parser, &token);
if (error != CSS_OK)
return error;
+
+ if (token->type == CSS_TOKEN_EOF) {
+ error = pushBack(parser, token);
+ if (error != CSS_OK)
+ return error;
+
+ return done(parser);
+ }
if (token->type != CSS_TOKEN_IDENT) {
/* parse error */
@@ -2498,8 +2561,13 @@
if (error != CSS_OK)
return error;
- if (token->type == CSS_TOKEN_EOF)
- break;
+ if (token->type == CSS_TOKEN_EOF) {
+ error = pushBack(parser, token);
+ if (error != CSS_OK)
+ return error;
+
+ return done(parser);
+ }
if (token->type != CSS_TOKEN_CHAR ||
lwc_string_length(token->idata) != 1 ||
Modified: trunk/libcss/test/data/parse2/eof.dat
URL: http://source.netsurf-browser.org/trunk/libcss/test/data/parse2/eof.dat?r...
==============================================================================
--- trunk/libcss/test/data/parse2/eof.dat (original)
+++ trunk/libcss/test/data/parse2/eof.dat Fri Jul 31 18:19:21 2009
@@ -177,6 +177,125 @@
#reset
#data
+@media screen
+#errors
+#expected
+| @media
+#reset
+
+#data
+@media screen
+#errors
+#expected
+| @media
+#reset
+
+#data
+@media screen{
+#errors
+#expected
+| @media
+#reset
+
+#data
+@media screen{
+#errors
+#expected
+| @media
+#reset
+
+#data
+@media screen{{
+#errors
+#expected
+| @media
+#reset
+
+#data
+@media screen{;
+#errors
+#expected
+| @media
+#reset
+
+#data
+@media screen{f
+#errors
+#expected
+| @media
+| f
+#reset
+
+#data
+@media screen{f{
+#errors
+#expected
+| @media
+| f
+#reset
+
+#data
+@media screen{f{color
+#errors
+#expected
+| @media
+| f
+#reset
+
+#data
+@media screen{f{color:
+#errors
+#expected
+| @media
+| f
+#reset
+
+#data
+@media screen{f{color:blue
+#errors
+#expected
+| @media
+| f
+| color: #0000ff00
+#reset
+
+#data
+@media screen{f{color:blue;
+#errors
+#expected
+| @media
+| f
+| color: #0000ff00
+#reset
+
+#data
+@media screen{f{color:blue}
+#errors
+#expected
+| @media
+| f
+| color: #0000ff00
+#reset
+
+#data
+@media screen{f{color:blue;}
+#errors
+#expected
+| @media
+| f
+| color: #0000ff00
+#reset
+
+#data
+@media screen{f{color:blue;}}
+#errors
+#expected
+| @media
+| f
+| color: #0000ff00
+#reset
+
+#data
l(
#errors
#expected
14 years, 1 month
r8930 paulblokus - in /branches/paulblokus/treeview: desktop/tree.c gtk/gtk_treeview.c
by netsurf@semichrome.net
Author: paulblokus
Date: Fri Jul 31 17:20:43 2009
New Revision: 8930
URL: http://source.netsurf-browser.org?rev=8930&view=rev
Log:
fixed redraw logic bugs
Modified:
branches/paulblokus/treeview/desktop/tree.c
branches/paulblokus/treeview/gtk/gtk_treeview.c
Modified: branches/paulblokus/treeview/desktop/tree.c
URL: http://source.netsurf-browser.org/branches/paulblokus/treeview/desktop/tr...
==============================================================================
--- branches/paulblokus/treeview/desktop/tree.c (original)
+++ branches/paulblokus/treeview/desktop/tree.c Fri Jul 31 17:20:43 2009
@@ -196,6 +196,8 @@
static void tree_stop_edit(struct tree *tree, bool keep_changes);
static void tree_icon_callback(content_msg msg, struct content *c,
intptr_t p1, intptr_t p2, union content_msg_data data);
+static void tree_textarea_redraw_request(void *data, int x, int y,
+ int width, int height);
/**
* Creates and initialises a new tree.
@@ -522,8 +524,9 @@
int y = node->box.y;
tree_delete_node_internal(tree, node, siblings);
tree_recalculate_node_positions(tree, tree->root);
- tree->redraw_request(tree->client_data,
- 0, y, tree->width, tree->height);
+ if (tree->redraw)
+ tree->redraw_request(tree->client_data,
+ 0, y, tree->width, tree->height);
tree_recalculate_size(tree);
}
@@ -657,8 +660,10 @@
if (height < tree->height)
height = tree->height;
- tree->redraw_request(tree->client_data,
- 0, node->box.y, width, height - node->box.y);
+ if (tree->redraw)
+ tree->redraw_request(tree->client_data,
+ 0, node->box.y,
+ width, height - node->box.y);
}
}
@@ -756,7 +761,7 @@
for (; node != end; node = node->next) {
if (node->selected != selected) {
node->selected = selected;
- if (tree != NULL)
+ if (tree != NULL && tree->redraw)
tree->redraw_request(tree->client_data,
node->box.x, node->box.y,
node->box.width,
@@ -1082,30 +1087,34 @@
/**
* Redraws a tree.
*
- * \param tree the tree to draw
- * \param clip_x the minimum x of the clipping rectangle
- * \param clip_y the minimum y of the clipping rectangle
- * \param clip_width the width of the clipping rectangle
- * \param clip_height the height of the clipping rectangle
+ * \param tree the tree to draw
+ * \param clip_x the minimum x of the clipping rectangle relative to
+ * the tree origin
+ * \param clip_y the minimum y of the clipping rectangle relative to
+ * the tree origin
+ * \param clip_width the width of the clipping rectangle
+ * \param clip_height the height of the clipping rectangle
*/
void tree_draw(struct tree *tree, int clip_x, int clip_y, int clip_width,
int clip_height)
{
+ int x, y;
assert(tree != NULL);
assert(tree->root != NULL);
/* don't draw empty trees or trees with redraw flag set to false */
if (tree->root->child == NULL || !tree->redraw) return;
- plot.rectangle(clip_x, clip_y, clip_x + clip_width,
- clip_y + clip_height,
+ x = tree->x + clip_x;
+ y = tree->y + clip_y;
+ plot.rectangle(x, y, x + clip_width, y + clip_height,
plot_style_fill_white);
- plot.clip(clip_x, clip_y, clip_x + clip_width, clip_y + clip_height);
- tree_draw_node(tree, tree->root->child, clip_x - tree->x,
- clip_y - tree->y, clip_width, clip_height);
+ plot.clip(x, y, x + clip_width, y + clip_height);
+ tree_draw_node(tree, tree->root->child, clip_x,
+ clip_y, clip_width, clip_height);
if (tree->editing != NULL) {
- textarea_redraw(tree->textarea, clip_x, clip_y,
- clip_x + clip_width, clip_y + clip_height);
+ textarea_redraw(tree->textarea, x, y,
+ x + clip_width, y + clip_height);
}
}
@@ -1773,15 +1782,17 @@
if (tree != NULL) {
if ((node->box.height != height) || (expansion)) {
tree_recalculate_node_positions(tree, tree->root);
- tree->redraw_request(tree->client_data,
- 0, node->box.y, tree->width,
- tree->height - node->box.y);
+ if (tree->redraw)
+ tree->redraw_request(tree->client_data,
+ 0, node->box.y, tree->width,
+ tree->height - node->box.y);
} else {
width = (width > node->box.width) ?
width : node->box.width;
- tree->redraw_request(tree->client_data,
- node->box.x, node->box.y,
- width, node->box.height);
+ if (tree->redraw)
+ tree->redraw_request(tree->client_data,
+ node->box.x, node->box.y,
+ width, node->box.height);
}
if ((recalculate_sizes) || (expansion))
tree_recalculate_size(tree);
@@ -1809,7 +1820,7 @@
if (element->box.height != height) {
tree_recalculate_node_sizes(tree, element->parent, false);
- if (tree != NULL)
+ if (tree != NULL && tree->redraw)
tree->redraw_request(tree->client_data,
0, element->box.y, tree->width +
element->box.width - width,
@@ -1822,9 +1833,10 @@
if (tree != NULL) {
width = (width > element->box.width) ? width :
element->box.width;
- tree->redraw_request(tree->client_data,
- element->box.x, element->box.y,
- width, element->box.height);
+ if (tree->redraw)
+ tree->redraw_request(tree->client_data,
+ element->box.x, element->box.y,
+ width, element->box.height);
}
}
}
@@ -2293,8 +2305,9 @@
tree_clear_processing(tree->root);
tree_recalculate_node_positions(tree, tree->root);
- tree->redraw_request(tree->client_data,
- 0, 0, tree->width, tree->height);
+ if (tree->redraw)
+ tree->redraw_request(tree->client_data,
+ 0, 0, tree->width, tree->height);
}
@@ -2408,8 +2421,8 @@
}
tree->textarea = textarea_create(x, y, width, height, 0,
- &plot_fstyle, tree->redraw_request,
- tree->client_data);
+ &plot_fstyle, tree_textarea_redraw_request,
+ tree);
if (tree->textarea == NULL) {
tree_stop_edit(tree, false);
return;
@@ -2553,3 +2566,16 @@
{
return;
}
+
+/**
+ * Redraw requests from the textarea are piped through this because we have to
+ * check the redraw flag of the tree before requesting a redraw.
+ */
+void tree_textarea_redraw_request(void *data, int x, int y,
+ int width, int height)
+{
+ struct tree *tree = data;
+ if (tree->redraw)
+ tree->redraw_request(tree->client_data,
+ x - tree->x, y - tree->y, width, height);
+}
Modified: branches/paulblokus/treeview/gtk/gtk_treeview.c
URL: http://source.netsurf-browser.org/branches/paulblokus/treeview/gtk/gtk_tr...
==============================================================================
--- branches/paulblokus/treeview/gtk/gtk_treeview.c (original)
+++ branches/paulblokus/treeview/gtk/gtk_treeview.c Fri Jul 31 17:20:43 2009
@@ -39,8 +39,12 @@
void gtk_tree_redraw_request(void *data, int x, int y, int width, int height)
{
struct gtk_treeview_window *tw = data;
+ struct tree *tree = tw->tree;
+ int tree_x, tree_y;
+
+ tree_get_position(tree, &tree_x, &tree_y);
gtk_widget_queue_draw_area(GTK_WIDGET(tw->drawing_area),
- x, y, width, height);
+ tree_x + x, tree_y + y, width, height);
}
@@ -262,7 +266,6 @@
int x, y;
tree_get_position(tree, &x, &y);
-
/* We consider only button 1 clicks as double clicks.
* If the mouse state is PRESS then we are waiting for a release to emit
* a click event, otherwise just reset the state to nothing*/
14 years, 1 month
r8929 paulblokus - in /branches/paulblokus/selectscroll: desktop/browser.c desktop/scroll.c desktop/textinput.c render/box.c render/box.h render/html_redraw.c
by netsurf@semichrome.net
Author: paulblokus
Date: Fri Jul 31 15:10:54 2009
New Revision: 8929
URL: http://source.netsurf-browser.org?rev=8929&view=rev
Log:
replaced int scrolls with pointers to scroll structs in box struct
Modified:
branches/paulblokus/selectscroll/desktop/browser.c
branches/paulblokus/selectscroll/desktop/scroll.c
branches/paulblokus/selectscroll/desktop/textinput.c
branches/paulblokus/selectscroll/render/box.c
branches/paulblokus/selectscroll/render/box.h
branches/paulblokus/selectscroll/render/html_redraw.c
Modified: branches/paulblokus/selectscroll/desktop/browser.c
URL: http://source.netsurf-browser.org/branches/paulblokus/selectscroll/deskto...
==============================================================================
--- branches/paulblokus/selectscroll/desktop/browser.c (original)
+++ branches/paulblokus/selectscroll/desktop/browser.c Fri Jul 31 15:10:54 2009
@@ -1477,14 +1477,14 @@
(overflow == CSS_OVERFLOW_SCROLL ||
overflow == CSS_OVERFLOW_AUTO) &&
((box_vscrollbar_present(box) &&
- box_x + box->scroll_x + box->padding[LEFT] +
- box->width < x) ||
+ box_x + scroll_get(box->scroll_x) +
+ box->padding[LEFT] + box->width < x) ||
(box_hscrollbar_present(box) &&
- box_y + box->scroll_y + box->padding[TOP] +
- box->height < y))) {
+ box_y + scroll_get(box->scroll_y) +
+ box->padding[TOP] + box->height < y))) {
scroll_box = box;
- scroll_box_x = box_x + box->scroll_x;
- scroll_box_y = box_y + box->scroll_y;
+ scroll_box_x = box_x + scroll_get(box->scroll_x);
+ scroll_box_y = box_y + scroll_get(box->scroll_y);
}
if (box->text && !box->object) {
@@ -1949,7 +1949,7 @@
assert(box);
if (bw->drag_type == DRAGGING_HSCROLL) {
- scroll_y = box->scroll_y;
+ scroll_y = scroll_get(box->scroll_y);
} else {
scroll_y = bw->drag_start_scroll_y +
(float) (y - bw->drag_start_y) /
@@ -1962,12 +1962,12 @@
scroll_y)
scroll_y = box->descendant_y1 -
box->height;
- if (scroll_y == box->scroll_y)
+ if (scroll_y == scroll_get(box->scroll_y))
return;
}
if (bw->drag_type == DRAGGING_VSCROLL) {
- scroll_x = box->scroll_x;
+ scroll_x = scroll_get(box->scroll_x);
} else {
scroll_x = bw->drag_start_scroll_x +
(float) (x - bw->drag_start_x) /
@@ -2180,8 +2180,8 @@
bw->scrolling_box = box;
bw->drag_start_x = box_x + x;
bw->drag_start_y = box_y + y;
- bw->drag_start_scroll_x = box->scroll_x;
- bw->drag_start_scroll_y = box->scroll_y;
+ bw->drag_start_scroll_x = scroll_get(box->scroll_x);
+ bw->drag_start_scroll_y = scroll_get(box->scroll_y);
bw->drag_well_width = well_width;
bw->drag_well_height = well_height;
@@ -2190,7 +2190,7 @@
box->padding[LEFT] + box->width < x) {
vert = true;
z = y;
- scroll = box->scroll_y;
+ scroll = scroll_get(box->scroll_y);
well_size = well_height;
bar_start = bar_top;
bar_size = bar_height;
@@ -2198,7 +2198,7 @@
} else {
vert = false;
z = x;
- scroll = box->scroll_x;
+ scroll = scroll_get(box->scroll_x);
well_size = well_width;
bar_start = bar_left;
bar_size = bar_width;
@@ -2270,18 +2270,18 @@
scroll = box->descendant_y0;
else if (box->descendant_y1 - box->height < scroll)
scroll = box->descendant_y1 - box->height;
- if (scroll != box->scroll_y)
- browser_window_scroll_box(bw, box, box->scroll_x,
- scroll);
+ if (scroll != scroll_get(box->scroll_y))
+ browser_window_scroll_box(bw, box,
+ scroll_get(box->scroll_x), scroll);
} else {
if (scroll < box->descendant_x0)
scroll = box->descendant_x0;
else if (box->descendant_x1 - box->width < scroll)
scroll = box->descendant_x1 - box->width;
- if (scroll != box->scroll_x)
+ if (scroll != scroll_get(box->scroll_x))
browser_window_scroll_box(bw, box, scroll,
- box->scroll_y);
+ scroll_get(box->scroll_y));
}
return status;
@@ -2410,8 +2410,8 @@
void browser_window_scroll_box(struct browser_window *bw, struct box *box,
int scroll_x, int scroll_y)
{
- box->scroll_x = scroll_x;
- box->scroll_y = scroll_y;
+ scroll_set(box->scroll_x, scroll_x, false);
+ scroll_set(box->scroll_y, scroll_y, false);
/* fall back to redrawing the whole box */
browser_redraw_box(bw->current_content, box);
@@ -2783,11 +2783,11 @@
while (child) {
if (child->type == BOX_FLOAT_LEFT ||
child->type == BOX_FLOAT_RIGHT) {
- c_bx = fx + child->x - child->scroll_x;
- c_by = fy + child->y - child->scroll_y;
+ c_bx = fx + child->x - scroll_get(child->scroll_x);
+ c_by = fy + child->y - scroll_get(child->scroll_y);
} else {
- c_bx = bx + child->x - child->scroll_x;
- c_by = by + child->y - child->scroll_y;
+ c_bx = bx + child->x - scroll_get(child->scroll_x);
+ c_by = by + child->y - scroll_get(child->scroll_y);
}
if (child->float_children) {
c_fx = c_bx;
Modified: branches/paulblokus/selectscroll/desktop/scroll.c
URL: http://source.netsurf-browser.org/branches/paulblokus/selectscroll/deskto...
==============================================================================
--- branches/paulblokus/selectscroll/desktop/scroll.c (original)
+++ branches/paulblokus/selectscroll/desktop/scroll.c Fri Jul 31 15:10:54 2009
@@ -420,6 +420,8 @@
int scroll_get(struct scroll *scroll)
{
+ if (scroll == NULL)
+ return 0;
return scroll->area_scroll;
}
Modified: branches/paulblokus/selectscroll/desktop/textinput.c
URL: http://source.netsurf-browser.org/branches/paulblokus/selectscroll/deskto...
==============================================================================
--- branches/paulblokus/selectscroll/desktop/textinput.c (original)
+++ branches/paulblokus/selectscroll/desktop/textinput.c Fri Jul 31 15:10:54 2009
@@ -30,6 +30,7 @@
#include "desktop/browser.h"
#include "desktop/gui.h"
+#include "desktop/scroll.h"
#include "desktop/selection.h"
#include "desktop/textinput.h"
#include "render/box.h"
@@ -279,11 +280,11 @@
textarea->gadget->caret_box_offset = char_offset;
textarea->gadget->caret_pixel_offset = pixel_offset;
- box_x += textarea->scroll_x;
- box_y += textarea->scroll_y;
+ box_x += scroll_get(textarea->scroll_x);
+ box_y += scroll_get(textarea->scroll_y);
scrolled = ensure_caret_visible(textarea);
- box_x -= textarea->scroll_x;
- box_y -= textarea->scroll_y;
+ box_x -= scroll_get(textarea->scroll_x);
+ box_y -= scroll_get(textarea->scroll_y);
browser_window_place_caret(bw,
box_x + inline_container->x + text_box->x +
@@ -332,8 +333,8 @@
(int) text_box->length, text_box->text));
box_coords(textarea, &box_x, &box_y);
- box_x -= textarea->scroll_x;
- box_y -= textarea->scroll_y;
+ box_x -= scroll_get(textarea->scroll_x);
+ box_y -= scroll_get(textarea->scroll_y);
if (!(key <= 0x001F || (0x007F <= key && key <= 0x009F))) {
/* normal character insertion */
@@ -756,8 +757,8 @@
assert(text_box);
assert(char_offset <= text_box->length);
/* Scroll back to the left */
- box_x += textarea->scroll_x;
- textarea->scroll_x = 0;
+ box_x += scroll_get(textarea->scroll_x);
+ scroll_set(textarea->scroll_x, 0, false);
} else {
assert(!text_box->next ||
(text_box->next &&
@@ -778,11 +779,11 @@
textarea->gadget->caret_box_offset = char_offset;
textarea->gadget->caret_pixel_offset = pixel_offset;
- box_x += textarea->scroll_x;
- box_y += textarea->scroll_y;
+ box_x += scroll_get(textarea->scroll_x);
+ box_y += scroll_get(textarea->scroll_y);
scrolled = ensure_caret_visible(textarea);
- box_x -= textarea->scroll_x;
- box_y -= textarea->scroll_y;
+ box_x -= scroll_get(textarea->scroll_x);
+ box_y -= scroll_get(textarea->scroll_y);
browser_window_place_caret(bw,
box_x + inline_container->x + text_box->x +
@@ -1398,11 +1399,11 @@
textarea->gadget->caret_pixel_offset = pixel_offset;
box_coords(textarea, &box_x, &box_y);
- box_x += textarea->scroll_x;
- box_y += textarea->scroll_y;
+ box_x += scroll_get(textarea->scroll_x);
+ box_y += scroll_get(textarea->scroll_y);
ensure_caret_visible(textarea);
- box_x -= textarea->scroll_x;
- box_y -= textarea->scroll_y;
+ box_x -= scroll_get(textarea->scroll_x);
+ box_y -= scroll_get(textarea->scroll_y);
browser_window_place_caret(bw,
box_x + inline_container->x + text_box->x +
@@ -1518,8 +1519,8 @@
font_plot_style_from_css(text_box->style, &fstyle);
box_coords(textarea, &box_x, &box_y);
- box_x -= textarea->scroll_x;
- box_y -= textarea->scroll_y;
+ box_x -= scroll_get(textarea->scroll_x);
+ box_y -= scroll_get(textarea->scroll_y);
nsfont.font_width(&fstyle, text_box->text,
char_offset, &pixel_offset);
@@ -2191,8 +2192,8 @@
assert(textarea->gadget);
- scrollx = textarea->scroll_x;
- scrolly = textarea->scroll_y;
+ scrollx = scroll_get(textarea->scroll_x);
+ scrolly = scroll_get(textarea->scroll_y);
/* Calculate the caret coordinates */
cx = textarea->gadget->caret_pixel_offset +
@@ -2202,27 +2203,29 @@
/* Ensure they are visible */
if (!box_hscrollbar_present(textarea)) {
scrollx = 0;
- } else if (cx-textarea->scroll_x < 0) {
+ } else if (cx - scroll_get(textarea->scroll_x) < 0) {
scrollx = cx;
- } else if (cx > textarea->scroll_x + textarea->width) {
+ } else if (cx > scroll_get(textarea->scroll_x) + textarea->width) {
scrollx = cx - textarea->width;
}
if (!box_vscrollbar_present(textarea)) {
scrolly = 0;
- } else if (cy - textarea->scroll_y < 0) {
+ } else if (cy - scroll_get(textarea->scroll_y) < 0) {
scrolly = cy;
} else if (cy + textarea->gadget->caret_text_box->height >
- textarea->scroll_y + textarea->height) {
+ scroll_get(textarea->scroll_y) + textarea->height) {
scrolly = (cy + textarea->gadget->caret_text_box->height) -
textarea->height;
}
- if ((scrollx == textarea->scroll_x) && (scrolly == textarea->scroll_y))
+ if ((scrollx == scroll_get(textarea->scroll_x)) &&
+ (scrolly == scroll_get(textarea->scroll_y)))
return false;
- textarea->scroll_x = scrollx;
- textarea->scroll_y = scrolly;
+
+ scroll_set(textarea->scroll_x, scrollx, false);
+ scroll_set(textarea->scroll_y, scrolly, false);
return true;
}
Modified: branches/paulblokus/selectscroll/render/box.c
URL: http://source.netsurf-browser.org/branches/paulblokus/selectscroll/render...
==============================================================================
--- branches/paulblokus/selectscroll/render/box.c (original)
+++ branches/paulblokus/selectscroll/render/box.c Fri Jul 31 15:10:54 2009
@@ -29,6 +29,7 @@
#include "content/content.h"
#include "css/css.h"
#include "css/dump.h"
+#include "desktop/scroll.h"
#include "desktop/options.h"
#include "render/box.h"
#include "render/form.h"
@@ -226,6 +227,10 @@
if (!box->clone) {
if (box->gadget)
form_free_control(box->gadget);
+ if (box->scroll_x != NULL)
+ scroll_destroy(box->scroll_x);
+ if (box->scroll_y != NULL)
+ scroll_destroy(box->scroll_y);
}
talloc_free(box);
@@ -251,8 +256,8 @@
} while (!box->float_children);
} else
box = box->parent;
- *x += box->x - box->scroll_x;
- *y += box->y - box->scroll_y;
+ *x += box->x - scroll_get(box->scroll_x);
+ *y += box->y - scroll_get(box->scroll_y);
}
}
@@ -328,8 +333,8 @@
/* consider floats second, since they will often overlap other boxes */
for (child = box->float_children; child; child = child->next_float) {
if (box_contains_point(child, x - bx, y - by, &physically)) {
- *box_x = bx + child->x - child->scroll_x;
- *box_y = by + child->y - child->scroll_y;
+ *box_x = bx + child->x - scroll_get(child->scroll_x);
+ *box_y = by + child->y - scroll_get(child->scroll_y);
if (physically)
return child;
@@ -345,8 +350,8 @@
if (box_is_float(child))
continue;
if (box_contains_point(child, x - bx, y - by, &physically)) {
- *box_x = bx + child->x - child->scroll_x;
- *box_y = by + child->y - child->scroll_y;
+ *box_x = bx + child->x - scroll_get(child->scroll_x);
+ *box_y = by + child->y - scroll_get(child->scroll_y);
if (physically)
return child;
@@ -370,16 +375,16 @@
/* siblings and siblings of ancestors */
while (box) {
if (box_is_float(box)) {
- bx -= box->x - box->scroll_x;
- by -= box->y - box->scroll_y;
+ bx -= box->x - scroll_get(box->scroll_x);
+ by -= box->y - scroll_get(box->scroll_y);
for (sibling = box->next_float; sibling;
sibling = sibling->next_float) {
if (box_contains_point(sibling,
x - bx, y - by, &physically)) {
- *box_x = bx + sibling->x -
- sibling->scroll_x;
- *box_y = by + sibling->y -
- sibling->scroll_y;
+ *box_x = bx + sibling->x - scroll_get(
+ sibling->scroll_x);
+ *box_y = by + sibling->y - scroll_get(
+ sibling->scroll_y);
if (physically)
return sibling;
@@ -398,18 +403,18 @@
goto non_float_children;
} else {
- bx -= box->x - box->scroll_x;
- by -= box->y - box->scroll_y;
+ bx -= box->x - scroll_get(box->scroll_x);
+ by -= box->y - scroll_get(box->scroll_y);
for (sibling = box->next; sibling;
sibling = sibling->next) {
if (box_is_float(sibling))
continue;
if (box_contains_point(sibling, x - bx, y - by,
&physically)) {
- *box_x = bx + sibling->x -
- sibling->scroll_x;
- *box_y = by + sibling->y -
- sibling->scroll_y;
+ *box_x = bx + sibling->x - scroll_get(
+ sibling->scroll_x);
+ *box_y = by + sibling->y - scroll_get(
+ sibling->scroll_y);
if (physically)
return sibling;
Modified: branches/paulblokus/selectscroll/render/box.h
URL: http://source.netsurf-browser.org/branches/paulblokus/selectscroll/render...
==============================================================================
--- branches/paulblokus/selectscroll/render/box.h (original)
+++ branches/paulblokus/selectscroll/render/box.h Fri Jul 31 15:10:54 2009
@@ -167,8 +167,8 @@
int padding[4]; /**< Padding: TOP, RIGHT, BOTTOM, LEFT. */
struct box_border border[4]; /**< Border: TOP, RIGHT, BOTTOM, LEFT. */
- int scroll_x; /**< Horizontal scroll of descendants. */
- int scroll_y; /**< Vertical scroll of descendants. */
+ struct scroll *scroll_x; /**< Horizontal scroll. */
+ struct scroll *scroll_y; /**< Vertical scroll. */
/** Width of box taking all line breaks (including margins etc). Must
* be non-negative. */
Modified: branches/paulblokus/selectscroll/render/html_redraw.c
URL: http://source.netsurf-browser.org/branches/paulblokus/selectscroll/render...
==============================================================================
--- branches/paulblokus/selectscroll/render/html_redraw.c (original)
+++ branches/paulblokus/selectscroll/render/html_redraw.c Fri Jul 31 15:10:54 2009
@@ -639,8 +639,8 @@
return false;
if (box->object) {
- x_scrolled = x - box->scroll_x * scale;
- y_scrolled = y - box->scroll_y * scale;
+ x_scrolled = x - scroll_get(box->scroll_x) * scale;
+ y_scrolled = y - scroll_get(box->scroll_y) * scale;
if (!content_redraw(box->object,
x_scrolled + padding_left,
y_scrolled + padding_top,
@@ -681,8 +681,8 @@
/* list marker */
if (box->list_marker)
if (!html_redraw_box(box->list_marker,
- x_parent + box->x - box->scroll_x,
- y_parent + box->y - box->scroll_y,
+ x_parent + box->x - scroll_get(box->scroll_x),
+ y_parent + box->y - scroll_get(box->scroll_y),
clip_x0, clip_y0, clip_x1, clip_y1,
scale, current_background_color))
return false;
@@ -734,16 +734,18 @@
if (c->type != BOX_FLOAT_LEFT && c->type != BOX_FLOAT_RIGHT)
if (!html_redraw_box(c,
- x_parent + box->x - box->scroll_x,
- y_parent + box->y - box->scroll_y,
+ x_parent + box->x -
+ scroll_get(box->scroll_x),
+ y_parent + box->y -
+ scroll_get(box->scroll_y),
clip_x0, clip_y0, clip_x1, clip_y1,
scale, current_background_color))
return false;
}
for (c = box->float_children; c; c = c->next_float)
if (!html_redraw_box(c,
- x_parent + box->x - box->scroll_x,
- y_parent + box->y - box->scroll_y,
+ x_parent + box->x - scroll_get(box->scroll_x),
+ y_parent + box->y - scroll_get(box->scroll_y),
clip_x0, clip_y0, clip_x1, clip_y1,
scale, current_background_color))
return false;
@@ -1984,9 +1986,7 @@
bool box_vscrollbar_present(const struct box * const box)
{
- return box->descendant_y0 < -box->border[TOP].width ||
- box->padding[TOP] + box->height + box->padding[BOTTOM] +
- box->border[BOTTOM].width < box->descendant_y1;
+ return box->scroll_y != NULL;
}
@@ -1999,9 +1999,7 @@
bool box_hscrollbar_present(const struct box * const box)
{
- return box->descendant_x0 < -box->border[LEFT].width ||
- box->padding[LEFT] + box->width + box->padding[RIGHT] +
- box->border[RIGHT].width < box->descendant_x1;
+ return box->scroll_x != NULL;
}
@@ -2036,7 +2034,7 @@
*bar_top = 0;
*bar_height = *well_height;
if (box->descendant_y1 - box->descendant_y0 != 0) {
- *bar_top = (float) *well_height * (float) box->scroll_y /
+ *bar_top = (float) *well_height * (float) scroll_get(box->scroll_y) /
(float) (box->descendant_y1 -
box->descendant_y0);
*bar_height = (float) *well_height * (float) box->height /
@@ -2047,7 +2045,7 @@
*bar_left = 0;
*bar_width = *well_width;
if (box->descendant_x1 - box->descendant_x0 != 0) {
- *bar_left = (float) *well_width * (float) box->scroll_x /
+ *bar_left = (float) *well_width * (float) scroll_get(box->scroll_x) /
(float) (box->descendant_x1 -
box->descendant_x0);
*bar_width = (float) *well_width * (float) box->width /
14 years, 1 month
r8927 MarkieB - in /branches/MarkieB/gtkmain: content/fetchcache.c gtk/dialogs/gtk_options.c
by netsurf@semichrome.net
Author: MarkieB
Date: Fri Jul 31 12:02:42 2009
New Revision: 8927
URL: http://source.netsurf-browser.org?rev=8927&view=rev
Log:
final detail modifications options; needs some debugging
Modified:
branches/MarkieB/gtkmain/content/fetchcache.c
branches/MarkieB/gtkmain/gtk/dialogs/gtk_options.c
Modified: branches/MarkieB/gtkmain/content/fetchcache.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/content/fetchc...
==============================================================================
--- branches/MarkieB/gtkmain/content/fetchcache.c (original)
+++ branches/MarkieB/gtkmain/content/fetchcache.c Fri Jul 31 12:02:42 2009
@@ -772,6 +772,10 @@
/* clear http:// plus trailing / from url, it is already escaped */
temp = strdup(c->url + SLEN("http://"));
+ if (temp == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return;
+ }
temp[strlen(temp)-1] = '\0';
redirurl = search_web_get_url(temp);
Modified: branches/MarkieB/gtkmain/gtk/dialogs/gtk_options.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/gtk/dialogs/gt...
==============================================================================
--- branches/MarkieB/gtkmain/gtk/dialogs/gtk_options.c (original)
+++ branches/MarkieB/gtkmain/gtk/dialogs/gtk_options.c Fri Jul 31 12:02:42 2009
@@ -49,6 +49,7 @@
static void dialog_response_handler (GtkDialog *dlg, gint res_id);
static gboolean on_dialog_close (GtkDialog *dlg, gboolean stay_alive);
+static void nsgtk_options_theme_combo(void);
/* Declares both widget and callback */
#define DECLARE(x) \
@@ -285,7 +286,7 @@
void nsgtk_options_load(void)
{
GtkBox *box;
- gchar *languagefile, *themefile;
+ gchar *languagefile;
const char *default_accept_language =
option_accept_language ? option_accept_language : "en";
int combo_row_count = 0;
@@ -333,32 +334,8 @@
gtk_box_pack_start(box, comboLanguage, FALSE, FALSE, 0);
gtk_widget_show(comboLanguage);
- /* populate theme combo from themelist file */
- box = GTK_BOX(glade_xml_get_widget(gladeFile, "themehbox"));
- combotheme = gtk_combo_box_new_text();
- themefile = g_strconcat(res_dir_location, "themelist", NULL);
- fp = fopen((const char *)themefile, "r");
- g_free(themefile);
- if (fp == NULL) {
- LOG(("Failed opening themes file"));
- warn_user("FileError", (const char *) themefile);
- return;
- }
- while (fgets(buf, sizeof(buf), fp)) {
- /* Ignore blank lines */
- if (buf[0] == '\0')
- continue;
-
- /* Remove trailing \n */
- buf[strlen(buf) - 1] = '\0';
-
- gtk_combo_box_append_text(GTK_COMBO_BOX(combotheme), buf);
- }
- gtk_combo_box_set_active(GTK_COMBO_BOX(combotheme),
- option_current_theme);
- gtk_box_pack_start(box, combotheme, FALSE, TRUE, 0);
- gtk_widget_show(combotheme);
-
+ nsgtk_options_theme_combo();
+
SET_ENTRY(entryHomePageURL,
option_homepage_url ? option_homepage_url : "");
SET_BUTTON(setCurrentPage);
@@ -467,6 +444,41 @@
stay_alive = FALSE;
}
return stay_alive;
+}
+
+static void nsgtk_options_theme_combo(void) {
+/* populate theme combo from themelist file */
+ GtkBox *box = GTK_BOX(glade_xml_get_widget(gladeFile, "themehbox"));
+ char buf[50];
+ combotheme = gtk_combo_box_new_text();
+ size_t len = SLEN("themelist") + strlen(res_dir_location) + 1;
+ char *themefile = malloc(len);
+ if ((themefile == NULL) || (combotheme == NULL) || (box == NULL)) {
+ warn_user(messages_get("NoMemory"), 0);
+ return;
+ }
+ snprintf(themefile, len, "%sthemelist", res_dir_location);
+ FILE *fp = fopen((const char *)themefile, "r");
+ free(themefile);
+ if (fp == NULL) {
+ LOG(("Failed opening themes file"));
+ warn_user("FileError", (const char *) themefile);
+ return;
+ }
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ /* Ignore blank lines */
+ if (buf[0] == '\0')
+ continue;
+
+ /* Remove trailing \n */
+ buf[strlen(buf) - 1] = '\0';
+
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combotheme), buf);
+ }
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combotheme),
+ option_current_theme);
+ gtk_box_pack_start(box, combotheme, FALSE, TRUE, 0);
+ gtk_widget_show(combotheme);
}
bool nsgtk_options_combo_theme_add(const char *themename)
@@ -779,6 +791,10 @@
gui_window_set_search_ico();
/* set entry */
name = search_web_provider_name();
+ if (name == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ continue;
+ }
while (current) {
nsgtk_scaffolding_set_websearch(current, name);
current = nsgtk_scaffolding_iterate(current);
@@ -788,11 +804,18 @@
COMBO_CHANGED(combotheme, option_current_theme)
nsgtk_scaffolding *current = scaf_list;
+ char *name;
if (option_current_theme != 0) {
if (nsgtk_theme_name() != NULL)
free(nsgtk_theme_name());
- nsgtk_theme_set_name(strdup(gtk_combo_box_get_active_text(
- GTK_COMBO_BOX(combotheme))));
+ name = strdup(gtk_combo_box_get_active_text(
+ GTK_COMBO_BOX(combotheme)));
+ if (name == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ continue;
+ }
+ nsgtk_theme_set_name(name);
+ free(name);
nsgtk_theme_prepare();
} else if (nsgtk_theme_name() != NULL) {
free(nsgtk_theme_name());
@@ -806,13 +829,21 @@
BUTTON_CLICKED(buttonaddtheme)
char *themesfolder, *filename, *directory;
+ size_t len;
GtkWidget *fc = gtk_file_chooser_dialog_new(
messages_get("gtkAddThemeTitle"),
GTK_WINDOW(wndPreferences),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
- themesfolder = g_strconcat(res_dir_location, "themes", NULL);
+ len = SLEN("themes") + strlen(res_dir_location) + 1;
+ themesfolder = malloc(len);
+ if (themesfolder == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ gtk_widget_destroy(fc);
+ continue;
+ }
+ snprintf(themesfolder, len, "%sthemes", res_dir_location);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc),
themesfolder);
gint res = gtk_dialog_run(GTK_DIALOG(fc));
14 years, 1 month
r8926 MarkieB - in /branches/MarkieB/gtkmain: content/ desktop/ gtk/ gtk/dialogs/ image/ render/ riscos/ utils/
by netsurf@semichrome.net
Author: MarkieB
Date: Fri Jul 31 11:28:39 2009
New Revision: 8926
URL: http://source.netsurf-browser.org?rev=8926&view=rev
Log:
nearly there searchweb; utils; save; various tidying up
Modified:
branches/MarkieB/gtkmain/content/fetchcache.c
branches/MarkieB/gtkmain/desktop/browser.c
branches/MarkieB/gtkmain/desktop/browser.h
branches/MarkieB/gtkmain/desktop/save_complete.c
branches/MarkieB/gtkmain/desktop/save_complete.h
branches/MarkieB/gtkmain/desktop/search.h
branches/MarkieB/gtkmain/desktop/searchweb.c
branches/MarkieB/gtkmain/gtk/dialogs/gtk_options.h
branches/MarkieB/gtkmain/gtk/gtk_scaffolding.c
branches/MarkieB/gtkmain/gtk/gtk_search.c
branches/MarkieB/gtkmain/gtk/gtk_window.c
branches/MarkieB/gtkmain/image/ico.c
branches/MarkieB/gtkmain/render/html.h
branches/MarkieB/gtkmain/render/html_redraw.c
branches/MarkieB/gtkmain/render/textplain.c
branches/MarkieB/gtkmain/riscos/save.c
branches/MarkieB/gtkmain/riscos/searchweb.c
branches/MarkieB/gtkmain/utils/container.c
branches/MarkieB/gtkmain/utils/utils.c
Modified: branches/MarkieB/gtkmain/content/fetchcache.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/content/fetchc...
==============================================================================
--- branches/MarkieB/gtkmain/content/fetchcache.c (original)
+++ branches/MarkieB/gtkmain/content/fetchcache.c Fri Jul 31 11:28:39 2009
@@ -728,24 +728,26 @@
* \param error message to display
*/
-void fetchcache_error_page(struct content *c, const char
- *error)
+void fetchcache_error_page(struct content *c, const char *error)
{
const char *params[] = { 0 };
int length;
char *host;
char checkmessage[24];
+ checkmessage[0] = '\0';
if (option_search_url_bar)
/* get the start of the error message for comparison
* the potential error message we're identifying is derived
* directly from libcurl, so hopefully no need for I18n */
snprintf(checkmessage, 24, "%s", error);
- if (((url_host(c->url, &host) != URL_FUNC_OK) || (strcasecmp(host,
- search_web_provider_host())!= 0)) &&
+ if (url_host(c->url, &host) != URL_FUNC_OK) {
+ warn_user(messages_get("NoMemory"), 0);
+ } else if ((strcasecmp(host, search_web_provider_host())!= 0) &&
(strcasecmp(checkmessage, "couldn't resolve host '")
== 0)) {
fetchcache_search_redirect(c, error);
+ free(host);
return;
}
if ((length = snprintf(error_page, sizeof(error_page),
Modified: branches/MarkieB/gtkmain/desktop/browser.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/desktop/browse...
==============================================================================
--- branches/MarkieB/gtkmain/desktop/browser.c (original)
+++ branches/MarkieB/gtkmain/desktop/browser.c Fri Jul 31 11:28:39 2009
@@ -171,6 +171,10 @@
else {
LOG(("creating blank content"));
struct content *c = content_create(" ");
+ if (c == NULL) {
+ LOG(("error creating blank content"));
+ return NULL;
+ }
const char *params[] = { 0 };
int length;
const char *blankcontent = "<html><head><title>blank page \
Modified: branches/MarkieB/gtkmain/desktop/browser.h
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/desktop/browse...
==============================================================================
--- branches/MarkieB/gtkmain/desktop/browser.h (original)
+++ branches/MarkieB/gtkmain/desktop/browser.h Fri Jul 31 11:28:39 2009
@@ -213,7 +213,6 @@
extern struct browser_window *current_redraw_browser;
-extern struct browser_window *search_current_window;
extern bool browser_reformat_pending;
struct browser_window * browser_window_create(const char *url,
Modified: branches/MarkieB/gtkmain/desktop/save_complete.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/desktop/save_c...
==============================================================================
--- branches/MarkieB/gtkmain/desktop/save_complete.c (original)
+++ branches/MarkieB/gtkmain/desktop/save_complete.c Fri Jul 31 11:28:39 2009
@@ -50,12 +50,6 @@
struct save_complete_entry *next; /**< Next entry in list */
};
-#ifdef RISCOS
- static char pathsep = '.';
-#else
- static char pathsep = '/';
-#endif
-
/** List of urls seen and saved so far. */
static struct save_complete_entry *save_complete_list = 0;
@@ -72,6 +66,12 @@
static bool save_complete_list_check(struct content *content);
/* static void save_complete_list_dump(void); */
static bool save_complete_inventory(const char *path);
+
+#ifdef RISCOS
+ static char pathsep = '.';
+#else
+ static char pathsep = '/';
+#endif
/**
* Save an HTML page with all dependencies.
Modified: branches/MarkieB/gtkmain/desktop/save_complete.h
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/desktop/save_c...
==============================================================================
--- branches/MarkieB/gtkmain/desktop/save_complete.h (original)
+++ branches/MarkieB/gtkmain/desktop/save_complete.h Fri Jul 31 11:28:39 2009
@@ -42,7 +42,8 @@
* \param type integer filetype [riscos]
* \return true for success
*/
-bool save_complete_gui_save(const char *path, const char *filename, struct content *c, int len, char *sourcedata, int type);
+bool save_complete_gui_save(const char *path, const char *filename,
+ struct content *c, int len, char *sourcedata, int type);
/**
* wrapper for lib function htmlSaveFileFormat
Modified: branches/MarkieB/gtkmain/desktop/search.h
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/desktop/search...
==============================================================================
--- branches/MarkieB/gtkmain/desktop/search.h (original)
+++ branches/MarkieB/gtkmain/desktop/search.h Fri Jul 31 11:28:39 2009
@@ -26,6 +26,7 @@
extern char *recent_search[RECENT_SEARCHES];
extern bool search_insert;
+extern struct browser_window *search_current_window;
void start_search(bool forwards);
Modified: branches/MarkieB/gtkmain/desktop/searchweb.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/desktop/search...
==============================================================================
--- branches/MarkieB/gtkmain/desktop/searchweb.c (original)
+++ branches/MarkieB/gtkmain/desktop/searchweb.c Fri Jul 31 11:28:39 2009
@@ -37,15 +37,20 @@
#include "utils/utils.h"
static struct search_provider {
- char *name;
- char *hostname;
- char *searchstring;
- char *ico;
+ char *name; /**< readable name such as 'google', 'yahoo', etc */
+ char *hostname; /**< host address such as www.google.com */
+ char *searchstring; /** < such as "www.google.com?search=%s" */
+ char *ico; /** < location of domain's favicon */
} current_search_provider;
struct content *search_ico = NULL;
char *search_engines_file_location;
char *search_default_ico_location;
+
+/**
+ * creates a new browser window according to the search term
+ * \param searchterm such as "my search term"
+ */
bool search_web_new_window(struct browser_window *bw, const char *searchterm)
{
@@ -55,12 +60,16 @@
URL_FUNC_OK)
return false;
url = search_web_get_url(encsearchterm);
- browser_window_create(url, bw, NULL,
- false, true);
+ free(encsearchterm);
+ browser_window_create(url, bw, NULL, false, true);
free(url);
return true;
}
+/** simplistic way of checking whether an entry from the url bar is an
+ * url / a search; could be improved to properly test terms
+ */
+
bool search_is_url(const char *url)
{
char *url2, *host;
@@ -73,6 +82,7 @@
return true;
}
+
/**
* caches the details of the current web search provider
* \param reference the enum value of the provider
@@ -83,65 +93,79 @@
void search_web_provider_details(int reference)
{
char buf[300];
- char delim[2];
int ref = 0;
if (search_engines_file_location == NULL)
return;
FILE *f = fopen(search_engines_file_location, "r");
if (f == NULL)
return;
- while (fgets(buf, sizeof(buf), f)) {
+ while (fgets(buf, sizeof(buf), f) != NULL) {
if (buf[0] == '\0')
continue;
buf[strlen(buf)-1] = '\0';
if (ref++ == reference)
break;
}
- strcpy(delim, "|");
- if (current_search_provider.name)
+ if (current_search_provider.name != NULL)
free(current_search_provider.name);
- current_search_provider.name = strdup(strtok(buf, delim));
- if (current_search_provider.hostname)
+ current_search_provider.name = strdup(strtok(buf, "|"));
+ if (current_search_provider.hostname != NULL)
free(current_search_provider.hostname);
- current_search_provider.hostname = strdup(strtok(NULL, delim));
- if (current_search_provider.searchstring)
+ current_search_provider.hostname = strdup(strtok(NULL, "|"));
+ if (current_search_provider.searchstring != NULL)
free(current_search_provider.searchstring);
- current_search_provider.searchstring = strdup(strtok(NULL, delim));
- if (current_search_provider.ico)
+ current_search_provider.searchstring = strdup(strtok(NULL, "|"));
+ if (current_search_provider.ico != NULL)
free(current_search_provider.ico);
- current_search_provider.ico = strdup(strtok(NULL, delim));
+ current_search_provider.ico = strdup(strtok(NULL, "|"));
return;
}
+/**
+ * escapes a search term then creates the appropriate url from it
+ */
+
char *search_web_from_term(const char *searchterm)
{
- char *encsearchterm;
+ char *encsearchterm, *url;
if (url_escape(searchterm, 0, true, NULL, &encsearchterm)
!= URL_FUNC_OK)
return strdup(searchterm);
- return search_web_get_url(encsearchterm);
-}
-
-char *search_web_provider_name()
+ url = search_web_get_url(encsearchterm);
+ free(encsearchterm);
+ return url;
+}
+
+/** accessor for global search provider name */
+
+char *search_web_provider_name(void)
{
if (current_search_provider.name)
return strdup(current_search_provider.name);
return strdup("google");
}
-char *search_web_provider_host()
+/** accessor for global search provider hostname */
+
+char *search_web_provider_host(void)
{
if (current_search_provider.hostname)
return strdup(current_search_provider.hostname);
return strdup("www.google.com");
}
-char *search_web_ico_name()
+/** accessor for global search provider ico name */
+
+char *search_web_ico_name(void)
{
if (current_search_provider.ico)
return strdup(current_search_provider.ico);
return strdup("http://www.google.com/favicon.ico");
}
+
+/**
+ * creates a full url from an encoded search term
+ */
char *search_web_get_url(const char *encsearchterm)
{
@@ -151,12 +175,28 @@
pref = strdup(current_search_provider.searchstring);
else
pref = strdup("http://www.google.com/search?q=%s");
+ if (pref == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
len = strlen(encsearchterm) + strlen(pref);
- ret = malloc(len -1);
+ ret = malloc(len -1); /* + '\0' - "%s" */
+ if (ret == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
snprintf(ret, len-1, pref, encsearchterm);
free(pref);
return ret;
}
+
+/**
+ * function to retrieve the search web ico, from cache / from local
+ * filesystem / from the web
+ * \param localdefault true when there is no appropriate favicon
+ * \return a favicon when one is accessible directly [such as cache]
+ * else delay until fetcher callback
+ */
struct content *search_web_retrieve_ico(bool localdefault)
{
@@ -166,6 +206,10 @@
return NULL;
url = malloc(SLEN("file://") + strlen(
search_default_ico_location) + 1);
+ if (url == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
strcpy(url, "file://");
strcat(url, search_default_ico_location);
} else {
@@ -173,8 +217,11 @@
}
struct content *icocontent = NULL;
- if (url != NULL)
- icocontent = fetchcache(url, search_web_ico_callback,
+ if (url == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
+ icocontent = fetchcache(url, search_web_ico_callback,
0, 0, 20, 20, true, 0,
0, false, false);
free(url);
@@ -185,12 +232,16 @@
0, 0, 20, 20,
0, 0, false, 0);
- if (icocontent == NULL) {
+ if (icocontent == NULL)
LOG(("web search ico loading delayed"));
- return NULL;
- }
+
return icocontent;
}
+
+/**
+ * callback function to cache ico then notify front when successful
+ * else retry default from local file system
+ */
void search_web_ico_callback(content_msg msg, struct content *ico,
intptr_t p1, intptr_t p2, union content_msg_data data)
Modified: branches/MarkieB/gtkmain/gtk/dialogs/gtk_options.h
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/gtk/dialogs/gt...
==============================================================================
--- branches/MarkieB/gtkmain/gtk/dialogs/gtk_options.h (original)
+++ branches/MarkieB/gtkmain/gtk/dialogs/gtk_options.h Fri Jul 31 11:28:39 2009
@@ -24,9 +24,11 @@
extern GtkDialog *wndPreferences;
-GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent); /** Init options and load window */
+GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent);
+ /** Init options and load window */
void nsgtk_options_load(void); /** Load current options into window */
void nsgtk_options_save(void); /** Save options from window */
-bool nsgtk_options_combo_theme_add(const char *themename); /** add new theme name to combo */
+bool nsgtk_options_combo_theme_add(const char *themename);
+ /** add new theme name to combo */
#endif
Modified: branches/MarkieB/gtkmain/gtk/gtk_scaffolding.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/gtk/gtk_scaffo...
==============================================================================
--- branches/MarkieB/gtkmain/gtk/gtk_scaffolding.c (original)
+++ branches/MarkieB/gtkmain/gtk/gtk_scaffolding.c Fri Jul 31 11:28:39 2009
@@ -223,12 +223,15 @@
nsgtk_tab_close_current(g->notebook);
}
LOG(("Being Destroyed = %d", g->being_destroyed));
+
+ /* code looks as though it segfaults; is it really necessary? */
/* if ((g->history_window) && (g->history_window->window)) {
gtk_widget_destroy(GTK_WIDGET(g->history_window->window));
}
if (g->window)
gtk_widget_destroy(GTK_WIDGET(g->window));
*/
+
if (--open_windows == 0)
netsurf_quit = true;
@@ -236,12 +239,12 @@
g->being_destroyed = 1;
nsgtk_window_destroy_browser(g->top_level);
}
- if (g->prev)
+ if (g->prev != NULL)
g->prev->next = g->next;
else
scaf_list = g->next;
- if (g->next)
+ if (g->next != NULL)
g->next->prev = g->prev;
}
@@ -325,11 +328,16 @@
{
struct gtk_scaffolding *g = data;
struct browser_window *bw = gui_window_get_browser_window(g->top_level);
- char *url = (char *)gtk_entry_get_text(GTK_ENTRY(g->url_bar));
- if (!search_is_url(url))
- url = search_web_from_term(url);
+ char *url;
+ if (search_is_url(gtk_entry_get_text(GTK_ENTRY(g->url_bar)))
+ == false)
+ url = search_web_from_term(gtk_entry_get_text(GTK_ENTRY(
+ g->url_bar)));
+ else
+ url = strdup(gtk_entry_get_text(GTK_ENTRY(g->url_bar)));
browser_window_go(bw, url, 0, true);
-
+ if (url != NULL)
+ free(url);
return TRUE;
}
Modified: branches/MarkieB/gtkmain/gtk/gtk_search.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/gtk/gtk_search...
==============================================================================
--- branches/MarkieB/gtkmain/gtk/gtk_search.c (original)
+++ branches/MarkieB/gtkmain/gtk/gtk_search.c Fri Jul 31 11:28:39 2009
@@ -18,7 +18,7 @@
/** \file
- * Free text search (implementation)
+ * Free text search (front component)
*/
#include <ctype.h>
#include <string.h>
@@ -42,6 +42,8 @@
void nsgtk_search_init(struct gtk_scaffolding *g);
+/** connected to the search forward button */
+
gboolean nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data)
{
struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
@@ -50,6 +52,8 @@
return TRUE;
}
+/** connected to the search back button */
+
gboolean nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data)
{
struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
@@ -57,6 +61,8 @@
start_search(false);
return TRUE;
}
+
+/** preparatory code when the search bar is made visible initially */
void nsgtk_search_init(struct gtk_scaffolding *g)
{
@@ -76,6 +82,8 @@
search_insert = true;
}
+/** connected to the search close button */
+
gboolean nsgtk_search_close_button_clicked(GtkWidget *widget, gpointer data)
{
struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
@@ -83,12 +91,16 @@
return TRUE;
}
+/** connected to the search entry [typing] */
+
gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data)
{
gui_search_set_forward_state(true);
gui_search_set_back_state(true);
return TRUE;
}
+
+/** connected to the search entry [return key] */
gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data)
{
@@ -97,6 +109,8 @@
start_search(true);
return FALSE;
}
+
+/** allows escape key to close search bar too */
gboolean nsgtk_search_entry_key(GtkWidget *widget, GdkEventKey *event,
gpointer data)
@@ -107,6 +121,8 @@
}
return FALSE;
}
+
+/** connected to the websearch entry [return key] */
gboolean nsgtk_websearch_activate(GtkWidget *widget, gpointer data)
{
@@ -120,6 +136,11 @@
return TRUE;
}
+/**
+ * allows a click in the websearch entry field to clear the name of the
+ * provider
+ */
+
gboolean nsgtk_websearch_clear(GtkWidget *widget, GdkEventFocus *f,
gpointer data)
{
Modified: branches/MarkieB/gtkmain/gtk/gtk_window.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/gtk/gtk_window...
==============================================================================
--- branches/MarkieB/gtkmain/gtk/gtk_window.c (original)
+++ branches/MarkieB/gtkmain/gtk/gtk_window.c Fri Jul 31 11:28:39 2009
@@ -61,13 +61,13 @@
GtkViewport *viewport;
GtkFixed *fixed;
GtkDrawingArea *drawing_area;
- gulong signalhandler[2];
-
+ gulong signalhandler[2]; /* window clicks /
+ repaints */
/* Keep gui_windows in a list for cleanup later */
struct gui_window *next, *prev;
};
-struct gui_window *window_list = 0; /**< first entry in win list*/
+struct gui_window *window_list = NULL; /**< first entry in win list*/
int temp_open_background = -1;
Modified: branches/MarkieB/gtkmain/image/ico.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/image/ico.c?re...
==============================================================================
--- branches/MarkieB/gtkmain/image/ico.c (original)
+++ branches/MarkieB/gtkmain/image/ico.c Fri Jul 31 11:28:39 2009
@@ -114,12 +114,15 @@
background_colour, BITMAPF_NONE);
}
+/** sets the bitmap for an ico according to the dimensions */
+
bool nsico_set_bitmap_from_size(struct content *c, int width, int height)
{
struct bmp_image *bmp = ico_find(c->data.ico.ico, width, height);
- if (!bmp->decoded)
- if (bmp_decode(bmp) != BMP_OK)
- return false;
+ if (bmp == NULL)
+ return false;
+ if ((bmp->decoded == false) && (bmp_decode(bmp) != BMP_OK))
+ return false;
c->bitmap = bmp->bitmap;
return true;
}
Modified: branches/MarkieB/gtkmain/render/html.h
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/render/html.h?...
==============================================================================
--- branches/MarkieB/gtkmain/render/html.h (original)
+++ branches/MarkieB/gtkmain/render/html.h Fri Jul 31 11:28:39 2009
@@ -128,7 +128,7 @@
colour background_colour; /**< Document background colour. */
const struct font_functions *font_func;
- struct content *favicon;
+ struct content *favicon; /**< the favicon for the page */
/** Number of entries in stylesheet_content. */
unsigned int stylesheet_count;
Modified: branches/MarkieB/gtkmain/render/html_redraw.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/render/html_re...
==============================================================================
--- branches/MarkieB/gtkmain/render/html_redraw.c (original)
+++ branches/MarkieB/gtkmain/render/html_redraw.c Fri Jul 31 11:28:39 2009
@@ -39,6 +39,7 @@
#include "desktop/textinput.h"
#include "desktop/options.h"
#include "desktop/print.h"
+#include "desktop/search.h"
#include "image/bitmap.h"
#include "render/box.h"
#include "render/font.h"
Modified: branches/MarkieB/gtkmain/render/textplain.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/render/textpla...
==============================================================================
--- branches/MarkieB/gtkmain/render/textplain.c (original)
+++ branches/MarkieB/gtkmain/render/textplain.c Fri Jul 31 11:28:39 2009
@@ -32,6 +32,7 @@
#include "css/css.h"
#include "desktop/gui.h"
#include "desktop/plotters.h"
+#include "desktop/search.h"
#include "desktop/selection.h"
#include "render/box.h"
#include "render/font.h"
Modified: branches/MarkieB/gtkmain/riscos/save.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/riscos/save.c?...
==============================================================================
--- branches/MarkieB/gtkmain/riscos/save.c (original)
+++ branches/MarkieB/gtkmain/riscos/save.c Fri Jul 31 11:28:39 2009
@@ -992,7 +992,7 @@
char *finame;
int namelen = strlen(path) + strlen(filename) + 2;
finame = malloc(namelen);
- if (!finame) {
+ if (finame == NULL) {
warn_user("NoMemory", 0);
return false;
}
@@ -1018,7 +1018,7 @@
int ret;
int len = strlen(path) + strlen(filename) + 2;
char *finame = malloc(len);
- if (!finame){
+ if (finame == NULL){
warn_user("NoMemory", 0);
return -1;
}
@@ -1033,7 +1033,7 @@
os_error *error;
int len = strlen(path) + strlen(filename) + 2;
char *finame = malloc(len);
- if (!finame){
+ if (finame == NULL){
warn_user("NoMemory", 0);
return -1;
}
Modified: branches/MarkieB/gtkmain/riscos/searchweb.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/riscos/searchw...
==============================================================================
--- branches/MarkieB/gtkmain/riscos/searchweb.c (original)
+++ branches/MarkieB/gtkmain/riscos/searchweb.c Fri Jul 31 11:28:39 2009
@@ -16,8 +16,3 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <string.h>
-#include "content/content.h"
-#include "desktop/searchweb.h"
-
-struct content *search_ico;
Modified: branches/MarkieB/gtkmain/utils/container.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/utils/containe...
==============================================================================
--- branches/MarkieB/gtkmain/utils/container.c (original)
+++ branches/MarkieB/gtkmain/utils/container.c Fri Jul 31 11:28:39 2009
@@ -39,6 +39,7 @@
#include "utils/config.h"
#include "utils/container.h"
#include "utils/log.h"
+#include "utils/messages.h"
#include "utils/utils.h"
#ifdef WITH_MMAP
#include <sys/mman.h>
@@ -108,7 +109,7 @@
if (ctx->fh == NULL) {
free(ctx);
- return NULL;
+ return NULL;
}
/* we don't actually load any of the data (including directory)
@@ -399,6 +400,10 @@
LOG(("theme author: %s", container_get_author(cctx)));
dirname = malloc(strlen(dirbasename) + strlen(themename) + 2);
+ if (dirname == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
strcpy(dirname, dirbasename);
strcat(dirname, themename);
if (stat(dirname, &statbuf) != -1) {
Modified: branches/MarkieB/gtkmain/utils/utils.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/utils/utils.c?...
==============================================================================
--- branches/MarkieB/gtkmain/utils/utils.c (original)
+++ branches/MarkieB/gtkmain/utils/utils.c Fri Jul 31 11:28:39 2009
@@ -61,6 +61,11 @@
return 1;
}
+/**
+ * returns a string without its underscores
+ * \param replacespace true to insert a space where there was an underscore
+ */
+
char *remove_underscores(const char *s, bool replacespace)
{
size_t i, len, offset = 0;
14 years, 1 month
r8925 MarkieB - in /branches/MarkieB/gtkmain: gtk/gtk_menu.c gtk/gtk_theme.c gtk/gtk_toolbar.c utils/utils.c
by netsurf@semichrome.net
Author: MarkieB
Date: Fri Jul 31 09:27:24 2009
New Revision: 8925
URL: http://source.netsurf-browser.org?rev=8925&view=rev
Log:
arranging the details more theme; toolbar; menu
Modified:
branches/MarkieB/gtkmain/gtk/gtk_menu.c
branches/MarkieB/gtkmain/gtk/gtk_theme.c
branches/MarkieB/gtkmain/gtk/gtk_toolbar.c
branches/MarkieB/gtkmain/utils/utils.c
Modified: branches/MarkieB/gtkmain/gtk/gtk_menu.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/gtk/gtk_menu.c...
==============================================================================
--- branches/MarkieB/gtkmain/gtk/gtk_menu.c (original)
+++ branches/MarkieB/gtkmain/gtk/gtk_menu.c Fri Jul 31 09:27:24 2009
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include "gtk/gtk_menu.h"
#include "utils/messages.h"
+#include "utils/utils.h"
static struct nsgtk_export_submenu *nsgtk_menu_export_submenu(GtkAccelGroup *);
static struct nsgtk_scaleview_submenu *nsgtk_menu_scaleview_submenu(
@@ -31,17 +32,18 @@
static struct nsgtk_debugging_submenu *nsgtk_menu_debugging_submenu(
GtkAccelGroup *);
-static unsigned int key;
-static GdkModifierType mod;
+static unsigned int key; /** to accept parsed key values */
+static GdkModifierType mod; /** to accept parsed modifier values */
#define IMAGE_ITEM(p, q, r)\
ret->q##_menuitem = GTK_IMAGE_MENU_ITEM(\
gtk_image_menu_item_new_with_mnemonic(\
messages_get(#r)));\
gtk_accelerator_parse(messages_get(#r "Accel"), &key, &mod);\
- if (key > 0)\
+ if ((key > 0) && (ret->q##_menuitem != NULL))\
gtk_widget_add_accelerator(GTK_WIDGET(ret->q##_menuitem),\
- "activate", group, key, mod, GTK_ACCEL_VISIBLE);\
+ "activate", group, key, mod,\
+ GTK_ACCEL_VISIBLE);\
gtk_menu_shell_append(GTK_MENU_SHELL(ret->p##_menu),\
GTK_WIDGET(ret->q##_menuitem));\
gtk_widget_show(GTK_WIDGET(ret->q##_menuitem))
@@ -55,17 +57,31 @@
#define SET_SUBMENU(q)\
ret->q##_submenu = nsgtk_menu_##q##_submenu(group);\
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(ret->q##_menuitem),\
- GTK_WIDGET(ret->q##_submenu->q##_menu))
+ if (ret->q##_submenu != NULL)\
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(ret->q##_menuitem),\
+ GTK_WIDGET(ret->q##_submenu->q##_menu))
#define ADD_SEP(q)\
w = gtk_separator_menu_item_new();\
gtk_menu_shell_append(GTK_MENU_SHELL(ret->q##_menu), w);\
gtk_widget_show(w)
+
+/**
+ * creates the a file menu
+ * \param group the 'global' in a gtk sense accelerator reference
+ */
struct nsgtk_file_menu *nsgtk_menu_file_menu(GtkAccelGroup *group)
{
GtkWidget *w;
struct nsgtk_file_menu *ret = malloc(sizeof(struct nsgtk_file_menu));
+ if (ret == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
ret->file_menu = GTK_MENU(gtk_menu_new());
+ if (ret->file_menu == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
IMAGE_ITEM(file, newwindow, gtkNewWindow);
IMAGE_ITEM(file, newtab, gtkNewTab);
IMAGE_ITEM(file, openfile, gtkOpenFile);
@@ -82,11 +98,24 @@
return ret;
}
+/**
+* creates an edit menu
+* \param group the 'global' in a gtk sense accelerator reference
+*/
+
struct nsgtk_edit_menu *nsgtk_menu_edit_menu(GtkAccelGroup *group)
{
GtkWidget *w;
struct nsgtk_edit_menu *ret = malloc(sizeof(struct nsgtk_edit_menu));
+ if (ret == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
ret->edit_menu = GTK_MENU(gtk_menu_new());
+ if (ret->edit_menu == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
IMAGE_ITEM(edit, cut, gtkCut);
IMAGE_ITEM(edit, copy, gtkCopy);
IMAGE_ITEM(edit, paste, gtkPaste);
@@ -100,11 +129,24 @@
return ret;
}
+/**
+* creates a view menu
+* \param group the 'global' in a gtk sense accelerator reference
+*/
+
struct nsgtk_view_menu *nsgtk_menu_view_menu(GtkAccelGroup *group)
{
GtkWidget *w;
struct nsgtk_view_menu *ret = malloc(sizeof(struct nsgtk_view_menu));
+ if (ret == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
ret->view_menu = GTK_MENU(gtk_menu_new());
+ if (ret->view_menu == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
IMAGE_ITEM(view, stop, gtkStop);
IMAGE_ITEM(view, reload, gtkReload);
ADD_SEP(view);
@@ -125,11 +167,24 @@
return ret;
}
+/**
+* creates a nav menu
+* \param group the 'global' in a gtk sense accelerator reference
+*/
+
struct nsgtk_nav_menu *nsgtk_menu_nav_menu(GtkAccelGroup *group)
{
GtkWidget *w;
struct nsgtk_nav_menu *ret = malloc(sizeof(struct nsgtk_nav_menu));
+ if (ret == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
ret->nav_menu = GTK_MENU(gtk_menu_new());
+ if (ret->nav_menu == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
IMAGE_ITEM(nav, back, gtkBack);
IMAGE_ITEM(nav, forward, gtkForward);
IMAGE_ITEM(nav, home, gtkHome);
@@ -144,21 +199,47 @@
return ret;
}
+/**
+* creates a tabs menu
+* \param group the 'global' in a gtk sense accelerator reference
+*/
+
struct nsgtk_tabs_menu *nsgtk_menu_tabs_menu(GtkAccelGroup *group)
{
struct nsgtk_tabs_menu *ret = malloc(sizeof(struct nsgtk_tabs_menu));
+ if (ret == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
ret->tabs_menu = GTK_MENU(gtk_menu_new());
+ if (ret->tabs_menu == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
IMAGE_ITEM(tabs, nexttab, gtkNextTab);
IMAGE_ITEM(tabs, prevtab, gtkPrevTab);
IMAGE_ITEM(tabs, closetab, gtkCloseTab);
return ret;
}
+/**
+* creates a help menu
+* \param group the 'global' in a gtk sense accelerator reference
+*/
+
struct nsgtk_help_menu *nsgtk_menu_help_menu(GtkAccelGroup *group)
{
GtkWidget *w;
struct nsgtk_help_menu *ret = malloc(sizeof(struct nsgtk_help_menu));
+ if (ret == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
ret->help_menu = GTK_MENU(gtk_menu_new());
+ if (ret->help_menu == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
IMAGE_ITEM(help, contents, gtkContents);
IMAGE_ITEM(help, guide, gtkGuide);
IMAGE_ITEM(help, info, gtkUserInformation);
@@ -167,11 +248,24 @@
return ret;
}
+/**
+* creates an export submenu
+* \param group the 'global' in a gtk sense accelerator reference
+*/
+
struct nsgtk_export_submenu *nsgtk_menu_export_submenu(GtkAccelGroup *group)
{
struct nsgtk_export_submenu *ret = malloc(sizeof(struct
nsgtk_export_submenu));
+ if (ret == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
ret->export_menu = GTK_MENU(gtk_menu_new());
+ if (ret->export_menu == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
IMAGE_ITEM(export, plaintext, gtkPlainText);
IMAGE_ITEM(export, drawfile, gtkDrawFile);
IMAGE_ITEM(export, postscript, gtkPostScript);
@@ -179,45 +273,104 @@
return ret;
}
-struct nsgtk_scaleview_submenu *nsgtk_menu_scaleview_submenu(GtkAccelGroup
- *group)
-{
- struct nsgtk_scaleview_submenu *ret = malloc(sizeof(struct
- nsgtk_scaleview_submenu));
+/**
+* creates a scaleview submenu
+* \param group the 'global' in a gtk sense accelerator reference
+*/
+
+struct nsgtk_scaleview_submenu *nsgtk_menu_scaleview_submenu(
+ GtkAccelGroup *group)
+{
+ struct nsgtk_scaleview_submenu *ret =
+ malloc(sizeof(struct nsgtk_scaleview_submenu));
+ if (ret == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
ret->scaleview_menu = GTK_MENU(gtk_menu_new());
+ if (ret->scaleview_menu == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
IMAGE_ITEM(scaleview, zoomplus, gtkZoomPlus);
IMAGE_ITEM(scaleview, zoomnormal, gtkZoomNormal);
IMAGE_ITEM(scaleview, zoomminus, gtkZoomMinus);
return ret;
}
+
+/**
+* creates an images submenu
+* \param group the 'global' in a gtk sense accelerator reference
+*/
+
struct nsgtk_images_submenu *nsgtk_menu_images_submenu(GtkAccelGroup *group)
{
- struct nsgtk_images_submenu *ret = malloc(sizeof(struct
- nsgtk_images_submenu));
+ struct nsgtk_images_submenu *ret =
+ malloc(sizeof(struct nsgtk_images_submenu));
+ if (ret == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
ret->images_menu = GTK_MENU(gtk_menu_new());
+ if (ret->images_menu == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
CHECK_ITEM(images, foregroundimages, gtkForegroundImages);
CHECK_ITEM(images, backgroundimages, gtkBackgroundImages);
return ret;
}
-struct nsgtk_toolbars_submenu *nsgtk_menu_toolbars_submenu(GtkAccelGroup *group)
-{
- struct nsgtk_toolbars_submenu *ret = malloc(sizeof(struct
- nsgtk_toolbars_submenu));
+
+/**
+* creates a toolbars submenu
+* \param group the 'global' in a gtk sense accelerator reference
+*/
+
+struct nsgtk_toolbars_submenu *nsgtk_menu_toolbars_submenu(
+ GtkAccelGroup *group)
+{
+ struct nsgtk_toolbars_submenu *ret =
+ malloc(sizeof(struct nsgtk_toolbars_submenu));
+ if (ret == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
ret->toolbars_menu = GTK_MENU(gtk_menu_new());
+ if (ret->toolbars_menu == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
CHECK_ITEM(toolbars, menubar, gtkMenuBar);
- gtk_check_menu_item_set_active(ret->menubar_menuitem, TRUE);
+ if (ret->menubar_menuitem != NULL)
+ gtk_check_menu_item_set_active(ret->menubar_menuitem, TRUE);
CHECK_ITEM(toolbars, toolbar, gtkToolBar);
- gtk_check_menu_item_set_active(ret->toolbar_menuitem, TRUE);
+ if (ret->menubar_menuitem != NULL)
+ gtk_check_menu_item_set_active(ret->toolbar_menuitem, TRUE);
CHECK_ITEM(toolbars, statusbar, gtkStatusBar);
- gtk_check_menu_item_set_active(ret->statusbar_menuitem, TRUE);
- return ret;
-}
-struct nsgtk_debugging_submenu *nsgtk_menu_debugging_submenu(GtkAccelGroup
- *group)
-{
- struct nsgtk_debugging_submenu *ret = malloc(sizeof(struct
- nsgtk_debugging_submenu));
+ if (ret->menubar_menuitem != NULL)
+ gtk_check_menu_item_set_active(ret->statusbar_menuitem, TRUE);
+ return ret;
+}
+
+/**
+* creates a debugging submenu
+* \param group the 'global' in a gtk sense accelerator reference
+*/
+
+struct nsgtk_debugging_submenu *nsgtk_menu_debugging_submenu(
+ GtkAccelGroup *group)
+{
+ struct nsgtk_debugging_submenu *ret =
+ malloc(sizeof(struct nsgtk_debugging_submenu));
+ if (ret == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
ret->debugging_menu = GTK_MENU(gtk_menu_new());
+ if (ret->debugging_menu == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
IMAGE_ITEM(debugging, toggledebugging, gtkToggleDebugging);
IMAGE_ITEM(debugging, saveboxtree, gtkSaveBoxTree);
IMAGE_ITEM(debugging, savedomtree, gtkSaveDomTree);
Modified: branches/MarkieB/gtkmain/gtk/gtk_theme.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/gtk/gtk_theme....
==============================================================================
--- branches/MarkieB/gtkmain/gtk/gtk_theme.c (original)
+++ branches/MarkieB/gtkmain/gtk/gtk_theme.c Fri Jul 31 09:27:24 2009
@@ -608,14 +608,14 @@
case (PLACEHOLDER_BUTTON + 2):
return GTK_IMAGE(gtk_image_new_from_stock("gtk-close", s));
default: {
- size_t len = SLEN("arrow_down_8x32.png") +
+ size_t len = SLEN("themes/Alpha.png") +
strlen(res_dir_location) + 1;
imagefile = malloc(len);
if (imagefile == NULL) {
warn_user(messages_get("NoMemory"), 0);
return NULL;
}
- snprintf(imagefile, len, "%sarrow_down_8x32.png",
+ snprintf(imagefile, len, "%sthemes/Alpha.png",
res_dir_location);
image = GTK_IMAGE(
gtk_image_new_from_file(imagefile));
Modified: branches/MarkieB/gtkmain/gtk/gtk_toolbar.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/gtk/gtk_toolba...
==============================================================================
--- branches/MarkieB/gtkmain/gtk/gtk_toolbar.c (original)
+++ branches/MarkieB/gtkmain/gtk/gtk_toolbar.c Fri Jul 31 09:27:24 2009
@@ -43,12 +43,14 @@
GtkWidget *store_buttons[PLACEHOLDER_BUTTON];
GtkWidget *widgetvbox;
GtkWidget *currentbar;
- char numberh;
- GladeXML *glade;
+ char numberh; /* current horizontal location while adding */
+ GladeXML *glade; /* button widgets to store */
int buttonlocations[PLACEHOLDER_BUTTON];
int currentbutton;
bool fromstore;
};
+/* the number of buttons that fit in the width of the store window */
+#define NSGTK_BUTTON_WIDTH 6
static struct nsgtk_toolbar_custom_store store;
static struct nsgtk_toolbar_custom_store *window = &store;
@@ -85,12 +87,14 @@
static int nsgtk_toolbar_get_id_at_location(struct gtk_scaffolding *g, int i);
/**
- * change behaviour of scaffoldings while editing toolbar
+ * change behaviour of scaffoldings while editing toolbar; all buttons as
+ * well as window clicks are desensitized; then buttons in the front window
+ * are changed to movable buttons
*/
void nsgtk_toolbar_customization_init(struct gtk_scaffolding *g)
{
int i;
- nsgtk_scaffolding *list = scaf_list;;
+ nsgtk_scaffolding *list = scaf_list;
edit_mode = true;
while (list) {
@@ -171,17 +175,32 @@
int x,y;
struct nsgtk_theme *theme =
nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
+ if (theme == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ nsgtk_toolbar_cancel_clicked(NULL, g);
+ return;
+ }
window->glade = glade_xml_new(glade_toolbar_file_location,
"toolbarwindow", NULL);
+ if (window->glade == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ nsgtk_toolbar_cancel_clicked(NULL, g);
+ }
glade_xml_signal_autoconnect(window->glade);
#define GET_TOOLWIDGET(p, q) window->p = glade_xml_get_widget(window->glade,\
- #q)
- GET_TOOLWIDGET(window, toolbarwindow);
- GET_TOOLWIDGET(widgetvbox, widgetvbox);
+ #q);\
+ if (window->p == NULL) {\
+ warn_user(messages_get("NoMemory"), 0);\
+ nsgtk_toolbar_cancel_clicked(NULL, g);\
+ }
+
+ GET_TOOLWIDGET(window, toolbarwindow)
+ GET_TOOLWIDGET(widgetvbox, widgetvbox)
#undef GET_TOOLWIDGET
- window->numberh = 6;
+ window->numberh = NSGTK_BUTTON_WIDTH; /* preset to width [in buttons] of */
+ /* store to cause creation of a new toolbar */
window->currentbutton = -1;
/* load toolbuttons */
/* add toolbuttons to window */
@@ -191,6 +210,10 @@
continue;
window->store_buttons[i] =
nsgtk_toolbar_make_widget(g, i, theme);
+ if (window->store_buttons[i] == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ continue;
+ }
nsgtk_toolbar_add_store_widget(window->store_buttons[i]);
g_signal_connect(window->store_buttons[i], "drag-data-get",
G_CALLBACK(
@@ -305,13 +328,19 @@
}
/**
- * set toolbar logical -> physical
+ * set toolbar logical -> physical; physically visible toolbar buttons are made
+ * to correspond to the logically stored schema in terms of location
+ * visibility etc
*/
void nsgtk_toolbar_set_physical(struct gtk_scaffolding *g)
{
int i;
struct nsgtk_theme *theme =
nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
+ if (theme == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return;
+ }
/* simplest is to clear the toolbar then reload it from memory */
gtk_container_foreach(GTK_CONTAINER(nsgtk_scaffolding_toolbar(g)),
nsgtk_toolbar_clear_toolbar, g);
@@ -322,7 +351,7 @@
}
/**
- * physical update of all toolbars; resensitize
+ * cleanup code physical update of all toolbars; resensitize
* \param g the 'front' scaffolding that called customize
*/
void nsgtk_toolbar_close(struct gtk_scaffolding *g)
@@ -332,6 +361,10 @@
while (list) {
struct nsgtk_theme *theme =
nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
+ if (theme == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ continue;
+ }
/* clear toolbar */
gtk_container_foreach(GTK_CONTAINER(nsgtk_scaffolding_toolbar(
list)), nsgtk_toolbar_clear_toolbar, list);
@@ -422,7 +455,7 @@
*/
bool nsgtk_toolbar_add_store_widget(GtkWidget *widget)
{
- if (window->numberh >= 6) {
+ if (window->numberh >= NSGTK_BUTTON_WIDTH) {
window->currentbar = gtk_toolbar_new();
gtk_toolbar_set_style(GTK_TOOLBAR(window->currentbar),
GTK_TOOLBAR_BOTH);
@@ -432,7 +465,8 @@
window->currentbar, FALSE, FALSE, 0);
window->numberh = 0;
}
- gtk_widget_set_size_request(widget, 111, 70);
+ gtk_widget_set_size_request(widget, 111, 70);
+ /* seems to fit most labels */
gtk_toolbar_insert(GTK_TOOLBAR(window->currentbar), GTK_TOOL_ITEM(
widget), window->numberh++);
gtk_tool_item_set_use_drag_window(GTK_TOOL_ITEM(widget), TRUE);
@@ -456,6 +490,10 @@
return TRUE;
struct nsgtk_theme *theme =
nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
+ if (theme == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return TRUE;
+ }
if (nsgtk_scaffolding_button(g, window->currentbutton)->location
!= -1) {
if (nsgtk_scaffolding_button(g, window->currentbutton)->
@@ -508,12 +546,18 @@
return TRUE;
}
-gboolean nsgtk_toolbar_move_complete(GtkWidget *widget, GdkDragContext *gdc,
+/**
+ * connected to toolbutton drop; perhaps one day it'll work properly so it may
+ * replace the global current_button
+ */
+
+gboolean nsgtk_toolbar_move_complete(GtkWidget *widget, GdkDragContext *gdc,
gint x, gint y, GtkSelectionData *selection, guint info, guint
time, gpointer data)
{
return FALSE;
}
+
/**
* called when a widget is dropped onto the store window
*/
@@ -550,7 +594,7 @@
/**
* called when hovering an item above the toolbar
*/
-gboolean nsgtk_toolbar_action(GtkWidget *widget, GdkDragContext *gdc, gint x,
+gboolean nsgtk_toolbar_action(GtkWidget *widget, GdkDragContext *gdc, gint x,
gint y, guint time, gpointer data)
{
struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
@@ -596,8 +640,10 @@
label = remove_underscores(item.label, false);\
w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(\
theme->image[p##_BUTTON]),label));\
- free(label);\
+ if (label != NULL)\
+ free(label);\
break
+
MAKE_STOCKBUTTON(HOME, gtk-home);
MAKE_STOCKBUTTON(BACK, gtk-go-back);
MAKE_STOCKBUTTON(FORWARD, gtk-go-forward);
@@ -608,18 +654,34 @@
w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(
theme->image[HISTORY_BUTTON]), NULL));
break;
- case URL_BAR_ITEM:
- label = g_strconcat(res_dir_location, "netsurf-16x16.xpm", NULL);
+ case URL_BAR_ITEM: {
+ size_t len = strlen(res_dir_location) +
+ SLEN("netsurf-16x16.xpm" + 1);
+ label = malloc(len);
+ if (label == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
+ snprintf(label, len, "%snetsurf-16x16.xpm", res_dir_location);
hbox = gtk_hbox_new(FALSE, 0);
image = GTK_WIDGET(gtk_image_new_from_file(label));
- g_free(label);
+ free(label);
entry = GTK_WIDGET(gtk_entry_new());
+ if (hbox == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
w = GTK_WIDGET(gtk_tool_item_new());
+ if (w == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
gtk_container_add(GTK_CONTAINER(w), hbox);
gtk_tool_item_set_expand(GTK_TOOL_ITEM(w), TRUE);
break;
+ }
case THROBBER_ITEM:
if (edit_mode)
return GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(
@@ -629,6 +691,10 @@
image = GTK_WIDGET(gtk_image_new_from_pixbuf(
nsgtk_throbber->framedata[0]));
w = GTK_WIDGET(gtk_tool_item_new());
+ if (w == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
gtk_container_add(GTK_CONTAINER(w), image);
break;
case WEBSEARCH_ITEM:
@@ -638,21 +704,35 @@
GTK_ICON_SIZE_LARGE_TOOLBAR)),
"[websearch]"));
hbox = gtk_hbox_new(FALSE, 0);
+ if (hbox == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
image = GTK_WIDGET(gtk_image_new_from_stock("gtk-info",
GTK_ICON_SIZE_LARGE_TOOLBAR));
entry = GTK_WIDGET(gtk_entry_new());
+ if (entry == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
gtk_widget_set_size_request(entry, 77, -1);
gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
w = GTK_WIDGET(gtk_tool_item_new());
+ if (w == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ return NULL;
+ }
gtk_container_add(GTK_CONTAINER(w), hbox);
break;
#define MAKE_MENUBUTTON(p, q) case p##_BUTTON:\
label = remove_underscores(messages_get(#q), false);\
w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(\
theme->image[p##_BUTTON]), label));\
- free(label);\
+ if (label != NULL)\
+ free(label);\
break
+
MAKE_MENUBUTTON(NEWWINDOW, gtkNewWindow);
MAKE_MENUBUTTON(NEWTAB, gtkNewTab);
MAKE_MENUBUTTON(OPENFILE, gtkOpenFile);
@@ -705,8 +785,8 @@
* \return toolbar item id when a widget is an element of the scaffolding
* else -1
*/
-int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, struct gtk_scaffolding
- *g)
+int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget,
+ struct gtk_scaffolding *g)
{
int i;
for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
@@ -731,6 +811,10 @@
return q;
return -1;
}
+
+/**
+ * connect 'normal' handlers to toolbar buttons
+ */
void nsgtk_toolbar_connect_all(struct gtk_scaffolding *g)
{
@@ -868,6 +952,7 @@
window->fromstore = false;\
return TRUE;\
}
+
DATAHANDLER(throbber, THROBBER);
DATAHANDLER(websearch, WEBSEARCH);
#undef DATAHANDLER
@@ -885,7 +970,8 @@
}
/**
- * load toolbar settings from file
+ * load toolbar settings from file; file is a set of fields arranged as
+ * <itemreference>;<itemlocation>|<itemreference>;<itemlocation>| etc
*/
void nsgtk_toolbar_customization_load(struct gtk_scaffolding *g)
{
@@ -894,14 +980,19 @@
char buffer[SLEN("11;|") * 2 * PLACEHOLDER_BUTTON]; /* numbers 0-99 */
buffer[0] = '\0';
char *buffer1, *subbuffer, *ptr = NULL, *pter = NULL;
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++)
+ nsgtk_scaffolding_button(g, i)->location =
+ (i <= WEBSEARCH_ITEM) ? i : -1;
FILE *f = fopen(toolbar_indices_file_location, "r");
+ if (f == NULL) {
+ warn_user(messages_get("gtkFileError"),
+ toolbar_indices_file_location);
+ return;
+ }
val = fgets(buffer, sizeof buffer, f);
if (val == NULL)
LOG(("empty read toolbar settings"));
fclose(f);
- for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++)
- nsgtk_scaffolding_button(g, i)->location =
- (i <= WEBSEARCH_ITEM) ? i : -1;
i = BACK_BUTTON;
ii = BACK_BUTTON;
buffer1 = strtok_r(buffer, "|", &ptr);
Modified: branches/MarkieB/gtkmain/utils/utils.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/utils/utils.c?...
==============================================================================
--- branches/MarkieB/gtkmain/utils/utils.c (original)
+++ branches/MarkieB/gtkmain/utils/utils.c Fri Jul 31 09:27:24 2009
@@ -67,6 +67,8 @@
char *ret;
len = strlen(s);
ret = malloc(len + 1);
+ if (ret == NULL)
+ return NULL;
for (i = 0; i < len; i++)
if (s[i] != '_')
ret[i - offset] = s[i];
14 years, 1 month
r8924 jmb - in /trunk/netsurf/image: png.c png.h
by netsurf@semichrome.net
Author: jmb
Date: Fri Jul 31 09:01:49 2009
New Revision: 8924
URL: http://source.netsurf-browser.org?rev=8924&view=rev
Log:
Actually handle failure to allocate bitmap structure or retrieve its data buffer pointer. I hope these longjmps are valid -- libpng's documentation is unhelpfully vague on this subject.
Modified:
trunk/netsurf/image/png.c
trunk/netsurf/image/png.h
Modified: trunk/netsurf/image/png.c
URL: http://source.netsurf-browser.org/trunk/netsurf/image/png.c?rev=8924&r1=8...
==============================================================================
--- trunk/netsurf/image/png.c (original)
+++ trunk/netsurf/image/png.c Fri Jul 31 09:01:49 2009
@@ -56,17 +56,19 @@
{
union content_msg_data msg_data;
+ c->data.png.bitmap = NULL;
+
c->data.png.png = png_create_read_struct(PNG_LIBPNG_VER_STRING,
0, 0, 0);
- c->data.png.bitmap = NULL;
- if (!c->data.png.png) {
+ if (c->data.png.png == NULL) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
warn_user("NoMemory", 0);
return false;
}
+
c->data.png.info = png_create_info_struct(c->data.png.png);
- if (!c->data.png.info) {
+ if (c->data.png.info == NULL) {
png_destroy_read_struct(&c->data.png.png,
&c->data.png.info, 0);
@@ -140,7 +142,11 @@
/* Claim the required memory for the converted PNG */
c->data.png.bitmap = bitmap_create(width, height, BITMAP_NEW);
- c->data.png.bitbuffer = bitmap_get_buffer(c->data.png.bitmap);
+ if (c->data.png.bitmap == NULL) {
+ /* Failed -- bail out */
+ longjmp(png_jmpbuf(png), 1);
+ }
+
c->data.png.rowstride = bitmap_get_rowstride(c->data.png.bitmap);
c->data.png.bpp = bitmap_get_bpp(c->data.png.bitmap);
@@ -195,23 +201,37 @@
struct content *c = png_get_progressive_ptr(png);
unsigned long i, j, rowbytes = c->data.png.rowbytes;
unsigned int start, step;
- unsigned char *row = c->data.png.bitbuffer +
- (c->data.png.rowstride * row_num);
+ unsigned char *buffer, *row;
+
+ /* Give up if there's no bitmap */
+ if (c->data.png.bitmap == NULL)
+ return;
/* Abort if we've not got any data */
- if (new_row == 0)
+ if (new_row == NULL)
return;
+
+ /* Get bitmap buffer */
+ buffer = bitmap_get_buffer(c->data.png.bitmap);
+ if (buffer == NULL) {
+ /* No buffer, bail out */
+ longjmp(png_jmpbuf(png), 1);
+ }
+
+ /* Calculate address of row start */
+ row = buffer + (c->data.png.rowstride * row_num);
/* Handle interlaced sprites using the Adam7 algorithm */
if (c->data.png.interlace) {
start = interlace_start[pass];
- step = interlace_step[pass];
+ step = interlace_step[pass];
row_num = interlace_row_start[pass] +
interlace_row_step[pass] * row_num;
/* Copy the data to our current row taking interlacing
* into consideration */
- row = c->data.png.bitbuffer + (c->data.png.rowstride * row_num);
+ row = buffer + (c->data.png.rowstride * row_num);
+
for (j = 0, i = start; i < rowbytes; i += step) {
row[i++] = new_row[j++];
row[i++] = new_row[j++];
@@ -233,8 +253,8 @@
bool nspng_convert(struct content *c, int width, int height)
{
- assert(c->data.png.png);
- assert(c->data.png.info);
+ assert(c->data.png.png != NULL);
+ assert(c->data.png.info != NULL);
png_destroy_read_struct(&c->data.png.png, &c->data.png.info, 0);
@@ -246,6 +266,8 @@
}
c->size += (c->width * c->height * 4) + NSPNG_TITLE_LEN;
+
+ assert(c->data.png.bitmap != NULL);
c->bitmap = c->data.png.bitmap;
bitmap_set_opaque(c->bitmap, bitmap_test_opaque(c->bitmap));
@@ -271,8 +293,7 @@
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale, colour background_colour)
{
- if (c->bitmap == NULL)
- return true;
+ assert(c->bitmap != NULL);
return plot.bitmap(x, y, width, height, c->bitmap,
background_colour, BITMAPF_NONE);
@@ -285,8 +306,7 @@
{
bitmap_flags_t flags = 0;
- if (c->bitmap == NULL)
- return true;
+ assert(c->bitmap != NULL);
if (repeat_x)
flags |= BITMAPF_REPEAT_X;
Modified: trunk/netsurf/image/png.h
URL: http://source.netsurf-browser.org/trunk/netsurf/image/png.h?rev=8924&r1=8...
==============================================================================
--- trunk/netsurf/image/png.h (original)
+++ trunk/netsurf/image/png.h Fri Jul 31 09:01:49 2009
@@ -37,7 +37,6 @@
png_infop info;
int interlace;
struct bitmap *bitmap; /**< Created NetSurf bitmap */
- unsigned char *bitbuffer; /**< Bitmap buffer */
size_t rowstride, bpp; /**< Bitmap rowstride and bpp */
size_t rowbytes; /**< Number of bytes per row */
};
14 years, 1 month
r8923 struggleyb - /branches/struggleyb/libdom-remain/src/core/document.c
by netsurf@semichrome.net
Author: struggleyb
Date: Fri Jul 31 08:40:00 2009
New Revision: 8923
URL: http://source.netsurf-browser.org?rev=8923&view=rev
Log:
Remove the use of node name array.
Modified:
branches/struggleyb/libdom-remain/src/core/document.c
Modified: branches/struggleyb/libdom-remain/src/core/document.c
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-remain/src/c...
==============================================================================
--- branches/struggleyb/libdom-remain/src/core/document.c (original)
+++ branches/struggleyb/libdom-remain/src/core/document.c Fri Jul 31 08:40:00 2009
@@ -45,27 +45,6 @@
struct dom_doc_nl *prev; /**< Previous item */
};
-/** Node name strings, indexed by node type
- * Index 0 is unused */
-static struct {
- const char *name;
- size_t len;
-} __nodenames_utf8[DOM_NODE_TYPE_COUNT + 1] = {
- { NULL, 0 }, /* Unused */
- { NULL, 0 }, /* Element */
- { NULL, 0 }, /* Attr */
- { "#text", 5 }, /* Text */
- { "#cdata-section", 14 }, /* CDATA section */
- { NULL, 0 }, /* Entity reference */
- { NULL, 0 }, /* Entity */
- { NULL, 0 }, /* Processing instruction */
- { "#comment", 8 }, /* Comment */
- { "#document", 9 }, /* Document */
- { NULL, 0 }, /* Document type */
- { "#document-fragment", 18 }, /* Document fragment */
- { NULL, 0 } /* Notation */
-};
-
/* The virtual functions of this dom_document */
static struct dom_document_vtable document_vtable = {
{
@@ -147,13 +126,12 @@
assert(alloc != NULL);
assert(impl != NULL);
+ static const char _document_name[] = "#document";
dom_exception err;
lwc_string *name;
lwc_error lerr;
- lerr = lwc_context_intern(ctx,
- __nodenames_utf8[DOM_DOCUMENT_NODE].name,
- __nodenames_utf8[DOM_DOCUMENT_NODE].len, &name);
+ lerr = lwc_context_intern(ctx, _document_name, 9, &name);
if (lerr != lwc_error_ok)
return dom_exception_from_lwc_error(lerr);
@@ -345,15 +323,14 @@
dom_exception _dom_document_create_document_fragment(struct dom_document *doc,
struct dom_document_fragment **result)
{
+ static const char _document_fragment_name[] = "#document-fragment";
lwc_string *name;
dom_exception err;
lwc_error lerr;
assert(doc->context != NULL);
- lerr = lwc_context_intern(doc->context,
- __nodenames_utf8[DOM_DOCUMENT_FRAGMENT_NODE].name,
- __nodenames_utf8[DOM_DOCUMENT_FRAGMENT_NODE].len, &name);
+ lerr = lwc_context_intern(doc->context, _document_fragment_name, 18, &name);
if (lerr != lwc_error_ok)
return dom_exception_from_lwc_error(lerr);
@@ -378,15 +355,14 @@
dom_exception _dom_document_create_text_node(struct dom_document *doc,
struct dom_string *data, struct dom_text **result)
{
+ static const char _text_name[] = "#text";
lwc_string *name;
dom_exception err;
lwc_error lerr;
assert(doc->context != NULL);
- lerr = lwc_context_intern(doc->context,
- __nodenames_utf8[DOM_TEXT_NODE].name,
- __nodenames_utf8[DOM_TEXT_NODE].len, &name);
+ lerr = lwc_context_intern(doc->context, _text_name, 5, &name);
if (lerr != lwc_error_ok)
return dom_exception_from_lwc_error(lerr);
@@ -411,15 +387,14 @@
dom_exception _dom_document_create_comment(struct dom_document *doc,
struct dom_string *data, struct dom_comment **result)
{
+ static const char _comment_name[] = "#comment";
lwc_string *name;
dom_exception err;
lwc_error lerr;
assert(doc->context != NULL);
- lerr = lwc_context_intern(doc->context,
- __nodenames_utf8[DOM_COMMENT_NODE].name,
- __nodenames_utf8[DOM_COMMENT_NODE].len, &name);
+ lerr = lwc_context_intern(doc->context, _comment_name, 8, &name);
if (lerr != lwc_error_ok)
return dom_exception_from_lwc_error(lerr);
@@ -445,15 +420,14 @@
dom_exception _dom_document_create_cdata_section(struct dom_document *doc,
struct dom_string *data, struct dom_cdata_section **result)
{
+ static const char _cdata_name[] = "#cdata-section";
lwc_string *name;
dom_exception err;
lwc_error lerr;
assert(doc->context != NULL);
- lerr = lwc_context_intern(doc->context,
- __nodenames_utf8[DOM_CDATA_SECTION_NODE].name,
- __nodenames_utf8[DOM_CDATA_SECTION_NODE].len, &name);
+ lerr = lwc_context_intern(doc->context, _cdata_name, 14, &name);
if (lerr != lwc_error_ok)
return dom_exception_from_lwc_error(lerr);
14 years, 1 month