.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Gtk2::Buildable 3pm" .TH Gtk2::Buildable 3pm "2019-09-16" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Gtk2::Buildable \- Interface for objects that can be built by Gtk2::Builder .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& package Thing; \& use Gtk2; \& use Glib::Object::Subclass \& Glib::Object::, \& \& # Some signals and properties on the object... \& signals => { \& exploderize => {}, \& }, \& properties => [ \& Glib::ParamSpec\->int (\*(Aqforce\*(Aq, \*(AqForce\*(Aq, \& \*(AqExplosive force, in megatons\*(Aq, \& 0, 1000000, 5, [\*(Aqreadable\*(Aq, \*(Aqwritable\*(Aq]), \& ], \& ; \& \& sub exploderize { \& my $self = shift; \& $self\->signal_emit (\*(Aqexploderize\*(Aq); \& } \& \& # We can accept all defaults for Buildable; see the description \& # for details on custom XML. \& \& package main; \& use Gtk2 \-init; \& my $builder = Gtk2::Builder\->new (); \& $builder\->add_from_string (\*(Aq \& \& 50 \& \& \& \*(Aq); \& $builder\->connect_signals (); \& \& my $thing = $builder\->get_object (\*(Aqthing1\*(Aq); \& \& $thing\->exploderize (); \& \& sub do_explode { \& my $thing = shift; \& printf "boom * %d!\en", $thing\->get (\*(Aqforce\*(Aq); \& } \& \& # This program prints "boom * 50!" on stdout. .Ve .SH "HIERARCHY" .IX Header "HIERARCHY" .Vb 2 \& Glib::Interface \& +\-\-\-\-Gtk2::Buildable .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Gtk2::Buildable interface allows objects and widgets to have \&\f(CW\*(C`\*(C'\fR objects, special property settings, or extra custom tags in a Gtk2::Builder \s-1UI\s0 description (). .PP The main user of the Gtk2::Buildable interface is Gtk2::Builder, so there should be very little need for applications to call any of the Gtk2::Buildable methods. So this documentation deals with implementing a buildable object. .PP Gtk2::Builder already supports plain Glib::Object or Gtk2::Widget with \&\f(CW\*(C`\*(C'\fR construction and \f(CW\*(C`\*(C'\fR settings, so often the \f(CW\*(C`Gtk2::Buildable\*(C'\fR interface is not needed. The only thing to note is that an object or widget implemented in Perl must be loaded before building. .SH "OVERRIDING BUILDABLE INTERFACE METHODS" .IX Header "OVERRIDING BUILDABLE INTERFACE METHODS" The buildable interface can be added to a Perl code object or widget subclass by putting \f(CW\*(C`Gtk2::Buildable\*(C'\fR in the interfaces list and implementing the following methods. .PP In current Gtk2\-Perl the custom tags code doesn't chain up to any buildable interfaces in superclasses. This means for instance if you implement Gtk2::Buildable on a new widget subclass then you lose the and tags normally available from Gtk2::Widget. This will likely change in the future, probably by chaining up by default for unhandled tags, maybe with a way to ask deliberately not to chain. .ie n .IP "\s-1SET_NAME\s0 ($self, $name)" 4 .el .IP "\s-1SET_NAME\s0 ($self, \f(CW$name\fR)" 4 .IX Item "SET_NAME ($self, $name)" .RS 4 .PD 0 .IP "\(bu" 4 .PD \&\f(CW$name\fR (string) .RE .RS 4 .Sp This method should store \fI\f(CI$name\fI\fR in \fI\f(CI$self\fI\fR somehow. For example, Gtk2::Widget maps this to the Gtk2::Widget's \f(CW\*(C`name\*(C'\fR property. If you don't implement this method, the name will be attached in object data down in C code. Implement this method if your object has some notion of \*(L"name\*(R" and it makes sense to map the \s-1XML\s0 name attribute to that. .RE .IP "string = \s-1GET_NAME\s0 ($self)" 4 .IX Item "string = GET_NAME ($self)" If you implement \f(CW\*(C`SET_NAME\*(C'\fR, you need to implement this method to retrieve that name. .ie n .IP "\s-1ADD_CHILD\s0 ($self, $builder, $child, $type)" 4 .el .IP "\s-1ADD_CHILD\s0 ($self, \f(CW$builder\fR, \f(CW$child\fR, \f(CW$type\fR)" 4 .IX Item "ADD_CHILD ($self, $builder, $child, $type)" .RS 4 .PD 0 .IP "\(bu" 4 .PD \&\f(CW$builder\fR (Gtk2::Builder) .IP "\(bu" 4 \&\f(CW$child\fR (Glib::Object or undef) .IP "\(bu" 4 \&\f(CW$type\fR (string) .RE .RS 4 .Sp \&\f(CW\*(C`ADD_CHILD\*(C'\fR will be called to add \fI\f(CI$child\fI\fR to \fI\f(CI$self\fI\fR. \fI\f(CI$type\fI\fR can be used to determine the kind of child. For example, Gtk2::Container implements this method to add a child widget to the container, and Gtk2::Notebook uses \&\fI\f(CI$type\fI\fR to distinguish between \*(L"page-label\*(R" and normal children. The value of \fI\f(CI$type\fI\fR comes directly from the \f(CW\*(C`type\*(C'\fR attribute of the \s-1XML\s0 \f(CW\*(C`child\*(C'\fR tag. .RE .ie n .IP "\s-1SET_BUILDABLE_PROPERTY\s0 ($self, $builder, $name, $value)" 4 .el .IP "\s-1SET_BUILDABLE_PROPERTY\s0 ($self, \f(CW$builder\fR, \f(CW$name\fR, \f(CW$value\fR)" 4 .IX Item "SET_BUILDABLE_PROPERTY ($self, $builder, $name, $value)" .RS 4 .PD 0 .IP "\(bu" 4 .PD \&\f(CW$builder\fR (Gtk2::Builder) .IP "\(bu" 4 \&\f(CW$name\fR (string) .IP "\(bu" 4 \&\f(CW$value\fR (scalar) .RE .RS 4 .Sp This will be called to set the object property \fI\f(CI$name\fI\fR on \fI\f(CI$self\fI\fR, directly from the \f(CW\*(C`property\*(C'\fR \s-1XML\s0 tag. It is not normally necessary to implement this method, as the fallback simply calls \f(CW\*(C`Glib::Object::set()\*(C'\fR. Gtk2::Window implements this method to delay showing itself (i.e., setting the \*(L"visible\*(R" property) until the whole interface is created. You can also use this to handle properties that are not wired up through the Glib::Object property system (though simply creating the property is easier). .RE .ie n .IP "parser or undef = \s-1CUSTOM_TAG_START\s0 ($self, $builder, $child, $tagname)" 4 .el .IP "parser or undef = \s-1CUSTOM_TAG_START\s0 ($self, \f(CW$builder\fR, \f(CW$child\fR, \f(CW$tagname\fR)" 4 .IX Item "parser or undef = CUSTOM_TAG_START ($self, $builder, $child, $tagname)" .RS 4 .PD 0 .IP "\(bu" 4 .PD \&\f(CW$builder\fR (Gtk2::Builder) .IP "\(bu" 4 \&\f(CW$child\fR (Glib::Object or undef) .IP "\(bu" 4 \&\f(CW$tagname\fR (string) .RE .RS 4 .Sp When Gtk2::Builder encounters an unknown tag while parsing the definition of \fI\f(CI$self\fI\fR, it will call \f(CW\*(C`CUSTOM_TAG_START\*(C'\fR to give your code a chance to do something with it. If \fI\f(CI$tagname\fI\fR was encountered inside a \f(CW\*(C`child\*(C'\fR tag, the corresponding object will be passed in \fI\f(CI$child\fI\fR; otherwise, \&\fI\f(CI$child\fI\fR will be \f(CW\*(C`undef\*(C'\fR. .Sp Your \f(CW\*(C`CUSTOM_TAG_START\*(C'\fR method should decide whether it supports \fI\f(CI$tagname\fI\fR. If not, return \f(CW\*(C`undef\*(C'\fR. If you do support it, return a blessed perl object that implements three special methods to be used to parse that tag. (These methods are defined by GLib's GMarkupParser, which is a simple SAX-style setup.) .ie n .IP "\s-1START_ELEMENT\s0 ($self, $context, $element_name, $attributes)" 4 .el .IP "\s-1START_ELEMENT\s0 ($self, \f(CW$context\fR, \f(CW$element_name\fR, \f(CW$attributes\fR)" 4 .IX Item "START_ELEMENT ($self, $context, $element_name, $attributes)" .RS 4 .PD 0 .IP "\(bu" 4 .PD \&\f(CW$context\fR (Gtk2::Buildable::ParseContext) .IP "\(bu" 4 \&\f(CW$element_name\fR (string) .IP "\(bu" 4 \&\f(CW$attributes\fR (hash reference) Dictionary of all attributes of this tag. .RE .RS 4 .RE .ie n .IP "\s-1TEXT\s0 ($self, $context, $text)" 4 .el .IP "\s-1TEXT\s0 ($self, \f(CW$context\fR, \f(CW$text\fR)" 4 .IX Item "TEXT ($self, $context, $text)" .RS 4 .PD 0 .IP "\(bu" 4 .PD \&\f(CW$context\fR (Gtk2::Buildable::ParseContext) .IP "\(bu" 4 \&\f(CW$text\fR (string) The text contained in the tag. .RE .RS 4 .RE .ie n .IP "\s-1END_ELEMENT\s0 ($self, $context, $element_name)" 4 .el .IP "\s-1END_ELEMENT\s0 ($self, \f(CW$context\fR, \f(CW$element_name\fR)" 4 .IX Item "END_ELEMENT ($self, $context, $element_name)" .RS 4 .PD 0 .IP "\(bu" 4 .PD \&\f(CW$context\fR (Gtk2::Buildable::ParseContext) .IP "\(bu" 4 \&\f(CW$element_name\fR (string) .RE .RS 4 .RE .RE .RS 4 .Sp Any blessed perl object that implements these methods is valid as a parser. (Ain't duck-typing great?) Gtk2::Builder will hang on to this object until the parsing is complete, and will pass it to \f(CW\*(C`CUSTOM_TAG_END\*(C'\fR and \&\f(CW\*(C`CUSTOM_FINISHED\*(C'\fR, so you shouldn't have to worry about its lifetime. .RE .ie n .IP "\s-1CUSTOM_TAG_END\s0 ($self, $builder, $child, $tagname, $parser)" 4 .el .IP "\s-1CUSTOM_TAG_END\s0 ($self, \f(CW$builder\fR, \f(CW$child\fR, \f(CW$tagname\fR, \f(CW$parser\fR)" 4 .IX Item "CUSTOM_TAG_END ($self, $builder, $child, $tagname, $parser)" .RS 4 .PD 0 .IP "\(bu" 4 .PD \&\f(CW$builder\fR (Gtk2::Builder) .IP "\(bu" 4 \&\f(CW$child\fR (Glib::Object or undef) .IP "\(bu" 4 \&\f(CW$tagname\fR (string) .IP "\(bu" 4 \&\f(CW$parser\fR (some perl object) as returned from \f(CW\*(C`CUSTOM_TAG_START\*(C'\fR .RE .RS 4 .Sp This method will be called (if it exists) when the close tag for \fI\f(CI$tagname\fI\fR is encountered. \fI\f(CI$parser\fI\fR will be the object you returned from \&\f(CW\*(C`CUSTOM_TAG_START\*(C'\fR. \fI\f(CI$child\fI\fR is the same object-or-undef as passed to \&\f(CW\*(C`CUSTOM_TAG_START\*(C'\fR. .RE .ie n .IP "\s-1CUSTOM_FINISHED\s0 ($self, $builder, $child, $tagname, $parser)" 4 .el .IP "\s-1CUSTOM_FINISHED\s0 ($self, \f(CW$builder\fR, \f(CW$child\fR, \f(CW$tagname\fR, \f(CW$parser\fR)" 4 .IX Item "CUSTOM_FINISHED ($self, $builder, $child, $tagname, $parser)" .RS 4 .PD 0 .IP "\(bu" 4 .PD \&\f(CW$builder\fR (Gtk2::Builder) .IP "\(bu" 4 \&\f(CW$child\fR (Glib::Object or undef) .IP "\(bu" 4 \&\f(CW$tagname\fR (string) .IP "\(bu" 4 \&\f(CW$parser\fR (some perl object) as returned from \f(CW\*(C`CUSTOM_TAG_START\*(C'\fR .RE .RS 4 .Sp This method will be called (if it exists) when the parser finishes dealing with the custom tag \fI\f(CI$tagname\fI\fR. \fI\f(CI$parser\fI\fR will be the object you returned from \f(CW\*(C`CUSTOM_TAG_START\*(C'\fR. \fI\f(CI$child\fI\fR is the same object-or-undef as passed to \f(CW\*(C`CUSTOM_TAG_START\*(C'\fR. .RE .ie n .IP "\s-1PARSER_FINISHED\s0 ($self, $builder)" 4 .el .IP "\s-1PARSER_FINISHED\s0 ($self, \f(CW$builder\fR)" 4 .IX Item "PARSER_FINISHED ($self, $builder)" .RS 4 .PD 0 .IP "\(bu" 4 .PD \&\f(CW$builder\fR (Gtk2::Builder) .RE .RS 4 .Sp If this method exists, it will be invoked when the builder finishes parsing the description data. This method is handy if you need to defer any object initialization until all of the rest of the input is parsed, most likely because you need to refer to an object that is declared after \fI\f(CI$self\fI\fR or you need to perform special cleanup actions. It is not normally necessary to implement this method. .RE .ie n .IP "object or undef = \s-1GET_INTERNAL_CHILD\s0 ($self, $builder, $childname)" 4 .el .IP "object or undef = \s-1GET_INTERNAL_CHILD\s0 ($self, \f(CW$builder\fR, \f(CW$childname\fR)" 4 .IX Item "object or undef = GET_INTERNAL_CHILD ($self, $builder, $childname)" .RS 4 .PD 0 .IP "\(bu" 4 .PD \&\f(CW$builder\fR (Gtk2::Builder) .IP "\(bu" 4 \&\f(CW$childname\fR (string) .RE .RS 4 .Sp This will be called to fetch an internal child of \fI\f(CI$self\fI\fR. Implement this method if your buildable has internal children that need to be accessed from a \s-1UI\s0 definition. For example, Gtk2::Dialog implements this to give access to its internal vbox child. .Sp If \fI\f(CI$childname\fI\fR is unknown then return \f(CW\*(C`undef\*(C'\fR. (The builder will then generally report a GError for the \s-1UI\s0 description referring to an unknown child.) .RE .SH "SEE ALSO" .IX Header "SEE ALSO" Gtk2, Glib::Interface, , Gtk2::Buildable::ParseContext .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2003\-2011 by the gtk2\-perl team. .PP This software is licensed under the \s-1LGPL.\s0 See Gtk2 for a full notice.