aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Persch <chpe@stud.uni-saarland.de>2003-04-01 19:55:41 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-04-01 19:55:41 +0800
commit6c25765d7c82c5b529746a5f75322473e8484a65 (patch)
treea2e6cfcd168e05ac0eabeb8f6a50ace9acaf662a /src
parentfe94f37cfdbeab550953efbe89cafedbafbaff51 (diff)
downloadgsoc2013-epiphany-6c25765d7c82c5b529746a5f75322473e8484a65.tar
gsoc2013-epiphany-6c25765d7c82c5b529746a5f75322473e8484a65.tar.gz
gsoc2013-epiphany-6c25765d7c82c5b529746a5f75322473e8484a65.tar.bz2
gsoc2013-epiphany-6c25765d7c82c5b529746a5f75322473e8484a65.tar.lz
gsoc2013-epiphany-6c25765d7c82c5b529746a5f75322473e8484a65.tar.xz
gsoc2013-epiphany-6c25765d7c82c5b529746a5f75322473e8484a65.tar.zst
gsoc2013-epiphany-6c25765d7c82c5b529746a5f75322473e8484a65.zip
Show favicons on tabs
2003-04-01 Christian Persch <chpe@stud.uni-saarland.de> * lib/widgets/ephy-notebook.c: (ephy_notebook_set_page_status), (ephy_notebook_set_page_icon), (tab_build_label): * lib/widgets/ephy-notebook.h: * src/ephy-tab.c: (ephy_tab_init), (ephy_tab_set_favicon), (ephy_tab_favicon_cache_changed_cb), (ephy_tab_favicon_cb), (ephy_tab_location_cb): * src/ephy-tab.h: * src/ephy-window.c: (ephy_window_init): Show favicons on tabs
Diffstat (limited to 'src')
-rw-r--r--src/ephy-tab.c71
-rw-r--r--src/ephy-tab.h3
-rw-r--r--src/ephy-window.c14
3 files changed, 67 insertions, 21 deletions
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index fa7756369..0e7213c26 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -81,6 +81,10 @@ ephy_tab_favicon_cb (EphyEmbed *embed,
const char *url,
EphyTab *tab);
static void
+ephy_tab_favicon_cache_changed_cb (EphyFaviconCache *cache,
+ char *url,
+ EphyTab *tab);
+static void
ephy_tab_link_message_cb (EphyEmbed *embed,
const char *message,
EphyTab *tab);
@@ -187,6 +191,7 @@ ephy_tab_init (EphyTab *tab)
{
GObject *embed, *embed_widget;
EphyEmbedSingle *single;
+ EphyFaviconCache *cache;
single = ephy_embed_shell_get_embed_single
(EPHY_EMBED_SHELL (ephy_shell));
@@ -267,6 +272,11 @@ ephy_tab_init (EphyTab *tab)
g_signal_connect (embed, "ge_favicon",
GTK_SIGNAL_FUNC (ephy_tab_favicon_cb),
tab);
+
+ cache = ephy_embed_shell_get_favicon_cache (EPHY_EMBED_SHELL (ephy_shell));
+ g_signal_connect_object (G_OBJECT (cache), "changed",
+ G_CALLBACK (ephy_tab_favicon_cache_changed_cb),
+ tab, 0);
}
/* Destructor */
@@ -437,25 +447,70 @@ ephy_tab_set_visibility (EphyTab *tab,
tab->priv->visibility = visible;
}
+void
+ephy_tab_set_favicon (EphyTab *tab,
+ GdkPixbuf *favicon)
+{
+ GtkWidget *nb;
+ EphyBookmarks *eb;
+
+ nb = ephy_window_get_notebook (tab->priv->window);
+ ephy_notebook_set_page_icon (EPHY_NOTEBOOK (nb),
+ GTK_WIDGET (tab->priv->embed),
+ favicon);
+
+ if (!tab->priv->is_active) return;
+
+ eb = ephy_shell_get_bookmarks (ephy_shell);
+ ephy_bookmarks_set_icon (eb, tab->priv->location,
+ tab->priv->favicon_url);
+ ephy_window_update_control (tab->priv->window,
+ FaviconControl);
+}
+
/* Private callbacks for embed signals */
static void
+ephy_tab_favicon_cache_changed_cb (EphyFaviconCache *cache,
+ char *url,
+ EphyTab *tab)
+{
+ GdkPixbuf *pixbuf = NULL;
+
+ /* is this for us? */
+ if (strncmp (tab->priv->favicon_url, url, 255) != 0) return;
+
+ /* set favicon */
+ pixbuf = ephy_favicon_cache_get (cache, tab->priv->favicon_url);
+ ephy_tab_set_favicon (tab, pixbuf);
+
+ if (pixbuf) g_object_unref (pixbuf);
+}
+
+static void
ephy_tab_favicon_cb (EphyEmbed *embed,
const char *url,
EphyTab *tab)
{
- EphyBookmarks *eb;
+ EphyFaviconCache *cache;
+ GdkPixbuf *pixbuf = NULL;
g_strlcpy (tab->priv->favicon_url,
url, 255);
- if (!tab->priv->is_active) return;
+ cache = ephy_embed_shell_get_favicon_cache
+ (EPHY_EMBED_SHELL (ephy_shell));
- eb = ephy_shell_get_bookmarks (ephy_shell);
- ephy_bookmarks_set_icon (eb, tab->priv->location,
- tab->priv->favicon_url);
- ephy_window_update_control (tab->priv->window,
- FaviconControl);
+ if (url && url[0] != '\0')
+ {
+ pixbuf = ephy_favicon_cache_get (cache, tab->priv->favicon_url);
+ ephy_tab_set_favicon (tab, pixbuf);
+ if (pixbuf) g_object_unref (pixbuf);
+ }
+ else
+ {
+ ephy_tab_set_favicon (tab, NULL);
+ }
}
static void
@@ -479,7 +534,9 @@ ephy_tab_location_cb (EphyEmbed *embed, EphyTab *tab)
ephy_embed_get_location (embed, TRUE,
&tab->priv->location);
tab->priv->link_message[0] = '\0';
+
tab->priv->favicon_url[0] = '\0';
+ ephy_tab_set_favicon (tab, NULL);
if (tab->priv->is_active)
{
diff --git a/src/ephy-tab.h b/src/ephy-tab.h
index 82f6d16a6..a2f162458 100644
--- a/src/ephy-tab.h
+++ b/src/ephy-tab.h
@@ -95,6 +95,9 @@ const char *ephy_tab_get_favicon_url (EphyTab *tab);
void ephy_tab_set_location (EphyTab *tab,
char *location);
+void ephy_tab_set_favicon (EphyTab *tab,
+ GdkPixbuf *favicon);
+
void ephy_tab_get_size (EphyTab *tab,
int *width,
int *height);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index c66d1f6ed..e3a60f6a4 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -489,16 +489,9 @@ setup_notebook (EphyWindow *window)
}
static void
-favicon_cache_changed_cb (EphyFaviconCache *cache, char *url, EphyWindow *window)
-{
- ephy_window_update_control (window, FaviconControl);
-}
-
-static void
ephy_window_init (EphyWindow *window)
{
Session *session;
- EphyFaviconCache *cache;
session = ephy_shell_get_session (ephy_shell);
@@ -509,13 +502,6 @@ ephy_window_init (EphyWindow *window)
window->priv->ppview_toolbar = NULL;
window->priv->toolbars = NULL;
- cache = ephy_embed_shell_get_favicon_cache (EPHY_EMBED_SHELL (ephy_shell));
- g_signal_connect_object (G_OBJECT (cache),
- "changed",
- G_CALLBACK (favicon_cache_changed_cb),
- window,
- 0);
-
/* Setup the window and connect verbs */
setup_window (window);