[PATCH] favicons in tabs
Juho Snellman <[email protected]>
| Newsgroups | gmane.comp.web.galeon.devel |
|---|---|
| Message-ID | <[email protected]> |
Attached patch restores support (Galeon 1.2 style) for showing favicons in tabs. The appearance (never show, always show, show if non-default icon) is configurable using a gconf variable. Since the the gconf key is already documented in README.ExtraPrefs, this shouldn't count as adding a new useless feature... ;-) One note on the implementation: changing the value of the gconf variable won't affect existing tabs, only ones created afterwards. -- Juho Snellman
favicon-2003-07-22.patch
(text/plain, 9.2 KB)
Index: galeon.schemas.in
===================================================================
RCS file: /cvs/gnome/galeon/galeon.schemas.in,v
retrieving revision 1.151
diff -u -r1.151 galeon.schemas.in
--- galeon.schemas.in 28 Jun 2003 20:51:52 -0000
+++ galeon.schemas.in 22 Jul 2003 01:32:41 -0000
@@ -436,6 +436,18 @@
</locale>
</schema>
<schema>
+ <key>/schemas/apps/galeon/UI/Tabs/favicons_in_tabs</key>
+ <applyto>/apps/galeon/UI/Tabs/favicons_in_tabs</applyto>
+ <owner>galeon</owner>
+ <type>int</type>
+ <default>0</default>
+ <locale name="C">
+ <short>Show favicons in tabs</short>
+ <long>Show favicons in tabs. Possible values are (0 don't show), 1 (show favicon or default icon), and 2 (show only favicons).
+ </long>
+ </locale>
+ </schema>
+ <schema>
<key>/schemas/apps/galeon/UI/Windows/show_toolbars_in_fullscreen</key>
<applyto>/apps/galeon/UI/Windows/show_toolbars_in_fullscreen</applyto>
<owner>galeon</owner>
Index: src/galeon-favicon.h
===================================================================
RCS file: /cvs/gnome/galeon/src/galeon-favicon.h,v
retrieving revision 1.2
diff -u -r1.2 galeon-favicon.h
--- src/galeon-favicon.h 20 May 2002 17:18:52 -0000 1.2
+++ src/galeon-favicon.h 22 Jul 2003 01:32:50 -0000
@@ -50,6 +50,12 @@
void (*changed) (GaleonFavicon *favicon);
} GaleonFaviconClass;
+typedef enum {
+ GALEON_FAVICON_NEVER_SHOW = 0,
+ GALEON_FAVICON_ALWAYS_SHOW = 1,
+ GALEON_FAVICON_NON_DEFAULT_SHOW = 2
+} GaleonFaviconMode;
+
GType galeon_favicon_get_type (void);
GtkWidget *galeon_favicon_new (const char *url);
@@ -58,6 +64,9 @@
const char *url);
const char *galeon_favicon_get_url (GaleonFavicon *favicon);
+
+void galeon_favicon_set_mode (GaleonFavicon *favicon,
+ GaleonFaviconMode mode);
G_END_DECLS
Index: src/galeon-tab.c
===================================================================
RCS file: /cvs/gnome/galeon/src/galeon-tab.c,v
retrieving revision 1.96
diff -u -r1.96 galeon-tab.c
--- src/galeon-tab.c 8 Jul 2003 20:36:34 -0000 1.96
+++ src/galeon-tab.c 22 Jul 2003 01:32:51 -0000
@@ -37,6 +37,7 @@
#include "galeon-embed-manual-scroller.h"
#include "gul-download.h"
#include "gul-gestures.h"
+#include "galeon-embed-favicon.h"
#include <bonobo/bonobo-i18n.h>
#include <libgnomevfs/gnome-vfs-uri.h>
@@ -55,6 +56,7 @@
{
GaleonEmbed *embed;
GaleonWindow *window;
+ GtkWidget *icon;
gboolean is_active;
gboolean closing;
TabLoadStatus load_status;
@@ -212,35 +214,6 @@
}
static void
-galeon_tab_favicon_cb (GaleonEmbed *embed, const char *favicon_url,
- GaleonTab *tab)
-{
- char *url1 = NULL, *url2 = NULL;
- gboolean download;
- gresult result;
-
- result = galeon_embed_get_location (embed, TRUE, FALSE, &url1);
- if (result != G_OK) return;
-
- result = galeon_embed_get_location (embed, TRUE, TRUE, &url2);
- if (result != G_OK) goto out;
-
- download = (url1 != NULL && url2 != NULL && strcmp (url1, url2) == 0);
- if (download)
- {
- GaleonFaviconCache *cache;
- cache = galeon_shell_get_favicon_cache (galeon_shell);
- galeon_favicon_cache_insert_from_url (cache,
- url1,
- favicon_url);
- }
-
-out:
- g_free (url1);
- g_free (url2);
-}
-
-static void
galeon_tab_init (GaleonTab *tab)
{
GObject *embed, *embed_widget;
@@ -251,7 +224,7 @@
shell = galeon_shell_get_embed_shell (galeon_shell);
tab->priv->embed = galeon_embed_new (G_OBJECT(shell));
-
+ tab->priv->icon = galeon_embed_favicon_new (tab->priv->embed);
tab->priv->window = NULL;
tab->priv->is_active = FALSE;
tab->priv->link_message = g_strdup ("");
@@ -269,7 +242,7 @@
embed = G_OBJECT (tab->priv->embed);
embed_widget = G_OBJECT (tab->priv->embed);
-
+
/* set a pointer in the embed's widget back to the tab */
g_object_set_data (embed_widget, "GaleonTab", tab);
@@ -327,9 +300,6 @@
g_signal_connect (embed, "ge_security_change",
GTK_SIGNAL_FUNC (galeon_tab_security_change_cb),
tab);
- g_signal_connect (embed, "ge_favicon",
- G_CALLBACK (galeon_tab_favicon_cb),
- tab);
g_signal_connect(embed, "ge_popupblocked",
G_CALLBACK(galeon_tab_popup_blocked_cb),
tab);
@@ -404,6 +374,13 @@
g_return_val_if_fail (IS_GALEON_TAB (G_OBJECT (tab)), NULL);
return tab->priv->embed;
+}
+
+
+GtkWidget *
+galeon_tab_get_icon (GaleonTab *tab)
+{
+ return tab->priv->icon;
}
void
Index: src/galeon-tab.h
===================================================================
RCS file: /cvs/gnome/galeon/src/galeon-tab.h,v
retrieving revision 1.20
diff -u -r1.20 galeon-tab.h
--- src/galeon-tab.h 8 Jul 2003 20:36:34 -0000 1.20
+++ src/galeon-tab.h 22 Jul 2003 01:32:52 -0000
@@ -72,6 +72,9 @@
GaleonEmbed *galeon_tab_get_embed (GaleonTab *tab);
+
+GtkWidget *galeon_tab_get_icon (GaleonTab *tab);
+
void galeon_tab_set_window (GaleonTab *tab,
GaleonWindow *window);
Index: src/galeon-window.c
===================================================================
RCS file: /cvs/gnome/galeon/src/galeon-window.c,v
retrieving revision 1.173
diff -u -r1.173 galeon-window.c
--- src/galeon-window.c 12 Jul 2003 17:51:46 -0000 1.173
+++ src/galeon-window.c 22 Jul 2003 01:32:55 -0000
@@ -45,6 +46,7 @@
#include "bookmarks-editor-dockable.h"
#include "window-recent-history-menu.h"
#include "galeon-embed-prefs.h"
+#include "galeon-favicon.h"
#include <stdlib.h>
#include <string.h>
@@ -1354,6 +1377,7 @@
gboolean jump_to)
{
GtkWidget *widget;
+ GtkWidget *icon;
g_return_if_fail (IS_GALEON_WINDOW (window));
g_return_if_fail (IS_GALEON_TAB (tab));
@@ -1361,9 +1385,12 @@
galeon_tab_set_window (tab, window);
widget = GTK_WIDGET(galeon_tab_get_embed (tab));
-
+ icon = galeon_tab_get_icon(tab);
+ galeon_favicon_set_mode(GALEON_FAVICON(icon),
+ eel_gconf_get_integer (CONF_TABS_FAVICON));
+
gul_notebook_insert_page (GUL_NOTEBOOK (window->priv->notebook),
- widget,
+ widget, icon,
GUL_NOTEBOOK_INSERT_GROUPED,
jump_to);
}
Index: utils/gul-notebook.c
===================================================================
RCS file: /cvs/gnome/galeon/utils/gul-notebook.c,v
retrieving revision 1.25
diff -u -r1.25 gul-notebook.c
--- utils/gul-notebook.c 6 Jul 2003 10:47:34 -0000 1.25
+++ utils/gul-notebook.c 22 Jul 2003 01:33:00 -0000
@@ -335,7 +335,7 @@
g_object_ref (G_OBJECT (tab_label));
g_object_ref (G_OBJECT (menu_label));
gul_notebook_remove_page (GUL_NOTEBOOK (src), src_page);
- gul_notebook_insert_page (GUL_NOTEBOOK (dest), src_page,
+ gul_notebook_insert_page (GUL_NOTEBOOK (dest), src_page, NULL,
dest_page, TRUE);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (dest), src_page, tab_label);
gtk_notebook_set_menu_label (GTK_NOTEBOOK (dest), src_page, menu_label);
@@ -654,20 +654,23 @@
}
static GtkWidget *
-tab_build_label (GulNotebook *nb, GtkWidget *child)
+tab_build_label (GulNotebook *nb, GtkWidget *child, GtkWidget *icon)
{
GtkWidget *label, *hbox, *close_button, *image;
GtkRequisition size;
GtkRcStyle *rcstyle;
GClosure *closure;
GtkWidget *window;
-
+
window = gtk_widget_get_toplevel (GTK_WIDGET (nb));
/* set hbox spacing and label padding (see below) so that there's an
* equal amount of space around the label */
hbox = gtk_hbox_new (FALSE, 4);
+ if (icon != NULL)
+ gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
+
/* setup close button, zero out {x,y}thickness to get smallest possible
* size */
close_button = gtk_button_new ();
@@ -719,6 +722,7 @@
gtk_widget_show (hbox);
gtk_widget_show (label);
gtk_widget_show (image);
+ gtk_widget_show (icon);
gtk_widget_show (close_button);
g_object_set_data (G_OBJECT (hbox), "label", label);
@@ -749,13 +753,14 @@
void
gul_notebook_insert_page (GulNotebook *nb,
GtkWidget *child,
+ GtkWidget *icon,
int position,
gboolean jump_to)
{
GtkWidget *tab_hbox;
GtkWidget *label;
- tab_hbox = tab_build_label (nb, child);
+ tab_hbox = tab_build_label (nb, child, icon);
update_tabs_visibility (nb, TRUE);
Index: utils/gul-notebook.h
===================================================================
RCS file: /cvs/gnome/galeon/utils/gul-notebook.h,v
retrieving revision 1.8
diff -u -r1.8 gul-notebook.h
--- utils/gul-notebook.h 6 Feb 2003 16:24:38 -0000 1.8
+++ utils/gul-notebook.h 22 Jul 2003 01:33:00 -0000
@@ -68,6 +68,7 @@
void gul_notebook_insert_page (GulNotebook *nb,
GtkWidget *child,
+ GtkWidget *icon,
int position,
gboolean jump_to);
Index: utils/prefs-strings.h
===================================================================
RCS file: /cvs/gnome/galeon/utils/prefs-strings.h,v
retrieving revision 1.24
diff -u -r1.24 prefs-strings.h
--- utils/prefs-strings.h 28 Jun 2003 19:14:13 -0000 1.24
+++ utils/prefs-strings.h 22 Jul 2003 01:33:01 -0000
@@ -31,6 +31,7 @@
#define CONF_TABS_TABBED_NEW_COLOR "/apps/galeon/UI/Tabs/tabbed_new_color"
#define CONF_TABS_TABBED_ALWAYS_SHOW "/apps/galeon/UI/Tabs/tabbed_always_show"
#define CONF_TABS_TABBED_EDGE "/apps/galeon/UI/Tabs/tabbed_position"
+#define CONF_TABS_FAVICON "/apps/galeon/UI/Tabs/favicons_in_tabs"
/* Window appeareance */
#define CONF_WINDOWS_SIDEBAR_PAGE "/apps/galeon/UI/Windows/sidebar_page"