summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2009-06-20 22:29:43 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2009-06-20 22:29:43 +0000
commit040da4cf7b5cdef29ee7811cd9250cade778036e (patch)
treefdecb34ba4858112417b85cfee1a054299b06f31
parent6dd385591dcda09a4b2a4fe34d812a2c33e9db02 (diff)
downloadnetsurf-040da4cf7b5cdef29ee7811cd9250cade778036e.tar.gz
Amiga Options GUI template code and a bonus "redraw" option in the menu
svn path=/trunk/netsurf/; revision=7900
-rw-r--r--Makefile.sources2
-rwxr-xr-xamiga/gui.c18
-rwxr-xr-xamiga/gui_options.c103
-rwxr-xr-xamiga/gui_options.h43
-rwxr-xr-xamiga/menu.c40
-rwxr-xr-xamiga/menu.h4
-rwxr-xr-xamiga/object.h1
7 files changed, 197 insertions, 14 deletions
diff --git a/Makefile.sources b/Makefile.sources
index d1f75a8a0..5620404f4 100644
--- a/Makefile.sources
+++ b/Makefile.sources
@@ -83,7 +83,7 @@ S_AMIGA := compat.c gui.c tree.c history.c hotlist.c schedule.c \
plotters.c object.c menu.c save_pdf.c arexx.c version.c \
cookies.c context_menu.c clipboard.c save_complete.c \
fetch_file.c fetch_mailto.c search.c history_local.c \
- download.c iff_dr2d.c sslcert.c
+ download.c iff_dr2d.c sslcert.c gui_options.c
S_AMIGA := $(addprefix amiga/,$(S_AMIGA))
# S_FRAMEBUFFER are sources purely for the framebuffer build
diff --git a/amiga/gui.c b/amiga/gui.c
index 23b5d0311..a36f04541 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -75,6 +75,7 @@
#include "amiga/font.h"
#include "amiga/download.h"
#include <graphics/blitattr.h>
+#include "amiga/gui_options.h"
#ifdef NS_AMIGA_CAIRO
#include <cairo/cairo-amigaos.h>
@@ -793,6 +794,23 @@ void ami_handle_msg(void)
continue;
}
}
+ else if(node->Type == AMINS_GUIOPTSWINDOW)
+ {
+ if(ami_gui_opts_event())
+ {
+ if(IsMinListEmpty(window_list))
+ {
+ /* last window closed, so exit */
+ netsurf_quit = true;
+ }
+ break;
+ }
+ else
+ {
+ node = nnode;
+ continue;
+ }
+ }
while((result = RA_HandleInput(gwin->objects[OID_MAIN],&code)) != WMHI_LASTMSG)
{
diff --git a/amiga/gui_options.c b/amiga/gui_options.c
new file mode 100755
index 000000000..dbdeebece
--- /dev/null
+++ b/amiga/gui_options.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2009 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 <stdbool.h>
+#include <proto/exec.h>
+#include <proto/intuition.h>
+
+#include "amiga/object.h"
+#include "amiga/gui.h"
+#include "amiga/gui_options.h"
+#include "utils/messages.h"
+#include "amiga/options.h"
+
+#include <proto/window.h>
+#include <proto/layout.h>
+#include <proto/button.h>
+#include <classes/window.h>
+#include <gadgets/button.h>
+#include <reaction/reaction.h>
+#include <reaction/reaction_macros.h>
+
+static struct ami_gui_opts_window *gow = NULL;
+
+void ami_gui_opts_open(void)
+{
+ if(!gow)
+ {
+ gow = AllocVec(sizeof(struct ami_gui_opts_window),MEMF_CLEAR | MEMF_PRIVATE);
+
+ gow->objects[OID_MAIN] = WindowObject,
+ WA_ScreenTitle,nsscreentitle,
+ WA_Title,messages_get("**guiopts"),
+ WA_Activate, TRUE,
+ WA_DepthGadget, TRUE,
+ WA_DragBar, TRUE,
+ WA_CloseGadget, FALSE,
+ WA_SizeGadget, FALSE,
+ WA_CustomScreen,scrn,
+ WINDOW_SharedPort,sport,
+ WINDOW_UserData,gow,
+ WINDOW_IconifyGadget, FALSE,
+ WINDOW_Position, WPOS_CENTERSCREEN,
+ WA_IDCMP,IDCMP_GADGETUP,
+ WINDOW_ParentGroup, gow->gadgets[GID_OPTS_MAIN] = VGroupObject,
+ LAYOUT_AddChild, gow->gadgets[GID_OPTS_CANCEL] = ButtonObject,
+ GA_ID,GID_OPTS_CANCEL,
+ GA_Text,messages_get("Cancel"),
+ GA_RelVerify,TRUE,
+ ButtonEnd,
+ EndGroup,
+ EndWindow;
+
+ gow->win = (struct Window *)RA_OpenWindow(gow->objects[OID_MAIN]);
+ gow->node = AddObject(window_list,AMINS_GUIOPTSWINDOW);
+ gow->node->objstruct = gow;
+ }
+}
+
+void ami_gui_opts_close(void)
+{
+ DisposeObject(gow->objects[OID_MAIN]);
+ DelObject(gow->node);
+ gow = NULL;
+}
+
+BOOL ami_gui_opts_event(void)
+{
+ /* return TRUE if window destroyed */
+ ULONG result;
+ uint16 code;
+
+ while((result = RA_HandleInput(gow->objects[OID_MAIN],&code)) != WMHI_LASTMSG)
+ {
+ switch(result & WMHI_CLASSMASK) // class
+ {
+ case WMHI_GADGETUP:
+ switch(result & WMHI_GADGETMASK)
+ {
+ case GID_OPTS_CANCEL:
+ ami_gui_opts_close();
+ return TRUE;
+ break;
+ }
+ break;
+ }
+ }
+ return FALSE;
+}
diff --git a/amiga/gui_options.h b/amiga/gui_options.h
new file mode 100755
index 000000000..0ac9b07e0
--- /dev/null
+++ b/amiga/gui_options.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2009 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_GUI_OPTIONS_H
+#define AMIGA_GUI_OPTIONS_H
+
+#include <exec/types.h>
+#include <intuition/classusr.h>
+#include "amiga/gui.h"
+
+enum
+{
+ GID_OPTS_MAIN=0,
+ GID_OPTS_CANCEL,
+ GID_OPTS_LAST
+};
+
+struct ami_gui_opts_window {
+ struct Window *win;
+ Object *objects[OID_LAST];
+ struct Gadget *gadgets[GID_OPTS_LAST];
+ struct nsObject *node;
+ ULONG pad[6];
+};
+
+void ami_opts_open(void);
+BOOL ami_opts_event(void);
+#endif
diff --git a/amiga/menu.c b/amiga/menu.c
index b96321372..e17bfeba7 100755
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -46,6 +46,7 @@
#include "amiga/iff_dr2d.h"
#include "amiga/clipboard.h"
#include "content/fetch.h"
+#include "amiga/gui_options.h"
BOOL menualreadyinit;
const char * const netsurf_version;
@@ -101,17 +102,21 @@ void ami_init_menulabs(void)
menulab[27] = ami_utf8_easy((char *)messages_get("HistGlobalNS"));
menulab[28] = NM_BARLABEL;
menulab[29] = ami_utf8_easy((char *)messages_get("ShowCookies"));
- menulab[30] = ami_utf8_easy((char *)messages_get("Hotlist"));
- menulab[31] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
- menulab[32] = ami_utf8_easy((char *)messages_get("HotlistShowNS"));
- menulab[33] = NM_BARLABEL;
+ menulab[30] = NM_BARLABEL;
+ menulab[31] = ami_utf8_easy((char *)messages_get("**redraw"));
+ menulab[32] = ami_utf8_easy((char *)messages_get("Hotlist"));
+ menulab[33] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
+ menulab[34] = ami_utf8_easy((char *)messages_get("HotlistShowNS"));
+ menulab[35] = NM_BARLABEL;
menulab[AMI_MENU_HOTLIST_MAX] = ami_utf8_easy((char *)messages_get("Settings"));
- menulab[AMI_MENU_HOTLIST_MAX+1] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
- menulab[AMI_MENU_HOTLIST_MAX+2] = ami_utf8_easy((char *)messages_get("SettingsSave"));
- menulab[AMI_MENU_HOTLIST_MAX+3] = ami_utf8_easy((char *)messages_get("ARexx"));
- menulab[AMI_MENU_HOTLIST_MAX+4] = ami_utf8_easy((char *)messages_get("ARexxExecute"));
- menulab[AMI_MENU_HOTLIST_MAX+5] = NM_BARLABEL;
+ menulab[AMI_MENU_HOTLIST_MAX+1] = ami_utf8_easy((char *)messages_get("**edit prefs..."));
+ menulab[AMI_MENU_HOTLIST_MAX+2] = NM_BARLABEL;
+ menulab[AMI_MENU_HOTLIST_MAX+3] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
+ menulab[AMI_MENU_HOTLIST_MAX+4] = ami_utf8_easy((char *)messages_get("SettingsSave"));
+ menulab[AMI_MENU_HOTLIST_MAX+5] = ami_utf8_easy((char *)messages_get("ARexx"));
+ menulab[AMI_MENU_HOTLIST_MAX+6] = ami_utf8_easy((char *)messages_get("ARexxExecute"));
+ menulab[AMI_MENU_HOTLIST_MAX+7] = NM_BARLABEL;
}
struct NewMenu *ami_create_menu(ULONG type)
@@ -149,6 +154,8 @@ struct NewMenu *ami_create_menu(ULONG type)
{ NM_ITEM,0,0,0,0,0,}, // global history
{ NM_ITEM,NM_BARLABEL,0,0,0,0,},
{ NM_ITEM,0,0,0,0,0,}, // cookies
+ { NM_ITEM,NM_BARLABEL,0,0,0,0,},
+ { NM_ITEM,0,0,0,0,0,}, // redraw
{NM_TITLE,0,0,0,0,0,}, // hotlist
{ NM_ITEM,0,0,0,0,0,}, // add to hotlist
{ NM_ITEM,0,"H",0,0,0,}, // show hotlist (treeview)
@@ -194,6 +201,8 @@ struct NewMenu *ami_create_menu(ULONG type)
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
{ NM_IGNORE,0,0,0,0,0,}, // ** hotlist entry **
{NM_TITLE,0,0,0,0,0,}, // settings
+ { NM_ITEM,0,0,0,0,0,}, // edit prefs
+ { NM_ITEM,NM_BARLABEL,0,0,0,0,},
{ NM_ITEM,0,0,0,0,0,}, // snapshot window
{ NM_ITEM,0,0,0,0,0,}, // save settings
{NM_TITLE,0,0,0,0,0,}, // arexx
@@ -652,6 +661,11 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item)
case 5: // cookies tree
ami_open_tree(cookies_tree,AMI_TREE_COOKIES);
break;
+
+ case 7: // redraw
+ gwin->redraw_required = true;
+ gwin->new_content = true;
+ break;
}
break;
@@ -677,14 +691,18 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item)
case 4: // settings
switch(itemnum)
{
- case 0: // snapshot
+ case 0: // edit prefs
+ ami_gui_opts_open();
+ break;
+
+ case 2: // snapshot
option_window_x = gwin->win->LeftEdge;
option_window_y = gwin->win->TopEdge;
option_window_width = gwin->win->Width;
option_window_height = gwin->win->Height;
break;
- case 1: // save settings
+ case 3: // save settings
options_write("PROGDIR:Resources/Options");
break;
}
diff --git a/amiga/menu.h b/amiga/menu.h
index 922791c69..6a3f93212 100755
--- a/amiga/menu.h
+++ b/amiga/menu.h
@@ -28,10 +28,10 @@
/* Maximum number of menu items - first value is number of static items
* (ie. everything not intially defined as NM_IGNORE) */
-#define AMI_MENU_MAX 40 + AMI_HOTLIST_ITEMS
+#define AMI_MENU_MAX 44 + AMI_HOTLIST_ITEMS
/* Where the hotlist entries start */
-#define AMI_MENU_HOTLIST 34
+#define AMI_MENU_HOTLIST 36
/* Where the hotlist entries end */
#define AMI_MENU_HOTLIST_MAX AMI_MENU_HOTLIST+AMI_HOTLIST_ITEMS
diff --git a/amiga/object.h b/amiga/object.h
index 452dbf6e0..d48e8918f 100755
--- a/amiga/object.h
+++ b/amiga/object.h
@@ -32,6 +32,7 @@ enum
AMINS_TVWINDOW,
AMINS_FINDWINDOW,
AMINS_HISTORYWINDOW,
+ AMINS_GUIOPTSWINDOW,
AMINS_FETCHER,
};