~ubuntu-branches/ubuntu/lucid/gtk+2.0/lucid-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Migrating from libglade to GtkBuilder</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="GTK+ Reference Manual">
<link rel="up" href="migrating.html" title="Part IV. Migrating from Previous Versions of GTK+">
<link rel="prev" href="gtk-migrating-GtkLinkButton.html" title="Migrating from GnomeHRef to GtkLinkButton">
<link rel="next" href="gtk-migrating-tooltips.html" title="Migrating from GtkTooltips to GtkTooltip">
<meta name="generator" content="GTK-Doc V1.13 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="part" href="gtk.html" title="Part I. GTK+ Overview">
<link rel="part" href="gtkbase.html" title="Part II. GTK+ Core Reference">
<link rel="part" href="gtkobjects.html" title="Part III. GTK+ Widgets and Objects">
<link rel="chapter" href="ch01.html" title="Object Hierarchy">
<link rel="chapter" href="ch02.html" title="Widget Gallery">
<link rel="chapter" href="WindowWidgets.html" title="Windows">
<link rel="chapter" href="DisplayWidgets.html" title="Display Widgets">
<link rel="chapter" href="ButtonWidgets.html" title="Buttons and Toggles">
<link rel="chapter" href="NumericEntry.html" title="Numeric/Text Data Entry">
<link rel="chapter" href="TextWidgetObjects.html" title="Multiline Text Editor">
<link rel="chapter" href="TreeWidgetObjects.html" title="Tree, List and Icon Grid Widgets">
<link rel="chapter" href="MenusAndCombos.html" title="Menus, Combo Box, Toolbar">
<link rel="chapter" href="Actions.html" title="Action-based menus and toolbars">
<link rel="chapter" href="SelectorWidgets.html" title="Selectors (File/Font/Color/Input Devices)">
<link rel="chapter" href="LayoutContainers.html" title="Layout Containers">
<link rel="chapter" href="Ornaments.html" title="Ornaments">
<link rel="chapter" href="ScrollingWidgets.html" title="Scrolling">
<link rel="chapter" href="Printing.html" title="Printing">
<link rel="chapter" href="MiscObjects.html" title="Miscellaneous">
<link rel="chapter" href="AbstractObjects.html" title="Abstract Base Classes">
<link rel="chapter" href="PlugSocket.html" title="Cross-process Embedding">
<link rel="chapter" href="SpecialObjects.html" title="Special-purpose features">
<link rel="chapter" href="RecentDocuments.html" title="Recently Used Documents">
<link rel="chapter" href="Builder.html" title="Interface builder">
<link rel="chapter" href="DeprecatedObjects.html" title="Deprecated">
<link rel="part" href="migrating.html" title="Part IV. Migrating from Previous Versions of GTK+">
<link rel="chapter" href="gtk-migrating-checklist.html" title="Migration Checklist">
<link rel="chapter" href="gtk-migrating-GtkFileChooser.html" title="Migrating from GtkFileSelection to GtkFileChooser">
<link rel="chapter" href="gtk-migrating-GtkAction.html" title="Migrating from old menu and toolbar systems to GtkAction">
<link rel="chapter" href="gtk-migrating-GtkComboBox.html" title="Migrating from GtkOptionMenu and GtkCombo to GtkComboBox and GtkComboBoxEntry">
<link rel="chapter" href="gtk-migrating-GtkIconView.html" title="Migrating from GnomeIconList to GtkIconView">
<link rel="chapter" href="gtk-migrating-GtkAboutDialog.html" title="Migrating from GnomeAbout to GtkAboutDialog">
<link rel="chapter" href="gtk-migrating-GtkColorButton.html" title="Migrating from GnomeColorPicker to GtkColorButton">
<link rel="chapter" href="gtk-migrating-GtkAssistant.html" title="Migrating from GnomeDruid to GtkAssistant">
<link rel="chapter" href="gtk-migrating-GtkRecentChooser.html" title="Migrating from EggRecent to GtkRecentChooser">
<link rel="chapter" href="gtk-migrating-GtkLinkButton.html" title="Migrating from GnomeHRef to GtkLinkButton">
<link rel="chapter" href="gtk-migrating-GtkBuilder.html" title="Migrating from libglade to GtkBuilder">
<link rel="chapter" href="gtk-migrating-tooltips.html" title="Migrating from GtkTooltips to GtkTooltip">
<link rel="chapter" href="gtk-migrating-entry-icons.html" title="Migrating from SexyIconEntry to GtkEntry">
<link rel="chapter" href="gtk-migrating-label-links.html" title="Migrating from SexyUrlLabel to GtkLabel">
<link rel="chapter" href="gtk-migrating-ClientSideWindows.html" title="Migrating to client-side windows">
<link rel="part" href="pt05.html" title="Part V. GTK+ Tools">
<link rel="glossary" href="glossary.html" title="Glossary">
<link rel="index" href="api-index-full.html" title="Index of all symbols">
<link rel="index" href="api-index-deprecated.html" title="Index of deprecated symbols">
<link rel="index" href="api-index-2-2.html" title="Index of new symbols in 2.2">
<link rel="index" href="api-index-2-4.html" title="Index of new symbols in 2.4">
<link rel="index" href="api-index-2-6.html" title="Index of new symbols in 2.6">
<link rel="index" href="api-index-2-8.html" title="Index of new symbols in 2.8">
<link rel="index" href="api-index-2-10.html" title="Index of new symbols in 2.10">
<link rel="index" href="api-index-2-12.html" title="Index of new symbols in 2.12">
<link rel="index" href="api-index-2-14.html" title="Index of new symbols in 2.14">
<link rel="index" href="api-index-2-16.html" title="Index of new symbols in 2.16">
<link rel="index" href="api-index-2-18.html" title="Index of new symbols in 2.18">
<link rel="index" href="api-index-2-20.html" title="Index of new symbols in 2.20">
<link rel="glossary" href="annotation-glossary.html" title="Annotation Glossary">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="gtk-migrating-GtkLinkButton.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="migrating.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GTK+ Reference Manual</th>
<td><a accesskey="n" href="gtk-migrating-tooltips.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="chapter" title="Migrating from libglade to GtkBuilder">
<div class="titlepage"><div><div><h2 class="title">
<a name="gtk-migrating-GtkBuilder"></a>Migrating from libglade to GtkBuilder</h2></div></div></div>
<p>
    Since version 2.12, GTK+ provides <a class="link" href="GtkBuilder.html" title="GtkBuilder"><span class="type">GtkBuilder</span></a> to construct
    user interfaces from XML descriptions, similar to the functionality
    provided by <a href="/usr/share/gtk-doc/html/libglade/GladeXML.html"><span class="type">GladeXML</span></a> in the libglade library.
  </p>
