aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ephy-notebook.c2
-rw-r--r--src/ephy-shell.c1
-rw-r--r--src/ephy-tab.c702
-rw-r--r--src/ephy-tab.h62
-rw-r--r--src/ephy-tabs-menu.c249
-rw-r--r--src/ephy-tabs-menu.h2
-rw-r--r--src/ephy-window.c2
-rwxr-xr-xsrc/toolbar.c2
-rw-r--r--src/window-commands.c2
9 files changed, 625 insertions, 399 deletions
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index e360b8bd9..1671126dd 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -1061,6 +1061,4 @@ ephy_notebook_set_page_title (EphyNotebook *nb,
ebox = GTK_WIDGET (g_object_get_data (G_OBJECT (hbox), "label-ebox"));
gtk_tooltips_set_tip (GTK_TOOLTIPS (nb->priv->title_tips), ebox, title, NULL);
-
- g_signal_emit (G_OBJECT (nb), ephy_notebook_signals[TABS_CHANGED], 0);
}
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index e126562c8..ab350a9a0 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -634,4 +634,3 @@ ephy_shell_show_history_window (EphyShell *gs,
gtk_window_present (GTK_WINDOW (gs->priv->history_window));
}
-
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 4c600a34d..0cf1c6ded 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -27,6 +27,10 @@
#include "ephy-embed-prefs.h"
#include "ephy-debug.h"
#include "egg-menu-merge.h"
+#include "ephy-string.h"
+#include "ephy-notebook.h"
+#include "ephy-file-helpers.h"
+#include "ephy-zoom.h"
#include <bonobo/bonobo-i18n.h>
#include <libgnomevfs/gnome-vfs-uri.h>
@@ -50,34 +54,61 @@ struct EphyTabPrivate
EphyEmbedEvent *event;
gboolean is_active;
TabLoadStatus load_status;
- char status_message[255];
+ char *status_message;
char *link_message;
- char favicon_url[255];
+ char *icon_address;
+ char *address;
char *title;
- char *location;
int load_percent;
gboolean visibility;
int cur_requests;
int total_requests;
int width;
int height;
+ EggAction *action;
+ float zoom;
+ EmbedSecurityLevel security_level;
};
-static void ephy_tab_class_init (EphyTabClass *klass);
-static void ephy_tab_init (EphyTab *tab);
-static void ephy_tab_finalize (GObject *object);
-
+static void ephy_tab_class_init (EphyTabClass *klass);
+static void ephy_tab_init (EphyTab *tab);
+static void ephy_tab_finalize (GObject *object);
+static void ephy_tab_update_color (EphyTab *tab);
enum
{
PROP_0,
- PROP_WINDOW,
+ PROP_ADDRESS,
+ PROP_ICON,
+ PROP_LOAD_PROGRESS,
PROP_LOAD_STATUS,
- PROP_ICON
+ PROP_MESSAGE,
+ PROP_SECURITY,
+ PROP_TITLE,
+ PROP_WINDOW,
+ PROP_ZOOM
};
static GObjectClass *parent_class = NULL;
+static gulong tab_id = 0;
+
+/* internal functions, accessible only from this file */
+void ephy_tab_set_icon_address (EphyTab *tab,
+ const char *location);
+void ephy_tab_set_load_status (EphyTab *tab,
+ TabLoadStatus status);
+void ephy_tab_set_link_message (EphyTab *tab,
+ const char *message);
+void ephy_tab_set_load_percent (EphyTab *tab,
+ int percent);
+void ephy_tab_set_security_level (EphyTab *tab,
+ EmbedSecurityLevel level);
+void ephy_tab_set_title (EphyTab *tab,
+ const char *new_title);
+void ephy_tab_set_zoom (EphyTab *tab,
+ float zoom);
+
/* Class functions */
GType
@@ -119,76 +150,162 @@ ephy_tab_set_property (GObject *object,
switch (prop_id)
{
- case PROP_WINDOW:
- tab->priv->window = g_value_get_object (value);
+ case PROP_ADDRESS:
+ ephy_tab_set_location (tab, g_value_get_string (value));
break;
- case PROP_LOAD_STATUS:
- tab->priv->load_status = g_value_get_int (value);
+ case PROP_WINDOW:
+ ephy_tab_set_window (tab, g_value_get_object (value));
break;
case PROP_ICON:
- /* do nothing yet */
+ case PROP_LOAD_PROGRESS:
+ case PROP_LOAD_STATUS:
+ case PROP_MESSAGE:
+ case PROP_SECURITY:
+ case PROP_TITLE:
+ case PROP_ZOOM:
+ /* read only */
break;
- }
+ }
}
static void
ephy_tab_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
EphyTab *tab = EPHY_TAB (object);
switch (prop_id)
{
- case PROP_WINDOW:
- g_value_set_object (value, tab->priv->window);
+ case PROP_ADDRESS:
+ g_value_set_string (value, tab->priv->address);
+ break;
+ case PROP_ICON:
+ g_value_set_string (value, tab->priv->icon_address);
+ break;
+ case PROP_LOAD_PROGRESS:
+ g_value_set_int (value, tab->priv->load_percent);
break;
case PROP_LOAD_STATUS:
g_value_set_int (value, tab->priv->load_status);
break;
- case PROP_ICON:
- g_value_set_string (value, tab->priv->favicon_url);
+ case PROP_MESSAGE:
+ g_value_set_string (value, ephy_tab_get_status_message (tab));
+ break;
+ case PROP_SECURITY:
+ g_value_set_int (value, tab->priv->security_level);
+ break;
+ case PROP_TITLE:
+ g_value_set_string (value, tab->priv->title);
+ break;
+ case PROP_WINDOW:
+ g_value_set_object (value, tab->priv->window);
+ break;
+ case PROP_ZOOM:
+ g_value_set_float (value, tab->priv->zoom);
break;
}
}
static void
-ephy_tab_class_init (EphyTabClass *klass)
+ephy_tab_action_activate_cb (EggAction *action, EphyTab *tab)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ g_return_if_fail (IS_EPHY_TAB (tab));
- parent_class = g_type_class_peek_parent (klass);
+ ephy_window_jump_to_tab (tab->priv->window, tab);
+}
+
+static void
+ephy_tab_class_init (EphyTabClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ parent_class = g_type_class_peek_parent (class);
object_class->finalize = ephy_tab_finalize;
object_class->get_property = ephy_tab_get_property;
object_class->set_property = ephy_tab_set_property;
g_object_class_install_property (object_class,
- PROP_WINDOW,
- g_param_spec_object ("EphyWindow",
- "EphyWindow",
- "The parent EphyWindow",
- EPHY_WINDOW_TYPE,
+ PROP_ADDRESS,
+ g_param_spec_string ("address",
+ "Address",
+ "The tab's address",
+ "",
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
+ PROP_ICON,
+ g_param_spec_string ("icon",
+ "Icon address",
+ "The tab icon's address",
+ NULL,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_LOAD_STATUS,
+ g_param_spec_int ("load-progress",
+ "Load progress",
+ "The tab's load progress in percent",
+ -1,
+ 100,
+ 0,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
PROP_LOAD_STATUS,
g_param_spec_int ("load-status",
- "LoadStatus",
+ "Load status",
"The tab's load status",
TAB_LOAD_NONE,
TAB_LOAD_COMPLETED,
TAB_LOAD_NONE,
- G_PARAM_READWRITE));
+ G_PARAM_READABLE));
g_object_class_install_property (object_class,
- PROP_ICON,
- g_param_spec_string ("icon",
- "Icon address",
- "The tab icon's address",
- "",
+ PROP_MESSAGE,
+ g_param_spec_string ("message",
+ "Message",
+ "The tab's statusbar message",
+ NULL,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_LOAD_STATUS,
+ g_param_spec_int ("security-level",
+ "Security Level",
+ "The tab's security level",
+ STATE_IS_UNKNOWN,
+ STATE_IS_SECURE_HIGH,
+ STATE_IS_UNKNOWN,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_TITLE,
+ g_param_spec_string ("title",
+ "Title",
+ "The tab's title",
+ _("Blank page"),
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_WINDOW,
+ g_param_spec_object ("window",
+ "Window",
+ "The tab's parent window",
+ EPHY_WINDOW_TYPE,
G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_ZOOM,
+ g_param_spec_float ("zoom",
+ "Zoom",
+ "The tab's zoom",
+ ZOOM_MINIMAL,
+ ZOOM_MAXIMAL,
+ 1.0,
+ G_PARAM_READABLE));
}
static void
@@ -229,8 +346,16 @@ ephy_tab_finalize (GObject *object)
g_object_unref (tab->priv->event);
}
- g_free (tab->priv->location);
+ if (tab->priv->action)
+ {
+ g_object_unref (tab->priv->action);
+ }
+
+ g_free (tab->priv->title);
+ g_free (tab->priv->address);
+ g_free (tab->priv->icon_address);
g_free (tab->priv->link_message);
+ g_free (tab->priv->status_message);
g_free (tab->priv);
@@ -242,7 +367,7 @@ ephy_tab_finalize (GObject *object)
/* Public functions */
EphyTab *
-ephy_tab_new ()
+ephy_tab_new (void)
{
EphyTab *tab;
@@ -251,9 +376,9 @@ ephy_tab_new ()
return tab;
}
-static void
+void
ephy_tab_set_load_status (EphyTab *tab,
- TabLoadStatus status)
+ TabLoadStatus status)
{
if (status == TAB_LOAD_COMPLETED)
{
@@ -271,12 +396,43 @@ ephy_tab_set_load_status (EphyTab *tab,
{
tab->priv->load_status = status;
}
+
+ ephy_tab_update_color (tab);
+
+ g_object_notify (G_OBJECT (tab), "load-status");
+}
+
+TabLoadStatus
+ephy_tab_get_load_status (EphyTab *tab)
+{
+ g_return_val_if_fail (IS_EPHY_TAB (tab), TAB_LOAD_NONE);
+
+ return tab->priv->load_status;
+}
+
+void
+ephy_tab_set_link_message (EphyTab *tab, const char *message)
+{
+ g_return_if_fail (IS_EPHY_TAB (tab));
+
+ g_free (tab->priv->link_message);
+ tab->priv->link_message = g_strdup (message);
+
+ g_object_notify (G_OBJECT (tab), "message");
+}
+
+const char *
+ephy_tab_get_link_message (EphyTab *tab)
+{
+ g_return_val_if_fail (IS_EPHY_TAB (tab), NULL);
+
+ return tab->priv->link_message;
}
EphyEmbed *
ephy_tab_get_embed (EphyTab *tab)
{
- g_return_val_if_fail (IS_EPHY_TAB (G_OBJECT (tab)), NULL);
+ g_return_val_if_fail (IS_EPHY_TAB (tab), NULL);
return tab->priv->embed;
}
@@ -284,16 +440,16 @@ ephy_tab_get_embed (EphyTab *tab)
void
ephy_tab_set_window (EphyTab *tab, EphyWindow *window)
{
- g_return_if_fail (IS_EPHY_TAB (G_OBJECT (tab)));
- if (window) g_return_if_fail (IS_EPHY_WINDOW (G_OBJECT (window)));
+ g_return_if_fail (IS_EPHY_TAB (tab));
+ if (window) g_return_if_fail (IS_EPHY_WINDOW (window));
- tab->priv->window = window;
+ tab->priv->window = window;
}
EphyWindow *
ephy_tab_get_window (EphyTab *tab)
{
- g_return_val_if_fail (IS_EPHY_TAB (G_OBJECT (tab)), NULL);
+ g_return_val_if_fail (IS_EPHY_TAB (tab), NULL);
return tab->priv->window;
}
@@ -334,45 +490,46 @@ ephy_tab_update_color (EphyTab *tab)
void
ephy_tab_set_is_active (EphyTab *tab, gboolean is_active)
{
- TabLoadStatus status;
-
- g_return_if_fail (IS_EPHY_TAB (G_OBJECT (tab)));
+ g_return_if_fail (IS_EPHY_TAB (tab));
tab->priv->is_active = is_active;
- status = ephy_tab_get_load_status (tab);
- if (status == TAB_LOAD_COMPLETED)
+ if (tab->priv->load_status == TAB_LOAD_COMPLETED)
{
ephy_tab_set_load_status (tab, TAB_LOAD_NONE);
}
- ephy_tab_update_color (tab);
}
gboolean
ephy_tab_get_is_active (EphyTab *tab)
{
- g_return_val_if_fail (IS_EPHY_TAB (G_OBJECT (tab)), FALSE);
+ g_return_val_if_fail (IS_EPHY_TAB (tab), FALSE);
return tab->priv->is_active;
}
-gboolean
-ephy_tab_get_visibility (EphyTab *tab)
-{
- return tab->priv->visibility;
-}
-
void
ephy_tab_get_size (EphyTab *tab, int *width, int *height)
{
+ g_return_if_fail (IS_EPHY_TAB (tab));
+
*width = tab->priv->width;
*height = tab->priv->height;
}
-static void
+gboolean
+ephy_tab_get_visibility (EphyTab *tab)
+{
+ g_return_val_if_fail (IS_EPHY_TAB (tab), FALSE);
+
+ return tab->priv->visibility;
+}
+
+void
ephy_tab_set_visibility (EphyTab *tab,
gboolean visible)
{
+ g_return_if_fail (IS_EPHY_TAB (tab));
g_return_if_fail (tab->priv->window != NULL);
tab->priv->visibility = visible;
@@ -383,96 +540,127 @@ ephy_tab_set_favicon (EphyTab *tab,
GdkPixbuf *favicon)
{
GtkWidget *nb;
- EphyBookmarks *eb;
- EphyHistory *history;
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->favicon_url[0] != '\0')
- {
- eb = ephy_shell_get_bookmarks (ephy_shell);
- history = ephy_embed_shell_get_global_history
- (EPHY_EMBED_SHELL (ephy_shell));
- ephy_bookmarks_set_icon (eb, tab->priv->location,
- tab->priv->favicon_url);
- ephy_history_set_icon (history, 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)
+ephy_tab_icon_cache_changed_cb (EphyFaviconCache *cache,
+ const char *address,
+ EphyTab *tab)
{
GdkPixbuf *pixbuf = NULL;
/* is this for us? */
- if (strncmp (tab->priv->favicon_url, url, 255) != 0) return;
+ if (strcmp (tab->priv->icon_address, address) != 0) return;
+ /* notify */
+ g_object_notify (G_OBJECT (tab), "icon");
+
/* set favicon */
- pixbuf = ephy_favicon_cache_get (cache, tab->priv->favicon_url);
- ephy_tab_set_favicon (tab, pixbuf);
+ if (tab->priv->icon_address)
+ {
+ pixbuf = ephy_favicon_cache_get (cache, tab->priv->icon_address);
+ ephy_tab_set_favicon (tab, pixbuf);
- if (pixbuf) g_object_unref (pixbuf);
+ if (pixbuf)
+ {
+ g_object_unref (pixbuf);
+ }
+ }
}
-static void
-ephy_tab_favicon_cb (EphyEmbed *embed,
- const char *url,
- EphyTab *tab)
+void
+ephy_tab_set_icon_address (EphyTab *tab, const char *address)
{
+ EphyBookmarks *eb;
+ EphyHistory *history;
EphyFaviconCache *cache;
GdkPixbuf *pixbuf = NULL;
- g_strlcpy (tab->priv->favicon_url,
- url, 255);
+ g_return_if_fail (IS_EPHY_TAB (tab));
+
+ g_free (tab->priv->icon_address);
+ tab->priv->icon_address = g_strdup (address);
cache = ephy_embed_shell_get_favicon_cache
(EPHY_EMBED_SHELL (ephy_shell));
- if (url && url[0] != '\0')
+ if (tab->priv->icon_address)
{
- pixbuf = ephy_favicon_cache_get (cache, tab->priv->favicon_url);
+ eb = ephy_shell_get_bookmarks (ephy_shell);
+ history = ephy_embed_shell_get_global_history
+ (EPHY_EMBED_SHELL (ephy_shell));
+ ephy_bookmarks_set_icon (eb, tab->priv->address,
+ tab->priv->icon_address);
+ ephy_history_set_icon (history, tab->priv->address,
+ tab->priv->icon_address);
+
+ pixbuf = ephy_favicon_cache_get (cache, tab->priv->icon_address);
+
ephy_tab_set_favicon (tab, pixbuf);
- if (pixbuf) g_object_unref (pixbuf);
+
+ if (pixbuf)
+ {
+ g_object_unref (pixbuf);
+ }
}
else
{
ephy_tab_set_favicon (tab, NULL);
}
+
+ ephy_window_update_control (tab->priv->window,
+ FaviconControl);
+
+ g_object_notify (G_OBJECT (tab), "icon");
+}
+
+const char *
+ephy_tab_get_icon_address (EphyTab *tab)
+{
+ g_return_val_if_fail (IS_EPHY_TAB (tab), "");
+
+ return tab->priv->icon_address;
+}
+
+/* Private callbacks for embed signals */
+
+static void
+ephy_tab_favicon_cb (EphyEmbed *embed,
+ const char *address,
+ EphyTab *tab)
+{
+ ephy_tab_set_icon_address (tab, address);
}
static void
ephy_tab_link_message_cb (EphyEmbed *embed,
- const char *message,
+ const gchar *message,
EphyTab *tab)
{
if (!tab->priv->is_active) return;
- g_free (tab->priv->link_message);
- tab->priv->link_message = g_strdup (message);
+ ephy_tab_set_link_message (tab, message);
ephy_window_update_control (tab->priv->window,
StatusbarMessageControl);
}
static void
-ephy_tab_location_cb (EphyEmbed *embed, EphyTab *tab)
+ephy_tab_address_cb (EphyEmbed *embed, EphyTab *tab)
{
- if (tab->priv->location) g_free (tab->priv->location);
- ephy_embed_get_location (embed, TRUE,
- &tab->priv->location);
- tab->priv->link_message = NULL;
- tab->priv->favicon_url[0] = '\0';
- ephy_tab_set_favicon (tab, NULL);
+ char *address;
+
+ ephy_embed_get_location (embed, TRUE, &address);
+ ephy_tab_set_location (tab, address);
+ g_free (address);
+
+ ephy_tab_set_link_message (tab, NULL);
+ ephy_tab_set_icon_address (tab, NULL);
if (tab->priv->is_active)
{
@@ -485,6 +673,8 @@ ephy_tab_location_cb (EphyEmbed *embed, EphyTab *tab)
static void
ephy_tab_zoom_changed_cb (EphyEmbed *embed, float zoom, EphyTab *tab)
{
+ ephy_tab_set_zoom (tab, zoom);
+
if (tab->priv->is_active)
{
ephy_window_update_control (tab->priv->window, ZoomControl);
@@ -492,55 +682,15 @@ ephy_tab_zoom_changed_cb (EphyEmbed *embed, float zoom, EphyTab *tab)
}
static void
-ephy_tab_set_title (EphyTab *tab, const char *title)
-{
- GtkWidget *nb;
-
- nb = ephy_window_get_notebook (tab->priv->window);
- ephy_notebook_set_page_title (EPHY_NOTEBOOK (nb),
- GTK_WIDGET (tab->priv->embed),
- title);
-}
-
-static void
ephy_tab_title_cb (EphyEmbed *embed, EphyTab *tab)
{
- GnomeVFSURI *uri;
-
- if (tab->priv->title) g_free (tab->priv->title);
- ephy_embed_get_title (embed, &tab->priv->title);
-
- if (*(tab->priv->title) == '\0')
- {
- g_free (tab->priv->title);
- tab->priv->title = NULL;
-
- uri = gnome_vfs_uri_new (tab->priv->location);
- if (uri)
- {
- tab->priv->title = gnome_vfs_uri_to_string (uri,
- GNOME_VFS_URI_HIDE_USER_NAME |
- GNOME_VFS_URI_HIDE_PASSWORD |
- GNOME_VFS_URI_HIDE_HOST_PORT |
- GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD |
- GNOME_VFS_URI_HIDE_FRAGMENT_IDENTIFIER);
- gnome_vfs_uri_unref (uri);
- }
+ char *title;
- if (tab->priv->title == NULL || *(tab->priv->title) == '\0')
- {
- g_free (tab->priv->title);
- tab->priv->title = g_strdup (_("Blank page"));
- }
- }
+ ephy_embed_get_title (embed, &title);
- ephy_tab_set_title (tab, tab->priv->title);
+ ephy_tab_set_title (tab, title);
- if (tab->priv->is_active)
- {
- ephy_window_update_control (tab->priv->window,
- TitleControl);
- }
+ g_free (title);
}
static int
@@ -585,13 +735,11 @@ get_host_name_from_uri (const char *uri)
return result;
}
-static void
-build_net_state_message (char *message,
- const char *uri,
- EmbedState flags)
+static char *
+build_net_state_message (const char *uri, EmbedState flags)
{
const char *msg = NULL;
- char *host;
+ char *host, *message = NULL;
host = get_host_name_from_uri (uri);
@@ -627,10 +775,12 @@ build_net_state_message (char *message,
if (msg)
{
- g_snprintf (message, 255, msg, host);
+ message = g_strdup_printf (msg, host);
}
g_free (host);
+
+ return message;
}
static void
@@ -653,30 +803,31 @@ build_progress_from_requests (EphyTab *tab, EmbedState state)
tab->priv->total_requests);
if (load_percent > tab->priv->load_percent)
{
- tab->priv->load_percent = load_percent;
+ ephy_tab_set_load_percent (tab, load_percent);
}
}
}
static void
-ensure_location (EphyTab *tab, const char *uri)
+ensure_address (EphyTab *tab, const char *address)
{
- if (tab->priv->location == NULL)
+ if (tab->priv->address == NULL)
{
- tab->priv->location = g_strdup (uri);
- ephy_window_update_control (tab->priv->window,
- LocationControl);
+ ephy_tab_set_location (tab, address);
+ ephy_window_update_control (tab->priv->window, LocationControl);
}
}
static void
ephy_tab_net_state_cb (EphyEmbed *embed, const char *uri,
- EmbedState state, EphyTab *tab)
+ EmbedState state, EphyTab *tab)
{
- build_net_state_message (tab->priv->status_message, uri, state);
+ g_free (tab->priv->status_message);
+ tab->priv->status_message = build_net_state_message (uri, state);
- ephy_window_update_control (tab->priv->window,
- StatusbarMessageControl);
+ g_object_notify (G_OBJECT (tab), "message");
+
+ ephy_window_update_control (tab->priv->window, StatusbarMessageControl);
if (state & EMBED_STATE_IS_NETWORK)
{
@@ -684,9 +835,9 @@ ephy_tab_net_state_cb (EphyEmbed *embed, const char *uri,
{
tab->priv->total_requests = 0;
tab->priv->cur_requests = 0;
- tab->priv->load_percent = 0;
+ ephy_tab_set_load_percent (tab, 0);
- ensure_location (tab, uri);
+ ensure_address (tab, uri);
ephy_tab_set_load_status (tab, TAB_LOAD_STARTED);
@@ -694,11 +845,10 @@ ephy_tab_net_state_cb (EphyEmbed *embed, const char *uri,
NavControl);
ephy_window_update_control (tab->priv->window,
SpinnerControl);
- ephy_tab_update_color (tab);
}
else if (state & EMBED_STATE_STOP)
{
- tab->priv->load_percent = 0;
+ ephy_tab_set_load_percent (tab, 0);
ephy_tab_set_load_status (tab, TAB_LOAD_COMPLETED);
@@ -718,7 +868,7 @@ ephy_tab_net_state_cb (EphyEmbed *embed, const char *uri,
static void
ephy_tab_new_window_cb (EphyEmbed *embed, EphyEmbed **new_embed,
- EmbedChromeMask chromemask, EphyTab *tab)
+ EmbedChromeMask chromemask, EphyTab *tab)
{
EphyTab *new_tab;
EphyWindow *window;
@@ -744,8 +894,6 @@ static void
ephy_tab_visibility_cb (EphyEmbed *embed, gboolean visibility,
EphyTab *tab)
{
- EphyWindow *window;
-
if (visibility)
{
gtk_widget_show (GTK_WIDGET(embed));
@@ -757,10 +905,9 @@ ephy_tab_visibility_cb (EphyEmbed *embed, gboolean visibility,
ephy_tab_set_visibility (tab, visibility);
- window = ephy_tab_get_window (tab);
- g_return_if_fail (window != NULL);
+ g_return_if_fail (tab->priv->window != NULL);
- ephy_window_update_control (window, WindowVisibilityControl);
+ ephy_window_update_control (tab->priv->window, WindowVisibilityControl);
}
static void
@@ -768,6 +915,9 @@ ephy_tab_destroy_brsr_cb (EphyEmbed *embed, EphyTab *tab)
{
EphyWindow *window;
+ g_return_if_fail (IS_EPHY_TAB (tab));
+ g_return_if_fail (tab->priv->window != NULL);
+
window = ephy_tab_get_window (tab);
ephy_window_remove_tab (window, tab);
@@ -780,14 +930,17 @@ static gint
ephy_tab_open_uri_cb (EphyEmbed *embed, const char *uri,
EphyTab *tab)
{
+ LOG ("ephy_tab_open_uri_cb %s", uri)
+
+ /* FIXME: what is this function supposed to do ? */
return FALSE;
}
static void
ephy_tab_size_to_cb (EphyEmbed *embed, gint width, gint height,
- EphyTab *tab)
+ EphyTab *tab)
{
- GList *tabs;
+ GList *tabs = NULL;
EphyWindow *window;
GtkWidget *widget;
EmbedChromeMask chromemask;
@@ -795,8 +948,8 @@ ephy_tab_size_to_cb (EphyEmbed *embed, gint width, gint height,
tab->priv->width = width;
tab->priv->height = height;
- window = ephy_tab_get_window (tab);
- tabs = (GList *) ephy_window_get_tabs (window);
+ window = tab->priv->window;
+ tabs = ephy_window_get_tabs (window);
widget = GTK_WIDGET (embed);
chromemask = ephy_window_get_chrome (window);
@@ -821,6 +974,8 @@ ephy_tab_size_to_cb (EphyEmbed *embed, gint width, gint height,
g_idle_add (let_me_resize_hack, embed);
}
}
+
+ g_list_free (tabs);
}
static void
@@ -843,7 +998,8 @@ ephy_tab_show_embed_popup (EphyTab *tab, EphyEmbedEvent *event)
char *path;
GtkWidget *widget;
- window = ephy_tab_get_window (tab);
+ g_return_if_fail (IS_EPHY_TAB (tab));
+ window = tab->priv->window;
ephy_embed_event_get_property (event, "framed_page", &value);
framed = g_value_get_int (value);
@@ -955,6 +1111,8 @@ static void
ephy_tab_security_change_cb (EphyEmbed *embed, EmbedSecurityLevel level,
EphyTab *tab)
{
+ ephy_tab_set_security_level (tab, level);
+
if (!tab->priv->is_active) return;
ephy_window_update_control (tab->priv->window,
@@ -967,7 +1125,10 @@ ephy_tab_init (EphyTab *tab)
GObject *embed, *embed_widget;
EphyEmbedSingle *single;
EphyFaviconCache *cache;
+ char *id;
+ LOG ("EphyTab initialising %p", tab)
+
single = ephy_embed_shell_get_embed_single
(EPHY_EMBED_SHELL (ephy_shell));
@@ -976,13 +1137,8 @@ ephy_tab_init (EphyTab *tab)
tab->priv->window = NULL;
tab->priv->event = NULL;
tab->priv->is_active = FALSE;
- *tab->priv->status_message = '\0';
+ tab->priv->status_message = NULL;
tab->priv->link_message = NULL;
- *tab->priv->favicon_url = '\0';
- tab->priv->load_status = TAB_LOAD_NONE;
- tab->priv->load_percent = 0;
- tab->priv->title = NULL;
- tab->priv->location = NULL;
tab->priv->total_requests = 0;
tab->priv->cur_requests = 0;
tab->priv->width = -1;
@@ -995,6 +1151,16 @@ ephy_tab_init (EphyTab *tab)
embed = G_OBJECT (tab->priv->embed);
embed_widget = G_OBJECT (tab->priv->embed);
+ id = g_strdup_printf ("Tab%lu", tab_id++);
+
+ tab->priv->action = g_object_new (EGG_TYPE_ACTION,
+ "name", id,
+ "label", _("Blank page"),
+ NULL);
+ g_free (id);
+ g_signal_connect (tab->priv->action, "activate",
+ G_CALLBACK (ephy_tab_action_activate_cb), tab);
+
/* set a pointer in the embed's widget back to the tab */
g_object_set_data (embed_widget, "EphyTab", tab);
@@ -1008,7 +1174,7 @@ ephy_tab_init (EphyTab *tab)
G_CALLBACK (ephy_tab_link_message_cb),
tab);
g_signal_connect (embed, "ge_location",
- G_CALLBACK (ephy_tab_location_cb),
+ G_CALLBACK (ephy_tab_address_cb),
tab);
g_signal_connect (embed, "ge_title",
G_CALLBACK (ephy_tab_title_cb),
@@ -1049,84 +1215,184 @@ ephy_tab_init (EphyTab *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),
+ G_CALLBACK (ephy_tab_icon_cache_changed_cb),
tab, 0);
}
-TabLoadStatus
-ephy_tab_get_load_status (EphyTab *tab)
+void
+ephy_tab_set_load_percent (EphyTab *tab, int percent)
{
- return tab->priv->load_status;
+ g_return_if_fail (IS_EPHY_TAB (tab));
+
+ tab->priv->load_percent = percent;
+
+ g_object_notify (G_OBJECT (tab), "load-progress");
}
int
ephy_tab_get_load_percent (EphyTab *tab)
{
+ g_return_val_if_fail (IS_EPHY_TAB (tab), -1);
+
return tab->priv->load_percent;
}
const char *
ephy_tab_get_status_message (EphyTab *tab)
{
+ g_return_val_if_fail (IS_EPHY_TAB (tab), "");
+
if (tab->priv->link_message)
{
return tab->priv->link_message;
}
- else
+ else if (tab->priv->status_message)
{
return tab->priv->status_message;
}
+ else
+ {
+ return "";
+ }
}
-const char *
-ephy_tab_get_title (EphyTab *tab)
+#define MAX_LABEL_LENGTH 32
+
+void
+ephy_tab_set_title (EphyTab *tab, const char *new_title)
{
- if (tab->priv->title &&
- g_utf8_strlen(tab->priv->title, -1))
+ GtkWidget *nb;
+ GnomeVFSURI *uri;
+ char *title_short = NULL;
+ char *title = NULL;
+
+ g_return_if_fail (IS_EPHY_TAB (tab));
+
+ g_free (tab->priv->title);
+
+ if (new_title == NULL || new_title[0] == '\0')
{
- return tab->priv->title;
+ uri = gnome_vfs_uri_new (tab->priv->address);
+ if (uri)
+ {
+ title = gnome_vfs_uri_to_string (uri,
+ GNOME_VFS_URI_HIDE_USER_NAME |
+ GNOME_VFS_URI_HIDE_PASSWORD |
+ GNOME_VFS_URI_HIDE_HOST_PORT |
+ GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD |
+ GNOME_VFS_URI_HIDE_FRAGMENT_IDENTIFIER);
+ gnome_vfs_uri_unref (uri);
+ }
+
+ if (title == NULL || title[0] == '\0')
+ {
+ g_free (title);
+ title = g_strdup (_("Blank page"));
+ }
}
else
{
- return _("Untitled");
+ title = g_strdup (new_title);
}
+
+ tab->priv->title = title;
+
+ title_short = ephy_string_shorten (title, MAX_LABEL_LENGTH);
+
+ /**
+ * FIXME: instead of shortening the title here, use an egg action
+ * which creates menu items with ellipsizing labels
+ */
+ g_object_set (G_OBJECT (tab->priv->action),
+ "label", title_short,
+ NULL);
+
+ g_free (title_short);
+
+ if (tab->priv->window != NULL)
+ {
+ nb = ephy_window_get_notebook (tab->priv->window);
+ ephy_notebook_set_page_title (EPHY_NOTEBOOK (nb),
+ GTK_WIDGET (tab->priv->embed),
+ tab->priv->title);
+
+ if (tab->priv->is_active)
+ {
+ ephy_window_update_control (tab->priv->window, TitleControl);
+ }
+ }
+
+ g_object_notify (G_OBJECT (tab), "title");
}
const char *
-ephy_tab_get_location (EphyTab *tab)
+ephy_tab_get_title (EphyTab *tab)
{
- return tab->priv->location;
+ g_return_val_if_fail (IS_EPHY_TAB (tab), "");
+
+ return tab->priv->title;
}
const char *
-ephy_tab_get_favicon_url (EphyTab *tab)
+ephy_tab_get_location (EphyTab *tab)
{
- if (tab->priv->favicon_url[0] == '\0')
- {
- return NULL;
- }
- else
- {
- return tab->priv->favicon_url;
- }
+ g_return_val_if_fail (IS_EPHY_TAB (tab), "");
+
+ return tab->priv->address;
}
void
ephy_tab_set_location (EphyTab *tab,
- char *location)
+ const char *address)
{
- if (tab->priv->location) g_free (tab->priv->location);
- tab->priv->location = g_strdup (location);
+ g_return_if_fail (IS_EPHY_TAB (tab));
+
+ if (tab->priv->address) g_free (tab->priv->address);
+ tab->priv->address = g_strdup (address);
+
+ g_object_notify (G_OBJECT (tab), "address");
}
void
-ephy_tab_update_control (EphyTab *tab,
- TabControlID id)
+ephy_tab_set_security_level (EphyTab *tab, EmbedSecurityLevel level)
{
- switch (id)
- {
- case TAB_CONTROL_TITLE:
- ephy_tab_set_title (tab, tab->priv->title);
- break;
- }
+ g_return_if_fail (IS_EPHY_TAB (tab));
+
+ tab->priv->security_level = level;
+
+ g_object_notify (G_OBJECT (tab), "security-level");
+}
+
+EmbedSecurityLevel
+ephy_tab_get_security_level (EphyTab *tab)
+{
+ g_return_val_if_fail (IS_EPHY_TAB (tab), STATE_IS_UNKNOWN);
+
+ return tab->priv->security_level;
+}
+
+void
+ephy_tab_set_zoom (EphyTab *tab, float zoom)
+{
+ g_return_if_fail (IS_EPHY_TAB (tab));
+
+ tab->priv->zoom = zoom;
+
+ g_object_notify (G_OBJECT (tab), "zoom");
+}
+
+float
+ephy_tab_get_zoom (EphyTab *tab)
+{
+ g_return_val_if_fail (IS_EPHY_TAB (tab), 1.0);
+
+ return tab->priv->zoom;
+}
+
+EggAction *
+ephy_tab_get_action (EphyTab *tab)
+{
+ g_return_val_if_fail (IS_EPHY_TAB (tab), NULL);
+
+ return tab->priv->action;
}
diff --git a/src/ephy-tab.h b/src/ephy-tab.h
index 82f6d16a6..8b38e8f6d 100644
--- a/src/ephy-tab.h
+++ b/src/ephy-tab.h
@@ -20,8 +20,10 @@
#define EPHY_TAB_H
#include "ephy-embed.h"
+#include "egg-action.h"
#include <glib-object.h>
+#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
@@ -32,17 +34,13 @@ typedef struct EphyTabClass EphyTabClass;
#define EPHY_TAB_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EPHY_TAB, EphyTabClass))
#define IS_EPHY_TAB(obj) (GTK_CHECK_TYPE ((obj), EPHY_TAB_TYPE))
#define IS_EPHY_TAB_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), EPHY_TAB))
+#define EPHY_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TAB_TYPE, EphyTabClass))
typedef struct EphyTab EphyTab;
typedef struct EphyTabPrivate EphyTabPrivate;
typedef enum
{
- TAB_CONTROL_TITLE
-} TabControlID;
-
-typedef enum
-{
TAB_LOAD_NONE,
TAB_LOAD_STARTED,
TAB_LOAD_COMPLETED
@@ -56,53 +54,63 @@ struct EphyTab
struct EphyTabClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
/* Include the header down here to resolve circular dependency */
#include "ephy-window.h"
-GType ephy_tab_get_type (void);
+GType ephy_tab_get_type (void);
-EphyTab *ephy_tab_new (void);
+EphyTab * ephy_tab_new (void);
-EphyEmbed *ephy_tab_get_embed (EphyTab *tab);
+EggAction * ephy_tab_get_action (EphyTab *tab);
+
+EphyEmbed * ephy_tab_get_embed (EphyTab *tab);
+
+EphyEmbedEvent *ephy_tab_get_event (EphyTab *tab);
-void ephy_tab_set_window (EphyTab *tab,
+void ephy_tab_set_window (EphyTab *tab,
EphyWindow *window);
-EphyWindow *ephy_tab_get_window (EphyTab *tab);
+EphyWindow * ephy_tab_get_window (EphyTab *tab);
-void ephy_tab_set_is_active (EphyTab *tab,
- gboolean is_active);
+const char * ephy_tab_get_icon_address (EphyTab *tab);
-gboolean ephy_tab_get_is_active (EphyTab *tab);
+void ephy_tab_set_is_active (EphyTab *tab,
+ gboolean is_active);
-gboolean ephy_tab_get_visibility (EphyTab *tab);
+gboolean ephy_tab_get_is_active (EphyTab *tab);
-TabLoadStatus ephy_tab_get_load_status (EphyTab *tab);
-int ephy_tab_get_load_percent (EphyTab *tab);
+TabLoadStatus ephy_tab_get_load_status (EphyTab *tab);
-const char *ephy_tab_get_status_message (EphyTab *tab);
+const char * ephy_tab_get_link_message (EphyTab *tab);
-const char *ephy_tab_get_title (EphyTab *tab);
-const char *ephy_tab_get_location (EphyTab *tab);
+int ephy_tab_get_load_percent (EphyTab *tab);
-const char *ephy_tab_get_favicon_url (EphyTab *tab);
+void ephy_tab_set_location (EphyTab *tab,
+ const char *location);
-void ephy_tab_set_location (EphyTab *tab,
- char *location);
+const char * ephy_tab_get_location (EphyTab *tab);
+
+EmbedSecurityLevel ephy_tab_get_security_level (EphyTab *tab);
-void ephy_tab_get_size (EphyTab *tab,
+void ephy_tab_get_size (EphyTab *tab,
int *width,
int *height);
-void ephy_tab_update_control (EphyTab *tab,
- TabControlID id);
+const char * ephy_tab_get_status_message (EphyTab *tab);
-EphyEmbedEvent *ephy_tab_get_event (EphyTab *tab);
+const char * ephy_tab_get_title (EphyTab *tab);
+
+void ephy_tab_set_visibility (EphyTab *tab,
+ gboolean visible);
+
+gboolean ephy_tab_get_visibility (EphyTab *tab);
+
+float ephy_tab_get_zoom (EphyTab *tab);
G_END_DECLS
diff --git a/src/ephy-tabs-menu.c b/src/ephy-tabs-menu.c
index f1352230d..972342e41 100644
--- a/src/ephy-tabs-menu.c
+++ b/src/ephy-tabs-menu.c
@@ -47,23 +47,14 @@ struct _EphyTabsMenuPrivate
/**
* Private functions, only availble from this file
*/
-static void ephy_tabs_menu_class_init (EphyTabsMenuClass *klass);
-static void ephy_tabs_menu_init (EphyTabsMenu *wrhm);
-static void ephy_tabs_menu_finalize_impl (GObject *o);
-static void ephy_tabs_menu_rebuild (EphyTabsMenu *wrhm);
-static void ephy_tabs_menu_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void ephy_tabs_menu_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void ephy_tabs_menu_class_init (EphyTabsMenuClass *klass);
+static void ephy_tabs_menu_init (EphyTabsMenu *menu);
+static void ephy_tabs_menu_finalize_impl (GObject *o);
enum
{
PROP_0,
- PROP_EPHY_WINDOW
+ PROP_WINDOW
};
static gpointer g_object_class;
@@ -101,6 +92,38 @@ ephy_tabs_menu_get_type (void)
}
static void
+ephy_tabs_menu_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyTabsMenu *m = EPHY_TABS_MENU (object);
+
+ switch (prop_id)
+ {
+ case PROP_WINDOW:
+ m->priv->window = g_value_get_object (value);
+ break;
+ }
+}
+
+static void
+ephy_tabs_menu_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyTabsMenu *m = EPHY_TABS_MENU (object);
+
+ switch (prop_id)
+ {
+ case PROP_WINDOW:
+ g_value_set_object (value, m->priv->window);
+ break;
+ }
+}
+
+static void
ephy_tabs_menu_class_init (EphyTabsMenuClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -112,28 +135,32 @@ ephy_tabs_menu_class_init (EphyTabsMenuClass *klass)
object_class->get_property = ephy_tabs_menu_get_property;
g_object_class_install_property (object_class,
- PROP_EPHY_WINDOW,
+ PROP_WINDOW,
g_param_spec_object ("EphyWindow",
"EphyWindow",
"Parent window",
EPHY_WINDOW_TYPE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
}
static void
-ephy_tabs_menu_init (EphyTabsMenu *wrhm)
+ephy_tabs_menu_init (EphyTabsMenu *menu)
{
- EphyTabsMenuPrivate *p = g_new0 (EphyTabsMenuPrivate, 1);
- wrhm->priv = p;
+ EphyTabsMenuPrivate *p;
+
+ p = g_new0 (EphyTabsMenuPrivate, 1);
+
+ menu->priv = p;
- wrhm->priv->ui_id = 0;
- wrhm->priv->action_group = NULL;
+ menu->priv->ui_id = 0;
+ menu->priv->action_group = NULL;
}
static void
-ephy_tabs_menu_clean (EphyTabsMenu *wrhm)
+ephy_tabs_menu_clean (EphyTabsMenu *menu)
{
- EphyTabsMenuPrivate *p = wrhm->priv;
+ EphyTabsMenuPrivate *p = menu->priv;
EggMenuMerge *merge = EGG_MENU_MERGE (p->window->ui_merge);
if (p->ui_id > 0)
@@ -153,8 +180,8 @@ ephy_tabs_menu_clean (EphyTabsMenu *wrhm)
static void
ephy_tabs_menu_finalize_impl (GObject *o)
{
- EphyTabsMenu *wrhm = EPHY_TABS_MENU (o);
- EphyTabsMenuPrivate *p = wrhm->priv;
+ EphyTabsMenu *menu = EPHY_TABS_MENU (o);
+ EphyTabsMenuPrivate *p = menu->priv;
if (p->action_group != NULL)
{
@@ -169,189 +196,117 @@ ephy_tabs_menu_finalize_impl (GObject *o)
G_OBJECT_CLASS (g_object_class)->finalize (o);
}
-static void
-ephy_tabs_menu_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyTabsMenu *m = EPHY_TABS_MENU (object);
-
- switch (prop_id)
- {
- case PROP_EPHY_WINDOW:
- m->priv->window = g_value_get_object (value);
- ephy_tabs_menu_rebuild (m);
- break;
- }
-}
-
-static void
-ephy_tabs_menu_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphyTabsMenu *m = EPHY_TABS_MENU (object);
-
- switch (prop_id)
- {
- case PROP_EPHY_WINDOW:
- g_value_set_object (value, m->priv->window);
- break;
- }
-}
EphyTabsMenu *
ephy_tabs_menu_new (EphyWindow *window)
{
- EphyTabsMenu *ret = g_object_new (EPHY_TYPE_TABS_MENU,
- "EphyWindow", window,
- NULL);
- return ret;
+ return EPHY_TABS_MENU (g_object_new (EPHY_TYPE_TABS_MENU,
+ "EphyWindow", window,
+ NULL));
}
-static void
-ephy_tabs_menu_verb_cb (EggAction *action, EphyTab *tab)
-{
- EphyWindow *window;
-
- g_return_if_fail (IS_EPHY_TAB (tab));
-
- window = ephy_tab_get_window (tab);
- ephy_window_jump_to_tab (window, tab);
-}
-
-
/* This code is from EggActionGroup:
* Ideally either EggAction should support setting an accelerator from
* a string or EggActionGroup would support adding single EggActionEntry's
* to an action group.
*/
static void
-ephy_tabs_menu_set_action_accelerator (EggActionGroup *action_group,
- EggAction *action,
- int tab_number)
+tab_set_action_accelerator (EggActionGroup *action_group,
+ EggAction *action,
+ guint tab_number)
{
- gchar *accel_path;
+ char *accel_path = NULL;
+ char accel[7];
gint accel_number;
-
- g_return_if_fail (tab_number >= 0);
+ guint accel_key;
+ GdkModifierType accel_mods;
/* set the accel path for the menu item */
- accel_path = g_strconcat ("<Actions>/", action_group->name, "/", action->name, NULL);
+ accel_path = g_strconcat ("<Actions>/", action_group->name, "/",
+ action->name, NULL);
/* Only the first ten tabs get accelerators starting from 1 through 0 */
- if (tab_number == 9)
- {
- accel_number = 0;
- }
- else
- {
- accel_number = (tab_number + 1);
- }
-
- if (accel_number < 10)
+ if (tab_number < 10)
{
- guint accel_key = 0;
- GdkModifierType accel_mods;
- gchar* accelerator;
+ accel_key = 0;
+ accel_number = (tab_number + 1) % 10;
- accelerator = g_strdup_printf ("<alt>%d", accel_number);
+ snprintf (accel, 7, "<alt>%d", accel_number);
- gtk_accelerator_parse (accelerator, &accel_key,
- &accel_mods);
- if (accel_key)
- gtk_accel_map_add_entry (accel_path, accel_key, accel_mods);
+ gtk_accelerator_parse (accel, &accel_key, &accel_mods);
- g_free (accelerator);
+ if (accel_key != 0)
+ {
+ gtk_accel_map_change_entry (accel_path, accel_key,
+ accel_mods, TRUE);
+ }
}
action->accel_quark = g_quark_from_string (accel_path);
g_free (accel_path);
}
-static void
-ephy_tabs_menu_rebuild (EphyTabsMenu *wrhm)
+void
+ephy_tabs_menu_update (EphyTabsMenu *menu)
{
- EphyTabsMenuPrivate *p = wrhm->priv;
- EggMenuMerge *merge = EGG_MENU_MERGE (p->window->ui_merge);
+ EphyTabsMenuPrivate *p;
+ EggMenuMerge *merge;
+ EphyTab *tab;
+ EggAction *action;
GString *xml;
guint i = 0;
- guint len;
- GList *tabs, *l;
+ guint num = 0;
+ GList *tabs = NULL, *l;
GError *error = NULL;
+ g_return_if_fail (EPHY_IS_TABS_MENU (menu));
+ p = menu->priv;
+ merge = EGG_MENU_MERGE (p->window->ui_merge);
+
LOG ("Rebuilding open tabs menu")
START_PROFILER ("Rebuilding tabs menu")
- ephy_tabs_menu_clean (wrhm);
+ ephy_tabs_menu_clean (menu);
tabs = ephy_window_get_tabs (p->window);
- len = g_list_length (tabs);
- if (len == 0) return;
- /* it's faster to preallocate */
- xml = g_string_sized_new (52 * len + 105);
+ num = g_list_length (tabs);
+ if (num == 0) return;
+
+ p->action_group = egg_action_group_new ("TabsActions");
+
+ /* it's faster to preallocate, MIN is sanity check */
+ xml = g_string_sized_new (44 * MIN (num, 64) + 105);
g_string_append (xml, "<Root><menu><submenu name=\"TabsMenu\">"
"<placeholder name=\"TabsOpen\">");
- p->action_group = egg_action_group_new ("TabsActions");
- egg_menu_merge_insert_action_group (merge, p->action_group, 0);
-
for (l = tabs; l != NULL; l = l->next)
{
- gchar *verb = g_strdup_printf ("TabsOpen%d", i);
- gchar *title_s;
- const gchar *title;
- EphyTab *tab;
- EggAction *action;
-
tab = (EphyTab *) l->data;
+ action = ephy_tab_get_action (tab);
- title = ephy_tab_get_title (tab);
- title_s = ephy_string_shorten (title, MAX_LABEL_LENGTH);
-
- action = g_object_new (EGG_TYPE_ACTION,
- "name", verb,
- "label", title_s,
- "tooltip", title,
- "stock_id", NULL,
- NULL);
-
- g_signal_connect (action, "activate",
- G_CALLBACK (ephy_tabs_menu_verb_cb), tab);
-
- ephy_tabs_menu_set_action_accelerator (p->action_group, action, i);
+ tab_set_action_accelerator (p->action_group, action, i);
egg_action_group_add_action (p->action_group, action);
- g_object_unref (action);
g_string_append (xml, "<menuitem name=\"");
- g_string_append (xml, verb);
- g_string_append (xml, "Menu");
- g_string_append (xml, "\" verb=\"");
- g_string_append (xml, verb);
+ g_string_append (xml, action->name);
+ g_string_append (xml, "Menu\" verb=\"");
+ g_string_append (xml, action->name);
g_string_append (xml, "\"/>\n");
- g_free (title_s);
- g_free (verb);
-
++i;
}
g_string_append (xml, "</placeholder></submenu></menu></Root>");
- p->ui_id = egg_menu_merge_add_ui_from_string (merge, xml->str, -1, &error);
+ egg_menu_merge_insert_action_group (merge, p->action_group, 0);
+ p->ui_id = egg_menu_merge_add_ui_from_string
+ (merge, xml->str, -1, &error);
g_string_free (xml, TRUE);
-
- STOP_PROFILER ("Rebuilding tabs menu")
-}
-void ephy_tabs_menu_update (EphyTabsMenu *wrhm)
-{
- ephy_tabs_menu_rebuild (wrhm);
+ STOP_PROFILER ("Rebuilding tabs menu")
}
diff --git a/src/ephy-tabs-menu.h b/src/ephy-tabs-menu.h
index a04329ef6..7e63a47cc 100644
--- a/src/ephy-tabs-menu.h
+++ b/src/ephy-tabs-menu.h
@@ -55,7 +55,7 @@ GType ephy_tabs_menu_get_type (void);
EphyTabsMenu *ephy_tabs_menu_new (EphyWindow *window);
-void ephy_tabs_menu_update (EphyTabsMenu *wrhm);
+void ephy_tabs_menu_update (EphyTabsMenu *menu);
#endif
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 853463b9b..48334b956 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1290,7 +1290,7 @@ update_favicon_control (EphyWindow *window)
cache = ephy_embed_shell_get_favicon_cache
(EPHY_EMBED_SHELL (ephy_shell));
- location = ephy_tab_get_favicon_url (tab);
+ location = ephy_tab_get_icon_address (tab);
if (location)
{
pixbuf = ephy_favicon_cache_get (cache, location);
diff --git a/src/toolbar.c b/src/toolbar.c
index b43a58c26..be3273e11 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -640,7 +640,7 @@ toolbar_update_favicon (Toolbar *t)
EggAction *action;
tab = ephy_window_get_active_tab (t->priv->window);
- url = ephy_tab_get_favicon_url (tab);
+ url = ephy_tab_get_icon_address (tab);
action_group = t->priv->action_group;
action = egg_action_group_get_action (action_group, "Favicon");
g_object_set (action, "icon", url, NULL);
diff --git a/src/window-commands.c b/src/window-commands.c
index 5fc3325df..e870716a1 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -301,7 +301,7 @@ window_cmd_file_bookmark_page (EggAction *action,
title = g_strdup (_("Untitled"));
}
- icon = ephy_tab_get_favicon_url (tab);
+ icon = ephy_tab_get_icon_address (tab);
bookmarks = ephy_shell_get_bookmarks (ephy_shell);
if (ephy_new_bookmark_is_unique (bookmarks, GTK_WINDOW (window),