Re: get source of pixmap
| From: | Steph | Date: | Wed, 15 May 2002 17:04:20 +0000 |
| Subject: | Re: get source of pixmap | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-1984@lists.php.net to get a copy of this message | ||
> get_args() ? whats that do BTW ??
Ah.
Sorry, haven't updated the manual in a while, trying to finish off GtkObject and stay sane :-\
Battle yr way thru the tags & etc ...
<method id="gtk.gtkobject.method.get_arg">
<funcsynopsis>
<funcprototype>
<funcdef>mixed <function>get_arg</function></funcdef>
<paramdef>string <parameter>arg_name</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<shortdesc>
Returns current argument set.
</shortdesc>
<desc>
<simpara>
In most cases where you are likely to need to know the content of an
argument, there will be a <literal>get</literal> method in place which
is basically a wrapper for
<function class="GtkObject">get_arg()</function>. This is good, because
there is, unfortunately, no way to know for certain the name of the
argument to pass to this function without looking at GTK+ source. A
brief tutorial on making sense of what you see there follows.
</simpara>
<para>
An individual widget's arguments are initialized as a set of enumerated
values at the beginning of the c file relating to that object. For
example, in <filename>gtklabel.c</filename> in GTK 1.2.10 you will see
this directly after the includes:
<informalexample>
<programlisting>
enum {
ARG_0,
ARG_LABEL,
ARG_PATTERN,
ARG_JUSTIFY,
ARG_WRAP
};
</programlisting>
</informalexample>
Around a hundred lines later, these argument types are defined as they
are added to the widget, in the <literal>class_init</literal> function:
<informalexample>
<programlisting>
gtk_object_add_arg_type ("GtkLabel::label", GTK_TYPE_STRING,
GTK_ARG_READWRITE, ARG_LABEL);
gtk_object_add_arg_type ("GtkLabel::pattern", GTK_TYPE_STRING,
GTK_ARG_READWRITE, ARG_PATTERN);
gtk_object_add_arg_type ("GtkLabel::justify",
GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_JUSTIFY);
gtk_object_add_arg_type ("GtkLabel::wrap", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_WRAP);
</programlisting>
</informalexample>
</para>
<simpara>
This gives you the name (in quotes) that you are looking for, the type
of data that the argument will consist of, the fact that it is writeable
(always), and the name of the original enumerated value to bind this
information to.
</simpara>
<simpara>
For <function class="GtkObject">get_arg()</function>, all you really
need is the part that is in quotes, which can be surmised by looking at
the initial enums. The datatype may, however, be useful information if
you need to set an argument and have no other means of doing so than
<function class="GtkObject">set_arg()</function>.
</simpara>
<para>
The way you would access this is as follows:
<informalexample>
<programlisting role="php">
$label = &new GtkLabel('This is an argumentative label');
$arg = $label->get_arg('GtkLabel::label');
echo $arg."\n";
</programlisting>
</informalexample>
</para>
</desc>
</method>
<method id="gtk.gtkobject.method.set_arg">
<funcsynopsis>
<funcprototype>
<funcdef>void <function>set_arg</function></funcdef>
<paramdef>array <parameter>arg_name</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<shortdesc>
Sets an argument or arguments on an object.
</shortdesc>
<desc>
<simpara>
In most cases, you will find that there is a <literal>set</literal>
method in place that is a wrapper function for
<function class="GtkObject">set_arg()</function>. In the rare situation
where this is not in place, you will need to refer to the GTK source in
order to find the argument name expected by this method. There is a
short tutorial explaining what to look for, under
<function class="GtkObject">get_arg()</function>.
</simpara>
<para>
The syntax used in this method is as follows:
<informalexample>
<programlisting role="php">
$label->set_arg(array('GtkLabel::label'=>'RTFS',
'GtkLabel::pattern'=>'____'));
</programlisting>
</informalexample>
</para>
</desc>
</method>