summaryrefslogtreecommitdiff
path: root/beos
diff options
context:
space:
mode:
authorFrançois Revel <mmu_man@netsurf-browser.org>2008-06-07 02:48:31 +0000
committerFrançois Revel <mmu_man@netsurf-browser.org>2008-06-07 02:48:31 +0000
commit5e393e19ceaa1fdd698df6f5f3217091e752d3b4 (patch)
tree1fdeaf9de9100d9e245628eb97f5cdd7d077611a /beos
parent8c1a5323e6bffdcfef658cd02bac45f5d1ba5141 (diff)
downloadnetsurf-5e393e19ceaa1fdd698df6f5f3217091e752d3b4.tar.gz
netsurf-5e393e19ceaa1fdd698df6f5f3217091e752d3b4.tar.bz2
Use bundled resources instead of separate files. throbber uses 'data' type also now.
svn path=/trunk/netsurf/; revision=4297
Diffstat (limited to 'beos')
-rw-r--r--beos/beos_fetch_rsrc.cpp5
-rw-r--r--beos/beos_fetch_rsrc.h3
-rw-r--r--beos/beos_gui.cpp15
-rw-r--r--beos/beos_res.rdef18
-rw-r--r--beos/beos_throbber.cpp23
-rw-r--r--beos/res/beosdefault.css2
6 files changed, 41 insertions, 25 deletions
diff --git a/beos/beos_fetch_rsrc.cpp b/beos/beos_fetch_rsrc.cpp
index 000482055..157395c91 100644
--- a/beos/beos_fetch_rsrc.cpp
+++ b/beos/beos_fetch_rsrc.cpp
@@ -346,6 +346,11 @@ static int find_app_resources()
return err;
}
+BResources *get_app_resources()
+{
+ return gAppResources;
+}
+
void fetch_rsrc_register(void)
{
int err;
diff --git a/beos/beos_fetch_rsrc.h b/beos/beos_fetch_rsrc.h
index cf275cd02..a2da41b26 100644
--- a/beos/beos_fetch_rsrc.h
+++ b/beos/beos_fetch_rsrc.h
@@ -27,4 +27,7 @@
void fetch_rsrc_register(void);
void fetch_rsrc_unregister(void);
+class BResources;
+BResources *get_app_resources();
+
#endif
diff --git a/beos/beos_gui.cpp b/beos/beos_gui.cpp
index 233a4337e..6d1372c74 100644
--- a/beos/beos_gui.cpp
+++ b/beos/beos_gui.cpp
@@ -341,10 +341,9 @@ void gui_init(int argc, char** argv)
*/
{
#define STROF(n) #n
-#define FIND_THROB(n) find_resource(filenames[(n)], \
- "throbber/throbber" STROF(n) ".png", \
- "./beos/res/throbber/throbber" STROF(n) ".png")
- char filenames[9][PATH_MAX];
+#define FIND_THROB(n) filenames[(n)] = \
+ "throbber" STROF(n) ".png";
+ char *filenames[9];
FIND_THROB(0);
FIND_THROB(1);
FIND_THROB(2);
@@ -448,13 +447,13 @@ void gui_init(int argc, char** argv)
beos_fetch_filetype_init(buf);
/* set up stylesheet urls */
- find_resource(buf, "beosdefault.css", "./beos/res/beosdefault.css");
- default_stylesheet_url = path_to_url(buf);
+ /*find_resource(buf, "beosdefault.css", "./beos/res/beosdefault.css");*/
+ default_stylesheet_url = strdup("rsrc:/beosdefault.css,text/css");
//default_stylesheet_url = generate_default_css();
LOG(("Using '%s' as Default CSS URL", default_stylesheet_url));
- find_resource(buf, "adblock.css", "./beos/res/adblock.css");
- adblock_stylesheet_url = path_to_url(buf);
+ /*find_resource(buf, "adblock.css", "./beos/res/adblock.css");*/
+ adblock_stylesheet_url = strdup("rsrc:/adblock.css,text/css");
LOG(("Using '%s' as AdBlock CSS URL", adblock_stylesheet_url));
urldb_load(option_url_file);
diff --git a/beos/beos_res.rdef b/beos/beos_res.rdef
index 5d3aaa0d7..dbf2f6849 100644
--- a/beos/beos_res.rdef
+++ b/beos/beos_res.rdef
@@ -37,15 +37,15 @@ resource(204, "messages") #'data' import "res/messages";
/* resource(205, "netsurf.xpm") #'data' import "res/netsurf.xpm"; */
/* throbber */
-resource(400, "throbber0.png") #'PNG ' import "res/throbber/throbber0.png";
-resource(401, "throbber1.png") #'PNG ' import "res/throbber/throbber1.png";
-resource(402, "throbber2.png") #'PNG ' import "res/throbber/throbber2.png";
-resource(403, "throbber3.png") #'PNG ' import "res/throbber/throbber3.png";
-resource(404, "throbber4.png") #'PNG ' import "res/throbber/throbber4.png";
-resource(405, "throbber5.png") #'PNG ' import "res/throbber/throbber5.png";
-resource(406, "throbber6.png") #'PNG ' import "res/throbber/throbber6.png";
-resource(407, "throbber7.png") #'PNG ' import "res/throbber/throbber7.png";
-resource(408, "throbber8.png") #'PNG ' import "res/throbber/throbber8.png";
+resource(400, "throbber0.png") #'data' import "res/throbber/throbber0.png";
+resource(401, "throbber1.png") #'data' import "res/throbber/throbber1.png";
+resource(402, "throbber2.png") #'data' import "res/throbber/throbber2.png";
+resource(403, "throbber3.png") #'data' import "res/throbber/throbber3.png";
+resource(404, "throbber4.png") #'data' import "res/throbber/throbber4.png";
+resource(405, "throbber5.png") #'data' import "res/throbber/throbber5.png";
+resource(406, "throbber6.png") #'data' import "res/throbber/throbber6.png";
+resource(407, "throbber7.png") #'data' import "res/throbber/throbber7.png";
+resource(408, "throbber8.png") #'data' import "res/throbber/throbber8.png";
resource(1, "BEOS:APP_FLAGS") (#'APPF') $"01000000";
diff --git a/beos/beos_throbber.cpp b/beos/beos_throbber.cpp
index b7ae0bf14..55fce870c 100644
--- a/beos/beos_throbber.cpp
+++ b/beos/beos_throbber.cpp
@@ -26,8 +26,10 @@ extern "C" {
}
#include "beos/beos_throbber.h"
#include "beos/beos_bitmap.h"
+#include "beos/beos_fetch_rsrc.h"
#include <File.h>
+#include <Resources.h>
#include <TranslationUtils.h>
struct nsbeos_throbber *nsbeos_throbber = NULL;
@@ -44,7 +46,6 @@ struct nsbeos_throbber *nsbeos_throbber = NULL;
bool nsbeos_throbber_initialise_from_png(const int frames, ...)
{
va_list filenames;
- status_t err;
struct nsbeos_throbber *throb; /**< structure we generate */
bool errors_when_loading = false; /**< true if a frame failed */
@@ -55,7 +56,13 @@ bool nsbeos_throbber_initialise_from_png(const int frames, ...)
frames));
return false;
}
-
+
+ BResources *res = get_app_resources();
+ if (res == NULL) {
+ LOG(("Can't find resources for throbber!"));
+ return false;
+ }
+
throb = (struct nsbeos_throbber *)malloc(sizeof(throb));
throb->nframes = frames;
throb->framedata = (BBitmap **)malloc(sizeof(BBitmap *) * throb->nframes);
@@ -64,15 +71,17 @@ bool nsbeos_throbber_initialise_from_png(const int frames, ...)
for (int i = 0; i < frames; i++) {
const char *fn = va_arg(filenames, const char *);
- BFile file(fn, B_READ_ONLY);
+ const void *data;
+ size_t size;
+ data = res->LoadResource('data', fn, &size);
throb->framedata[i] = NULL;
- err = file.InitCheck();
- if (err < B_OK) {
- LOG(("Error when loading %s: %s", fn, strerror(err)));
+ if (!data) {
+ LOG(("Error when loading resource %s", fn));
errors_when_loading = true;
continue;
}
- throb->framedata[i] = BTranslationUtils::GetBitmap(&file);
+ BMemoryIO mem(data, size);
+ throb->framedata[i] = BTranslationUtils::GetBitmap(&mem);
if (throb->framedata[i] == NULL) {
LOG(("Error when loading %s: GetBitmap() returned NULL", fn));
errors_when_loading = true;
diff --git a/beos/res/beosdefault.css b/beos/res/beosdefault.css
index 9021eedd9..1101176cb 100644
--- a/beos/res/beosdefault.css
+++ b/beos/res/beosdefault.css
@@ -4,7 +4,7 @@
/* Load base stylesheet. */
-@import "default.css";
+@import "rsrc:/default.css,text/css";
/* Apply GTK specific rules. */