aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-02-25 01:43:48 +0800
committerChristian Persch <chpe@src.gnome.org>2004-02-25 01:43:48 +0800
commit881bfd24e673370efefc8f5ceb3cec3afa9e44bc (patch)
tree49ade73b432ced4cc693e48ab9710999dc622286
parentcb176ab1f40f443c4051fb430c8b6ccb79290f67 (diff)
downloadgsoc2013-epiphany-881bfd24e673370efefc8f5ceb3cec3afa9e44bc.tar
gsoc2013-epiphany-881bfd24e673370efefc8f5ceb3cec3afa9e44bc.tar.gz
gsoc2013-epiphany-881bfd24e673370efefc8f5ceb3cec3afa9e44bc.tar.bz2
gsoc2013-epiphany-881bfd24e673370efefc8f5ceb3cec3afa9e44bc.tar.lz
gsoc2013-epiphany-881bfd24e673370efefc8f5ceb3cec3afa9e44bc.tar.xz
gsoc2013-epiphany-881bfd24e673370efefc8f5ceb3cec3afa9e44bc.tar.zst
gsoc2013-epiphany-881bfd24e673370efefc8f5ceb3cec3afa9e44bc.zip
Make EphyTab inherit from GtkBin, and contain the EphyEmbed as its child.
2004-02-24 Christian Persch <chpe@cvs.gnome.org> * src/ephy-nautilus-view.c: (gnv_embed_new_window_cb): * src/ephy-notebook.c: (ephy_notebook_class_init), (tab_label_size_request_cb), (ephy_notebook_move_tab), (move_tab), (motion_notify_cb), (move_tab_to_another_notebook), (button_release_cb), (ephy_notebook_switch_page_cb), (ephy_notebook_init), (close_button_clicked_cb), (build_tab_label), (ephy_notebook_insert_tab), (smart_tab_switching_on_closure), (ephy_notebook_remove_tab): * src/ephy-notebook.h: * src/ephy-session.c: (tab_added_cb), (tab_removed_cb): * src/ephy-shell.c: (ephy_shell_new_tab): * src/ephy-tab.c: (ephy_tab_get_type), (ephy_tab_size_allocate), (ephy_tab_parent_set), (ephy_tab_class_init), (ephy_tab_finalize), (ephy_tab_new), (ephy_tab_get_embed), (ephy_tab_for_embed), (ephy_tab_new_window_cb), (let_me_resize_hack), (ephy_tab_visibility_cb), (ephy_tab_size_to_cb), (ephy_tab_dom_mouse_click_cb), (ephy_tab_init), (ephy_tab_update_navigation_flags), (ephy_tab_set_title): * src/ephy-tab.h: * src/ephy-tabs-menu.c: (tab_added_cb), (tab_removed_cb), (tabs_reordered_cb), (ephy_tabs_menu_set_window), (ephy_tabs_menu_update): * src/ephy-window.c: (tab_added_cb), (tab_removed_cb), (tab_detached_cb), (tabs_reordered_cb), (tab_delete_cb), (setup_notebook), (ephy_window_add_tab), (ephy_window_jump_to_tab), (real_get_active_tab), (ephy_window_remove_tab), (ephy_window_get_active_tab), (ephy_window_get_active_embed), (ephy_window_get_tabs): * src/ephy-window.h: * src/window-commands.c: (window_cmd_tabs_move_left), (window_cmd_tabs_move_right), (window_cmd_tabs_detach): Make EphyTab inherit from GtkBin, and contain the EphyEmbed as its child.
-rw-r--r--ChangeLog36
-rw-r--r--src/ephy-nautilus-view.c3
-rw-r--r--src/ephy-notebook.c167
-rw-r--r--src/ephy-notebook.h43
-rw-r--r--src/ephy-session.c8
-rw-r--r--src/ephy-shell.c3
-rw-r--r--src/ephy-tab.c138
-rw-r--r--src/ephy-tab.h7
-rw-r--r--src/ephy-tabs-menu.c36
-rw-r--r--src/ephy-window.c103
-rw-r--r--src/ephy-window.h2
-rw-r--r--src/window-commands.c15
12 files changed, 297 insertions, 264 deletions
diff --git a/ChangeLog b/ChangeLog
index 1db752b27..179b0bf3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+2004-02-24 Christian Persch <chpe@cvs.gnome.org>
+
+ * src/ephy-nautilus-view.c: (gnv_embed_new_window_cb):
+ * src/ephy-notebook.c: (ephy_notebook_class_init),
+ (tab_label_size_request_cb), (ephy_notebook_move_tab), (move_tab),
+ (motion_notify_cb), (move_tab_to_another_notebook),
+ (button_release_cb), (ephy_notebook_switch_page_cb),
+ (ephy_notebook_init), (close_button_clicked_cb), (build_tab_label),
+ (ephy_notebook_insert_tab), (smart_tab_switching_on_closure),
+ (ephy_notebook_remove_tab):
+ * src/ephy-notebook.h:
+ * src/ephy-session.c: (tab_added_cb), (tab_removed_cb):
+ * src/ephy-shell.c: (ephy_shell_new_tab):
+ * src/ephy-tab.c: (ephy_tab_get_type), (ephy_tab_size_allocate),
+ (ephy_tab_parent_set), (ephy_tab_class_init), (ephy_tab_finalize),
+ (ephy_tab_new), (ephy_tab_get_embed), (ephy_tab_for_embed),
+ (ephy_tab_new_window_cb), (let_me_resize_hack),
+ (ephy_tab_visibility_cb), (ephy_tab_size_to_cb),
+ (ephy_tab_dom_mouse_click_cb), (ephy_tab_init),
+ (ephy_tab_update_navigation_flags), (ephy_tab_set_title):
+ * src/ephy-tab.h:
+ * src/ephy-tabs-menu.c: (tab_added_cb), (tab_removed_cb),
+ (tabs_reordered_cb), (ephy_tabs_menu_set_window),
+ (ephy_tabs_menu_update):
+ * src/ephy-window.c: (tab_added_cb), (tab_removed_cb),
+ (tab_detached_cb), (tabs_reordered_cb), (tab_delete_cb),
+ (setup_notebook), (ephy_window_add_tab), (ephy_window_jump_to_tab),
+ (real_get_active_tab), (ephy_window_remove_tab),
+ (ephy_window_get_active_tab), (ephy_window_get_active_embed),
+ (ephy_window_get_tabs):
+ * src/ephy-window.h:
+ * src/window-commands.c: (window_cmd_tabs_move_left),
+ (window_cmd_tabs_move_right), (window_cmd_tabs_detach):
+
+ Make EphyTab inherit from GtkBin, and contain the EphyEmbed as its child.
+
2004-02-24 Marco Pesenti Gritti <marco@gnome.org>
* src/ephy-tab.c: (address_has_web_scheme):
diff --git a/src/ephy-nautilus-view.c b/src/ephy-nautilus-view.c
index 7a05e0b91..fd6b5420e 100644
--- a/src/ephy-nautilus-view.c
+++ b/src/ephy-nautilus-view.c
@@ -428,12 +428,13 @@ gnv_embed_new_window_cb (EphyEmbed *embed, EphyEmbed **new_embed,
window = ephy_window_new ();
new_tab = ephy_tab_new ();
+ gtk_widget_show (GTK_WIDGET (new_tab));
+
ephy_window_add_tab (window, new_tab, EPHY_NOTEBOOK_INSERT_LAST, FALSE);
*new_embed = ephy_tab_get_embed (new_tab);
}
-
static void
gnv_bonobo_control_activate_cb (BonoboControl *control, gboolean state, EphyNautilusView *view)
{
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index 56353b936..1a6d65cc8 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2002 Christophe Fergeau
- * Copyright (C) 2003 Christian Persch
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -74,7 +75,7 @@ static void ephy_notebook_class_init (EphyNotebookClass *klass);
static void ephy_notebook_finalize (GObject *object);
static void move_tab_to_another_notebook (EphyNotebook *src,
EphyNotebook *dest,
- gint dest_page);
+ int dest_position);
/* Local variables */
static GdkCursor *cursor = NULL;
@@ -146,7 +147,7 @@ ephy_notebook_class_init (EphyNotebookClass *klass)
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1,
- GTK_TYPE_WIDGET);
+ EPHY_TYPE_TAB);
signals[TAB_REMOVED] =
g_signal_new ("tab_removed",
G_OBJECT_CLASS_TYPE (object_class),
@@ -156,7 +157,7 @@ ephy_notebook_class_init (EphyNotebookClass *klass)
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1,
- GTK_TYPE_WIDGET);
+ EPHY_TYPE_TAB);
signals[TAB_DETACHED] =
g_signal_new ("tab_detached",
G_OBJECT_CLASS_TYPE (object_class),
@@ -166,7 +167,7 @@ ephy_notebook_class_init (EphyNotebookClass *klass)
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1,
- GTK_TYPE_WIDGET);
+ EPHY_TYPE_TAB);
signals[TABS_REORDERED] =
g_signal_new ("tabs_reordered",
G_OBJECT_CLASS_TYPE (object_class),
@@ -185,7 +186,7 @@ ephy_notebook_class_init (EphyNotebookClass *klass)
ephy_marshal_BOOLEAN__OBJECT,
G_TYPE_BOOLEAN,
1,
- GTK_TYPE_WIDGET);
+ EPHY_TYPE_TAB);
g_type_class_add_private (object_class, sizeof(EphyNotebookPrivate));
}
@@ -344,26 +345,28 @@ tab_label_set_size (GtkWidget *window, GtkWidget *label)
static void
tab_label_size_request_cb (GtkWidget *window,
GtkRequisition *requisition,
- GtkWidget *child)
+ GtkWidget *tab)
{
GtkWidget *hbox;
GtkWidget *nb;
- nb = child->parent;
+ nb = tab->parent;
hbox = gtk_notebook_get_tab_label (GTK_NOTEBOOK (nb),
- child);
+ tab);
tab_label_set_size (window, hbox);
}
-
void
-ephy_notebook_move_page (EphyNotebook *src, EphyNotebook *dest,
- GtkWidget *src_page, gint dest_page)
+ephy_notebook_move_tab (EphyNotebook *src,
+ EphyNotebook *dest,
+ EphyTab *tab,
+ int dest_position)
{
if (dest == NULL || src == dest)
{
- gtk_notebook_reorder_child (GTK_NOTEBOOK (src), src_page, dest_page);
+ gtk_notebook_reorder_child
+ (GTK_NOTEBOOK (src), GTK_WIDGET (tab), dest_position);
if (src->priv->drag_in_progress == FALSE)
{
@@ -372,12 +375,11 @@ ephy_notebook_move_page (EphyNotebook *src, EphyNotebook *dest,
}
else
{
- /* make sure the tab isn't destroyed while we move its embed */
- g_object_ref (G_OBJECT (src_page));
- ephy_notebook_remove_page (EPHY_NOTEBOOK (src), src_page);
- ephy_notebook_insert_page (EPHY_NOTEBOOK (dest), src_page,
- dest_page, TRUE);
- g_object_unref (G_OBJECT (src_page));
+ /* make sure the tab isn't destroyed while we move it */
+ g_object_ref (tab);
+ ephy_notebook_remove_tab (src, tab);
+ ephy_notebook_insert_tab (dest, tab, dest_position, TRUE);
+ g_object_unref (tab);
}
}
@@ -420,19 +422,22 @@ drag_stop (EphyNotebook *notebook)
* here, instead we do it on drag_stop
*/
static void
-move_tab (EphyNotebook *notebook, gint dest_page_num)
+move_tab (EphyNotebook *notebook,
+ int dest_position)
{
gint cur_page_num;
cur_page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
- if (dest_page_num != cur_page_num)
+ if (dest_position != cur_page_num)
{
- GtkWidget *cur_page;
- cur_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook),
- cur_page_num);
- ephy_notebook_move_page (EPHY_NOTEBOOK (notebook), NULL, cur_page,
- dest_page_num);
+ GtkWidget *cur_tab;
+
+ cur_tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook),
+ cur_page_num);
+ ephy_notebook_move_tab (EPHY_NOTEBOOK (notebook), NULL,
+ EPHY_TAB (cur_tab),
+ dest_position);
/* Reset the list of newly opened tabs when moving tabs. */
g_list_free (notebook->priv->opened_tabs);
@@ -441,7 +446,8 @@ move_tab (EphyNotebook *notebook, gint dest_page_num)
}
static gboolean
-motion_notify_cb (EphyNotebook *notebook, GdkEventMotion *event,
+motion_notify_cb (EphyNotebook *notebook,
+ GdkEventMotion *event,
gpointer data)
{
EphyNotebook *dest;
@@ -485,11 +491,12 @@ motion_notify_cb (EphyNotebook *notebook, GdkEventMotion *event,
}
static void
-move_tab_to_another_notebook(EphyNotebook *src,
- EphyNotebook *dest, gint dest_page)
+move_tab_to_another_notebook (EphyNotebook *src,
+ EphyNotebook *dest,
+ int dest_position)
{
- GtkWidget *child;
- gint cur_page;
+ EphyTab *tab;
+ int cur_page;
/* This is getting tricky, the tab was dragged in a notebook
* in another window of the same app, we move the tab
@@ -500,13 +507,13 @@ move_tab_to_another_notebook(EphyNotebook *src,
g_assert (dest != src);
cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (src));
- child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (src), cur_page);
+ tab = EPHY_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (src), cur_page));
/* stop drag in origin window */
drag_stop (src);
gtk_grab_remove (GTK_WIDGET (src));
- ephy_notebook_move_page (src, dest, child, dest_page);
+ ephy_notebook_move_tab (src, dest, tab, dest_position);
/* start drag handling in dest notebook */
drag_start (dest);
@@ -518,9 +525,9 @@ move_tab_to_another_notebook(EphyNotebook *src,
NULL);
}
-/* Callbacks */
static gboolean
-button_release_cb (EphyNotebook *notebook, GdkEventButton *event,
+button_release_cb (EphyNotebook *notebook,
+ GdkEventButton *event,
gpointer data)
{
if (notebook->priv->drag_in_progress)
@@ -553,7 +560,6 @@ button_release_cb (EphyNotebook *notebook, GdkEventButton *event,
return FALSE;
}
-
static gboolean
button_press_cb (EphyNotebook *notebook,
GdkEventButton *event,
@@ -590,9 +596,9 @@ ephy_notebook_new (void)
static void
ephy_notebook_switch_page_cb (GtkNotebook *notebook,
- GtkNotebookPage *page,
- guint page_num,
- gpointer data)
+ GtkNotebookPage *page,
+ guint page_num,
+ gpointer data)
{
EphyNotebook *nb = EPHY_NOTEBOOK (notebook);
GtkWidget *child;
@@ -737,6 +743,10 @@ ephy_notebook_init (EphyNotebook *notebook)
{
notebook->priv = EPHY_NOTEBOOK_GET_PRIVATE (notebook);
+ gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
+
notebook->priv->title_tips = gtk_tooltips_new ();
g_object_ref (G_OBJECT (notebook->priv->title_tips));
gtk_object_sink (GTK_OBJECT (notebook->priv->title_tips));
@@ -864,22 +874,22 @@ sync_label (EphyTab *tab, GParamSpec *pspec, GtkWidget *proxy)
}
static void
-close_button_clicked_cb (GtkWidget *widget, GtkWidget *child)
+close_button_clicked_cb (GtkWidget *widget, GtkWidget *tab)
{
EphyNotebook *notebook;
gboolean inhibited = FALSE;
- notebook = EPHY_NOTEBOOK (gtk_widget_get_parent (child));
- g_signal_emit (G_OBJECT (notebook), signals[TAB_DELETE], 0, child, &inhibited);
+ notebook = EPHY_NOTEBOOK (gtk_widget_get_parent (tab));
+ g_signal_emit (G_OBJECT (notebook), signals[TAB_DELETE], 0, tab, &inhibited);
if (inhibited == FALSE)
{
- ephy_notebook_remove_page (notebook, child);
+ ephy_notebook_remove_tab (notebook, EPHY_TAB (tab));
}
}
static GtkWidget *
-build_tab_label (EphyNotebook *nb, GtkWidget *child)
+build_tab_label (EphyNotebook *nb, EphyTab *tab)
{
GtkWidget *label, *hbox, *close_button, *image;
int h, w;
@@ -930,7 +940,7 @@ build_tab_label (EphyNotebook *nb, GtkWidget *child)
tab_label_set_size (GTK_WIDGET (window), hbox);
closure = g_cclosure_new (G_CALLBACK (tab_label_size_request_cb),
- child, NULL);
+ tab, NULL);
g_object_watch_closure (G_OBJECT (label), closure);
g_signal_connect_closure_by_id (G_OBJECT (window),
g_signal_lookup ("size_request",
@@ -944,7 +954,7 @@ build_tab_label (EphyNotebook *nb, GtkWidget *child)
g_signal_connect (G_OBJECT (close_button), "clicked",
G_CALLBACK (close_button_clicked_cb),
- child);
+ tab);
gtk_widget_show (hbox);
gtk_widget_show (label_ebox);
@@ -970,19 +980,16 @@ ephy_notebook_set_show_tabs (EphyNotebook *nb, gboolean show_tabs)
}
void
-ephy_notebook_insert_page (EphyNotebook *nb,
- GtkWidget *child,
- int position,
- gboolean jump_to)
+ephy_notebook_insert_tab (EphyNotebook *nb,
+ EphyTab *tab,
+ int position,
+ gboolean jump_to)
{
- EphyTab *tab;
GtkWidget *label;
- g_return_if_fail (EPHY_IS_EMBED (child));
- tab = ephy_tab_for_embed (EPHY_EMBED (child));
g_return_if_fail (EPHY_IS_TAB (tab));
- label = build_tab_label (nb, child);
+ label = build_tab_label (nb, tab);
update_tabs_visibility (nb, TRUE);
@@ -1005,16 +1012,16 @@ ephy_notebook_insert_page (EphyNotebook *nb,
(GTK_NOTEBOOK (nb)) + 1;
}
nb->priv->opened_tabs =
- g_list_append (nb->priv->opened_tabs, child);
+ g_list_append (nb->priv->opened_tabs, tab);
}
- gtk_notebook_insert_page (GTK_NOTEBOOK (nb), child,
+ gtk_notebook_insert_page (GTK_NOTEBOOK (nb), GTK_WIDGET (tab),
label, position);
/* Set up drag-and-drop target */
g_signal_connect (G_OBJECT(label), "drag_data_received",
- G_CALLBACK(notebook_drag_data_received_cb), child);
+ G_CALLBACK(notebook_drag_data_received_cb), tab);
gtk_drag_dest_set (label, GTK_DEST_DEFAULT_ALL,
url_drag_types,n_url_drag_types,
GDK_ACTION_MOVE | GDK_ACTION_COPY);
@@ -1030,25 +1037,25 @@ ephy_notebook_insert_page (EphyNotebook *nb,
g_signal_connect_object (tab, "notify::load-status",
G_CALLBACK (sync_load_status), label, 0);
- g_signal_emit (G_OBJECT (nb), signals[TAB_ADDED], 0, child);
+ g_signal_emit (G_OBJECT (nb), signals[TAB_ADDED], 0, tab);
if (jump_to)
{
gtk_notebook_set_current_page (GTK_NOTEBOOK (nb),
position);
- g_object_set_data (G_OBJECT (child), "jump_to",
+ g_object_set_data (G_OBJECT (tab), "jump_to",
GINT_TO_POINTER (jump_to));
}
}
static void
smart_tab_switching_on_closure (EphyNotebook *nb,
- GtkWidget *child)
+ EphyTab *tab)
{
gboolean jump_to;
jump_to = GPOINTER_TO_INT (g_object_get_data
- (G_OBJECT (child), "jump_to"));
+ (G_OBJECT (tab), "jump_to"));
if (!jump_to || !nb->priv->focused_pages)
{
@@ -1071,17 +1078,13 @@ smart_tab_switching_on_closure (EphyNotebook *nb,
}
void
-ephy_notebook_remove_page (EphyNotebook *nb,
- GtkWidget *child)
+ephy_notebook_remove_tab (EphyNotebook *nb,
+ EphyTab *tab)
{
int num, position, curr;
- EphyTab *tab;
GtkWidget *label, *ebox;
g_return_if_fail (EPHY_IS_NOTEBOOK (nb));
- g_return_if_fail (EPHY_IS_EMBED (child));
-
- tab = ephy_tab_for_embed (EPHY_EMBED (child));
g_return_if_fail (EPHY_IS_TAB (tab));
num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
@@ -1095,39 +1098,39 @@ ephy_notebook_remove_page (EphyNotebook *nb,
/* Remove the page from the focused pages list */
nb->priv->focused_pages = g_list_remove (nb->priv->focused_pages,
- child);
- nb->priv->opened_tabs = g_list_remove (nb->priv->opened_tabs, child);
+ tab);
+ nb->priv->opened_tabs = g_list_remove (nb->priv->opened_tabs, tab);
- position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), child);
+ position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));
curr = gtk_notebook_get_current_page (GTK_NOTEBOOK (nb));
if (position == curr)
{
- smart_tab_switching_on_closure (nb, child);
+ smart_tab_switching_on_closure (nb, tab);
}
- label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (nb), child);
+ label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));
ebox = GTK_WIDGET (g_object_get_data (G_OBJECT (label), "label-ebox"));
gtk_tooltips_set_tip (GTK_TOOLTIPS (nb->priv->title_tips), ebox, NULL, NULL);
- g_signal_handlers_disconnect_by_func (label,
- G_CALLBACK (sync_icon), tab);
- g_signal_handlers_disconnect_by_func (label,
- G_CALLBACK (sync_label), tab);
- g_signal_handlers_disconnect_by_func (label,
- G_CALLBACK (sync_load_status), tab);
+ g_signal_handlers_disconnect_by_func (tab,
+ G_CALLBACK (sync_icon), label);
+ g_signal_handlers_disconnect_by_func (tab,
+ G_CALLBACK (sync_label), label);
+ g_signal_handlers_disconnect_by_func (tab,
+ G_CALLBACK (sync_load_status), label);
/**
- * we ref the child so that it's still alive while the tabs_removed
+ * we ref the tab so that it's still alive while the tabs_removed
* signal is processed.
*/
- g_object_ref (child);
+ g_object_ref (tab);
gtk_notebook_remove_page (GTK_NOTEBOOK (nb), position);
update_tabs_visibility (nb, FALSE);
- g_signal_emit (G_OBJECT (nb), signals[TAB_REMOVED], 0, child);
+ g_signal_emit (G_OBJECT (nb), signals[TAB_REMOVED], 0, tab);
- g_object_unref (child);
+ g_object_unref (tab);
}
diff --git a/src/ephy-notebook.h b/src/ephy-notebook.h
index 314ad098c..452fb10db 100644
--- a/src/ephy-notebook.h
+++ b/src/ephy-notebook.h
@@ -1,5 +1,7 @@
/*
* Copyright (C) 2002 Christophe Fergeau
+ * Copyright (C) 2003 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,6 +23,8 @@
#ifndef EPHY_NOTEBOOK_H
#define EPHY_NOTEBOOK_H
+#include "ephy-tab.h"
+
#include <glib.h>
#include <gtk/gtknotebook.h>
@@ -33,21 +37,14 @@ G_BEGIN_DECLS
#define EPHY_IS_NOTEBOOK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_NOTEBOOK))
#define EPHY_NOTEBOOK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_NOTEBOOK, EphyNotebookClass))
-typedef struct EphyNotebookClass EphyNotebookClass;
-typedef struct EphyNotebook EphyNotebook;
-typedef struct EphyNotebookPrivate EphyNotebookPrivate;
-
-typedef enum
-{
- EPHY_NOTEBOOK_TAB_LOAD_NORMAL,
- EPHY_NOTEBOOK_TAB_LOAD_LOADING,
- EPHY_NOTEBOOK_TAB_LOAD_COMPLETED
-} EphyNotebookPageLoadStatus;
+typedef struct EphyNotebookClass EphyNotebookClass;
+typedef struct EphyNotebook EphyNotebook;
+typedef struct EphyNotebookPrivate EphyNotebookPrivate;
enum
{
- EPHY_NOTEBOOK_INSERT_LAST = -1,
- EPHY_NOTEBOOK_INSERT_GROUPED = -2
+ EPHY_NOTEBOOK_INSERT_LAST = -1,
+ EPHY_NOTEBOOK_INSERT_GROUPED = -2
};
struct EphyNotebook
@@ -64,32 +61,32 @@ struct EphyNotebookClass
/* Signals */
void (* tab_added) (EphyNotebook *notebook,
- GtkWidget *child);
+ EphyTab *tab);
void (* tab_removed) (EphyNotebook *notebook,
- GtkWidget *child);
+ EphyTab *tab);
void (* tab_detached) (EphyNotebook *notebook,
- GtkWidget *child);
+ EphyTab *tab);
void (* tabs_reordered) (EphyNotebook *notebook);
void (* tab_delete) (EphyNotebook *notebook,
- GtkWidget *child);
+ EphyTab *tab);
};
GType ephy_notebook_get_type (void);
GtkWidget *ephy_notebook_new (void);
-void ephy_notebook_insert_page (EphyNotebook *nb,
- GtkWidget *child,
+void ephy_notebook_insert_tab (EphyNotebook *nb,
+ EphyTab *tab,
int position,
gboolean jump_to);
-void ephy_notebook_remove_page (EphyNotebook *nb,
- GtkWidget *child);
+void ephy_notebook_remove_tab (EphyNotebook *nb,
+ EphyTab *tab);
-void ephy_notebook_move_page (EphyNotebook *src,
+void ephy_notebook_move_tab (EphyNotebook *src,
EphyNotebook *dest,
- GtkWidget *src_page,
- gint dest_page);
+ EphyTab *tab,
+ int dest_position);
void ephy_notebook_set_show_tabs (EphyNotebook *nb,
gboolean show_tabs);
diff --git a/src/ephy-session.c b/src/ephy-session.c
index cd318d264..7c91444e5 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -151,22 +151,22 @@ net_stop_cb (EphyEmbed *embed,
static void
tab_added_cb (GtkWidget *notebook,
- GtkWidget *child,
+ EphyTab *tab,
EphySession *session)
{
- g_signal_connect (child, "net_stop",
+ g_signal_connect (ephy_tab_get_embed (tab), "net_stop",
G_CALLBACK (net_stop_cb), session);
}
static void
tab_removed_cb (GtkWidget *notebook,
- GtkWidget *child,
+ EphyTab *tab,
EphySession *session)
{
ephy_session_save (session, SESSION_CRASHED);
g_signal_handlers_disconnect_by_func
- (child, G_CALLBACK (net_stop_cb), session);
+ (ephy_tab_get_embed (tab), G_CALLBACK (net_stop_cb), session);
}
static void
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index f22da2cc0..7bd229531 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -600,8 +600,9 @@ ephy_shell_new_tab (EphyShell *shell,
}
tab = ephy_tab_new ();
+ gtk_widget_show (GTK_WIDGET (tab));
embed = ephy_tab_get_embed (tab);
- gtk_widget_show (GTK_WIDGET(embed));
+
ephy_window_add_tab (window, tab,
position,
jump_to);
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 5cf9c83aa..0f0d84d67 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2000-2003 Marco Pesenti Gritti
- * Copyright (C) 2003 Christian Persch
+ * Copyright (C) 2003, 2004 Christian Persch
+ * Copyright (C) 2004 Crispin Flowerday
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -61,7 +62,6 @@
struct EphyTabPrivate
{
- EphyEmbed *embed;
EphyWindow *window;
char *status_message;
char *link_message;
@@ -146,7 +146,7 @@ ephy_tab_get_type (void)
(GInstanceInitFunc) ephy_tab_init
};
- ephy_tab_type = g_type_register_static (G_TYPE_OBJECT,
+ ephy_tab_type = g_type_register_static (GTK_TYPE_BIN,
"EphyTab",
&our_info, 0);
}
@@ -233,6 +233,40 @@ ephy_tab_get_property (GObject *object,
}
static void
+ephy_tab_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GtkWidget *child;
+
+ widget->allocation = *allocation;
+
+ child = GTK_BIN (widget)->child;
+
+ if (child && GTK_WIDGET_VISIBLE (child))
+ {
+ gtk_widget_size_allocate (child, allocation);
+ }
+}
+
+static void
+ephy_tab_parent_set (GtkWidget *widget,
+ GtkWidget *previous_parent)
+{
+ if (widget->parent)
+ {
+ GtkWidget *toplevel;
+ toplevel = gtk_widget_get_toplevel (widget);
+
+ ephy_tab_set_window (EPHY_TAB (widget), EPHY_WINDOW (toplevel));
+ }
+
+ if (GTK_WIDGET_CLASS (parent_class)->parent_set)
+ {
+ GTK_WIDGET_CLASS (parent_class)->parent_set (widget, previous_parent);
+ }
+}
+
+static void
ephy_tab_action_activate_cb (GtkAction *action, EphyTab *tab)
{
g_return_if_fail (EPHY_IS_TAB (tab));
@@ -248,6 +282,7 @@ static void
ephy_tab_class_init (EphyTabClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(class);
parent_class = g_type_class_peek_parent (class);
@@ -255,6 +290,9 @@ ephy_tab_class_init (EphyTabClass *class)
object_class->get_property = ephy_tab_get_property;
object_class->set_property = ephy_tab_set_property;
+ widget_class->size_allocate = ephy_tab_size_allocate;
+ widget_class->parent_set = ephy_tab_parent_set;
+
g_object_class_install_property (object_class,
PROP_ADDRESS,
g_param_spec_string ("address",
@@ -357,31 +395,13 @@ ephy_tab_class_init (EphyTabClass *class)
}
static void
-ephy_tab_parent_set_cb (GtkWidget *widget, GtkWidget *previous_parent,
- EphyTab *tab)
-{
- GtkWidget *toplevel;
-
- if (widget->parent == NULL) return;
-
- toplevel = gtk_widget_get_toplevel (widget);
- ephy_tab_set_window (tab, EPHY_WINDOW (toplevel));
-}
-static void
-ephy_tab_embed_destroy_cb (GtkWidget *widget, EphyTab *tab)
-{
- LOG ("GtkMozEmbed destroy signal on EphyTab")
- g_object_unref (tab);
-}
-
-static void
ephy_tab_finalize (GObject *object)
{
EphyTab *tab = EPHY_TAB (object);
- g_idle_remove_by_data (tab->priv->embed);
+ g_idle_remove_by_data (tab);
- if (tab->priv->action)
+ if (tab->priv->action != NULL)
{
g_object_unref (tab->priv->action);
}
@@ -420,11 +440,7 @@ address_has_web_scheme (const char *address)
EphyTab *
ephy_tab_new (void)
{
- EphyTab *tab;
-
- tab = EPHY_TAB (g_object_new (EPHY_TYPE_TAB, NULL));
-
- return tab;
+ return EPHY_TAB (g_object_new (EPHY_TYPE_TAB, NULL));
}
static void
@@ -469,19 +485,20 @@ ephy_tab_get_embed (EphyTab *tab)
{
g_return_val_if_fail (EPHY_IS_TAB (tab), NULL);
- return tab->priv->embed;
+ return EPHY_EMBED (gtk_bin_get_child (GTK_BIN (tab)));
}
EphyTab *
ephy_tab_for_embed (EphyEmbed *embed)
{
- EphyTab *tab;
+ GtkWidget *parent;
g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL);
- tab = EPHY_TAB (g_object_get_data (G_OBJECT (embed), "ephy-tab"));
+ parent = GTK_WIDGET (embed)->parent;
+ g_return_val_if_fail (parent != NULL, NULL);
- return tab;
+ return EPHY_TAB (parent);
}
void
@@ -878,30 +895,38 @@ ephy_tab_new_window_cb (EphyEmbed *embed, EphyEmbed **new_embed,
ephy_window_request_chrome (window, chromemask);
new_tab = ephy_tab_new ();
+ gtk_widget_show (GTK_WIDGET (new_tab));
+
ephy_window_add_tab (window, new_tab, EPHY_NOTEBOOK_INSERT_GROUPED, FALSE);
*new_embed = ephy_tab_get_embed (new_tab);
}
static gboolean
-let_me_resize_hack (gpointer data)
+let_me_resize_hack (gpointer *tab_ptr)
{
- gtk_widget_set_size_request (GTK_WIDGET(data),
- -1, -1);
+ if (*tab_ptr != NULL)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (*tab_ptr), tab_ptr);
+ gtk_widget_set_size_request (GTK_WIDGET (*tab_ptr), -1, -1);
+
+ g_free (tab_ptr);
+ }
+
return FALSE;
}
static void
ephy_tab_visibility_cb (EphyEmbed *embed, gboolean visibility,
- EphyTab *tab)
+ EphyTab *tab)
{
if (visibility)
{
- gtk_widget_show (GTK_WIDGET(embed));
+ gtk_widget_show (GTK_WIDGET (tab));
}
else
{
- gtk_widget_hide (GTK_WIDGET(embed));
+ gtk_widget_hide (GTK_WIDGET (tab));
}
ephy_tab_set_visibility (tab, visibility);
@@ -922,14 +947,13 @@ ephy_tab_size_to_cb (EphyEmbed *embed, gint width, gint height,
{
GtkWidget *notebook;
EphyWindow *window;
- GtkWidget *widget;
+ gpointer *tab_ptr;
tab->priv->width = width;
tab->priv->height = height;
window = tab->priv->window;
notebook = ephy_window_get_notebook (window);
- widget = GTK_WIDGET (embed);
/* Do not resize window with multiple tabs.
* Do not resize window already showed because
@@ -939,14 +963,18 @@ ephy_tab_size_to_cb (EphyEmbed *embed, gint width, gint height,
!tab->priv->visibility)
{
gtk_widget_set_size_request
- (widget, width, height);
+ (GTK_WIDGET (tab), width, height);
/* HACK reset widget requisition after the container
* has been resized. It appears to be the only way
* to have the window sized according to embed
* size correctly.
*/
- g_idle_add (let_me_resize_hack, embed);
+
+ tab_ptr = g_new (gpointer, 1);
+ *tab_ptr = tab;
+ g_object_add_weak_pointer (G_OBJECT (tab), tab_ptr);
+ g_idle_add ((GSourceFunc) let_me_resize_hack, tab_ptr);
}
}
@@ -1100,7 +1128,7 @@ ephy_tab_dom_mouse_click_cb (EphyEmbed *embed,
g_object_add_weak_pointer (G_OBJECT (tab), weak_ptr);
gtk_clipboard_request_text
- (gtk_widget_get_clipboard (GTK_WIDGET (tab->priv->embed),
+ (gtk_widget_get_clipboard (GTK_WIDGET (tab),
GDK_SELECTION_PRIMARY),
(GtkClipboardTextReceivedFunc) clipboard_text_received_cb,
weak_ptr);
@@ -1124,7 +1152,7 @@ ephy_tab_security_change_cb (EphyEmbed *embed, EmbedSecurityLevel level,
static void
ephy_tab_init (EphyTab *tab)
{
- GObject *embed, *embed_widget;
+ GObject *embed;
EphyFaviconCache *cache;
char *id;
@@ -1150,12 +1178,11 @@ ephy_tab_init (EphyTab *tab)
tab->priv->setting_zoom = FALSE;
tab->priv->address_expire = TAB_ADDRESS_EXPIRE_NOW;
- tab->priv->embed = EPHY_EMBED
- (ephy_embed_factory_new_object ("EphyEmbed"));
- g_assert (tab->priv->embed != NULL);
+ embed = ephy_embed_factory_new_object ("EphyEmbed");
+ g_assert (embed != NULL);
- embed = G_OBJECT (tab->priv->embed);
- embed_widget = G_OBJECT (tab->priv->embed);
+ gtk_container_add (GTK_CONTAINER (tab), GTK_WIDGET (embed));
+ gtk_widget_show (GTK_WIDGET (embed));
id = g_strdup_printf ("Tab%lu", tab_id++);
@@ -1169,15 +1196,6 @@ ephy_tab_init (EphyTab *tab)
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, "ephy-tab", tab);
-
- g_signal_connect_object (embed_widget, "parent_set",
- G_CALLBACK (ephy_tab_parent_set_cb),
- tab, 0);
- g_signal_connect_object (embed_widget, "destroy",
- G_CALLBACK (ephy_tab_embed_destroy_cb),
- tab, 0);
g_signal_connect_object (embed, "link_message",
G_CALLBACK (ephy_tab_link_message_cb),
tab, 0);
@@ -1249,7 +1267,7 @@ ephy_tab_update_navigation_flags (EphyTab *tab)
EphyEmbed *embed;
TabNavigationFlags flags = 0;
- embed = tab->priv->embed;
+ embed = ephy_tab_get_embed (tab);
if (ephy_embed_can_go_up (embed))
{
@@ -1318,7 +1336,7 @@ ephy_tab_set_title (EphyTab *tab, const char *new_title)
GnomeVFSURI *uri = NULL;
char *address;
- address = ephy_embed_get_location (tab->priv->embed, TRUE);
+ address = ephy_embed_get_location (ephy_tab_get_embed (tab), TRUE);
if (address)
{
diff --git a/src/ephy-tab.h b/src/ephy-tab.h
index cb685cd74..69408213f 100644
--- a/src/ephy-tab.h
+++ b/src/ephy-tab.h
@@ -24,8 +24,7 @@
#include "ephy-embed.h"
-#include <glib-object.h>
-#include <gtk/gtkwidget.h>
+#include <gtk/gtkbin.h>
G_BEGIN_DECLS
@@ -56,7 +55,7 @@ typedef enum
struct EphyTab
{
- GObject parent;
+ GtkBin parent;
/*< private >*/
EphyTabPrivate *priv;
@@ -64,7 +63,7 @@ struct EphyTab
struct EphyTabClass
{
- GObjectClass parent_class;
+ GtkBinClass parent_class;
};
/* Include the header down here to resolve circular dependency */
diff --git a/src/ephy-tabs-menu.c b/src/ephy-tabs-menu.c
index ffa4a7058..df6984627 100644
--- a/src/ephy-tabs-menu.c
+++ b/src/ephy-tabs-menu.c
@@ -38,10 +38,6 @@
#define MAX_LABEL_LENGTH 30
-/**
- * Private data
- */
-
#define EPHY_TABS_MENU_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TABS_MENU, EphyTabsMenuPrivate))
struct _EphyTabsMenuPrivate
@@ -51,9 +47,6 @@ struct _EphyTabsMenuPrivate
guint ui_id;
};
-/**
- * Private functions, only availble from this file
- */
static void ephy_tabs_menu_class_init (EphyTabsMenuClass *klass);
static void ephy_tabs_menu_init (EphyTabsMenu *menu);
@@ -63,10 +56,6 @@ enum
PROP_WINDOW
};
-/**
- * EphyTabsMenu object
- */
-
GType
ephy_tabs_menu_get_type (void)
{
@@ -96,13 +85,11 @@ ephy_tabs_menu_get_type (void)
}
static void
-tab_added_cb (EphyNotebook *notebook, EphyEmbed *embed, EphyTabsMenu *menu)
+tab_added_cb (EphyNotebook *notebook, EphyTab *tab, EphyTabsMenu *menu)
{
- EphyTab *tab;
GtkAction *action;
- g_return_if_fail (EPHY_IS_EMBED (embed));
- tab = ephy_tab_for_embed (embed);
+ g_return_if_fail (EPHY_IS_TAB (tab));
action = GTK_ACTION (ephy_tab_get_action (tab));
gtk_action_group_add_action (menu->priv->action_group, action);
@@ -111,13 +98,11 @@ tab_added_cb (EphyNotebook *notebook, EphyEmbed *embed, EphyTabsMenu *menu)
}
static void
-tab_removed_cb (EphyNotebook *notebook, EphyEmbed *embed, EphyTabsMenu *menu)
+tab_removed_cb (EphyNotebook *notebook, EphyTab *tab, EphyTabsMenu *menu)
{
- EphyTab *tab;
GtkAction *action;
- g_return_if_fail (EPHY_IS_EMBED (embed));
- tab = ephy_tab_for_embed (embed);
+ g_return_if_fail (EPHY_IS_TAB (tab));
action = GTK_ACTION (ephy_tab_get_action (tab));
gtk_action_group_remove_action (menu->priv->action_group, action);
@@ -126,6 +111,12 @@ tab_removed_cb (EphyNotebook *notebook, EphyEmbed *embed, EphyTabsMenu *menu)
}
static void
+tabs_reordered_cb (EphyNotebook *notebook, EphyTabsMenu *menu)
+{
+ ephy_tabs_menu_update (menu);
+}
+
+static void
ephy_tabs_menu_set_window (EphyTabsMenu *menu, EphyWindow *window)
{
GtkWidget *notebook;
@@ -143,6 +134,8 @@ ephy_tabs_menu_set_window (EphyTabsMenu *menu, EphyWindow *window)
G_CALLBACK (tab_added_cb), menu, 0);
g_signal_connect_object (notebook, "tab_removed",
G_CALLBACK (tab_removed_cb), menu, 0);
+ g_signal_connect_object (notebook, "tabs_reordered",
+ G_CALLBACK (tabs_reordered_cb), menu, 0);
}
static void
@@ -281,7 +274,6 @@ ephy_tabs_menu_update (EphyTabsMenu *menu)
EphyTab *tab;
GtkAction *action;
guint i = 0;
- guint num = 0;
GList *tabs = NULL, *l;
g_return_if_fail (EPHY_IS_TABS_MENU (menu));
@@ -296,8 +288,7 @@ ephy_tabs_menu_update (EphyTabsMenu *menu)
tabs = ephy_window_get_tabs (p->window);
- num = g_list_length (tabs);
- if (num == 0) return;
+ if (g_list_length (tabs) == 0) return;
p->ui_id = gtk_ui_manager_new_merge_id (merge);
@@ -306,7 +297,6 @@ ephy_tabs_menu_update (EphyTabsMenu *menu)
const char *action_name;
char *name;
-
tab = (EphyTab *) l->data;
action = GTK_ACTION (ephy_tab_get_action (tab));
action_name = gtk_action_get_name (action);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 193858355..0b3a4fa5e 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1563,12 +1563,11 @@ update_tabs_menu_sensitivity (EphyWindow *window)
}
static void
-tab_added_cb (EphyNotebook *notebook, EphyEmbed *embed, EphyWindow *window)
+tab_added_cb (EphyNotebook *notebook,
+ EphyTab *tab,
+ EphyWindow *window)
{
- EphyTab *tab;
-
- g_return_if_fail (EPHY_IS_EMBED (embed));
- tab = ephy_tab_for_embed (embed);
+ g_return_if_fail (EPHY_IS_TAB (tab));
window->priv->num_tabs++;
@@ -1579,12 +1578,11 @@ tab_added_cb (EphyNotebook *notebook, EphyEmbed *embed, EphyWindow *window)
}
static void
-tab_removed_cb (EphyNotebook *notebook, EphyEmbed *embed, EphyWindow *window)
+tab_removed_cb (EphyNotebook *notebook,
+ EphyTab *tab,
+ EphyWindow *window)
{
- EphyTab *tab;
-
- g_return_if_fail (EPHY_IS_EMBED (embed));
- tab = ephy_tab_for_embed (embed);
+ g_return_if_fail (EPHY_IS_TAB (tab));
g_signal_handlers_disconnect_by_func (G_OBJECT (tab),
G_CALLBACK (sync_tab_visibility),
@@ -1604,18 +1602,18 @@ tab_removed_cb (EphyNotebook *notebook, EphyEmbed *embed, EphyWindow *window)
}
static void
-tab_detached_cb (EphyNotebook *notebook, GtkWidget *child,
+tab_detached_cb (EphyNotebook *notebook,
+ EphyTab *tab,
gpointer data)
{
EphyWindow *window;
- g_return_if_fail (EPHY_IS_NOTEBOOK (notebook));
- g_return_if_fail (EPHY_IS_EMBED (child));
+ g_return_if_fail (EPHY_IS_TAB (tab));
window = ephy_window_new ();
- ephy_notebook_move_page (notebook,
- EPHY_NOTEBOOK (ephy_window_get_notebook (window)),
- child, 0);
+ ephy_notebook_move_tab (notebook,
+ EPHY_NOTEBOOK (ephy_window_get_notebook (window)),
+ tab, 0);
gtk_widget_show (GTK_WIDGET (window));
}
@@ -1623,15 +1621,16 @@ static void
tabs_reordered_cb (EphyNotebook *notebook, EphyWindow *window)
{
update_tabs_menu_sensitivity (window);
- ephy_tabs_menu_update (window->priv->tabs_menu);
}
static gboolean
-tab_delete_cb (EphyNotebook *notebook, GtkWidget *child, EphyWindow *window)
+tab_delete_cb (EphyNotebook *notebook,
+ EphyTab *tab,
+ EphyWindow *window)
{
- g_return_val_if_fail (EPHY_IS_EMBED (child), FALSE);
+ g_return_val_if_fail (EPHY_IS_TAB (tab), FALSE);
- if (ephy_embed_has_modified_forms (EPHY_EMBED (child)))
+ if (ephy_embed_has_modified_forms (ephy_tab_get_embed (tab)))
{
return !confirm_close_with_modified_forms (window);
}
@@ -1645,9 +1644,6 @@ setup_notebook (EphyWindow *window)
GtkNotebook *notebook;
notebook = GTK_NOTEBOOK (ephy_notebook_new ());
- gtk_notebook_set_scrollable (notebook, TRUE);
- gtk_notebook_set_show_border (notebook, FALSE);
- gtk_notebook_set_show_tabs (notebook, FALSE);
g_signal_connect_after (G_OBJECT (notebook), "switch_page",
G_CALLBACK (
@@ -2126,21 +2122,18 @@ ephy_window_add_tab (EphyWindow *window,
widget = GTK_WIDGET(ephy_tab_get_embed (tab));
- ephy_notebook_insert_page (EPHY_NOTEBOOK (window->priv->notebook),
- widget, position, jump_to);
+ ephy_notebook_insert_tab (EPHY_NOTEBOOK (window->priv->notebook),
+ tab, position, jump_to);
}
void
ephy_window_jump_to_tab (EphyWindow *window,
- EphyTab *tab)
+ EphyTab *tab)
{
- GtkWidget *widget;
int page;
- widget = GTK_WIDGET(ephy_tab_get_embed (tab));
-
page = gtk_notebook_page_num
- (window->priv->notebook, widget);
+ (window->priv->notebook, GTK_WIDGET (tab));
gtk_notebook_set_current_page
(window->priv->notebook, page);
}
@@ -2148,21 +2141,17 @@ ephy_window_jump_to_tab (EphyWindow *window,
static EphyTab *
real_get_active_tab (EphyWindow *window, int page_num)
{
- EphyTab *tab;
- GtkWidget *embed_widget;
+ GtkWidget *tab;
if (page_num == -1)
{
page_num = gtk_notebook_get_current_page (window->priv->notebook);
}
- embed_widget = gtk_notebook_get_nth_page (window->priv->notebook,
- page_num);
+ tab = gtk_notebook_get_nth_page (window->priv->notebook, page_num);
- g_return_val_if_fail (GTK_IS_WIDGET (embed_widget), NULL);
- tab = ephy_tab_for_embed (EPHY_EMBED (embed_widget));
g_return_val_if_fail (EPHY_IS_TAB (tab), NULL);
- return tab;
+ return EPHY_TAB (tab);
}
void
@@ -2186,8 +2175,7 @@ ephy_window_remove_tab (EphyWindow *window,
return;
}
- ephy_notebook_remove_page (EPHY_NOTEBOOK (window->priv->notebook),
- GTK_WIDGET (embed));
+ ephy_notebook_remove_tab (EPHY_NOTEBOOK (window->priv->notebook), tab);
}
/**
@@ -2264,6 +2252,7 @@ EphyTab *
ephy_window_get_active_tab (EphyWindow *window)
{
g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (EPHY_IS_TAB (window->priv->active_tab), NULL);
return window->priv->active_tab;
}
@@ -2276,35 +2265,33 @@ ephy_window_get_active_embed (EphyWindow *window)
g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
tab = ephy_window_get_active_tab (window);
+ g_return_val_if_fail (EPHY_IS_TAB (tab), NULL);
- if (tab)
- {
- return ephy_tab_get_embed (tab);
- }
-
- return NULL;
+ return ephy_tab_get_embed (tab);
}
+/**
+ * ephy_window_get_tabs:
+ * @window: a #EphyWindow
+ *
+ * Returns the list of #EphyTab:s in the window.
+ *
+ */
GList *
ephy_window_get_tabs (EphyWindow *window)
{
- GList *tabs = NULL;
- GtkWidget *w;
- int i = 0;
+ GtkNotebook *notebook;
+ GList *list = NULL;
+ int i, num;
- while ((w = gtk_notebook_get_nth_page (window->priv->notebook, i)) != NULL)
+ notebook = GTK_NOTEBOOK (window->priv->notebook);
+ num = gtk_notebook_get_n_pages (notebook);
+ for (i = 0; i < num; i++)
{
- EphyTab *tab;
-
- g_return_val_if_fail (EPHY_IS_EMBED (w), NULL);
- tab = ephy_tab_for_embed (EPHY_EMBED (w));
- g_return_val_if_fail (EPHY_IS_TAB (tab), NULL);
-
- tabs = g_list_prepend (tabs, tab);
- i++;
+ list = g_list_prepend (list, gtk_notebook_get_nth_page (notebook, i));
}
- return g_list_reverse (tabs);
+ return g_list_reverse (list);
}
static void
diff --git a/src/ephy-window.h b/src/ephy-window.h
index 8d124ea77..dede5259f 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -23,7 +23,6 @@
#include "ephy-embed.h"
#include "ephy-dialog.h"
-#include "ephy-notebook.h"
#include <glib-object.h>
#include <glib.h>
@@ -66,6 +65,7 @@ typedef enum
/* Include the header down here to resolve circular dependency */
#include "ephy-tab.h"
+#include "ephy-notebook.h"
GType ephy_window_get_type (void);
diff --git a/src/window-commands.c b/src/window-commands.c
index dd952d474..5a39dee4e 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1058,7 +1058,8 @@ window_cmd_tabs_move_left (GtkAction *action,
GtkWidget *child;
child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page);
- ephy_notebook_move_page (EPHY_NOTEBOOK (notebook), NULL, child, page - 1);
+ ephy_notebook_move_tab (EPHY_NOTEBOOK (notebook), NULL,
+ EPHY_TAB (child), page - 1);
}
}
@@ -1078,7 +1079,8 @@ void window_cmd_tabs_move_right (GtkAction *action,
GtkWidget *child;
child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page);
- ephy_notebook_move_page (EPHY_NOTEBOOK (notebook), NULL, child, page + 1);
+ ephy_notebook_move_tab (EPHY_NOTEBOOK (notebook), NULL,
+ EPHY_TAB (child), page + 1);
}
}
@@ -1087,19 +1089,18 @@ window_cmd_tabs_detach (GtkAction *action,
EphyWindow *window)
{
EphyTab *tab;
- GtkWidget *src_page, *nb;
+ GtkWidget *nb;
EphyWindow *new_win;
nb = ephy_window_get_notebook (window);
if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb)) <= 1) return;
tab = ephy_window_get_active_tab (window);
- src_page = GTK_WIDGET (ephy_tab_get_embed (tab));
+
new_win = ephy_window_new ();
- ephy_notebook_move_page (EPHY_NOTEBOOK (ephy_window_get_notebook (window)),
+ ephy_notebook_move_tab (EPHY_NOTEBOOK (ephy_window_get_notebook (window)),
EPHY_NOTEBOOK (ephy_window_get_notebook (new_win)),
- src_page, 0);
- ephy_tab_set_window (tab, new_win);
+ tab, 0);
gtk_widget_show (GTK_WIDGET (new_win));
}