0.1. Why not C++/GTK+?

Well if you have ever tried to create some small open-source projects with graphical interface you probably have heard of things like Qt, GTK+, Gtkmm, wxWidgets, etc… These are all the toolkits used by developers around the world to create GUI (graphical user interface) for their applications.

About more than a year ago, I myself started learning C++. And then about 4 month later I improved pretty fast (although I still consider myself a beginner), since I was already taught C & Pascal and some fundamental algorithms like quick sort, insertion sort, recursion, etc… in high school. I solved a pretty good amount of problems in Project Euler as well as those in Introduction to Algorithms by Cormen.

However, it came the point where I really feel bored with non-graphical programming and want to actually create some medium-to-large projects, where I can practice the object-oriented paradigm and get the most out of it. That was how I started with my very first personal open source project – Dingo Music Manager.

Well about six months ago I started to find a graphical toolkit for my software. I finally came down to three: GTK+, Gtkmm and Qt. Lots of developers have recommended Qt to me. But I am kinda a minimalist person and really do not like the sleek look of Qt. I prefer the simplistic and uniqueness of GNOME and GTK. Therefore, I went with GTK.

I tried out Gtkmm for a week and then gave up. It was so lack of documentation. The only tutorial available is on the main website and it is too terse and hard to understand. I could not grab things like Gtk::VBox, Gtk::HBox, or know what Gtk::Adjustment is used for. All I did was trying to read the main tutorial and try to understand the core GTK theories behind it. Plus, I did not have an insanely strong OOP foundation (since Dingo is my very first software), which prevents me from fully understanding some problems. The inability to understand the core concepts and a weak OOP foundation made me turn away from Gtkmm and use GTK+ instead.

In my experience, using GTK+ with C++ is fine. You can just declare callback functions and variables in your classes as static and then connect the signals to those static functions. However, these were not very nice to me, because when my software grew larger and larger, I had to declare more and more static members, and ended up “static” my whole class. Well I could not live with that design.

Then I finally switched back to Gtkmm about a month ago. And guess what? I grabbed Gtkmm in a breeze. Part of this phenomenon was that I was able to understand the core GTK concepts, like GtkWidget, GtkVBox, GtkAdjustment, GtkTreeView, etc… and only have to use the tutorial to translate GTK+ codes into Gtkmm. My OOP foundation has been getting better too after 5 months of coding a music manager and trying to program in C++ with GTK+ (weird, is it?). That is why I decide to spend my free time this summer to write a tutorial for the Gtkmm toolkit.

I think that except for the large executable file after compiling, Gtkmm has no drawbacks or weaknesses when comparing to GTK+. Gtkmm even has some advantages over its older brother in terms of memory management and OOP. It is just because Gtkmm main tutorial is too terse and overly concise that makes it difficult for newbies to get the ideas. Lots of these newbies, including me six months ago, switch to another GUI toolkit. That was wasteful because in my opinion, using Gtkmm/C++ is way better than GTK+/C++ (I have never used Qt4 so I can not give my opinion here. But anyway…).

Using Gtkmm, I was able to create a powerful GUI for my Dingo Music Manager. I wrote less codes in Gtkmm/C++ than in GTK+/C++. However, the best part was that my class became less “static”. I am also integrating gstreamermm, SQLite3 and cURLpp into Dingo. I am planning on releasing it this October. Here is a screenshot of the application.

dingo-music
Dingo Music Manager

Those reasons above pushes me to start writing an easy-to-understand and very foundation tutorial for Gtkmm. I really hoped that by reading my tutorials, you guys as newbie Gtkmm developers will not have to waste several months on learning GTK+ just to switch to Gtkmm like I did, and fully understand the GTK concept to apply to other programming languages (Well most of them have better documentation than Gtkmm).

Lastly, feel free to leave comments and questions. I am willing correct the mistakes in this tutorial and answer your questions, although I am nowhere near a Gtkmm master. I strongly advise you to subscribe to the gtkmm mailing list to ask questions as well as keep-in-touch with gtkmm’s changes and development process.

Have fun hacking Gtkmm!!

Advertisements

Tags: , , , , ,

One Response to “0.1. Why not C++/GTK+?”

  1. Jonathan Says:

    To reduce the binary size try to pass -fvisibility=hidden and -fvisibility-inlines-hidden to the compiler and then use the strip tool to remove symbols from the binary.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: