mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-02-22 17:34:19 +03:00
[project @ 2005-02-07 23:00:09 by rjw]
Stop toolbar scrolling by 1px, make theme saving use leafnames, improve error handling svn path=/import/netsurf/; revision=1499
This commit is contained in:
parent
d21ec26259
commit
350247a0f2
@ -31,7 +31,6 @@ static void netsurf_init(int argc, char** argv);
|
||||
static void netsurf_poll(void);
|
||||
static void netsurf_exit(void);
|
||||
static void lib_init(void);
|
||||
static void netsurf_cleanup(void);
|
||||
|
||||
|
||||
/**
|
||||
@ -74,8 +73,6 @@ void netsurf_init(int argc, char** argv)
|
||||
"machine <%s>", utsname.sysname,
|
||||
utsname.nodename, utsname.release,
|
||||
utsname.version, utsname.machine));
|
||||
|
||||
atexit(netsurf_cleanup);
|
||||
lib_init();
|
||||
url_init();
|
||||
gui_init(argc, argv);
|
||||
@ -121,12 +118,4 @@ static void lib_init(void)
|
||||
die("Failed to add encoding alias");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures NetSurf exits cleanly.
|
||||
*/
|
||||
static void netsurf_cleanup(void)
|
||||
{
|
||||
#ifdef riscos
|
||||
ro_gui_buffer_close();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -678,7 +678,7 @@ void ro_gui_dialog_config_set(void) {
|
||||
option_theme = NULL;
|
||||
}
|
||||
if (theme_choice) {
|
||||
option_theme = strdup(theme_choice->filename);
|
||||
option_theme = strdup(theme_choice->leafname);
|
||||
ro_gui_theme_apply(theme_choice);
|
||||
}
|
||||
|
||||
|
42
riscos/gui.c
42
riscos/gui.c
@ -11,6 +11,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
@ -40,6 +41,7 @@
|
||||
#include "netsurf/desktop/tree.h"
|
||||
#include "netsurf/render/font.h"
|
||||
#include "netsurf/render/html.h"
|
||||
#include "netsurf/riscos/buffer.h"
|
||||
#include "netsurf/riscos/global_history.h"
|
||||
#include "netsurf/riscos/gui.h"
|
||||
#include "netsurf/riscos/help.h"
|
||||
@ -145,7 +147,8 @@ struct ro_gui_poll_block {
|
||||
};
|
||||
struct ro_gui_poll_block *ro_gui_poll_queued_blocks = 0;
|
||||
|
||||
|
||||
static void gui_signal(int sig);
|
||||
static void ro_gui_cleanup(void);
|
||||
static void ro_gui_choose_language(void);
|
||||
static void ro_gui_check_fonts(void);
|
||||
static void ro_gui_sprites_init(void);
|
||||
@ -180,7 +183,6 @@ static char *ro_path_to_url(const char *path);
|
||||
|
||||
void gui_init(int argc, char** argv)
|
||||
{
|
||||
char theme_path[256];
|
||||
char path[40];
|
||||
os_error *error;
|
||||
int length;
|
||||
@ -188,6 +190,14 @@ void gui_init(int argc, char** argv)
|
||||
|
||||
xhourglass_start(1);
|
||||
|
||||
atexit(ro_gui_cleanup);
|
||||
signal(SIGABRT, gui_signal);
|
||||
signal(SIGFPE, gui_signal);
|
||||
signal(SIGILL, gui_signal);
|
||||
signal(SIGINT, gui_signal);
|
||||
signal(SIGSEGV, gui_signal);
|
||||
signal(SIGTERM, gui_signal);
|
||||
|
||||
/* create our choices directories */
|
||||
#ifndef NCOS
|
||||
xosfile_create_dir("<Choices$Write>.WWW", 0);
|
||||
@ -209,6 +219,9 @@ void gui_init(int argc, char** argv)
|
||||
#else
|
||||
options_read("<User$Path>.Choices.NetSurf.Choices");
|
||||
#endif
|
||||
if (!option_theme)
|
||||
option_theme = strdup("Aletheia"); /* default for no options */
|
||||
|
||||
ro_gui_choose_language();
|
||||
|
||||
url_store_load("Choices:WWW.NetSurf.URL");
|
||||
@ -280,11 +293,8 @@ void gui_init(int argc, char** argv)
|
||||
*/
|
||||
ro_gui_theme_initialise();
|
||||
descriptor = ro_gui_theme_find(option_theme);
|
||||
if (!descriptor) {
|
||||
snprintf(theme_path, 256, "%s.Resources.Theme", NETSURF_DIR);
|
||||
theme_path[255] = '\0';
|
||||
descriptor = ro_gui_theme_find(theme_path);
|
||||
}
|
||||
if (!descriptor)
|
||||
descriptor = ro_gui_theme_find("Aletheia");
|
||||
ro_gui_theme_apply(descriptor);
|
||||
|
||||
/* We don't create an Iconbar icon on NCOS */
|
||||
@ -558,6 +568,24 @@ void gui_quit(void)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles a signal
|
||||
*/
|
||||
static void gui_signal(int sig) {
|
||||
ro_gui_cleanup();
|
||||
raise(sig);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ensures the gui exits cleanly.
|
||||
*/
|
||||
void ro_gui_cleanup(void) {
|
||||
ro_gui_buffer_close();
|
||||
xhourglass_off();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Poll the OS for events (RISC OS).
|
||||
*
|
||||
|
@ -87,8 +87,6 @@ static char theme_separator_name[] = "separator\0";
|
||||
* Initialise the theme handler
|
||||
*/
|
||||
void ro_gui_theme_initialise(void) {
|
||||
/* Get an initial theme list
|
||||
*/
|
||||
theme_descriptors = ro_gui_theme_get_available();
|
||||
}
|
||||
|
||||
@ -97,8 +95,6 @@ void ro_gui_theme_initialise(void) {
|
||||
* Finalise the theme handler
|
||||
*/
|
||||
void ro_gui_theme_finalise(void) {
|
||||
/* Free all closed descriptors
|
||||
*/
|
||||
ro_gui_theme_close(theme_current, false);
|
||||
ro_gui_theme_free(theme_descriptors, true);
|
||||
}
|
||||
@ -111,23 +107,19 @@ void ro_gui_theme_finalise(void) {
|
||||
* to ro_gui_theme_get_available() unless it has been opened using
|
||||
* ro_gui_theme_open().
|
||||
*
|
||||
* \param filename the filename of the theme_descriptor to return
|
||||
* \param leafname the filename of the theme_descriptor to return
|
||||
* \return the requested theme_descriptor, or NULL if not found
|
||||
*/
|
||||
struct theme_descriptor *ro_gui_theme_find(const char *filename) {
|
||||
struct theme_descriptor *ro_gui_theme_find(const char *leafname) {
|
||||
struct theme_descriptor *descriptor;
|
||||
|
||||
/* Check for bad filename
|
||||
*/
|
||||
if (!filename) return NULL;
|
||||
if (!leafname)
|
||||
return NULL;
|
||||
|
||||
/* Work through until we find our required filename
|
||||
*/
|
||||
descriptor = theme_descriptors;
|
||||
while (descriptor) {
|
||||
if (!strcmp(filename, descriptor->filename)) return descriptor;
|
||||
descriptor = descriptor->next;
|
||||
}
|
||||
for (descriptor = theme_descriptors; descriptor; descriptor = descriptor->next)
|
||||
if ((!strcmp(leafname, descriptor->leafname)) ||
|
||||
(!strcmp(leafname, descriptor->filename))) /* legacy (preserve options) */
|
||||
return descriptor;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -231,7 +223,7 @@ static void ro_gui_theme_get_available_in_dir(const char *directory) {
|
||||
|
||||
/* Only process files
|
||||
*/
|
||||
if ((info.obj_type == fileswitch_IS_FILE) && (!ro_gui_theme_find(pathname))) {
|
||||
if ((info.obj_type == fileswitch_IS_FILE) && (!ro_gui_theme_find(info.name))) {
|
||||
|
||||
/* Get the header
|
||||
*/
|
||||
@ -280,6 +272,7 @@ static void ro_gui_theme_get_available_in_dir(const char *directory) {
|
||||
return;
|
||||
}
|
||||
strcpy(current->filename, pathname);
|
||||
current->leafname = current->filename + strlen(directory) + 1;
|
||||
|
||||
/* Link in our new descriptor
|
||||
*/
|
||||
@ -1326,7 +1319,7 @@ bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width) {
|
||||
if (toolbar->reformat_buttons) {
|
||||
extent.x1 = 16384;
|
||||
extent.y0 = 0;
|
||||
extent.y1 = toolbar->height;
|
||||
extent.y1 = toolbar->height - 2;
|
||||
xwimp_set_extent(toolbar->toolbar_handle, &extent);
|
||||
if ((parent) && (old_height != toolbar->height)) {
|
||||
ro_gui_theme_attach_toolbar(toolbar, parent);
|
||||
|
@ -2,7 +2,7 @@
|
||||
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
||||
* Licensed under the GNU General Public License,
|
||||
* http://www.opensource.org/licenses/gpl-license
|
||||
* Copyright 2004 Richard Wilson <not_ginger_matt@users.sourceforge.net>
|
||||
* Copyright 2005 Richard Wilson <info@tinct.net>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
@ -81,7 +81,8 @@ struct toolbar {
|
||||
};
|
||||
|
||||
struct theme_descriptor {
|
||||
char *filename; /**< theme filename (leaf only) */
|
||||
char *leafname; /**< theme leafname */
|
||||
char *filename; /**< theme filename */
|
||||
char name[32]; /**< theme name */
|
||||
char author[64]; /**< theme author */
|
||||
int browser_background; /**< background colour of browser toolbar */
|
||||
@ -99,7 +100,7 @@ struct theme_descriptor {
|
||||
|
||||
void ro_gui_theme_initialise(void);
|
||||
void ro_gui_theme_finalise(void);
|
||||
struct theme_descriptor *ro_gui_theme_find(const char *filename);
|
||||
struct theme_descriptor *ro_gui_theme_find(const char *leafname);
|
||||
struct theme_descriptor *ro_gui_theme_get_available(void);
|
||||
bool ro_gui_theme_read_file_header(struct theme_descriptor *descriptor,
|
||||
struct theme_file_header *file_header);
|
||||
|
Loading…
x
Reference in New Issue
Block a user