[Bf-committers] helpmenu/browser patch.

Daniel Fairhead bf-committers@blender.org
Mon, 17 May 2004 01:17:55 +0300


This is a multi-part message in MIME format.

--Multipart=_Mon__17_May_2004_01_17_55_+0300_WDpe4bxNT+XBNlJJ
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Hi all,

Here is a simple patch which adds 4 links to the helpmenu, and calls
(hopefully) the default browser to deal with them. This is something
often called for by newbies and others, and I believe to be useful.

Calling the default browser is very easy on Windows and OSX, and so
is done accordingly. On *NIX, there is no official standard for calling a
browser, so I have followed the (IMHO sensible but slightly 
over-compilcated (colons?!)) proposal of ESR:

http://www.catb.org/~esr/BROWSER/

so if a $BROWSER variable is set, it will use that, and if not, it will pop
up a pupmenu saying "Please set your $BROWSER" but also giving the
option of calling mozilla, dillo, or copy to clipboard. I have no idea how
to copy to clipboard, so at the moment instead it just 'echo's it. :-)

Discussed before was the possibility of using the webbrowser python
module. This would also work... but means another python module to
distibute, and doesn't add anything any better than that which I could
write myself.

I also have some begining code I wrote for attempting to find the default
browser if $BROWSER is not set. However, it is all rather large, and kind
of hacky, so I would rather use what is in this patch, partly to try and 
get people to use the $BROWSER variable, which is (IMHO) a Good Idea.

About the links I have put in... These are (almost definately) not the 
best ones to have. Perhaps a FunBoard question? The only problem 
is that 4 is the maximum easily availiable, as the events system is 
rather full.

Oh, and the options of dillo or moz if $BROWSER isn't set is probably
another funboard question?

Please comment,

Dan

--Multipart=_Mon__17_May_2004_01_17_55_+0300_WDpe4bxNT+XBNlJJ
Content-Type: text/plain;
 name="helpmenu-patch-1.txt"
Content-Disposition: attachment;
 filename="helpmenu-patch-1.txt"
Content-Transfer-Encoding: 7bit

Index: source/blender/include/blendef.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/blendef.h,v
retrieving revision 1.20
diff -u -B -r1.20 blendef.h
--- source/blender/include/blendef.h	16 Jan 2004 23:40:12 -0000	1.20
+++ source/blender/include/blendef.h	16 May 2004 22:11:56 -0000
@@ -188,6 +188,10 @@
 #define B_FLIPINFOMENU		64
 #define B_FLIPFULLSCREEN	65
 
+#define B_HELPWEBSITE		66
+#define B_HELPMANUAL		67
+#define B_HELPTUTORIALS		68
+#define B_HELPBUGREP		69
 
 #define B_SHOWSPLASH		70
 #define B_RESETAUTOSAVE		71
