Watchmen Trailer

Late last week the Watchmen trailer was put up on the web, I meant to blog about this earlier but I kept forgetting. This is a movie I am very much looking forward to as I am a fan of the book and needless to say I really enjoyed the trailer. After watching the trailer again I can see how people who have not read the book could be confused, due to the trailer giving next to nothing away about the plot which is not necessairly a bad thing. Below is the trailer which you could also get off of daves trailer page in various resolutions, enjoy.

iPhone and the Openmoko

Typing this post from a friends new iPhone, it is easier than I thought it would be. It’s a pity that the plans in New Zealand are so expensive and the iPhone isn’t free (as in speech) as they are really quite nice.

At the moment I’m a little disappointed with the openmoko which I was quite keen to get but from everything I’ve heard it doesn’t seem quite ready for release, I think in about 6 months there should be quite nice product there, I wait with high hopes.

Also Jason a new post because you asked without trying to insult me.

Syntax highlighting with GtkSourceviewmm 2.0 and Giomm

Can you tell I’ve recently begun coding on personal projects again?  In a follow up to yesterdays post about loading a file with Giomm, last night I decided to upgrade a project I am working on from GtkSourceviewmm 1.0 to 2.0.  This turned out to be more difficult than I initially expected as the API documentation provided with Ubuntu seems to be horribly wrong, it includes functionality that doesn’t exist anymore.  So after referring to the GtkSourceview 2.0 documentation I got it all working so below is a simplified version with all error checking removed but should do the trick.

void load_highlightable_text(Glib::ustring file_name, Glib::RefPtr<gtksourceview::SourceBuffer> buffer)
{
	Glib::RefPtr<Gio::File> fp = Gio::File::create_for_uri(file_name);
 
	char *raw;
	gsize read_bytes;
	std::string e_tag;
 
	fp->load_contents(raw, read_bytes, m_e_tag);
 
	Glib::ustring buf = raw;
 
	buffer->begin_not_undoable_action();
	buffer->set_text(buf);
	buffer->end_not_undoable_action();
 
	// Retrieve the mime type of the file.
	Glib::RefPtr<Gio::FileInfo> info = fp->query_info();
	Glib::ustring mime_type = Gio::content_type_get_mime_type(info->get_content_type());
 
	// variables needed for getting the language
	Glib::RefPtr<gtksourceview::SourceLanguageManager> manager = gtksourceview::SourceLanguageManager::create();
	Glib::RefPtr<gtksourceview::SourceLanguage> language;
 
	std::vector<Glib::ustring> lang_ids = manager->get_language_ids();
	std::vector<Glib::ustring> mime_types;
 
	// Cycle through all available languages matching the first one that will highlight the given mime type
	for(std::vector<Glib::ustring>::iterator i = lang_ids.begin(); i != lang_ids.end(); i++) {
		language = manager->get_language(*i);
 
		if(language) {
			mime_types = language->get_mime_types();
 
			for(std::vector<Glib::ustring>::iterator j = mime_types.begin(); j != mime_types.end(); j++) {
				if(*j == mime_type) {
					buffer->set_language(language);
					buffer->set_highlight_syntax(true);
					return;
				}
			}
		}
	}
 
	return;
}

If anyone knows of a more sane way to do this please tell me as what I have currently looks bloody horrible to me.

Reading and Writing files with GIOmm

Seeing as a while ago I posted on reading a file in with GnomeVFSmm since now and then the folks at GNOME have release GIO their new i/o library.  Thankfully this makes life for the developer a lot easier from what I can tell to prove this here is my example from my GnomeVFSmm reworked to use GIO.

Reading from a file:

Glib::ustring read_from_file(Glib::ustring file_name)
{
	Glib::RefPtr<Gio::File> fp = Gio::File::create_for_uri(file_name);
 
	char *raw;
	gsize read_bytes;
	std::string e_tag;
 
	fp->load_contents(raw, read_bytes, e_tag);
 
	Glib::ustring buffer = raw;
	return buffer;
}

Writing to a file:

void write_to_file(Glib::ustring file_name, std::string e_tag, Glib::ustring buf)
{
	Glib::RefPtr<Gio::File> fp = Gio::File::create_for_uri(file_name);
	fp->replace_contents(buf.c_str(), e_tag, e_tag);
}

Just as a note this method only works for reading and writing text files, and there should be some error checking which has been omitted.  If there is any problems in the above code do not hesitate to let me know.  Also as a side note does anyone know how to retrieve the mime type for a file using GIOmm.

Ironman

So on Monday night me and a few friends went to go see Ironman.  Well let me tell you it was damn awesome, if you get the chance go and see it.  It did what I thought transformers should have done had a few token human characters and then got the hell out of the way while the robots (well men in robotic suits) fought.  It also had it’s fair share of funny moments which served as a nice counter balance to the action.

Also if going to see it wait until the end of the credits for a bonus scene.  It doesn’t add anything to the storyline of the movie but it is several degrees of awesome.

Spidey is dead. Long live Spidey

Last week my desktop computer (Spidey) died which was a bit of a bitch as I had assignments due, though it had thankfully lasted a good 4 years so I wasn’t too angry (if it had waited a week I would’ve been a lot happier).

But every cloud has a silver lining, this one was I got me a new desktop computer, zeddicus.  It’s a 3 Ghz Intel core 2 duo with 4 Gigs of ram, unfortunately I don’t game much anymore so I couldn’t justify buying a new graphics card so it’s using the GeForce 7950 GT from spidey.

All in all I’m very happy with my and a little sad to see my old machine die after having it so long.

Upgrading Wordpress

Today I upgraded to the latest version of Wordpress (2.5.1) from 2.3 and I’m happy to say that it was a very stress free and quick upgrade.  It was nice and easy and I’ve found no problems so far.

Watchmen

I’ve finally finished reading Watchmen, and what can I say apart from ‘Wow!’ I can’t think of anything that accurately describes this book, it simply is great and I would recommend it to everyone to read.

Projects

Now that the new server is up and running smoothley I decided to migrate my two relatively new project into the svn repositries on this sever, at some point I’ll make a better post about each project but for now a brief introduction will have to do. Both of these projects are available for anonymous checkout from svn and the source is browsable online, a link will be posted so you can do both these things.

Axalon

Axalon is a collaborative GUI designer written in C# and is being developed on windows, I haven’t quite yet decided what license to release it under, but chances are it will be the GPL. For those that are curious it is the rewrite of my research project I did at university last year, after seeing how to do things better I figured a complete re-write might be easier. The svn repo (also where you can browse the source on line) is:

http://mlowen.com/svn/axalon

gIDE

gIDE is a simplistic IDE designed for the Gnome desktop enviroment written in C++, it uses Gtkmm and various other related librarie. gIDE is being released under version 2 of the GNU GPL, the svn repo is:

http://mlowen.com/svn/gIDE

With both these projects feel free to check them out and play around with them, they are both in early stages of development and not really all that useful, hopefully I will have pages up for them by the end of the weekend but don’t hold me to anything.

Laptop keyboard issues

Earlier today I installed some new ram in my laptop (NEC Versa E2000) which was really starting to feel the crunch with only 256 ram. After adding a GB of ram I decided to re-installing stock Ubuntu and once again ran across the problem of my key which is meant to produce | and \ instead produced < and > I found the fix to this at the Ubuntu forums but decided to document it here as well.

To fix this problem you need to have the following command run when you log in:

xmodmap -e 'keycode 94 = backslash bar'