Blog

Blog

blame-browse

Posted at 23:50 on 16 Aug 2008

The one thing that's worse about Git compared to Subversion is that git-blame is so much harder to use than svn blame. The output from git-blame is very wide so if you run it on the terminal then often most of the line of source code will be cropped off the right edge. SVN's revision numbers are replaced with a git commit hash so it's also not immediatly obvious what the parent of a commit is from the information in git-blame. When I use either blame command, I often find the commit reported against a given line is not the change that I'm interested in so I usually want to re-run the annotation with the parent commit.

I thought it might be fun to knock up a program to browse the output of git-blame. I initially thought 'oh that's easy, that'll take about half an hour' so I cobbled together a quick program in Ruby with the GTK bindings. It was pretty quick to write because Ruby (like Perl) has excellent support for processing text. However I eventually got fed up with the Ruby GTK bindings because they are randomly missing bindings for some functions that I wanted and it's difficult to debug. After discovering this bug I got fed up and rewrote it in C. I also ended up making it much more complicated because now it tries to run git asynchronously and process the output as it comes using the glib main-loop.

So far you can see the source code for the file you've annotated with the hash of the commit for the that line. A tooltip is displayed for the commit with a short summary. If you click on the commit you get more information in a dialog and you can jump to the parent commit from there.

image

The screenshot gives away that I stole a function from ebassi's Tweet and also that I fixed a tiny bug in it :)

There's quite a lot left to do:

  • I would like to add forward and back buttons to the main window so that you can move through the history of what you have visited.
  • Searching the source and jumping to a line number are probably pretty essential.
  • It should probably use GtkSourceView instead of my crazy custom widget.
  • The UI looks nasty

I also should probably have tried to implement within the giggle source code but I didn't look at this until I'd got too far. It looks like giggle already has a lot of code to handle running git asynchrously so I could've avoided a lot of work.

The code is available on Github at http://github.com/bpeel/blame-browse

Compiling Clutter on Windows with MinGW + MSYS

Posted at 20:23 on 13 Jul 2008

I keep getting asked how to compile Clutter on Win32 now that we have a native backend so here is some instructions to compile with MinGW and MSYS on a fresh Windows installation.

First you need to install the MinGW and MSYS packages from here.

Select the top package called 'Automated MinGW Intaller' and download the exe of the latest version. Run the executable and install to the default location. Make sure you DON'T install 'MinGW make' to make life easier.

Next download the 'MSYS Base System'. Use the .exe installer from 'Current release' (not the technology preview). Run the executable and install to the default location. Answer yes to whether you want to continue with the post install and tell it the location where you installed MinGW (which should be c:/MinGW).

Next install the 'MSYS supplementary tools'. Again select .exe from the current release and install it to the default location.

To make downloading the dependencies for Clutter easier, we want to be able to run the mingw-cross-compile.sh script which will do some of the leg work automatically. However to do this we first need some extra utilities.

Make a directory called c:/msys/1.0/clutter-work and another directory called downloads under that. Go back to the SourceForge page for MinGW and select the 'User Contributed: mingwPORT' section. Download the wget tarball to the newly created downloads folder.

Start MSYS and type the following to install wget.

cd /clutter-work/downloads
tar -jvxf wget-1.9.1-mingwPORT.tar.bz2
cd wget-1.9.1/mingwPORT
mkdir /usr/src
PATH="$PATH":"$PWD" ./mingwPORT.sh 

Press enter at each question to just use the default

Next we need to install unzip.exe which we can get from the GNUWin32 ports. Visit here and download the 'complete package, except sources'. Install it to the default location.

Now we can type the following to download and install the clutter dependencies using the helper script:

cd /clutter-work
wget -O downloads/mingw-cross-compile.sh \
'http://svn.o-hand.com/view/*checkout*/clutter/trunk/clutter/build/mingw/mingw-cross-compile.sh'
PATH="$PATH:/c/Program Files/GnuWin32/bin" sh ./downloads/mingw-cross-compile.sh

Press enter to all of the questions to get the default except the 'Do you want to download and install Clutter...' questions because these will try to use SVN which we don't have installed.

Next we need to install pkg-config to get Clutter's configure script to work. Type the following:

