From fb73ff80eddbe52b240d1e8cd023199a5d2059f3 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 12 Apr 2015 13:52:56 +0100 Subject: [PATCH] Fixup gtk3 ssl certificate dialog and ensure its parent is set. --- gtk/gui.c | 97 +++++++------- gtk/res/ssl.gtk3.ui | 319 +++++++++++++++++++++----------------------- 2 files changed, 198 insertions(+), 218 deletions(-) diff --git a/gtk/gui.c b/gtk/gui.c index c3fe6bb78..27d40385a 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -82,11 +82,6 @@ struct glade_file_location_s *glade_file_location; static GtkWindow *nsgtk_warning_window; GtkWidget *widWarning; -static void nsgtk_ssl_accept(GtkButton *w, gpointer data); -static void nsgtk_ssl_reject(GtkWidget *w, gpointer data); -static gboolean nsgtk_ssl_delete_event(GtkWidget *w, GdkEvent *event, - gpointer data); - #define THROBBER_FRAMES 9 char **respaths; /** resource search path vector */ @@ -583,6 +578,39 @@ void warn_user(const char *warning, const char *detail) } +static void nsgtk_ssl_accept(GtkButton *w, gpointer data) +{ + void **session = data; + GtkBuilder *x = session[0]; + struct nsgtk_treeview *wnd = session[1]; + struct sslcert_session_data *ssl_data = session[2]; + + sslcert_viewer_accept(ssl_data); + + nsgtk_treeview_destroy(wnd); + g_object_unref(G_OBJECT(x)); + free(session); +} + +static void nsgtk_ssl_reject(GtkWidget *w, gpointer data) +{ + void **session = data; + GtkBuilder *x = session[0]; + struct nsgtk_treeview *wnd = session[1]; + struct sslcert_session_data *ssl_data = session[2]; + + sslcert_viewer_reject(ssl_data); + + nsgtk_treeview_destroy(wnd); + g_object_unref(G_OBJECT(x)); + free(session); +} + +static gboolean nsgtk_ssl_delete_event(GtkWidget *w, GdkEvent *event, gpointer data) +{ + nsgtk_ssl_reject(w, data); + return FALSE; +} static void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), @@ -592,19 +620,20 @@ static void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, struct sslcert_session_data *data; GtkButton *accept, *reject; void **session; - GtkWindow *window; + GtkDialog *dlg; GtkScrolledWindow *scrolled; GtkDrawingArea *drawing_area; - GError* error = NULL; - GtkBuilder* builder; + GError *error = NULL; + GtkBuilder *builder; + GtkWindow *gtk_parent; - /* state while window is open */ + /* state while dlg is open */ session = calloc(sizeof(void *), 3); if (session == NULL) { return; } - builder = gtk_builder_new (); + builder = gtk_builder_new(); if (!gtk_builder_add_from_file(builder, glade_file_location->ssl, &error)) { g_warning("Couldn't load builder file: %s", error->message); g_error_free(error); @@ -616,16 +645,22 @@ static void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, sslcert_viewer_create_session_data(num, url, cb, cbpw, certs, &data); ssl_current_session = data; - window = GTK_WINDOW(gtk_builder_get_object(builder, "wndSSLProblem")); + dlg = GTK_DIALOG(gtk_builder_get_object(builder, "wndSSLProblem")); + + /* set parent for transient dialog */ + gtk_parent = nsgtk_scaffolding_window(nsgtk_current_scaffolding()); + gtk_window_set_transient_for(GTK_WINDOW(dlg), gtk_parent); + scrolled = GTK_SCROLLED_WINDOW(gtk_builder_get_object(builder, "SSLScrolled")); drawing_area = GTK_DRAWING_AREA(gtk_builder_get_object(builder, "SSLDrawingArea")); - ssl_window = nsgtk_treeview_create(TREE_SSLCERT, window, scrolled, + ssl_window = nsgtk_treeview_create(TREE_SSLCERT, GTK_WINDOW(dlg), scrolled, drawing_area); if (ssl_window == NULL) { free(session); + g_object_unref(G_OBJECT(dlg)); return; } @@ -641,44 +676,10 @@ static void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, CONNECT(accept, "clicked", nsgtk_ssl_accept, session); CONNECT(reject, "clicked", nsgtk_ssl_reject, session); - CONNECT(window, "delete_event", G_CALLBACK(nsgtk_ssl_delete_event), + CONNECT(dlg, "delete_event", G_CALLBACK(nsgtk_ssl_delete_event), (gpointer)session); - gtk_widget_show(GTK_WIDGET(window)); -} - -void nsgtk_ssl_accept(GtkButton *w, gpointer data) -{ - void **session = data; - GtkBuilder *x = session[0]; - struct nsgtk_treeview *wnd = session[1]; - struct sslcert_session_data *ssl_data = session[2]; - - sslcert_viewer_accept(ssl_data); - - nsgtk_treeview_destroy(wnd); - g_object_unref(G_OBJECT(x)); - free(session); -} - -void nsgtk_ssl_reject(GtkWidget *w, gpointer data) -{ - void **session = data; - GtkBuilder *x = session[0]; - struct nsgtk_treeview *wnd = session[1]; - struct sslcert_session_data *ssl_data = session[2]; - - sslcert_viewer_reject(ssl_data); - - nsgtk_treeview_destroy(wnd); - g_object_unref(G_OBJECT(x)); - free(session); -} - -gboolean nsgtk_ssl_delete_event(GtkWidget *w, GdkEvent *event, gpointer data) -{ - nsgtk_ssl_reject(w, data); - return FALSE; + gtk_widget_show(GTK_WIDGET(dlg)); } diff --git a/gtk/res/ssl.gtk3.ui b/gtk/res/ssl.gtk3.ui index 90f449ddd..dace2a49e 100644 --- a/gtk/res/ssl.gtk3.ui +++ b/gtk/res/ssl.gtk3.ui @@ -1,195 +1,174 @@ - - + + + + True + False + gtk-apply + + + True + False + gtk-cancel + - 1 - SSL certificate problem - True - 500 - 250 - GDK_WINDOW_TYPE_HINT_DIALOG + False + 5 + 440 + 260 + True + dialog - - True - - - True + + False + vertical + 2 + + + False + end - + + _Reject + False True - 0 - 6 - gtk-dialog-warning + True + True + False + image3 + True False - False + True + 0 - - - True - - - True - NetSurf failed to verify the authenticity of an SSL certificate. Please verify the details presented below. - GTK_JUSTIFY_CENTER - True - - - False - False - - - - - True - 5 - 0 - - - True - 12 - - - True - True - GTK_SHADOW_IN - - - True - GTK_RESIZE_QUEUE - - - True - True - True - GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK - - - - - - - - - - - True - <b>Certificate chain</b> - True - - - - - 1 - - - - - 1 - - - - - 2 - - - - - True - GTK_BUTTONBOX_END - - - True - True - True - - - True - 0 - 0 - - - True - 2 - - - True - gtk-cancel - - - False - False - - - - - True - Reject - True - - - False - False - 1 - - - - - - - - + _Accept + False True True - True - - - True - 0 - 0 - - - True - 2 - - - True - gtk-apply - - - False - False - - - - - True - Accept - True - - - False - False - 1 - - - - - - + True + False + image2 + True + False + True 1 False - GTK_PACK_END + True + end + 0 + + + + + True + False + vertical + + + True + False + + + True + False + 8 + gtk-dialog-warning + 6 + + + False + True + 0 + + + + + True + False + NetSurf failed to verify the authenticity of an SSL certificate. Please verify the details presented below. + True + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + 0 + none + + + True + False + 12 + + + True + True + in + + + True + False + + + True + True + True + GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK + start + True + True + + + + + + + + + + + True + False + <b>Certificate Chain</b> + True + + + + + False + True + 1 + + + + + False + True + 1