Glade 3 + GtkBuilder + Anjuta Example.
Today I whipped up a simple GTK application using the Anjuta IDE, Glade 3, and the new GtkBuilder system. As some of you know, Glade 3 and GTK changed things up. First Glade stopped using generated code which required you to use libglade. Now the GTK developers created their own interface interpretor called GtkBuilder. Your whole entire Gtk+ application is now done using mainly signals, making it fairly easy to develop Gnome type applications.
Note: This is not an in-debth tutorial on using Anjuta however I did provide a few screenshots. This is just to give you a quick idea of how to grab widgets with GtkBuilder and how to process signals from a Glade 3 interface. I just happen to be using Anjuta as my IDE.
Here is my development setup:
Anjuta: 2.82.2
Glade: 3.6.7-1
GTK: 2.18.7-1
If you are running Arch Linux these are available through pacman.
Once you have the above installed you’ll want to create a GTK+ project. Select File -> New Project, Select C (not C++), then GTK+. I unchecked the option to support other languages, but you don’t have to if you want to make your app multi-lingual.
Once you have a project setup you should see a few source files and a UI file. The UI file contains a user interface file which you can edit in glade. The screenshot below shows a basic setup after a project is created. I use horizontal and vertical splitters to align all my GtkWidgets. I created two buttons and one entry box.
Now to put text in the textbox (entry1) when a user clicks on the “button” you’ll need to add a GtkEntry pointer to your callback.c file.
callback.c
#include <gtk/gtk.h> GtkEntry *myEntry; void destroy (GtkWidget *widget, gpointer data);
main.c
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <config.h>
#include <gtk/gtk.h>
#include "callbacks.h"
/* For testing propose use the local (not installed) ui file */
/* #define UI_FILE PACKAGE_DATA_DIR"/gtk_foobar/ui/gtk_foobar.ui" */
#define UI_FILE "src/gtk_foobar.ui"
GtkWidget* create_window (void)
{
GtkWidget *window;
GtkBuilder *builder;
GError* error = NULL;
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder, UI_FILE, &error))
{
g_warning ("Couldn't load builder file: %s", error->message);
g_error_free (error);
}
/* This is important */
gtk_builder_connect_signals (builder, NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
Now we need to populate the myEntry GtkEntry pointer in callback.c to our object that we made in the Glade interface builder. I named my entrybox “entry”. In the glade interface you can name your Widgets in the properties section. Remember, we defined GtkEntry *myEntry in callback.c.
myEntry = GTK_ENTRY (gtk_builder_get_object (builder, "entry1"));
gtk_entry_set_text (myEntry, "Hello World!");
g_object_unref (builder);
return window;
}
int main (int argc, char *argv[])
{
GtkWidget *window;
gtk_set_locale ();
gtk_init (&argc, &argv);
window = create_window ();
gtk_widget_show (window);
gtk_main ();
return 0;
}
void
button1_clicked_cb (GtkButton *self, gpointer user_data)
{
gtk_main_quit();
}
Here is the signal I created when creating my interface in Glade 3 from within Anjuta. Click on your Widget, then properties (lower left), then Signals (upper right, left side bar). If you don’t see a signals tab you might have to scroll over to see it using the scroll (left/right arrow looking things) buttons they built in.

void
btn1_Click (GtkButton *self, gpointer user_data)
{
gtk_entry_set_text (myEntry, "Hello From Button Click!");
}
Now you can click build and execute your program! The program will populated your entry box when the application starts and then change the text when you click the “button” button.











Today I received my first piece of spam in Google Voice. At first I was really PISSED-OFF but then a feeling of serenity passed over my whole body as I noticed the “block” button. Slowly and cautiously I clicked it, making my day THAT MUCH better. Just knowing that I will no longer be getting text messages or spam from that phone number makes me feel so good inside. Sorta like that feel you get after drinking hot coca from a hard day of skiing on the mountain or a cold beer from a hot days hike in the hills. Thank you Google for the Blocked, Pwnt, Owned, Face Palmed, Jacked Up, Beat Down button called “Block” in Google Voice, it is much appreciated.
In this tutorial I will hopefully teach you how to configure and build a custom kernel. We’ll be using the unmodified generic Linux source code available here. Many Linux distributions sometimes add custom code to their kernel but for this example we’ll be using a pure Linux kernel. Creating a custom kernel can not only be educational but also make your computer run smoother and use less resources such as disk space. You may be required to install some additional software in order to build a custom kernel. We will not be covering boot loaders and initial rams disks in this article. I will however give you a general idea on where to go to test your kernel.
Currently you can not watch Netflix if you are a Linux user and all those new Ubuntu Netbook owners will not be watching Netflix anytime soon either. Watching movies online through Netflix is an awesome service, but worthless to Linux users. Netflix has chosen to only allow Windows and MAC users access to their online streaming movie service and they are losing tons of money because of it.
