pseudoberries random thoughts about life, hacking and open source

3Dec/071

Strange errors from GtkComboBox? Glade’s probably to blame!

Alright, so I've been trying to debug this strange issue with two GtkComboBoxes which I load with Glade XML. As these two combo boxes have the same structure, I create a function for filling them with data. This procedure sets up the model and two cell renderers: First a GdkPixbuf renderer, then one for text. Then it adds some data to the model. When I call this method on the first combo box, it works fine. However when I try to do the exact same on the second combo box, GObject repeatedly spews out the following warning:

GLib-GObject-WARNING **: unable to set property `text' of type `gchararray' from value of type `GdkPixbuf'

This warning is triggered whenever anything happens with the erroneous combo box: Rendering, hovering over the box, selecting items, etc. The pixbuf is also shifted 20px or so to the right in the box. After hours of debugging this, I discovered that the XML for the two combo boxes were different:

Working combo box:

<widget class="GtkComboBox" id="sound-combo">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>

Erroneous combo box:

<widget class="GtkComboBox" id="app-combo">
<property name="visible">True</property>
<property name="items" translatable="yes"></property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>

Apparently I had previously added some simple text entries to this last combo box in Glade, then deleted them afterwards as I figured I would generate this content in the application instead. Instead of removing the items property altogether, Glade set it to the empty string. This difference was not apparent in the Glade user interface. Thus this combo box would already have a text cell renderer by default at index 0 and later setting it to a GdkPixbuf would result in errors.

Tagged as: 1 Comment
10Jan/071

Welcome to the world of Java

Java
So finally (after half a year of JSP madness) they're teaching us a real programming language - Java (as part of my Object Oriented Programming class.) Although I'd rather sink my teeth into C# and Mono I think Java is a quite good alternative.

With Sun's plans to open source Java the future of Java is looking even more promising. So here goes my first Java program - the compulsory Hello World:

  1. class HelloWorld {
  2.     public static void main(String[] arg)
  3.     {
  4.         System.out.println("Hello world!");
  5.     }
  6. }

Exciting indeed...

Filed under: Java, Programming 1 Comment