aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--lib/widgets/ephy-notebook.c35
-rw-r--r--lib/widgets/ephy-notebook.h4
-rw-r--r--src/ephy-tab.c71
-rw-r--r--src/ephy-tab.h3
-rw-r--r--src/ephy-window.c14
6 files changed, 117 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 6d7e2eaa6..81701b228 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+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
+
2003-04-01 Patanjali Somayaji <patanjali@codito.com>
* help/C/epiphany.xml:
diff --git a/lib/widgets/ephy-notebook.c b/lib/widgets/ephy-notebook.c
index 9a0a1278b..b2ee52b57 100644
--- a/lib/widgets/ephy-notebook.c
+++ b/lib/widgets/ephy-notebook.c
@@ -634,7 +634,7 @@ ephy_notebook_set_page_status (EphyNotebook *nb,
GtkWidget *child,
EphyNotebookPageLoadStatus status)
{
- GtkWidget *tab, *image;
+ GtkWidget *tab, *image, *icon;
g_return_if_fail (nb != NULL);
@@ -650,22 +650,48 @@ ephy_notebook_set_page_status (EphyNotebook *nb,
image = g_object_get_data (G_OBJECT (tab), "loading-image");
g_return_if_fail (image != NULL);
+
+ icon = g_object_get_data (G_OBJECT (tab), "icon");
+
+ g_return_if_fail (icon != NULL);
switch (status)
{
case EPHY_NOTEBOOK_TAB_LOAD_LOADING:
+ gtk_widget_hide (icon);
gtk_widget_show (image);
break;
case EPHY_NOTEBOOK_TAB_LOAD_COMPLETED:
case EPHY_NOTEBOOK_TAB_LOAD_NORMAL:
gtk_widget_hide (image);
+ gtk_widget_show (icon);
break;
}
nb->priv->current_status = status;
}
+void
+ephy_notebook_set_page_icon (EphyNotebook *nb,
+ GtkWidget *child,
+ GdkPixbuf *icon)
+{
+ GtkWidget *tab, *image;
+
+ g_return_if_fail (nb != NULL);
+
+ tab = gtk_notebook_get_tab_label (GTK_NOTEBOOK (nb), child);
+
+ g_return_if_fail (tab != NULL);
+
+ image = g_object_get_data (G_OBJECT (tab), "icon");
+
+ g_return_if_fail (image != NULL);
+
+ gtk_image_set_from_pixbuf (GTK_IMAGE (image), icon);
+}
+
static void
ephy_tab_close_button_clicked_cb (GtkWidget *widget,
GtkWidget *child)
@@ -683,7 +709,7 @@ tab_build_label (EphyNotebook *nb, GtkWidget *child)
int h, w;
GClosure *closure;
GtkWidget *window;
- GtkWidget *loading_image;
+ GtkWidget *loading_image, *icon;
GdkPixbufAnimation *loading_pixbuf;
window = gtk_widget_get_toplevel (GTK_WIDGET (nb));
@@ -710,6 +736,10 @@ tab_build_label (EphyNotebook *nb, GtkWidget *child)
g_object_unref (loading_pixbuf);
gtk_box_pack_start (GTK_BOX (hbox), loading_image, FALSE, FALSE, 0);
+ /* setup site icon, empty by default */
+ icon = gtk_image_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
+
/* setup label */
label = gtk_label_new (_("Untitled"));
gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.5);
@@ -742,6 +772,7 @@ tab_build_label (EphyNotebook *nb, GtkWidget *child)
g_object_set_data (G_OBJECT (hbox), "label", label);
g_object_set_data (G_OBJECT (hbox), "loading-image", loading_image);
+ g_object_set_data (G_OBJECT (hbox), "icon", icon);
return hbox;
}
diff --git a/lib/widgets/ephy-notebook.h b/lib/widgets/ephy-notebook.h
index 755eea84d..e90aa56b9 100644
--- a/lib/widgets/ephy-notebook.h
+++ b/lib/widgets/ephy-notebook.h
@@ -94,6 +94,10 @@ void ephy_notebook_set_page_title (EphyNotebook *nb,
GtkWidget *child,
const char *title);
+void ephy_notebook_set_page_icon (EphyNotebook *nb,
+ GtkWidget *child,
+ GdkPixbuf *icon);
+
G_END_DECLS;
#endif /* EPHY_NOTEBOOK_H */
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);