From 57c2867ef748fcc32fc7773223b651b0fc8fd345 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 11 Oct 2017 22:12:36 -0400 Subject: MqWebView: Use g_signal_connect() --- (limited to 'src/web-view.c') diff --git a/src/web-view.c b/src/web-view.c index f9ead49..4e686cc 100644 --- a/src/web-view.c +++ b/src/web-view.c @@ -345,8 +345,8 @@ context_menu_document_cb(WebKitContextMenu *context_menu, GList *nav_items, } while (0) static gboolean -context_menu(WebKitWebView *wk_web_view, WebKitContextMenu *context_menu, - GdkEvent *event, WebKitHitTestResult *hit_test_result) +context_menu_cb(WebKitWebView *wk_web_view, WebKitContextMenu *context_menu, + GdkEvent G_GNUC_UNUSED *event, WebKitHitTestResult *hit_test_result) { MqWebView *web_view; GList *items; @@ -499,8 +499,7 @@ context_menu(WebKitWebView *wk_web_view, WebKitContextMenu *context_menu, } /* Propagate the event further and show the context menu. */ - return PARENT_CLASS->context_menu(WEBKIT_WEB_VIEW(web_view), - context_menu, event, hit_test_result); + return FALSE; } static void @@ -515,7 +514,7 @@ clipboard_text_recv_cb(GtkClipboard G_GNUC_UNUSED *clipboard, * API provided webkit_web_view_get_hit_test_result() which would have been * easier. */ static void -mouse_target_changed(WebKitWebView *wk_web_view, +mouse_target_changed_cb(WebKitWebView *wk_web_view, WebKitHitTestResult *hit_test_result, guint G_GNUC_UNUSED modifiers) { MqWebView *web_view; @@ -527,7 +526,7 @@ mouse_target_changed(WebKitWebView *wk_web_view, } static gboolean -button_press_event(GtkWidget *widget, GdkEventButton *event) +button_press_cb(GtkWidget *widget, GdkEventButton *event) { MqWebView *web_view; WebKitHitTestResult *hit_test_result; @@ -537,8 +536,7 @@ button_press_event(GtkWidget *widget, GdkEventButton *event) /* Make sure this is a middle mouse button press event. */ if (event->button != 2) { - return GTK_WIDGET_CLASS(mq_web_view_parent_class)-> - button_press_event(widget, event); + return FALSE; } hit_test_result = web_view->mouse_target_hit_test_result; @@ -551,8 +549,7 @@ button_press_event(GtkWidget *widget, GdkEventButton *event) /* Let WebKit handle pasting from the primary clipboard into an * editable element. */ g_object_unref(hit_test_result); - return GTK_WIDGET_CLASS(mq_web_view_parent_class)-> - button_press_event(widget, event); + return FALSE; } else { clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); gtk_clipboard_request_text(clipboard, @@ -622,15 +619,11 @@ constructed(GObject *object) static void mq_web_view_class_init(MqWebViewClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS(klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); - object_class->constructed = constructed; - object_class->get_property = get_property; - object_class->set_property = set_property; - widget_class->button_press_event = button_press_event; - PARENT_CLASS->context_menu = context_menu; - PARENT_CLASS->mouse_target_changed = mouse_target_changed; + object_class->constructed = constructed; + object_class->get_property = get_property; + object_class->set_property = set_property; obj_properties[PROP_TAB] = g_param_spec_pointer( "tab", "MqTab", "Parent MqTab instance", @@ -649,6 +642,13 @@ static void mq_web_view_init(MqWebView *web_view) { web_view->hit_test_result = NULL; + + g_signal_connect(web_view, "context-menu", + G_CALLBACK(context_menu_cb), NULL); + g_signal_connect(web_view, "mouse-target-changed", + G_CALLBACK(mouse_target_changed_cb), NULL); + g_signal_connect(web_view, "button-press-event", + G_CALLBACK(button_press_cb), NULL); } MqWebView * -- cgit v0.9.1