<p>
    A good way to start a migration from libglade to GtkBuilder is using
    <span class="application">glade3</span> to convert your .glade file.
    If your code uses the <em class="parameter"><code>root</code></em> parameter of <a href="/usr/share/gtk-doc/html/libglade/GladeXML.html#glade-xml-new"><code class="function">glade_xml_new()</code></a>,
    you can use <a class="link" href="GtkBuilder.html#gtk-builder-add-objects-from-file" title="gtk_builder_add_objects_from_file ()"><code class="function">gtk_builder_add_objects_from_file()</code></a> to construct only certain
    objects from a GtkBuilder file.
  </p>
<p>
    Alternatively, GTK+ also offers the
    <a href="gtk-builder-convert.html">gtk-builder-convert</a> script you can use
    to do the conversion; in which case you should be careful to inspect the output
    and make sure you didn't lose any data.
  </p>
<div class="table">
<a name="id1476793"></a><p class="title"><b>Table 1. Step-by-step instructions for porting code from libglade to GtkBuilder</b></p>
<div class="table-contents"><table summary="Step-by-step instructions for porting code from libglade to GtkBuilder" width="100%" border="1">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>libglade</th>
<th>GtkBuilder</th>
</tr></thead>
<tbody>
<tr>
<td>#include &lt;glade/glade.h&gt;</td>
<td>not needed</td>
</tr>
<tr>
<td><pre class="screen">GladeXML*</pre></td>
<td><pre class="screen">GtkBuilder*</pre></td>
</tr>
<tr>
<td><pre class="screen">glade_xml_new (FILE, "first_widget", NULL)</pre></td>
<td>
<pre class="screen">
GError* error = NULL;
GtkBuilder* builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder, FILE, &amp;error))
  {
    g_warning ("Couldn't load builder file: %s", error-&gt;message);
    g_error_free (error);
  }
</pre>
          </td>
</tr>
<tr>
<td><pre class="screen">glade_xml_get_widget (gxml, “widget_name”)</pre></td>
<td><pre class="screen">GTK_WIDGET (gtk_builder_get_object (builder, “widget_name”))</pre></td>
</tr>
<tr>
<td><pre class="screen">glade_get_widget_name (widget)</pre></td>
<td><pre class="screen">gtk_widget_get_name (widget)</pre></td>
</tr>
<tr>
<td><pre class="screen">glade_xml_get_widget_prefix (gxml, “prefix”)</pre></td>
<td>can be emulated by <code class="literal">gtk_builder_get_objects (builder)</code> together with manual filtering. It returns a GSList* instead of a GList* though.</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>
    While GtkBuilder strives to be a complete replacement for
    libglade, there are a number of areas where it is currently
    still behind libglade:
    </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
        GtkBuilder supports context information in translatable
        properties in a slightly different way than libglade.
        Intltool does not yet support this; see
        <a class="ulink" href="http://bugzilla.gnome.org/show_bug.cgi?id=454894" target="_top">bug
        454894</a> for the current status of intltool support for
        GtkBuilder files. Thankfully, context in translations is a
        rarely used feature, and if you are not using it, intltools
        glade format support works just fine for GtkBuilder files.
      </p></li>
<li class="listitem"><p>
        While libglade can often tolerate multiple widgets having the
        same id in a glade file, GtkBuilder will not accept duplicate
        object ids. Both <span class="application">gtk-builder-convert</span>
        and the GtkBuilder parser emit warnings when they see
        duplicate ids.
      </p></li>
</ul></div>
<p>
  </p>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.13</div>
</body>
</html>