aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ephy-location-action.c86
-rw-r--r--src/ephy-notebook.c31
-rw-r--r--src/ephy-tab.c121
-rw-r--r--src/ephy-tab.h5
-rwxr-xr-xsrc/ephy-toolbar.c2
-rw-r--r--src/ephy-toolbar.h3
-rw-r--r--src/ephy-window.c33
7 files changed, 163 insertions, 118 deletions
diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c
index 1abf8c43b..773743bea 100644
--- a/src/ephy-location-action.c
+++ b/src/ephy-location-action.c
@@ -24,7 +24,6 @@
#include "ephy-location-action.h"
#include "ephy-location-entry.h"
#include "ephy-shell.h"
-#include "ephy-favicon-cache.h"
#include "ephy-completion-model.h"
#include "ephy-link.h"
#include "ephy-debug.h"
@@ -46,8 +45,7 @@ struct _EphyLocationActionPrivate
char *typed_address;
EphyNode *smart_bmks;
EphyBookmarks *bookmarks;
- char *icon;
- EphyFaviconCache *cache;
+ GdkPixbuf *icon;
char *lock_stock_id;
char *lock_tooltip;
guint editable : 1;
@@ -240,16 +238,8 @@ sync_icon (GtkAction *gaction,
EphyLocationAction *action = EPHY_LOCATION_ACTION (gaction);
EphyLocationActionPrivate *priv = action->priv;
EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (proxy);
- GdkPixbuf *pixbuf;
- pixbuf = ephy_favicon_cache_get (priv->cache, priv->icon);
-
- ephy_location_entry_set_favicon (entry, pixbuf);
-
- if (pixbuf != NULL)
- {
- g_object_unref (pixbuf);
- }
+ ephy_location_entry_set_favicon (entry, priv->icon);
}
static void
@@ -444,6 +434,7 @@ ephy_location_action_set_property (GObject *object,
GParamSpec *pspec)
{
EphyLocationAction *action = EPHY_LOCATION_ACTION (object);
+ EphyLocationActionPrivate *priv = action->priv;
switch (prop_id)
{
@@ -451,25 +442,28 @@ ephy_location_action_set_property (GObject *object,
ephy_location_action_set_address (action, g_value_get_string (value), NULL);
break;
case PROP_EDITABLE:
- action->priv->editable = g_value_get_boolean (value);
+ priv->editable = g_value_get_boolean (value);
break;
case PROP_ICON:
- g_free (action->priv->icon);
- action->priv->icon = g_value_dup_string (value);
+ if (priv->icon != NULL)
+ {
+ g_object_unref (priv->icon);
+ }
+ priv->icon = GDK_PIXBUF (g_value_dup_object (value));
break;
case PROP_LOCK_STOCK:
- g_free (action->priv->lock_stock_id);
- action->priv->lock_stock_id = g_value_dup_string (value);
+ g_free (priv->lock_stock_id);
+ priv->lock_stock_id = g_value_dup_string (value);
break;
case PROP_LOCK_TOOLTIP:
- g_free (action->priv->lock_tooltip);
- action->priv->lock_tooltip = g_value_dup_string (value);
+ g_free (priv->lock_tooltip);
+ priv->lock_tooltip = g_value_dup_string (value);
break;
case PROP_SHOW_LOCK:
- action->priv->show_lock = g_value_get_boolean (value);
+ priv->show_lock = g_value_get_boolean (value);
break;
case PROP_WINDOW:
- action->priv->window = EPHY_WINDOW (g_value_get_object (value));
+ priv->window = EPHY_WINDOW (g_value_get_object (value));
break;
}
}
@@ -481,6 +475,7 @@ ephy_location_action_get_property (GObject *object,
GParamSpec *pspec)
{
EphyLocationAction *action = EPHY_LOCATION_ACTION (object);
+ EphyLocationActionPrivate *priv = action->priv;
switch (prop_id)
{
@@ -488,19 +483,19 @@ ephy_location_action_get_property (GObject *object,
g_value_set_string (value, ephy_location_action_get_address (action));
break;
case PROP_EDITABLE:
- g_value_set_boolean (value, action->priv->editable);
+ g_value_set_boolean (value, priv->editable);
break;
case PROP_ICON:
- g_value_set_string (value, action->priv->icon);
+ g_value_set_object (value, priv->icon);
break;
case PROP_LOCK_STOCK:
- g_value_set_string (value, action->priv->lock_stock_id);
+ g_value_set_string (value, priv->lock_stock_id);
break;
case PROP_LOCK_TOOLTIP:
- g_value_set_string (value, action->priv->lock_tooltip);
+ g_value_set_string (value, priv->lock_tooltip);
break;
case PROP_SHOW_LOCK:
- g_value_set_boolean (value, action->priv->show_lock);
+ g_value_set_boolean (value, priv->show_lock);
break;
case PROP_WINDOW:
/* not readable */
@@ -551,11 +546,11 @@ ephy_location_action_class_init (EphyLocationActionClass *class)
g_object_class_install_property (object_class,
PROP_ICON,
- g_param_spec_string ("icon",
- "Icon",
- "The icon",
- NULL,
- G_PARAM_READWRITE));
+ g_param_spec_object ("icon",
+ "Icon",
+ "The icon",
+ GDK_TYPE_PIXBUF,
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_LOCK_STOCK,
@@ -700,32 +695,30 @@ actions_child_changed_cb (EphyNode *node,
static void
ephy_location_action_init (EphyLocationAction *action)
{
- action->priv = EPHY_LOCATION_ACTION_GET_PRIVATE (action);
+ EphyLocationActionPrivate *priv;
+
+ priv = action->priv = EPHY_LOCATION_ACTION_GET_PRIVATE (action);
- action->priv->address = g_strdup ("");
- action->priv->editable = TRUE;
- action->priv->bookmarks = ephy_shell_get_bookmarks (ephy_shell);
- action->priv->smart_bmks = ephy_bookmarks_get_smart_bookmarks
+ priv->address = g_strdup ("");
+ priv->editable = TRUE;
+ priv->bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+ priv->smart_bmks = ephy_bookmarks_get_smart_bookmarks
(action->priv->bookmarks);
init_actions_list (action);
- ephy_node_signal_connect_object (action->priv->smart_bmks,
+ ephy_node_signal_connect_object (priv->smart_bmks,
EPHY_NODE_CHILD_ADDED,
(EphyNodeCallback)actions_child_added_cb,
G_OBJECT (action));
- ephy_node_signal_connect_object (action->priv->smart_bmks,
+ ephy_node_signal_connect_object (priv->smart_bmks,
EPHY_NODE_CHILD_REMOVED,
(EphyNodeCallback)actions_child_removed_cb,
G_OBJECT (action));
- ephy_node_signal_connect_object (action->priv->smart_bmks,
+ ephy_node_signal_connect_object (priv->smart_bmks,
EPHY_NODE_CHILD_CHANGED,
(EphyNodeCallback)actions_child_changed_cb,
G_OBJECT (action));
-
- action->priv->cache = EPHY_FAVICON_CACHE
- (ephy_embed_shell_get_favicon_cache (embed_shell));
- g_object_ref (action->priv->cache);
}
static void
@@ -734,13 +727,16 @@ ephy_location_action_finalize (GObject *object)
EphyLocationAction *action = EPHY_LOCATION_ACTION (object);
EphyLocationActionPrivate *priv = action->priv;
+ if (priv->icon != NULL)
+ {
+ g_object_unref (priv->icon);
+ }
+
g_list_free (priv->actions);
g_free (priv->address);
g_free (priv->typed_address);
- g_free (priv->icon);
g_free (priv->lock_stock_id);
g_free (priv->lock_tooltip);
- g_object_unref (priv->cache);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index 6ca48217c..d2ec4691b 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -32,7 +32,6 @@
#include "ephy-embed.h"
#include "ephy-window.h"
#include "ephy-shell.h"
-#include "ephy-favicon-cache.h"
#include "ephy-spinner.h"
#include "ephy-link.h"
#include "ephy-debug.h"
@@ -864,32 +863,16 @@ sync_load_status (EphyTab *tab, GParamSpec *pspec, GtkWidget *proxy)
}
static void
-sync_icon (EphyTab *tab, GParamSpec *pspec, GtkWidget *proxy)
+sync_icon (EphyTab *tab,
+ GParamSpec *pspec,
+ GtkWidget *proxy)
{
- EphyFaviconCache *cache;
- GdkPixbuf *pixbuf = NULL;
- GtkImage *icon = NULL;
- const char *address;
-
- cache = EPHY_FAVICON_CACHE
- (ephy_embed_shell_get_favicon_cache (EPHY_EMBED_SHELL (ephy_shell)));
- address = ephy_tab_get_icon_address (tab);
-
- if (address)
- {
- pixbuf = ephy_favicon_cache_get (cache, address);
- }
+ GtkImage *icon;
icon = GTK_IMAGE (g_object_get_data (G_OBJECT (proxy), "icon"));
- if (icon)
- {
- gtk_image_set_from_pixbuf (icon, pixbuf);
- }
-
- if (pixbuf)
- {
- g_object_unref (pixbuf);
- }
+ g_return_if_fail (icon != NULL);
+
+ gtk_image_set_from_pixbuf (icon, ephy_tab_get_icon (tab));
}
static void
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 739ba5215..ae2f2dbbf 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -72,11 +72,12 @@ struct _EphyTabPrivate
{
char *status_message;
char *link_message;
- char *icon_address;
char *address;
char *typed_address;
char *title;
char *loading_title;
+ char *icon_address;
+ GdkPixbuf *icon;
int cur_requests;
int total_requests;
int width;
@@ -121,6 +122,7 @@ enum
PROP_ADDRESS,
PROP_DOCUMENT_TYPE,
PROP_ICON,
+ PROP_ICON_ADDRESS,
PROP_LOAD_PROGRESS,
PROP_LOAD_STATUS,
PROP_MESSAGE,
@@ -222,12 +224,12 @@ ephy_tab_set_property (GObject *object,
ephy_tab_set_typed_address (tab, g_value_get_string (value));
break;
case PROP_POPUPS_ALLOWED:
- ephy_tab_set_popups_allowed
- (tab, g_value_get_boolean (value));
+ ephy_tab_set_popups_allowed (tab, g_value_get_boolean (value));
break;
case PROP_ADDRESS:
case PROP_DOCUMENT_TYPE:
case PROP_ICON:
+ case PROP_ICON_ADDRESS:
case PROP_LOAD_PROGRESS:
case PROP_LOAD_STATUS:
case PROP_MESSAGE:
@@ -249,32 +251,36 @@ ephy_tab_get_property (GObject *object,
GParamSpec *pspec)
{
EphyTab *tab = EPHY_TAB (object);
+ EphyTabPrivate *priv = tab->priv;
switch (prop_id)
{
case PROP_ADDRESS:
- g_value_set_string (value, tab->priv->address);
+ g_value_set_string (value, priv->address);
break;
case PROP_DOCUMENT_TYPE:
- g_value_set_enum (value, tab->priv->document_type);
+ g_value_set_enum (value, priv->document_type);
break;
case PROP_ICON:
- g_value_set_string (value, tab->priv->icon_address);
+ g_value_set_object (value, priv->icon);
+ break;
+ case PROP_ICON_ADDRESS:
+ g_value_set_string (value, priv->icon_address);
break;
case PROP_LOAD_PROGRESS:
- g_value_set_int (value, tab->priv->load_percent);
+ g_value_set_int (value, priv->load_percent);
break;
case PROP_LOAD_STATUS:
- g_value_set_boolean (value, tab->priv->is_loading);
+ g_value_set_boolean (value, priv->is_loading);
break;
case PROP_MESSAGE:
g_value_set_string (value, ephy_tab_get_status_message (tab));
break;
case PROP_NAVIGATION:
- g_value_set_flags (value, tab->priv->nav_flags);
+ g_value_set_flags (value, priv->nav_flags);
break;
case PROP_SECURITY:
- g_value_set_enum (value, tab->priv->security_level);
+ g_value_set_enum (value, priv->security_level);
break;
case PROP_HIDDEN_POPUP_COUNT:
g_value_set_int (value, popup_blocker_n_hidden (tab));
@@ -284,16 +290,16 @@ ephy_tab_get_property (GObject *object,
(value, ephy_tab_get_popups_allowed (tab));
break;
case PROP_TITLE:
- g_value_set_string (value, tab->priv->title);
+ g_value_set_string (value, priv->title);
break;
case PROP_TYPED_ADDRESS:
g_value_set_string (value, ephy_tab_get_typed_address (tab));
break;
case PROP_VISIBLE:
- g_value_set_boolean (value, tab->priv->visibility);
+ g_value_set_boolean (value, priv->visibility);
break;
case PROP_ZOOM:
- g_value_set_float (value, tab->priv->zoom);
+ g_value_set_float (value, priv->zoom);
break;
}
}
@@ -397,8 +403,16 @@ ephy_tab_class_init (EphyTabClass *class)
G_PARAM_READABLE));
g_object_class_install_property (object_class,
- PROP_ICON,
- g_param_spec_string ("icon",
+ PROP_ICON_ADDRESS,
+ g_param_spec_object ("icon",
+ "Icon",
+ "The tab icon's",
+ GDK_TYPE_PIXBUF,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_ICON_ADDRESS,
+ g_param_spec_string ("icon-address",
"Icon address",
"The tab icon's address",
NULL,
@@ -808,6 +822,12 @@ ephy_tab_finalize (GObject *object)
EphyTab *tab = EPHY_TAB (object);
EphyTabPrivate *priv = tab->priv;
+ if (priv->icon != NULL)
+ {
+ g_object_unref (priv->icon);
+ priv->icon = NULL;
+ }
+
g_free (priv->title);
g_free (priv->address);
g_free (priv->icon_address);
@@ -1148,18 +1168,37 @@ ephy_tab_get_visibility (EphyTab *tab)
}
static void
+ephy_tab_load_icon (EphyTab *tab)
+{
+ EphyTabPrivate *priv = tab->priv;
+ EphyEmbedShell *shell;
+ EphyFaviconCache *cache;
+
+ if (priv->icon_address == NULL || priv->icon != NULL) return;
+
+ shell = ephy_embed_shell_get_default ();
+ cache = EPHY_FAVICON_CACHE (ephy_embed_shell_get_favicon_cache (shell));
+
+ /* ephy_favicon_cache_get returns a reference already */
+ priv->icon = ephy_favicon_cache_get (cache, priv->icon_address);
+
+ g_object_notify (G_OBJECT (tab), "icon");
+}
+
+static void
ephy_tab_icon_cache_changed_cb (EphyFaviconCache *cache,
const char *address,
EphyTab *tab)
{
+ EphyTabPrivate *priv = tab->priv;
+
g_return_if_fail (address != NULL);
/* is this for us? */
- if (tab->priv->icon_address != NULL &&
- strcmp (tab->priv->icon_address, address) == 0)
+ if (priv->icon_address != NULL &&
+ strcmp (priv->icon_address, address) == 0)
{
- /* notify */
- g_object_notify (G_OBJECT (tab), "icon");
+ ephy_tab_load_icon (tab);
}
}
@@ -1167,6 +1206,7 @@ static void
ephy_tab_set_icon_address (EphyTab *tab,
const char *address)
{
+ GObject *object = G_OBJECT (tab);
EphyTabPrivate *priv = tab->priv;
EphyBookmarks *eb;
EphyHistory *history;
@@ -1174,6 +1214,14 @@ ephy_tab_set_icon_address (EphyTab *tab,
g_free (priv->icon_address);
priv->icon_address = g_strdup (address);
+ if (priv->icon != NULL)
+ {
+ g_object_unref (priv->icon);
+ priv->icon = NULL;
+
+ g_object_notify (object, "icon");
+ }
+
if (priv->icon_address)
{
eb = ephy_shell_get_bookmarks (ephy_shell);
@@ -1183,9 +1231,11 @@ ephy_tab_set_icon_address (EphyTab *tab,
priv->icon_address);
ephy_history_set_icon (history, priv->address,
priv->icon_address);
+
+ ephy_tab_load_icon (tab);
}
- g_object_notify (G_OBJECT (tab), "icon");
+ g_object_notify (object, "icon-address");
}
static void
@@ -1337,12 +1387,33 @@ ephy_tab_update_file_monitor (EphyTab *tab,
}
/**
+ * ephy_tab_get_icon:
+ * @tab: an #EphyTab
+ *
+ * Returns the tab's site icon as a #GdkPixbuf,
+ * or %NULL if it is not available.
+ *
+ * Return value: a the tab's site icon
+ **/
+GdkPixbuf *
+ephy_tab_get_icon (EphyTab *tab)
+{
+ EphyTabPrivate *priv;
+
+ g_return_val_if_fail (EPHY_IS_TAB (tab), NULL);
+
+ priv = tab->priv;
+
+ return priv->icon;
+}
+
+/**
* ephy_tab_get_icon_address:
* @tab: an #EphyTab
*
- * Returns a URL which points to @tab's favicon.
+ * Returns a URL which points to @tab's site icon.
*
- * Return value: a URL to @tab's favicon
+ * Return value: the URL of @tab's site icon
**/
const char *
ephy_tab_get_icon_address (EphyTab *tab)
@@ -1962,6 +2033,12 @@ ephy_tab_init (EphyTab *tab)
tab->priv->zoom = 1.0;
priv->title = NULL;
priv->is_blank = TRUE;
+ priv->icon_address = NULL;
+ priv->icon = NULL;
+ priv->address = NULL;
+ priv->typed_address = NULL;
+ priv->title = NULL;
+ priv->loading_title = NULL;
embed = ephy_embed_factory_new_object (EPHY_TYPE_EMBED);
g_assert (embed != NULL);
diff --git a/src/ephy-tab.h b/src/ephy-tab.h
index 8b5c48c88..479a3b04c 100644
--- a/src/ephy-tab.h
+++ b/src/ephy-tab.h
@@ -24,6 +24,7 @@
#include "ephy-embed.h"
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtkbin.h>
G_BEGIN_DECLS
@@ -69,7 +70,9 @@ EphyTab *ephy_tab_for_embed (EphyEmbed *embed);
EphyEmbedDocumentType ephy_tab_get_document_type (EphyTab *tab);
-const char *ephy_tab_get_icon_address (EphyTab *tab);
+GdkPixbuf *ephy_tab_get_icon (EphyTab *tab);
+
+const char *ephy_tab_get_icon_address (EphyTab *tab);
gboolean ephy_tab_get_load_status (EphyTab *tab);
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index 1dea8471b..da6b9ac55 100755
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -377,7 +377,7 @@ ephy_toolbar_set_window (EphyToolbar *toolbar,
void
ephy_toolbar_set_favicon (EphyToolbar *toolbar,
- const char *icon)
+ GdkPixbuf *icon)
{
EphyToolbarPrivate *priv = toolbar->priv;
diff --git a/src/ephy-toolbar.h b/src/ephy-toolbar.h
index be9860c82..2c349c5c0 100644
--- a/src/ephy-toolbar.h
+++ b/src/ephy-toolbar.h
@@ -25,6 +25,7 @@
#include <glib.h>
#include <glib-object.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include "egg-editable-toolbar.h"
#include "ephy-window.h"
@@ -65,7 +66,7 @@ GType ephy_toolbar_get_type (void);
EphyToolbar *ephy_toolbar_new (EphyWindow *window);
void ephy_toolbar_set_favicon (EphyToolbar *toolbar,
- const char *icon);
+ GdkPixbuf *icon);
void ephy_toolbar_set_show_leave_fullscreen (EphyToolbar *toolbar,
gboolean show);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 7ab8cf956..949077ca3 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -49,7 +49,6 @@
#include "ephy-tabs-menu.h"
#include "ephy-stock-icons.h"
#include "ephy-extension.h"
-#include "ephy-favicon-cache.h"
#include "ephy-link.h"
#include "ephy-gui.h"
#include "ephy-notebook.h"
@@ -1193,33 +1192,19 @@ sync_tab_document_type (EphyTab *tab,
}
static void
-sync_tab_icon (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
+sync_tab_icon (EphyTab *tab,
+ GParamSpec *pspec,
+ EphyWindow *window)
{
- const char *address;
- EphyFaviconCache *cache;
- GdkPixbuf *pixbuf = NULL;
-
- if (window->priv->closing) return;
-
- cache = EPHY_FAVICON_CACHE
- (ephy_embed_shell_get_favicon_cache
- (EPHY_EMBED_SHELL (ephy_shell)));
-
- address = ephy_tab_get_icon_address (tab);
-
- if (address)
- {
- pixbuf = ephy_favicon_cache_get (cache, address);
- }
+ EphyWindowPrivate *priv = window->priv;
+ GdkPixbuf *icon;
- gtk_window_set_icon (GTK_WINDOW (window), pixbuf);
+ if (priv->closing) return;
- ephy_toolbar_set_favicon (window->priv->toolbar, address);
+ icon = ephy_tab_get_icon (tab);
- if (pixbuf)
- {
- g_object_unref (pixbuf);
- }
+ gtk_window_set_icon (GTK_WINDOW (window), icon);
+ ephy_toolbar_set_favicon (priv->toolbar, icon);
}
static void