[epiphany/mcatanzaro/web-view-signals: 2/2] web-view: avoid unnecessary g_signal_connect()
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/mcatanzaro/web-view-signals: 2/2] web-view: avoid unnecessary g_signal_connect()
- Date: Tue, 17 Dec 2019 23:09:13 +0000 (UTC)
commit 7c8f059ca67943de9b3b5187e2dba31af3601f85
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Tue Dec 17 17:06:37 2019 -0600
web-view: avoid unnecessary g_signal_connect()
We don't need to connect to our own signals.
embed/ephy-web-view.c | 153 ++++++++++++++++++--------------------------------
embed/ephy-web-view.h | 2 +-
src/ephy-session.c | 2 +-
3 files changed, 58 insertions(+), 99 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 977a45eaf..3cbefba36 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -1040,24 +1040,24 @@ uri_changed_cb (WebKitWebView *web_view,
}
static void
-mouse_target_changed_cb (EphyWebView *web_view,
- WebKitHitTestResult *hit_test_result,
- guint modifiers,
- gpointer data)
+ephy_web_view_mouse_target_changed (WebKitWebView *web_view,
+ WebKitHitTestResult *hit_test_result,
+ guint modifiers)
{
const char *message = NULL;
if (webkit_hit_test_result_context_is_link (hit_test_result))
message = webkit_hit_test_result_get_link_uri (hit_test_result);
- ephy_web_view_set_link_message (web_view, message);
+ ephy_web_view_set_link_message (EPHY_WEB_VIEW (web_view), message);
}
static void
-process_terminated_cb (EphyWebView *web_view,
- WebKitWebProcessTerminationReason reason,
- gpointer user_data)
+ephy_web_view_web_process_terminated (WebKitWebView *view,
+ WebKitWebProcessTerminationReason reason)
{
+ EphyWebView *web_view = EPHY_WEB_VIEW (view);
+
switch (reason) {
case WEBKIT_WEB_PROCESS_CRASHED:
g_warning (_("Web process crashed"));
@@ -1074,13 +1074,12 @@ process_terminated_cb (EphyWebView *web_view,
}
static void
-style_updated_cb (EphyWebView *web_view,
- gpointer user_data)
+ephy_web_view_style_updated (GtkWidget *web_view)
{
GtkStyleContext *context;
GdkRGBA color;
- context = gtk_widget_get_style_context (GTK_WIDGET (web_view));
+ context = gtk_widget_get_style_context (web_view);
if (!gtk_style_context_lookup_color (context, "theme_base_color", &color)) {
/* Fall back to white */
color.red = 1;
@@ -1108,10 +1107,9 @@ new_window_cb (EphyWebView *view,
}
static gboolean
-decide_policy_cb (WebKitWebView *web_view,
- WebKitPolicyDecision *decision,
- WebKitPolicyDecisionType decision_type,
- gpointer user_data)
+ephy_web_view_decide_policy (WebKitWebView *web_view,
+ WebKitPolicyDecision *decision,
+ WebKitPolicyDecisionType decision_type)
{
WebKitResponsePolicyDecision *response_decision;
WebKitURIResponse *response;
@@ -1344,8 +1342,8 @@ show_permission_request_info_bar (WebKitWebView *web_view,
}
static gboolean
-permission_request_cb (WebKitWebView *web_view,
- WebKitPermissionRequest *decision)
+ephy_web_view_permission_request (WebKitWebView *web_view,
+ WebKitPermissionRequest *decision)
{
const char *address;
char *origin;
@@ -1619,9 +1617,8 @@ update_ucm_ads_state (WebKitWebView *web_view,
}
static void
-load_changed_cb (WebKitWebView *web_view,
- WebKitLoadEvent load_event,
- gpointer user_data)
+ephy_web_view_load_changed (WebKitWebView *web_view,
+ WebKitLoadEvent load_event)
{
EphyWebView *view = EPHY_WEB_VIEW (web_view);
GObject *object = G_OBJECT (web_view);
@@ -2404,11 +2401,10 @@ ephy_web_view_load_error_page (EphyWebView *view,
}
static gboolean
-load_failed_cb (WebKitWebView *web_view,
- WebKitLoadEvent load_event,
- const char *uri,
- GError *error,
- gpointer user_data)
+ephy_web_view_load_failed (WebKitWebView *web_view,
+ WebKitLoadEvent load_event,
+ const char *uri,
+ GError *error)
{
EphyWebView *view = EPHY_WEB_VIEW (web_view);
@@ -2467,11 +2463,10 @@ load_failed_cb (WebKitWebView *web_view,
}
static gboolean
-load_failed_with_tls_error_cb (WebKitWebView *web_view,
- const char *uri,
- GTlsCertificate *certificate,
- GTlsCertificateFlags errors,
- gpointer user_data)
+ephy_web_view_load_failed_with_tls_errors (WebKitWebView *web_view,
+ const char *uri,
+ GTlsCertificate *certificate,
+ GTlsCertificateFlags errors)
{
EphyWebView *view = EPHY_WEB_VIEW (web_view);
@@ -2488,9 +2483,8 @@ load_failed_with_tls_error_cb (WebKitWebView *web_view,
}
static void
-mixed_content_detected_cb (WebKitWebView *web_view,
- WebKitInsecureContentEvent event,
- gpointer user_data)
+ephy_web_view_insecure_content_detected (WebKitWebView *web_view,
+ WebKitInsecureContentEvent event)
{
EphyWebView *view = EPHY_WEB_VIEW (web_view);
@@ -2499,8 +2493,7 @@ mixed_content_detected_cb (WebKitWebView *web_view,
}
static void
-close_web_view_cb (WebKitWebView *web_view,
- gpointer user_data)
+ephy_web_view_close (WebKitWebView *web_view)
{
GtkWidget *widget = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
@@ -2537,8 +2530,8 @@ zoom_changed_cb (WebKitWebView *web_view,
}
static gboolean
-script_dialog_cb (WebKitWebView *web_view,
- WebKitScriptDialog *dialog)
+ephy_web_view_script_dialog (WebKitWebView *web_view,
+ WebKitScriptDialog *dialog)
{
if (webkit_script_dialog_get_dialog_type (dialog) != WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM)
return FALSE;
@@ -2600,9 +2593,8 @@ reader_setting_changed_cb (GSettings *settings,
}
static gboolean
-authenticate_cb (WebKitWebView *web_view,
- WebKitAuthenticationRequest *request,
- gpointer user_data)
+ephy_web_view_authenticate (WebKitWebView *web_view,
+ WebKitAuthenticationRequest *request)
{
EphyWebView *ephy_web_view = EPHY_WEB_VIEW (web_view);
g_autoptr (WebKitCredential) credential = NULL;
@@ -2742,8 +2734,8 @@ password_manager_handle_query_password_message (WebKitWebView *web_view,
}
static gboolean
-user_message_received_cb (WebKitWebView *web_view,
- WebKitUserMessage *message)
+ephy_web_view_user_message_received (WebKitWebView *web_view,
+ WebKitUserMessage *message)
{
const char *name;
@@ -2889,7 +2881,7 @@ ephy_web_view_is_loading (EphyWebView *view)
}
/**
- * ephy_web_view_load_failed:
+ * ephy_web_view_get_load_failed:
* @view: an #EphyWebView
*
* Returns whether the web page in @view has failed to load.
@@ -2898,7 +2890,7 @@ ephy_web_view_is_loading (EphyWebView *view)
* or load finished successfully
**/
gboolean
-ephy_web_view_load_failed (EphyWebView *view)
+ephy_web_view_get_load_failed (EphyWebView *view)
{
return view->load_failed;
}
@@ -3763,14 +3755,10 @@ ephy_web_view_constructed (GObject *object)
g_signal_emit_by_name (ephy_embed_shell_get_default (), "web-view-created", web_view);
- g_signal_connect (web_view, "web-process-terminated",
- G_CALLBACK (process_terminated_cb), NULL);
- g_signal_connect_swapped (webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (web_view)),
- "changed", G_CALLBACK (update_navigation_flags), web_view);
+ g_signal_connect_object (webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (web_view)),
+ "changed", G_CALLBACK (update_navigation_flags), web_view, G_CONNECT_SWAPPED);
- g_signal_connect (web_view, "style-updated",
- G_CALLBACK (style_updated_cb), NULL);
- style_updated_cb (web_view, NULL);
+ ephy_web_view_style_updated (GTK_WIDGET (web_view));
}
static void
@@ -3798,33 +3786,6 @@ ephy_web_view_init (EphyWebView *web_view)
G_CALLBACK (reader_setting_changed_cb),
web_view, 0);
- g_signal_connect (web_view, "decide-policy",
- G_CALLBACK (decide_policy_cb),
- NULL);
-
- g_signal_connect (web_view, "permission-request",
- G_CALLBACK (permission_request_cb),
- NULL);
-
- g_signal_connect (web_view, "load-changed",
- G_CALLBACK (load_changed_cb),
- NULL);
-
- g_signal_connect (web_view, "close",
- G_CALLBACK (close_web_view_cb),
- NULL);
- g_signal_connect (web_view, "load-failed",
- G_CALLBACK (load_failed_cb),
- NULL);
-
- g_signal_connect (web_view, "load-failed-with-tls-errors",
- G_CALLBACK (load_failed_with_tls_error_cb),
- NULL);
-
- g_signal_connect (web_view, "insecure-content-detected",
- G_CALLBACK (mixed_content_detected_cb),
- NULL);
-
g_signal_connect (web_view, "notify::zoom-level",
G_CALLBACK (zoom_changed_cb),
NULL);
@@ -3837,30 +3798,15 @@ ephy_web_view_init (EphyWebView *web_view)
G_CALLBACK (uri_changed_cb),
NULL);
- g_signal_connect (web_view, "mouse-target-changed",
- G_CALLBACK (mouse_target_changed_cb),
- NULL);
-
g_signal_connect (web_view, "notify::favicon",
G_CALLBACK (icon_changed_cb),
NULL);
- g_signal_connect (web_view, "script-dialog",
- G_CALLBACK (script_dialog_cb),
- NULL);
-
+ /* FIXME: this signal does not exist, so this code is dead, see epiphany #124 */
g_signal_connect (web_view, "new-window",
G_CALLBACK (new_window_cb),
NULL);
- g_signal_connect (web_view, "authenticate",
- G_CALLBACK (authenticate_cb),
- NULL);
-
- g_signal_connect (web_view, "user-message-received",
- G_CALLBACK (user_message_received_cb),
- NULL);
-
g_signal_connect_object (shell, "password-form-focused",
G_CALLBACK (password_form_focused_cb),
web_view, 0);
@@ -3879,7 +3825,7 @@ ephy_web_view_class_init (EphyWebViewClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- WebKitWebViewClass *webkit_webview_class = WEBKIT_WEB_VIEW_CLASS (klass);
+ WebKitWebViewClass *webview_class = WEBKIT_WEB_VIEW_CLASS (klass);
gobject_class->dispose = ephy_web_view_dispose;
gobject_class->finalize = ephy_web_view_finalize;
@@ -3889,8 +3835,21 @@ ephy_web_view_class_init (EphyWebViewClass *klass)
widget_class->button_press_event = ephy_web_view_button_press_event;
widget_class->key_press_event = ephy_web_view_key_press_event;
-
- webkit_webview_class->run_file_chooser = ephy_web_view_run_file_chooser;
+ widget_class->style_updated = ephy_web_view_style_updated;
+
+ webview_class->authenticate = ephy_web_view_authenticate;
+ webview_class->close = ephy_web_view_close;
+ webview_class->decide_policy = ephy_web_view_decide_policy;
+ webview_class->insecure_content_detected = ephy_web_view_insecure_content_detected;
+ webview_class->load_changed = ephy_web_view_load_changed;
+ webview_class->load_failed = ephy_web_view_load_failed;
+ webview_class->load_failed_with_tls_errors = ephy_web_view_load_failed_with_tls_errors;
+ webview_class->mouse_target_changed = ephy_web_view_mouse_target_changed;
+ webview_class->permission_request = ephy_web_view_permission_request;
+ webview_class->run_file_chooser = ephy_web_view_run_file_chooser;
+ webview_class->script_dialog = ephy_web_view_script_dialog;
+ webview_class->user_message_received = ephy_web_view_user_message_received;
+ webview_class->web_process_terminated = ephy_web_view_web_process_terminated;
/**
* EphyWebView:address:
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index 3d66760be..ec7c10421 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -84,7 +84,7 @@ void ephy_web_view_load_request (EphyWebView
void ephy_web_view_load_url (EphyWebView *view,
const char *url);
gboolean ephy_web_view_is_loading (EphyWebView *view);
-gboolean ephy_web_view_load_failed (EphyWebView *view);
+gboolean ephy_web_view_get_load_failed (EphyWebView *view);
GdkPixbuf * ephy_web_view_get_icon (EphyWebView *view);
EphyWebViewDocumentType ephy_web_view_get_document_type (EphyWebView *view);
EphyWebViewNavigationFlags ephy_web_view_get_navigation_flags (EphyWebView *view);
diff --git a/src/ephy-session.c b/src/ephy-session.c
index bcf17b297..d677e1cc8 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -123,7 +123,7 @@ load_changed_cb (WebKitWebView *view,
WebKitLoadEvent load_event,
EphySession *session)
{
- if (ephy_web_view_load_failed (EPHY_WEB_VIEW (view)))
+ if (ephy_web_view_get_load_failed (EPHY_WEB_VIEW (view)))
return;
if (load_event == WEBKIT_LOAD_FINISHED)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]