diff --git a/src/Widgets/Browser.vala b/src/Widgets/Browser.vala index 86e27a2..4108424 100644 --- a/src/Widgets/Browser.vala +++ b/src/Widgets/Browser.vala @@ -191,5 +191,13 @@ namespace Webpin.Widgets { public bool can_go_forward () { return web_view.can_go_forward (); } + + public void reload () { + web_view.reload (); + } + + public void reload_bypass_cache () { + web_view.reload_bypass_cache (); + } } } diff --git a/src/Windows/WebApp.vala b/src/Windows/WebApp.vala index 9f9d34f..1844556 100644 --- a/src/Windows/WebApp.vala +++ b/src/Windows/WebApp.vala @@ -54,10 +54,9 @@ namespace Webpin.Windows { var copy_url = new Gtk.Button.from_icon_name ("insert-link-symbolic", Gtk.IconSize.MENU); copy_url.valign = Gtk.Align.CENTER; copy_url.tooltip_text = _ ("Copy URL into clipboard"); - copy_url.clicked.connect ( - () => { - Gtk.Clipboard.get_default (Gdk.Display.get_default ()).set_text (browser.web_view.uri, -1); - }); + copy_url.clicked.connect (() => { + Gtk.Clipboard.get_default (Gdk.Display.get_default ()).set_text (browser.web_view.uri, -1); + }); headerbar.pack_end (copy_url); var stay_open = new Gtk.ToggleButton (); @@ -65,18 +64,26 @@ namespace Webpin.Windows { stay_open.active = desktop_file.hide_on_close; stay_open.tooltip_text = _ ("Run in background if closed"); stay_open.image = new Gtk.Image.from_icon_name ("view-pin-symbolic", Gtk.IconSize.MENU); - stay_open.toggled.connect ( - () => { - desktop_file.edit_property ("X-Webpin-StayOpen", stay_open.active.to_string ()); - desktop_file.save_to_file (); - }); + stay_open.toggled.connect (() => { + desktop_file.edit_property ("X-Webpin-StayOpen", stay_open.active.to_string ()); + desktop_file.save_to_file (); + }); headerbar.pack_end (stay_open); + var button_refresh = new Gtk.Button.from_icon_name ("view-refresh-symbolic", Gtk.IconSize.MENU); + button_refresh.tooltip_text = _("Reload"); + button_refresh.valign = Gtk.Align.CENTER; + button_refresh.clicked.connect (() => { + browser.reload (); + }); + headerbar.pack_end (button_refresh); + spinner = new Gtk.Spinner (); spinner.set_size_request (16, 16); headerbar.pack_end (spinner); var button_back = new Gtk.Button.from_icon_name ("go-previous-symbolic", Gtk.IconSize.MENU); + button_back.tooltip_text = _("Back"); button_back.sensitive = false; button_back.valign = Gtk.Align.CENTER; button_back.clicked.connect (() => { @@ -85,6 +92,7 @@ namespace Webpin.Windows { headerbar.pack_start (button_back); var button_home = new Gtk.Button.from_icon_name ("go-home-symbolic", Gtk.IconSize.MENU); + button_home.tooltip_text = _("Home"); button_home.valign = Gtk.Align.CENTER; button_home.clicked.connect (() => { browser.go_home (); @@ -92,70 +100,62 @@ namespace Webpin.Windows { headerbar.pack_start (button_home); var button_forward = new Gtk.Button.from_icon_name ("go-next-symbolic", Gtk.IconSize.MENU); + button_forward.tooltip_text = _("Forward"); button_forward.sensitive = false; button_forward.valign = Gtk.Align.CENTER; button_forward.clicked.connect (() => { browser.go_forward (); }); headerbar.pack_start (button_forward); - this.set_titlebar (headerbar); - this.delete_event.connect ( - () => { - save_settings (); - if (desktop_file.hide_on_close) { - this.hide_on_delete (); - } - return desktop_file.hide_on_close; - }); + this.delete_event.connect (() => { + save_settings (); + if (desktop_file.hide_on_close) { + this.hide_on_delete (); + } + return desktop_file.hide_on_close; + }); - this.window_state_event.connect ( - (event) => { - current_state = event.new_window_state; - return false; - }); + this.window_state_event.connect ((event) => { + current_state = event.new_window_state; + return false; + }); - browser.external_request.connect ( - (action) => { - debug ("Web app external request: %s", action.get_request ().uri); - try { - Process.spawn_command_line_async ("xdg-open " + action.get_request ().uri); - } catch (Error e) { - warning (e.message); - } - }); + browser.external_request.connect ((action) => { + try { + Process.spawn_command_line_async ("xdg-open " + action.get_request ().uri); + } catch (Error e) { + warning (e.message); + } + }); - browser.desktop_notification.connect ( - (title, body, icon) => { - var desktop_notification = new Notification (title); - desktop_notification.set_body (body); - desktop_notification.set_icon (icon); - desktop_notification.add_button_with_target_value (_ ("Open %s").printf (desktop_file.name), "app.open-web-app", new GLib.Variant.string (desktop_file.url)); - WebpinApp.instance.send_notification (null, desktop_notification); - }); + browser.desktop_notification.connect ((title, body, icon) => { + var desktop_notification = new Notification (title); + desktop_notification.set_body (body); + desktop_notification.set_icon (icon); + desktop_notification.add_button_with_target_value (_ ("Open %s").printf (desktop_file.name), "app.open-web-app", new GLib.Variant.string (desktop_file.url)); + WebpinApp.instance.send_notification (null, desktop_notification); + }); - browser.request_begin.connect ( - () => { - spinner.active = true; - }); + browser.request_begin.connect (() => { + spinner.active = true; + }); - browser.request_finished.connect ( - () => { - spinner.active = false; - button_back.sensitive = browser.can_go_back (); - button_forward.sensitive = browser.can_go_forward (); - }); + browser.request_finished.connect (() => { + spinner.active = false; + button_back.sensitive = browser.can_go_back (); + button_forward.sensitive = browser.can_go_forward (); + }); - browser.found_website_color.connect ( - (color) => { - stdout.printf ("%s\n", color.to_string ()); - int gray_val = (int)(desktop_file.color.red * 255); - if (desktop_file.color == null || ((gray_val == 222 || gray_val == 255) && desktop_file.color.red == desktop_file.color.green && desktop_file.color.red == desktop_file.color.blue)) { - set_color (color); - desktop_file.color = color; - } - }); + browser.found_website_color.connect ((color) => { + stdout.printf ("%s\n", color.to_string ()); + int gray_val = (int)(desktop_file.color.red * 255); + if (desktop_file.color == null || ((gray_val == 222 || gray_val == 255) && desktop_file.color.red == desktop_file.color.green && desktop_file.color.red == desktop_file.color.blue)) { + set_color (color); + desktop_file.color = color; + } + }); this.add (browser); @@ -163,14 +163,13 @@ namespace Webpin.Windows { this.show_all (); - this.show.connect ( - () => { - var x = desktop_file.get_property ("X-Webpin-WindowX"); - var y = desktop_file.get_property ("X-Webpin-WindowY"); - if (x != null && y != null) { - this.move (int.parse (x), int.parse (y)); - } - }); + this.show.connect (() => { + var x = desktop_file.get_property ("X-Webpin-WindowX"); + var y = desktop_file.get_property ("X-Webpin-WindowY"); + if (x != null && y != null) { + this.move (int.parse (x), int.parse (y)); + } + }); } private void set_color (Gdk.RGBA color) { @@ -271,9 +270,9 @@ namespace Webpin.Windows { break; case Gdk.Key.F5 : if (Gdk.ModifierType.CONTROL_MASK in event.state) { - browser.web_view.reload (); + browser.reload (); } else { - browser.web_view.reload_bypass_cache (); + browser.reload_bypass_cache (); } return true; case Gdk.Key.Left :