summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2005-01-13 22:42:39 +0000
committerJames Bursa <james@netsurf-browser.org>2005-01-13 22:42:39 +0000
commitf0b264670e57d1eefd6f7e297b87cedf38d8be9a (patch)
treea9f2680f01e5cb9dab890b83ce05954a87bc8793 /riscos
parenta76404dfd076925eebeb8166f588e0d5e7a9fdd3 (diff)
downloadnetsurf-f0b264670e57d1eefd6f7e297b87cedf38d8be9a.tar.gz
netsurf-f0b264670e57d1eefd6f7e297b87cedf38d8be9a.tar.bz2
[project @ 2005-01-13 22:42:38 by bursa]
Start on theme auto-install. Fix content_add_user() not to broadcast error on memory exhaustion. svn path=/import/netsurf/; revision=1448
Diffstat (limited to 'riscos')
-rw-r--r--riscos/gui.c1
-rw-r--r--riscos/gui.h9
-rw-r--r--riscos/theme_install.c111
3 files changed, 120 insertions, 1 deletions
diff --git a/riscos/gui.c b/riscos/gui.c
index 8ef2d561f..f7e8fa12c 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -258,6 +258,7 @@ void gui_init(int argc, char** argv)
ro_gui_401login_init();
#endif
ro_gui_history_init();
+ ro_gui_theme_install_init();
wimp_close_template();
ro_gui_sprites_init();
ro_gui_tree_initialise(); /* must be done after sprite loading */
diff --git a/riscos/gui.h b/riscos/gui.h
index bf5db9b85..0d25890bc 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -30,7 +30,7 @@ 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_config_th_pane, dialog_debug, dialog_folder, dialog_entry,
- dialog_search, dialog_print, dialog_config_font;
+ dialog_search, dialog_print, dialog_config_font, dialog_theme_install;
extern wimp_w history_window;
extern wimp_menu *iconbar_menu, *browser_menu, *combo_menu, *hotlist_menu,
*proxyauth_menu, *languages_menu, *toolbar_menu,
@@ -251,6 +251,9 @@ extern int ro_plot_origin_x;
extern int ro_plot_origin_y;
void ro_plot_set_scale(float scale);
+/* in theme_install.c */
+void ro_gui_theme_install_init(void);
+
/* toolbar types */
#define TOOLBAR_BROWSER 0
#define TOOLBAR_HOTLIST 1
@@ -414,4 +417,8 @@ void ro_plot_set_scale(float scale);
#define ICON_PRINT_PRINT 16
#define ICON_PRINT_TEXT_BLACK 20
+#define ICON_THEME_INSTALL_MESSAGE 0
+#define ICON_THEME_INSTALL_INSTALL 1
+#define ICON_THEME_INSTALL_CANCEL 2
+
#endif
diff --git a/riscos/theme_install.c b/riscos/theme_install.c
new file mode 100644
index 000000000..cdf9c0c6a
--- /dev/null
+++ b/riscos/theme_install.c
@@ -0,0 +1,111 @@
+/*
+ * 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 2005 James Bursa <bursa@users.sourceforge.net>
+ */
+
+/** \file
+ * Theme auto-installing.
+ */
+
+#include <assert.h>
+#include <stdbool.h>
+#include "netsurf/content/content.h"
+#include "netsurf/desktop/browser.h"
+#include "netsurf/riscos/gui.h"
+#include "netsurf/riscos/wimp.h"
+#include "netsurf/utils/messages.h"
+#include "netsurf/utils/utils.h"
+
+
+static bool theme_install_active = false;
+wimp_w dialog_theme_install;
+
+
+void theme_install_callback(content_msg msg, struct content *c,
+ void *p1, void *p2, union content_msg_data data);
+
+
+/**
+ * Handle a CONTENT_THEME that has started loading.
+ */
+
+void theme_install_start(struct content *c)
+{
+ assert(c);
+ assert(c->type == CONTENT_THEME);
+
+ if (theme_install_active) {
+ warn_user("ThemeInstActive", 0);
+ /* raise & centre dialog */
+ return;
+ }
+
+ if (!content_add_user(c, theme_install_callback, 0, 0)) {
+ warn_user("NoMemory", 0);
+ return;
+ }
+
+ theme_install_active = true;
+
+ ro_gui_set_icon_string(dialog_theme_install, ICON_THEME_INSTALL_MESSAGE,
+ messages_get("ThemeInstDown"));
+ ro_gui_set_icon_shaded_state(dialog_theme_install,
+ ICON_THEME_INSTALL_INSTALL, true);
+ ro_gui_dialog_open(dialog_theme_install);
+}
+
+
+/**
+ * Callback for fetchcache() for theme install fetches.
+ */
+
+void theme_install_callback(content_msg msg, struct content *c,
+ void *p1, void *p2, union content_msg_data data)
+{
+ switch (msg) {
+ case CONTENT_MSG_READY:
+ break;
+
+ case CONTENT_MSG_DONE:
+ /** \todo: parse the theme data, extract name & author,
+ * and ask the user if they want to install */
+ ro_gui_set_icon_string(dialog_theme_install,
+ ICON_THEME_INSTALL_MESSAGE,
+ "Would you like to install the theme "
+ "\"x\" by y?");
+ ro_gui_set_icon_shaded_state(dialog_theme_install,
+ ICON_THEME_INSTALL_INSTALL, false);
+ break;
+
+ case CONTENT_MSG_ERROR:
+ ro_gui_dialog_close(dialog_theme_install);
+ warn_user(data.error, 0);
+ theme_install_active = false;
+ break;
+
+ case CONTENT_MSG_STATUS:
+ break;
+
+ case CONTENT_MSG_LOADING:
+ case CONTENT_MSG_REDIRECT:
+ case CONTENT_MSG_REFORMAT:
+ case CONTENT_MSG_REDRAW:
+ case CONTENT_MSG_NEWPTR:
+ case CONTENT_MSG_AUTH:
+ default:
+ assert(0);
+ break;
+ }
+}
+
+
+/**
+ * Create theme install window.
+ */
+
+void ro_gui_theme_install_init(void)
+{
+ dialog_theme_install = ro_gui_dialog_create("themeinstall");
+}