summaryrefslogtreecommitdiff
path: root/gtk/window.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2012-02-21 20:54:31 +0000
committerVincent Sanders <vince@netsurf-browser.org>2012-02-21 20:54:31 +0000
commitea0c028cac3617d74e542577837631a2c1f6c69a (patch)
tree9f6925f74daccb894c2932c10e21b139eed87f65 /gtk/window.c
parent8e3e8f2ca101355c98d74cf535d2673f08f859a6 (diff)
downloadnetsurf-ea0c028cac3617d74e542577837631a2c1f6c69a.tar.gz
netsurf-ea0c028cac3617d74e542577837631a2c1f6c69a.tar.bz2
fix favicon display
svn path=/trunk/netsurf/; revision=13460
Diffstat (limited to 'gtk/window.c')
-rw-r--r--gtk/window.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/gtk/window.c b/gtk/window.c
index 1b4d4e0bb..068da6fa7 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -39,6 +39,8 @@
#include "gtk/plotters.h"
#include "gtk/schedule.h"
#include "gtk/tabs.h"
+#include "gtk/bitmap.h"
+#include "gtk/gdk.h"
#include "utils/log.h"
#include "utils/utils.h"
@@ -46,7 +48,7 @@ struct gui_window {
/** The gtk scaffold object containing menu, buttons, url bar, [tabs],
* drawing area, etc that may contain one or more gui_windows.
*/
- nsgtk_scaffolding *scaffold;
+ nsgtk_scaffolding *scaffold;
/** The 'content' window that is rendered in the gui_window */
struct browser_window *bw;
@@ -86,6 +88,9 @@ struct gui_window {
/** to allow disactivation / resume of normal window behaviour */
gulong signalhandler[NSGTK_WINDOW_SIGNAL_COUNT];
+ /** The icon this window should have */
+ GdkPixbuf *icon;
+
/** list for cleanup */
struct gui_window *next, *prev;
};
@@ -98,6 +103,11 @@ nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g)
return g->scaffold;
}
+GdkPixbuf *nsgtk_get_icon(struct gui_window *gw)
+{
+ return gw->icon;
+}
+
struct browser_window *nsgtk_get_browser_window(struct gui_window *g)
{
return g->bw;
@@ -692,17 +702,38 @@ void gui_window_destroy(struct gui_window *g)
/* tab => remove tab */
gtk_widget_destroy(gtk_widget_get_parent(GTK_WIDGET(g->layout)));
+}
- /* if it was the last tab, destroy scaffold too */
- if (gtk_notebook_get_n_pages(nsgtk_scaffolding_notebook(g->scaffold)) == 0) {
- nsgtk_scaffolding_destroy(g->scaffold);
+/**
+ * set favicon
+ */
+void gui_window_set_icon(struct gui_window *gw, hlcache_handle *icon)
+{
+ struct bitmap *icon_bitmap = NULL;
+
+ /* free any existing icon */
+ if (gw->icon != NULL) {
+ g_object_unref(gw->icon);
+ gw->icon = NULL;
}
- free(g);
+ if (icon != NULL) {
+ icon_bitmap = content_get_bitmap(icon);
+ if (icon_bitmap != NULL) {
+ LOG(("Using %p bitmap", icon_bitmap));
+ gw->icon = nsgdk_pixbuf_get_from_surface(icon_bitmap->surface, 16, 16);
+ }
+ }
+
+ if (gw->icon == NULL) {
+ LOG(("Using default favicon"));
+ g_object_ref(favicon_pixbuf);
+ gw->icon = favicon_pixbuf;
+ }
+ nsgtk_scaffolding_set_icon(gw);
}
-
static void nsgtk_redraw_caret(struct gui_window *g)
{
int sx, sy;