summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--!NetSurf/Resources/en/Messages2
-rw-r--r--!NetSurf/Resources/en/Templates,fecbin6478 -> 6298 bytes
-rw-r--r--!NetSurf/Resources/fr/Messages2
-rw-r--r--!NetSurf/Resources/fr/Templates,fecbin6580 -> 6404 bytes
-rw-r--r--riscos/dialog.c467
-rw-r--r--riscos/gui.c4
-rw-r--r--riscos/gui.h15
-rw-r--r--riscos/menus.c2
-rw-r--r--riscos/theme.c110
-rw-r--r--riscos/theme.h10
-rw-r--r--riscos/wimp.c60
-rw-r--r--riscos/wimp.h2
12 files changed, 423 insertions, 251 deletions
diff --git a/!NetSurf/Resources/en/Messages b/!NetSurf/Resources/en/Messages
index 01386df66..52a355a0b 100644
--- a/!NetSurf/Resources/en/Messages
+++ b/!NetSurf/Resources/en/Messages
@@ -86,6 +86,8 @@ DragError:An error occurred when dragging the icon:
TbarError:An error occurred when constructing the toolbar:
WimpError:An unexpected Window Manager error occurred:
Template:A window template is missing from the Templates file. Please reinstall NetSurf.
+MiscError:An unexpected error occurred:
+FileError:File does not exist:
# Some general purpose words and phrases
Bytes: B
diff --git a/!NetSurf/Resources/en/Templates,fec b/!NetSurf/Resources/en/Templates,fec
index f6ce5ec67..7398f2f09 100644
--- a/!NetSurf/Resources/en/Templates,fec
+++ b/!NetSurf/Resources/en/Templates,fec
Binary files differ
diff --git a/!NetSurf/Resources/fr/Messages b/!NetSurf/Resources/fr/Messages
index 1c77c4d65..7a783a616 100644
--- a/!NetSurf/Resources/fr/Messages
+++ b/!NetSurf/Resources/fr/Messages
@@ -86,6 +86,8 @@ DragError:An error occurred when dragging the icon:
TbarError:An error occurred when constructing the toolbar:
WimpError:An unexpected Window Manager error occurred:
Template:A window template is missing from the Templates file. Please reinstall NetSurf.
+MiscError:An unexpected error occurred:
+FileError:File does not exist:
Bytes: O
kBytes: kO
diff --git a/!NetSurf/Resources/fr/Templates,fec b/!NetSurf/Resources/fr/Templates,fec
index bd28d32a3..0f10e5998 100644
--- a/!NetSurf/Resources/fr/Templates,fec
+++ b/!NetSurf/Resources/fr/Templates,fec
Binary files differ
diff --git a/riscos/dialog.c b/riscos/dialog.c
index dbb1687ca..8df308dfb 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -21,6 +21,7 @@
#include "netsurf/riscos/constdata.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/options.h"
+#include "netsurf/riscos/theme.h"
#include "netsurf/riscos/wimp.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
@@ -32,18 +33,23 @@ wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
dialog_401li,
#endif
dialog_zoom, dialog_pageinfo, dialog_objinfo, dialog_tooltip,
- dialog_warning;
-wimp_menu* theme_menu = NULL;
+ dialog_warning, dialog_config_th_pane;
static int font_size;
static int font_min_size;
+static char *theme_choice = 0;
+static struct theme_entry *theme_list = 0;
+static unsigned int theme_list_entries = 0;
static void ro_gui_dialog_click_config(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_br(wimp_pointer *pointer);
static void ro_gui_dialog_update_config_br(void);
static void ro_gui_dialog_click_config_prox(wimp_pointer *pointer);
+static void ro_gui_dialog_open_config_th(void);
static void ro_gui_dialog_click_config_th(wimp_pointer *pointer);
+static void ro_gui_dialog_click_config_th_pane(wimp_pointer *pointer);
+static void ro_gui_redraw_config_th_pane_plot(wimp_draw *redraw);
static void ro_gui_dialog_click_zoom(wimp_pointer *pointer);
static void ro_gui_dialog_reset_zoom(void);
static void ro_gui_dialog_click_warning(wimp_pointer *pointer);
@@ -53,10 +59,6 @@ static void set_proxy_choices(void);
static void get_proxy_choices(void);
static void set_theme_choices(void);
static void get_theme_choices(void);
-static void load_theme_preview(char* thname);
-/*static void ro_gui_destroy_theme_menu(void);*/
-static void ro_gui_build_theme_menu(void);
-static int file_exists(const char* base, const char* dir, const char* leaf, bits ftype);
static const char *language_name(const char *code);
@@ -75,6 +77,7 @@ void ro_gui_dialog_init(void)
dialog_config_br = ro_gui_dialog_create("config_br");
dialog_config_prox = ro_gui_dialog_create("config_prox");
dialog_config_th = ro_gui_dialog_create("config_th");
+ dialog_config_th_pane = ro_gui_dialog_create("config_th_pa");
dialog_zoom = ro_gui_dialog_create("zoom");
dialog_pageinfo = ro_gui_dialog_create("pageinfo");
dialog_objinfo = ro_gui_dialog_create("objectinfo");
@@ -184,7 +187,7 @@ wimp_window * ro_gui_dialog_load_template(const char *template_name)
void ro_gui_dialog_open(wimp_w w)
{
int screen_x, screen_y, dx, dy;
- wimp_window_state open;
+ wimp_window_state open;
/* find screen centre in os units */
ro_gui_screen_size(&screen_x, &screen_y);
@@ -234,6 +237,8 @@ void ro_gui_dialog_click(wimp_pointer *pointer)
ro_gui_dialog_click_config_prox(pointer);
else if (pointer->w == dialog_config_th)
ro_gui_dialog_click_config_th(pointer);
+ else if (pointer->w == dialog_config_th_pane)
+ ro_gui_dialog_click_config_th_pane(pointer);
#ifdef WITH_AUTH
else if (pointer->w == dialog_401li)
ro_gui_401login_click(pointer);
@@ -256,7 +261,7 @@ void ro_gui_dialog_click_config(wimp_pointer *pointer)
get_browser_choices();
get_proxy_choices();
get_theme_choices();
- xosfile_create_dir("<Choices$Write>.WWW", 0);
+ xosfile_create_dir("<Choices$Write>.WWW", 0);
xosfile_create_dir("<Choices$Write>.WWW.NetSurf", 0);
options_write("<Choices$Write>.WWW.NetSurf.Choices");
if (pointer->buttons == wimp_CLICK_SELECT) {
@@ -284,7 +289,7 @@ void ro_gui_dialog_click_config(wimp_pointer *pointer)
ro_gui_dialog_open(dialog_config_prox);
break;
case ICON_CONFIG_THEME:
- ro_gui_dialog_open(dialog_config_th);
+ ro_gui_dialog_open_config_th();
break;
}
}
@@ -373,6 +378,24 @@ void ro_gui_dialog_click_config_prox(wimp_pointer *pointer)
/**
+ * Prepare and open the Theme Choices dialog.
+ */
+
+void ro_gui_dialog_open_config_th(void)
+{
+ if (theme_list)
+ ro_theme_list_free(theme_list, theme_list_entries);
+
+ theme_list = ro_theme_list(&theme_list_entries);
+ if (!theme_list)
+ return;
+
+ ro_gui_dialog_open(dialog_config_th);
+ ro_gui_dialog_open(dialog_config_th_pane);
+}
+
+
+/**
* Handle clicks in the Theme Choices dialog.
*/
@@ -388,12 +411,6 @@ void ro_gui_dialog_click_config_th(wimp_pointer *pointer)
ro_gui_dialog_close(dialog_config_th);
set_theme_choices();
break;
- case ICON_CONFIG_TH_NAME:
- case ICON_CONFIG_TH_PICK:
- ro_gui_build_theme_menu();
- ro_gui_popup_menu(theme_menu, dialog_config_th,
- ICON_CONFIG_TH_PICK);
- break;
case ICON_CONFIG_TH_MANAGE:
os_cli("Filer_OpenDir " THEMES_DIR);
break;
@@ -404,6 +421,174 @@ void ro_gui_dialog_click_config_th(wimp_pointer *pointer)
}
+#define THEME_HEIGHT 80
+
+/**
+ * Handle clicks in the scrolling Theme Choices list pane.
+ */
+
+void ro_gui_dialog_click_config_th_pane(wimp_pointer *pointer)
+{
+ unsigned int i, y;
+ wimp_window_state state;
+ os_error *error;
+
+ state.w = dialog_config_th_pane;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ LOG(("xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+
+ y = -(pointer->pos.y - (state.visible.y1 - state.yscroll)) /
+ THEME_HEIGHT;
+
+ if (!theme_list || theme_list_entries <= y)
+ return;
+
+ if (theme_choice && strcmp(theme_choice, theme_list[y].name) == 0)
+ return;
+
+ if (theme_choice) {
+ for (i = 0; i != theme_list_entries &&
+ strcmp(theme_choice, theme_list[i].name); i++)
+ ;
+ if (i != theme_list_entries) {
+ error = xwimp_force_redraw(dialog_config_th_pane,
+ 0, -i * THEME_HEIGHT - THEME_HEIGHT - 2,
+ 600, -i * THEME_HEIGHT + 2);
+ if (error) {
+ LOG(("xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+ }
+ }
+
+ free(theme_choice);
+ theme_choice = strdup(theme_list[y].name);
+
+ error = xwimp_force_redraw(dialog_config_th_pane,
+ 0, -y * THEME_HEIGHT - THEME_HEIGHT - 2,
+ 600, -y * THEME_HEIGHT + 2);
+ if (error) {
+ LOG(("xwimp_force_redraw: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+}
+
+
+/**
+ * Redraw the scrolling Theme Choices list pane.
+ */
+
+void ro_gui_redraw_config_th_pane(wimp_draw *redraw)
+{
+ osbool more;
+ os_error *error;
+
+ error = xwimp_redraw_window(redraw, &more);
+ if (error) {
+ LOG(("xwimp_redraw_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+ while (more) {
+ ro_gui_redraw_config_th_pane_plot(redraw);
+ error = xwimp_get_rectangle(redraw, &more);
+ if (error) {
+ LOG(("xwimp_get_rectangle: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+ }
+}
+
+
+/**
+ * Redraw the scrolling Theme Choices list pane.
+ */
+
+void ro_gui_redraw_config_th_pane_plot(wimp_draw *redraw)
+{
+ unsigned int i, j;
+ int x0 = redraw->box.x0 - redraw->xscroll;
+ int y0 = redraw->box.y1 - redraw->yscroll;
+ int x;
+ static char sprite[][10] = { "back", "forward", "stop", "reload",
+ "history", "scale", "save" };
+ wimp_icon icon;
+ os_error *error = 0;
+
+ icon.flags = wimp_ICON_SPRITE | wimp_ICON_HCENTRED |
+ wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED;
+
+ for (i = 0; i != theme_list_entries; i++) {
+ error = xwimptextop_set_colour(os_COLOUR_BLACK,
+ os_COLOUR_VERY_LIGHT_GREY);
+ if (error)
+ break;
+
+ /* plot background for selected theme */
+ if (theme_choice &&
+ strcmp(theme_list[i].name, theme_choice) == 0) {
+ error = xcolourtrans_set_gcol(os_COLOUR_LIGHT_GREY,
+ 0, os_ACTION_OVERWRITE, 0, 0);
+ if (error)
+ break;
+ error = xos_plot(os_MOVE_TO, x0, y0 - i * THEME_HEIGHT);
+ if (error)
+ break;
+ error = xos_plot(os_PLOT_RECTANGLE | os_PLOT_BY,
+ 600, -THEME_HEIGHT);
+ if (error)
+ break;
+ error = xwimptextop_set_colour(os_COLOUR_BLACK,
+ os_COLOUR_LIGHT_GREY);
+ if (error)
+ break;
+ }
+
+ /* icons */
+ icon.extent.y0 = -i * THEME_HEIGHT - THEME_HEIGHT;
+ icon.extent.y1 = -i * THEME_HEIGHT;
+ icon.data.indirected_sprite.area = theme_list[i].sprite_area;
+ icon.data.indirected_sprite.size = 12;
+ for (j = 0, x = 0; j != sizeof sprite / sizeof sprite[0]; j++) {
+ icon.extent.x0 = x;
+ icon.extent.x1 = x + 50;
+ icon.data.indirected_sprite.id =
+ (osspriteop_id) sprite[j];
+ error = xwimp_plot_icon(&icon);
+ if (error)
+ break;
+ x += 50;
+ }
+ if (error)
+ break;
+
+ /* theme name */
+ error = xwimptextop_paint(0, theme_list[i].name,
+ x0 + 400,
+ y0 - i * THEME_HEIGHT - THEME_HEIGHT / 2);
+ if (error)
+ break;
+ }
+
+ if (error) {
+ LOG(("0x%x: %s", error->errnum, error->errmess));
+ warn_user("MiscError", error->errmess);
+ }
+}
+
+
/**
* Handle clicks in the Scale view dialog.
*/
@@ -450,11 +635,12 @@ void ro_gui_dialog_click_zoom(wimp_pointer *pointer)
}
-/*
- * Resets the Scale view dialog
+/**
+ * Resets the Scale view dialog.
*/
+
void ro_gui_dialog_reset_zoom(void) {
- char scale_buffer[8];
+ char scale_buffer[8];
sprintf(scale_buffer, "%.0f", current_gui->scale * 100);
ro_gui_set_icon_string(dialog_zoom, ICON_ZOOM_VALUE, scale_buffer);
}
@@ -477,7 +663,31 @@ void ro_gui_dialog_click_warning(wimp_pointer *pointer)
void ro_gui_dialog_close(wimp_w close)
{
- wimp_close_window(close);
+ os_error *error;
+
+ error = xwimp_close_window(close);
+ if (error) {
+ LOG(("xwimp_close_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+
+ if (close == dialog_config_th) {
+ error = xwimp_close_window(dialog_config_th_pane);
+
+ if (theme_list) {
+ ro_theme_list_free(theme_list, theme_list_entries);
+ theme_list = 0;
+ }
+
+ if (error) {
+ LOG(("xwimp_close_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ return;
+ }
+ }
}
@@ -545,9 +755,10 @@ void get_proxy_choices(void)
void set_theme_choices(void)
{
- ro_gui_set_icon_string(dialog_config_th, ICON_CONFIG_TH_NAME,
- option_theme ? option_theme : "Default");
- load_theme_preview(option_theme ? option_theme : "Default");
+ free(theme_choice);
+ theme_choice = 0;
+ if (option_theme)
+ theme_choice = strdup(option_theme);
}
@@ -558,220 +769,10 @@ void set_theme_choices(void)
void get_theme_choices(void)
{
free(option_theme);
- option_theme = strdup(ro_gui_get_icon_string(dialog_config_th,
- ICON_CONFIG_TH_NAME));
+ option_theme = strdup(theme_choice);
}
-osspriteop_area* theme_preview = NULL;
-
-void load_theme_preview(char* thname)
-{
-if (theme_preview != NULL)
- xfree(theme_preview);
-
-theme_preview = NULL;
-
- if (file_exists(THEMES_DIR, thname, "Preview", 0xff9))
- {
-char filename[256];
-FILE* fp;
-int size;
-
-
- sprintf(filename, "%s.%s.Preview", THEMES_DIR, thname);
- fp = fopen(filename, "rb");
- if (fp == 0) return;
- if (fseek(fp, 0, SEEK_END) != 0) die("fseek() failed");
- if ((size = (int) ftell(fp)) == -1) die("ftell() failed");
- fclose(fp);
-
- theme_preview = xcalloc((unsigned int)(size + 16), 1);
- if (theme_preview == NULL)
- return;
-
- theme_preview->size = size + 16;
- theme_preview->sprite_count = 0;
- theme_preview->first = 16;
- theme_preview->used = 16;
- osspriteop_clear_sprites(osspriteop_USER_AREA, theme_preview);
- osspriteop_load_sprite_file(osspriteop_USER_AREA, theme_preview, filename);
-
-
- }
-}
-
-void ro_gui_redraw_config_th(wimp_draw* redraw)
-{
- int x, y, size;
- osbool more;
- wimp_icon_state preview;
- wimp_window_state win;
- osspriteop_trans_tab* trans_tab;
-
- win.w = dialog_config_th;
- wimp_get_window_state(&win);
-
- preview.w = dialog_config_th;
- preview.i = ICON_CONFIG_TH_PREVIEW;
- wimp_get_icon_state(&preview);
-
- if (theme_preview != NULL)
- {
- x = preview.icon.extent.x0 + win.visible.x0 + 4;
- y = preview.icon.extent.y0 + win.visible.y1 + 4;
-
- xcolourtrans_generate_table_for_sprite(theme_preview,
- (osspriteop_id)"preview",
- (os_mode)-1,
- (os_palette const*)-1,
- 0, 0, 0, 0, &size);
- trans_tab = malloc((unsigned int)(size + 32));
- xcolourtrans_generate_table_for_sprite(theme_preview,
- (osspriteop_id)"preview",
- (os_mode)-1,
- (os_palette const*)-1,
- trans_tab, 0, 0, 0, &size);
-
- more = wimp_redraw_window(redraw);
- while (more)
- {
- xosspriteop_put_sprite_scaled(osspriteop_NAME, theme_preview,
- (osspriteop_id)"preview", x, y,
- (osspriteop_action)osspriteop_USE_MASK |
- osspriteop_USE_PALETTE,
- 0, trans_tab);
- more = wimp_get_rectangle(redraw);
- }
-
- xfree(trans_tab);
- }
- else
- {
- preview.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED | wimp_ICON_HCENTRED | wimp_ICON_VCENTRED | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | (wimp_COLOUR_VERY_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT);
- preview.icon.data.indirected_text.text = "No preview available";
- preview.icon.data.indirected_text.size = 21;
-
- more = wimp_redraw_window(redraw);
- while (more)
- {
- wimp_plot_icon(&preview.icon);
- more = wimp_get_rectangle(redraw);
- }
-
- }
- return;
-
-}
-
-
-/**
- * Construct or update theme_menu by scanning THEMES_DIR.
- */
-
-void ro_gui_build_theme_menu(void)
-{
- unsigned int i;
- static unsigned int entries = 0;
- int context = 0;
- int read_count;
- osgbpb_INFO(100) info;
-
- if (theme_menu) {
- /* free entry text buffers */
- for (i = 0; i != entries; i++)
- free(theme_menu->entries[i].data.indirected_text.text);
- } else {
- theme_menu = xcalloc(1, wimp_SIZEOF_MENU(1));
- theme_menu->title_data.indirected_text.text =
- messages_get("Themes");
- theme_menu->title_fg = wimp_COLOUR_BLACK;
- theme_menu->title_bg = wimp_COLOUR_LIGHT_GREY;
- theme_menu->work_fg = wimp_COLOUR_BLACK;
- theme_menu->work_bg = wimp_COLOUR_WHITE;
- theme_menu->width = 256;
- theme_menu->height = 44;
- theme_menu->gap = 0;
- }
-
- i = 0;
- while (context != -1) {
- context = osgbpb_dir_entries_info(THEMES_DIR,
- (osgbpb_info_list *) &info, 1, context,
- sizeof(info), 0, &read_count);
- if (read_count == 0)
- continue;
- if (info.obj_type != fileswitch_IS_DIR)
- continue;
- if (!file_exists(THEMES_DIR, info.name, "Sprites", 0xff9))
- continue;
-
- theme_menu = xrealloc(theme_menu, wimp_SIZEOF_MENU(i + 1));
-
- theme_menu->entries[i].menu_flags = 0;
- if (option_theme && strcmp(info.name, option_theme) == 0)
- theme_menu->entries[i].menu_flags |= wimp_MENU_TICKED;
- theme_menu->entries[i].sub_menu = wimp_NO_SUB_MENU;
- theme_menu->entries[i].icon_flags = wimp_ICON_TEXT |
- wimp_ICON_FILLED | wimp_ICON_INDIRECTED |
- (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) |
- (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT);
- theme_menu->entries[i].data.indirected_text.text =
- xstrdup(info.name);
- theme_menu->entries[i].data.indirected_text.validation = (char*)-1;
- theme_menu->entries[i].data.indirected_text.size =
- strlen(info.name) + 1;
-
- i++;
- }
- if (i == 0) {
- theme_menu->entries[0].menu_flags = 0;
- theme_menu->entries[0].sub_menu = wimp_NO_SUB_MENU;
- theme_menu->entries[0].icon_flags = wimp_ICON_TEXT |
- wimp_ICON_FILLED | wimp_ICON_INDIRECTED |
- (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) |
- (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT) |
- wimp_ICON_SHADED;
- theme_menu->entries[0].data.indirected_text.text = xstrdup("-");
- theme_menu->entries[0].data.indirected_text.validation = (char*)-1;
- theme_menu->entries[0].data.indirected_text.size = 2;
- i = 1;
- }
- entries = i;
-
- theme_menu->entries[0].menu_flags |= wimp_MENU_TITLE_INDIRECTED;
- theme_menu->entries[i - 1].menu_flags |= wimp_MENU_LAST;
-}
-
-
-
-
-void ro_gui_theme_menu_selection(char *theme)
-{
- ro_gui_set_icon_string(dialog_config_th, ICON_CONFIG_TH_NAME, theme);
- load_theme_preview(theme);
- wimp_set_icon_state(dialog_config_th, ICON_CONFIG_TH_PREVIEW, 0, 0);
-}
-
-int file_exists(const char* base, const char* dir, const char* leaf, bits ftype)
-{
- char buffer[256];
- fileswitch_object_type type;
- bits load, exec;
- int size;
- fileswitch_attr attr;
- bits file_type;
-
- snprintf(buffer, 255, "%s.%s.%s", base, dir, leaf);
- LOG(("checking %s", buffer));
- if (xosfile_read_stamped_no_path(buffer, &type, &load, &exec, &size, &attr, &file_type) == NULL)
- {
- return (type == 1 && ftype == file_type);
- }
-
- return 0;
-}
-
/**
* Convert a 2-letter ISO language code to the language name.
*
diff --git a/riscos/gui.c b/riscos/gui.c
index e5d4af80c..7f50bb260 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -596,8 +596,8 @@ void ro_gui_redraw_window_request(wimp_draw *redraw)
{
gui_window *g;
- if (redraw->w == dialog_config_th)
- ro_gui_redraw_config_th(redraw);
+ if (redraw->w == dialog_config_th_pane)
+ ro_gui_redraw_config_th_pane(redraw);
else if (redraw->w == history_window)
ro_gui_history_redraw(redraw);
else {
diff --git a/riscos/gui.h b/riscos/gui.h
index 4d0f94a52..18822d445 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -23,9 +23,9 @@
extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
dialog_config_prox, dialog_config_th, dialog_zoom, dialog_pageinfo,
- dialog_objinfo, dialog_tooltip, dialog_warning;
+ dialog_objinfo, dialog_tooltip, dialog_warning, dialog_config_th_pane;
extern wimp_w history_window;
-extern wimp_menu *iconbar_menu, *browser_menu, *combo_menu, *theme_menu;
+extern wimp_menu *iconbar_menu, *browser_menu, *combo_menu;
extern int iconbar_menu_height;
extern struct form_control *current_gadget;
extern gui_window *window_list;
@@ -124,8 +124,7 @@ void ro_gui_dialog_open(wimp_w w);
void ro_gui_dialog_click(wimp_pointer *pointer);
bool ro_gui_dialog_keypress(wimp_key *key);
void ro_gui_dialog_close(wimp_w close);
-void ro_gui_redraw_config_th(wimp_draw* redraw);
-void ro_gui_theme_menu_selection(char *theme);
+void ro_gui_redraw_config_th_pane(wimp_draw *redraw);
/* in download.c */
void ro_gui_download_init(void);
@@ -242,12 +241,8 @@ void schedule_run(void);
#define ICON_CONFIG_TH_OK 0
#define ICON_CONFIG_TH_CANCEL 1
-#define ICON_CONFIG_TH_DEFAULT 2
-#define ICON_CONFIG_TH_NAME 4
-#define ICON_CONFIG_TH_PICK 5
-#define ICON_CONFIG_TH_PREVIEW 7
-#define ICON_CONFIG_TH_GET 8
-#define ICON_CONFIG_TH_MANAGE 9
+#define ICON_CONFIG_TH_GET 2
+#define ICON_CONFIG_TH_MANAGE 3
#define ICON_DOWNLOAD_URL 0
#define ICON_DOWNLOAD_STATUS 1
diff --git a/riscos/menus.c b/riscos/menus.c
index 7e713d6e2..a756451b5 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -556,8 +556,6 @@ void ro_gui_menu_selection(wimp_selection *selection)
break;
}
- } else if (current_menu == theme_menu && theme_menu != NULL) {
- ro_gui_theme_menu_selection(theme_menu->entries[selection->items[0]].data.indirected_text.text);
}
if (pointer.buttons == wimp_CLICK_ADJUST) {
diff --git a/riscos/theme.c b/riscos/theme.c
index 505f66edf..fb74a3ddd 100644
--- a/riscos/theme.c
+++ b/riscos/theme.c
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <string.h>
#include "oslib/os.h"
+#include "oslib/osgbpb.h"
#include "oslib/osfile.h"
#include "oslib/osspriteop.h"
#include "oslib/wimp.h"
@@ -304,3 +305,112 @@ int ro_theme_resize_toolbar(gui_window *g) {
}
return return_value;
}
+
+
+/**
+ * Make a list of available themes.
+ *
+ * \param entries updated to number of themes
+ * \return array of struct theme_entry, or 0 on error, and error reported
+ */
+
+struct theme_entry *ro_theme_list(unsigned int *entries)
+{
+ char pathname[256];
+ unsigned int i = 0, n = 0;
+ int context = 0;
+ int read_count;
+ struct theme_entry *list = 0, *list1;
+ fileswitch_object_type obj_type;
+ int file_type;
+ osgbpb_INFO(100) info;
+ os_error *error;
+
+ /* invariant: list[0..n) are valid */
+ while (context != -1) {
+ error = xosgbpb_dir_entries_info(THEMES_DIR,
+ (osgbpb_info_list *) &info, 1, context,
+ sizeof(info), 0, &read_count, &context);
+ if (error) {
+ LOG(("xosgbpb_dir_entries_info: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("MiscError", error->errmess);
+ ro_theme_list_free(list, n);
+ return 0;
+ }
+
+ if (read_count == 0)
+ continue;
+ if (info.obj_type != fileswitch_IS_DIR)
+ continue;
+
+ /* check for presence of Sprites in directory */
+ snprintf(pathname, sizeof pathname, "%s.%s.%s",
+ THEMES_DIR, info.name, "Sprites");
+ pathname[sizeof pathname - 1] = 0;
+ error = xosfile_read_stamped_no_path(pathname,
+ &obj_type, 0, 0, 0, 0, &file_type);
+ if (error) {
+ LOG(("xosfile_read_stamped_no_path: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("MiscError", error->errmess);
+ ro_theme_list_free(list, n);
+ return 0;
+ }
+ if (obj_type != fileswitch_IS_FILE ||
+ file_type != osfile_TYPE_SPRITE)
+ continue;
+
+ /* expand list */
+ list1 = realloc(list, sizeof *list * (i + 1));
+ if (!list1) {
+ warn_user("NoMemory", 0);
+ ro_theme_list_free(list, n);
+ return 0;
+ }
+ list = list1;
+
+ /* update invariant */
+ list[i].name = 0;
+ list[i].sprite_area = 0;
+ n = i + 1;
+
+ /* copy name */
+ list[i].name = strdup(info.name);
+ if (!list[i].name) {
+ warn_user("NoMemory", 0);
+ ro_theme_list_free(list, n);
+ return 0;
+ }
+
+ /* load sprites */
+ list[i].sprite_area = ro_gui_load_sprite_file(pathname);
+ if (!list[i].sprite_area) {
+ ro_theme_list_free(list, n);
+ return 0;
+ }
+
+ i++;
+ }
+
+ *entries = n;
+ return list;
+}
+
+
+/**
+ * Free an array of themes, as returned by ro_theme_list().
+ *
+ * \param list array of struct theme_entry
+ * \param entries size of array
+ */
+
+void ro_theme_list_free(struct theme_entry *list, unsigned int entries)
+{
+ unsigned int i;
+ for (i = 0; i != entries; i++) {
+ free(list[i].name);
+ free(list[i].sprite_area);
+ }
+ free(list);
+}
diff --git a/riscos/theme.h b/riscos/theme.h
index c04c6aa6e..3f22f7af6 100644
--- a/riscos/theme.h
+++ b/riscos/theme.h
@@ -17,7 +17,13 @@
#ifndef _NETSURF_RISCOS_THEME_H_
#define _NETSURF_RISCOS_THEME_H_
-#include "oslib/wimp.h"
+#include "oslib/osspriteop.h"
+#include "netsurf/desktop/gui.h"
+
+struct theme_entry {
+ char *name;
+ osspriteop_area *sprite_area;
+};
extern int theme_throbs;
@@ -25,5 +31,7 @@ void ro_theme_load(char *pathname);
void ro_theme_create_toolbar(gui_window *g);
int ro_theme_update_toolbar(gui_window *g);
int ro_theme_resize_toolbar(gui_window *g);
+struct theme_entry *ro_theme_list(unsigned int *entries);
+void ro_theme_list_free(struct theme_entry *list, unsigned int entries);
#endif
diff --git a/riscos/wimp.c b/riscos/wimp.c
index 0c8a3a3f8..5cfc2728d 100644
--- a/riscos/wimp.c
+++ b/riscos/wimp.c
@@ -14,9 +14,11 @@
#include <stdlib.h>
#include <stdio.h>
#include "oslib/os.h"
+#include "oslib/osfile.h"
#include "oslib/wimp.h"
#include "oslib/wimpextend.h"
#include "oslib/wimpreadsysinfo.h"
+#include "netsurf/desktop/gui.h"
#include "netsurf/riscos/wimp.h"
#include "netsurf/utils/log.h"
@@ -29,14 +31,14 @@ static wimpextend_furniture_sizes furniture_sizes;
*/
int ro_get_hscroll_height(wimp_w w) {
wimp_version_no version;
-
-
+
+
/* Read the hscroll height
*/
furniture_sizes.w = w;
furniture_sizes.border_widths.y0 = 38;
xwimpextend_get_furniture_sizes(&furniture_sizes);
-
+
/* There is a quirk with the returned size as it differs between versions of the
WindowManager module. The incorrect height is returned by the version distributed
with the universal boot sequence (3.98) and presumably any previous version.
@@ -216,3 +218,55 @@ int ro_gui_get_icon_selected_state(wimp_w w, wimp_i i) {
* \param state selected state
*/
#define ro_gui_set_icon_shaded_state(w, i, state) xwimp_set_icon_state(w, i, (state ? wimp_ICON_SHADED : 0), wimp_ICON_SHADED)
+
+
+/**
+ * Load a sprite file into memory.
+ *
+ * \param pathname file to load
+ * \return sprite area, or 0 on memory exhaustion or error and error reported
+ */
+
+osspriteop_area *ro_gui_load_sprite_file(const char *pathname)
+{
+ int len;
+ fileswitch_object_type obj_type;
+ osspriteop_area *area;
+ os_error *error;
+
+ error = xosfile_read_stamped_no_path(pathname,
+ &obj_type, 0, 0, &len, 0, 0);
+ if (error) {
+ LOG(("xosfile_read_stamped_no_path: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("MiscError", error->errmess);
+ return 0;
+ }
+ if (obj_type != fileswitch_IS_FILE) {
+ warn_user("FileError", pathname);
+ return 0;
+ }
+
+ area = malloc(len + 4);
+ if (!area) {
+ warn_user("NoMemory", 0);
+ return 0;
+ }
+
+ area->size = len + 4;
+ area->sprite_count = 0;
+ area->first = 16;
+ area->used = 16;
+
+ error = xosspriteop_load_sprite_file(osspriteop_USER_AREA,
+ area, pathname);
+ if (error) {
+ LOG(("xosspriteop_load_sprite_file: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("MiscError", error->errmess);
+ free(area);
+ return 0;
+ }
+
+ return area;
+}
diff --git a/riscos/wimp.h b/riscos/wimp.h
index e80a4f7d1..3ac3ed4c4 100644
--- a/riscos/wimp.h
+++ b/riscos/wimp.h
@@ -39,4 +39,6 @@ void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value);
int ro_gui_get_icon_selected_state(wimp_w w, wimp_i i);
#define ro_gui_set_icon_shaded_state(w, i, state) xwimp_set_icon_state(w, i, (state ? wimp_ICON_SHADED : 0), wimp_ICON_SHADED)
+osspriteop_area *ro_gui_load_sprite_file(const char *pathname);
+
#endif