r9510 struggleyb - in /branches/struggleyb/libdom-html/src/events: event_target.c event_target.h
by netsurf@semichrome.net
Author: struggleyb
Date: Sun Aug 30 08:43:29 2009
New Revision: 9510
URL: http://source.netsurf-browser.org?rev=9510&view=rev
Log:
Add function to dispatch a generic event.
Modified:
branches/struggleyb/libdom-html/src/events/event_target.c
branches/struggleyb/libdom-html/src/events/event_target.h
Modified: branches/struggleyb/libdom-html/src/events/event_target.c
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/src/eve...
==============================================================================
--- branches/struggleyb/libdom-html/src/events/event_target.c (original)
+++ branches/struggleyb/libdom-html/src/events/event_target.c Sun Aug 30 08:43:29 2009
@@ -720,9 +720,10 @@
/**
* Dispatch a DOMCharacterDataModified event
*
- * \param et The EventTarget object
- * \param prev The preValue of the DOMCharacterData
- * \param new The newValue of the DOMCharacterData
+ * \param et The EventTarget object
+ * \param prev The preValue of the DOMCharacterData
+ * \param new The newValue of the DOMCharacterData
+ * \param success Whether this event's default handler get called
* \return DOM_NO_ERR on success, appropirate dom_exception on failure.
*
* TODO:
@@ -774,7 +775,7 @@
*
* \param doc The Document
* \param et The EventTarget object
- * \param success The newValue of the DOMCharacterData
+ * \param success Whether this event's default handler get called
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception _dom_dispatch_subtree_modified_event(struct dom_document *doc,
@@ -815,3 +816,51 @@
return err;
}
+/**
+ * Dispatch a generic event
+ *
+ * \param doc The Document
+ * \param et The EventTarget object
+ * \param name The name of the event
+ * \param len The length of the name string
+ * \param bubble Whether this event bubbles
+ * \param cancelable Whether this event can be cancelable
+ * \param success Whether this event's default handler get called
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_dispatch_generic_event(struct dom_document *doc,
+ dom_event_target *et, const uint8_t *name, size_t len,
+ bool bubble, bool cancelable, bool *success)
+{
+ struct dom_event *evt;
+ dom_exception err;
+
+ err = _dom_event_create(doc, &evt);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ lwc_string *type = NULL;
+ err = _dom_document_create_lwcstring(doc, name, len, &type);
+ if (err != DOM_NO_ERR)
+ goto cleanup;
+
+ dom_string *t = NULL;
+ err = _dom_document_create_string_from_lwcstring(doc, type, &t);
+ _dom_document_unref_lwcstring(doc, type);
+ if (err != DOM_NO_ERR)
+ goto cleanup;
+
+ err = dom_event_init(evt, t, bubble, cancelable);
+ dom_string_unref(t);
+ if (err != DOM_NO_ERR) {
+ goto cleanup;
+ }
+
+ err = dom_event_target_dispatch_event(et, evt, success);
+
+cleanup:
+ _dom_event_destroy(doc, evt);
+
+ return err;
+}
+
Modified: branches/struggleyb/libdom-html/src/events/event_target.h
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/src/eve...
==============================================================================
--- branches/struggleyb/libdom-html/src/events/event_target.h (original)
+++ branches/struggleyb/libdom-html/src/events/event_target.h Sun Aug 30 08:43:29 2009
@@ -85,4 +85,8 @@
dom_exception _dom_dispatch_subtree_modified_event(struct dom_document *doc,
dom_event_target *et, bool *success);
+/* Dispatch a generic event */
+dom_exception _dom_dispatch_generic_event(struct dom_document *doc,
+ dom_event_target *et, const uint8_t *name, size_t len,
+ bool bubble, bool cancelable, bool *success);
#endif
13 years, 7 months
r9509 struggleyb - in /branches/struggleyb/libdom-html: include/dom/html/html_form_element.h src/html/html_form_element.c src/html/html_form_element.h
by netsurf@semichrome.net
Author: struggleyb
Date: Sun Aug 30 08:24:02 2009
New Revision: 9509
URL: http://source.netsurf-browser.org?rev=9509&view=rev
Log:
Add the form control collection.
Modified:
branches/struggleyb/libdom-html/include/dom/html/html_form_element.h
branches/struggleyb/libdom-html/src/html/html_form_element.c
branches/struggleyb/libdom-html/src/html/html_form_element.h
Modified: branches/struggleyb/libdom-html/include/dom/html/html_form_element.h
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/include...
==============================================================================
--- branches/struggleyb/libdom-html/include/dom/html/html_form_element.h (original)
+++ branches/struggleyb/libdom-html/include/dom/html/html_form_element.h Sun Aug 30 08:24:02 2009
@@ -8,7 +8,18 @@
#ifndef dom_html_form_element_h_
#define dom_html_form_element_h_
+#include <dom/core/exceptions.h>
+
+struct dom_html_collection;
+
typedef struct dom_html_form_element dom_html_form_element;
+
+dom_exception dom_html_form_element_get_elements(dom_html_form_element *ele,
+ struct dom_html_collection **col);
+dom_exception dom_html_form_element_get_length(dom_html_form_element *ele,
+ unsigned long *len);
+dom_exception dom_html_form_element_submit(dom_html_form_element *ele);
+dom_exception dom_html_form_element_reset(dom_html_form_element *ele);
#endif
Modified: branches/struggleyb/libdom-html/src/html/html_form_element.c
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/src/htm...
==============================================================================
--- branches/struggleyb/libdom-html/src/html/html_form_element.c (original)
+++ branches/struggleyb/libdom-html/src/html/html_form_element.c Sun Aug 30 08:24:02 2009
@@ -5,7 +5,11 @@
* Copyright 2009 Bo Yang <struggleyb.nku.com>
*/
+#include <assert.h>
+
#include "html/html_form_element.h"
+
+#include "html/html_collection.h"
#include "core/node.h"
#include "core/document.h"
@@ -17,6 +21,8 @@
},
DOM_HTML_FORM_ELEMENT_PROTECT_VTABLE
};
+
+static bool _dom_is_form_control(struct dom_node_internal *node);
/**
* Create a dom_html_form_element object
@@ -62,6 +68,8 @@
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
_dom_document_unref_lwcstring(doc, name);
+ ele->col = NULL;
+
return err;
}
@@ -135,3 +143,94 @@
return _dom_html_element_copy(new, old);
}
+/*-----------------------------------------------------------------------*/
+/* Public APIs */
+
+/**
+ * Get the form controls under this form element
+ *
+ * \param ele The form object
+ * \param col The collection of form controls
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_form_element_get_elements(dom_html_form_element *ele,
+ struct dom_html_collection **col)
+{
+ dom_exception err;
+
+ if (ele->col == NULL) {
+ dom_document *doc = dom_node_get_owner(ele);
+ assert(doc != NULL);
+ err = _dom_html_collection_create(doc,
+ (dom_node_internal *) ele,
+ _dom_is_form_control, col);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ ele->col = *col;
+ }
+
+ *col = ele->col;
+ dom_html_collection_ref(*col);
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Get the number of form controls under this form element
+ *
+ * \param ele The form object
+ * \param len The number of controls
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_form_element_get_length(dom_html_form_element *ele,
+ unsigned long *len)
+{
+ dom_exception err;
+
+ if (ele->col == NULL) {
+ dom_document *doc = dom_node_get_owner(ele);
+ assert(doc != NULL);
+ err = _dom_html_collection_create(doc,
+ (dom_node_internal *) ele,
+ _dom_is_form_control, &ele->col);
+ if (err != DOM_NO_ERR)
+ return err;
+ }
+
+ return dom_html_collection_get_length(ele->col, len);
+}
+
+/**
+ * Submit this form
+ *
+ * \param ele The form object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_form_element_submit(dom_html_form_element *ele)
+{
+}
+
+/**
+ * Reset this form
+ *
+ * \param ele The form object
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_html_form_element_reset(dom_html_form_element *ele)
+{
+}
+
+/*-----------------------------------------------------------------------*/
+/* Internal functions */
+
+/* Callback function to test whether certain node is a form control, see
+ * src/html/html_collection.h for detail. */
+static bool _dom_is_form_control(struct dom_node_internal *node)
+{
+ assert(node->type == DOM_ELEMENT_NODE);
+ dom_html_element *ele = (dom_html_element *) node;
+
+ return ele->form != NULL;
+}
+
Modified: branches/struggleyb/libdom-html/src/html/html_form_element.h
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/src/htm...
==============================================================================
--- branches/struggleyb/libdom-html/src/html/html_form_element.h (original)
+++ branches/struggleyb/libdom-html/src/html/html_form_element.h Sun Aug 30 08:24:02 2009
@@ -12,9 +12,13 @@
#include "html/html_element.h"
+struct dom_html_collection;
+
struct dom_html_form_element {
struct dom_html_element base;
/**< The base class */
+ struct dom_html_collection *col;
+ /**< The collection of form controls */
};
/* Create a dom_html_form_element object */
13 years, 7 months
r9508 struggleyb - in /branches/struggleyb/libdom-html: include/dom/html/html_collection.h include/dom/html/html_options_collection.h src/html/html_collection.c src/html/html_collection.h src/html/html_options_collection.c
by netsurf@semichrome.net
Author: struggleyb
Date: Sun Aug 30 08:14:53 2009
New Revision: 9508
URL: http://source.netsurf-browser.org?rev=9508&view=rev
Log:
Add reference counting for collection objects.
Modified:
branches/struggleyb/libdom-html/include/dom/html/html_collection.h
branches/struggleyb/libdom-html/include/dom/html/html_options_collection.h
branches/struggleyb/libdom-html/src/html/html_collection.c
branches/struggleyb/libdom-html/src/html/html_collection.h
branches/struggleyb/libdom-html/src/html/html_options_collection.c
Modified: branches/struggleyb/libdom-html/include/dom/html/html_collection.h
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/include...
==============================================================================
--- branches/struggleyb/libdom-html/include/dom/html/html_collection.h (original)
+++ branches/struggleyb/libdom-html/include/dom/html/html_collection.h Sun Aug 30 08:14:53 2009
@@ -22,5 +22,8 @@
dom_exception dom_html_collection_named_item(dom_html_collection *col,
struct dom_string *name, struct dom_node **node);
+void dom_html_collection_ref(dom_html_collection *col);
+void dom_html_collection_unref(dom_html_collection *col);
+
#endif
Modified: branches/struggleyb/libdom-html/include/dom/html/html_options_collection.h
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/include...
==============================================================================
--- branches/struggleyb/libdom-html/include/dom/html/html_options_collection.h (original)
+++ branches/struggleyb/libdom-html/include/dom/html/html_options_collection.h Sun Aug 30 08:14:53 2009
@@ -26,5 +26,8 @@
dom_html_options_collection *col, struct dom_string *name,
struct dom_node **node);
+void dom_html_options_collection_ref(dom_html_options_collection *col);
+void dom_html_options_collection_unref(dom_html_options_collection *col);
+
#endif
Modified: branches/struggleyb/libdom-html/src/html/html_collection.c
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/src/htm...
==============================================================================
--- branches/struggleyb/libdom-html/src/html/html_collection.c (original)
+++ branches/struggleyb/libdom-html/src/html/html_collection.c Sun Aug 30 08:14:53 2009
@@ -67,6 +67,7 @@
dom_node_ref(root);
col->ic = ic;
+ col->refcnt = 1;
return DOM_NO_ERR;
}
@@ -267,3 +268,33 @@
return DOM_NO_ERR;
}
+/**
+ * Claim a reference on this collection
+ *
+ * \pram col The collection object
+ */
+void dom_html_collection_ref(dom_html_collection *col)
+{
+ if (col == NULL)
+ return;
+
+ col->refcnt ++;
+}
+
+/**
+ * Relese a reference on this collection
+ *
+ * \pram col The collection object
+ */
+void dom_html_collection_unref(dom_html_collection *col)
+{
+ if (col == NULL)
+ return;
+
+ if (col->refcnt > 0)
+ col->refcnt --;
+
+ if (col->refcnt == 0)
+ _dom_html_collection_destroy(col);
+}
+
Modified: branches/struggleyb/libdom-html/src/html/html_collection.h
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/src/htm...
==============================================================================
--- branches/struggleyb/libdom-html/src/html/html_collection.h (original)
+++ branches/struggleyb/libdom-html/src/html/html_collection.h Sun Aug 30 08:14:53 2009
@@ -28,6 +28,8 @@
*/
struct dom_node_internal *root;
/**< The root node of this collection */
+ uint32_t refcnt;
+ /**< Reference counting */
};
dom_exception _dom_html_collection_create(struct dom_document *doc,
Modified: branches/struggleyb/libdom-html/src/html/html_options_collection.c
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/src/htm...
==============================================================================
--- branches/struggleyb/libdom-html/src/html/html_options_collection.c (original)
+++ branches/struggleyb/libdom-html/src/html/html_options_collection.c Sun Aug 30 08:14:53 2009
@@ -145,3 +145,33 @@
return dom_html_collection_named_item(&col->base, name, node);
}
+/**
+ * Claim a reference on this collection
+ *
+ * \pram col The collection object
+ */
+void dom_html_options_collection_ref(dom_html_options_collection *col)
+{
+ if (col == NULL)
+ return;
+
+ col->base.refcnt ++;
+}
+
+/**
+ * Relese a reference on this collection
+ *
+ * \pram col The collection object
+ */
+void dom_html_options_collection_unref(dom_html_options_collection *col)
+{
+ if (col == NULL)
+ return;
+
+ if (col->base.refcnt > 0)
+ col->base.refcnt --;
+
+ if (col->base.refcnt == 0)
+ _dom_html_options_collection_destroy(col);
+}
+
13 years, 7 months
r9507 MarkieB - /branches/MarkieB/gtkmain/render/favicon.c
by netsurf@semichrome.net
Author: MarkieB
Date: Sun Aug 30 07:12:18 2009
New Revision: 9507
URL: http://source.netsurf-browser.org?rev=9507&view=rev
Log:
add handling of gif animation content messages
Modified:
branches/MarkieB/gtkmain/render/favicon.c
Modified: branches/MarkieB/gtkmain/render/favicon.c
URL: http://source.netsurf-browser.org/branches/MarkieB/gtkmain/render/favicon...
==============================================================================
--- branches/MarkieB/gtkmain/render/favicon.c (original)
+++ branches/MarkieB/gtkmain/render/favicon.c Sun Aug 30 07:12:18 2009
@@ -217,7 +217,13 @@
c->data.html.favicon = 0;
content_add_error(c, "?", 0);
break;
-
+ case CONTENT_MSG_REDRAW:
+ /* currently no support for favicon animations */
+ case CONTENT_MSG_REFRESH:
+ break;
+ case CONTENT_MSG_REFORMAT:
+ /* would be unusual :) */
+ break;
default:
assert(0);
}
13 years, 7 months
r9505 chris_y - in /trunk/netsurf: !NetSurf/Resources/de/Messages !NetSurf/Resources/en/Messages !NetSurf/Resources/fr/Messages !NetSurf/Resources/it/Messages !NetSurf/Resources/nl/Messages amiga/gui.c amiga/print.c
by netsurf@semichrome.net
Author: chris_y
Date: Sun Aug 30 05:14:16 2009
New Revision: 9505
URL: http://source.netsurf-browser.org?rev=9505&view=rev
Log:
Show printing progress
Modified:
trunk/netsurf/!NetSurf/Resources/de/Messages
trunk/netsurf/!NetSurf/Resources/en/Messages
trunk/netsurf/!NetSurf/Resources/fr/Messages
trunk/netsurf/!NetSurf/Resources/it/Messages
trunk/netsurf/!NetSurf/Resources/nl/Messages
trunk/netsurf/amiga/gui.c
trunk/netsurf/amiga/print.c
Modified: trunk/netsurf/!NetSurf/Resources/de/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/%21NetSurf/Resources/de/M...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/de/Messages (original)
+++ trunk/netsurf/!NetSurf/Resources/de/Messages Sun Aug 30 05:14:16 2009
@@ -441,6 +441,9 @@
PrintSheetFilled:Druckseite
PrintSheetsFilled:Druckseiten
+Printer:Printer
+Copies:Copies
+Printing:Printing page
# Find text user interface tokens
Modified: trunk/netsurf/!NetSurf/Resources/en/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/%21NetSurf/Resources/en/M...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/en/Messages (original)
+++ trunk/netsurf/!NetSurf/Resources/en/Messages Sun Aug 30 05:14:16 2009
@@ -445,6 +445,9 @@
PrintSheetFilled:sheet is filled
PrintSheetsFilled:sheets are filled
+Printer:Printer
+Copies:Copies
+Printing:Printing page
# Find text user interface tokens
Modified: trunk/netsurf/!NetSurf/Resources/fr/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/%21NetSurf/Resources/fr/M...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/fr/Messages (original)
+++ trunk/netsurf/!NetSurf/Resources/fr/Messages Sun Aug 30 05:14:16 2009
@@ -441,6 +441,9 @@
PrintSheetFilled:feuille remplie
PrintSheetsFilled:feuilles remplies
+Printer:Printer
+Copies:Copies
+Printing:Printing page
# Find text user interface tokens
Modified: trunk/netsurf/!NetSurf/Resources/it/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/%21NetSurf/Resources/it/M...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/it/Messages (original)
+++ trunk/netsurf/!NetSurf/Resources/it/Messages Sun Aug 30 05:14:16 2009
@@ -448,6 +448,9 @@
PrintSheetFilled:Il foglio stampato è pieno
PrintSheetsFilled:I fogli stampati sono pieni
+Printer:Printer
+Copies:Copies
+Printing:Printing page
# Find text user interface tokens
Modified: trunk/netsurf/!NetSurf/Resources/nl/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/%21NetSurf/Resources/nl/M...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/nl/Messages (original)
+++ trunk/netsurf/!NetSurf/Resources/nl/Messages Sun Aug 30 05:14:16 2009
@@ -441,6 +441,9 @@
PrintSheetFilled:pagina
PrintSheetsFilled:pagina's
+Printer:Printer
+Copies:Copies
+Printing:Printing page
# Find text user interface tokens
Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=9505&r1=9...
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Sun Aug 30 05:14:16 2009
@@ -2742,7 +2742,7 @@
if((g->shared->status == NULL) || (strcmp(utf8text,g->shared->status)))
{
- SetGadgetAttrs(g->shared->gadgets[GID_STATUS],
+ RefreshSetGadgetAttrs(g->shared->gadgets[GID_STATUS],
g->shared->win, NULL,
GA_Text, utf8text,
TAG_DONE);
Modified: trunk/netsurf/amiga/print.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/print.c?rev=9505&r1...
==============================================================================
--- trunk/netsurf/amiga/print.c (original)
+++ trunk/netsurf/amiga/print.c Sun Aug 30 05:14:16 2009
@@ -22,15 +22,29 @@
#include "amiga/gui.h"
#include "amiga/options.h"
#include "amiga/print.h"
-
+#include "utils/messages.h"
+#include "utils/utils.h"
+
+#include <proto/intuition.h>
#include <proto/Picasso96API.h>
#include <devices/printer.h>
#include <devices/prtbase.h>
+
+#include <proto/window.h>
+#include <proto/layout.h>
+
+#include <proto/fuelgauge.h>
+#include <classes/window.h>
+#include <gadgets/fuelgauge.h>
+#include <gadgets/layout.h>
+
+#include <reaction/reaction_macros.h>
bool ami_print_begin(struct print_settings *ps);
bool ami_print_next_page(void);
void ami_print_end(void);
bool ami_print_dump(void);
+void ami_print_progress(void);
const struct printer amiprinter = {
&amiplot,
@@ -50,6 +64,9 @@
struct print_settings *ps;
int page;
int pages;
+ struct Gadget *gadgets[GID_LAST];
+ struct Object *objects[OID_LAST];
+ struct Window *win;
};
struct ami_printer_info ami_print_info;
@@ -87,6 +104,8 @@
height *= ami_print_info.ps->scale;
ami_print_info.pages = height / ami_print_info.ps->page_height;
ami_print_info.c = c;
+
+ ami_print_progress();
while(ami_print_cont()); /* remove while() for async printing */
}
@@ -151,6 +170,10 @@
{
ami_print_info.page++;
+ RefreshSetGadgetAttrs(ami_print_info.gadgets[GID_STATUS],
+ ami_print_info.win, NULL,
+ FUELGAUGE_Level, ami_print_info.page,
+ TAG_DONE);
return true;
}
@@ -158,6 +181,7 @@
{
ami_free_layers(ami_print_info.gg);
FreeVec(ami_print_info.gg);
+ DisposeObject(ami_print_info.objects[OID_MAIN]);
glob = &browserglob;
CloseDevice(ami_print_info.PReq);
@@ -184,3 +208,47 @@
return true;
}
+
+void ami_print_progress(void)
+{
+ ami_print_info.objects[OID_MAIN] = WindowObject,
+ WA_ScreenTitle,nsscreentitle,
+ WA_Title, messages_get("Printing"),
+ WA_Activate, TRUE,
+ WA_DepthGadget, TRUE,
+ WA_DragBar, TRUE,
+ WA_CloseGadget, FALSE,
+ WA_SizeGadget, TRUE,
+ WA_CustomScreen,scrn,
+ //WINDOW_SharedPort,sport,
+ WINDOW_UserData, &ami_print_info,
+ WINDOW_IconifyGadget, FALSE,
+ WINDOW_LockHeight,TRUE,
+ WINDOW_Position, WPOS_CENTERSCREEN,
+ WINDOW_ParentGroup, ami_print_info.gadgets[GID_MAIN] = VGroupObject,
+ LAYOUT_AddChild, ami_print_info.gadgets[GID_STATUS] = FuelGaugeObject,
+ GA_ID,GID_STATUS,
+ FUELGAUGE_Min,0,
+ FUELGAUGE_Max,ami_print_info.pages,
+ FUELGAUGE_Level,0,
+ FUELGAUGE_Ticks,11,
+ FUELGAUGE_ShortTicks,TRUE,
+ FUELGAUGE_Percent,TRUE,
+ FUELGAUGE_Justification,FGJ_CENTER,
+ FuelGaugeEnd,
+ CHILD_NominalSize,TRUE,
+ CHILD_WeightedHeight,0,
+/*
+ LAYOUT_AddChild, ami_print_info.gadgets[GID_CANCEL] = ButtonObject,
+ GA_ID,GID_CANCEL,
+ GA_Disabled,TRUE,
+ GA_RelVerify,TRUE,
+ GA_Text,messages_get("Abort"),
+ GA_TabCycle,TRUE,
+ ButtonEnd,
+*/
+ EndGroup,
+ EndWindow;
+
+ ami_print_info.win = (struct Window *)RA_OpenWindow(ami_print_info.objects[OID_MAIN]);
+}
13 years, 7 months
r9504 MarkieB - /branches/MarkieB/windows/windows/localhistory.c
by netsurf@semichrome.net
Author: MarkieB
Date: Sun Aug 30 03:00:10 2009
New Revision: 9504
URL: http://source.netsurf-browser.org?rev=9504&view=rev
Log:
improve scrolling of local history window
Modified:
branches/MarkieB/windows/windows/localhistory.c
Modified: branches/MarkieB/windows/windows/localhistory.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/localh...
==============================================================================
--- branches/MarkieB/windows/windows/localhistory.c (original)
+++ branches/MarkieB/windows/windows/localhistory.c Sun Aug 30 03:00:10 2009
@@ -23,6 +23,7 @@
#include "desktop/browser.h"
#include "desktop/history_core.h"
+#include "desktop/plotters.h"
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -60,14 +61,16 @@
LOG(("gui window %p", w));
static const char localhistorywindowclassname[] = "nsws_localhistory_window";
WNDCLASSEX we;
- HWND hwnd, mainhwnd = gui_window_main_window(w);
+ HWND mainhwnd = gui_window_main_window(w);
INITCOMMONCONTROLSEX icc;
HICON hIcon = nsws_window_get_ico(true);
HICON hIconS = nsws_window_get_ico(false);
struct browser_window *bw = gui_window_browser_window(w);
int margin = 50;
RECT r;
-
+
+ localhistory.width = 0;
+ localhistory.height = 0;
current_gui = NULL;
current_hwnd = NULL;
doublebuffering = false;
@@ -107,7 +110,7 @@
LoadIcon(NULL, IDI_APPLICATION) : hIconS;
RegisterClassEx(&we);
LOG(("creating local history window for hInstance %p", hinstance));
- hwnd = CreateWindow(localhistorywindowclassname,
+ localhistory.hwnd = CreateWindow(localhistorywindowclassname,
"NetSurf History",WS_THICKFRAME | WS_HSCROLL |
WS_VSCROLL | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
CS_DBLCLKS, r.left + margin/2, r.top + margin/2,
@@ -116,10 +119,9 @@
LOG(("gui_window %p width %d height %d hwnd %p", w,
localhistory.guiwidth, localhistory.guiheight,
localhistory.hwnd));
- current_hwnd = hwnd;
- ShowWindow(hwnd, SW_SHOWNORMAL);
- UpdateWindow(hwnd);
- localhistory.hwnd = hwnd;
+ current_hwnd = localhistory.hwnd;
+ ShowWindow(localhistory.hwnd, SW_SHOWNORMAL);
+ UpdateWindow(localhistory.hwnd);
gui_window_set_localhistory(w, &localhistory);
nsws_localhistory_up(w);
}
@@ -149,6 +151,10 @@
localhistory.guiheight = HIWORD(lparam);
localhistory.guiwidth = LOWORD(lparam);
nsws_localhistory_scroll_check(w);
+ current_gui = NULL;
+ current_hwnd = hwnd;
+ plot.rectangle(0, 0, localhistory.guiwidth,
+ localhistory.guiheight, plot_style_fill_white);
break;
case WM_MOVE: {
RECT r, rmain;
@@ -237,19 +243,20 @@
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
GetScrollInfo(hwnd, SB_VERT, &si);
if (si.nPos != mem) {
- RECT r;
- HDC hdc = GetDC(hwnd);
- ScrollWindowEx(hwnd, 0, mem - si.nPos, NULL, NULL, NULL,
- &r, 0);
+ current_gui = NULL;
+ current_hwnd = hwnd;
localhistory.vscroll += si.nPos - mem;
+ plot.rectangle(0, 0, localhistory.guiwidth,
+ localhistory.guiheight,
+ plot_style_fill_white);
history_redraw_rectangle(bw->history,
- r.left + localhistory.hscroll,
- r.top + localhistory.vscroll,
- r.right + localhistory.hscroll,
- r.bottom + localhistory.vscroll,
- r.left, r.top);
-
- ReleaseDC(hwnd, hdc);
+ localhistory.hscroll,
+ localhistory.vscroll,
+ localhistory.guiwidth +
+ localhistory.hscroll,
+ localhistory.guiheight
+ + localhistory.vscroll,
+ 0, 0);
}
break;
}
@@ -289,22 +296,28 @@
SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
GetScrollInfo(hwnd, SB_HORZ, &si);
if (si.nPos != mem) {
- RECT r;
- ScrollWindowEx(hwnd, mem - si.nPos, 0, NULL, NULL, NULL,
- &r, 0);
+ current_gui = NULL;
+ current_hwnd = hwnd;
localhistory.hscroll += si.nPos - mem;
if (bw == NULL)
break;
+ plot.rectangle(0, 0, localhistory.guiwidth,
+ localhistory.guiheight,
+ plot_style_fill_white);
history_redraw_rectangle(bw->history,
- r.left + localhistory.hscroll,
- r.top + localhistory.vscroll,
- r.right + localhistory.hscroll,
- r.bottom + localhistory.vscroll,
- r.left, r.top);
+ localhistory.hscroll,
+ localhistory.vscroll,
+ localhistory.guiwidth +
+ localhistory.hscroll,
+ localhistory.guiheight
+ + localhistory.vscroll,
+ 0, 0);
}
break;
}
case WM_PAINT: {
+ current_gui = NULL;
+ current_hwnd = hwnd;
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
if (bw != NULL)
@@ -343,6 +356,8 @@
if (bw != NULL)
history_redraw(bw->history);
+
+ nsws_localhistory_scroll_check(w);
ReleaseDC(localhistory.hwnd, hdc);
}
13 years, 7 months
r9503 MarkieB - in /branches/MarkieB/gtkmain/gtk: gtk_theme.c gtk_toolbar.c
by netsurf@semichrome.net
Author: MarkieB
Date: Sun Aug 30 00:16:28 2009
New Revision: 9503
URL: http://source.netsurf-browser.org?rev=9503&view=rev
Log:
make all macros self-contained
Modified:
branches/MarkieB/gtkmain/gtk/gtk_theme.c
branches/MarkieB/gtkmain/gtk/gtk_toolbar.c
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 Sun Aug 30 00:16:28 2009
@@ -55,7 +55,11 @@
static GtkImage *nsgtk_theme_image_default(nsgtk_toolbar_button i,
GtkIconSize s);
static bool nsgtk_theme_verify(const char *themename);
-
+static void nsgtk_theme_cache_image(nsgtk_toolbar_button i,
+ const char *filename, const char *path);
+static void nsgtk_theme_cache_searchimage(nsgtk_search_buttons i,
+ const char *filename, const char *path);
+
#ifdef WITH_THEME_INSTALL
static struct content *theme_install_content = NULL;
@@ -388,88 +392,122 @@
if (cachetheme == NULL)
return NULL;
-#define SET_BUTTON_IMAGE(q)\
- if (cachetheme->image[q##_BUTTON] != NULL)\
- theme->image[q##_BUTTON] = GTK_IMAGE(gtk_image_new_from_pixbuf(\
- cachetheme->image[q##_BUTTON]));\
+#define SET_BUTTON_IMAGE(p, q, r)\
+ if (p->image[q##_BUTTON] != NULL)\
+ r->image[q##_BUTTON] = GTK_IMAGE(gtk_image_new_from_pixbuf(\
+ p->image[q##_BUTTON]));\
else\
- theme->image[q##_BUTTON] = nsgtk_theme_image_default(\
+ r->image[q##_BUTTON] = nsgtk_theme_image_default(\
q##_BUTTON, s);
- SET_BUTTON_IMAGE(BACK)
- SET_BUTTON_IMAGE(HISTORY)
- SET_BUTTON_IMAGE(FORWARD)
- SET_BUTTON_IMAGE(STOP)
- SET_BUTTON_IMAGE(RELOAD)
- SET_BUTTON_IMAGE(HOME)
- SET_BUTTON_IMAGE(NEWWINDOW)
- SET_BUTTON_IMAGE(NEWTAB)
- SET_BUTTON_IMAGE(OPENFILE)
- SET_BUTTON_IMAGE(CLOSETAB)
- SET_BUTTON_IMAGE(CLOSEWINDOW)
- SET_BUTTON_IMAGE(SAVEPAGE)
- SET_BUTTON_IMAGE(PRINTPREVIEW)
- SET_BUTTON_IMAGE(PRINT)
- SET_BUTTON_IMAGE(QUIT)
- SET_BUTTON_IMAGE(CUT)
- SET_BUTTON_IMAGE(COPY)
- SET_BUTTON_IMAGE(PASTE)
- SET_BUTTON_IMAGE(DELETE)
- SET_BUTTON_IMAGE(SELECTALL)
- SET_BUTTON_IMAGE(PREFERENCES)
- SET_BUTTON_IMAGE(ZOOMPLUS)
- SET_BUTTON_IMAGE(ZOOMMINUS)
- SET_BUTTON_IMAGE(ZOOMNORMAL)
- SET_BUTTON_IMAGE(FULLSCREEN)
- SET_BUTTON_IMAGE(VIEWSOURCE)
- SET_BUTTON_IMAGE(CONTENTS)
- SET_BUTTON_IMAGE(ABOUT)
- SET_BUTTON_IMAGE(PDF)
- SET_BUTTON_IMAGE(PLAINTEXT)
- SET_BUTTON_IMAGE(DRAWFILE)
- SET_BUTTON_IMAGE(POSTSCRIPT)
- SET_BUTTON_IMAGE(FIND)
- SET_BUTTON_IMAGE(DOWNLOADS)
- SET_BUTTON_IMAGE(SAVEWINDOWSIZE)
- SET_BUTTON_IMAGE(TOGGLEDEBUGGING)
- SET_BUTTON_IMAGE(SAVEBOXTREE)
- SET_BUTTON_IMAGE(SAVEDOMTREE)
- SET_BUTTON_IMAGE(LOCALHISTORY)
- SET_BUTTON_IMAGE(GLOBALHISTORY)
- SET_BUTTON_IMAGE(ADDBOOKMARKS)
- SET_BUTTON_IMAGE(SHOWBOOKMARKS)
- SET_BUTTON_IMAGE(OPENLOCATION)
- SET_BUTTON_IMAGE(NEXTTAB)
- SET_BUTTON_IMAGE(PREVTAB)
- SET_BUTTON_IMAGE(GUIDE)
- SET_BUTTON_IMAGE(INFO)
+ SET_BUTTON_IMAGE(cachetheme, BACK, theme)
+ SET_BUTTON_IMAGE(cachetheme, HISTORY, theme)
+ SET_BUTTON_IMAGE(cachetheme, FORWARD, theme)
+ SET_BUTTON_IMAGE(cachetheme, STOP, theme)
+ SET_BUTTON_IMAGE(cachetheme, RELOAD, theme)
+ SET_BUTTON_IMAGE(cachetheme, HOME, theme)
+ SET_BUTTON_IMAGE(cachetheme, NEWWINDOW, theme)
+ SET_BUTTON_IMAGE(cachetheme, NEWTAB, theme)
+ SET_BUTTON_IMAGE(cachetheme, OPENFILE, theme)
+ SET_BUTTON_IMAGE(cachetheme, CLOSETAB, theme)
+ SET_BUTTON_IMAGE(cachetheme, CLOSEWINDOW, theme)
+ SET_BUTTON_IMAGE(cachetheme, SAVEPAGE, theme)
+ SET_BUTTON_IMAGE(cachetheme, PRINTPREVIEW, theme)
+ SET_BUTTON_IMAGE(cachetheme, PRINT, theme)
+ SET_BUTTON_IMAGE(cachetheme, QUIT, theme)
+ SET_BUTTON_IMAGE(cachetheme, CUT, theme)
+ SET_BUTTON_IMAGE(cachetheme, COPY, theme)
+ SET_BUTTON_IMAGE(cachetheme, PASTE, theme)
+ SET_BUTTON_IMAGE(cachetheme, DELETE, theme)
+ SET_BUTTON_IMAGE(cachetheme, SELECTALL, theme)
+ SET_BUTTON_IMAGE(cachetheme, PREFERENCES, theme)
+ SET_BUTTON_IMAGE(cachetheme, ZOOMPLUS, theme)
+ SET_BUTTON_IMAGE(cachetheme, ZOOMMINUS, theme)
+ SET_BUTTON_IMAGE(cachetheme, ZOOMNORMAL, theme)
+ SET_BUTTON_IMAGE(cachetheme, FULLSCREEN, theme)
+ SET_BUTTON_IMAGE(cachetheme, VIEWSOURCE, theme)
+ SET_BUTTON_IMAGE(cachetheme, CONTENTS, theme)
+ SET_BUTTON_IMAGE(cachetheme, ABOUT, theme)
+ SET_BUTTON_IMAGE(cachetheme, PDF, theme)
+ SET_BUTTON_IMAGE(cachetheme, PLAINTEXT, theme)
+ SET_BUTTON_IMAGE(cachetheme, DRAWFILE, theme)
+ SET_BUTTON_IMAGE(cachetheme, POSTSCRIPT, theme)
+ SET_BUTTON_IMAGE(cachetheme, FIND, theme)
+ SET_BUTTON_IMAGE(cachetheme, DOWNLOADS, theme)
+ SET_BUTTON_IMAGE(cachetheme, SAVEWINDOWSIZE, theme)
+ SET_BUTTON_IMAGE(cachetheme, TOGGLEDEBUGGING, theme)
+ SET_BUTTON_IMAGE(cachetheme, SAVEBOXTREE, theme)
+ SET_BUTTON_IMAGE(cachetheme, SAVEDOMTREE, theme)
+ SET_BUTTON_IMAGE(cachetheme, LOCALHISTORY, theme)
+ SET_BUTTON_IMAGE(cachetheme, GLOBALHISTORY, theme)
+ SET_BUTTON_IMAGE(cachetheme, ADDBOOKMARKS, theme)
+ SET_BUTTON_IMAGE(cachetheme, SHOWBOOKMARKS, theme)
+ SET_BUTTON_IMAGE(cachetheme, OPENLOCATION, theme)
+ SET_BUTTON_IMAGE(cachetheme, NEXTTAB, theme)
+ SET_BUTTON_IMAGE(cachetheme, PREVTAB, theme)
+ SET_BUTTON_IMAGE(cachetheme, GUIDE, theme)
+ SET_BUTTON_IMAGE(cachetheme, INFO, theme)
#undef SET_BUTTON_IMAGE
-#define SET_BUTTON_IMAGE(p, q)\
- if (cachetheme->searchimage[SEARCH_##p##_BUTTON] != NULL)\
- theme->searchimage[SEARCH_##p##_BUTTON] =\
+#define SET_BUTTON_IMAGE(p, q, qq, r)\
+ if (qq->searchimage[SEARCH_##p##_BUTTON] != NULL)\
+ r->searchimage[SEARCH_##p##_BUTTON] =\
GTK_IMAGE(gtk_image_new_from_pixbuf(\
- cachetheme->searchimage[\
+ qq->searchimage[\
SEARCH_##p##_BUTTON]));\
- else if (cachetheme->image[q##_BUTTON] != NULL)\
- theme->searchimage[SEARCH_##p##_BUTTON] =\
+ else if (qq->image[q##_BUTTON] != NULL)\
+ r->searchimage[SEARCH_##p##_BUTTON] =\
GTK_IMAGE(gtk_image_new_from_pixbuf(\
- cachetheme->image[q##_BUTTON]));\
+ qq->image[q##_BUTTON]));\
else\
- theme->searchimage[SEARCH_##p##_BUTTON] =\
+ r->searchimage[SEARCH_##p##_BUTTON] =\
nsgtk_theme_image_default(\
PLACEHOLDER_BUTTON + SEARCH_##p##_BUTTON, s);
- SET_BUTTON_IMAGE(BACK, BACK)
- SET_BUTTON_IMAGE(FORWARD, FORWARD)
- SET_BUTTON_IMAGE(CLOSE, CLOSEWINDOW)
+ SET_BUTTON_IMAGE(BACK, BACK, cachetheme, theme)
+ SET_BUTTON_IMAGE(FORWARD, FORWARD, cachetheme, theme)
+ SET_BUTTON_IMAGE(CLOSE, CLOSEWINDOW, cachetheme, theme)
#undef SET_BUTTON_IMAGE
return theme;
}
/**
+ * caches individual theme images from file
+ * \param i the toolbar button reference
+ * \param filename the image file name
+ * \param path the path to the theme folder
+ */
+void nsgtk_theme_cache_image(nsgtk_toolbar_button i, const char *filename,
+ const char *path)
+{
+ char fullpath[strlen(filename) + strlen(path) + 1];
+ sprintf(fullpath, "%s%s", path, filename);
+ if (theme_cache_toolbar != NULL)
+ theme_cache_toolbar->image[i] =
+ gdk_pixbuf_new_from_file_at_size(fullpath,
+ 24, 24, NULL);
+ if (theme_cache_menu != NULL)
+ theme_cache_menu->image[i] = gdk_pixbuf_new_from_file_at_size(
+ fullpath, 16, 16, NULL);
+}
+
+void nsgtk_theme_cache_searchimage(nsgtk_search_buttons i,
+ const char *filename, const char *path)
+{
+ char fullpath[strlen(filename) + strlen(path) + 1];
+ sprintf(fullpath, "%s%s", path, filename);
+ if (theme_cache_toolbar != NULL)
+ theme_cache_toolbar->searchimage[i] =
+ gdk_pixbuf_new_from_file_at_size(fullpath,
+ 24, 24, NULL);
+ if (theme_cache_menu != NULL)
+ theme_cache_menu->searchimage[i] =
+ gdk_pixbuf_new_from_file_at_size(fullpath,
+ 16, 16, NULL);
+}
+
+/**
* caches theme images from file as pixbufs
*/
-
void nsgtk_theme_prepare(void)
{
if (current_theme_name == NULL)
@@ -483,96 +521,63 @@
char path[len];
snprintf(path, len, "%sthemes/%s/", res_dir_location,
current_theme_name);
- char *filename;
-#define CACHE_IMAGE(p, q)\
- len = SLEN(#q ".png") + strlen(path) + 1;\
- filename = malloc(len);\
- if (filename == NULL) {\
- warn_user(messages_get("NoMemory"), 0);\
- free(path);\
- return;\
- }\
- snprintf(filename, len, "%s" #q ".png", path);\
- if (theme_cache_toolbar != NULL)\
- theme_cache_toolbar->image[p##_BUTTON] =\
- gdk_pixbuf_new_from_file_at_size(filename,\
- 24, 24, NULL);\
- if (theme_cache_menu != NULL)\
- theme_cache_menu->image[p##_BUTTON] =\
- gdk_pixbuf_new_from_file_at_size(filename,\
- 16, 16, NULL);\
- free(filename)
-
- CACHE_IMAGE(BACK, back);
- CACHE_IMAGE(HISTORY, history);
- CACHE_IMAGE(FORWARD, forward);
- CACHE_IMAGE(STOP, stop);
- CACHE_IMAGE(RELOAD, reload);
- CACHE_IMAGE(HOME, home);
- CACHE_IMAGE(NEWWINDOW, newwindow);
- CACHE_IMAGE(NEWTAB, newtab);
- CACHE_IMAGE(OPENFILE, openfile);
- CACHE_IMAGE(CLOSETAB, closetab);
- CACHE_IMAGE(CLOSEWINDOW, closewindow);
- CACHE_IMAGE(SAVEPAGE, savepage);
- CACHE_IMAGE(PRINTPREVIEW, printpreview);
- CACHE_IMAGE(PRINT, print);
- CACHE_IMAGE(QUIT, quit);
- CACHE_IMAGE(CUT, cut);
- CACHE_IMAGE(COPY, copy);
- CACHE_IMAGE(PASTE, paste);
- CACHE_IMAGE(DELETE, delete);
- CACHE_IMAGE(SELECTALL, selectall);
- CACHE_IMAGE(PREFERENCES, preferences);
- CACHE_IMAGE(ZOOMPLUS, zoomplus);
- CACHE_IMAGE(ZOOMMINUS, zoomminus);
- CACHE_IMAGE(ZOOMNORMAL, zoomnormal);
- CACHE_IMAGE(FULLSCREEN, fullscreen);
- CACHE_IMAGE(VIEWSOURCE, viewsource);
- CACHE_IMAGE(CONTENTS, helpcontents);
- CACHE_IMAGE(ABOUT, helpabout);
- CACHE_IMAGE(PDF, pdf);
- CACHE_IMAGE(PLAINTEXT, plaintext);
- CACHE_IMAGE(DRAWFILE, drawfile);
- CACHE_IMAGE(POSTSCRIPT, postscript);
- CACHE_IMAGE(FIND, find);
- CACHE_IMAGE(DOWNLOADS, downloads);
- CACHE_IMAGE(SAVEWINDOWSIZE, savewindowsize);
- CACHE_IMAGE(TOGGLEDEBUGGING, toggledebugging);
- CACHE_IMAGE(SAVEBOXTREE, boxtree);
- CACHE_IMAGE(SAVEDOMTREE, domtree);
- CACHE_IMAGE(LOCALHISTORY, localhistory);
- CACHE_IMAGE(GLOBALHISTORY, globalhistory);
- CACHE_IMAGE(ADDBOOKMARKS, addbookmarks);
- CACHE_IMAGE(SHOWBOOKMARKS, showbookmarks);
- CACHE_IMAGE(OPENLOCATION, openlocation);
- CACHE_IMAGE(NEXTTAB, nexttab);
- CACHE_IMAGE(PREVTAB, prevtab);
- CACHE_IMAGE(GUIDE, helpguide);
- CACHE_IMAGE(INFO, helpinfo);
+#define CACHE_IMAGE(p, q, r)\
+ nsgtk_theme_cache_image(p##_BUTTON, #q ".png", r)
+
+ CACHE_IMAGE(BACK, back, path);
+ CACHE_IMAGE(HISTORY, history, path);
+ CACHE_IMAGE(FORWARD, forward, path);
+ CACHE_IMAGE(STOP, stop, path);
+ CACHE_IMAGE(RELOAD, reload, path);
+ CACHE_IMAGE(HOME, home, path);
+ CACHE_IMAGE(NEWWINDOW, newwindow, path);
+ CACHE_IMAGE(NEWTAB, newtab, path);
+ CACHE_IMAGE(OPENFILE, openfile, path);
+ CACHE_IMAGE(CLOSETAB, closetab, path);
+ CACHE_IMAGE(CLOSEWINDOW, closewindow, path);
+ CACHE_IMAGE(SAVEPAGE, savepage, path);
+ CACHE_IMAGE(PRINTPREVIEW, printpreview, path);
+ CACHE_IMAGE(PRINT, print, path);
+ CACHE_IMAGE(QUIT, quit, path);
+ CACHE_IMAGE(CUT, cut, path);
+ CACHE_IMAGE(COPY, copy, path);
+ CACHE_IMAGE(PASTE, paste, path);
+ CACHE_IMAGE(DELETE, delete, path);
+ CACHE_IMAGE(SELECTALL, selectall, path);
+ CACHE_IMAGE(PREFERENCES, preferences, path);
+ CACHE_IMAGE(ZOOMPLUS, zoomplus, path);
+ CACHE_IMAGE(ZOOMMINUS, zoomminus, path);
+ CACHE_IMAGE(ZOOMNORMAL, zoomnormal, path);
+ CACHE_IMAGE(FULLSCREEN, fullscreen, path);
+ CACHE_IMAGE(VIEWSOURCE, viewsource, path);
+ CACHE_IMAGE(CONTENTS, helpcontents, path);
+ CACHE_IMAGE(ABOUT, helpabout, path);
+ CACHE_IMAGE(PDF, pdf, path);
+ CACHE_IMAGE(PLAINTEXT, plaintext, path);
+ CACHE_IMAGE(DRAWFILE, drawfile, path);
+ CACHE_IMAGE(POSTSCRIPT, postscript, path);
+ CACHE_IMAGE(FIND, find, path);
+ CACHE_IMAGE(DOWNLOADS, downloads, path);
+ CACHE_IMAGE(SAVEWINDOWSIZE, savewindowsize, path);
+ CACHE_IMAGE(TOGGLEDEBUGGING, toggledebugging, path);
+ CACHE_IMAGE(SAVEBOXTREE, boxtree, path);
+ CACHE_IMAGE(SAVEDOMTREE, domtree, path);
+ CACHE_IMAGE(LOCALHISTORY, localhistory, path);
+ CACHE_IMAGE(GLOBALHISTORY, globalhistory, path);
+ CACHE_IMAGE(ADDBOOKMARKS, addbookmarks, path);
+ CACHE_IMAGE(SHOWBOOKMARKS, showbookmarks, path);
+ CACHE_IMAGE(OPENLOCATION, openlocation, path);
+ CACHE_IMAGE(NEXTTAB, nexttab, path);
+ CACHE_IMAGE(PREVTAB, prevtab, path);
+ CACHE_IMAGE(GUIDE, helpguide, path);
+ CACHE_IMAGE(INFO, helpinfo, path);
#undef CACHE_IMAGE
-#define CACHE_IMAGE(p, q)\
- len = SLEN(#q ".png") + strlen(path) + 1;\
- filename = malloc(len);\
- if (filename == NULL) {\
- warn_user(messages_get("NoMemory"), 0);\
- free(path);\
- return;\
- }\
- snprintf(filename, len, "%s" #q ".png", path);\
- if (theme_cache_toolbar != NULL)\
- theme_cache_toolbar->searchimage[p] =\
- gdk_pixbuf_new_from_file_at_size(filename,\
- 24, 24, NULL);\
- if (theme_cache_menu != NULL)\
- theme_cache_menu->searchimage[p] =\
- gdk_pixbuf_new_from_file_at_size(filename,\
- 16, 16, NULL);\
- free(filename)
-
- CACHE_IMAGE(SEARCH_BACK_BUTTON, searchback);
- CACHE_IMAGE(SEARCH_FORWARD_BUTTON, searchforward);
- CACHE_IMAGE(SEARCH_CLOSE_BUTTON, searchclose);
+#define CACHE_IMAGE(p, q, r)\
+ nsgtk_theme_cache_searchimage(p, #q ".png", r);
+
+ CACHE_IMAGE(SEARCH_BACK_BUTTON, searchback, path);
+ CACHE_IMAGE(SEARCH_FORWARD_BUTTON, searchforward, path);
+ CACHE_IMAGE(SEARCH_CLOSE_BUTTON, searchclose, path);
#undef CACHE_IMAGE
}
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 Sun Aug 30 00:16:28 2009
@@ -201,16 +201,15 @@
}
glade_xml_signal_autoconnect(window->glade);
-#define GET_TOOLWIDGET(p, q) window->p = glade_xml_get_widget(window->glade,\
- #q);\
- if (window->p == NULL) {\
+#define GET_TOOLWIDGET(p, q, r, s) r->p = glade_xml_get_widget(r->s, #q);\
+ if (r->p == NULL) {\
warn_user(messages_get("NoMemory"), 0);\
nsgtk_toolbar_cancel_clicked(NULL, g);\
return;\
}
- GET_TOOLWIDGET(window, toolbarwindow)
- GET_TOOLWIDGET(widgetvbox, widgetvbox)
+ GET_TOOLWIDGET(window, toolbarwindow, window, glade)
+ GET_TOOLWIDGET(widgetvbox, widgetvbox, window, glade)
#undef GET_TOOLWIDGET
window->numberh = NSGTK_STORE_WIDTH; /* preset to width [in buttons] of */
@@ -670,48 +669,41 @@
GtkWidget *nsgtk_toolbar_make_widget(nsgtk_scaffolding *g,
nsgtk_toolbar_button i, struct nsgtk_theme *theme)
{
- GtkWidget *w = NULL, *image = NULL, *entry = NULL,
- *al = NULL;
- char *label = NULL;
- GtkStockItem item;
- switch(i){
+ switch(i) {
/* gtk_tool_button_new() accepts NULL args */
-#define MAKE_STOCKBUTTON(p, q) case p##_BUTTON:\
+#define MAKE_STOCKBUTTON(p, q) case p##_BUTTON: {\
+ GtkStockItem item;\
+ char *label = NULL;\
gtk_stock_lookup(#q, &item);\
if (item.label != NULL)\
label = remove_underscores(item.label, false);\
- w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(\
+ GtkWidget *w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(\
theme->image[p##_BUTTON]), label));\
if (label != NULL) {\
free(label);\
label = NULL;\
}\
- break
+ return w;\
+ }
- MAKE_STOCKBUTTON(HOME, gtk-home);
- MAKE_STOCKBUTTON(BACK, gtk-go-back);
- MAKE_STOCKBUTTON(FORWARD, gtk-go-forward);
- MAKE_STOCKBUTTON(STOP, gtk-stop);
- MAKE_STOCKBUTTON(RELOAD, gtk-refresh);
+ MAKE_STOCKBUTTON(HOME, gtk-home)
+ MAKE_STOCKBUTTON(BACK, gtk-go-back)
+ MAKE_STOCKBUTTON(FORWARD, gtk-go-forward)
+ MAKE_STOCKBUTTON(STOP, gtk-stop)
+ MAKE_STOCKBUTTON(RELOAD, gtk-refresh)
#undef MAKE_STOCKBUTTON
case HISTORY_BUTTON:
- w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(
+ return GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(
theme->image[HISTORY_BUTTON]), NULL));
- break;
case URL_BAR_ITEM: {
- size_t len = strlen(res_dir_location) +
- SLEN("html.png") + 1;
- label = malloc(len);
- if (label == NULL) {
- warn_user(messages_get("NoMemory"), 0);
- return NULL;
- }
- snprintf(label, len, "%shtml.png", res_dir_location);
- image = GTK_WIDGET(gtk_image_new_from_file(label));
- free(label);
- entry = GTK_WIDGET(sexy_icon_entry_new());
- w = GTK_WIDGET(gtk_tool_item_new());
+ char imagefile[strlen(res_dir_location) + SLEN("html.png")
+ + 1];
+ sprintf(imagefile, "%shtml.png", res_dir_location);
+ GtkWidget *image = GTK_WIDGET(gtk_image_new_from_file(
+ imagefile));
+ GtkWidget *entry = GTK_WIDGET(sexy_icon_entry_new());
+ GtkWidget *w = GTK_WIDGET(gtk_tool_item_new());
if ((entry == NULL) || (w == NULL)) {
warn_user(messages_get("NoMemory"), 0);
return NULL;
@@ -723,9 +715,9 @@
GTK_IMAGE(image));
gtk_container_add(GTK_CONTAINER(w), entry);
gtk_tool_item_set_expand(GTK_TOOL_ITEM(w), TRUE);
- break;
- }
- case THROBBER_ITEM:
+ return w;
+ }
+ case THROBBER_ITEM: {
if (edit_mode)
return GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(
gtk_image_new_from_pixbuf(
@@ -735,10 +727,10 @@
NULL) || (nsgtk_throbber->framedata[0] ==
NULL))
return NULL;
- image = GTK_WIDGET(gtk_image_new_from_pixbuf(
+ GtkWidget *image = GTK_WIDGET(gtk_image_new_from_pixbuf(
nsgtk_throbber->framedata[0]));
- w = GTK_WIDGET(gtk_tool_item_new());
- al = GTK_WIDGET(gtk_alignment_new(0.1,0.1,0.8,0.8));
+ GtkWidget *w = GTK_WIDGET(gtk_tool_item_new());
+ GtkWidget *al = GTK_WIDGET(gtk_alignment_new(0.1,0.1,0.8,0.8));
if ((w == NULL) || (al == NULL)) {
warn_user(messages_get("NoMemory"), 0);
return NULL;
@@ -747,17 +739,18 @@
if (image != NULL)
gtk_container_add(GTK_CONTAINER(al), image);
gtk_container_add(GTK_CONTAINER(w), al);
- break;
- case WEBSEARCH_ITEM:
+ return w;
+ }
+ case WEBSEARCH_ITEM: {
if (edit_mode)
return GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(
gtk_image_new_from_stock("gtk-find",
GTK_ICON_SIZE_LARGE_TOOLBAR)),
"[websearch]"));
- image = GTK_WIDGET(gtk_image_new_from_stock("gtk-info",
- GTK_ICON_SIZE_LARGE_TOOLBAR));
- entry = GTK_WIDGET(sexy_icon_entry_new());
- w = GTK_WIDGET(gtk_tool_item_new());
+ GtkWidget *image = GTK_WIDGET(gtk_image_new_from_stock(
+ "gtk-info", GTK_ICON_SIZE_LARGE_TOOLBAR));
+ GtkWidget *entry = GTK_WIDGET(sexy_icon_entry_new());
+ GtkWidget *w = GTK_WIDGET(gtk_tool_item_new());
if ((entry == NULL) || (w == NULL)) {
warn_user(messages_get("NoMemory"), 0);
return NULL;
@@ -770,63 +763,65 @@
SEXY_ICON_ENTRY_PRIMARY,
GTK_IMAGE(image));
gtk_container_add(GTK_CONTAINER(w), entry);
- break;
+ return w;
+ }
/* gtk_tool_button_new accepts NULL args */
-#define MAKE_MENUBUTTON(p, q) case p##_BUTTON:\
+#define MAKE_MENUBUTTON(p, q) case p##_BUTTON: {\
+ char *label = NULL;\
label = remove_underscores(messages_get(#q), false);\
- w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(\
+ GtkWidget *w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(\
theme->image[p##_BUTTON]), label));\
if (label != NULL)\
free(label);\
- break
+ return w;\
+ }
- MAKE_MENUBUTTON(NEWWINDOW, gtkNewWindow);
- MAKE_MENUBUTTON(NEWTAB, gtkNewTab);
- MAKE_MENUBUTTON(OPENFILE, gtkOpenFile);
- MAKE_MENUBUTTON(CLOSETAB, gtkCloseTab);
- MAKE_MENUBUTTON(CLOSEWINDOW, gtkCloseWindow);
- MAKE_MENUBUTTON(SAVEPAGE, gtkSavePage);
- MAKE_MENUBUTTON(PRINTPREVIEW, gtkPrintPreview);
- MAKE_MENUBUTTON(PRINT, gtkPrint);
- MAKE_MENUBUTTON(QUIT, gtkQuitMenu);
- MAKE_MENUBUTTON(CUT, gtkCut);
- MAKE_MENUBUTTON(COPY, gtkCopy);
- MAKE_MENUBUTTON(PASTE, gtkPaste);
- MAKE_MENUBUTTON(DELETE, gtkDelete);
- MAKE_MENUBUTTON(SELECTALL, gtkSelectAll);
- MAKE_MENUBUTTON(PREFERENCES, gtkPreferences);
- MAKE_MENUBUTTON(ZOOMPLUS, gtkZoomPlus);
- MAKE_MENUBUTTON(ZOOMMINUS, gtkZoomMinus);
- MAKE_MENUBUTTON(ZOOMNORMAL, gtkZoomNormal);
- MAKE_MENUBUTTON(FULLSCREEN, gtkFullScreen);
- MAKE_MENUBUTTON(VIEWSOURCE, gtkViewSource);
- MAKE_MENUBUTTON(CONTENTS, gtkContents);
- MAKE_MENUBUTTON(ABOUT, gtkAbout);
- MAKE_MENUBUTTON(PDF, gtkPDF);
- MAKE_MENUBUTTON(PLAINTEXT, gtkPlainText);
- MAKE_MENUBUTTON(DRAWFILE, gtkDrawFile);
- MAKE_MENUBUTTON(POSTSCRIPT, gtkPostScript);
- MAKE_MENUBUTTON(FIND, gtkFind);
- MAKE_MENUBUTTON(DOWNLOADS, gtkDownloads);
- MAKE_MENUBUTTON(SAVEWINDOWSIZE, gtkSaveWindowSize);
- MAKE_MENUBUTTON(TOGGLEDEBUGGING, gtkToggleDebugging);
- MAKE_MENUBUTTON(SAVEBOXTREE, gtkSaveBoxTree);
- MAKE_MENUBUTTON(SAVEDOMTREE, gtkSaveDomTree);
- MAKE_MENUBUTTON(LOCALHISTORY, gtkLocalHistory);
- MAKE_MENUBUTTON(GLOBALHISTORY, gtkGlobalHistory);
- MAKE_MENUBUTTON(ADDBOOKMARKS, gtkAddBookMarks);
- MAKE_MENUBUTTON(SHOWBOOKMARKS, gtkShowBookMarks);
- MAKE_MENUBUTTON(OPENLOCATION, gtkOpenLocation);
- MAKE_MENUBUTTON(NEXTTAB, gtkNextTab);
- MAKE_MENUBUTTON(PREVTAB, gtkPrevTab);
- MAKE_MENUBUTTON(GUIDE, gtkGuide);
- MAKE_MENUBUTTON(INFO, gtkUserInformation);
+ MAKE_MENUBUTTON(NEWWINDOW, gtkNewWindow)
+ MAKE_MENUBUTTON(NEWTAB, gtkNewTab)
+ MAKE_MENUBUTTON(OPENFILE, gtkOpenFile)
+ MAKE_MENUBUTTON(CLOSETAB, gtkCloseTab)
+ MAKE_MENUBUTTON(CLOSEWINDOW, gtkCloseWindow)
+ MAKE_MENUBUTTON(SAVEPAGE, gtkSavePage)
+ MAKE_MENUBUTTON(PRINTPREVIEW, gtkPrintPreview)
+ MAKE_MENUBUTTON(PRINT, gtkPrint)
+ MAKE_MENUBUTTON(QUIT, gtkQuitMenu)
+ MAKE_MENUBUTTON(CUT, gtkCut)
+ MAKE_MENUBUTTON(COPY, gtkCopy)
+ MAKE_MENUBUTTON(PASTE, gtkPaste)
+ MAKE_MENUBUTTON(DELETE, gtkDelete)
+ MAKE_MENUBUTTON(SELECTALL, gtkSelectAll)
+ MAKE_MENUBUTTON(PREFERENCES, gtkPreferences)
+ MAKE_MENUBUTTON(ZOOMPLUS, gtkZoomPlus)
+ MAKE_MENUBUTTON(ZOOMMINUS, gtkZoomMinus)
+ MAKE_MENUBUTTON(ZOOMNORMAL, gtkZoomNormal)
+ MAKE_MENUBUTTON(FULLSCREEN, gtkFullScreen)
+ MAKE_MENUBUTTON(VIEWSOURCE, gtkViewSource)
+ MAKE_MENUBUTTON(CONTENTS, gtkContents)
+ MAKE_MENUBUTTON(ABOUT, gtkAbout)
+ MAKE_MENUBUTTON(PDF, gtkPDF)
+ MAKE_MENUBUTTON(PLAINTEXT, gtkPlainText)
+ MAKE_MENUBUTTON(DRAWFILE, gtkDrawFile)
+ MAKE_MENUBUTTON(POSTSCRIPT, gtkPostScript)
+ MAKE_MENUBUTTON(FIND, gtkFind)
+ MAKE_MENUBUTTON(DOWNLOADS, gtkDownloads)
+ MAKE_MENUBUTTON(SAVEWINDOWSIZE, gtkSaveWindowSize)
+ MAKE_MENUBUTTON(TOGGLEDEBUGGING, gtkToggleDebugging)
+ MAKE_MENUBUTTON(SAVEBOXTREE, gtkSaveBoxTree)
+ MAKE_MENUBUTTON(SAVEDOMTREE, gtkSaveDomTree)
+ MAKE_MENUBUTTON(LOCALHISTORY, gtkLocalHistory)
+ MAKE_MENUBUTTON(GLOBALHISTORY, gtkGlobalHistory)
+ MAKE_MENUBUTTON(ADDBOOKMARKS, gtkAddBookMarks)
+ MAKE_MENUBUTTON(SHOWBOOKMARKS, gtkShowBookMarks)
+ MAKE_MENUBUTTON(OPENLOCATION, gtkOpenLocation)
+ MAKE_MENUBUTTON(NEXTTAB, gtkNextTab)
+ MAKE_MENUBUTTON(PREVTAB, gtkPrevTab)
+ MAKE_MENUBUTTON(GUIDE, gtkGuide)
+ MAKE_MENUBUTTON(INFO, gtkUserInformation)
default:
- break;
+ return NULL;
#undef MAKE_MENUBUTTON
}
- return w;
}
/**
@@ -922,92 +917,92 @@
}
}
-#define DATAHANDLER(p, q)\
+#define DATAHANDLER(p, q, r)\
gboolean nsgtk_toolbar_##p##_button_data(GtkWidget *widget, GdkDragContext\
*cont, GtkSelectionData *selection, guint info, guint time,\
gpointer data)\
{\
- window->currentbutton = q##_BUTTON;\
- window->fromstore = true;\
+ r->currentbutton = q##_BUTTON;\
+ r->fromstore = true;\
return TRUE;\
}\
gboolean nsgtk_toolbar_##p##_toolbar_button_data(GtkWidget *widget,\
GdkDragContext *cont, GtkSelectionData *selection, guint info,\
guint time, gpointer data)\
{\
- window->currentbutton = q##_BUTTON;\
- window->fromstore = false;\
+ r->currentbutton = q##_BUTTON;\
+ r->fromstore = false;\
return TRUE;\
}
-
-DATAHANDLER(home, HOME)
-DATAHANDLER(forward, FORWARD)
-DATAHANDLER(back, BACK)
-DATAHANDLER(stop, STOP)
-DATAHANDLER(reload, RELOAD)
-DATAHANDLER(history, HISTORY)
-DATAHANDLER(newwindow, NEWWINDOW);
-DATAHANDLER(newtab, NEWTAB);
-DATAHANDLER(openfile, OPENFILE);
-DATAHANDLER(closetab, CLOSETAB);
-DATAHANDLER(closewindow, CLOSEWINDOW);
-DATAHANDLER(savepage, SAVEPAGE);
-DATAHANDLER(printpreview, PRINTPREVIEW);
-DATAHANDLER(print, PRINT);
-DATAHANDLER(quit, QUIT);
-DATAHANDLER(cut, CUT);
-DATAHANDLER(copy, COPY);
-DATAHANDLER(paste, PASTE);
-DATAHANDLER(delete, DELETE);
-DATAHANDLER(selectall, SELECTALL);
-DATAHANDLER(preferences, PREFERENCES);
-DATAHANDLER(zoomplus, ZOOMPLUS);
-DATAHANDLER(zoomminus, ZOOMMINUS);
-DATAHANDLER(zoomnormal, ZOOMNORMAL);
-DATAHANDLER(fullscreen, FULLSCREEN);
-DATAHANDLER(viewsource, VIEWSOURCE);
-DATAHANDLER(contents, CONTENTS);
-DATAHANDLER(about, ABOUT);
-DATAHANDLER(pdf, PDF);
-DATAHANDLER(plaintext, PLAINTEXT);
-DATAHANDLER(drawfile, DRAWFILE);
-DATAHANDLER(postscript, POSTSCRIPT);
-DATAHANDLER(find, FIND);
-DATAHANDLER(downloads, DOWNLOADS);
-DATAHANDLER(savewindowsize, SAVEWINDOWSIZE);
-DATAHANDLER(toggledebugging, TOGGLEDEBUGGING);
-DATAHANDLER(saveboxtree, SAVEBOXTREE);
-DATAHANDLER(savedomtree, SAVEDOMTREE);
-DATAHANDLER(localhistory, LOCALHISTORY);
-DATAHANDLER(globalhistory, GLOBALHISTORY);
-DATAHANDLER(addbookmarks, ADDBOOKMARKS);
-DATAHANDLER(showbookmarks, SHOWBOOKMARKS);
-DATAHANDLER(openlocation, OPENLOCATION);
-DATAHANDLER(nexttab, NEXTTAB);
-DATAHANDLER(prevtab, PREVTAB);
-DATAHANDLER(guide, GUIDE);
-DATAHANDLER(info, INFO);
+
+DATAHANDLER(home, HOME, window)
+DATAHANDLER(forward, FORWARD, window)
+DATAHANDLER(back, BACK, window)
+DATAHANDLER(stop, STOP, window)
+DATAHANDLER(reload, RELOAD, window)
+DATAHANDLER(history, HISTORY, window)
+DATAHANDLER(newwindow, NEWWINDOW, window)
+DATAHANDLER(newtab, NEWTAB, window)
+DATAHANDLER(openfile, OPENFILE, window)
+DATAHANDLER(closetab, CLOSETAB, window)
+DATAHANDLER(closewindow, CLOSEWINDOW, window)
+DATAHANDLER(savepage, SAVEPAGE, window)
+DATAHANDLER(printpreview, PRINTPREVIEW, window)
+DATAHANDLER(print, PRINT, window)
+DATAHANDLER(quit, QUIT, window)
+DATAHANDLER(cut, CUT, window)
+DATAHANDLER(copy, COPY, window)
+DATAHANDLER(paste, PASTE, window)
+DATAHANDLER(delete, DELETE, window)
+DATAHANDLER(selectall, SELECTALL, window)
+DATAHANDLER(preferences, PREFERENCES, window)
+DATAHANDLER(zoomplus, ZOOMPLUS, window)
+DATAHANDLER(zoomminus, ZOOMMINUS, window)
+DATAHANDLER(zoomnormal, ZOOMNORMAL, window)
+DATAHANDLER(fullscreen, FULLSCREEN, window)
+DATAHANDLER(viewsource, VIEWSOURCE, window)
+DATAHANDLER(contents, CONTENTS, window)
+DATAHANDLER(about, ABOUT, window)
+DATAHANDLER(pdf, PDF, window)
+DATAHANDLER(plaintext, PLAINTEXT, window)
+DATAHANDLER(drawfile, DRAWFILE, window)
+DATAHANDLER(postscript, POSTSCRIPT, window)
+DATAHANDLER(find, FIND, window)
+DATAHANDLER(downloads, DOWNLOADS, window)
+DATAHANDLER(savewindowsize, SAVEWINDOWSIZE, window)
+DATAHANDLER(toggledebugging, TOGGLEDEBUGGING, window)
+DATAHANDLER(saveboxtree, SAVEBOXTREE, window)
+DATAHANDLER(savedomtree, SAVEDOMTREE, window)
+DATAHANDLER(localhistory, LOCALHISTORY, window)
+DATAHANDLER(globalhistory, GLOBALHISTORY, window)
+DATAHANDLER(addbookmarks, ADDBOOKMARKS, window)
+DATAHANDLER(showbookmarks, SHOWBOOKMARKS, window)
+DATAHANDLER(openlocation, OPENLOCATION, window)
+DATAHANDLER(nexttab, NEXTTAB, window)
+DATAHANDLER(prevtab, PREVTAB, window)
+DATAHANDLER(guide, GUIDE, window)
+DATAHANDLER(info, INFO, window)
#undef DATAHANDLER
-#define DATAHANDLER(p, q)\
+#define DATAHANDLER(p, q, r)\
gboolean nsgtk_toolbar_##p##_button_data(GtkWidget *widget, GdkDragContext\
*cont, GtkSelectionData *selection, guint info, guint time,\
gpointer data)\
{\
- window->currentbutton = q##_ITEM;\
- window->fromstore = true;\
+ r->currentbutton = q##_ITEM;\
+ r->fromstore = true;\
return TRUE;\
}\
gboolean nsgtk_toolbar_##p##_toolbar_button_data(GtkWidget *widget,\
GdkDragContext *cont, GtkSelectionData *selection, guint info,\
guint time, gpointer data)\
{\
- window->currentbutton = q##_ITEM;\
- window->fromstore = false;\
+ r->currentbutton = q##_ITEM;\
+ r->fromstore = false;\
return TRUE;\
}
-DATAHANDLER(throbber, THROBBER);
-DATAHANDLER(websearch, WEBSEARCH);
+DATAHANDLER(throbber, THROBBER, window)
+DATAHANDLER(websearch, WEBSEARCH, window)
#undef DATAHANDLER
/**
13 years, 7 months
r9502 jmb - in /trunk/libcss/src: stylesheet.c stylesheet.h utils/utils.h
by netsurf@semichrome.net
Author: jmb
Date: Sat Aug 29 18:38:32 2009
New Revision: 9502
URL: http://source.netsurf-browser.org?rev=9502&view=rev
Log:
1) Allocate css_style bytecode in 16 byte chunks
2) Cache unused css_style objects with chunks of size 16, 32, 48, and 64 bytes
The above should reduce heap churn somewhat.
Further improvements are possible:
1) Make the property parsers write the parsed values direct into the output
bytecode, instead of into a temporary object which is then merged into
the output.
2) Perform similar caching for css_rule and selector objects.
3) Shrink-wrap finalised output styles rather than leaving them oversized.
4) Perform measurement to determine the optimal chunk sizes (power-of-2 makes
maths simple and 16 is plucked from thin air) and cache bucket count/sizes.
Modified:
trunk/libcss/src/stylesheet.c
trunk/libcss/src/stylesheet.h
trunk/libcss/src/utils/utils.h
Modified: trunk/libcss/src/stylesheet.c
URL: http://source.netsurf-browser.org/trunk/libcss/src/stylesheet.c?rev=9502&...
==============================================================================
--- trunk/libcss/src/stylesheet.c (original)
+++ trunk/libcss/src/stylesheet.c Sat Aug 29 18:38:32 2009
@@ -162,6 +162,7 @@
*/
css_error css_stylesheet_destroy(css_stylesheet *sheet)
{
+ uint32_t bucket;
css_rule *r, *s;
if (sheet == NULL)
@@ -185,6 +186,17 @@
css_selector_hash_destroy(sheet->selectors);
+ /* Release cached free styles */
+ for (bucket = 0; bucket != N_ELEMENTS(sheet->free_styles); bucket++) {
+ while (sheet->free_styles[bucket] != NULL) {
+ css_style *s = sheet->free_styles[bucket];
+
+ sheet->free_styles[bucket] = s->bytecode;
+
+ sheet->alloc(s, 0, sheet->pw);
+ }
+ }
+
/* These two may have been destroyed when parsing completed */
if (sheet->parser_frontend != NULL)
css_language_destroy(sheet->parser_frontend);
@@ -228,6 +240,7 @@
css_error css_stylesheet_data_done(css_stylesheet *sheet)
{
const css_rule *r;
+ uint32_t bucket;
css_error error;
if (sheet == NULL)
@@ -246,6 +259,17 @@
sheet->parser_frontend = NULL;
sheet->parser = NULL;
+
+ /* Release cached free styles */
+ for (bucket = 0; bucket != N_ELEMENTS(sheet->free_styles); bucket++) {
+ while (sheet->free_styles[bucket] != NULL) {
+ css_style *s = sheet->free_styles[bucket];
+
+ sheet->free_styles[bucket] = s->bytecode;
+
+ sheet->alloc(s, 0, sheet->pw);
+ }
+ }
/* Determine if there are any pending imports */
for (r = sheet->rule_list; r != NULL; r = r->next) {
@@ -565,13 +589,21 @@
css_style **style)
{
css_style *s;
+ const uint32_t alloclen = ((len + 15) & ~15);
+ const uint32_t bucket = (alloclen / N_ELEMENTS(sheet->free_styles)) - 1;
if (sheet == NULL || len == 0 || style == NULL)
return CSS_BADPARM;
- s = sheet->alloc(NULL, sizeof(css_style) + len, sheet->pw);
- if (s == NULL)
- return CSS_NOMEM;
+ if (bucket < N_ELEMENTS(sheet->free_styles) &&
+ sheet->free_styles[bucket] != NULL) {
+ s = sheet->free_styles[bucket];
+ sheet->free_styles[bucket] = s->bytecode;
+ } else {
+ s = sheet->alloc(NULL, sizeof(css_style) + alloclen, sheet->pw);
+ if (s == NULL)
+ return CSS_NOMEM;
+ }
/* DIY variable-sized data member */
s->bytecode = ((uint8_t *) s + sizeof(css_style));
@@ -593,10 +625,20 @@
*/
css_error css_stylesheet_style_destroy(css_stylesheet *sheet, css_style *style)
{
+ uint32_t alloclen, bucket;
+
if (sheet == NULL || style == NULL)
return CSS_BADPARM;
- sheet->alloc(style, 0, sheet->pw);
+ alloclen = ((style->length + 15) & ~15);
+ bucket = (alloclen / N_ELEMENTS(sheet->free_styles)) - 1;
+
+ if (bucket < N_ELEMENTS(sheet->free_styles)) {
+ style->bytecode = sheet->free_styles[bucket];
+ sheet->free_styles[bucket] = style;
+ } else {
+ sheet->alloc(style, 0, sheet->pw);
+ }
return CSS_OK;
}
@@ -1067,20 +1109,31 @@
if (cur != NULL) {
/* Already have a style, so append to the end of the bytecode */
- css_style *temp = sheet->alloc(cur,
- sizeof(css_style) + cur->length + style->length,
- sheet->pw);
- if (temp == NULL)
- return CSS_NOMEM;
-
- /* Ensure bytecode pointer is correct */
- temp->bytecode = ((uint8_t *) temp + sizeof(css_style));
+ const uint32_t reqlen = cur->length + style->length;
+ const uint32_t curlen = ((cur->length + 15) & ~15);
+
+ if (curlen < reqlen) {
+ css_style *temp;
+ css_error error;
+
+ error = css_stylesheet_style_create(sheet,
+ reqlen, &temp);
+ if (error != CSS_OK)
+ return error;
+
+ memcpy((uint8_t *) temp->bytecode, cur->bytecode,
+ cur->length);
+ temp->length = cur->length;
+
+ css_stylesheet_style_destroy(sheet, cur);
+
+ cur = temp;
+ }
/** \todo Can we optimise the bytecode here? */
- memcpy((uint8_t *) temp->bytecode + temp->length,
+ memcpy((uint8_t *) cur->bytecode + cur->length,
style->bytecode, style->length);
- cur = temp;
cur->length += style->length;
/* Add this to the sheet's size */
Modified: trunk/libcss/src/stylesheet.h
URL: http://source.netsurf-browser.org/trunk/libcss/src/stylesheet.h?rev=9502&...
==============================================================================
--- trunk/libcss/src/stylesheet.h (original)
+++ trunk/libcss/src/stylesheet.h Sat Aug 29 18:38:32 2009
@@ -24,7 +24,6 @@
typedef struct css_rule css_rule;
typedef struct css_selector css_selector;
-/** \todo would a parserutils_buffer be better here? */
typedef struct css_style {
uint32_t length; /**< Length, in bytes, of bytecode */
void *bytecode; /**< Pointer to bytecode */
@@ -177,6 +176,8 @@
size_t size; /**< Size, in bytes */
+ css_style *free_styles[4]; /**< Free styles: 16B buckets */
+
css_url_resolution_fn resolve; /**< URL resolution function */
void *resolve_pw; /**< Private word */
Modified: trunk/libcss/src/utils/utils.h
URL: http://source.netsurf-browser.org/trunk/libcss/src/utils/utils.h?rev=9502...
==============================================================================
--- trunk/libcss/src/utils/utils.h (original)
+++ trunk/libcss/src/utils/utils.h Sat Aug 29 18:38:32 2009
@@ -28,6 +28,10 @@
#ifndef UNUSED
#define UNUSED(x) ((x)=(x))
+#endif
+
+#ifndef N_ELEMENTS
+#define N_ELEMENTS(x) (sizeof((x)) / sizeof((x)[0]))
#endif
css_fixed number_from_lwc_string(lwc_string *string, bool int_only,
13 years, 7 months
r9501 jmb - /trunk/tools/buildsystem/makefiles/Makefile.tools
by netsurf@semichrome.net
Author: jmb
Date: Sat Aug 29 18:20:10 2009
New Revision: 9501
URL: http://source.netsurf-browser.org?rev=9501&view=rev
Log:
Fix RISC OS default CXX.
Modified:
trunk/tools/buildsystem/makefiles/Makefile.tools
Modified: trunk/tools/buildsystem/makefiles/Makefile.tools
URL: http://source.netsurf-browser.org/trunk/tools/buildsystem/makefiles/Makef...
==============================================================================
--- trunk/tools/buildsystem/makefiles/Makefile.tools (original)
+++ trunk/tools/buildsystem/makefiles/Makefile.tools Sat Aug 29 18:20:10 2009
@@ -91,7 +91,7 @@
AR__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*ar)
CC__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
- CXX__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN/*g++)
+ CXX__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++)
CMHG ?= PATH="$(GCCSDK_INSTALL_CROSSBIN):$(PATH)" $(GCCSDK_INSTALL_CROSSBIN)/cmunge
GENHTML ?= echo
LCOV ?= echo
13 years, 7 months