<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Defcon3 by Fredre</title>
	<atom:link href="http://fredreh.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://fredreh.wordpress.com</link>
	<description>Still thinking of a tagline</description>
	<lastBuildDate>Tue, 25 Aug 2009 08:04:32 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='fredreh.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/0a83008fd14bcc5e98f6766f83b533e1?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Defcon3 by Fredre</title>
		<link>http://fredreh.wordpress.com</link>
	</image>
			<item>
		<title>C Tutorial: switch, loops, and recursive functions</title>
		<link>http://fredreh.wordpress.com/2009/08/25/c-tutorial-switch-loops-and-recursive-functions/</link>
		<comments>http://fredreh.wordpress.com/2009/08/25/c-tutorial-switch-loops-and-recursive-functions/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 08:04:32 +0000</pubDate>
		<dc:creator>fredreh</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://fredreh.wordpress.com/?p=170</guid>
		<description><![CDATA[This is the Tutorial I recently created for my Software Design students that we use during lab time here at the university. SFD is a basic intro to C type subject. I cannot post the other tutorials since they have been created by other lecturers but this one I can share. Enjoy !!!
Tutorial 5 (Outcome [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=170&subd=fredreh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This is the Tutorial I recently created for my Software Design students that we use during lab time here at the university. SFD is a basic intro to C type subject. I cannot post the other tutorials since they have been created by other lecturers but this one I can share. Enjoy !!!</p>
<p><strong>Tutorial 5 (Outcome 3 ,4)</strong></p>
<p><strong>Part 1:  switch Multiple-Selection Statement </strong></p>
<p>When testing for many conditions the if statements that will be needed will grow large and make the code of your program harder to read. There is also some performance loss when using the if statement to check the same variable for many conditions. So when checking one variable for many conditions it is better to use the switch statement.</p>
<p>The basic syntax for a switch statement is:</p>
<p>switch (variable)<br />
{</p>
<p>case test :<br />
statement(s) if is case is true<br />
break;</p>
<p>case test :<br />
statement(s) if is case is true<br />
even more statements<br />
break;</p>
<p>&#8230;</p>
<p>default:<br />
statement(s) if not one of the cases evaluated to true<br />
break;</p>
<p>}</p>
<p>variable is the variables value you want to test.<br />
test is the value you want to test variable for.<br />
the statement(s) is the code that is going to be executed if true.<br />
default: contains the code that is going to be executed if not one case evaluates to true.<br />
always remember to end the case with a break;</p>
<p>Lets look at example one that uses a switch statement. In the example the user is asked to enter a number (int) between 1 and 5. The program first checks if the number is between one and five using an if statement. Then it displays on the screen the number the user entered but it shows the number in word format. So if the user enters 5 the program will display FIVE. </p>
<div id="attachment_171" class="wp-caption aligncenter" style="width: 520px"><img src="http://fredreh.files.wordpress.com/2009/08/ex1.png?w=510&#038;h=603" alt="Example 1" title="Example 1" width="510" height="603" class="size-full wp-image-171" /><p class="wp-caption-text">Example 1</p></div>
<p>In example 1 the switch statement starts at line 25 and ends at line 47. In line 25 the variable number is sent to the switch. Line 28 contains the first case and checks if the number was 1. If the number was indeed one the program will move to line 29 were the printf() statement is executed. After the printf() in line 29 the program will encounter a break; statement in line 30 letting it know the case is done. If the number was not 1 the program moves to the next case etc.  </p>
<p>You would notice that the switch statement in example one does not contain a default case. This is because the default case is optional. We can rewrite the code in example 1 and add a default case to the switch statement. The default case will only be executed if no other cases matched. This means if the user did not enter a number between 1 and 5 the default statement will execute. Since we now have a default case we can remove the if statement on lines 15 &#8211; 22 that checks if the number is between 1 and 5. Example 2 contains a switch with a default statement:</p>
<p><img src="http://fredreh.files.wordpress.com/2009/08/ex2.png?w=510&#038;h=552" alt="Example 2" title="Example 2" width="510" height="552" class="aligncenter size-full wp-image-173" /></p>
<p>In example 2 the if statement was removed.  Line 38 &#8211; 43 now contains a default case. Note that each case including the default case ends with a break; statement. The break statement is very important since it tells the program that the statements in the case was executed and the program can now &#8220;break&#8221; out of the switch.</p>
<p><strong>Part 2: Loop structures</strong></p>
<p>Most programs contain structures known as loops. Loops allow for repetition in programs. Each loop structure will contain a number of instructions that gets repeated a certain number of times. The three basic loop structures are For, While and Do While.</p>
<p>Although the three types of loop structures do the same thing (repeat instructions) the way that they are implemented and used differ. Deciding on what type of loop structure to use will depend mostly on the type of repetition that is needed. The two types of repetition is Counter-controlled repetition and Sentinel-controlled repetition.</p>
<p>Counter-controlled repetition needs 3 things:</p>
<p>The loop counter that will count how many times the loop has been executed. The loop counter also needs an initial value.</p>
<p>The increment (+) or decrement (-) by which the loop counter is modified each time the loop is executed.</p>
<p>The  test to check the loop counter and determine if the loop should be executed again.</p>
<p><strong>Part 2.1: The while loop</strong></p>
<p>The while loop will execute its statements while a certain condition is true. The basic syntax for a while loop is as follows:</p>
<p>while(test condition = = true)<br />
{<br />
//Execute some statements like incrementing the counter<br />
}</p>
<p>Example 3 shows a basic while loop that will loop 10 times and display the counter. On line 8 the variable counter is created. counter Is the variable that will keep track of how many times the loop was executed and gets an initial value of 1. Line 10 &#8211; 15 contains the while loop. In line 10 one can see the test for the while loop. This loop will execute only while counter is less then or is 10. In line 14 after all the normal statements but still inside the loop counter is incremented with 1. This is done so that each time the loops executes counter gets larger by one until counter is more then 10 and the loop is not executed. If we do not increment counter at the end of each loop each time we will get what is called an infinite loop.</p>
<p>Infinite loops occur when the loop just gets executed for ever usually there is no way the test can result in false so the loop just keeps going. </p>
<p><img src="http://fredreh.files.wordpress.com/2009/08/ex3.png?w=389&#038;h=331" alt="Example 3" title="Example 3" width="389" height="331" class="aligncenter size-full wp-image-174" /></p>
<p><strong>Part 2.2: The for loop</strong></p>
<p>Unlike when using the while loop with the for loop you can initialise the counter, test the counter and increment / decrement the counter in one line. The syntax for the for loop is as follows:</p>
<p>for(assign value to counter ; test condition ; counter increment / decrement)<br />
{<br />
// Statements to execute<br />
} </p>
<p>Example 4 shows an for loop implementation that does exactly the same thing as example 3.</p>
<p><img src="http://fredreh.files.wordpress.com/2009/08/ex4.png?w=510&#038;h=303" alt="Example 4" title="Example 4" width="510" height="303" class="aligncenter size-full wp-image-175" /></p>
<p>In example 4 a variable counter is declared on line 8. counter Will keep track of how many times the loop has been executed. The for loop is located at line 10 &#8211; 13. The counter was set to 1 the test will make sure the counter is not more then ten before the loop is executed and the counter is incremented by 1 each time the loop is executed. This al happens in line 10.</p>
<p><strong>Part 2.3: The do&#8230;while loop</strong></p>
<p>Very similar to the while loop the do&#8230;while loop is only different in that it tests the loop condition at the end of the loop instead of the beginning. This means that the statements included in the loop body will be executed at least once before the test condition is evaluated. If after the initial execution the test condition evaluates to false the loop will not be executed again. You can use the do&#8230;while loop when you want to ensure the statements inside the loop is executed at least once in your application. The syntax for the do&#8230;while loop is:</p>
<p>do<br />
{<br />
	//Statements to be executed<br />
}<br />
while (condition)</p>
<p>Example 5 shows the do&#8230;while in action. Notice that even if the counter variable is set to more then 10 the statements will be executed at least once. This is different to the for and while loops that will first evaluate the test condition before any statements is executed:</p>
<p><img src="http://fredreh.files.wordpress.com/2009/08/ex5.png?w=411&#038;h=343" alt="Example 5" title="Example 5" width="411" height="343" class="aligncenter size-full wp-image-176" /></p>
<p>In example 5 a variable counter with default value 1 is created in line 8. The do&#8230;while statement is located in lines 6 -15. Notice how the while is located at the end in line 15. Also be sure to remember to increment the counter each time the loop is executed as in line 13.</p>
<p><strong>Part 2.4: break and continue</strong></p>
<p>We can use the break and continue statements to alter the flow of programs especially inside loops. </p>
<p>The break statement is used to exit the loop completely even if the next condition will still evaluate to true. We have used the break statement in the switch statement before to exit the switch after the cases statements have been executed. break Can perform the same function loops. </p>
<p>The continue statement will continue with next iteration of the loop ignoring any additional statements in the loop body after the statement.</p>
<p>Example program 6 shows the use of break and continue:</p>
<p><img src="http://fredreh.files.wordpress.com/2009/08/ex61.png?w=509&#038;h=682" alt="Example 6" title="Example 6" width="509" height="682" class="aligncenter size-full wp-image-178" /></p>
<p>Example program 6 tracks the numbers of years that the Dalton gang spends in jail. Line 6 -7 contains variables that is used in the program. jail_years is the number of years in jail and rnum is a random number between 0 &#8211; 10  </p>
<p>Line 13 &#8211; 39 contains the for loop. On line 13 a new for loop is created. The for loop is created in such a way that the loop will execute until a break statement is encountered. </p>
<p>The first statement in the the for loop (line 16) will use the the getran() function  (line 45 -54) to get a random number between 0 and 10.</p>
<p>The first if in the for loop will execute if the random number is 4 and then break out of the loop. A message is displayed showing that the Dalton gang breaks out of jail.</p>
<p>The second if in the for loop (line 28) will check if the random number is more then 5. If that is the case the number of years in jail will be incremented two times. The continue statement is then executed ignoring any other lines of code in the for loop (lines 37 &#8211; 38) .</p>
<p>If the random number was not more then 5 then the jail time is only incremented once in line 37.  </p>
<p><strong>Part 2.5: Nested loops</strong></p>
<p>Just like if statements loops can also be nested. A nested loop will contain an outer and inner loop. With nested loops the inner loop is executed for each time that the outer loop is executed. Example 7 shows a nested loop:</p>
<p><img src="http://fredreh.files.wordpress.com/2009/08/ex7.png?w=510&#038;h=380" alt="Example 7" title="Example 7" width="510" height="380" class="aligncenter size-full wp-image-179" /></p>
<p><strong>Part 3: Recursive functions</strong></p>
<p>A recursive function is  a function that calls itself repeatedly until some condition is met and the function can return a value. This sounds very much like loops and in a way they are the same. The most basic recursive function you can create is shown in example 8:</p>
<p><img src="http://fredreh.files.wordpress.com/2009/08/ex8.png?w=384&#038;h=428" alt="Example 8" title="Example 8" width="384" height="428" class="aligncenter size-full wp-image-180" /></p>
<p> In Example program 8 the function recurse(int count) (line 15) receives as an argument one integer. Then inside the function on line 18 the function calls itself with the original count + 1. This will lead to each instance of the recurse function receiving an argument that was incremented by one. The recurse function will keep calling itself and never return a value leading to an infinite recurse.</p>
<p>To make sure that the function does not just keep calling itself one needs to add a base case to the function. The base case is a condition that will return something from the function and stop the cycle of calls. </p>
<p>Example 9 shows a recursive function with a base case. The function will receive a number and start counting down until 0 is reached where it will the return 0 :</p>
<p><img src="http://fredreh.files.wordpress.com/2009/08/exp9.png?w=510&#038;h=302" alt="Example 9 " title="Example 9 " width="510" height="302" class="aligncenter size-full wp-image-181" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fredreh.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fredreh.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fredreh.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fredreh.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fredreh.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fredreh.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fredreh.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fredreh.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fredreh.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fredreh.wordpress.com/170/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=170&subd=fredreh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://fredreh.wordpress.com/2009/08/25/c-tutorial-switch-loops-and-recursive-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/261c50bef03f7c2ca33d339bd785c3a3?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">fredreh</media:title>
		</media:content>

		<media:content url="http://fredreh.files.wordpress.com/2009/08/ex1.png" medium="image">
			<media:title type="html">Example 1</media:title>
		</media:content>

		<media:content url="http://fredreh.files.wordpress.com/2009/08/ex2.png" medium="image">
			<media:title type="html">Example 2</media:title>
		</media:content>

		<media:content url="http://fredreh.files.wordpress.com/2009/08/ex3.png" medium="image">
			<media:title type="html">Example 3</media:title>
		</media:content>

		<media:content url="http://fredreh.files.wordpress.com/2009/08/ex4.png" medium="image">
			<media:title type="html">Example 4</media:title>
		</media:content>

		<media:content url="http://fredreh.files.wordpress.com/2009/08/ex5.png" medium="image">
			<media:title type="html">Example 5</media:title>
		</media:content>

		<media:content url="http://fredreh.files.wordpress.com/2009/08/ex61.png" medium="image">
			<media:title type="html">Example 6</media:title>
		</media:content>

		<media:content url="http://fredreh.files.wordpress.com/2009/08/ex7.png" medium="image">
			<media:title type="html">Example 7</media:title>
		</media:content>

		<media:content url="http://fredreh.files.wordpress.com/2009/08/ex8.png" medium="image">
			<media:title type="html">Example 8</media:title>
		</media:content>

		<media:content url="http://fredreh.files.wordpress.com/2009/08/exp9.png" medium="image">
			<media:title type="html">Example 9 </media:title>
		</media:content>
	</item>
		<item>
		<title>My Podcast selection</title>
		<link>http://fredreh.wordpress.com/2009/06/21/my-podcast-selection/</link>
		<comments>http://fredreh.wordpress.com/2009/06/21/my-podcast-selection/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 16:32:14 +0000</pubDate>
		<dc:creator>fredreh</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://fredreh.wordpress.com/?p=166</guid>
		<description><![CDATA[I have a 30 min drive to work each day. The road I use is single lane and used by big trucks, taxi&#8217;s and a wide array of mine vehicles. I always thought that taxi drivers were the worst but have since changed my mind.
In my opinion the worst drivers are people driving mine vehicles [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=166&subd=fredreh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have a 30 min drive to work each day. The road I use is single lane and used by big trucks, taxi&#8217;s and a wide array of mine vehicles. I always thought that taxi drivers were the worst but have since changed my mind.</p>
<p>In my opinion the worst drivers are people driving mine vehicles especially the ones with 4&#215;4&#8217;s. But luckily I have found something to take my mind of the driving in a range of nice podcasts. This is my selection in order of preference:</p>
<p>1.  <a href="http://www.dancarlin.com/disp.php/hh">Dan Carlin&#8217;s Hardcore History</a></p>
<p>WOW History presented in an interesting and fun way. You can hear that Dan does much research before each show. The way he presents each topic makes you think differently about history and the present day.</p>
<p>2. <a href="http://www.thenakedscientists.com/">The Naked Scientists</a></p>
<p>Not just science news but also stuff you can do at home. Great for learning about all the different science fields </p>
<p>3. <a href="http://linuxoutlaws.com/">Linux Outlaws </a></p>
<p>Fabian and Dan are just two normal Linux users talking about Linux and related free/open source topics. The show always has a great selection of news and is probably the best pod cast when it comes to finding out what distribution released when. The Microwatch section also keeps tabs on what the evil Micro$oft is up to. </p>
<p>4. <a href="http://podcast.ubuntu-uk.org/">Ubuntu UK Podcast</a>   </p>
<p>A few Brits talking about Linux and Ubuntu. Because of their link to the Ubuntu distribution you get a good idea about the latest ongoings at Canonical and the Ubuntu distro. Also look out for the competitions.</p>
<p>There you go. If you have any other podcasts that you like please let me know so that I can try them.   </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fredreh.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fredreh.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fredreh.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fredreh.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fredreh.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fredreh.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fredreh.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fredreh.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fredreh.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fredreh.wordpress.com/166/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=166&subd=fredreh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://fredreh.wordpress.com/2009/06/21/my-podcast-selection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/261c50bef03f7c2ca33d339bd785c3a3?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">fredreh</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Web Toolkit (GWT) &#8211; Generate FileMenu from XML</title>
		<link>http://fredreh.wordpress.com/2009/06/21/google-web-toolkit-gwt-generate-filemenu-from-xml/</link>
		<comments>http://fredreh.wordpress.com/2009/06/21/google-web-toolkit-gwt-generate-filemenu-from-xml/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 09:48:06 +0000</pubDate>
		<dc:creator>fredreh</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://fredreh.wordpress.com/?p=159</guid>
		<description><![CDATA[I have been playing around with GWT the last few weeks and wrote a nice little function that reads a XML file and builds a FileMenu.
Real GWT programmers will probably frown on the code but please keep in mind this is only for fun. The XML structure looks like this:

links
mainLink name='My Links'
subLink name='Blog' url='http://fredreh.wordpress.com' title='My [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=159&subd=fredreh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have been playing around with GWT the last few weeks and wrote a nice little function that reads a XML file and builds a FileMenu.</p>
<p>Real GWT programmers will probably frown on the code but please keep in mind this is only for fun. The XML structure looks like this:</p>
<p><code><br />
links</p>
<p>mainLink name='My Links'<br />
subLink name='Blog' url='http://fredreh.wordpress.com' title='My Blog' /subLink<br />
subLink name='Facebook' url='http://facebook.com' title='See some friends' /subLink<br />
/mainLink</p>
<p>mainLink name='Test'<br />
subLink name='Tester' url='http://www.test.ac.za/' title='Tester' /subLink<br />
/mainLink</p>
<p>mainLink name='Search Engines'<br />
subLink name='Google' url='http://www.google.com/' title='Google'  /subLink<br />
subLink name='Wolfram' url='http://www.google.com/' title='Wolfram' /subLink<br />
/mainLink</p>
<p>/links<br />
</code></p>
<p>The file name is links.xml the function BuildMenu() looks like this:</p>
<p><code><br />
public void BuildMenu()<br />
{<br />
//Build the menus<br />
//The requist builder for the XML passwords<br />
RequestBuilder buildL = new RequestBuilder(RequestBuilder.GET,"links.xml");<br />
//The main menu<br />
final MenuBar linksmen = new MenuBar(true);<br />
try<br />
{<br />
buildL.sendRequest(null,new RequestCallback()<br />
{<br />
public void onError(Request request, Throwable exception)<br />
{<br />
Window.alert("Could not get a list of Links for MenuBar");<br />
}</code></p>
<p><code>public void onResponseReceived(Request request, Response response)<br />
{</p>
<p>//Check the xml file and load the nodes inside<br />
Element TopLvl = XMLParser.parse(response.getText()).getDocumentElement();</p>
<p>//Get a list of nodes under the main  node<br />
NodeList mainLink = TopLvl.getElementsByTagName("mainLink");</p>
<p>//Loop through the list of mainLink nodes<br />
for(int j=0;j&lt;mainLink.getLength();j++)<br />
{<br />
//Create the Element representing a<br />
Element main = (Element)mainLink.item(j);</p>
<p>//The menubar representing a<br />
MenuBar MLink = new MenuBar(true);</p>
<p>//A list of nodes inside the   each one is a<br />
NodeList subLink = main.getElementsByTagName("subLink");</p>
<p>//Loop through the list of subLink nodes<br />
for(int i=0;i&lt;subLink.getLength();i++)<br />
{<br />
//Create the Element representing a<br />
final Element sub = (Element)subLink.item(i);<br />
//Add the subLink details to the Mlink MenuBar<br />
MLink.addItem(sub.getAttribute("name"),new Command(){public void execute(){Window.open(sub.getAttribute("url"),sub.getAttribute("title"),"");}});<br />
}</p>
<p>//Add the completed MLink menubar to the main linksmen MenuBar<br />
linksmen.addItem( main.getAttribute("name"),MLink);<br />
}</p>
<p>}<br />
}<br />
);<br />
}<br />
catch (RequestException e)<br />
{<br />
Window.alert("Error");<br />
return;<br />
}</p>
<p>GLeftMen.setWidget(0,0,lblLinks);<br />
GLeftMen.setWidget(1,0,linksmen);<br />
}</p>
<p></code></p>
<p>I commented the code heavily and it shoud be clear.</p>
<p>Looking at the code I wonder how difficult it would be to take the XML generated by Glade and then build an interface when the user loads the page.</p>
<p>Anyway I hope someone can use the code it is licenced under WTFPL</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fredreh.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fredreh.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fredreh.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fredreh.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fredreh.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fredreh.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fredreh.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fredreh.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fredreh.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fredreh.wordpress.com/159/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=159&subd=fredreh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://fredreh.wordpress.com/2009/06/21/google-web-toolkit-gwt-generate-filemenu-from-xml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/261c50bef03f7c2ca33d339bd785c3a3?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">fredreh</media:title>
		</media:content>
	</item>
		<item>
		<title>A Cyber-Attack on an American City&#8230; (by South Africans)</title>
		<link>http://fredreh.wordpress.com/2009/04/23/a-cyber-attack-on-an-american-city-by-south-africans/</link>
		<comments>http://fredreh.wordpress.com/2009/04/23/a-cyber-attack-on-an-american-city-by-south-africans/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 07:53:14 +0000</pubDate>
		<dc:creator>fredreh</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://fredreh.wordpress.com/?p=157</guid>
		<description><![CDATA[Bruce Perens writes about a recent cyber attack on an American  city:
&#8220;Just after midnight on Thursday, April 9, unidentified attackers climbed         down four manholes serving the Northern California city of Morgan Hill and          cut eight fiber cables  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=157&subd=fredreh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Bruce Perens <a href="http://perens.com/works/articles/MorganHill/">writes about</a> a recent cyber attack on an American  city:</p>
<p style="padding-left:30px;">&#8220;Just after midnight on Thursday, April 9, unidentified attackers climbed         down four manholes serving the Northern California city of Morgan Hill and         <a href="http://www.mercurynews.com/localnewsheadlines/ci_12106300"> cut eight fiber cables </a> in what appears to have been an organized attack on the electronic         infrastructure of an         American city. Its implications, though startling, have gone almost         un-reported.&#8221;</p>
<p>We have been having problems with criminals stealing the Telkom cables maybe they upped their game and went International with this job.  Did anyone check if the cables was removed instead of just cut ?.</p>
<p>But it is interesting on how a city can be technology disabled by cutting a cable in America, luckily we don&#8217;t suffer from the same problem since we can not  rely on fixed lines in the first place.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fredreh.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fredreh.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fredreh.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fredreh.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fredreh.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fredreh.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fredreh.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fredreh.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fredreh.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fredreh.wordpress.com/157/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=157&subd=fredreh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://fredreh.wordpress.com/2009/04/23/a-cyber-attack-on-an-american-city-by-south-africans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/261c50bef03f7c2ca33d339bd785c3a3?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">fredreh</media:title>
		</media:content>
	</item>
		<item>
		<title>Long time no post</title>
		<link>http://fredreh.wordpress.com/2009/04/19/long-time-no-post/</link>
		<comments>http://fredreh.wordpress.com/2009/04/19/long-time-no-post/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 09:17:22 +0000</pubDate>
		<dc:creator>fredreh</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://fredreh.wordpress.com/?p=155</guid>
		<description><![CDATA[I am happy to report that my lack of posting is because of a few nice changes in my life.
I have started a new job as Junior Lecturer at Tswane University of Technology teaching 1st and 3rd years. This doest leave a lot of time for working on projects but I have made some progress [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=155&subd=fredreh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I am happy to report that my lack of posting is because of a few nice changes in my life.</p>
<p>I have started a new job as Junior Lecturer at Tswane University of Technology teaching 1st and 3rd years. This doest leave a lot of time for working on projects but I have made some progress on the Mxit perl library.</p>
<p>Since Mxit have released the protocol specification I have moved the project over to their site located here:<a href="http://devzone.mxit.com/"> http://devzone.mxit.com/</a></p>
<p>The project has its own space located<a href="http://devzone.mxit.com/trac/libmxit_perl"> here (Wiki)</a> and <a href="http://devzone.mxit.com/libmxit_perl/">here (Blog) </a></p>
<p>Since the campus were I teach is located in Witbank I have moved back in with my parents in Middelburg about 30 km from the campus. I will probably get my own place before the end of the year.</p>
<p>One cool application I can report on is <a href="https://www.getdropbox.com/link/21.X7hWEhmrJV">DropBox</a> . DropBox allows you to sync files over multiple computers and is nicely<br />
integrated with Gnome. The registration process is totally painless and you get 2 GB free when you sign up (250 mb extra for using this <a href="https://www.getdropbox.com/link/21.X7hWEhmrJV">https://www.getdropbox.com/link/21.X7hWEhmrJV</a> link)</p>
<p>I have also upgraded to Ubuntu 9.04 and will report on the experience at a later time.</p>
<p>Remember keep the source open and have a nice series of long weekends (If you are in S.A)</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fredreh.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fredreh.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fredreh.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fredreh.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fredreh.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fredreh.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fredreh.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fredreh.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fredreh.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fredreh.wordpress.com/155/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=155&subd=fredreh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://fredreh.wordpress.com/2009/04/19/long-time-no-post/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/261c50bef03f7c2ca33d339bd785c3a3?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">fredreh</media:title>
		</media:content>
	</item>
		<item>
		<title>Why you dont steal a Linux users car</title>
		<link>http://fredreh.wordpress.com/2008/11/22/why-you-dont-steal-a-linux-users-car/</link>
		<comments>http://fredreh.wordpress.com/2008/11/22/why-you-dont-steal-a-linux-users-car/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 17:47:38 +0000</pubDate>
		<dc:creator>fredreh</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://fredreh.wordpress.com/?p=153</guid>
		<description><![CDATA[I just picked this story up from the GLUG mailing list. 
Apparently Andre Coetzee and his family was driving along when they spotted his wife&#8217;s car that was stolen a while back. He then chased the criminals down and got his own back.
My own car was also stolen about six months ago but unfortunately I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=153&subd=fredreh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I just picked <a href="http://www.andre.co.za/a.php?a=191/How-to-Hijack-a-car-in-Johannesburg">this</a> story up from the GLUG mailing list. </p>
<p>Apparently Andre Coetzee and his family was driving along when they spotted his wife&#8217;s car that was stolen a while back. He then chased the criminals down and got his own back.</p>
<p>My own car was also stolen about six months ago but unfortunately I have had no such luck.</p>
<p>Read the full story on his site:<br />
<a href="http://www.andre.co.za/a.php?a=191/How-to-Hijack-a-car-in-Johannesburg">http://www.andre.co.za/a.php?a=191/How-to-Hijack-a-car-in-Johannesburg</a> </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fredreh.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fredreh.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fredreh.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fredreh.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fredreh.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fredreh.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fredreh.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fredreh.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fredreh.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fredreh.wordpress.com/153/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=153&subd=fredreh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://fredreh.wordpress.com/2008/11/22/why-you-dont-steal-a-linux-users-car/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/261c50bef03f7c2ca33d339bd785c3a3?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">fredreh</media:title>
		</media:content>
	</item>
		<item>
		<title>Fun with the Facebook API and a new WargenInt</title>
		<link>http://fredreh.wordpress.com/2008/09/28/fun-with-the-facebook-api-and-a-new-wargenint/</link>
		<comments>http://fredreh.wordpress.com/2008/09/28/fun-with-the-facebook-api-and-a-new-wargenint/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 17:42:52 +0000</pubDate>
		<dc:creator>fredreh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fredreh.wordpress.com/?p=140</guid>
		<description><![CDATA[I wrote my first Facebook desktop application called Lfcal last week. The process was mostly painless thanks to the people from pyfacebook.  On the Perl side of things WargenInt 1.0 sees the light of day with both scripts for Xchat and Irssi.
Lfcal
It was my birthday last week and some of my friends on Facebook [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=140&subd=fredreh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I wrote my first Facebook desktop application called <a href="http://fredreh.wordpress.com/lfcal/">Lfcal</a> last week. The process was mostly painless thanks to the people from <a href="http://code.google.com/p/pyfacebook">pyfacebook</a>.  On the Perl side of things WargenInt 1.0 sees the light of day with both scripts for Xchat and Irssi.</p>
<p><strong>Lfcal</strong><br />
It was my birthday last week and some of my friends on Facebook sent a message or wall post saying Happy B day. This set me thinking  I almost never do this because I don&#8217;t remember birthdays  and I only log in to Facebook about once a week to see what everybody is doing. So after a Google or two I found pyfacebook &#8220;a thin wrapper for accessing Facebook&#8217;s RESTful API through Python&#8221; and created a application to get all the birthdays of my Facebook friends. But just to get the dates is not enough I also want to be reminded each day this is where Calender comes in handy.</p>
<p><a href="http://www.computerhope.com/unix/ucalande.htm">Calender</a> is a Linux command line application that reads a calendar file with dates and prints the information on the screen. A while back I added calendar to bashrc to get all my reminders each time I open a new bash shell something I am guaranteed to do at least once a day when I use my computer. Instead of just displaying birthdays Lfcal can also add each birthday to the calendar file provided as an argument. Now it is possible to be reminded of birthdays without going to Facebook everyday. To find out more about Lfcal  click <a href="http://fredreh.wordpress.com/my-projects/lfcal/">here</a>.     </p>
<p><strong>WargenInt</strong><br />
I started hacking on a GTK interface for the All-Out-War IRC game and released version 1 this week. Some of the changes since 0.6 include a small rewrite to the way that the interface communicates with the Bot running the game. </p>
<p>In the past the interface needed an Ip and port provided by the Bot when the DCC request is sent and in a way bypassed the DCC chat capability of the users IRC client. This was removed and the interface now uses the Xchat perl scripting interface allowing a tighter integration with the Xchat DCC chat capabilities leading to a more stable and reliable application. This also turns the Interface into a Xchat script.  Another small addition is a Irssi script that includes all the automatic features of WargenInt without the GTK interface.</p>
<p>Finally I have given up on Windows users most of them use MIRC anyway and are not to keen to switch to Xchat. Testing on Windows is also hard since I don&#8217;t have a copy installed at the moment. I will be happy to provide information if someone wants to maintain a Windows version or try the Interface with Xchat on Windows but I think it will just be easier to install <a href="http://www.ubuntu.com/">Ubuntu</a> or <a href="http://www.mandriva.com/">Mandriva</a> and come over to the good side of the force.  </p>
<p>For more on WargenInt click <a href="http://fredreh.wordpress.com/my-projects/wargenint/">here</a>.</p>
<p>If you are looking for a nice game head over to irc.atrum.org #all-out-war. Happy <a href="http://www.catb.org/~esr/faqs/hacker-howto.html#what_is">hacking</a> !!!.      </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fredreh.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fredreh.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fredreh.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fredreh.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fredreh.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fredreh.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fredreh.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fredreh.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fredreh.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fredreh.wordpress.com/140/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=140&subd=fredreh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://fredreh.wordpress.com/2008/09/28/fun-with-the-facebook-api-and-a-new-wargenint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/261c50bef03f7c2ca33d339bd785c3a3?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">fredreh</media:title>
		</media:content>
	</item>
		<item>
		<title>Xchat DCC Chat how to send a message using /msg</title>
		<link>http://fredreh.wordpress.com/2008/08/21/xchat-dcc-chat-how-to-send-a-message-using-msg/</link>
		<comments>http://fredreh.wordpress.com/2008/08/21/xchat-dcc-chat-how-to-send-a-message-using-msg/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 08:18:55 +0000</pubDate>
		<dc:creator>fredreh</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://fredreh.wordpress.com/?p=123</guid>
		<description><![CDATA[I was working on a Xchat script in Perl that does some things based on the text received by a BOT over a DCC chat connection.
Creating a DCC chat session with the bot is easy and once the chat is connected a new tab is created with the nick of the bot where you can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=123&subd=fredreh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I was working on a Xchat script in Perl that does some things based on the text received by a BOT over a DCC chat connection.</p>
<p>Creating a DCC chat session with the bot is easy and once the chat is connected a new tab is created with the nick of the bot where you can type in messages. The problem with the script was that their was obviously no tab and no human to type in the needed responses based on what the BOT was sending. </p>
<p>I looked this up and according to documentation once a DCC chat connection is established you can just use MSG   to send messages over the link. So in the Perl script I was suppose to use: Xchat::command(&#8220;msg BOT-NAME MY MESSAGE&#8221;);. This didn&#8217;t work the message I just sent using the script was displayed in the tab as if I typed it in but the BOT didn&#8217;t respond. I also tried to type in &#8220;/msg BOT-NAME My message&#8221; again the same results. It was as if xchat got the message but didn&#8217;t send the message.</p>
<p>After a lot of searching around I found <a href="http://tldp.org/HOWTO/text/IRC">this Linux IRC mini-HOWTO by Frédéric L. W. Meunier</a> and the following line of text in this howto: &#8220;/dcc chat nick starts a chat with nick. Use /msg =nick (notice the =) to send messages over the chat.</p>
<p>It turns out in Xhat 2.8.4 on Linux when using /msg over a dcc CHAT link you should add = to the nick you are sending a message to: Xchat::command(&#8220;msg =BOT-NAME MY MESSAGE&#8221;);. This solved my problem thanks Frédéric. </p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/fredreh.wordpress.com/123/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/fredreh.wordpress.com/123/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fredreh.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fredreh.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fredreh.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fredreh.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fredreh.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fredreh.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fredreh.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fredreh.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fredreh.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fredreh.wordpress.com/123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=123&subd=fredreh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://fredreh.wordpress.com/2008/08/21/xchat-dcc-chat-how-to-send-a-message-using-msg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/261c50bef03f7c2ca33d339bd785c3a3?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">fredreh</media:title>
		</media:content>
	</item>
		<item>
		<title>Gtk Perl Notebook get_current_page Problem and Solution</title>
		<link>http://fredreh.wordpress.com/2008/07/30/gtk-perl-notebook-get_current_page-problem-and-solution/</link>
		<comments>http://fredreh.wordpress.com/2008/07/30/gtk-perl-notebook-get_current_page-problem-and-solution/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 16:40:32 +0000</pubDate>
		<dc:creator>fredreh</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://fredreh.wordpress.com/?p=99</guid>
		<description><![CDATA[I am working on something that uses Perl Gtk and Glade. Everything works fine except that when I want to get the currently selected page on the notebook using $notebook-&#62;get_current_page the currently selected page is not returned but the previous selected page.
My code looks like this:
#Get widget and assign to variable 
$notebookMain =  $gladexml-&#62;get_widget(&#8216;notebookMain&#8217;);
#Bind [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=99&subd=fredreh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I am working on something that uses Perl Gtk and Glade. Everything works fine except that when I want to get the currently selected page on the notebook using $notebook-&gt;get_current_page the currently selected page is not returned but the previous selected page.</p>
<p>My code looks like this:</p>
<p><strong>#Get widget and assign to variable </strong><br />
$notebookMain =  $gladexml-&gt;get_widget(&#8216;notebookMain&#8217;);</p>
<p><strong>#Bind signal to a subroutine in this case the switch-page signal of Notebook </strong><br />
on_notebookMain_switch_page=&gt;\&amp;on_notebookMain_switch_page </p>
<p><strong>#The sub getting executed when user changes to another page</strong><br />
sub on_notebookMain_switch_page<br />
{<br />
$curr_page = $notebookMain-&gt;get_current_page;<br />
}</p>
<p>From that I should get the current page of $notebookMain when the user clicks on a different page but like I said before this doesn&#8217;t  work.</p>
<p>The big hint when searching Google for a answer <a href="http://osdir.com/ml/gnome.gtk+.perl/2003-10/msg00081.html">came with this post</a>. So I tried what Torsten suggested and changed my  <em>sub on_notebookMain_switch_page</em> like this:</p>
<p><strong>#The sub getting executed when user changes to another page</strong><br />
sub on_notebookMain_switch_page<br />
{<br />
$curr_page = $notebookMain-&gt;get_current_page;<br />
<em>warn join(&#8220;, &#8220;, @_);</em><br />
}</p>
<p>This gave the following output when I changed pages:</p>
<p>Gtk2::Notebook=HASH(0&#215;85ffff0), 141979504, 1,  at /home/fredre/Desktop/WargenInterface/WIP.pl line 93.<br />
Gtk2::Notebook=HASH(0&#215;85ffff0), 141773512, 0,  at /home/fredre/Desktop/WargenInterface/WIP.pl line 93.<br />
Gtk2::Notebook=HASH(0&#215;85ffff0), 141982680, 2,  at /home/fredre/Desktop/WargenInterface/WIP.pl line 93.<br />
Gtk2::Notebook=HASH(0&#215;85ffff0), 141989048, 3,  at /home/fredre/Desktop/WargenInterface/WIP.pl line 93.</p>
<p>From this I could gather that the correct current page is located in @_ and it is not the number get_current_page is returning.</p>
<p>So to get the correct currently selected page the subroutine should look like this:</p>
<p><strong>#The sub getting executed when user changes to another page</strong><br />
sub on_notebookMain_switch_page<br />
{<br />
$curr_page = $_[2];<br />
}</p>
<p>I don&#8217;t know if the problem occurs because I was using Glade or if I just missed something along the way.</p>
<p>I was using:</p>
<p>libGtk2-Perl 1:1.161-1<br />
libGtk2-gladexml-perl 1.006-1<br />
Glade 3.4.2<br />
perl 5.8.8</p>
<p>all from the Ubuntu repositories .</p>
<p>Happy Hacking !!!!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/fredreh.wordpress.com/99/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/fredreh.wordpress.com/99/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fredreh.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fredreh.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fredreh.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fredreh.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fredreh.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fredreh.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fredreh.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fredreh.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fredreh.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fredreh.wordpress.com/99/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=99&subd=fredreh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://fredreh.wordpress.com/2008/07/30/gtk-perl-notebook-get_current_page-problem-and-solution/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/261c50bef03f7c2ca33d339bd785c3a3?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">fredreh</media:title>
		</media:content>
	</item>
		<item>
		<title>Perl GTK: How to insert text at the end of a GTK TextView</title>
		<link>http://fredreh.wordpress.com/2008/07/28/perl-gtk-how-to-insert-text-at-the-end-of-a-gtk-textview/</link>
		<comments>http://fredreh.wordpress.com/2008/07/28/perl-gtk-how-to-insert-text-at-the-end-of-a-gtk-textview/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 17:46:54 +0000</pubDate>
		<dc:creator>fredreh</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://fredreh.wordpress.com/?p=95</guid>
		<description><![CDATA[Just a quick note if you are working with Perl and GTK and you want to append the text or insert some text into a GTK TextView while keeping the original text. This code will add text to TextView at the bottom.
#First create your TextView
$textview_Main = Code to create TextView;
#Get the buffer of the newly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=95&subd=fredreh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Just a quick note if you are working with Perl and GTK and you want to append the text or insert some text into a GTK TextView while keeping the original text. This code will add text to TextView at the bottom.</p>
<p><strong>#First create your TextView</strong><br />
$textview_Main = Code to create TextView;</p>
<p><strong>#Get the buffer of the newly created TextView</strong><br />
$textbuffer = $textview_Main-&gt;get_buffer;</p>
<p><strong>#Get the end iter of the buffer</strong><br />
$textiter = $textbuffer-&gt;get_end_iter;</p>
<p><strong>#Insert some text into the buffer</strong><br />
$textbuffer-&gt;insert($textiter,&#8221;Testing \n&#8221;);</p>
<p><strong>#Set the buffer of the TextView to display new text</strong><br />
$textview_Main-&gt;set_buffer($textbuffer);</p>
<p>Enjoy programming with Perl and GTK !!!!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/fredreh.wordpress.com/95/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/fredreh.wordpress.com/95/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fredreh.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fredreh.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fredreh.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fredreh.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fredreh.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fredreh.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fredreh.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fredreh.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fredreh.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fredreh.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fredreh.wordpress.com&blog=3067023&post=95&subd=fredreh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://fredreh.wordpress.com/2008/07/28/perl-gtk-how-to-insert-text-at-the-end-of-a-gtk-textview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/261c50bef03f7c2ca33d339bd785c3a3?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">fredreh</media:title>
		</media:content>
	</item>
	</channel>
</rss>