Archive for October, 2009

Compiling my first DirectFB program

October 19, 2009 2 comments

I have to admit I am a total DirectFB newbie and I had a hard time even compiling my first DirectFB program (the official DirectFB or tutorials on the Internet described procedures how to build DirectFB but not how to even compile the simplest demo program, forgive my poor google skill if somebody already posted the compiling instruction). Anyway I use the following command to compile successfully:

gcc -o simple simple.c `directfb-config --cflags` `directfb-config --libs`

OS: fresh installation of Gentoo 09132009
DirectFB version: 1.2.7
Source code of the demo program:

Splash Screen with GTK+

October 12, 2009 5 comments

The code:

#include <gtk/gtk.h>
static void destroy (GtkWidget*, gpointer);
static gboolean delete_event (GtkWidget*, GdkEvent*, gpointer);
int main (int argc,
          char *argv[])
  GtkWidget *window, *image;
  gtk_init (&argc, &argv);
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "A Splash Screen Demo");
  gtk_container_set_border_width (GTK_CONTAINER (window), 0);
  gtk_widget_set_size_request (window, 800, 480);
  gtk_window_set_decorated(GTK_WINDOW (window), FALSE);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_window_set_resizable(GTK_WINDOW(window), FALSE);

  /* Connect the main window to the destroy and delete-event signals. */
  g_signal_connect (G_OBJECT (window), "destroy",
                    G_CALLBACK (destroy), NULL);
  g_signal_connect (G_OBJECT (window), "delete_event",
                    G_CALLBACK (delete_event), NULL);

  gtk_container_add(GTK_CONTAINER(window), image);

  gtk_widget_show_all (window);
  gtk_main ();
  return 0;

/* Stop the GTK+ main loop function when the window is destroyed. */
static void
destroy (GtkWidget *window,
          gpointer data)
   gtk_main_quit ();
/* Return FALSE to destroy the widget. By returning TRUE, you can cancel
  * a delete-event. This can be used to confirm quitting the application. */
static gboolean delete_event (GtkWidget *window,
               GdkEvent *event,
               gpointer data)
    return FALSE;

And here’s the included “Please wait” image file in .png format:

The png file used by the splash screen demo program

The png file used by the splash screen demo program

To compile:

gcc -Wall -g demo.c -o splash `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`

Now test it:

# use Alt + F4 to close and exit.
Categories: gtk, Programming