urlbox, a featureless webapp viewer

Discussion in 'all things UNIX' started by Gullible Jones, Apr 7, 2015.

  1. Gullible Jones

    Gullible Jones Registered Member

    Joined:
    May 16, 2013
    Posts:
    1,461
    17 lines of Vala, 16 KB binary when compiled, public domain. It's more or less the Webkit sample browser here:

    https://wiki.gnome.org/Projects/Vala/WebKitSample

    with all the bells and whistles torn out of it. Brought to you courtesy of stupid bloated browsers not loading GMail fast enough for my liking.


    Code:
    using Gtk;
    using WebKit;
    
    public static int main(string[] args) {
      Gtk.init(ref args);
      var window = new Window();
      window.set_default_size(800, 600);
      window.delete_event.connect(() => { Gtk.main_quit(); return false; });
      var scrollbox = new ScrolledWindow(null, null);
      var view = new WebView();
      scrollbox.add(view);
      window.add(scrollbox);
      window.show_all();
      view.open(args[1]);
      Gtk.main();
      return 0;
    }
    

    You can save it to urlbox.vala, and (after installing Vala) compile it with

    Code:
    valac urlbox.vala --pkg=gtk+-2.0 --pkg=webkit-1.0 --thread


    The compiled binary can then be invoked as

    Code:
    urlbox https://www.gmail.com
    or such.

    NB: I make no guarantees whatsoever as to this program's security in the face of malicious input. For starters, I suspect it doesn't handle unrecognized SSL certificates properly, so please use it only with URLs you know to be trustworthy, and only if you can reasonably trust your DNS cache. Thanks!

    [Edit: omitting --thread during compile doesn't do what I thought. Corrected.]
     
    Last edited: Apr 7, 2015