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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
|
<HTML
><HEAD
><TITLE
>Embedding Libglade Interfaces</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.49"><LINK
REL="HOME"
TITLE="Libglade Reference Manual"
HREF="libglade.html"><LINK
REL="UP"
TITLE="Libglade Programming Notes"
HREF="libglade-notes.html"><LINK
REL="PREVIOUS"
TITLE="Extending Libglade"
HREF="libglade-extending.html"><LINK
REL="NEXT"
TITLE="Libglade Library Reference"
HREF="libglade-lib.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
BGCOLOR="#000000"
CELLPADDING="1"
CELLSPACING="0"
><TR
><TH
COLSPAN="4"
ALIGN="center"
><FONT
COLOR="#FFFFFF"
SIZE="5"
>Libglade Reference Manual</FONT
></TH
></TR
><TR
><TD
WIDTH="25%"
BGCOLOR="#C00000"
ALIGN="left"
><A
HREF="libglade-extending.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
><<< Previous Page</B
></FONT
></A
></TD
><TD
WIDTH="25%"
BGCOLOR="#0000C0"
ALIGN="center"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
><A
HREF="libglade.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Home</B
></FONT
></A
></B
></FONT
></TD
><TD
WIDTH="25%"
BGCOLOR="#00C000"
ALIGN="center"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
><A
HREF="libglade-notes.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Up</B
></FONT
></A
></B
></FONT
></TD
><TD
WIDTH="25%"
BGCOLOR="#C00000"
ALIGN="right"
><A
HREF="libglade-lib.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Next Page >>></B
></FONT
></A
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="LIBGLADE-EMBEDDING"
>Embedding Libglade Interfaces</A
></H1
><P
>Sometimes you will only want to use libglade for a small
part of your program. If it is just for some dialogs, this is
easy -- you just generate the dialogs from the interface files
when needed (note that libglade caches the XML parse tree
between calls to <TT
CLASS="FUNCTION"
>glade_xml_new</TT
>, so you will
not suffer the performance hit of parsing a particular XML file
more than once). On the other hand, you may want to use
libglade to generate just the menubar or just a notebook for a
dialog or something. Libglade allows this as well.</P
><P
>Libglade allows you to build only part of the interface if
you want to. The second argument to
<TT
CLASS="FUNCTION"
>glade_xml_new</TT
> specifies the name of the
base widget to build the interface from. This way we can limit
the widgets that are constructed by libglade.</P
><P
>For the menubar example, we would create a dummy window in
Glade, and insert a menubar widget into the window. We would
then name the menubar in glade ("menubar" isn't a bad name :),
and customise it as much as we want. Now in the program, we can
use the following code:</P
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>GladeXML *xml;
GtkWidget *menubar;
xml = glade_xml_new("some-interface-file", "menubar");
glade_xml_signal_autoconnect(xml);
menubar = glade_xml_get_widget(xml, "menubar");
/* do whatever we want to with the menubar */</PRE
></TD
></TR
></TABLE
><P
>From here, we can do what ever we want with the menubar
widget. The dummy window we created in Glade is never created,
so does not affect the program. You can also use similar code
to only build a single dialog from a file that contains many
dialogs.</P
><P
>One thing to note -- if you don't want a widget to be
displayed as soon as it is built with
<TT
CLASS="FUNCTION"
>glade_xml_new</TT
>, you should turn off the
visible flag on that widget in Glade. This is the correct
solution to the problem (putting a hack into libglade so that it
never shows the toplevel windows is not The Right Thing).</P
></DIV
><DIV
CLASS="NAVFOOTER"
><BR><BR><TABLE
WIDTH="100%"
BORDER="0"
BGCOLOR="#000000"
CELLPADDING="1"
CELLSPACING="0"
><TR
><TD
WIDTH="25%"
BGCOLOR="#C00000"
ALIGN="left"
><A
HREF="libglade-extending.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
><<< Previous Page</B
></FONT
></A
></TD
><TD
WIDTH="25%"
BGCOLOR="#0000C0"
ALIGN="center"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
><A
HREF="libglade.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Home</B
></FONT
></A
></B
></FONT
></TD
><TD
WIDTH="25%"
BGCOLOR="#00C000"
ALIGN="center"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
><A
HREF="libglade-notes.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Up</B
></FONT
></A
></B
></FONT
></TD
><TD
WIDTH="25%"
BGCOLOR="#C00000"
ALIGN="right"
><A
HREF="libglade-lib.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Next Page >>></B
></FONT
></A
></TD
></TR
><TR
><TD
COLSPAN="2"
ALIGN="left"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Extending Libglade</B
></FONT
></TD
><TD
COLSPAN="2"
ALIGN="right"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Libglade Library Reference</B
></FONT
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
|