r2823 dsilvers - /branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c
by netsurf@semichrome.net
Author: dsilvers
Date: Wed Aug 9 16:02:27 2006
New Revision: 2823
URL: http://svn.semichrome.net?rev=2823&view=rev
Log:
Add code comments
Modified:
branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c
Modified: branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c
URL: http://svn.semichrome.net/branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bi...
==============================================================================
--- branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c (original)
+++ branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c Wed Aug 9 16:02:27 2006
@@ -229,6 +229,11 @@
return bitmap->primary;
}
+/**
+ * The X-pretiled image associated with this bitmap object.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
GdkPixbuf *
gtk_bitmap_get_pretile_x(struct bitmap* bitmap)
{
@@ -243,6 +248,11 @@
}
+/**
+ * The Y-pretiled image associated with this bitmap object.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
GdkPixbuf *
gtk_bitmap_get_pretile_y(struct bitmap* bitmap)
{
@@ -256,6 +266,11 @@
return bitmap->pretile_y;
}
+/**
+ * The XY-pretiled image associated with this bitmap object.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
GdkPixbuf *
gtk_bitmap_get_pretile_xy(struct bitmap* bitmap)
{
17 years, 3 months
r2822 dsilvers - /branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c
by netsurf@semichrome.net
Author: dsilvers
Date: Wed Aug 9 15:58:41 2006
New Revision: 2822
URL: http://svn.semichrome.net?rev=2822&view=rev
Log:
Ensure that if not tiling, we ref the primary and return it
Modified:
branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c
Modified: branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c
URL: http://svn.semichrome.net/branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bi...
==============================================================================
--- branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c (original)
+++ branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c Wed Aug 9 15:58:41 2006
@@ -198,6 +198,12 @@
/* This algorithm won't work if the strides are not multiples */
assert(target_stride == (primary_stride * repeat_x));
+ if (repeat_x == 1 && repeat_y == 1) {
+ g_object_ref(primary);
+ g_object_unref(result);
+ return primary;
+ }
+
for (y = 0; y < repeat_y; ++y) {
char *primary_buffer = (char *)gdk_pixbuf_get_pixels(primary);
for (row = 0; row < height; ++row) {
17 years, 3 months
r2821 dsilvers - in /branches/dsilvers/gtk-bitmap-pretile/gtk: gtk_bitmap.c gtk_bitmap.h gtk_plotters.c
by netsurf@semichrome.net
Author: dsilvers
Date: Wed Aug 9 15:46:40 2006
New Revision: 2821
URL: http://svn.semichrome.net?rev=2821&view=rev
Log:
Initial stab at pretiling in GTK frontend
Modified:
branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c
branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.h
branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_plotters.c
Modified: branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c
URL: http://svn.semichrome.net/branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bi...
==============================================================================
--- branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c (original)
+++ branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c Wed Aug 9 15:46:40 2006
@@ -19,11 +19,18 @@
#include "netsurf/content/content.h"
#include "netsurf/gtk/gtk_window.h"
#include "netsurf/image/bitmap.h"
+#include "netsurf/utils/log.h"
struct bitmap {
GdkPixbuf *primary;
+ GdkPixbuf *pretile_x;
+ GdkPixbuf *pretile_y;
+ GdkPixbuf *pretile_xy;
};
+
+#define MIN_PRETILE_WIDTH 256
+#define MIN_PRETILE_HEIGHT 256
/**
@@ -40,6 +47,7 @@
struct bitmap *bmp = malloc(sizeof(struct bitmap));
bmp->primary = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8,
width, height);
+ bmp->pretile_x = bmp->pretile_y = bmp->pretile_xy = NULL;
return bmp;
}
@@ -115,6 +123,16 @@
}
+static void
+gtk_bitmap_free_pretiles(struct bitmap *bitmap)
+{
+#define FREE_TILE(XY) if (bitmap->pretile_##XY) g_object_unref(bitmap->pretile_##XY); bitmap->pretile_##XY = NULL
+ FREE_TILE(x);
+ FREE_TILE(y);
+ FREE_TILE(xy);
+#undef FREE_TILE
+}
+
/**
* Free a bitmap.
*
@@ -124,6 +142,7 @@
void bitmap_destroy(struct bitmap *bitmap)
{
assert(bitmap);
+ gtk_bitmap_free_pretiles(bitmap);
g_object_unref(bitmap->primary);
free(bitmap);
}
@@ -149,6 +168,7 @@
* \param bitmap a bitmap, as returned by bitmap_create()
*/
void bitmap_modified(struct bitmap *bitmap) {
+ gtk_bitmap_free_pretiles(bitmap);
}
@@ -164,6 +184,34 @@
void (*invalidate)(struct bitmap *bitmap, void *private_word)) {
}
+static GdkPixbuf *
+gtk_bitmap_generate_pretile(GdkPixbuf *primary, int repeat_x, int repeat_y)
+{
+ int width = gdk_pixbuf_get_width(primary);
+ int height = gdk_pixbuf_get_height(primary);
+ size_t primary_stride = gdk_pixbuf_get_rowstride(primary);
+ GdkPixbuf *result = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8,
+ width * repeat_x, height * repeat_y);
+ char *target_buffer = (char *)gdk_pixbuf_get_pixels(result);
+ size_t target_stride = gdk_pixbuf_get_rowstride(result);
+ int x,y,row;
+ /* This algorithm won't work if the strides are not multiples */
+ assert(target_stride == (primary_stride * repeat_x));
+
+ for (y = 0; y < repeat_y; ++y) {
+ char *primary_buffer = (char *)gdk_pixbuf_get_pixels(primary);
+ for (row = 0; row < height; ++row) {
+ for (x = 0; x < repeat_x; ++x) {
+ memcpy(target_buffer,
+ primary_buffer, primary_stride);
+ target_buffer += primary_stride;
+ }
+ primary_buffer += primary_stride;
+ }
+ }
+ return result;
+}
+
/**
* The primary image associated with this bitmap object.
*
@@ -174,3 +222,44 @@
{
return bitmap->primary;
}
+
+GdkPixbuf *
+gtk_bitmap_get_pretile_x(struct bitmap* bitmap)
+{
+ if (!bitmap->pretile_x) {
+ int width = gdk_pixbuf_get_width(bitmap->primary);
+ int height = gdk_pixbuf_get_height(bitmap->primary);
+ int xmult = (MIN_PRETILE_WIDTH + width - 1)/width;
+ LOG(("Pretiling %p for X*%d", bitmap, xmult));
+ bitmap->pretile_x = gtk_bitmap_generate_pretile(bitmap->primary, xmult, 1);
+ }
+ return bitmap->pretile_x;
+
+}
+
+GdkPixbuf *
+gtk_bitmap_get_pretile_y(struct bitmap* bitmap)
+{
+ if (!bitmap->pretile_y) {
+ int width = gdk_pixbuf_get_width(bitmap->primary);
+ int height = gdk_pixbuf_get_height(bitmap->primary);
+ int ymult = (MIN_PRETILE_HEIGHT + height - 1)/height;
+ LOG(("Pretiling %p for Y*%d", bitmap, ymult));
+ bitmap->pretile_y = gtk_bitmap_generate_pretile(bitmap->primary, 1, ymult);
+ }
+ return bitmap->pretile_y;
+}
+
+GdkPixbuf *
+gtk_bitmap_get_pretile_xy(struct bitmap* bitmap)
+{
+ if (!bitmap->pretile_xy) {
+ int width = gdk_pixbuf_get_width(bitmap->primary);
+ int height = gdk_pixbuf_get_height(bitmap->primary);
+ int xmult = (MIN_PRETILE_WIDTH + width - 1)/width;
+ int ymult = (MIN_PRETILE_HEIGHT + height - 1)/height;
+ LOG(("Pretiling %p for X*%d Y*%d", bitmap, xmult, ymult));
+ bitmap->pretile_xy = gtk_bitmap_generate_pretile(bitmap->primary, xmult, ymult);
+ }
+ return bitmap->pretile_xy;
+}
Modified: branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.h
URL: http://svn.semichrome.net/branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bi...
==============================================================================
--- branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.h (original)
+++ branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.h Wed Aug 9 15:46:40 2006
@@ -13,6 +13,10 @@
#include "netsurf/image/bitmap.h"
GdkPixbuf *gtk_bitmap_get_primary(struct bitmap*);
+GdkPixbuf *gtk_bitmap_get_pretile_x(struct bitmap*);
+GdkPixbuf *gtk_bitmap_get_pretile_y(struct bitmap*);
+GdkPixbuf *gtk_bitmap_get_pretile_xy(struct bitmap*);
+
#endif /* NS_GTK_BITMAP_H */
Modified: branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_plotters.c
URL: http://svn.semichrome.net/branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_pl...
==============================================================================
--- branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_plotters.c (original)
+++ branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_plotters.c Wed Aug 9 15:46:40 2006
@@ -257,13 +257,12 @@
return true;
}
-bool nsgtk_plot_bitmap(int x, int y, int width, int height,
- struct bitmap *bitmap, colour bg)
+static bool nsgtk_plot_pixbuf(int x, int y, int width, int height,
+ GdkPixbuf *pixbuf, colour bg)
{
/* XXX: This currently ignores the background colour supplied.
* Does this matter?
*/
- GdkPixbuf *pixbuf = gtk_bitmap_get_primary(bitmap);
if (width == 0 || height == 0)
return true;
@@ -299,18 +298,39 @@
return true;
}
+bool nsgtk_plot_bitmap(int x, int y, int width, int height,
+ struct bitmap *bitmap, colour bg)
+{
+ GdkPixbuf *pixbuf = gtk_bitmap_get_primary(bitmap);
+ nsgtk_plot_pixbuf(x, y, width, height, pixbuf, bg);
+}
bool nsgtk_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y)
{
int doneheight = 0, donewidth = 0;
-
+ GdkPixbuf *primary;
+ GdkPixbuf *pretiled;
+
if (!(repeat_x || repeat_y)) {
/* Not repeating at all, so just pass it on */
return nsgtk_plot_bitmap(x,y,width,height,bitmap,bg);
}
-
+
+ if (repeat_x && !repeat_y)
+ pretiled = gtk_bitmap_get_pretile_x(bitmap);
+ if (repeat_x && repeat_y)
+ pretiled = gtk_bitmap_get_pretile_xy(bitmap);
+ if (!repeat_x && repeat_y)
+ pretiled = gtk_bitmap_get_pretile_y(bitmap);
+ primary = gtk_bitmap_get_primary(bitmap);
+ /* use the primary and pretiled widths to scale the w/h provided */
+ width *= gdk_pixbuf_get_width(pretiled);
+ width /= gdk_pixbuf_get_width(primary);
+ height *= gdk_pixbuf_get_height(pretiled);
+ height /= gdk_pixbuf_get_height(primary);
+
if (y > cliprect.y)
doneheight = (cliprect.y - height) + ((y - cliprect.y) % height);
else
@@ -322,8 +342,8 @@
else
donewidth = x;
while (donewidth < (cliprect.x + cliprect.width)) {
- nsgtk_plot_bitmap(donewidth, doneheight,
- width, height, bitmap, bg);
+ nsgtk_plot_pixbuf(donewidth, doneheight,
+ width, height, pretiled, bg);
donewidth += width;
if (!repeat_x) break;
}
17 years, 3 months
r2820 dsilvers - /branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_thumbnail.c
by netsurf@semichrome.net
Author: dsilvers
Date: Wed Aug 9 15:46:20 2006
New Revision: 2820
URL: http://svn.semichrome.net?rev=2820&view=rev
Log:
Fix thumbnail to use struct style bitmap
Modified:
branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_thumbnail.c
Modified: branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_thumbnail.c
URL: http://svn.semichrome.net/branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_th...
==============================================================================
--- branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_thumbnail.c (original)
+++ branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_thumbnail.c Wed Aug 9 15:46:20 2006
@@ -24,6 +24,7 @@
#include "netsurf/utils/log.h"
#include "netsurf/gtk/gtk_window.h"
#include "netsurf/gtk/gtk_plotters.h"
+#include "netsurf/gtk/gtk_bitmap.h"
/**
* Create a thumbnail of a page.
@@ -35,7 +36,7 @@
bool thumbnail_create(struct content *content, struct bitmap *bitmap,
const char *url)
{
- GdkPixbuf *pixbuf = (GdkPixbuf *) bitmap;
+ GdkPixbuf *pixbuf = gtk_bitmap_get_primary(bitmap);
gint width = gdk_pixbuf_get_width(pixbuf);
gint height = gdk_pixbuf_get_height(pixbuf);
gint depth = (gdk_screen_get_system_visual(gdk_screen_get_default()))->depth;
17 years, 3 months
r2819 dsilvers - in /branches/dsilvers/gtk-bitmap-pretile/gtk: gtk_bitmap.c gtk_bitmap.h gtk_plotters.c
by netsurf@semichrome.net
Author: dsilvers
Date: Wed Aug 9 14:46:51 2006
New Revision: 2819
URL: http://svn.semichrome.net?rev=2819&view=rev
Log:
GTK struct bitmap is now a struct, also alter plotters to use a specific call to get the primary image out.
Added:
branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.h
Modified:
branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c
branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_plotters.c
Modified: branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c
URL: http://svn.semichrome.net/branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bi...
==============================================================================
--- branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c (original)
+++ branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.c Wed Aug 9 14:46:51 2006
@@ -21,7 +21,9 @@
#include "netsurf/image/bitmap.h"
-struct bitmap;
+struct bitmap {
+ GdkPixbuf *primary;
+};
/**
@@ -35,9 +37,10 @@
struct bitmap *bitmap_create(int width, int height, unsigned int state)
{
- GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8,
- width, height);
- return (struct bitmap *) pixbuf;
+ struct bitmap *bmp = malloc(sizeof(struct bitmap));
+ bmp->primary = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8,
+ width, height);
+ return bmp;
}
@@ -94,7 +97,7 @@
char *bitmap_get_buffer(struct bitmap *bitmap)
{
assert(bitmap);
- return (char *)gdk_pixbuf_get_pixels((GdkPixbuf *) bitmap);
+ return (char *)gdk_pixbuf_get_pixels(bitmap->primary);
}
@@ -108,7 +111,7 @@
size_t bitmap_get_rowstride(struct bitmap *bitmap)
{
assert(bitmap);
- return gdk_pixbuf_get_rowstride((GdkPixbuf *) bitmap);
+ return gdk_pixbuf_get_rowstride(bitmap->primary);
}
@@ -121,7 +124,8 @@
void bitmap_destroy(struct bitmap *bitmap)
{
assert(bitmap);
- g_object_unref((GdkPixbuf *) bitmap);
+ g_object_unref(bitmap->primary);
+ free(bitmap);
}
@@ -159,3 +163,14 @@
void bitmap_set_suspendable(struct bitmap *bitmap, void *private_word,
void (*invalidate)(struct bitmap *bitmap, void *private_word)) {
}
+
+/**
+ * The primary image associated with this bitmap object.
+ *
+ * \param bitmap a bitmap, as returned by bitmap_create()
+ */
+GdkPixbuf *
+gtk_bitmap_get_primary(struct bitmap* bitmap)
+{
+ return bitmap->primary;
+}
Added: branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.h
URL: http://svn.semichrome.net/branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bi...
==============================================================================
--- branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.h (added)
+++ branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_bitmap.h Wed Aug 9 14:46:51 2006
@@ -1,0 +1,18 @@
+/*
+ * This file is part of NetSurf, http://netsurf.sourceforge.net/
+ * Licensed under the GNU General Public License,
+ * http://www.opensource.org/licenses/gpl-license
+ * Copyright 2006 Daniel Silverstone <dsilvers(a)digital-scurf.org>
+ */
+
+#ifndef NS_GTK_BITMAP_H
+#define NS_GTK_BITMAP_H
+
+#include <gdk/gdk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include "netsurf/image/bitmap.h"
+
+GdkPixbuf *gtk_bitmap_get_primary(struct bitmap*);
+
+
+#endif /* NS_GTK_BITMAP_H */
Modified: branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_plotters.c
URL: http://svn.semichrome.net/branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_pl...
==============================================================================
--- branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_plotters.c (original)
+++ branches/dsilvers/gtk-bitmap-pretile/gtk/gtk_plotters.c Wed Aug 9 14:46:51 2006
@@ -26,6 +26,7 @@
#include "netsurf/utils/log.h"
#include "netsurf/desktop/options.h"
#include "netsurf/gtk/options.h"
+#include "netsurf/gtk/gtk_bitmap.h"
static bool nsgtk_plot_clg(colour c);
static bool nsgtk_plot_rectangle(int x0, int y0, int width, int height,
@@ -262,7 +263,7 @@
/* XXX: This currently ignores the background colour supplied.
* Does this matter?
*/
- GdkPixbuf *pixbuf = (GdkPixbuf *) bitmap;
+ GdkPixbuf *pixbuf = gtk_bitmap_get_primary(bitmap);
if (width == 0 || height == 0)
return true;
17 years, 3 months
r2817 rjek - in /trunk/netsurf: gtk/gtk_gui.c gtk/gtk_gui.h gtk/gtk_login.c gtk/netsurf.glade makefile
by netsurf@semichrome.net
Author: rjek
Date: Sun Aug 6 23:29:58 2006
New Revision: 2817
URL: http://svn.semichrome.net?rev=2817&view=rev
Log:
Implement 401 login window in nsgtk
Added:
trunk/netsurf/gtk/gtk_login.c
Modified:
trunk/netsurf/gtk/gtk_gui.c
trunk/netsurf/gtk/gtk_gui.h
trunk/netsurf/gtk/netsurf.glade
trunk/netsurf/makefile
Modified: trunk/netsurf/gtk/gtk_gui.c
URL: http://svn.semichrome.net/trunk/netsurf/gtk/gtk_gui.c?rev=2817&r1=2816&r2...
==============================================================================
--- trunk/netsurf/gtk/gtk_gui.c (original)
+++ trunk/netsurf/gtk/gtk_gui.c Sun Aug 6 23:29:58 2006
@@ -303,9 +303,6 @@
{
}
-
-void gui_401login_open(struct browser_window *bw, struct content *c,
- const char *realm) {}
void gui_cert_verify(struct browser_window *bw, struct content *c,
const struct ssl_cert_info *certs, unsigned long num) {}
Modified: trunk/netsurf/gtk/gtk_gui.h
URL: http://svn.semichrome.net/trunk/netsurf/gtk/gtk_gui.h?rev=2817&r1=2816&r2...
==============================================================================
--- trunk/netsurf/gtk/gtk_gui.h (original)
+++ trunk/netsurf/gtk/gtk_gui.h Sun Aug 6 23:29:58 2006
@@ -11,5 +11,6 @@
extern bool gui_in_multitask;
extern GladeXML *gladeWindows;
+extern char *glade_file_location;
extern char *options_file_location;
Added: trunk/netsurf/gtk/gtk_login.c
URL: http://svn.semichrome.net/trunk/netsurf/gtk/gtk_login.c?rev=2817&view=auto
==============================================================================
--- trunk/netsurf/gtk/gtk_login.c (added)
+++ trunk/netsurf/gtk/gtk_login.c Sun Aug 6 23:29:58 2006
@@ -1,0 +1,163 @@
+/*
+ * This file is part of NetSurf, http://netsurf.sourceforge.net/
+ * Licensed under the GNU General Public License,
+ * http://www.opensource.org/licenses/gpl-license
+ * Copyright 2006 Rob Kendrick <rjek(a)rjek.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+#include "netsurf/utils/log.h"
+#include "netsurf/gtk/gtk_gui.h"
+#include "netsurf/content/content.h"
+#include "netsurf/content/urldb.h"
+#include "netsurf/desktop/browser.h"
+#include "netsurf/desktop/401login.h"
+#include "netsurf/desktop/gui.h"
+#include "netsurf/utils/messages.h"
+#include "netsurf/utils/url.h"
+#include "netsurf/utils/utils.h"
+
+struct session_401 {
+ char *url; /**< URL being fetched */
+ char *host; /**< Host for user display */
+ char *realm; /**< Authentication realm */
+ struct browser_window *bw; /**< Browser window handle */
+ GladeXML *x; /**< Our glade windows */
+ GtkWindow *wnd; /**< The login window itself */
+ GtkEntry *user; /**< Widget with username */
+ GtkEntry *pass; /**< Widget with password */
+};
+
+static void create_login_window(struct browser_window *bw, const char *host,
+ const char *realm, const char *fetchurl);
+static void destroy_login_window(struct session_401 *session);
+static void nsgtk_login_next(GtkWidget *w, gpointer data);
+static void nsgtk_login_ok_clicked(GtkButton *w, gpointer data);
+static void nsgtk_login_cancel_clicked(GtkButton *w, gpointer data);
+
+void gui_401login_open(struct browser_window *bw, struct content *c,
+ const char *realm)
+{
+ char *host;
+ url_func_result res;
+
+ res = url_host(c->url, &host);
+ assert(res == URL_FUNC_OK);
+
+ create_login_window(bw, host, realm, c->url);
+
+ free(host);
+}
+
+void create_login_window(struct browser_window *bw, const char *host,
+ const char *realm, const char *fetchurl)
+{
+ struct session_401 *session;
+
+ /* create a new instance of the login window, and get handles to all
+ * the widgets we're interested in.
+ */
+
+ GladeXML *x = glade_xml_new(glade_file_location, NULL, NULL);
+ GtkWindow *wnd = GTK_WINDOW(glade_xml_get_widget(x, "wndLogin"));
+ GtkLabel *lhost, *lrealm;
+ GtkEntry *euser, *epass;
+ GtkButton *bok, *bcan;
+
+ lhost = GTK_LABEL(glade_xml_get_widget(x, "labelLoginHost"));
+ lrealm = GTK_LABEL(glade_xml_get_widget(x, "labelLoginRealm"));
+ euser = GTK_ENTRY(glade_xml_get_widget(x, "entryLoginUser"));
+ epass = GTK_ENTRY(glade_xml_get_widget(x, "entryLoginPass"));
+ bok = GTK_BUTTON(glade_xml_get_widget(x, "buttonLoginOK"));
+ bcan = GTK_BUTTON(glade_xml_get_widget(x, "buttonLoginCan"));
+
+ /* create and fill in our session structure */
+
+ session = calloc(1, sizeof(struct session_401));
+ session->url = strdup(fetchurl);
+ session->host = strdup(host);
+ session->realm = strdup(realm ? realm : "Secure Area");
+ session->bw = bw;
+ session->x = x;
+ session->wnd = wnd;
+ session->user = euser;
+ session->pass = epass;
+
+ /* fill in our new login window */
+
+ gtk_label_set_text(GTK_LABEL(lhost), host);
+ gtk_label_set_text(lrealm, realm);
+ gtk_entry_set_text(euser, "");
+ gtk_entry_set_text(epass, "");
+
+ /* 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));
+}
+
+void destroy_login_window(struct session_401 *session)
+{
+ free(session->url);
+ free(session->host);
+ free(session->realm);
+ gtk_widget_destroy(GTK_WIDGET(session->wnd));
+ g_object_unref(G_OBJECT(session->x));
+ free(session);
+}
+
+void nsgtk_login_next(GtkWidget *w, gpointer data)
+{
+ gtk_widget_grab_focus(GTK_WIDGET(data));
+}
+
+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 = gtk_entry_get_text(session->user);
+ const gchar *pass = gtk_entry_get_text(session->pass);
+ char *auth;
+
+ auth = malloc(strlen(user) + strlen(pass) + 2);
+ sprintf(auth, "%s:%s", user, pass);
+ urldb_set_auth_details(session->url, session->realm, auth);
+ free(auth);
+
+ browser_window_go(session->bw, session->url, 0, true);
+
+ destroy_login_window(session);
+}
+
+void nsgtk_login_cancel_clicked(GtkButton *w, gpointer data)
+{
+ /* just close and destroy the window */
+ destroy_login_window((struct session_401 *)data);
+}
Modified: trunk/netsurf/gtk/netsurf.glade
URL: http://svn.semichrome.net/trunk/netsurf/gtk/netsurf.glade?rev=2817&r1=281...
==============================================================================
--- trunk/netsurf/gtk/netsurf.glade (original)
+++ trunk/netsurf/gtk/netsurf.glade Sun Aug 6 23:29:58 2006
@@ -2557,9 +2557,8 @@
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
- <widget class="GtkButton" id="cancelbutton2">
+ <widget class="GtkButton" id="buttonLoginCan">
<property name="visible">True</property>
- <property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
@@ -2570,15 +2569,16 @@
</child>
<child>
- <widget class="GtkButton" id="okbutton2">
+ <widget class="GtkButton" id="buttonLoginOK">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property>
- <property name="has_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
+ <signal name="clicked" handler="nsgtk_401login_apply" last_modification_time="Sun, 06 Aug 2006 20:48:22 GMT"/>
+ <signal name="clicked" handler="gtk_widget_hide" last_modification_time="Sun, 06 Aug 2006 20:48:32 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment14">
@@ -2658,6 +2658,7 @@
<child>
<widget class="GtkHBox" id="hbox12">
+ <property name="border_width">3</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
@@ -2668,8 +2669,8 @@
<property name="icon_size">6</property>
<property name="icon_name">gtk-dialog-authentication</property>
<property name="xalign">0.5</property>
- <property name="yalign">0</property>
- <property name="xpad">5</property>
+ <property name="yalign">0.10000000149</property>
+ <property name="xpad">12</property>
<property name="ypad">0</property>
</widget>
<packing>
@@ -2686,17 +2687,18 @@
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
- <property name="row_spacing">0</property>
- <property name="column_spacing">5</property>
+ <property name="row_spacing">10</property>
+ <property name="column_spacing">11</property>
<child>
- <widget class="GtkEntry" id="entry2">
+ <widget class="GtkEntry" id="entryLoginUser">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
+ <property name="text" translatable="yes">sesame</property>
<property name="has_frame">True</property>
<property name="invisible_char">â</property>
<property name="activates_default">False</property>
@@ -2711,16 +2713,16 @@
</child>
<child>
- <widget class="GtkEntry" id="entry3">
+ <widget class="GtkEntry" id="entryLoginPass">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
- <property name="visibility">True</property>
+ <property name="visibility">False</property>
<property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
+ <property name="text" translatable="yes">opensesame</property>
<property name="has_frame">True</property>
- <property name="invisible_char">â</property>
- <property name="activates_default">False</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -2732,7 +2734,7 @@
</child>
<child>
- <widget class="GtkLabel" id="label59">
+ <widget class="GtkLabel" id="labelLoginRealm">
<property name="visible">True</property>
<property name="label" translatable="yes">my sekr3t area</property>
<property name="use_underline">False</property>
@@ -2744,7 +2746,7 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_MIDDLE</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
@@ -2867,7 +2869,7 @@
</child>
<child>
- <widget class="GtkLabel" id="label58">
+ <widget class="GtkLabel" id="labelLoginHost">
<property name="visible">True</property>
<property name="label" translatable="yes">moo.yoo.com</property>
<property name="use_underline">False</property>
@@ -2879,7 +2881,7 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_MIDDLE</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
@@ -2894,7 +2896,7 @@
</child>
</widget>
<packing>
- <property name="padding">0</property>
+ <property name="padding">1</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
Modified: trunk/netsurf/makefile
URL: http://svn.semichrome.net/trunk/netsurf/makefile?rev=2817&r1=2816&r2=2817...
==============================================================================
--- trunk/netsurf/makefile (original)
+++ trunk/netsurf/makefile Sun Aug 6 23:29:58 2006
@@ -69,7 +69,7 @@
OBJECTS_GTK += font_pango.o gtk_bitmap.o gtk_gui.o \
gtk_schedule.o gtk_thumbnail.o gtk_options.o \
gtk_plotters.o gtk_treeview.o gtk_window.o \
- gtk_completion.o # gtk/
+ gtk_completion.o gtk_login.o # gtk/
OBJDIR_RISCOS = arm-riscos-aof
17 years, 3 months
r2816 jmb - /trunk/netsurf/content/fetchcache.c
by netsurf@semichrome.net
Author: jmb
Date: Sun Aug 6 18:51:23 2006
New Revision: 2816
URL: http://svn.semichrome.net?rev=2816&view=rev
Log:
Detect attempted fetches using protocols we can't handle.
Mark content in error in a couple of cases that I'd missed ages ago.
Modified:
trunk/netsurf/content/fetchcache.c
Modified: trunk/netsurf/content/fetchcache.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetchcache.c?rev=2816&r1=...
==============================================================================
--- trunk/netsurf/content/fetchcache.c (original)
+++ trunk/netsurf/content/fetchcache.c Sun Aug 6 18:51:23 2006
@@ -222,7 +222,39 @@
LOG(("url %s, status %s", content->url,
content_status_name[content->status]));
- if (content->status == CONTENT_STATUS_TYPE_UNKNOWN && content->fetch) {
+ /* We may well have been asked to fetch an URL using a protocol
+ * that we can't support. Check for this here and, if we can't
+ * perform the fetch, notify the caller and exit */
+ if (!fetch_can_fetch(content->url)) {
+
+ /* The only case where this should fail is if we're a
+ * brand new content with no active fetch. If we're not,
+ * another content with the same URL somehow got through
+ * the fetch_can_fetch check. That should be impossible.
+ */
+ assert(content->status == CONTENT_STATUS_TYPE_UNKNOWN &&
+ !content->fetch);
+
+ snprintf(error_message, sizeof error_message,
+ messages_get("InvalidURL"),
+ content->url);
+
+ if (content->no_error_pages) {
+ /* Mark as in error so content is destroyed
+ * on cache clean */
+ content->status = CONTENT_STATUS_ERROR;
+ msg_data.error = error_message;
+ callback(CONTENT_MSG_ERROR,
+ content, p1, p2, msg_data);
+ } else {
+ fetchcache_error_page(content, error_message);
+ }
+
+ return;
+ }
+
+ if (content->status == CONTENT_STATUS_TYPE_UNKNOWN &&
+ content->fetch) {
/* fetching, but not yet received any response:
* no action required */
@@ -236,7 +268,7 @@
content->cache_data->date = 0;
headers = malloc(3 * sizeof(char *));
if (!headers) {
- talloc_free(etag);
+ content->status = CONTENT_STATUS_ERROR;
msg_data.error = messages_get("NoMemory");
callback(CONTENT_MSG_ERROR, content, p1, p2,
msg_data);
@@ -246,7 +278,7 @@
headers[i] = malloc(15 + strlen(etag) + 1);
if (!headers[i]) {
free(headers);
- talloc_free(etag);
+ content->status = CONTENT_STATUS_ERROR;
msg_data.error = messages_get("NoMemory");
callback(CONTENT_MSG_ERROR, content, p1, p2,
msg_data);
@@ -262,6 +294,7 @@
free(headers[i]);
}
free(headers);
+ content->status = CONTENT_STATUS_ERROR;
msg_data.error = messages_get("NoMemory");
callback(CONTENT_MSG_ERROR, content, p1, p2,
msg_data);
@@ -318,7 +351,6 @@
/* shouldn't usually occur */
msg_data.error = messages_get("MiscError");
callback(CONTENT_MSG_ERROR, content, p1, p2, msg_data);
-
}
}
17 years, 3 months
r2815 adrianl - /trunk/netsurf/riscos/gui.c
by netsurf@semichrome.net
Author: adrianl
Date: Sun Aug 6 16:40:02 2006
New Revision: 2815
URL: http://svn.semichrome.net?rev=2815&view=rev
Log:
Save and restore FP registers for APCS compliance
Modified:
trunk/netsurf/riscos/gui.c
Modified: trunk/netsurf/riscos/gui.c
URL: http://svn.semichrome.net/trunk/netsurf/riscos/gui.c?rev=2815&r1=2814&r2=...
==============================================================================
--- trunk/netsurf/riscos/gui.c (original)
+++ trunk/netsurf/riscos/gui.c Sun Aug 6 16:40:02 2006
@@ -845,7 +845,7 @@
{
wimp_event_no event;
wimp_block block;
- const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN;
+ const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN | wimp_SAVE_FP;
/* Poll wimp. */
xhourglass_off();
@@ -968,7 +968,7 @@
return;
xhourglass_off();
- event = wimp_poll(wimp_MASK_LOSE | wimp_MASK_GAIN, &block, 0);
+ event = wimp_poll(wimp_MASK_LOSE | wimp_MASK_GAIN | wimp_SAVE_FP, &block, 0);
xhourglass_on();
gui_last_poll = clock();
17 years, 3 months
r2814 bursa - /trunk/netsurf/gtk/gtk_window.c
by netsurf@semichrome.net
Author: bursa
Date: Sun Aug 6 16:18:53 2006
New Revision: 2814
URL: http://svn.semichrome.net?rev=2814&view=rev
Log:
Do not send referer when Home button is used. Fix some compile warnings.
Modified:
trunk/netsurf/gtk/gtk_window.c
Modified: trunk/netsurf/gtk/gtk_window.c
URL: http://svn.semichrome.net/trunk/netsurf/gtk/gtk_window.c?rev=2814&r1=2813...
==============================================================================
--- trunk/netsurf/gtk/gtk_window.c (original)
+++ trunk/netsurf/gtk/gtk_window.c Sun Aug 6 16:18:53 2006
@@ -486,16 +486,12 @@
void nsgtk_window_home_button_clicked(GtkWidget *widget, gpointer data)
{
struct gui_window *g = data;
- char *referer = 0;
const char *addr = "http://netsurf.sourceforge.net/";
if (option_homepage_url != NULL)
addr = option_homepage_url;
- if (g->bw->current_content && g->bw->current_content->url)
- referer = g->bw->current_content->url;
-
- browser_window_go(g->bw, addr, referer, true);
+ browser_window_go(g->bw, addr, 0, true);
}
gboolean nsgtk_window_expose_event(GtkWidget *widget,
@@ -598,10 +594,11 @@
gboolean nsgtk_window_url_changed(GtkWidget *widget, GdkEventKey *event,
gpointer data)
{
- struct gui_window *g = data;
const char *prefix;
prefix = gtk_entry_get_text(GTK_ENTRY(widget));
nsgtk_completion_update(prefix);
+
+ return TRUE;
}
gboolean nsgtk_window_keypress_event(GtkWidget *widget,
17 years, 3 months