mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-23 14:59:47 +03:00
fix favicon display
svn path=/trunk/netsurf/; revision=13460
This commit is contained in:
parent
8e3e8f2ca1
commit
ea0c028cac
@ -494,7 +494,7 @@ static gboolean nsgtk_window_tool_bar_clicked(GtkToolbar *toolbar,
|
||||
/**
|
||||
* Update the menus when the number of tabs changes.
|
||||
*/
|
||||
static void nsgtk_window_tabs_num_changed(GtkNotebook *notebook,
|
||||
static void nsgtk_window_tabs_add(GtkNotebook *notebook,
|
||||
GtkWidget *page, guint page_num, struct gtk_scaffolding *g)
|
||||
{
|
||||
gboolean visible = gtk_notebook_get_show_tabs(g->notebook);
|
||||
@ -506,6 +506,26 @@ static void nsgtk_window_tabs_num_changed(GtkNotebook *notebook,
|
||||
nsgtk_scaffolding_set_sensitivity(g);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the menus when the number of tabs changes.
|
||||
*/
|
||||
static void nsgtk_window_tabs_remove(GtkNotebook *notebook,
|
||||
GtkWidget *page, guint page_num, struct gtk_scaffolding *g)
|
||||
{
|
||||
|
||||
if (gtk_notebook_get_n_pages(notebook) == 0) {
|
||||
nsgtk_scaffolding_destroy(g);
|
||||
} else {
|
||||
gboolean visible = gtk_notebook_get_show_tabs(g->notebook);
|
||||
g_object_set(g->menu_bar->view_submenu->tabs_menuitem, "visible", visible, NULL);
|
||||
g_object_set(g->menu_popup->view_submenu->tabs_menuitem, "visible", visible, NULL);
|
||||
g->buttons[NEXTTAB_BUTTON]->sensitivity = visible;
|
||||
g->buttons[PREVTAB_BUTTON]->sensitivity = visible;
|
||||
g->buttons[CLOSETAB_BUTTON]->sensitivity = visible;
|
||||
nsgtk_scaffolding_set_sensitivity(g);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle opening a file path.
|
||||
*/
|
||||
@ -1844,9 +1864,9 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
|
||||
gtk_widget_hide_on_delete, NULL);
|
||||
|
||||
g_signal_connect_after(g->notebook, "page-added",
|
||||
G_CALLBACK(nsgtk_window_tabs_num_changed), g);
|
||||
G_CALLBACK(nsgtk_window_tabs_add), g);
|
||||
g_signal_connect_after(g->notebook, "page-removed",
|
||||
G_CALLBACK(nsgtk_window_tabs_num_changed), g);
|
||||
G_CALLBACK(nsgtk_window_tabs_remove), g);
|
||||
|
||||
/* connect signals to handlers. */
|
||||
CONNECT(g->window, "delete-event", nsgtk_window_delete_event, g);
|
||||
@ -1935,13 +1955,9 @@ void gui_window_set_title(struct gui_window *_g, const char *title)
|
||||
nsgtk_tab_set_title(_g, title);
|
||||
|
||||
if (g->top_level == _g) {
|
||||
if (title == NULL || title[0] == '\0')
|
||||
{
|
||||
if (title == NULL || title[0] == '\0') {
|
||||
gtk_window_set_title(g->window, "NetSurf");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
strcpy(nt, title);
|
||||
strcat(nt, suffix);
|
||||
gtk_window_set_title(g->window, nt);
|
||||
@ -1994,42 +2010,23 @@ void gui_window_stop_throbber(struct gui_window* _g)
|
||||
/**
|
||||
* set favicon
|
||||
*/
|
||||
void gui_window_set_icon(struct gui_window *_g, hlcache_handle *icon)
|
||||
void
|
||||
nsgtk_scaffolding_set_icon(struct gui_window *gw)
|
||||
{
|
||||
struct gtk_scaffolding *g = nsgtk_get_scaffold(_g);
|
||||
struct bitmap *icon_bitmap = NULL;
|
||||
GdkPixbuf *icon_pixbuf = NULL;
|
||||
struct gtk_scaffolding *sc = nsgtk_get_scaffold(gw);
|
||||
GdkPixbuf *icon_pixbuf = nsgtk_get_icon(gw);
|
||||
|
||||
if (g->top_level != _g) {
|
||||
/* check icon needs to be shown */
|
||||
if ((icon_pixbuf == NULL) ||
|
||||
(sc->top_level != gw)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (icon != NULL) {
|
||||
icon_bitmap = content_get_bitmap(icon);
|
||||
if (icon_bitmap != NULL) {
|
||||
LOG(("Using %p bitmap", icon_bitmap));
|
||||
icon_pixbuf = nsgdk_pixbuf_get_from_surface(icon_bitmap->surface, 16, 16);
|
||||
}
|
||||
}
|
||||
|
||||
if (icon_pixbuf == NULL) {
|
||||
LOG(("Using default favicon"));
|
||||
g_object_ref(favicon_pixbuf);
|
||||
icon_pixbuf = favicon_pixbuf;
|
||||
}
|
||||
|
||||
if (icon_pixbuf == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsgtk_entry_set_icon_from_pixbuf(g->url_bar,
|
||||
nsgtk_entry_set_icon_from_pixbuf(sc->url_bar,
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
icon_pixbuf);
|
||||
|
||||
gtk_widget_show_all(GTK_WIDGET(g->buttons[URL_BAR_ITEM]->button));
|
||||
|
||||
g_object_unref(icon_pixbuf);
|
||||
|
||||
gtk_widget_show_all(GTK_WIDGET(sc->buttons[URL_BAR_ITEM]->button));
|
||||
}
|
||||
|
||||
void gui_window_set_search_ico(hlcache_handle *ico)
|
||||
@ -2224,15 +2221,25 @@ struct gui_window *nsgtk_scaffolding_top_level(nsgtk_scaffolding *g)
|
||||
return g->top_level;
|
||||
}
|
||||
|
||||
void nsgtk_scaffolding_set_top_level (struct gui_window *gw)
|
||||
/* set the current active top level gui window */
|
||||
void nsgtk_scaffolding_set_top_level(struct gui_window *gw)
|
||||
{
|
||||
nsgtk_get_scaffold(gw)->top_level = gw;
|
||||
struct browser_window *bw = nsgtk_get_browser_window(gw);
|
||||
struct browser_window *bw;
|
||||
nsgtk_scaffolding *sc;
|
||||
|
||||
assert(gw != NULL);
|
||||
|
||||
bw = nsgtk_get_browser_window(gw);
|
||||
|
||||
assert(bw != NULL);
|
||||
|
||||
sc = nsgtk_get_scaffold(gw);
|
||||
assert(sc != NULL);
|
||||
|
||||
sc->top_level = gw;
|
||||
|
||||
/* Synchronise the history (will also update the URL bar) */
|
||||
nsgtk_window_update_back_forward(nsgtk_get_scaffold(gw));
|
||||
nsgtk_window_update_back_forward(sc);
|
||||
|
||||
/* clear effects of potential searches */
|
||||
browser_window_search_destroy_context(bw);
|
||||
@ -2240,6 +2247,8 @@ void nsgtk_scaffolding_set_top_level (struct gui_window *gw)
|
||||
nsgtk_search_set_forward_state(true, bw);
|
||||
nsgtk_search_set_back_state(true, bw);
|
||||
|
||||
nsgtk_scaffolding_set_icon(gw);
|
||||
|
||||
/* Ensure the window's title bar is updated */
|
||||
if (bw->current_content != NULL) {
|
||||
gui_window_set_title(gw, content_get_title(bw->current_content));
|
||||
|
@ -150,6 +150,7 @@ void nsgtk_scaffolding_popup_menu(struct gtk_scaffolding *g, gdouble x,
|
||||
gdouble y);
|
||||
void nsgtk_scaffolding_toolbar_size_allocate(GtkWidget *widget,
|
||||
GtkAllocation *alloc, gpointer data);
|
||||
void nsgtk_scaffolding_set_icon(struct gui_window *gw);
|
||||
|
||||
gboolean nsgtk_window_url_activate_event(GtkWidget *, gpointer);
|
||||
gboolean nsgtk_window_url_changed(GtkWidget *, GdkEventKey *, gpointer);
|
||||
|
14
gtk/tabs.c
14
gtk/tabs.c
@ -111,17 +111,9 @@ static void nsgtk_tab_page_changed(GtkNotebook *notebook, gpointer *page,
|
||||
GtkWidget *window = gtk_notebook_get_nth_page(notebook, page_num);
|
||||
struct gui_window *gw = g_object_get_data(G_OBJECT(window),
|
||||
"gui_window");
|
||||
if (gw == NULL)
|
||||
return;
|
||||
struct browser_window *bw = nsgtk_get_browser_window(gw);
|
||||
if (bw == NULL)
|
||||
return;
|
||||
|
||||
browser_window_search_destroy_context(bw);
|
||||
|
||||
nsgtk_search_set_forward_state(true, bw);
|
||||
nsgtk_search_set_back_state(true, bw);
|
||||
nsgtk_scaffolding_set_top_level(gw);
|
||||
if (gw != NULL) {
|
||||
nsgtk_scaffolding_set_top_level(gw);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
49
gtk/window.c
49
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,16 +702,37 @@ 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);
|
||||
}
|
||||
|
||||
free(g);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -36,6 +36,7 @@ extern int temp_open_background;
|
||||
|
||||
struct browser_window *nsgtk_get_browser_window(struct gui_window *g);
|
||||
nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g);
|
||||
GdkPixbuf *nsgtk_get_icon(struct gui_window *gw);
|
||||
void nsgtk_reflow_all_windows(void);
|
||||
void nsgtk_window_process_reformats(void);
|
||||
float nsgtk_get_scale_for_gui(struct gui_window *g);
|
||||
|
Loading…
Reference in New Issue
Block a user