Index: source/blender/src/header_info.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/header_info.c,v
retrieving revision 1.32
diff -u -B -r1.32 header_info.c
--- source/blender/src/header_info.c	20 Apr 2004 22:00:32 -0000	1.32
+++ source/blender/src/header_info.c	16 May 2004 22:11:59 -0000
@@ -1635,29 +1635,35 @@
 	
 	block= uiNewBlock(&curarea->uiblocks, "info_helpmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
 	uiBlockSetButmFunc(block, do_info_helpmenu, NULL);
+
+	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Benchmark",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
+
 	
-	uiDefIconTextBut(block, BUTM, B_SHOWSPLASH, ICON_BLANK1, "About Blender...",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
 	
 	uiDefBut(block, SEPR, 0, "",				0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 	
-	/*	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "-- Placeholders only --",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
-	
-	uiDefBut(block, SEPR, 0, "",				0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+	/*	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "-- Placeholders only --",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); 
 	
-	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Tutorials *",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
-	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "User Manual *",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
-	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Python Scripting Reference *",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
+	uiDefBut(block, SEPR, 0, "",				0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); */
 	
+	uiDefIconTextBut(block, BUTM, B_HELPWEBSITE, ICON_BLANK1, "Website",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
+	uiDefIconTextBut(block, BUTM, B_HELPMANUAL, ICON_BLANK1, "Online Manual",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
+	uiDefIconTextBut(block, BUTM, B_HELPTUTORIALS, ICON_BLANK1, "Online Tutorials",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
+	uiDefIconTextBut(block, BUTM, B_HELPBUGREP, ICON_BLANK1, "Report a Bug",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
+
+	/*
 	uiDefBut(block, SEPR, 0, "",				0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 	
 	uiDefIconTextBlockBut(block, info_help_websitesmenu, NULL, ICON_RIGHTARROW_THIN, "Websites", 0, yco-=20, 120, 19, "");
 
 	uiDefBut(block, SEPR, 0, "",				0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 */
-	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Benchmark",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
-	
-/*	uiDefBut(block, SEPR, 0, "",				0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+		
+	uiDefBut(block, SEPR, 0, "",				0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); 
+
+	uiDefIconTextBut(block, BUTM, B_SHOWSPLASH, ICON_BLANK1, "About Blender...",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
 
+/*
 	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Release Notes *",	0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
 */
 	uiBlockSetDirection(block, UI_DOWN);
Index: source/blender/src/headerbuttons.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/headerbuttons.c,v
retrieving revision 1.81
diff -u -B -r1.81 headerbuttons.c
--- source/blender/src/headerbuttons.c	20 Apr 2004 22:00:33 -0000	1.81
+++ source/blender/src/headerbuttons.c	16 May 2004 22:11:59 -0000
@@ -658,7 +658,10 @@
 	ID *id, *idtest, *from;
 	ScrArea *sa;
 	int nr= 1;
+	int helptype= 0;
 	char buf[FILE_MAXDIR+FILE_MAXFILE];
+	char url[150] = "";
+
 
 
 	ob= OBACT;
@@ -1409,8 +1412,87 @@
 	case B_SOUNDTOGGLE:
 		SYS_WriteCommandLineInt(SYS_GetSystem(), "noaudio", (U.gameflags & USER_DISABLE_SOUND));
 		break;
+	
+	case B_HELPWEBSITE:
+		strcat(url, "http://www.blender3d.org");
+		/* Intentionly no break; */
+	case B_HELPMANUAL:
+		if (url[0]=='\0')
+			strcat(url,"http://download.blender.org/documentation/html/");
+		/* Intentionly no break; */
+	case B_HELPTUTORIALS:
+		if (url[0]=='\0')
+			strcat(url,"http://www.blender3d.com/cms/Using_Blender.80.0.html");
+		/* Intentionly no break; */
+	case B_HELPBUGREP:
+		{
+			char full_url[150] = "";
+			char browser[150] = "";
+			int val = 0;
+			char *colon;
+			
+			if (url[0]=='\0')
+				strcat(url,"http://projects.blender.org/tracker/?func=add&group_id=9&atid=125");
+		
+#ifdef WIN32
+			strcat(browser, "start %s");
+#else
+	#ifdef __APPLE__
+			strcat(browser, "open %s");
+	#else
+			if (getenv("BROWSER")) {
+				/* http://www.catb.org/~esr/BROWSER/ */
+				/* Only check first browser. To much effort to do all. 
+				   Note to anyone interested: If you want to recode all this to
+				   be correct, do so! ;) */
+				strcat(browser,getenv("BROWSER"));
+				colon = strstr(browser,":");
+				if (colon)
+					colon[0] = '\0';
+					
+				/* colon abuse! */
+				colon = NULL;
+				colon = strstr(browser,"%s");
+				if (!colon)
+					strcat(browser, " %s");
+			}else{
+				val = pupmenu("Please set $BROWSER variable.%t|Launch Mozilla %x1|Launch Dillo %x2|Copy URL to clipboard %x3");
+				if (val > 0){
+					switch (val){
+					case 1:
+						strcat(browser, "mozilla -remote 'openurl(%s,new-window)'");
+						break;
+					case 2:
+						strcat(browser, "dillo %s");
+						break;
+					case 3:
+						strcat(browser, "echo %s");
+						break;
+					}
+				} else {
+					break;
+				}
+			}
+	#endif
+#endif
+			strcpy(full_url,browser);
+			/* abuse 'colon' as '%s' now. */
+			colon = NULL;
+			colon = strstr(full_url,"%s");
+			strcpy(colon,url);
+			
+
+    		colon = NULL;
+		    colon = strstr(browser,"%s")+2;
+		    strcat(full_url,colon);
+
+			strcat(full_url, " &");
+			system(full_url);
+		}
+		break;
+	
 	case B_SHOWSPLASH:
-				show_splash();
+		show_splash();
 		break;
 	case B_MIPMAPCHANGED:
 		set_mipmap(!(U.gameflags & USER_DISABLE_SOUND));

--Multipart=_Mon__17_May_2004_01_17_55_+0300_WDpe4bxNT+XBNlJJ--