From 405bdb8e341657bdce7040b90fdca805e5540280 Mon Sep 17 00:00:00 2001 From: Artem Anufrij Date: Tue, 1 Aug 2017 00:24:50 +0200 Subject: [PATCH] some fixes --- src/Application.vala | 2 +- src/DesktopFile.vala | 1 + src/MainWindow.vala | 4 ++-- src/WebApp.vala | 20 +++++++++----------- src/WebAppWindow.vala | 8 ++++---- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 9b402c8..ce030a6 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -54,7 +54,7 @@ namespace Webpin { return; } - mainwindow = new MainWindow (); + mainwindow = new MainWindow (); mainwindow.set_application(this); } } diff --git a/src/DesktopFile.vala b/src/DesktopFile.vala index 36da0c4..c44be02 100644 --- a/src/DesktopFile.vala +++ b/src/DesktopFile.vala @@ -41,6 +41,7 @@ namespace Webpin { Type=Application Categories=Network; X-GNOME-FullName=webpin + StartupWMClass=Webpin WebpinThemeColor=none"""; private GLib.KeyFile file; diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 5d6c4eb..038d69b 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -62,8 +62,8 @@ namespace Webpin { add_button.tooltip_text = _("Add a new Web App"); headerbar.pack_start (add_button); - var welcome = new Granite.Widgets.Welcome (_("No Web Apps Availible"), _("Create a new Webby Web App.")); - welcome.append ("document-new", _("Create App"), _("Create a new Webby web app.")); + var welcome = new Granite.Widgets.Welcome (_("No Web Apps Availible"), _("Create a new Webpin Web App.")); + welcome.append ("document-new", _("Create App"), _("Create a new Webpin web app.")); welcome.activated.connect ((index) => { switch (index) { case 0: diff --git a/src/WebApp.vala b/src/WebApp.vala index 9618525..1ac04eb 100644 --- a/src/WebApp.vala +++ b/src/WebApp.vala @@ -108,7 +108,7 @@ namespace Webpin { //load theme color saved in desktop file if (info != null && info.has_key("WebpinThemeColor")) { var color = info.get_string("WebpinThemeColor"); - print("COLOR: " + color+"\n"); + debug("COLOR: " + color+"\n"); if(color != "none") { ui_color = color; } @@ -124,7 +124,7 @@ namespace Webpin { //update theme color if changed app_view.load_changed.connect ( (load_event) => { if (load_event == WebKit.LoadEvent.FINISHED) { - print("determine color"); + debug ("determine color"); determine_theme_color.begin(); } else { container.set_visible(true); @@ -149,24 +149,22 @@ namespace Webpin { });*/ - uint8[] data = {0, 0, 0}; - int snap_width = 0; - try { - var snap = (Cairo.ImageSurface) yield app_view.get_snapshot (WebKit.SnapshotRegion.VISIBLE, WebKit.SnapshotOptions.NONE, null); + Cairo.ImageSurface snap = null; - // data ist in BGRA apparently (according to testing). Docs said ARGB, but that - // appears not to be the case - data = snap.get_data (); - snap_width = snap.get_width (); + try { + snap = (Cairo.ImageSurface) yield app_view.get_snapshot (WebKit.SnapshotRegion.VISIBLE, WebKit.SnapshotOptions.NONE, null); } catch (Error e) { warning (e.message); } + // data ist in BGRA apparently (according to testing). Docs said ARGB, but that + // appears not to be the case + unowned uint8[] data = snap.get_data (); uint8 r = data[2]; uint8 g = data[1]; uint8 b = data[0]; - for (var i = 4; i < snap_width * 3 * 4; i += 4) { + for (var i = 4; i < snap.get_width () * 3 * 4; i += 4) { r = (r + data[i + 2]) / 2; g = (g + data[i + 1]) / 2; b = (b + data[i + 0]) / 2; diff --git a/src/WebAppWindow.vala b/src/WebAppWindow.vala index 3057bab..322b54a 100644 --- a/src/WebAppWindow.vala +++ b/src/WebAppWindow.vala @@ -50,7 +50,7 @@ namespace Webpin { //style if (web_app.ui_color != "none") { try { - print("set color"); + debug ("set color"); var style_cp = style_str.replace ("@titlebar_color", web_app.ui_color); var style_provider = new Gtk.CssProvider (); style_provider.load_from_data (style_cp, -1); @@ -63,7 +63,7 @@ namespace Webpin { web_app.theme_color_changed.connect( (color)=> { try { - print("set color"); + debug ("set color"); var style_cp = style_str.replace ("@titlebar_color", color); var style_provider = new Gtk.CssProvider (); style_provider.load_from_data (style_cp, -1); @@ -92,14 +92,14 @@ namespace Webpin { this.destroy.connect(Gtk.main_quit); web_app.external_request.connect ( () => { - print("Web app external request\n"); + debug ("Web app external request\n"); web_app.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT); headerbar.set_title_mode (WebBar.title_mode.BROWSER); web_app.set_visible_child_name ("external"); }); headerbar.back_event.connect ( () => { - print ("back"); + debug ("back"); headerbar.set_title_mode (WebBar.title_mode.TITLE); web_app.set_transition_type (Gtk.StackTransitionType.SLIDE_RIGHT); web_app.set_visible_child_name ("app");