Posts Tagged ‘C’

Starting GNOME Development – Starting your own project

Tuesday, February 17th, 2009

I had already posted a *very* quick start guide on how to start working on existing GNOME projects. Today I will focus on how to start your own GNOME/GTK+ project.

What programming language do I use?

The mother of all questions. While you may know that you want to do GNOME/GTK+ development the choice of languages with excellent bindings is sheer overwhelming. Unfortunately it seems that picking a language and sticking with it always involves a trade off. Anyway here are a few thoughts about picking the right language just in case you can’t make the choice on your own.

C is the language most of GNOME is written in. If you want to later contribute to core GNOME projects, C is worth learning and there is no better way than writing your own little project. The drawback is the amount of boilerplate code, the need for memory management and if you come from another language the need not only to familiarize yourself with GTK+, but also with a new programming language.

Python, C#, Java, Perl, C++ all of these languages have official GNOME bindings making all of these languages a good choice. If you come from one of these languages you will probably be up and running quite quickly. Python and pygtk are widely used in GTK+ development. C# runtime is developed in the mono project and is used in several more recent GNOME projects. Java has the benefit of running on top of the very fast Java Virtual Machine (JVM). The documentation of the Java GNOME bindings are not up to par with the other languages, but that is supposed to change in the near term and might be something you can help with? The Perl GTK+ project is gtk2-perl and C++’s project is gtkmm.

Other languages. Check the official GNOME bindings for any of the other languages. You will probably do just fine using any of these if you already know the language.

Then there isĀ Vala. Vala is a new high level language that compiles into native C code and thus will be as fast or at least almost as fast as apps written in C. Vala can therefore be used to write core GNOME libraries and apps because it does not depend on a runtime like Java, C# and Python for example do. The irc channel is always crowded so there seems to be quite some interesst in this language. Is it the future of GNOME development? I don’t know, but you should keep an eye on the project.

Summing up I would suggest to be very pragmatic with your choice. Stick to what you know and you will find success a lot quicker. After all the many GTK+ bindings have the intention of letting programmers program with whatever language they like most. If you learned the basics of GTK+ and have written your first little apps take a look at other languages. Each language has its own strengths and merits and soon you might choose a different language depending on the type of GTK+ project you are writing.

If you are new to programming and do not yet have a preferred programming language I would suggest getting started with either Python, Java or C# (I might give a slight edge to python).

Use Glade for GUI development?

So you have chosen a programming language. Now do I hand code my GUIs or do I use Glade as a graphical user interface builder? My advice would be to get started by hand coding a few of the basic widgets. Seeing the code and seeing how it works gives you a much better understanding of the GTK+ widgets and programming principles. Once you have a basic understanding of events, signals, arranging widgets etc. go ahead and start learning to use glade. For most straightforward GUIs this tool can save you a tremendous amount of time. The place to start learning to use glade is here.

I heard something about GtkBuilder instead of libglade?

Everything you need to know about this can be read Micah Carrick’s blog.

What tutorials are worth following?

  1. The best tutorial I have found to get you started quickly is Micah Carrick’s tutorial.
  2. Then there is the book Foundations of GTK+ development. So far I think it is a good resource and I will post a detailed review sometime in the near future. The only apparent problem is that the book focuses only on the C programming language and that will not be of great use if you do not plan to write your code in C.
  3. The official GTK+ tutorial is lengthy but a good starting point. Programming language is once again C.
  4. For python there is the pygtk tutorial.
  5. For Java there is this tutorial which gives you a quick overview of how to develop with javagnome bindings including using glade.
  6. For Vala there is the Vala tutorial.
  7. For C# and GTK# there are a whole bunch of articles and tutorials.

Starting GNOME Development – Working on existing projects

Wednesday, February 4th, 2009

I have been a GNOME user for many years but only until very recently I decided to write my own GNOME/GTK+ apps and help out with the development of GNOME.

So where do I start my GNOME journey? The obvious place of course is to look at the GNOME.org website and in particular the GNOME Love wiki page. GNOME Love is the name of the project that helps new contributors find their way into the GNOME community. I found the information on the GNOME Love page and the referenced documents to be quite vast so I put together a list of steps that will get you up and running as quickly as possible.

These steps are meant for developers i.e. not technical writers, artists etc. without a C or GTK+ background. I am assuming that you have a some sort of programming background and that you are running Linux, OpenSolaris or some other flavor of UNIX.

  1. Sign up to GNOME Love mailing list to see what issues other beginners are having.
  2. Hang out on irc (irc.gnome.org) to get answers to questions while your coding. Recommended channels: #gnome-love and the channel of the project you are working on.
  3. Follow GNOME news sites to get a feel for what is going on in the GNOME community. This is kind of difficult because in my opinion there is a lack of a good monthly newsletter that sums up the most recent activities. Other sources include Planet GNOME (very fine grained and quite a few off topic posts), Footnotes (very few posts), GNOME Journal (very few posts), GNOME News (good but also quite fine grained).
  4. Start learning GTK+ (Micah Carrick’s tutorial very concise and up to date, Foundations of GTK+ Development most recently published GTK+ book)
  5. Checkout a project of your choice it might be good to start with something small like one of the GNOME utilities. (svn co http://svn.gnome.org/svn/yourprojectname/trunk yourprojectname)
  6. Install the dependencies (on debian try something like sudo apt-get build-dep your_package_name otherwise use your package manager and Google).
  7. Build the project (usually run ./autogen in the source directory and then make see your project’s help/readme/install files for details)
  8. Take a look at the source code, make a few modifications and see what happens ;-)
  9. Check for bugs for your project on Bugzilla and start working on these.
  10. Get in touch with the program developers if you have any questions (irc or mailinglist instead of private mail).
  11. Lastly, seriously consider becoming a Friend of GNOME. This greatly helps the project move ahead .

I will post a similiar article of steps to get you started if you are interested in writing your own GTK+/GNOME apps.