summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/gtk_gui.c8
-rw-r--r--gtk/gtk_plotters.c15
-rw-r--r--gtk/gtk_thumbnail.c91
-rw-r--r--gtk/gtk_window.c1
-rw-r--r--gtk/gtk_window.h3
5 files changed, 109 insertions, 9 deletions
diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c
index b258deb2d..eafb82ab5 100644
--- a/gtk/gtk_gui.c
+++ b/gtk/gtk_gui.c
@@ -215,14 +215,6 @@ void hotlist_visited(struct content *content)
}
-struct history *history_create(void) { return 0; }
-void history_add(struct history *history, struct content *content,
- char *frag_id) {}
-void history_update(struct history *history, struct content *content) {}
-void history_destroy(struct history *history) {}
-void history_back(struct browser_window *bw, struct history *history) {}
-void history_forward(struct browser_window *bw, struct history *history) {}
-
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,
diff --git a/gtk/gtk_plotters.c b/gtk/gtk_plotters.c
index 0a65c4ec9..ad761194f 100644
--- a/gtk/gtk_plotters.c
+++ b/gtk/gtk_plotters.c
@@ -40,13 +40,15 @@ static bool nsgtk_plot_bitmap_tile(int x, int y, int width, int height,
bool repeat_x, bool repeat_y);
static bool nsgtk_plot_group_start(const char *name);
static bool nsgtk_plot_group_end(void);
-
static void nsgtk_set_colour(colour c);
static void nsgtk_set_solid(void); /**< Set for drawing solid lines */
static void nsgtk_set_dotted(void); /**< Set for drawing dotted lines */
static void nsgtk_set_dashed(void); /**< Set for drawing dashed lines */
+void nsgtk_plot_set_scale(float s);
+float nsgtk_plot_get_scale(void);
static GdkRectangle cliprect;
+static float nsgtk_plot_scale = 1.0;
struct plotter_table plot;
@@ -386,3 +388,14 @@ void nsgtk_set_dashed()
GDK_CAP_BUTT, GDK_JOIN_MITER);
#endif
}
+
+void nsgtk_plot_set_scale(float s)
+{
+ nsgtk_plot_scale = s;
+}
+
+float nsgtk_plot_get_scale(void)
+{
+ return nsgtk_plot_scale;
+}
+
diff --git a/gtk/gtk_thumbnail.c b/gtk/gtk_thumbnail.c
new file mode 100644
index 000000000..0de132d2d
--- /dev/null
+++ b/gtk/gtk_thumbnail.c
@@ -0,0 +1,91 @@
+/*
+ * 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@rjek.com>
+ */
+
+/** \file
+ * Page thumbnail creation (implementation).
+ *
+ * Thumbnails are created by setting the current drawing contexts to the
+ * bitmap (a gdk pixbuf) we are passed, and plotting the page at a small
+ * scale.
+ */
+
+#include <assert.h>
+#include <gtk/gtk.h>
+#include "netsurf/content/content.h"
+#include "netsurf/content/url_store.h"
+#include "netsurf/desktop/plotters.h"
+#include "netsurf/desktop/browser.h"
+#include "netsurf/image/bitmap.h"
+#include "netsurf/render/font.h"
+#include "netsurf/utils/log.h"
+#include "netsurf/gtk/gtk_window.h"
+#include "netsurf/gtk/gtk_plotters.h"
+
+/**
+ * Create a thumbnail of a page.
+ *
+ * \param content content structure to thumbnail
+ * \param bitmap the bitmap to draw to
+ * \param url the URL the thumnail belongs to, or NULL
+ */
+bool thumbnail_create(struct content *content, struct bitmap *bitmap,
+ const char *url)
+{
+ GdkPixbuf *pixbuf = (GdkPixbuf *) 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;
+ GdkPixmap *pixmap = gdk_pixmap_new(NULL, width, height, depth);
+ GdkColor c = { 0, 65535, 65535, 65535 };
+ float scale = 1.0;
+
+ assert(content);
+ assert(bitmap);
+
+ gdk_drawable_set_colormap(pixmap, gdk_colormap_get_system());
+
+ /* set the plotting functions up */
+ plot = nsgtk_plotters;
+
+ if (content->width)
+ scale = (float)width / (float)content->width;
+ nsgtk_plot_set_scale(scale);
+
+ /* set to plot to pixmap */
+ current_drawable = pixmap;
+ current_gc = gdk_gc_new(current_drawable);
+#ifdef CAIRO_VERSION
+ current_cr = gdk_cairo_create(current_drawable);
+#endif
+
+ /* render the content */
+ content_redraw(content, 0, 0, width, height,
+ 0, 0, width, height, scale, 0xFFFFFF);
+
+ /* copy thumbnail to pixbuf we've been passed */
+ gdk_pixbuf_get_from_drawable(pixbuf, pixmap, NULL, 0, 0, 0, 0,
+ width, height);
+
+ /* As a debugging aid, try this to dump out a copy of the thumbnail as a PNG:
+ * gdk_pixbuf_save(pixbuf, "thumbnail.png", "png", NULL, NULL);
+ */
+
+ /* register the thumbnail with the URL */
+ if (url)
+ url_store_add_thumbnail(url, bitmap);
+
+ bitmap_modified(bitmap);
+
+ g_object_unref(current_gc);
+#ifdef CAIRO_VERSION
+ cairo_destroy(current_cr);
+#endif
+ g_object_unref(pixmap);
+
+ return true;
+}
+
diff --git a/gtk/gtk_window.c b/gtk/gtk_window.c
index 858d1336e..de3c21421 100644
--- a/gtk/gtk_window.c
+++ b/gtk/gtk_window.c
@@ -188,6 +188,7 @@ gboolean gui_window_expose_event(GtkWidget *widget,
#endif
plot = nsgtk_plotters;
+ nsgtk_plot_set_scale(1.0);
content_redraw(c, 0, 0,
widget->allocation.width,
diff --git a/gtk/gtk_window.h b/gtk/gtk_window.h
index 0ac1908d1..73e890f1e 100644
--- a/gtk/gtk_window.h
+++ b/gtk/gtk_window.h
@@ -15,3 +15,6 @@ extern GdkGC *current_gc;
extern cairo_t *current_cr;
#endif
+void nsgtk_plot_set_scale(float s);
+float nsgtk_plot_get_scale(void);
+