<?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>As Big As This &#187; GTK Programming</title>
	<atom:link href="http://asbigasthis.wordpress.com/category/gtk-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://asbigasthis.wordpress.com</link>
	<description>Alalalalala</description>
	<lastBuildDate>Thu, 25 Jun 2009 01:24:57 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='asbigasthis.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/83d5eccacbd45f05fa62474f527e150d?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>As Big As This &#187; GTK Programming</title>
		<link>http://asbigasthis.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://asbigasthis.wordpress.com/osd.xml" title="As Big As This" />
		<item>
		<title>Sorry I haven&#8217;t been posting&#8230;.</title>
		<link>http://asbigasthis.wordpress.com/2009/06/25/sorry-i-havent-been-posting/</link>
		<comments>http://asbigasthis.wordpress.com/2009/06/25/sorry-i-havent-been-posting/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 01:24:57 +0000</pubDate>
		<dc:creator>negavite</dc:creator>
				<category><![CDATA[GTK Programming]]></category>
		<category><![CDATA[busy]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[sorry]]></category>

		<guid isPermaLink="false">http://asbigasthis.wordpress.com/2009/06/25/sorry-i-havent-been-posting/</guid>
		<description><![CDATA[Hello Everyone,
Sorry I haven&#8217;t been able to post as much as I&#8217;ve been wanting to. I&#8217;ve been studying a lot, and well, just very busy. I do have a little good news, I&#8217;m trying to make a &#8220;Pong&#8221; like game in Gtk+, and when it&#8217;s done, I&#8217;ll post the source code for everyone to see [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asbigasthis.wordpress.com&blog=2946776&post=36&subd=asbigasthis&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Hello Everyone,</p>
<p>Sorry I haven&#8217;t been able to post as much as I&#8217;ve been wanting to. I&#8217;ve been studying a lot, and well, just very busy. I do have a little good news, I&#8217;m trying to make a &#8220;Pong&#8221; like game in Gtk+, and when it&#8217;s done, I&#8217;ll post the source code for everyone to see <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
Posted in GTK Programming  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asbigasthis.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asbigasthis.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asbigasthis.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asbigasthis.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asbigasthis.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asbigasthis.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asbigasthis.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asbigasthis.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asbigasthis.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asbigasthis.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asbigasthis.wordpress.com&blog=2946776&post=36&subd=asbigasthis&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://asbigasthis.wordpress.com/2009/06/25/sorry-i-havent-been-posting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0f57e9e62bb4e4cfed18b3ae58a60507?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Negavite</media:title>
		</media:content>
	</item>
		<item>
		<title>Why Gtk+ May be the Greatest GUI Toolkit Ever!</title>
		<link>http://asbigasthis.wordpress.com/2009/06/06/why-gtk-may-be-the-greatest-gui-toolkit-ever/</link>
		<comments>http://asbigasthis.wordpress.com/2009/06/06/why-gtk-may-be-the-greatest-gui-toolkit-ever/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 04:46:24 +0000</pubDate>
		<dc:creator>negavite</dc:creator>
				<category><![CDATA[GTK Programming]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[gtk+]]></category>

		<guid isPermaLink="false">http://asbigasthis.wordpress.com/?p=27</guid>
		<description><![CDATA[This is an article I wrote a while back, it&#8217;s been published an spread around a little.
 
When it comes to programming a lot of people look to C/C++ for answers. They’re pretty straightforward languages that are general-purpose(they aren’t really good at anything in particular, but can be used to do just about anything). The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asbigasthis.wordpress.com&blog=2946776&post=27&subd=asbigasthis&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This is an article I wrote a while back, it&#8217;s been published an spread around a little.</p>
<p><span style="background:#f9f9f9;font-size:10px;"> </span></p>
<p>When it comes to programming a lot of people look to C/C++ for answers. They’re pretty straightforward languages that are general-purpose(they aren’t really good at anything in particular, but can be used to do just about anything). The only strike against these languages is that unlike Java, they don’t bring a GUI API built in. Instead, C/C++ coders must rely on other libraries and even system APIs to get the job done.</p>
<p>Introduction<br />
Nowadays almost every application has to have a GUI. Users rely on graphical interfaces, and a programmers job isn’t only to code up an app, but to also make it best for the consumer. Now this leads one to wonder, “What should I use to make the GUI part of my program?”.</p>
<p>Well, the answer isn’t always straightforward, but there is one toolkit that looks a little better than the rest. It’s Gtk+. GTK+, or The GIMP Toolkit, is a cross-platform GUI toolkit and, is one of the most popular toolkits for the X Window System, along with Qt.</p>
<p>So what makes Gtk+ so speacial? Why could it possibly deserve the title of “Greatest GUI Toolkit Ever”? That is the point of this article. Here we will discuss a little bit about it, and see why it is a very good choice for developers.</p>
<p>1. Simple Syntax<br />
One of the best features of Gtk+ is its simplicity of syntax. Almost everything is predefined, you just gotta point everything in the right direction.</p>
<p>For example, this little snippet below creates a pretty basic window (300px wide, 150px high, aligned to the center of screen, and says “A Window” in the titlebar):</p>
<p>#include</p>
<p>int main( int argc, char *argv[])<br />
{<br />
GtkWidget *window; // creates the window object</p>
<p>gtk_init(&amp;argc, &amp;argv); // this handles commandline arguments, don&#8217;t worry to much about it</p>
<p>/* Here we setup the window */<br />
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);<br />
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);<br />
gtk_window_set_default_size(GTK_WINDOW(window), 300, 150);<br />
gtk_window_set_title(GTK_WINDOW(window), &#8220;A Window&#8221;);</p>
<p>gtk_widget_show(window); // this makes it appear</p>
<p>gtk_main(); // this puts the program in a loop waiting for events</p>
<p>return 0;<br />
}</p>
<p>Amazing. That was all done in about twenty lines of code, and you could even reduce that more by getting rid of whitespace. Just for fun, I tried making something similar in Win32; my result was more than 70 lines of code, and that was just for the basics.</p>
<p>In case you’re wondering why you would choose a toolkit just because of syntax ease (or if you should even care), you must consider that the easier it is to write a program, the easier it would be to take care of it, as well as find bugs. As you will see later, Gtk+ has many features that help to make maintenance easier.</p>
<p>2. Great Structure<br />
Not does only does Gtk+ have sytax that’s easy to follow, but is also designed in a way that makes it easier to work with. For example, you define the objects and widgets (a button or window, or dialogue), you pass it parameters and set it up, and you then either pack it into the window, or a box etc. Then all that’s left is to make it show up. Of course a real application would have callbacks so that widgets would respond to events, but still that’s pretty good.</p>
<p>It’s structure like this that helps programs for becoming “code soup” and lets developers worry less about “how they’re gonna setup the application”, and more about “when they are gonna code that badboy up”.</p>
<p>3. Lightweight and Fast<br />
One of the best things about Gtk+ is its weight and execution times. This toolkit is especially good if resources are a concern to you. Applications written with Gtk+ are far less likely to crash due to not enough memory, freeze up, etc.</p>
<p>Here’s a good example: I’m working on creating a open source project right now. So far all I’ve coded is the GUI, and while I still have a long way to go before it has full functionality, the bare-bones app is only 30.4KB and executes in well under a second. Now it’s been a while since I’ve done a lot in Win32, but from what I remember even very simple applications were in the “200KB” range. That’s more than 6 times as big. In the long run, that could really add up.</p>
<p>4. Portable<br />
Last but not least is the fact that Gtk+ is portable. It’s pretty much write once, work anywhere (Of course the users have to have the right stuff to run you’re program, but this generally wouldn’t be an issue).</p>
<p>This is a great thing for programmers. A lot of programmers are turning to Java because of its “multi-platformism”; but this gives C/C++ coders a real alternative to learning a whole new language, or having to be greatly limited by another language. The portability of Gtk+ is a truly great advantage and is also a good explanation for success of toolkits like “WxWidgets” and “QT”</p>
<p>Conclusion<br />
In conclusion I hope you considered many of the things I’ve mentioned here, and are now looking into getting to know/use Gtk+. My goal here was to show you that Gtk+ is an amazing resource for C/C++ developers, and I hope I did so in as best as I could. If you find any errors, or have any suggestions, etc. please comment (I love it when people comment <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ).</p>
Posted in GTK Programming  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asbigasthis.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asbigasthis.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asbigasthis.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asbigasthis.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asbigasthis.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asbigasthis.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asbigasthis.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asbigasthis.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asbigasthis.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asbigasthis.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asbigasthis.wordpress.com&blog=2946776&post=27&subd=asbigasthis&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://asbigasthis.wordpress.com/2009/06/06/why-gtk-may-be-the-greatest-gui-toolkit-ever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0f57e9e62bb4e4cfed18b3ae58a60507?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Negavite</media:title>
		</media:content>
	</item>
		<item>
		<title>Changing the Basic Window</title>
		<link>http://asbigasthis.wordpress.com/2008/10/19/changing-the-basic-window/</link>
		<comments>http://asbigasthis.wordpress.com/2008/10/19/changing-the-basic-window/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 15:50:32 +0000</pubDate>
		<dc:creator>punongbisyonaryo</dc:creator>
				<category><![CDATA[GTK Programming]]></category>
		<category><![CDATA[GTK Tutorials]]></category>

		<guid isPermaLink="false">http://asbigasthis.wordpress.com/?p=16</guid>
		<description><![CDATA[In the last lesson, we learned the basic structure of a GTK Window. We also learned how to set the text that appears in the title bar. This time, we&#8217;ll go a small step further; we&#8217;ll change the window size as well as its position, set an icon for our program, create a basic menu, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asbigasthis.wordpress.com&blog=2946776&post=16&subd=asbigasthis&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In the last lesson, we learned the basic structure of a GTK Window. We also learned how to set the text that appears in the title bar. This time, we&#8217;ll go a small step further; we&#8217;ll change the window size as well as its position, set an icon for our program, create a basic menu, and finally destroy the program properly,</p>
<p><strong>Center and Set Window Size</strong></p>
<p>The code to do this is:</p>
<p><code>gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);<br />
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);</code></p>
<p>You may have already guessed, 400 is the width and 300 is the height, which we will set as the default size of our window. For the initial position, you may have noticed that one of the parameters is the constant GTK_WIN_POS_CENTER, which, you guessed it, centers the window.</p>
<p><strong>Set Window Icon</strong></p>
<p>The following is the function used for setting the window icon, using 2 parameters: the window, and a Gdk Pixelbuffer object.</p>
<p><code>gtk_window_set_icon(GTK_WINDOW(window), pixbuf);</code></p>
<p>The problem is converting your desired graphic into something useable as an icon. Here we borrow a function from Zetcode&#8217;s First Programs tutorial (see References) which accepts a filename as a parameter and returns a GdkPixbuf object:</p>
<p><code>GdkPixbuf *create_pixbuf(const gchar * filename)<br />
{<br />
GdkPixbuf *pixbuf;<br />
GError *error = NULL;<br />
pixbuf = gdk_pixbuf_new_from_file(filename, &amp;error);<br />
if(!pixbuf) {<br />
fprintf(stderr, "%s\n", error-&gt;message);<br />
g_error_free(error);<br />
}<br />
return pixbuf;<br />
}</code></p>
<p>The gdk_pixbuf_new_from_file() functions takes two parameters&#8211;the filename of the image, and a GError object where it&#8217;ll put an error message if something goes wrong. It automatically detects the filetype of the file and convert it into a GdkPixbuf object.</p>
<p>We make a call to the create_pixbuf() function as follows:</p>
<p><code>gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf("mylogo.gif"));</code></p>
<p>You can replace mylogo.gif with your own GIF, PNG, BMP, or JPG file.</p>
<p><strong>Create a Menu</strong></p>
<p>As mentioned in the first post, GTK uses hierarchies and containers quite extensively, and menus and submenus are no different. A menu is basically a container where you can put in items or even other containers i.e. submenus. The basic logic behind putting a menu into your GTK application is that the window itself is a container, and you attach a box container that will hold your menubar (itself a container), which will hold your menu (another container), which holds your menu items or even submenus (yet another container).</p>
<p>I did not grasp this relationship immediately when I studied it, so here I present the sample code relating to that hierarchical relationship. It may not be the best coding standard (personally, I prefer to put all my variable declarations together at the beginning), but for the sake of easier understanding, we&#8217;ll put relevant objects as they are needed and being built.</p>
<p>First, we create the menu items like so by creating new GtkWidgets and initializing them like so:</p>
<p><code>//Initialize the File menu items<br />
GtkWidget *file;<br />
GtkWidget *open;<br />
GtkWidget *quit;<br />
file = gtk_menu_item_new_with_label("File");<br />
open = gtk_menu_item_new_with_label("Open...");<br />
quit = gtk_menu_item_new_with_label("Quit");</code></p>
<p>Next, we create the File menu to hold our menu items:</p>
<p><code>//Initialize File menu and put in the menu items<br />
GtkWidget *filemenu;<br />
filemenu = gtk_menu_new();<br />
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu);<br />
gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), open);<br />
gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit);</code></p>
<p>Take note that we are actually setting first item (file) as a submenu. The open and quit menu items are then added to the filemenu using the gtk_menu_shell_append() function.</p>
<p>Next, we put our File menu into the menu bar:</p>
<p><code>//Initialize the menu bar and put in the File menu we created<br />
GtkWidget *menubar;<br />
menubar = gtk_menu_bar_new();<br />
gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file);</code></p>
<p>Now that everything&#8217;s almost set, we have to put our menubar on to the window itself:</p>
<p><code>//Put the menu bar into the window<br />
GtkWidget *vbox;<br />
vbox = gtk_vbox_new(FALSE, 0);<br />
gtk_container_add(GTK_CONTAINER(window), vbox);<br />
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 3);</code></p>
<p>vbox is initialized into a GtkVBox object, which is a vertical container box. No, I don&#8217;t know either why they called a horizontal-looking box a vertical container box. I guess we&#8217;ll learn that soon enough. Anyway, gtk_container_add() adds the vbox container to the window (our big, main container) and gtk_box_pack_start() packs our menu bar into our box.</p>
<p><strong>Closing the Window Properly</strong></p>
<p>In our last lesson, although clicking on the close button makes the window disappear, it doesn&#8217;t actually destroy the program. We have to connect the destroy signal to the gtk_main_quit function().</p>
<p><code>g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);</code></p>
<p>If you noticed, the Quit button doesn&#8217;t close our program, even if we have just set the callback for the destroy signal event. That&#8217;s because the Quit menu item is just a menu item like Open. Until we tell it what to do, it does nothing. The signal we actually have to listen for is not the destroy signal, but the activate signal, which is sent whenever you click on a menu item. So we connect the quit object&#8217;s &#8220;activate&#8221; signal to the gtk_main_quit() function, which we already know will terminate our program nicely.</p>
<p><code>g_signal_connect(G_OBJECT(quit), "activate", G_CALLBACK(gtk_main_quit), NULL);</code></p>
<p><strong>Summing Up</strong></p>
<p>Our program which contains the previous Hello Wolrd lesson, as well as the new window size and position, icon, menu, and proper destruction on exit should look something similar to this:</p>
<p><code>#include &lt;gtk/gtk.h&gt;</code></p>
<p><code>GdkPixbuf *create_pixbuf(const gchar * filename)<br />
{<br />
GdkPixbuf *pixbuf;<br />
GError *error = NULL;<br />
pixbuf = gdk_pixbuf_new_from_file(filename, &amp;error);<br />
if(!pixbuf) {<br />
fprintf(stderr, "%s\n", error-&gt;message);<br />
g_error_free(error);<br />
}<br />
return pixbuf;<br />
}</code></p>
<p><code> int main (int argc, char **argv) {<br />
gtk_init(&amp;argc, &amp;argv);</code></p>
<p><code> //Basic Window Setup<br />
GtkWidget *window;<br />
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);<br />
gtk_window_set_title (GTK_WINDOW (window), "Hello, World");<br />
gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);<br />
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);<br />
gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf("mylogo.gif"));</code></p>
<p><code> //Initialize the File menu items<br />
GtkWidget *file;<br />
GtkWidget *open;<br />
GtkWidget *quit;<br />
file = gtk_menu_item_new_with_label("File");<br />
open = gtk_menu_item_new_with_label("Open...");<br />
quit = gtk_menu_item_new_with_label("Quit");</code></p>
<p><code> //Initialize File menu and put in the menu items<br />
GtkWidget *filemenu;<br />
filemenu = gtk_menu_new();<br />
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu);<br />
gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), open);<br />
gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit);</code></p>
<p><code> //Initialize the menu bar and put in the File menu we created<br />
GtkWidget *menubar;<br />
menubar = gtk_menu_bar_new();<br />
gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file);</code></p>
<p><code> //Put the menu bar into the window<br />
GtkWidget *vbox;<br />
vbox = gtk_vbox_new(FALSE, 0);<br />
gtk_container_add(GTK_CONTAINER(window), vbox);<br />
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 3);</code></p>
<p><code> //All set. Display all.<br />
gtk_widget_show_all (window);</code></p>
<p><code> //Connect the destroy signal to the gtk_main_quit() function<br />
g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);</code></p>
<p><code> //Connect the "quit" object's "activate" signal to the gtk_main_quit() function<br />
g_signal_connect(G_OBJECT(quit), "activate", G_CALLBACK(gtk_main_quit), NULL);</code></p>
<p><code> gtk_main();<br />
return 0;<br />
}</code></p>
<p>References:</p>
<ul>
<li><a href="http://zetcode.com/tutorials/gtktutorial/firstprograms/" target="_blank">First Programs in GTK+</a></li>
<li><a href="http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-file-loading.html#gdk-pixbuf-new-from-file" target="_blank">GNOME Documentation Library &#8211; The gdk-pixbuf Library &#8211; File Loading</a></li>
</ul>
Posted in GTK Programming, GTK Tutorials  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asbigasthis.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asbigasthis.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asbigasthis.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asbigasthis.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asbigasthis.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asbigasthis.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asbigasthis.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asbigasthis.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asbigasthis.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asbigasthis.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asbigasthis.wordpress.com&blog=2946776&post=16&subd=asbigasthis&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://asbigasthis.wordpress.com/2008/10/19/changing-the-basic-window/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8cea894377aba2539632dbb92db83a51?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">punongbisyonaryo</media:title>
		</media:content>
	</item>
		<item>
		<title>Saying Hello World With GTK</title>
		<link>http://asbigasthis.wordpress.com/2008/02/29/saying-hello-world-with-gtk/</link>
		<comments>http://asbigasthis.wordpress.com/2008/02/29/saying-hello-world-with-gtk/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 16:05:29 +0000</pubDate>
		<dc:creator>punongbisyonaryo</dc:creator>
				<category><![CDATA[GTK Programming]]></category>
		<category><![CDATA[GTK Tutorials]]></category>

		<guid isPermaLink="false">http://asbigasthis.wordpress.com/?p=9</guid>
		<description><![CDATA[So now we&#8217; re going to start nice and easy by making a common, household Hello World application. Here I&#8217;ll lay out a bare-essentials GTK application which I will try to explain as breifly as I can so fire up your text editor and create a base.c file:
This tells your compiler to include the gtk [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asbigasthis.wordpress.com&blog=2946776&post=9&subd=asbigasthis&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>So now we&#8217; re going to start nice and easy by making a common, household Hello World application. Here I&#8217;ll lay out a bare-essentials GTK application which I will try to explain as breifly as I can so fire up your text editor and create a base.c file:</p>
<p>This tells your compiler to include the gtk header files which includes the variables, structures, and other neat stuff in the GTK toolkit.</p>
<p><code>#include &lt;gtk/gtk.h&gt;</code></p>
<p>Here we have your main application function declaration. It has two parameters, which are pretty much standard:</p>
<p><code>int main(int argc, char **argv)</code><br />
<code>{</code></p>
<p>Here we declare an instance of GtkWidget which is a storage type for widgets and we&#8217;ll name it window:</p>
<p><code>GtkWidget *window;</code></p>
<p>Next, we call gtk_init, which as the name implies initializes GTK, initializing such stuff like color space, libararies, default signal handlers, etc. Here we see argc and argv again, which contain the arguments passed from the command line. gtk_init parses these arguments for special reserved arguments and removes them from the argument list. That&#8217;ll be useful in our future programs, so take note:</p>
<p><code>gtk_init (&amp;argc, argv);</code></p>
<p>This creates a new window:</p>
<p><code>window = gtk_window_new (GTK_WINDOW_TOPLEVEL);</code></p>
<p>And this one shows the window:</p>
<p><code>gtk_widget_show (window);</code></p>
<p>Last, but certainly not the least, calling this gets us into the main processing loop:</p>
<p><code>gtk_main ();</code></p>
<p>And, then we elegantly close off our function</p>
<p><code>return 0;<br />
}</code></p>
<p>Ok, put that all together and compile using the following basic compile command:</p>
<p><code><tt>gcc base.c -o base `pkg-config --cflags --libs gtk+-2.0`</tt></code></p>
<p>After it compiles, you&#8217;ll have a program that you can either double-click, or in terminal type</p>
<p><code>./base</code></p>
<p>This will open up a window with the default 200&#215;200 size because we didn&#8217;t specify a size. But wait, it say&#8217;s base on it&#8217;s title bar, not &#8220;Hello World&#8221;! Yes, that&#8217;s just the bare-essential base application we did. We need to add these right before gtk_window_show:</p>
<p><code>gtk_window_set_title (GTK_WINDOW (window), "Hello, World");</code></p>
<p>Compile it again, and we have our extremely easy Hello World program.</p>
<div style="text-align:center;"><a title="Hello World In Three Flavors" href="http://asbigasthis.files.wordpress.com/2008/02/hello_worlds_01.png"><img src="http://asbigasthis.files.wordpress.com/2008/02/hello_worlds_01.png?w=448&#038;h=167" alt="Hello World In Three Flavors" width="448" height="167" /></a></div>
<p>In one of my previous posts I mentioned that GTK is language-neutral, so you may be wondering why this code looks an awful lot like C. That&#8217;s because I prefer to code in C, but you can just as easily code this in C#, Ruby, Perl, or others by referring to the GTK Hello World In Six Different Languages article on which this tutorial was based on. Just scroll down and click on the link in my references below.</p>
<p>Next &gt;&gt; <a href="http://asbigasthis.wordpress.com/2008/10/19/changing-the-basic-window/">Changing The Basic Window</a></p>
<p>References:</p>
<ul>
<li><a href="http://library.gnome.org/devel/gtk-tutorial/stable/">GNOME GTK tutorial</a></li>
<li><a href="http://www.vector-seven.com/2008/01/23/gtk-hello-world-in-six-different-languages/">GTK Hello World in Six Different Languages</a></li>
</ul>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/asbigasthis.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/asbigasthis.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asbigasthis.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asbigasthis.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asbigasthis.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asbigasthis.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asbigasthis.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asbigasthis.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asbigasthis.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asbigasthis.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asbigasthis.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asbigasthis.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asbigasthis.wordpress.com&blog=2946776&post=9&subd=asbigasthis&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://asbigasthis.wordpress.com/2008/02/29/saying-hello-world-with-gtk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8cea894377aba2539632dbb92db83a51?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">punongbisyonaryo</media:title>
		</media:content>

		<media:content url="http://asbigasthis.files.wordpress.com/2008/02/hello_worlds_01.png" medium="image">
			<media:title type="html">Hello World In Three Flavors</media:title>
		</media:content>
	</item>
		<item>
		<title>A Short Introduction to GTK</title>
		<link>http://asbigasthis.wordpress.com/2008/02/28/a-short-introduction-to-gtk/</link>
		<comments>http://asbigasthis.wordpress.com/2008/02/28/a-short-introduction-to-gtk/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 17:24:35 +0000</pubDate>
		<dc:creator>punongbisyonaryo</dc:creator>
				<category><![CDATA[GTK Programming]]></category>

		<guid isPermaLink="false">http://asbigasthis.wordpress.com/?p=5</guid>
		<description><![CDATA[What is GTK And Why Would I Want To Learn It?
I&#8217;ll try to keep this really short. First, GTK stands for the Gimp Toolkit and is the main toolkit used by GNOME (GNU Network Object Model Environment), although it is an object-oriented cross-platform toolkit that can be used to create applications independent of GNOME. Why [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asbigasthis.wordpress.com&blog=2946776&post=5&subd=asbigasthis&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>What is GTK And Why Would I Want To Learn It?</p>
<p>I&#8217;ll try to keep this really short. First, GTK stands for the <b>G</b>imp <b>T</b>ool<b>k</b>it and is the main toolkit used by GNOME (GNU Network Object Model Environment), although it is an object-oriented cross-platform toolkit that can be used to create applications independent of GNOME. Why is it called the Gimp Toolkit you ask? Well, it was originally written for the Gimp (GNU Image Manipulation Program, basically the equivalent of Photoshop in Linux). But since GTK had support for several languages, GTK was chosen as the toolkit for GNOME.</p>
<p>It uses <a href="http://en.wikipedia.org/wiki/LGPL" title="Wikipedia LGPL Article">LGPL</a>, which means you won&#8217;t have to pay a penny for licenses and royalties, EVEN IF you&#8217;re program is not for personal or educational use e.g. commercial, paid programs. Programming with a toolkit allows your program to integrate well with your GNOME desktop, which means your program will have the same look and feel as your desktop theme. The toolkit also features high-level and easy to use widgets which are built on the concept of hierarchies and containers, which I&#8217;ll probably find out to be more useful than I think (think class hierarchies and inheritance, change the parent, change the children, et cetera).</p>
<p>Well, that was longer than I had wanted. So without further ado, I&#8217;m just gonna dive in and get ready to set up my GTK workspace.</p>
<p><a href="http://asbigasthis.wordpress.com/2008/02/28/setting-up-your-gtk-workspace/" title="Setting Up Your GTK Workspace">Next &gt;&gt;  Setting Up Your GTK Workspace</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/asbigasthis.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/asbigasthis.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asbigasthis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asbigasthis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/asbigasthis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/asbigasthis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/asbigasthis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/asbigasthis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/asbigasthis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/asbigasthis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/asbigasthis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/asbigasthis.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asbigasthis.wordpress.com&blog=2946776&post=5&subd=asbigasthis&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://asbigasthis.wordpress.com/2008/02/28/a-short-introduction-to-gtk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8cea894377aba2539632dbb92db83a51?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">punongbisyonaryo</media:title>
		</media:content>
	</item>
	</channel>
</rss>