repurpose ssl certificate core window for nitial page infor window on gtk

This commit is contained in:
Vincent Sanders 2019-12-01 16:20:42 +00:00
parent a0af810966
commit 08e2cc32ba
5 changed files with 60 additions and 23 deletions

View File

@ -169,7 +169,7 @@ S_FRONTEND := gui.c schedule.c layout_pango.c bitmap.c plotters.c \
selection.c window.c fetch.c download.c menu.c print.c \
search.c tabs.c toolbar.c gettext.c compat.c viewdata.c \
viewsource.c preferences.c about.c resources.c corewindow.c \
local_history.c global_history.c cookies.c hotlist.c ssl_cert.c
local_history.c global_history.c cookies.c hotlist.c page_info.c
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image

View File

@ -69,7 +69,6 @@
#include "gtk/schedule.h"
#include "gtk/selection.h"
#include "gtk/search.h"
#include "gtk/ssl_cert.h"
#include "gtk/bitmap.h"
#include "gtk/resources.h"
#include "gtk/layout_pango.h"

View File

@ -28,12 +28,13 @@
#include "utils/log.h"
#include "netsurf/keypress.h"
#include "netsurf/plotters.h"
#include "netsurf/browser_window.h"
#include "desktop/sslcert_viewer.h"
#include "gtk/plotters.h"
#include "gtk/scaffolding.h"
#include "gtk/resources.h"
#include "gtk/ssl_cert.h"
#include "gtk/page_info.h"
#include "gtk/corewindow.h"
@ -166,16 +167,24 @@ nsgtk_crtvrfy_draw(struct nsgtk_corewindow *nsgtk_cw, struct rect *r)
return NSERROR_OK;
}
/* exported interface documented in gtk/ssl_cert.h */
nserror gtk_cert_verify(struct nsurl *url,
const struct ssl_cert_info *certs,
unsigned long num,
nserror (*cb)(bool proceed, void *pw),
void *cbpw)
static nserror dummy_cb(bool proceed, void *pw)
{
return NSERROR_OK;
}
/* exported interface documented in gtk/page_info.h */
nserror nsgtk_page_info(struct browser_window *bw)
{
struct nsgtk_crtvrfy_window *ncwin;
nserror res;
size_t num;
struct ssl_cert_info *chain;
struct nsurl *url;
browser_window_get_ssl_chain(bw, &num, &chain);
url = browser_window_access_url(bw);
ncwin = malloc(sizeof(struct nsgtk_crtvrfy_window));
if (ncwin == NULL) {
return NSERROR_NOMEM;
@ -236,7 +245,7 @@ nserror gtk_cert_verify(struct nsurl *url,
}
/* initialise certificate viewing interface */
res = sslcert_viewer_create_session_data(num, url, cb, cbpw, certs,
res = sslcert_viewer_create_session_data(num, url, dummy_cb, NULL, chain,
&ncwin->ssl_data);
if (res != NSERROR_OK) {
g_object_unref(G_OBJECT(ncwin->dlg));

View File

@ -1,5 +1,5 @@
/*
* Copyright 2005 James Bursa <bursa@users.sourceforge.net>
* Copyright 2019 Vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@ -16,22 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NETSURF_GTK_SSL_CERT_H
#define NETSURF_GTK_SSL_CERT_H 1
struct nsurl;
struct ssl_cert_info;
#ifndef NETSURF_GTK_PAGE_INFO_H
#define NETSURF_GTK_PAGE_INFO_H 1
/**
* Prompt the user to verify a certificate with issuse.
* Page information window
*
* \param url The URL being verified.
* \param certs The certificate to be verified
* \param num The number of certificates to be verified.
* \param cb Callback upon user decision.
* \param cbpw Context pointer passed to cb
* \param bw the browser window to get page information for
* \return NSERROR_OK or error code if prompt creation failed.
*/
nserror gtk_cert_verify(struct nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw);
nserror nsgtk_page_info(struct browser_window *bw);
#endif

View File

@ -69,6 +69,7 @@
#include "gtk/about.h"
#include "gtk/gdk.h"
#include "gtk/bitmap.h"
#include "gtk/page_info.h"
#include "gtk/toolbar.h"
/**
@ -301,6 +302,9 @@ make_toolbar_item_throbber(bool sensitivity, bool edit)
* create url bar toolbar item widget
*
* create a gtk entry widget with a completion attached
*
* \param sensitivity if the entry should be created sensitive to input
* \param edit if the entry should be editable
*/
static GtkToolItem *
make_toolbar_item_url_bar(bool sensitivity, bool edit)
@ -314,6 +318,9 @@ make_toolbar_item_url_bar(bool sensitivity, bool edit)
if (entry == NULL) {
return NULL;
}
nsgtk_entry_set_icon_from_icon_name(entry,
GTK_ENTRY_ICON_PRIMARY,
NSGTK_STOCK_INFO);
if (edit) {
gtk_entry_set_width_chars(GTK_ENTRY(entry), 9);
@ -1940,6 +1947,31 @@ url_entry_changed_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
}
/**
* callback for url entry widget icon button release
*
* handler connected to url entry widget for the icon release signal
*
* \param widget The widget the signal is being delivered to.
* \param event The key change event that changed the entry.
* \param data The toolbar context passed when the signal was connected
* \return TRUE to allow activation.
*/
static void
url_entry_icon_release_cb(GtkEntry *entry,
GtkEntryIconPosition icon_pos,
GdkEvent *event,
gpointer data)
{
struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
struct browser_window *bw;
bw = tb->get_bw(tb->get_ctx);
nsgtk_page_info(bw);
}
/**
* handler for web search tool bar entry item activate signal
*
@ -3276,6 +3308,10 @@ toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
"changed",
G_CALLBACK(url_entry_changed_cb),
tb);
g_signal_connect(GTK_WIDGET(entry),
"icon-release",
G_CALLBACK(url_entry_icon_release_cb),
tb);
nsgtk_completion_connect_signals(entry,
tb->get_bw,