Hey Monks!
So I'm creating the AboutDialog for my GUI and I'm doing the "set_website" portion and trying to make the URL I enter actually do something when you click on it. I read that you do the
set_url_hook() part before you run the
set_website() method/function.
So I was having trouble just getting Perl to open a Browser and go to a URL, but I figured out how to do that part by using the Perl Module
use Browser::Open qw( open_browser ); which seems to work pretty well. I then tried the code below and now, when I open the AboutDialog box, it instantly opens whatever URL I put in the "open_browser()" function from that Module without clicking on the link.
# Create a MessageDialog to display the "About" Info in:
my $about_window = Gtk2::AboutDialog->new;
$about_window->set_program_name("Program-Name");
$about_window->set_version('v1.0');
$about_window->set_copyright('August 2013');
$about_window->set_comments("This is the Comment String");
# Using Google.com just as an example:
my $url = "http://www.google.com";
$about_window->set_url_hook(open_browser($url));
$about_window->set_website($url);
$about_window->set_authors("....author_data....");
my $about_img = "$icon_DIR/Icon_Logo.png";
my $about_pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($about_img);
$about_window->set_logo($about_pixbuf);
# Add the Hide action to the 'Close' button in the AboutDialog():
$about_window->signal_connect('response' => sub { $about_window->h
+ide; });
$about_window->show;
So from what's going on here I would assume that whatever you put inside the "set_url_hook()" function gets executed immediately upon creation of the AboutDialog. I did see a SIGNAL available for the AboutDialog that's called "activate-link" but I couldn't connect it with "signal_connect" function...
Does anyone know what I'm missing here? I would assume there is something that I need to add to this to get it working?
UPDATE:
I've also noticed this... So I click the MenuItem to open the AboutDialog, and like I mentioned before, the set_url_hook() gets executed immediately without having to click the link. So I close the page that opened and go back to the About Window and click on the Link itself. When that happens I can see this error below being printed to the terminal.
Undefined subroutine &main::0 called at
And the line that the error references to is the line that has
Gtk2->main; on it... So I tried putting a test sub in the set_url_hook() and I get the same error and whatever the Sub returns is what Perl is saying is a Undefined Subroutine.
So if my function returns "Hello", the Error would be:
Undefined subroutine &main::Hello called at
So I just thought I should mention that since I'm tinkering with it a bit...
Thanks in Advance,
Matt
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.