summaryrefslogtreecommitdiff
path: root/frontends/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/gtk')
-rw-r--r--frontends/gtk/Makefile2
-rw-r--r--frontends/gtk/gui.c1
-rw-r--r--frontends/gtk/login.c288
-rw-r--r--frontends/gtk/login.h36
-rw-r--r--frontends/gtk/res/login.gtk2.ui162
-rw-r--r--frontends/gtk/res/login.gtk3.ui161
-rw-r--r--frontends/gtk/res/netsurf.gresource.xml2
-rw-r--r--frontends/gtk/resources.c1
8 files changed, 1 insertions, 652 deletions
diff --git a/frontends/gtk/Makefile b/frontends/gtk/Makefile
index 72d748362..db8a07a07 100644
--- a/frontends/gtk/Makefile
+++ b/frontends/gtk/Makefile
@@ -165,7 +165,7 @@ endif
# S_FRONTEND are sources purely for the GTK frontend
S_FRONTEND := gui.c schedule.c layout_pango.c bitmap.c plotters.c \
- scaffolding.c gdk.c completion.c login.c throbber.c accelerator.c \
+ scaffolding.c gdk.c completion.c throbber.c accelerator.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 \
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index 384f3fccc..f0bee4eec 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -71,7 +71,6 @@
#include "gtk/ssl_cert.h"
#include "gtk/bitmap.h"
#include "gtk/resources.h"
-#include "gtk/login.h"
#include "gtk/layout_pango.h"
#include "gtk/accelerator.h"
diff --git a/frontends/gtk/login.c b/frontends/gtk/login.c
deleted file mode 100644
index 184ef2931..000000000
--- a/frontends/gtk/login.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright 2006 Rob Kendrick <rjek@rjek.com>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <gtk/gtk.h>
-
-#include "utils/log.h"
-#include "utils/nsurl.h"
-#include "utils/messages.h"
-#include "netsurf/url_db.h"
-
-#include "gtk/resources.h"
-#include "gtk/login.h"
-
-/** login window session data */
-struct session_401 {
- nserror (*cb)(const char *username,
- const char *password,
- void *pw); /**< Continuation callback */
- void *cbpw; /**< Continuation data */
- GtkBuilder *x; /**< Our builder windows */
- GtkWindow *wnd; /**< The login window itself */
- GtkEntry *user; /**< Widget with username */
- GtkEntry *pass; /**< Widget with password */
-};
-
-/**
- * Destroy login window and free all associated resources
- *
- * \param session The login window session to destroy.
- */
-static void destroy_login_window(struct session_401 *session)
-{
- gtk_widget_destroy(GTK_WIDGET(session->wnd));
- g_object_unref(G_OBJECT(session->x));
- free(session);
-}
-
-
-/**
- * process next signal in entry widgets.
- *
- * \param w current widget
- * \param data next widget
- */
-static void nsgtk_login_next(GtkWidget *w, gpointer data)
-{
- gtk_widget_grab_focus(GTK_WIDGET(data));
-}
-
-
-/**
- * handler called when navigation is continued
- *
- * \param w current widget
- * \param data login window session
- */
-static void nsgtk_login_ok_clicked(GtkButton *w, gpointer data)
-{
- /* close the window and destroy it, having continued the fetch
- * assoicated with it.
- */
-
- struct session_401 *session = (struct session_401 *)data;
- const gchar *user;
- const gchar *pass;
-
- user = gtk_entry_get_text(session->user);
- pass = gtk_entry_get_text(session->pass);
-
- session->cb(user, pass, session->cbpw);
-
- destroy_login_window(session);
-}
-
-
-/**
- * handler called when navigation is cancelled
- *
- * \param w widget
- * \param data login window session
- */
-static void nsgtk_login_cancel_clicked(GtkButton *w, gpointer data)
-{
- struct session_401 *session = (struct session_401 *) data;
-
- session->cb(NULL, NULL, session->cbpw);
-
- /* close and destroy the window */
- destroy_login_window(session);
-}
-
-
-/**
- * generate the description of the login request
- */
-static nserror
-get_login_description(struct nsurl *url,
- const char *realm,
- const char *username,
- const char *password,
- char **out_str)
-{
- char *url_s;
- size_t url_l;
- nserror res;
- char *str = NULL;
- int slen;
- const char *key;
-
- res = nsurl_get(url, NSURL_SCHEME | NSURL_HOST, &url_s, &url_l);
- if (res != NSERROR_OK) {
- return res;
- }
-
- if ((*username == 0) && (*password == 0)) {
- key = "LoginDescription";
- } else {
- key = "LoginAgain";
- }
-
- str = messages_get_buff(key, url_s, realm);
- NSLOG(netsurf, INFO,
- "key:%s url:%s realm:%s str:%s", key, url_s, realm, str);
-
- if ((str != NULL) && (strcmp(key, str) != 0)) {
- *out_str = str;
- } else {
- /* no message so fallback */
- const char *fmt = "The site %s is requesting your username and password. The realm is \"%s\"";
- slen = snprintf(str, 0, fmt, url_s, realm) + 1;
- str = malloc(slen);
- if (str == NULL) {
- res = NSERROR_NOMEM;
- } else {
- snprintf(str, slen, fmt, url_s, realm);
- *out_str = str;
- }
- }
-
- free(url_s);
-
- return res;
-}
-
-
-/**
- * create a new instance of the login window
- *
- * creates login window and handles to all the widgets we're
- * interested in.
- *
- * \param url The url causing the login.
- * \param host the host being logged into
- * \param realm realmm the login relates to
- * \param cb callback when complete
- * \param cbpw data to pass to callback
- * \return NSERROR_OK on sucessful window creation or error code on faliure.
- */
-static nserror
-create_login_window(nsurl *url,
- lwc_string *host,
- const char *realm,
- const char *username,
- const char *password,
- nserror (*cb)(const char *username,
- const char *password,
- void *pw),
- void *cbpw)
-{
- nserror res;
- struct session_401 *session;
- GtkWindow *wnd;
- GtkLabel *ldesc;
- GtkEntry *euser, *epass;
- GtkButton *bok, *bcan;
- GtkBuilder *builder;
- char *description = NULL;
-
- session = calloc(1, sizeof(struct session_401));
- if (session == NULL) {
- return NSERROR_NOMEM;
- }
-
- res = nsgtk_builder_new_from_resname("login", &builder);
- if (res != NSERROR_OK) {
- free(session);
- return res;
- }
-
- gtk_builder_connect_signals(builder, NULL);
-
- wnd = GTK_WINDOW(gtk_builder_get_object(builder, "LoginDialog"));
- ldesc = GTK_LABEL(gtk_builder_get_object(builder, "LoginDescription"));
- euser = GTK_ENTRY(gtk_builder_get_object(builder, "LoginUsername"));
- epass = GTK_ENTRY(gtk_builder_get_object(builder, "LoginPassword"));
- bok = GTK_BUTTON(gtk_builder_get_object(builder, "LoginOK"));
- bcan = GTK_BUTTON(gtk_builder_get_object(builder, "LoginCancel"));
-
- /* create and fill in our session structure */
- session->cb = cb;
- session->cbpw = cbpw;
- session->x = builder;
- session->wnd = wnd;
- session->user = euser;
- session->pass = epass;
-
- /* fill in our new login window */
- res = get_login_description(url, realm, username, password, &description);
- if (res == NSERROR_OK) {
- gtk_label_set_text(GTK_LABEL(ldesc), description);
- free(description);
- }
- gtk_entry_set_text(euser, username);
- gtk_entry_set_text(epass, password);
-
- /* attach signal handlers to the Login and Cancel buttons in our new
- * window to call functions in this file to process the login
- */
- g_signal_connect(G_OBJECT(bok), "clicked",
- G_CALLBACK(nsgtk_login_ok_clicked), (gpointer)session);
- g_signal_connect(G_OBJECT(bcan), "clicked",
- G_CALLBACK(nsgtk_login_cancel_clicked),
- (gpointer)session);
-
- /* attach signal handlers to the entry boxes such that pressing
- * enter in one progresses the focus onto the next widget.
- */
- g_signal_connect(G_OBJECT(euser), "activate",
- G_CALLBACK(nsgtk_login_next), (gpointer)epass);
- g_signal_connect(G_OBJECT(epass), "activate",
- G_CALLBACK(nsgtk_login_next), (gpointer)bok);
-
- /* make sure the username entry box currently has the focus */
- gtk_widget_grab_focus(GTK_WIDGET(euser));
-
- /* finally, show the window */
- gtk_widget_show(GTK_WIDGET(wnd));
-
- return NSERROR_OK;
-}
-
-
-/* exported function documented in gtk/login.h */
-nserror
-gui_401login_open(nsurl *url,
- const char *realm,
- const char *username,
- const char *password,
- nserror (*cb)(const char *username,
- const char *password,
- void *pw),
- void *cbpw)
-{
- lwc_string *host;
- nserror res;
-
- host = nsurl_get_component(url, NSURL_HOST);
- assert(host != NULL);
-
- res = create_login_window(url, host, realm, username, password,
- cb, cbpw);
- if (res != NSERROR_OK) {
- NSLOG(netsurf, INFO, "Login init failed");
-
- return res;
- }
-
- lwc_string_unref(host);
-
- return NSERROR_OK;
-}
diff --git a/frontends/gtk/login.h b/frontends/gtk/login.h
deleted file mode 100644
index 1be1b4c29..000000000
--- a/frontends/gtk/login.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2015 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Login interfaces.
- */
-
-#ifndef __NSGTK_LOGIN_H__
-#define __NSGTK_LOGIN_H__
-
-/**
- * login window request.
- */
-extern nserror gui_401login_open(nsurl *url, const char *realm,
- const char *username, const char *password,
- nserror (*cb)(const char *username,
- const char *password,
- void *pw),
- void *cbpw);
-
-#endif
diff --git a/frontends/gtk/res/login.gtk2.ui b/frontends/gtk/res/login.gtk2.ui
deleted file mode 100644
index 6d9bf98cf..000000000
--- a/frontends/gtk/res/login.gtk2.ui
+++ /dev/null
@@ -1,162 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
- <!-- interface-requires gtk+ 2.12 -->
- <!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkImage" id="imageLogin">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-ok</property>
- </object>
- <object class="GtkDialog" id="LoginDialog">
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">2</property>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="LoginCancel">
- <property name="label">gtk-cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="LoginOK">
- <property name="label" translatable="yes">Login</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="image">imageLogin</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkTable" id="table1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="n_rows">3</property>
- <property name="n_columns">2</property>
- <child>
- <object class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-dialog-authentication</property>
- <property name="icon-size">6</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="LoginDescription">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">LoginLabel</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Username</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_EXPAND</property>
- <property name="y_options">GTK_EXPAND</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Password</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_EXPAND</property>
- <property name="y_options">GTK_EXPAND</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="LoginUsername">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">True</property>
- <property name="secondary_icon_sensitive">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options">GTK_EXPAND</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="LoginPassword">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="visibility">False</property>
- <property name="invisible_char">●</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">True</property>
- <property name="secondary_icon_sensitive">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="y_options">GTK_EXPAND</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="0">LoginCancel</action-widget>
- <action-widget response="0">LoginOK</action-widget>
- </action-widgets>
- </object>
-</interface>
diff --git a/frontends/gtk/res/login.gtk3.ui b/frontends/gtk/res/login.gtk3.ui
deleted file mode 100644
index 543005757..000000000
--- a/frontends/gtk/res/login.gtk3.ui
+++ /dev/null
@@ -1,161 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
-<!--*- mode: xml -*-->
-<interface>
- <requires lib="gtk+" version="3.0"/>
- <object class="GtkImage" id="imageLogin">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-ok</property>
- </object>
- <object class="GtkDialog" id="LoginDialog">
- <property name="can_focus">False</property>
- <property name="title" translatable="yes">Authentication Request</property>
- <property name="default_width">400</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
- <object class="GtkBox">
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox">
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="LoginCancel">
- <property name="label">gtk-cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="LoginOK">
- <property name="label" translatable="yes">Login</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="image">imageLogin</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-dialog-authentication</property>
- <property name="icon_size">6</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="margin_left">2</property>
- <property name="margin_right">4</property>
- <property name="margin_top">2</property>
- <property name="margin_bottom">2</property>
- <property name="label" translatable="yes">Username</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="margin_left">2</property>
- <property name="margin_right">4</property>
- <property name="margin_top">2</property>
- <property name="margin_bottom">2</property>
- <property name="label" translatable="yes">Password</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="LoginDescription">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="margin_top">2</property>
- <property name="margin_bottom">2</property>
- <property name="vexpand">True</property>
- <property name="label" translatable="yes">LoginLabel</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="LoginUsername">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="margin_top">2</property>
- <property name="margin_bottom">2</property>
- <property name="hexpand">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="LoginPassword">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="margin_top">2</property>
- <property name="margin_bottom">2</property>
- <property name="visibility">False</property>
- <property name="invisible_char">●</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
-</interface>
diff --git a/frontends/gtk/res/netsurf.gresource.xml b/frontends/gtk/res/netsurf.gresource.xml
index e8243254a..c170df206 100644
--- a/frontends/gtk/res/netsurf.gresource.xml
+++ b/frontends/gtk/res/netsurf.gresource.xml
@@ -19,13 +19,11 @@
<file>ssl.gtk3.ui</file>
<file>viewdata.gtk2.ui</file>
<file>downloads.gtk3.ui</file>
- <file>login.gtk2.ui</file>
<file>options.gtk3.ui</file>
<file>tabcontents.gtk2.ui</file>
<file>viewdata.gtk3.ui</file>
<file>localhistory.gtk2.ui</file>
<file>globalhistory.gtk2.ui</file>
- <file>login.gtk3.ui</file>
<file>password.gtk2.ui</file>
<file>tabcontents.gtk3.ui</file>
<file>warning.gtk2.ui</file>
diff --git a/frontends/gtk/resources.c b/frontends/gtk/resources.c
index fc3ac6ff3..7aea43ce3 100644
--- a/frontends/gtk/resources.c
+++ b/frontends/gtk/resources.c
@@ -77,7 +77,6 @@ static struct nsgtk_resource_s ui_resource[] = {
RES_ENTRY("netsurf"),
RES_ENTRY("tabcontents"),
RES_ENTRY("password"),
- RES_ENTRY("login"),
RES_ENTRY("ssl"),
RES_ENTRY("toolbar"),
RES_ENTRY("downloads"),