using Gtk; using WebKit; public class BeneditoGloboApp : Gtk.Window { private WebKit.WebView webview; private Gtk.Entry url_entry; private Gtk.Button back_button; private Gtk.Button forward_button; private Gtk.Button reload_button; public BeneditoGloboApp() { this.title = "Benedito G lobo"; this.set_default_size(1200, 800); this.window_position = WindowPosition.CENTER; this.destroy.connect(Gtk.main_quit); // Create main vertical box var vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0); // Create toolbar var toolbar = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 5); toolbar.margin = 5; // Navigation buttons back_button = new Gtk.Button.from_icon_name("go-previous", Gtk.IconSize.BUTTON); back_button.clicked.connect(() => { webview.go_back(); }); forward_button = new Gtk.Button.from_icon_name("go-next", Gtk.IconSize.BUTTON); forward_button.clicked.connect(() => { webview.go_forward(); }); reload_button = new Gtk.Button.from_icon_name("view-refresh", Gtk.IconSize.BUTTON); reload_button.clicked.connect(() => { webview.reload(); }); // URL entry url_entry = new Gtk.Entry(); url_entry.set_text("https://beneditoglobo.com.br"); url_entry.activate.connect(() => { load_url(url_entry.get_text()); }); // Go button var go_button = new Gtk.Button.with_label("Ir"); go_button.clicked.connect(() => { load_url(url_entry.get_text()); }); // Add widgets to toolbar toolbar.pack_start(back_button, false, false, 0); toolbar.pack_start(forward_button, false, false, 0); toolbar.pack_start(reload_button, false, false, 0); toolbar.pack_start(url_entry, true, true, 0); toolbar.pack_start(go_button, false, false, 0); // Create WebView webview = new WebKit.WebView(); // Update URL entry when page loads webview.load_changed.connect((load_event) => { if (load_event == WebKit.LoadEvent.COMMITTED) { url_entry.set_text(webview.get_uri()); } // Update button sensitivity back_button.sensitive = webview.can_go_back(); forward_button.sensitive = webview.can_go_forward(); }); // Create scrolled window for webview var scrolled = new Gtk.ScrolledWindow(null, null); scrolled.add(webview); // Add widgets to main box vbox.pack_start(toolbar, false, false, 0); vbox.pack_start(scrolled, true, true, 0); this.add(vbox); // Load initial URL load_url("https://beneditoglobo.com.br"); } private void load_url(string url) { string final_url = url; // Add https:// if no protocol is specified if (!url.has_prefix("http://") && !url.has_prefix("https://")) { final_url = "https://" + url; } webview.load_uri(final_url); } public static int main(string[] args) { Gtk.init(ref args); var app = new BeneditoGloboApp(); app.show_all(); Gtk.main(); return 0; } }