Forking A New Thread

Call On A Background Thread fork creates a clone of the current process on a new thread. Use with execlp to trigger other processes, e.g. open another application Do something that might take a while without waiting example IMPORTANT NOTE: The child process once it dies remains in the Linux process table marked as <defunct>. You’ll […]

Read More

Playing Audio

Using Omxplayer And System This will play an audio file but it won’t return until playing is complete. #include <stdlib.h> system(“omxplayer /home/pi/projects/my_project/audio/my_audio.wav”);   Play On A Background Thread This will trigger omxplayer on a separate thread and return immediately so your program execution doesn’t stall until the file has finished playing.   You can even use this multiple […]

Read More

Desktop Shortcuts

Adding A New Desktop Shortcut Create a new text file called yourname.desktop in the /home/pi/Desktop/ directory, e.g. /home/pi/Desktop/yourname.desktop It should contain the following: [Desktop Entry] Name=My Name Comment=My application which does this Icon=/usr/share/pixmaps/openbox.xpm Exec=/usr/bin/leafpad Type=Application Encoding=UTF-8 Terminal=false Categories=None;   Name – The name you want displayed Comment – Your comment Icon – A file to […]

Read More

.Labels General

Adding A Label At A Fixed Position Update Label Styling Text See the available Pango styling options here. Setting A Font Name Font Size Using Newly Installed Fonts We originally copied new ttf fonts into ~/.fonts (/home/pi/.fonts ) and couldn’t use them in GTK.  We moved them to /usr/share/fonts/truetype, rebooted and they worked fine, e.g. Multi Line […]

Read More

Images

Display Images In A fixed Container This example sets the main window to be a fixed container into which you can place images at specified positions Change an image Clear an image Delete an image You can safely used destroy on a widget that hasn’t actually been displayed yet.  You can re-create and place the widget […]

Read More

Fonts

Adding New Fonts For full details on adding new fonts see here. Copy a new TrueType fonts (*.ttf) font file in the directory /usr/share/fonts (for all users) or ~/.fonts (for a specific user, e.g. /home/pi/.fonts  – create the directory if necessary and note the dot'). You can test the new fonts are then available using Leafpad List Installed Fonts […]

Read More

Fonts

Adding New Fonts For full details on adding new fonts see here. However if you are using just single user account on the RPi its actually very easy to add true type fonts (TTF) as you can just install them in your home directory. Create a new directory in your home folder called ".fonts" (/home/pi/.fonts […]

Read More

.Window General

  Maximize The Window gtk_window_maximize(GTK_WINDOW(MainWindow)); Resizable gtk_window_set_resizable(GTK_WINDOW(MainWindow), FALSE);   Hide the title bar etc gtk_window_set_decorated(GTK_WINDOW(MainWindow), false); //Request the window title bar to be hidden, use before gtk_widget_show() Set Fullscreen Fill entire screen, displaying over the top of the taskbar panel. gtk_widget_show(fixed); //Make the window fullscreen gtk_window_fullscreen(GTK_WINDOW(MainWindow));  

Read More

.Color General

Set Main Window Background Colour MainWindow= gtk_window_new(GTK_WINDOW_TOPLEVEL); //Set background colour GdkColor color; gdk_color_parse("#000", &color); gtk_widget_modify_bg(MainWindow, GTK_STATE_NORMAL, &color);      

Read More