Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: support webkit2gtk-4.1 #794

Merged
merged 6 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ basic_command = [
'--package-version', meson.project_version(),
'--driver', meson.get_compiler('vala').version(),
'--pkg', 'folks',
'--pkg', 'webkit2gtk-4.0',
'--pkg', 'libedataserverui-1.2',
'--pkg', 'libedataserver-1.2',
'--pkg', 'libhandy-1',
Expand All @@ -22,6 +21,17 @@ basic_command = [
'--use-svg-images'
]

if libedataserverui_dep.version().version_compare('>=3.45.1')
basic_command += [
'--pkg', 'webkit2gtk-4.1',
'--define=HAS_SOUP_3'
]
else
basic_command += [
'--pkg', 'webkit2gtk-4.0',
]
endif

all_doc_target = custom_target(
'full documentation',
command: [
Expand Down
10 changes: 8 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ handy_dep = dependency('libhandy-1', version: '>=1.1.90')
camel_dep = dependency('camel-1.2', version: '>= 3.28')
libedataserver_dep = dependency('libedataserver-1.2', version: '>= 3.28')
libedataserverui_dep = dependency('libedataserverui-1.2', version: '>= 3.28')
webkit2_dep = dependency('webkit2gtk-4.0', version: '>=2.28')
webkit2_web_extension_dep = dependency('webkit2gtk-web-extension-4.0', version: '>=2.28')
if libedataserverui_dep.version().version_compare('>=3.45.1')
add_project_arguments('--define=HAS_SOUP_3', language: 'vala')
webkit2_dep = dependency('webkit2gtk-4.1')
webkit2_web_extension_dep = dependency('webkit2gtk-web-extension-4.1')
else
webkit2_dep = dependency('webkit2gtk-4.0', version: '>=2.28')
webkit2_web_extension_dep = dependency('webkit2gtk-web-extension-4.0', version: '>=2.28')
endif
folks_dep = dependency('folks')
m_dep = meson.get_compiler('c').find_library('m')

Expand Down
27 changes: 27 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,32 @@ public class Mail.Application : Gtk.Application {
string to = null;

try {
#if HAS_SOUP_3
GLib.Uri? mailto= null;
try {
mailto = GLib.Uri.parse (mailto_uri, GLib.UriFlags.NONE);
} catch (Error e) {
throw new OptionError.BAD_VALUE ("Argument is not a URL.");
}

if (mailto == null) {
throw new OptionError.BAD_VALUE ("Argument is not a URL.");
}

if (mailto.get_scheme () != "mailto") {
throw new OptionError.BAD_VALUE ("Cannot open non-mailto: URL");
}

to = GLib.Uri.unescape_string (mailto.get_path ());

if (main_window.is_session_started) {
new ComposerWindow (main_window, to, mailto.get_query ()).show_all ();
} else {
main_window.session_started.connect (() => {
new ComposerWindow (main_window, to, mailto.get_query ()).show_all ();
});
}
#else
Soup.URI mailto = new Soup.URI (mailto_uri);
if (mailto == null) {
throw new OptionError.BAD_VALUE ("Argument is not a URL.");
Expand All @@ -87,6 +113,7 @@ public class Mail.Application : Gtk.Application {
new ComposerWindow (main_window, to, mailto.query).show_all ();
});
}
#endif
} catch (OptionError e) {
warning ("Argument parsing error. %s", e.message);
}
Expand Down
8 changes: 8 additions & 0 deletions src/Composer/ComposerWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,11 @@ public class Mail.ComposerWidget : Gtk.Grid {
foreach (unowned string param in params) {
var terms = param.split ("=");
if (terms.length == 2) {
#if HAS_SOUP_3
result[terms[0].down ()] = (GLib.Uri.unescape_string (terms[1]));
#else
result[terms[0].down ()] = (Soup.URI.decode (terms[1]));
#endif
} else {
critical ("Invalid mailto URL");
}
Expand Down Expand Up @@ -486,7 +490,11 @@ public class Mail.ComposerWidget : Gtk.Grid {
private void on_mouse_target_changed (WebKit.WebView web_view, WebKit.HitTestResult hit_test, uint mods) {
if (hit_test.context_is_link ()) {
var url = hit_test.get_link_uri ();
#if HAS_SOUP_3
var hover_url = url != null ? GLib.Uri.unescape_string (url) : null;
#else
var hover_url = url != null ? Soup.URI.decode (url) : null;
#endif

if (hover_url == null) {
message_url_overlay.hide ();
Expand Down
4 changes: 4 additions & 0 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ public class Mail.MainWindow : Hdy.ApplicationWindow {
message_overlay.no_show_all = true;

message_list_box.hovering_over_link.connect ((label, url) => {
#if HAS_SOUP_3
var hover_url = url != null ? GLib.Uri.unescape_string (url) : null;
#else
var hover_url = url != null ? Soup.URI.decode (url) : null;
#endif

if (hover_url == null) {
message_overlay.hide ();
Expand Down
4 changes: 4 additions & 0 deletions src/WebView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ public class Mail.WebView : WebKit.WebView {
}

private bool handle_internal_response (WebKit.URISchemeRequest request) {
#if HAS_SOUP_3
string name = GLib.Uri.unescape_string (request.get_path ());
#else
string name = Soup.URI.decode (request.get_path ());
#endif
InputStream? buf = this.internal_resources[name];
if (buf != null) {
request.finish (buf, -1, null);
Expand Down
Loading