summaryrefslogtreecommitdiff
path: root/atari/hotlist.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-01-05 21:02:22 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-01-05 21:02:22 +0000
commit124e4cd78814e368488d8e86c15f95223f365a44 (patch)
treece09522fee51a4fa1c92c12faa60aeff96403a52 /atari/hotlist.c
parent9422e6dad0dffa134c961d16e9aa503324245cd7 (diff)
downloadnetsurf-124e4cd78814e368488d8e86c15f95223f365a44.tar.gz
netsurf-124e4cd78814e368488d8e86c15f95223f365a44.tar.bz2
Atari frontend (credit: Ole Loots)
svn path=/trunk/netsurf/; revision=11218
Diffstat (limited to 'atari/hotlist.c')
-rw-r--r--atari/hotlist.c165
1 files changed, 165 insertions, 0 deletions
diff --git a/atari/hotlist.c b/atari/hotlist.c
new file mode 100644
index 000000000..c0f4a93d3
--- /dev/null
+++ b/atari/hotlist.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2010 Ole Loots <ole@monochrom.net>
+ *
+ * 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 <ctype.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include "desktop/browser.h"
+#include "content/content.h"
+#include "content/hlcache.h"
+#include "content/urldb.h"
+#include "desktop/options.h"
+#include "desktop/hotlist.h"
+#include "desktop/tree.h"
+#include "desktop/gui.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "utils/url.h"
+#include "atari/gui.h"
+#include "atari/misc.h"
+#include "atari/treeview.h"
+#include "atari/hotlist.h"
+#include "atari/findfile.h"
+#include "atari/res/netsurf.rsh"
+
+static struct atari_hotlist {
+ WINDOW * window;
+ NSTREEVIEW tv; /*< The hotlist treeview handle. */
+ bool open;
+} hl;
+
+static const struct {
+ const char *url;
+ const char *msg_key;
+} default_entries[] = {
+ { "http://www.netsurf-browser.org/", "HotlistHomepage" },
+ { "http://www.netsurf-browser.org/downloads/riscos/testbuilds", "HotlistTestBuild" },
+ { "http://www.netsurf-browser.org/documentation", "HotlistDocumentation" },
+ { "http://sourceforge.net/tracker/?atid=464312&group_id=51719",
+ "HotlistBugTracker" },
+ { "http://sourceforge.net/tracker/?atid=464315&group_id=51719",
+ "HotlistFeatureRequest" }
+};
+#define ENTRIES_COUNT (sizeof(default_entries) / sizeof(default_entries[0]))
+
+
+static void evnt_hl_toolbar( WINDOW *win, short buff[8]) {
+ int obj = buff[4]; /* Selected object */
+
+ LOG(("item: %d clicked", obj ));
+
+ switch( obj) {
+ case TOOLBAR_HOTLIST_CREATE_FOLDER:
+ break;
+ case TOOLBAR_HOTLIST_ADD:
+ break;
+ case TOOLBAR_HOTLIST_DELETE:
+ break;
+ }
+
+ /* object state to normal and redraw object */
+/*
+ ObjcChange( TOOLBAR_HOTLIST, hl.window, obj, SELECTED, 1);
+ ObjcChange( TOOLBAR_HOTLIST, hl.window, obj, 0 , 1);
+*/
+}
+
+static void __CDECL evnt_hl_close( WINDOW *win, short buff[8] )
+{
+ hotlist_close();
+}
+
+void hotlist_init(void)
+{
+ char hlfilepath[PATH_MAX];
+
+ atari_find_resource(
+ (char*)&hlfilepath, "hotlist", "./res/Hotlist"
+ );
+
+ if( hl.window == NULL ){
+ int flags = CLOSER | MOVER | SIZER| NAME | FULLER | SMALLER ;
+ OBJECT * tree = get_tree(TOOLBAR_HOTLIST);
+ assert( tree );
+ hl.open = false;
+ hl.window = WindCreate( flags,40, 40, app.w, app.h );
+ if( hl.window == NULL ) {
+ LOG(("Failed to allocate Hotlist"));
+ return;
+ }
+ /* TODO: load hotlist strings from messages */
+ WindSetStr( hl.window, WF_NAME, (char*)"Hotlist" );
+ WindSetPtr( hl.window, WF_TOOLBAR,
+ tree,
+ evnt_hl_toolbar
+ );
+ EvntAttach( hl.window, WM_CLOSED, evnt_hl_close );
+ hl.tv = atari_treeview_create(
+ hotlist_get_tree_flags(),
+ hl.window
+ );
+ if (hl.tv == NULL) {
+ LOG(("Failed to allocate treeview"));
+ return;
+ }
+ hotlist_initialise(
+ atari_treeview_get_tree(hl.tv),
+ /* TODO: use option_hotlist_file or slt*/
+ (char*)&hlfilepath,
+ hlfilepath
+ );
+ } else {
+
+ }
+}
+
+
+void hotlist_open(void)
+{
+ hotlist_init();
+ if( hl.open == false ) {
+ WindOpen( hl.window, -1, -1, app.w/3, app.h/2);
+ hl.open = true;
+ }
+ tree_set_redraw(atari_treeview_get_tree(hl.tv), true);
+}
+
+void hotlist_close(void)
+{
+ WindClose(hl.window);
+ hl.open = false;
+}
+
+void hotlist_destroy(void)
+{
+ if( hl.window != NULL ) {
+ if( hl.open )
+ hotlist_close();
+ WindDelete( hl.window );
+ printf("delete hl tree");
+ atari_treeview_destroy( hl.tv );
+ hl.window = NULL;
+ }
+}
+
+
+