简体   繁体   中英

How can I get html code from the web with vala(gtk)?

How can I get a html code from some site(eg www.google.com) using vala(gtk)? I am using Val(a)IDE for programming.

Here is my code if someone need it:

public class Main
{
  public static int main (string[] args)
  {
    Gtk.init (ref args);

    Gtk.Window window = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
    window.title = "First test app";
    window.set_default_size (320, 420);
    window.position = Gtk.WindowPosition.CENTER;
    window.destroy.connect(Gtk.main_quit);
    var buttonBack = new Gtk.Button.with_label ("<");
    var buttonForward = new Gtk.Button.with_label (">");
    var buttonRefresh = new Gtk.Button.with_label ("Refresh");
    var buttonStop = new Gtk.Button.with_label ("Stop");
    buttonBack.set_size_request (20, 40);
    buttonForward.set_size_request (20, 40);
    buttonRefresh.set_size_request (20, 40);
    buttonStop.set_size_request (20, 40); 
    //window.add (buttonBack);
    var label1 = new Gtk.Label ("There will be something! :)");
    label1.set_size_request (320,380);
    //window.add (label1);
    var hbox1 = new Gtk.HBox (true, 0);
    var vbox1 = new Gtk.VBox (false, 0);
    //var html = new Gtk.Widget();
    //var empty = new Gtk.Label ("");
    //empty.set_size_request(300, 10);
    hbox1.add (buttonBack);
    hbox1.add (buttonForward);
    hbox1.add (buttonRefresh);
    hbox1.add (buttonStop);
    //hbox1.add (empty);
    vbox1.add (hbox1);
    vbox1.add (label1);
    window.add (vbox1);

    window.show_all ();
    Gtk.main ();
    return 0;
  }
}

Forget it, someone just give me an answer on ask ubuntu site.

The answer is:

Use the Vala GIO File open shown here http://live.gnome.org/Vala/GIOSamples

 var web_page = File.new_for_uri ("http://live.gnome.org/Vala"); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM