| 1 |
/* |
|---|
| 2 |
* Glade bindings by John Demme (me@teqdruid.com) |
|---|
| 3 |
*/ |
|---|
| 4 |
|
|---|
| 5 |
module glade; |
|---|
| 6 |
|
|---|
| 7 |
private import gtk; |
|---|
| 8 |
|
|---|
| 9 |
public { |
|---|
| 10 |
|
|---|
| 11 |
/* From glade-init.h */ |
|---|
| 12 |
/* handle dynamic loading of libglade extensions */ |
|---|
| 13 |
extern(C) void glade_require(gchar *library); |
|---|
| 14 |
extern(C) void glade_provide(gchar *library); |
|---|
| 15 |
|
|---|
| 16 |
/* From glade-xml.h */ |
|---|
| 17 |
/* Hack... but who cares? */ |
|---|
| 18 |
typedef void GladeXML; |
|---|
| 19 |
typedef void GladeXMLClass; |
|---|
| 20 |
typedef void GladeXMLPrivate; |
|---|
| 21 |
|
|---|
| 22 |
extern(C) GType glade_xml_get_type (); |
|---|
| 23 |
extern(C) GladeXML* glade_xml_new (char *fname, char *root, char *domain); |
|---|
| 24 |
extern(C) GladeXML* glade_xml_new_from_buffer (char *buffer, int size, char *root, char *domain); |
|---|
| 25 |
extern(C) gboolean glade_xml_construct (GladeXML *self, char *fname, char *root, char *domain); |
|---|
| 26 |
|
|---|
| 27 |
extern(C) void glade_xml_signal_connect (GladeXML *self, char *handlername, GCallback func); |
|---|
| 28 |
extern(C) void glade_xml_signal_connect_data (GladeXML *self, char *handlername, GCallback func, gpointer user_data); |
|---|
| 29 |
/* |
|---|
| 30 |
* use gmodule to connect signals automatically. Basically a symbol with |
|---|
| 31 |
* the name of the signal handler is searched for, and that is connected to |
|---|
| 32 |
* the associated symbols. So setting gtk_main_quit as a signal handler |
|---|
| 33 |
* for the destroy signal of a window will do what you expect. |
|---|
| 34 |
*/ |
|---|
| 35 |
extern(C) void glade_xml_signal_autoconnect (GladeXML *self); |
|---|
| 36 |
|
|---|
| 37 |
/* if the gtk_signal_connect_object behaviour is required, connect_object |
|---|
| 38 |
* will point to the object, otherwise it will be NULL. |
|---|
| 39 |
*/ |
|---|
| 40 |
typedef void (*GladeXMLConnectFunc) (gchar *handler_name, |
|---|
| 41 |
GObject *object, |
|---|
| 42 |
gchar *signal_name, |
|---|
| 43 |
gchar *signal_data, |
|---|
| 44 |
GObject *connect_object, |
|---|
| 45 |
gboolean after, |
|---|
| 46 |
gpointer user_data); |
|---|
| 47 |
|
|---|
| 48 |
/* |
|---|
| 49 |
* These two are to make it easier to use libglade with an interpreted |
|---|
| 50 |
* language binding. |
|---|
| 51 |
*/ |
|---|
| 52 |
extern(C) void glade_xml_signal_connect_full (GladeXML *self, |
|---|
| 53 |
gchar *handler_name, |
|---|
| 54 |
GladeXMLConnectFunc func, |
|---|
| 55 |
gpointer user_data); |
|---|
| 56 |
|
|---|
| 57 |
extern(C) void glade_xml_signal_autoconnect_full (GladeXML *self, |
|---|
| 58 |
GladeXMLConnectFunc func, |
|---|
| 59 |
gpointer user_data); |
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
extern(C) GtkWidget *glade_xml_get_widget (GladeXML *self, |
|---|
| 63 |
char *name); |
|---|
| 64 |
extern(C) GList *glade_xml_get_widget_prefix (GladeXML *self, |
|---|
| 65 |
char *name); |
|---|
| 66 |
|
|---|
| 67 |
extern(C) gchar *glade_xml_relative_file (GladeXML *self, |
|---|
| 68 |
gchar *filename); |
|---|
| 69 |
|
|---|
| 70 |
/* don't free the results of these two ... */ |
|---|
| 71 |
extern(C) char *glade_get_widget_name (GtkWidget *widget); |
|---|
| 72 |
GladeXML *glade_get_widget_tree (GtkWidget *widget); |
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
/* interface for changing the custom widget handling */ |
|---|
| 76 |
typedef GtkWidget *(* GladeXMLCustomWidgetHandler) (GladeXML *xml, |
|---|
| 77 |
gchar *func_name, |
|---|
| 78 |
gchar *name, |
|---|
| 79 |
gchar *string1, |
|---|
| 80 |
gchar *string2, |
|---|
| 81 |
gint int1, |
|---|
| 82 |
gint int2, |
|---|
| 83 |
gpointer user_data); |
|---|
| 84 |
|
|---|
| 85 |
extern(C) void glade_set_custom_handler(GladeXMLCustomWidgetHandler handler, |
|---|
| 86 |
gpointer user_data); |
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
/* From glade-parser.h */ |
|---|
| 90 |
typedef _GladeProperty GladeProperty; |
|---|
| 91 |
struct _GladeProperty { |
|---|
| 92 |
gchar *name; |
|---|
| 93 |
gchar *value; |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
typedef _GladeSignalInfo GladeSignalInfo; |
|---|
| 97 |
struct _GladeSignalInfo { |
|---|
| 98 |
gchar *name; |
|---|
| 99 |
gchar *handler; |
|---|
| 100 |
gchar *object; /* NULL if this isn't a connect_object signal */ |
|---|
| 101 |
guint after; |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
typedef _GladeAtkActionInfo GladeAtkActionInfo; |
|---|
| 105 |
struct _GladeAtkActionInfo { |
|---|
| 106 |
gchar *action_name; |
|---|
| 107 |
gchar *description; |
|---|
| 108 |
} |
|---|
| 109 |
|
|---|
| 110 |
typedef _GladeAtkRelationInfo GladeAtkRelationInfo; |
|---|
| 111 |
struct _GladeAtkRelationInfo { |
|---|
| 112 |
gchar *target; |
|---|
| 113 |
gchar *type; |
|---|
| 114 |
} |
|---|
| 115 |
|
|---|
| 116 |
typedef _GladeAccelInfo GladeAccelInfo; |
|---|
| 117 |
struct _GladeAccelInfo { |
|---|
| 118 |
guint key; |
|---|
| 119 |
GdkModifierType modifiers; |
|---|
| 120 |
gchar *signal; |
|---|
| 121 |
} |
|---|
| 122 |
|
|---|
| 123 |
typedef _GladeWidgetInfo GladeWidgetInfo; |
|---|
| 124 |
typedef _GladeChildInfo GladeChildInfo; |
|---|
| 125 |
|
|---|
| 126 |
struct _GladeWidgetInfo { |
|---|
| 127 |
GladeWidgetInfo *parent; |
|---|
| 128 |
|
|---|
| 129 |
gchar *classname; |
|---|
| 130 |
gchar *name; |
|---|
| 131 |
|
|---|
| 132 |
GladeProperty *properties; |
|---|
| 133 |
guint n_properties; |
|---|
| 134 |
|
|---|
| 135 |
GladeProperty *atk_props; |
|---|
| 136 |
guint n_atk_props; |
|---|
| 137 |
|
|---|
| 138 |
GladeSignalInfo *signals; |
|---|
| 139 |
guint n_signals; |
|---|
| 140 |
|
|---|
| 141 |
GladeAtkActionInfo *atk_actions; |
|---|
| 142 |
guint n_atk_actions; |
|---|
| 143 |
|
|---|
| 144 |
GladeAtkRelationInfo *relations; |
|---|
| 145 |
guint n_relations; |
|---|
| 146 |
|
|---|
| 147 |
GladeAccelInfo *accels; |
|---|
| 148 |
guint n_accels; |
|---|
| 149 |
|
|---|
| 150 |
GladeChildInfo *children; |
|---|
| 151 |
guint n_children; |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|
| 154 |
struct _GladeChildInfo { |
|---|
| 155 |
GladeProperty *properties; |
|---|
| 156 |
guint n_properties; |
|---|
| 157 |
|
|---|
| 158 |
GladeWidgetInfo *child; |
|---|
| 159 |
gchar *internal_child; |
|---|
| 160 |
} |
|---|
| 161 |
|
|---|
| 162 |
typedef _GladeInterface GladeInterface; |
|---|
| 163 |
struct _GladeInterface { |
|---|
| 164 |
gchar **requires; |
|---|
| 165 |
guint n_requires; |
|---|
| 166 |
|
|---|
| 167 |
GladeWidgetInfo **toplevels; |
|---|
| 168 |
guint n_toplevels; |
|---|
| 169 |
|
|---|
| 170 |
GHashTable *names; |
|---|
| 171 |
|
|---|
| 172 |
GHashTable *strings; |
|---|
| 173 |
} |
|---|
| 174 |
|
|---|
| 175 |
/* the actual functions ... */ |
|---|
| 176 |
extern(C) GladeInterface *glade_parser_parse_file (gchar *file, |
|---|
| 177 |
gchar *domain); |
|---|
| 178 |
extern(C) GladeInterface *glade_parser_parse_buffer (gchar *buffer, gint len, |
|---|
| 179 |
gchar *domain); |
|---|
| 180 |
extern(C) void glade_interface_destroy (GladeInterface *Interface); |
|---|
| 181 |
|
|---|
| 182 |
extern(C) void glade_interface_dump (GladeInterface *Interface, |
|---|
| 183 |
gchar *filename); |
|---|
| 184 |
|
|---|
| 185 |
/* From glade-build.h */ |
|---|
| 186 |
|
|---|
| 187 |
/* create a new widget of some type. Don't parse `standard' widget options */ |
|---|
| 188 |
typedef GtkWidget *(* GladeNewFunc) (GladeXML *xml, |
|---|
| 189 |
GType widget_type, |
|---|
| 190 |
GladeWidgetInfo *info); |
|---|
| 191 |
/* call glade_xml_build_widget on each child node, and pack in self */ |
|---|
| 192 |
typedef void (* GladeBuildChildrenFunc) (GladeXML *xml, |
|---|
| 193 |
GtkWidget *parent, |
|---|
| 194 |
GladeWidgetInfo *info); |
|---|
| 195 |
typedef GtkWidget *(* GladeFindInternalChildFunc) (GladeXML *xml, |
|---|
| 196 |
GtkWidget *parent, |
|---|
| 197 |
gchar *childname); |
|---|
| 198 |
|
|---|
| 199 |
typedef void (* GladeApplyCustomPropFunc) (GladeXML *xml, |
|---|
| 200 |
GtkWidget *widget, |
|---|
| 201 |
gchar *propname, |
|---|
| 202 |
gchar *value); |
|---|
| 203 |
|
|---|
| 204 |
/* register handlers for a widget */ |
|---|
| 205 |
extern(C) void glade_register_widget(GType type, |
|---|
| 206 |
GladeNewFunc new_func, |
|---|
| 207 |
GladeBuildChildrenFunc build_children, |
|---|
| 208 |
GladeFindInternalChildFunc find_internal_child); |
|---|
| 209 |
|
|---|
| 210 |
/* register a custom handler for a property (that may not have an |
|---|
| 211 |
* associated gobject property. Works in conjunction with |
|---|
| 212 |
* glade_standard_build_widget. */ |
|---|
| 213 |
extern(C) void glade_register_custom_prop(GType type, |
|---|
| 214 |
gchar *prop_name, |
|---|
| 215 |
GladeApplyCustomPropFunc apply_prop); |
|---|
| 216 |
|
|---|
| 217 |
/* set the current toplevel widget while building (use NULL to unset) */ |
|---|
| 218 |
extern(C) void glade_xml_set_toplevel(GladeXML *xml, GtkWindow *window); |
|---|
| 219 |
|
|---|
| 220 |
/* make sure that xml->priv->accel_group is a valid AccelGroup */ |
|---|
| 221 |
extern(C) GtkAccelGroup *glade_xml_ensure_accel(GladeXML *xml); |
|---|
| 222 |
|
|---|
| 223 |
extern(C) void glade_xml_handle_widget_prop(GladeXML *self, GtkWidget *widget, |
|---|
| 224 |
gchar *prop_name, |
|---|
| 225 |
gchar *value_name); |
|---|
| 226 |
|
|---|
| 227 |
extern(C) void glade_xml_set_packing_property (GladeXML *self, |
|---|
| 228 |
GtkWidget *parent, GtkWidget *child, |
|---|
| 229 |
char *name, char *value); |
|---|
| 230 |
|
|---|
| 231 |
/* this function is called to build the interface by GladeXML */ |
|---|
| 232 |
extern(C) GtkWidget *glade_xml_build_widget(GladeXML *self, GladeWidgetInfo *info); |
|---|
| 233 |
|
|---|
| 234 |
/* this function is used to get a pointer to the internal child of a |
|---|
| 235 |
* container widget. It would generally be called by the |
|---|
| 236 |
* build_children callback for any children with the internal_child |
|---|
| 237 |
* name set. */ |
|---|
| 238 |
extern(C) void glade_xml_handle_internal_child(GladeXML *self, GtkWidget *parent, |
|---|
| 239 |
GladeChildInfo *child_info); |
|---|
| 240 |
|
|---|
| 241 |
/* This function performs half of what glade_xml_build_widget does. It is |
|---|
| 242 |
* useful when the widget has already been created. Usually it would not |
|---|
| 243 |
* have any use at all. */ |
|---|
| 244 |
extern(C) void glade_xml_set_common_params(GladeXML *self, |
|---|
| 245 |
GtkWidget *widget, |
|---|
| 246 |
GladeWidgetInfo *info); |
|---|
| 247 |
|
|---|
| 248 |
extern(C) gboolean glade_xml_set_value_from_string (GladeXML *xml, |
|---|
| 249 |
GParamSpec *pspec, |
|---|
| 250 |
gchar *string, |
|---|
| 251 |
GValue *value); |
|---|
| 252 |
|
|---|
| 253 |
extern(C) GtkWidget *glade_standard_build_widget(GladeXML *xml, GType widget_type, |
|---|
| 254 |
GladeWidgetInfo *info); |
|---|
| 255 |
|
|---|
| 256 |
/* A standard child building routine that can be used in widget builders */ |
|---|
| 257 |
extern(C) void glade_standard_build_children(GladeXML *self, GtkWidget *parent, |
|---|
| 258 |
GladeWidgetInfo *info); |
|---|
| 259 |
|
|---|
| 260 |
/* this is a wrapper for gtk_type_enum_find_value, that just returns the |
|---|
| 261 |
* integer value for the enum */ |
|---|
| 262 |
extern(C) gint glade_enum_from_string(GType type, char *string); |
|---|
| 263 |
extern(C) guint glade_flags_from_string(GType type, char *string); |
|---|
| 264 |
|
|---|
| 265 |
/* the module dynamic loading interface ... */ |
|---|
| 266 |
|
|---|
| 267 |
/* increase this when there is a binary incompatible change in the |
|---|
| 268 |
* libglade module API */ |
|---|
| 269 |
extern(C) gchar *glade_module_check_version(gint Version); |
|---|
| 270 |
} |
|---|