Re: Signal disconnecting



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Great.

Thanks,

Fred.


On Sat, 16 Aug 2003, Ross McFarland wrote:

On Sat, 2003-08-16 at 16:55, Fred. Oger wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


As you said it's obvious, hopelessly I can't go that way as I have to
change the callback on the button only when what I'm doing in the original
callback succeeds.

What I want to do is :

In my function NewCustomer, I have a  button which alls the
\&SaveCustomer function. If this function successfully save the
data, I rename the button to 'Create a new customer' and connect it to the
NewCustomer function.

It works, but my only problem is that the first connected signal is still
emited, so it tries to save the customer's data again and then calls the
NewCustomer function.

if i under stand what you're looking to do:

# saved means that customer is saved and the button is creating new
# if not saved then the button saves the customer
my $saved = 0;
$button->signal_connect( clicked => sub {
      if( $saved )
      {
              create_new_customer(...);
              $button->set_label('Save customer');
              $saved = 0;
      }
      else
      {
              if( $saved = save_customer(...) )
              {
                      $button->set_label('Create new customer');
              }
      }
});

if not sorry.

-rm


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/Pp/HgcR1FkaCE7oRAixLAJwLVBGbcFMj0fKLT85IHNIOAt778wCfeIjR
pYjdCZB0PJIfQ1dlenIG36A=
=Onte
-----END PGP SIGNATURE-----



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]