r5453 chris_y - in /trunk/netsurf/amiga: gui.c menu.c menu.h tree.c tree.h

netsurf at semichrome.net netsurf at semichrome.net
Sun Sep 28 14:55:40 BST 2008


Author: chris_y
Date: Sun Sep 28 08:55:40 2008
New Revision: 5453

URL: http://source.netsurf-browser.org?rev=5453&view=rev
Log:
Treeview window event handling (currently just double-clicking hotlist items and
closing the window)

Modified:
    trunk/netsurf/amiga/gui.c
    trunk/netsurf/amiga/menu.c
    trunk/netsurf/amiga/menu.h
    trunk/netsurf/amiga/tree.c
    trunk/netsurf/amiga/tree.h

Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=5453&r1=5452&r2=5453&view=diff
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Sun Sep 28 08:55:40 2008
@@ -404,12 +404,26 @@
 	struct nsObject *nnode;
 	struct gui_window *gwin,*destroywin=NULL;
 	struct MenuItem *item;
+	struct InputEvent *ie;
 
 	node = (struct nsObject *)window_list->mlh_Head;
 
 	while(nnode=(struct nsObject *)(node->dtz_Node.mln_Succ))
 	{
 		gwin = node->objstruct;
+
+		if(node->Type == AMINS_TVWINDOW)
+		{
+			if(ami_tree_event((struct treeviw_window *)gwin))
+			{
+				break;
+			}
+			else
+			{
+				node = nnode;
+				continue;
+			}
+		}
 
 		while((result = RA_HandleInput(gwin->objects[OID_MAIN],&code)) != WMHI_LASTMSG)
 		{
@@ -588,6 +602,8 @@
 
 				case WMHI_RAWKEY:
 					storage = result & WMHI_GADGETMASK;
+
+					GetAttr(WINDOW_InputEvent,gwin->objects[OID_MAIN],(ULONG *)&ie);
 					switch(storage)
 					{
 						case RAWKEY_CRSRUP:
@@ -633,17 +649,7 @@
 				break;
 
 				case WMHI_CLOSEWINDOW:
-					switch(node->Type)
-					{
-						case AMINS_TVWINDOW:
-							ami_tree_close((struct treeview_window *)gwin);
-						break;
-
-						default:
-							browser_window_destroy(gwin->bw);
-						break;
-					}
-					//destroywin=gwin;
+					browser_window_destroy(gwin->bw);
 		        break;
 
 				case WMHI_INTUITICK:

Modified: trunk/netsurf/amiga/menu.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/menu.c?rev=5453&r1=5452&r2=5453&view=diff
==============================================================================
--- trunk/netsurf/amiga/menu.c (original)
+++ trunk/netsurf/amiga/menu.c Sun Sep 28 08:55:40 2008
@@ -31,6 +31,7 @@
 #include "desktop/save_text.h"
 #include "desktop/save_pdf/pdf_plotters.h"
 #include <string.h>
+#include "amiga/tree.h"
 
 void ami_free_menulabs(void)
 {
@@ -61,9 +62,10 @@
 	menulab[14] = ami_utf8_easy((char *)messages_get("Hotlist"));
 	menulab[15] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
 	menulab[16] = ami_utf8_easy((char *)messages_get("HotlistShowNS"));
-	menulab[17] = ami_utf8_easy((char *)messages_get("Settings"));
-	menulab[18] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
-	menulab[19] = ami_utf8_easy((char *)messages_get("SettingsSave"));
+	menulab[17] = ami_utf8_easy((char *)messages_get("Hotlist-browser"));
+	menulab[18] = ami_utf8_easy((char *)messages_get("Settings"));
+	menulab[19] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
+	menulab[20] = ami_utf8_easy((char *)messages_get("SettingsSave"));
 }
 
 struct NewMenu *ami_create_menu(ULONG type)
@@ -87,7 +89,8 @@
 			  	{ NM_ITEM,0,"Z",0,0,0,}, // clear selection
 				{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
+			  	{ NM_ITEM,0,"H",0,0,0,}, // show hotlist (treeview)
+			  	{ NM_ITEM,0,0,0,0,0,}, // show hotlist (browser window)
 				{NM_TITLE,0,0,0,0,0,}, // settings
 				{ NM_ITEM,0,0,0,0,0,}, // snapshot window
 				{ NM_ITEM,0,0,0,0,0,}, // save settings
@@ -208,6 +211,7 @@
 			{
 				case 0: // copy
 					gui_copy_to_clipboard(gwin->bw->sel);
+					browser_window_key_press(gwin->bw, 26);
 				break;
 
 				case 1: // paste
@@ -232,9 +236,14 @@
 					options_save_tree(hotlist,"Resources/Hotlist","NetSurf hotlist");
 				break;
 
+				case 2: // show
+/* this along with save_tree above is very temporary!
+config option for this? */
+					browser_window_go(gwin->bw,"file:///netsurf/resources/hotlist",NULL,true);
+				break;
+
 				case 1: // show
-/* this along with save_tree above is very temporary! */
-					browser_window_go(gwin->bw,"file:///netsurf/resources/hotlist",NULL,true);
+					ami_open_tree(hotlist);
 				break;
 			}
 		break;

Modified: trunk/netsurf/amiga/menu.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/menu.h?rev=5453&r1=5452&r2=5453&view=diff
==============================================================================
--- trunk/netsurf/amiga/menu.h (original)
+++ trunk/netsurf/amiga/menu.h Sun Sep 28 08:55:40 2008
@@ -20,7 +20,7 @@
 #define AMIGA_MENU_H
 #include <exec/types.h>
 
-#define AMI_MENU_MAX 19
+#define AMI_MENU_MAX 20
 char *menulab[AMI_MENU_MAX+1];
 
 struct NewMenu *ami_create_menu(ULONG type);

Modified: trunk/netsurf/amiga/tree.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/tree.c?rev=5453&r1=5452&r2=5453&view=diff
==============================================================================
--- trunk/netsurf/amiga/tree.c (original)
+++ trunk/netsurf/amiga/tree.c Sun Sep 28 08:55:40 2008
@@ -31,17 +31,9 @@
 #include <proto/intuition.h>
 #include "amiga/tree.h"
 
-struct treeview_window {
-	struct Window *win;
-	Object *objects[OID_LAST];
-	struct Gadget *gadgets[GID_LAST];
-	struct nsObject *node;
-	ULONG pad[5];
-	struct tree *tree;
-	struct List *listbrowser_list;
-};
-
 void ami_add_elements(struct treeview_window *twin,struct node *root,WORD *gen);
+bool ami_tree_launch_node(struct tree *tree, struct node *node);
+void free_browserlist(struct List *list);
 
 void tree_initialise_redraw(struct tree *tree)
 {
@@ -184,7 +176,14 @@
 	struct treeview_window *twin;
 	BOOL msel = TRUE;
 	static WORD gen=0;
-/* open window with listbrowser gadget added */
+
+	if(tree->handle)
+	{
+		twin = tree->handle;
+		WindowToFront(twin->win);
+		ActivateWindow(twin->win);
+		return;
+	}
 
 	twin = AllocVec(sizeof(struct treeview_window),MEMF_CLEAR);
 	twin->listbrowser_list = AllocVec(sizeof(struct List),MEMF_CLEAR);
@@ -214,7 +213,8 @@
            	WA_CloseGadget, TRUE,
            	WA_SizeGadget, TRUE,
 			WA_CustomScreen,scrn,
-		WINDOW_SharedPort,sport,
+			WINDOW_SharedPort,sport,
+			WINDOW_UserData,twin,
 			WINDOW_IconifyGadget, TRUE,
          	WINDOW_Position, WPOS_CENTERSCREEN,
            	WINDOW_ParentGroup, twin->gadgets[GID_MAIN] = VGroupObject,
@@ -225,11 +225,13 @@
 					LISTBROWSER_ColumnInfo, &columninfo,
 					LISTBROWSER_ColumnTitles, TRUE,
 					LISTBROWSER_Hierarchical,TRUE,
+					LISTBROWSER_Editable,TRUE,
 //	LISTBROWSER_TitleClickable,TRUE,
 					LISTBROWSER_AutoFit, TRUE,
 					LISTBROWSER_HorizontalProp, TRUE,
 					LISTBROWSER_Labels, twin->listbrowser_list,
 					LISTBROWSER_MultiSelect,msel,
+					LISTBROWSER_ShowSelected,TRUE,
         		ListBrowserEnd,
 				CHILD_NominalSize,TRUE,
 			EndGroup,
@@ -272,15 +274,14 @@
 	return false;
 }
 
-void ami_tree_close(struct tree *tree)
-{
-	struct treeview_window *twin = tree->handle;
-
+void ami_tree_close(struct treeview_window *twin)
+{
+	twin->tree->handle = NULL;
 	DisposeObject(twin->objects[OID_MAIN]);
 	FreeListBrowserList(twin->listbrowser_list);
+	FreeVec(twin->listbrowser_list);
 	//free_browserlist(twin->listbrowser_list);
 	DelObject(twin->node);
-	win_destroyed = true;
 }
 
 void free_browserlist(struct List *list)
@@ -307,33 +308,55 @@
 	BOOL edit = FALSE;
 	struct node_element *element=NULL,*element2=NULL,*element3=NULL;
 	struct node *node;
+	ULONG flags = 0;
+	STRPTR text1 = "",text2 = "",text3 = "";
 
 	*gen = *gen + 1;
 	for (node = root; node; node = node->next)
 	{
 		element = tree_find_element(node, TREE_ELEMENT_NAME);
 		if(!element) element = tree_find_element(node, TREE_ELEMENT_TITLE);
+		if(element && element->text)
+		{
+			text1 = element->text;
+		}
+
 //		printf("node %lx url %s gen %ld\n",node,element->text,*gen);
 		element2 = tree_find_element(node, TREE_ELEMENT_URL);
-		element3 = tree_find_element(node, TREE_ELEMENT_VISITS);
+
+		if(element2 && element2->text)
+		{
+			text2 = element2->text;
+		}
+
+//		element = tree_find_element(node, TREE_ELEMENT_VISITS);
+
+		if(node->expanded) flags = LBFLG_SHOWCHILDREN;
 
 		switch (element->type) {
 			case NODE_ELEMENT_TEXT_PLUS_SPRITE:
 			case NODE_ELEMENT_TEXT:
     	    		if (lbnode = AllocListBrowserNode(3,
-//					LBNA_UserData,nodetime,
-				LBNA_Generation,*gen,
+					LBNA_UserData,node,
+					LBNA_Generation,*gen,
+					LBNA_Selected,node->selected,
+					LBNA_Flags,flags,
 	            	LBNA_Column, 0,
-					LBNCA_CopyText,TRUE,
-	 	               LBNCA_Text, element->text,
-					LBNCA_Editable,edit,
- 	    	       LBNA_Column, 1,
-					LBNCA_CopyText,TRUE,
- 	            	   LBNCA_Text, element2->text,
-	 	           LBNA_Column, 2,
-					LBNCA_CopyText,TRUE,
-	 	               LBNCA_Text, "",
- 		           TAG_DONE))
+						LBNCA_CopyText,TRUE,
+						LBNCA_MaxChars,256,
+	 	               	LBNCA_Text, text1,
+						LBNCA_Editable,node->editable,
+ 	    	       	LBNA_Column, 1,
+						LBNCA_CopyText,TRUE,
+						LBNCA_MaxChars,256,
+ 	            	   	LBNCA_Text, text2,
+						LBNCA_Editable,node->editable,
+	 	           	LBNA_Column, 2,
+						LBNCA_CopyText,TRUE,
+						LBNCA_MaxChars,256,
+	 	               	LBNCA_Text,"",
+						LBNCA_Editable,node->editable,
+ 		           	TAG_DONE))
 					{
 						AddTail(twin->listbrowser_list, lbnode);
  		       		}
@@ -347,3 +370,59 @@
 	}
 	*gen = *gen - 1;
 }
+
+BOOL ami_tree_event(struct treeview_window *twin)
+{
+	/* return TRUE if window destroyed */
+	ULONG class,result,relevent = 0;
+	uint16 code;
+	struct MenuItem *item;
+	struct node *treenode;
+	struct Node *lbnode;
+
+	while((result = RA_HandleInput(twin->objects[OID_MAIN],&code)) != WMHI_LASTMSG)
+	{
+       	switch(result & WMHI_CLASSMASK) // class
+   		{
+			case WMHI_GADGETUP:
+				switch(result & WMHI_GADGETMASK)
+				{
+					case GID_TREEBROWSER:
+						GetAttrs(twin->gadgets[GID_TREEBROWSER],
+							LISTBROWSER_RelEvent,&relevent,
+							TAG_DONE);
+
+							switch(relevent)
+						{
+							case LBRE_DOUBLECLICK:
+								GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode);
+								GetListBrowserNodeAttrs(lbnode,
+									LBNA_UserData,(ULONG *)&treenode,
+									TAG_DONE);
+								ami_tree_launch_node(twin->tree,treenode);
+							break;
+						}
+					break;
+				}
+			break;
+
+/* no menus yet, copied in as will probably need it later
+			case WMHI_MENUPICK:
+				item = ItemAddress(gwin->win->MenuStrip,code);
+				while (code != MENUNULL)
+				{
+					ami_menupick(code,gwin);
+					if(win_destroyed) break;
+					code = item->NextSelect;
+				}
+			break;
+*/
+
+			case WMHI_CLOSEWINDOW:
+				ami_tree_close(twin);
+				return TRUE;
+			break;
+		}
+	}
+	return FALSE;
+}

Modified: trunk/netsurf/amiga/tree.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/tree.h?rev=5453&r1=5452&r2=5453&view=diff
==============================================================================
--- trunk/netsurf/amiga/tree.h (original)
+++ trunk/netsurf/amiga/tree.h Sun Sep 28 08:55:40 2008
@@ -19,8 +19,17 @@
 #ifndef AMIGA_TREE_H
 #define AMIGA_TREE_H
 
+struct treeview_window {
+	struct Window *win;
+	Object *objects[OID_LAST];
+	struct Gadget *gadgets[GID_LAST];
+	struct nsObject *node;
+	ULONG pad[5];
+	struct tree *tree;
+	struct List *listbrowser_list;
+};
+
 void ami_open_tree(struct tree *tree);
-bool ami_tree_launch_node(struct tree *tree, struct node *node);
-void ami_tree_close(struct tree *tree);
-void free_browserlist(struct List *list);
+void ami_tree_close(struct treeview_window *twin);
+BOOL ami_tree_event(struct treeview_window *twin);
 #endif




More information about the netsurf-commits mailing list