[epiphany/carlosgc/webkit-notifications: 5/5] shell: use WebKit implementation for notifications
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/carlosgc/webkit-notifications: 5/5] shell: use WebKit implementation for notifications
- Date: Mon, 29 Aug 2022 13:41:03 +0000 (UTC)
commit cd3400e99aa664381327dcc693fa4565a1661376
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Fri Aug 12 11:58:13 2022 +0200
shell: use WebKit implementation for notifications
Current implementation in WebKit supports service workers and
notification icon.
Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1187>
meson.build | 2 +-
src/ephy-shell.c | 52 +---------------------------------------------------
2 files changed, 2 insertions(+), 52 deletions(-)
---
diff --git a/meson.build b/meson.build
index 0b13e036d..0e206f60f 100644
--- a/meson.build
+++ b/meson.build
@@ -76,7 +76,7 @@ conf.set10('ENABLE_GSB', gsb_api_key != '')
glib_requirement = '>= 2.67.4'
gtk_requirement = '>= 3.24.0'
nettle_requirement = '>= 3.4'
-webkitgtk_requirement = '>= 2.37.1'
+webkitgtk_requirement = '>= 2.37.90'
conf.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_68')
conf.set('GLIB_VERSION_MAX_ALLOWED', 'GLIB_VERSION_2_68')
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index f1afda736..4d76c252e 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -70,7 +70,6 @@ struct _EphyShell {
EphyShellStartupContext *remote_startup_context;
GSList *open_uris_idle_ids;
- GHashTable *notifications;
gchar *open_notification_id;
gboolean startup_finished;
};
@@ -338,20 +337,6 @@ launch_app (GSimpleAction *action,
ephy_web_application_launch (webapp_id);
}
-static void
-notification_clicked (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- EphyShell *shell = ephy_shell_get_default ();
- guint64 id = g_variant_get_uint64 (parameter);
- WebKitNotification *notification;
-
- notification = g_hash_table_lookup (shell->notifications, GINT_TO_POINTER (id));
- if (notification)
- webkit_notification_clicked (notification);
-}
-
static void
webextension_action (GSimpleAction *action,
GVariant *parameter,
@@ -385,7 +370,6 @@ static GActionEntry app_entries[] = {
{ "quit", quit_application, NULL, NULL, NULL },
{ "show-downloads", show_downloads, NULL, NULL, NULL },
{ "launch-app", launch_app, "s", NULL, NULL },
- { "notification-clicked", notification_clicked, "t", NULL, NULL },
{ "webextension-notification", webextension_action, "(ssi)", NULL, NULL },
{ "webextension-context-menu", webextension_context_menu_action, "(sss)", NULL, NULL },
};
@@ -400,7 +384,6 @@ static GActionEntry app_mode_app_entries[] = {
{ "about", show_about, NULL, NULL, NULL },
{ "quit", quit_application, NULL, NULL, NULL },
{ "run-in-background", NULL, NULL, "false", NULL},
- { "notification-clicked", notification_clicked, "t", NULL, NULL},
};
static void
@@ -872,8 +855,6 @@ ephy_shell_init (EphyShell *shell)
ephy_shell->startup_finished = FALSE;
g_object_add_weak_pointer (G_OBJECT (ephy_shell),
(gpointer *)ptr);
-
- ephy_shell->notifications = g_hash_table_new (g_direct_hash, g_direct_equal);
}
static void
@@ -900,8 +881,6 @@ ephy_shell_dispose (GObject *object)
g_clear_object (&shell->open_tabs_manager);
g_clear_object (&shell->web_extension_manager);
- g_hash_table_destroy (shell->notifications);
-
if (shell->open_notification_id) {
g_application_withdraw_notification (G_APPLICATION (shell), shell->open_notification_id);
g_clear_pointer (&shell->open_notification_id, g_free);
@@ -977,43 +956,14 @@ webkit_notification_clicked_cb (WebKitNotification *notification,
}
}
-static void
-webkit_notification_closed_cb (WebKitNotification *notification,
- gpointer user_data)
-{
- EphyShell *shell = ephy_shell_get_default ();
- g_autofree char *id = NULL;
-
- id = g_strdup_printf ("%" G_GUINT64_FORMAT, webkit_notification_get_id (notification));
-
- g_application_withdraw_notification (G_APPLICATION (g_application_get_default ()), id);
- g_hash_table_remove (shell->notifications, GINT_TO_POINTER (webkit_notification_get_id (notification)));
-}
-
static gboolean
show_notification_cb (WebKitWebView *web_view,
WebKitNotification *notification,
gpointer user_data)
{
- EphyShell *shell = ephy_shell_get_default ();
- GNotification *notify;
- g_autofree char *id = NULL;
-
- id = g_strdup_printf ("%" G_GUINT64_FORMAT, webkit_notification_get_id (notification));
-
g_signal_connect_object (notification, "clicked", G_CALLBACK (webkit_notification_clicked_cb), web_view,
0);
- g_signal_connect_object (notification, "closed", G_CALLBACK (webkit_notification_closed_cb), web_view, 0);
- notify = g_notification_new (webkit_notification_get_title (notification));
- g_notification_set_body (notify, webkit_notification_get_body (notification));
-
- g_notification_set_default_action_and_target (notify, "app.notification-clicked", "t",
webkit_notification_get_id (notification));
-
- g_hash_table_insert (shell->notifications, GINT_TO_POINTER (webkit_notification_get_id (notification)),
notification);
-
- g_application_send_notification (G_APPLICATION (g_application_get_default ()), id, notify);
-
- return TRUE;
+ return FALSE;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]