show spinner in the headerbar when page is loading

This commit is contained in:
Artem Anufrij 2017-08-11 18:58:46 +02:00
parent 2ac4804bf7
commit 5eb6de86b1
2 changed files with 25 additions and 2 deletions

View file

@ -36,6 +36,8 @@ namespace Webpin {
//widgets
private WebApp web_app;
Gtk.Spinner spinner;
public WebWindow (string webapp_name, string webapp_uri) {
set_wmclass(webapp_uri, webapp_uri);
@ -44,6 +46,11 @@ namespace Webpin {
var headerbar = new Gtk.HeaderBar ();
headerbar.title = webapp_name;
headerbar.show_close_button = true;
spinner = new Gtk.Spinner ();
spinner.set_size_request (16, 16);
headerbar.pack_end (spinner);
//style
if (web_app.ui_color != "none") {
try {
@ -97,6 +104,14 @@ namespace Webpin {
}
});
web_app.request_begin.connect (() => {
spinner.active = true;
});
web_app.request_finished.connect (() => {
spinner.active = false;
});
add(web_app);
show_all();
}

View file

@ -40,6 +40,9 @@ namespace Webpin {
public signal void external_request (WebKit.NavigationAction action);
public signal void theme_color_changed(string color);
public signal void request_begin ();
public signal void request_finished ();
public WebApp (string webapp_name, string app_url) {
@ -73,7 +76,7 @@ namespace Webpin {
spinner.active = true;
spinner.halign = Gtk.Align.CENTER;
spinner.valign = Gtk.Align.CENTER;
spinner.set_size_request (24, 24);
spinner.set_size_request (32, 32);
container = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
container.halign = Gtk.Align.FILL;
container.valign = Gtk.Align.FILL;
@ -118,6 +121,7 @@ namespace Webpin {
//update theme color if changed
app_view.load_changed.connect ( (load_event) => {
request_begin ();
if (load_event == WebKit.LoadEvent.FINISHED) {
debug ("determine color");
determine_theme_color.begin();
@ -174,7 +178,11 @@ namespace Webpin {
if (file != null)
file.edit_propertie ("WebpinThemeColor", ui_color);
}
container.set_visible(false);
if(container.visible) {
container.visible = false;
}
request_finished ();
}
}
}