[Glade-users] Calling Perl GTK modules

On Thu, 2005-10-06 at 14:40 -0400, Dale wrote:
Hello all...

I'm a little confused as to how to go about something.

I have a small (well, sort of) module called CheckSecure that is
nothing more than a user/password popup I want to use for
authentication via LDAP.  The module works great like this:

require CheckSecure;
my $auth = CheckSecure::check_secure;
if ($auth) {
  #do whatever

It does the popup, and returns the value to me.  I can use it from a
non-GUI Perl script, and it's perfect.  However...

I'm not sure how to use it from a GTK program.  When I call the module
like this, my GTK program isn't waiting to get a response back.  The
$auth variable has no value when I'm trying to use it, because a value
hasn't been returned from CheckSecure yet.

I originally had Gtk->main and Gtk->main_quit in the module, but I
have since removed them, because of course ->main_quit was killing the
GTK app that was calling the module.  My main problem is just
retrieving the value though.

You need to create your own GMainLoop and run it to handle your dialog
(which should be modal), just as the gtk_dialog_run() code does:

  ri.loop = g_main_loop_new (NULL, FALSE);

  g_main_loop_run (ri.loop);

  g_main_loop_unref (ri.loop);

Actually the simplest thing to do is just use gtk_dialog_run().


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