Re: Queries on tree items and signals
- From: muppet <scott asofyet org>
- To: "rashwin" <rashwin infosys com>
- Cc: gtk-perl-list gnome org
- Subject: Re: Queries on tree items and signals
- Date: Tue, 8 Mar 2005 08:49:36 -0500
On Mar 8, 2005, at 2:09 AM, rashwin wrote:
Hi, I am new to the list and I have a couple of queries on the
following:
welcome.
1. Signals and callback functions.
I have a requirement in which I have to a function like below:
sub display_type {
my ($tree, $ext_name, $help) = @_;
$::button_ok->signal_handlers_destroy();
$::button_cancel->signal_handlers_destroy();
these aren't bound, as you probably already found. since it destroys
*all* signal handlers, it's not what you really want to do, anyway.
$::button_ok->signal_connect( 'clicked',
\&type_direct_apply,$tree,$::external_text,$help_text);
also, you can only pass one user-data argument to callbacks via
signal_connect(). the workaround is to create an anonymous hash or the
like, put your extra values in that, and pass that instead.
$::button_cancel->signal_connect( 'clicked',
\&type_sample_cancel,$tree, $::external_text,$help_text );
...
I stopped the infinite loop by calling the signal connect functions
for the buttons only once but the problem is the apply and cancel
functions are called with the first values of the arguements when they
were created.
the right thing to do is indeed to connect only once. you don't *have*
to store the arguments in the signal_connect data; you can place them
in the instance and therefore use the same handler with all such
events.
Can someone throw light on why it keeps calling the signal connect
functions
endlessly when $button_ok is clicked on once?
signal_connect() sets up a callback function to be invoked at a later
time. it doesn't get invoked at signal_connect() time. you use this
to set up behavior, not to pass data around.
the fragment you posted is too small to give you any advice on how to
fix it -- sorry.
2. THis is on dynamically changing labels of tree items.
When you create a tree item the first time and when selecting that
tree item,
I want the user to change the label of the tree item on the fly.
Is that possible? What commands to be used for the same?
"label" of a tree item? a GtkTreeView does not contain GtkLabels, it
contains GtkTreeViewColumns which are drawn by GtkCellRenderers.
do you mean you want to allow the user to edit cells in-place? in that
case, you need to make the cell renderer editable and hook into its
"edited" signal to apply the changes to the model.
see the editable-cells example program in the gtk-demo directory of the
Gtk2 source tarball, or at
http://cvs.sourceforge.net/viewcvs.py/gtk2-perl/gtk2-perl-xs/Gtk2/gtk-
demo/editable_cells.pl?rev=1.7&view=auto
--
Package contains eight 13-inch aliens in assorted colors.
-- Catalog copy for space invaders wall decals.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]