2.3. Accessing Widget Resources

There are potentially three ways to access widget resources in Gamma/GTK:

GTK programmers who are used to the C function syntax may be more comfortable with using the method and function calls, but since Gamma is an object-oriented language, we often use the resource name syntax for getting and setting resource values. Here is an example of a code snippet that uses resource name syntax:

frame = new(GtkFrame)
frame.label = "Test Frame";
frame.shadow_type = GTK_SHADOW_OUT;

Here it is in method and function syntax:

frame = gtk_frame_new("Test Frame");
frame.set_shadow_type(GTK_SHADOW_OUT);
  

Of course, many methods provide additional functionality beyond setting or getting a resource value, and thus have no equivalent resource syntax. Also, you will find that a few resources have no resource syntax at all, and can only be set with a method. On the other hand, some resources do not have associated methods, and can only be set directly. The reason for this unusual arrangement is that the GTK widgets and functions are not all written in a completely consistent way. To adapt to some small inconsistencies and to provide the full functionality of GTK, Gamma needs to access certain hidden resources and make them available.

In addition to the above functions, there are many more that are not associated with any particular widget. None of these functions are wrapped as methods, but as functions. They always take the same name as the corresponding C functions, and are generally used in the same way. A list of them appears in the List of Functions (Non Widget-Specific) Appendix of this guide.