In this walkthrough, i'll show you how to write a simple GTK3 Webkit based browser that turns a webpage into a "native application". Apple Users probably would call it an App.

Fixing MakeMaker

First of all, If you are - like me - using any Ubuntu x64 derivate with ActivePerl 5.14, you're in for quite a ride. Mostly, because ExtUtils::MakeMaker wont find most libraries. This is easy to fix if you know how (and a bit risky too, since you are disabling checks). These checks in MakeMaker try to make sure you have the required libraries but wont find them even if you do have them.

So, find the file Kid.pm in */lib/ExtUtils/Liblist and find the following lines (somewhere around line 170 in my MakeMaker version):

} else { warn "$thislib not found in $thispth\n" if $verbose; next; } warn "'-l$thislib' found at $fullname\n" if $verbose; push @libs, $fullname unless $libs_seen{$fullname}++; $found++; $found_lib++; # Now update library lists

We'll disabling using the "results" of this checks, just comment out four lines:

} else { #warn "$thislib not found in $thispth\n" if $verbose; #next; } #warn "'-l$thislib' found at $fullname\n" if $verbose; #push @libs, $fullname unless $libs_seen{$fullname}++; $found++; $found_lib++; # Now update library lists

UPDATE: A nicer workaround of course is to check for environment variables. Let's say, if MM_DISABLE_LIBCHECKS is set to a nonzero value, override the broken checks:

} else { if(!defined($ENV{MM_DISABLE_LIBCHECKS}) || $ENV{MM_DIS +ABLE_LIBCHECKS} == 0) { warn "$thislib not found in $thispth\n" if $verbos +e; next; } } if(!defined($ENV{MM_DISABLE_LIBCHECKS}) || $ENV{MM_DISABLE +_LIBCHECKS} == 0) { warn "'-l$thislib' found at $fullname\n" if $verbose; push @libs, $fullname unless $libs_seen{$fullname}++; } $found++; $found_lib++; # Now update library lists

So, running Makefile.PL like this should do the trick:
MM_DISABLE_LIBCHECKS=1 perl Makefile.PL
Of course, this also should also work when calling any CPAN script (untested but plausible).
END-OF-UPDATE

This should do it. Since (most) Makefile.PL's use checks with "pkg-config" in addition to internal MakeMaker checks anyway, you should still see all missing dependencies from your operating system.

Installing the dependencies

You got a lot of dependencies for the module we are going to use, which is Gtk3::WebKit. Honestly, i didn't write those down - and i didn't do a clean install anyway, so i leave out the details. Mostly, you'll hunt for obscure "*-dev" packages in apt-get/synaptic. (If someone is kind enough to reply with a list of all the required packages, i'll gladly update this post).

The one, most obscure of the library packages is certainly libgirepository1.0-dev. That should pull in many of the required packages.

Writing the Browser

Without further delay, let's state some of the requirements for our project:

For the last two requirements, the only thing we have to do is not implementing those features. So, let's forget about them alltogether.

For the first two, we can just set the correct properties of the webkit element in our Gtk3 window. No big deal. For the third requirement, we set the Window title and we're done, too.

So, let's get right down to the code:

#!/usr/bin/env perl =head1 NAME gtk3_browser.pl - The PerlMonks Browser =head1 SYNOPSIS browser.pl [URL] Simple usage: browser.pl http://search.cpan.org/ =head1 DESCRIPTION Display a web page as "Native Application". =cut use strict; use warnings; use Gtk3 -init; use Gtk3::WebKit; sub main { my ($url) = shift @ARGV || 'http://www.perlmonks.org'; my $window = Gtk3::Window->new('toplevel'); $window->set_default_size(800, 600); $window->signal_connect(destroy => sub { Gtk3->main_quit() }); $window->set_title("PerlMonks Native Client"); # Create a WebKit widget my $view = Gtk3::WebKit::WebView->new(); my $settings = $view->get_settings(); $settings->set_property("user-agent", 'PerlMonks/1.0'); $settings->set_property("enable-default-context-menu", 0); # Load a page $view->load_uri($url); # Pack the widgets together my $scrolls = Gtk3::ScrolledWindow->new(); $scrolls->add($view); $window->add($scrolls); $window->show_all(); Gtk3->main(); return 0; } exit main() unless caller;

As you can see, no big deal, after you actually fought the battles against MakeMaker and your Distributions clearly confusing package managment.

All we do here is open a Gtk3 window, add a WebKit widget with some custom settings and pack it into the main window with some attached scrollbars. Then we call the Gtk3 mainloop and we got a nice, one-window one-tab browser that simulates a native application.

BREW /very/strong/coffee HTTP/1.1
Host: goodmorning.example.com

418 I'm a teapot

In reply to Turn a Website into a native application by cavac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.