cd /clutter-work/downloads
wget 'http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz'
tar -zvxf pkg-config-0.23.tar.gz
cd pkg-config-0.23
prefix=/clutter-work/clutter-cross
libdir="${prefix}/lib"
includedir="${prefix}/include"
CFLAGS="-g -O2 -Wall -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include" \
LDFLAGS="-L${libdir} -lglib-2.0 -lintl -liconv" \
./configure
make all install

Now we should finally be ready to compile Clutter:

cd /clutter-work/downloads
wget http://www.clutter-project.org/sources/clutter/0.8/clutter-0.8.0.tar.bz2
cd ..
tar -jvxf downloads/clutter-0.8.0.tar.bz2
cd clutter-0.8.0
PKG_CONFIG_PATH=/clutter-work/clutter-cross/lib/pkgconfig \
 PATH="$PATH:/clutter-work/clutter-cross/bin" \
 CFLAGS="-mms-bitfields -I/clutter-work/clutter-cross/include -g -O2 -Wall" \
 ./configure --prefix=/clutter-work/clutter-cross --with-flavour=win32
make all install

Now to prove that it worked we can run test-actors. Windows needs the Clutter DLL to be in the system path for this to work so type the following:

export PATH="$PATH:/clutter-work/clutter-cross/bin"
cd /clutter-work/clutter-0.8.0/tests
.libs/test-actors

If you want to compile a simple app without using autotools, it's easiest to use the libtool generated in the Clutter source so that it can work some voodoo with the included libraries. This assumes you've still got your path set up from the previous test:

libtool --mode=link gcc -Wall -g -o simple-app simple-app.c \
-I/clutter-work/clutter-cross/include \
`PKG_CONFIG_PATH=/clutter-work/clutter-cross/lib/pkgconfig pkg-config clutter-0.8 --cflags --libs`

Enjoy!

Abusing Clutter

Posted at 22:57 on 06 Jun 2008

I thought it might be fun to see how easy it is to use Clutter with full 3D actors instead of just flat rectangles. I started off by thinking I could make something like a table tennis game with a proper model for a table and the bats. I made a model for the table with a bit of wrestling with Blender so I needed a way to display the model in Clutter.

I decided to write a library to display MD2 models as a Clutter actor. MD2 is the model format from Quake 2 for players and weapons. It seemed like a good format because it's quite simple and it already represents the model as a set of triangle fans and triangle strips so it fits nicely with OpenGL.

The result of that is available in a git repo here:

git clone git://github.com/bpeel/clutter-md2.git

You can create an actor from an MD2 file by passing it the filename. When painting the model it scales the coordinates to fit in the width and height of the actor while preserving the aspect ratio (so you can position it easily with other pixel-based actors). You can rotate and move the actor with the regular actor API. There is also a new behaviour to animate the model using the frames in the file. The frames are interpolated as key frames to make the animation a bit smoother.

image

I didn't have much luck with the MD2 exporter of Blender because it kept complaining that I'd scaled the model and it made a mess when it tried to convert it to triangles. So for now I've given up on the table tennis game and started making a simpler game to demonstrate the library using the ready-made MD2 models from here.

The game creates a scrolling road (made entirely out of ClutterRectangles) and animates driving past some tractors in a car (which are MD2 models). You can move the car with the arrow keys, but other than that it needs a lot of work.

image

The git repo for the game is at:

git clone git://github.com/bpeel/tractordodge.git

Cycling fail

Posted at 20:01 on 01 Jun 2008

image

oops..

Twitter.el

Posted at 22:08 on 19 May 2008

Everyone and their uncle is releasing a Twitter client these days so I thought I'd release the one I've been using too. It's just a simple Emacs lisp script but it lets you view your friends timeline and edit a new one so it's quite quick if you're already running Emacs (what else would you be doing?).

You can install it by downloading twitter.el and putting it somewhere in your Emacs load-path. Then put the following in your .emacs file:

(autoload 'twitter-get-friends-timeline "twitter" nil t)
(autoload 'twitter-status-edit "twitter" nil t)
(global-set-key "\C-xt" 'twitter-get-friends-timeline)
(add-hook 'twitter-status-edit-mode-hook 'longlines-mode)

You can tell it your username and password and change the appearence by typing M-x customize-group RET twitter RET. Once you've done that you can view the statuses by pressing C-x t and you can start editing a message with M-x twitter-status-edit RET. Once the message is finished press C-c C-c to publish.

image