summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2013-01-24 20:00:09 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2013-01-24 20:00:09 +0000
commit18091ec1a9ab94db511ff0c01e590e1a8aa533f9 (patch)
treecd285791cb0988a03341b84682a275aa279282fd
parentdb71ffc8eae9a857e92310f5aba665adb058ff4c (diff)
downloadnetsurf-18091ec1a9ab94db511ff0c01e590e1a8aa533f9.tar.gz
netsurf-18091ec1a9ab94db511ff0c01e590e1a8aa533f9.tar.bz2
Add basic context-sensitive help.
-rw-r--r--amiga/Makefile.target5
-rwxr-xr-xamiga/agclass/amigaguide_class.c3
-rwxr-xr-xamiga/gui.c10
-rwxr-xr-xamiga/gui_options.c11
-rwxr-xr-xamiga/help.c66
-rwxr-xr-xamiga/help.h36
6 files changed, 127 insertions, 4 deletions
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index d7abea5cf..dc79479c5 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -75,11 +75,12 @@ EXETARGET := NetSurf
S_AMIGA := gui.c tree.c history.c hotlist.c schedule.c file.c \
thumbnail.c misc.c bitmap.c font.c filetype.c utf8.c login.c \
plotters.c object.c menu.c save_pdf.c arexx.c version.c \
- cookies.c context_menu.c clipboard.c \
+ cookies.c context_menu.c clipboard.c help.c font_scan.c \
launch.c search.c history_local.c download.c iff_dr2d.c \
sslcert.c gui_options.c print.c theme.c drag.c icon.c system_colour.c \
datatypes.c dt_picture.c dt_anim.c dt_sound.c plugin_hack.c \
- stringview/stringview.c stringview/urlhistory.c font_scan.c
+ stringview/stringview.c stringview/urlhistory.c \
+ agclass/amigaguide_class.c
S_AMIGA := $(addprefix amiga/,$(S_AMIGA))
# This is the final source build list
diff --git a/amiga/agclass/amigaguide_class.c b/amiga/agclass/amigaguide_class.c
index a4bebd00e..dfac7ad7a 100755
--- a/amiga/agclass/amigaguide_class.c
+++ b/amiga/agclass/amigaguide_class.c
@@ -4,11 +4,10 @@
* by Daniel "Trixie" Jedlicka
*/
+#undef __USE_INLINE__
#include "amigaguide_class.h"
-
-
struct localObjectData
{
struct NewAmigaGuide nag;
diff --git a/amiga/gui.c b/amiga/gui.c
index 08408b0a8..e544dbd60 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -53,6 +53,7 @@
#include "amiga/font.h"
#include "amiga/gui.h"
#include "amiga/gui_options.h"
+#include "amiga/help.h"
#include "amiga/history.h"
#include "amiga/history_local.h"
#include "amiga/hotlist.h"
@@ -385,6 +386,7 @@ void ami_open_resources(void)
TAG_DONE))) die(messages_get("NoMemory"));
ami_file_req_init();
+ ami_help_init(NULL);
}
void ami_set_options(void)
@@ -666,6 +668,8 @@ void ami_openscreen(void)
gui_system_colour_finalize();
gui_system_colour_init();
+
+ ami_help_new_screen(scrn);
}
void ami_openscreenfirst(void)
@@ -1002,6 +1006,7 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
else nskey = KEY_TAB;
break;
case RAWKEY_F5:
+ case RAWKEY_HELP:
// don't translate
nskey = keycode;
break;
@@ -1823,6 +1828,10 @@ void ami_handle_msg(void)
if(browser_window_reload_available(gwin->bw))
browser_window_reload(gwin->bw,false);
break;
+
+ case RAWKEY_HELP: // help
+ ami_help_open(AMI_HELP_GUI);
+ break;
}
}
}
@@ -2410,6 +2419,7 @@ void gui_quit(void)
FreeSysObject(ASOT_PORT,appport);
FreeSysObject(ASOT_PORT,sport);
+ ami_help_free();
ami_file_req_free();
ami_openurl_close();
diff --git a/amiga/gui_options.c b/amiga/gui_options.c
index d2478d67f..7e4cef584 100755
--- a/amiga/gui_options.c
+++ b/amiga/gui_options.c
@@ -33,6 +33,7 @@
#include "amiga/font.h"
#include "amiga/gui.h"
#include "amiga/gui_options.h"
+#include "amiga/help.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
#include "utils/messages.h"
@@ -1890,6 +1891,16 @@ BOOL ami_gui_opts_event(void)
return TRUE;
break;
+ case WMHI_GADGETHELP:
+ if((result & WMHI_GADGETMASK) == 0) {
+ /* Pointer not over our window */
+ ami_help_open(AMI_HELP_MAIN);
+ } else {
+ /* TODO: Make this sensitive to the tab the user is currently on */
+ ami_help_open(AMI_HELP_PREFS);
+ }
+ break;
+
case WMHI_GADGETUP:
switch(result & WMHI_GADGETMASK)
{
diff --git a/amiga/help.c b/amiga/help.c
new file mode 100755
index 000000000..214e59d96
--- /dev/null
+++ b/amiga/help.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2013 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "amiga/help.h"
+
+/* AmigaGuide class */
+#include "amiga/agclass/amigaguide_class.h"
+
+Class *AmigaGuideClass = NULL;
+Object *AmigaGuideObject = NULL;
+
+/* This array needs to match the enum in help.h */
+STRPTR context_nodes[] = {
+ "Main",
+ "GUI",
+ "Prefs",
+ NULL
+};
+
+void ami_help_init(struct Screen *screen)
+{
+ AmigaGuideClass = initAGClass();
+
+ AmigaGuideObject = NewObject(AmigaGuideClass, NULL,
+ AMIGAGUIDE_Name, "PROGDIR:NetSurf.guide",
+ AMIGAGUIDE_BaseName, "NetSurf",
+ AMIGAGUIDE_Screen, screen,
+ AMIGAGUIDE_ContextArray, context_nodes,
+ AMIGAGUIDE_ContextID, AMI_HELP_MAIN,
+ TAG_DONE);
+}
+
+void ami_help_open(ULONG node)
+{
+ SetAttrs(AmigaGuideObject, AMIGAGUIDE_ContextID, node, TAG_DONE);
+ IDoMethod(AmigaGuideObject, AGM_OPEN, NULL);
+}
+
+void ami_help_free(void)
+{
+ if (AmigaGuideObject) DisposeObject(AmigaGuideObject);
+ if (AmigaGuideClass) freeAGClass(AmigaGuideClass);
+
+ AmigaGuideObject = NULL;
+ AmigaGuideClass = NULL;
+}
+
+void ami_help_new_screen(struct Screen *screen)
+{
+ SetAttrs(AmigaGuideObject, AMIGAGUIDE_Screen, screen, TAG_DONE);
+}
diff --git a/amiga/help.h b/amiga/help.h
new file mode 100755
index 000000000..4baa2a0e2
--- /dev/null
+++ b/amiga/help.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2013 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef AMIGA_HELP_H
+#define AMIGA_HELP_H
+#include <exec/types.h>
+
+/* This enum needs to match context_array in help.c */
+enum {
+ AMI_HELP_MAIN,
+ AMI_HELP_GUI,
+ AMI_HELP_PREFS,
+};
+
+struct Screen;
+
+void ami_help_init(struct Screen *screen);
+void ami_help_open(ULONG node);
+void ami_help_free(void);
+void ami_help_new_screen(struct Screen *screen);
+#endif