1 | /* -*- Mode: C; c-basic-offset: 4 -*- |
---|
2 | * libglade - a library for building interfaces from XML files at runtime |
---|
3 | * Copyright (C) 1998-2002 James Henstridge <james@daa.com.au> |
---|
4 | * |
---|
5 | * glade-build.h: functions useful for adding support for new widgets. |
---|
6 | * |
---|
7 | * This library is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the GNU Library General Public |
---|
9 | * License as published by the Free Software Foundation; either |
---|
10 | * version 2 of the License, or (at your option) any later version. |
---|
11 | * |
---|
12 | * This library is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | * Library General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU Library General Public |
---|
18 | * License along with this library; if not, write to the |
---|
19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
20 | * Boston, MA 02111-1307, USA. |
---|
21 | */ |
---|
22 | #ifndef GLADE_BUILD_H |
---|
23 | #define GLADE_BUILD_H |
---|
24 | |
---|
25 | #include <glib.h> |
---|
26 | #include <glib-object.h> |
---|
27 | #include <gmodule.h> |
---|
28 | #include <glade/glade-xml.h> |
---|
29 | #include <gtk/gtkwidget.h> |
---|
30 | #include <gtk/gtkwindow.h> |
---|
31 | #include <gtk/gtkaccelgroup.h> |
---|
32 | #include <gtk/gtkadjustment.h> |
---|
33 | |
---|
34 | #include <glade/glade-parser.h> |
---|
35 | |
---|
36 | G_BEGIN_DECLS |
---|
37 | |
---|
38 | /* create a new widget of some type. Don't parse `standard' widget options */ |
---|
39 | typedef GtkWidget *(* GladeNewFunc) (GladeXML *xml, |
---|
40 | GType widget_type, |
---|
41 | GladeWidgetInfo *info); |
---|
42 | /* call glade_xml_build_widget on each child node, and pack in self */ |
---|
43 | typedef void (* GladeBuildChildrenFunc) (GladeXML *xml, |
---|
44 | GtkWidget *parent, |
---|
45 | GladeWidgetInfo *info); |
---|
46 | typedef GtkWidget *(* GladeFindInternalChildFunc) (GladeXML *xml, |
---|
47 | GtkWidget *parent, |
---|
48 | const gchar *childname); |
---|
49 | |
---|
50 | typedef void (* GladeApplyCustomPropFunc) (GladeXML *xml, |
---|
51 | GtkWidget *widget, |
---|
52 | const gchar *propname, |
---|
53 | const gchar *value); |
---|
54 | |
---|
55 | /* register handlers for a widget */ |
---|
56 | void glade_register_widget(GType type, |
---|
57 | GladeNewFunc new_func, |
---|
58 | GladeBuildChildrenFunc build_children, |
---|
59 | GladeFindInternalChildFunc find_internal_child); |
---|
60 | |
---|
61 | /* register a custom handler for a property (that may not have an |
---|
62 | * associated gobject property. Works in conjunction with |
---|
63 | * glade_standard_build_widget. */ |
---|
64 | void glade_register_custom_prop(GType type, |
---|
65 | const gchar *prop_name, |
---|
66 | GladeApplyCustomPropFunc apply_prop); |
---|
67 | |
---|
68 | /* set the current toplevel widget while building (use NULL to unset) */ |
---|
69 | void glade_xml_set_toplevel(GladeXML *xml, GtkWindow *window); |
---|
70 | |
---|
71 | /* make sure that xml->priv->accel_group is a valid AccelGroup */ |
---|
72 | GtkAccelGroup *glade_xml_ensure_accel(GladeXML *xml); |
---|
73 | |
---|
74 | void glade_xml_handle_widget_prop(GladeXML *self, GtkWidget *widget, |
---|
75 | const gchar *prop_name, |
---|
76 | const gchar *value_name); |
---|
77 | |
---|
78 | void glade_xml_set_packing_property (GladeXML *self, |
---|
79 | GtkWidget *parent, GtkWidget *child, |
---|
80 | const char *name, const char *value); |
---|
81 | |
---|
82 | /* this function is called to build the interface by GladeXML */ |
---|
83 | GtkWidget *glade_xml_build_widget(GladeXML *self, GladeWidgetInfo *info); |
---|
84 | |
---|
85 | /* this function is used to get a pointer to the internal child of a |
---|
86 | * container widget. It would generally be called by the |
---|
87 | * build_children callback for any children with the internal_child |
---|
88 | * name set. */ |
---|
89 | void glade_xml_handle_internal_child(GladeXML *self, GtkWidget *parent, |
---|
90 | GladeChildInfo *child_info); |
---|
91 | |
---|
92 | /* This function performs half of what glade_xml_build_widget does. It is |
---|
93 | * useful when the widget has already been created. Usually it would not |
---|
94 | * have any use at all. */ |
---|
95 | void glade_xml_set_common_params(GladeXML *self, |
---|
96 | GtkWidget *widget, |
---|
97 | GladeWidgetInfo *info); |
---|
98 | |
---|
99 | gboolean glade_xml_set_value_from_string (GladeXML *xml, |
---|
100 | GParamSpec *pspec, |
---|
101 | const gchar *string, |
---|
102 | GValue *value); |
---|
103 | |
---|
104 | GtkWidget *glade_standard_build_widget(GladeXML *xml, GType widget_type, |
---|
105 | GladeWidgetInfo *info); |
---|
106 | |
---|
107 | /* A standard child building routine that can be used in widget builders */ |
---|
108 | void glade_standard_build_children(GladeXML *self, GtkWidget *parent, |
---|
109 | GladeWidgetInfo *info); |
---|
110 | |
---|
111 | /* this is a wrapper for gtk_type_enum_find_value, that just returns the |
---|
112 | * integer value for the enum */ |
---|
113 | gint glade_enum_from_string(GType type, const char *string); |
---|
114 | guint glade_flags_from_string(GType type, const char *string); |
---|
115 | |
---|
116 | /* the module dynamic loading interface ... */ |
---|
117 | |
---|
118 | /* increase this when there is a binary incompatible change in the |
---|
119 | * libglade module API */ |
---|
120 | #define GLADE_MODULE_API_VERSION 1 |
---|
121 | gchar *glade_module_check_version(gint version); |
---|
122 | |
---|
123 | #define GLADE_MODULE_CHECK_INIT \ |
---|
124 | G_MODULE_EXPORT const gchar *g_module_check_init(GModule *gmodule); \ |
---|
125 | const gchar * \ |
---|
126 | g_module_check_init(GModule *gmodule) \ |
---|
127 | { \ |
---|
128 | return glade_module_check_version(GLADE_MODULE_API_VERSION); \ |
---|
129 | } |
---|
130 | |
---|
131 | /* prototype for plugin init function (should be implemented by plugin) */ |
---|
132 | G_MODULE_EXPORT void glade_module_register_widgets(void); |
---|
133 | |
---|
134 | G_END_DECLS |
---|
135 | |
---|
136 | #endif |
---|