Class GTKGladeXML

Inherits from:
GTKData
Declared in:
GToolKit/GTKGladeXML.h

Class Hierarchy

    NSObject
      |
      +---GTK
	    |
	    +---GTKObject
		  |
		  +---GTKData
			|
			+---GTKGladeXML

Class Description

Instead of creating a program's user interface "by hand", this class uses libglade and libxml to load an interface description from a file and build it at runtime. Each GTKGladeXML object represents a single loaded user interface description file (i.e. an XML file created by the Glade interface builder). All signal connections defined in the XML file are automatically established when the file is loaded.

Interface files loaded through this class use an extended signal handler syntax (within Glade) that differs slightly from the standard syntax used for C function calls. However, you can still load all standard Glade files by directly calling the C functions in libglade (glade_xml_new etc.). In this case, you can create individual Objective-C wrapper objects using the GTOOLKIT_OBJECT macro.

Last modified:
21-Feb-2002 (GToolKit/GTKGladeXML.m)

Method Index

Methods

+ (NSString *) defaultTranslationDomain

Return the current default translation domain used by GladeXML (or nil if no translation domain has been set).

See also:
+setDefaultTranslationDomain:

+ (GtkType) getType

Return the unique type id of this class.

Overrides:
+getType in class GTKData

+ (id) gladeXMLFromFile:(NSString *) file rootObject:(NSString *) root nameTable:(NSDictionary *) context

Create an autoreleased GTKGladeXML instance. It will read the given file and construct all objects stored inside the file (if root is nil) or just a subtree starting from the widget named root. See below for a description of the context parameter and how it is used.

See also:
-initFromFile:rootObject:nameTable:

+ (id) gladeXMLFromFile:(NSString *) file rootObject:(NSString *) root owner:(id) owner

Create an autoreleased GTKGladeXML instance. It will read the given file and construct all objects stored inside the file (if root is nil) or just a subtree starting from the widget named root. This method is equivalent to the call:

[... gladeXMLFromFile:file rootObject:root nameTable:
   [NSDictionary dictionaryWithObject:owner forKey:@"owner"]];
See also:
-initFromFile:rootObject:nameTable:

+ (void) setDefaultTranslationDomain:(NSString *) domain

Set the default translation domain for all translatable strings in the XML files to domain (this requires GNU gettext). The initial translation domain is nil, i.e. the current text domain will be used.

- (GTKWidget *) getWidget:(NSString *) name

Return the widget in the XML file with the name name, or nil if no such object exists.

- (GTKWidget *) getWidgetByLongName:(NSString *) name

Return the widget in the XML file with the long name (including all its parent widget names, separated by periods) name, or nil if no such object exists.

- (id) initFromFile:(NSString *) file rootObject:(NSString *) root nameTable:(NSDictionary *) context

Initialize a new GTKGladeXML instance. It will read the given file and construct all objects stored inside the file (if root is nil) or just a subtree starting from the widget named root. The context parameter contains an external name table of objects in your program that the loaded interface description may refer to in its signal connections.

The Objective-C interface to libglade allows some extended features:

This method automatically retains all widgets at the root of the created widget hierarchy, typically windows, dialogs or popup-menus (take a look at the widget tree in Glade), or the object specified by root.

Returns:
If the file was successfully loaded, this method returns self, otherwise the receiver is released and an NSGenericException is raised.

- (id) initFromFile:(NSString *) file rootObject:(NSString *) root owner:(id) owner

Initialize a new GTKGladeXML instance. It will read the given file and construct all objects stored inside the file (if root is nil) or just a subtree starting from the widget named root. This method is equivalent to the call:

[... initFromFile:file rootObject:root nameTable:
   [NSDictionary dictionaryWithObject:owner forKey:@"owner"]];
See also:
-initFromFile:rootObject:nameTable:

- (BOOL) resolveReferences:(NSString *) name, ...

This method can resolve several widget references with a single method call, so it can be used to avoid repeated invocations of -getWidget: (see there). It may be called with any number of name/ref_pointer pairs, followed by a single nil argument to terminate the variable argument list. A ref_pointer is the address of a variable of type id, GTKObject *, etc. (in fact, any pointer will do) where the result can be stored.

The method tries to look up (by name) each widget in turn and stores the corresponding reference (or nil if a widget with this name could not be found) in the address that the following argument points to. If the ref_pointer for a given name is NULL, no value will be assigned. It is typically used like this:

GTKWindow *my_window;
GTKButton *ok, *cancel;

[... resolveReferences:@"window", &my_window, @"ok_button", &ok,
   @"cancel_button", &cancel, nil];
Returns:
YES if all references could be resolved, NO otherwise
See also:
-getWidget:

generated on 06-Mar-2002 by ObjcDoc 3.0.1