aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ephy-lockdown.c2
-rw-r--r--src/ephy-notebook.c664
-rw-r--r--src/ephy-notebook.h21
-rw-r--r--src/ephy-session.c32
-rw-r--r--src/ephy-tabs-menu.c32
-rw-r--r--src/ephy-window.c170
-rw-r--r--src/epiphany.defs26
-rw-r--r--src/window-commands.c61
8 files changed, 262 insertions, 746 deletions
diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c
index 1141d0b83..046aff66c 100644
--- a/src/ephy-lockdown.c
+++ b/src/ephy-lockdown.c
@@ -201,8 +201,6 @@ update_window (EphyWindow *window,
ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, fullscreen);
action = gtk_action_group_get_action (action_group, "ViewFullscreen");
ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, fullscreen);
- action = gtk_action_group_get_action (action_group, "TabsDetach");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, fullscreen);
if (fullscreen)
{
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index 2cb8bb293..23173b81f 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -37,15 +37,14 @@
#include <glib/gi18n.h>
#include <gtk/gtkeventbox.h>
-#include <gtk/gtknotebook.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtktooltips.h>
-#include <gtk/gtkmain.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkimage.h>
#include <gtk/gtkbutton.h>
+#include <gtk/gtkaccelgroup.h>
#include <gtk/gtkiconfactory.h>
#define TAB_WIDTH_N_CHARS 15
@@ -65,15 +64,7 @@ struct _EphyNotebookPrivate
GList *focused_pages;
GtkTooltips *title_tips;
guint tabs_vis_notifier_id;
- gulong motion_notify_handler_id;
- gulong grab_notify_handler_id;
- gulong toplevel_grab_broken_handler_id;
- gulong toplevel_motion_notify_handler_id;
- gulong toplevel_button_release_handler_id;
- int x_start;
- int y_start;
-
- guint drag_in_progress : 1;
+
guint show_tabs : 1;
guint dnd_enabled : 1;
};
@@ -81,15 +72,13 @@ struct _EphyNotebookPrivate
static void ephy_notebook_init (EphyNotebook *notebook);
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,
- GdkEventMotion *event,
- int dest_position);
-static void move_tab (EphyNotebook *notebook,
- int dest_position);
-
-/* Local variables */
-static GdkCursor *cursor = NULL;
+static int ephy_notebook_insert_page (GtkNotebook *notebook,
+ GtkWidget *child,
+ GtkWidget *tab_label,
+ GtkWidget *menu_label,
+ int position);
+static void ephy_notebook_remove (GtkContainer *container,
+ GtkWidget *tab_widget);
static const GtkTargetEntry url_drag_types [] =
{
@@ -106,17 +95,12 @@ enum
enum
{
- TAB_ADDED,
- TAB_REMOVED,
- TABS_REORDERED,
- TAB_DETACHED,
TAB_CLOSE_REQUEST,
LAST_SIGNAL
};
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static GObjectClass *parent_class = NULL;
+static guint signals[LAST_SIGNAL];
+static GObjectClass *parent_class;
GType
ephy_notebook_get_type (void)
@@ -211,6 +195,8 @@ static void
ephy_notebook_class_init (EphyNotebookClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
+ GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@@ -218,45 +204,10 @@ ephy_notebook_class_init (EphyNotebookClass *klass)
object_class->get_property = ephy_notebook_get_property;
object_class->set_property = ephy_notebook_set_property;
- signals[TAB_ADDED] =
- g_signal_new ("tab_added",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EphyNotebookClass, tab_added),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- EPHY_TYPE_TAB);
- signals[TAB_REMOVED] =
- g_signal_new ("tab_removed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EphyNotebookClass, tab_removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- EPHY_TYPE_TAB);
- signals[TAB_DETACHED] =
- g_signal_new ("tab_detached",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EphyNotebookClass, tab_detached),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- EPHY_TYPE_TAB);
- signals[TABS_REORDERED] =
- g_signal_new ("tabs_reordered",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EphyNotebookClass, tabs_reordered),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ container_class->remove = ephy_notebook_remove;
+
+ notebook_class->insert_page = ephy_notebook_insert_page;
+
signals[TAB_CLOSE_REQUEST] =
g_signal_new ("tab-close-request",
G_OBJECT_CLASS_TYPE (object_class),
@@ -287,6 +238,8 @@ ephy_notebook_class_init (EphyNotebookClass *klass)
g_type_class_add_private (object_class, sizeof (EphyNotebookPrivate));
}
+
+/* FIXME remove when gtknotebook's func for this becomes public, bug #.... */
static EphyNotebook *
find_notebook_at_pointer (gint abs_x, gint abs_y)
{
@@ -389,391 +342,18 @@ find_tab_num_at_pos (EphyNotebook *notebook, gint abs_x, gint abs_y)
return AFTER_ALL_TABS;
}
-static gint find_notebook_and_tab_at_pos (gint abs_x, gint abs_y,
- EphyNotebook **notebook,
- gint *page_num)
-{
- *notebook = find_notebook_at_pointer (abs_x, abs_y);
- if (*notebook == NULL)
- {
- return NOT_IN_APP_WINDOWS;
- }
- *page_num = find_tab_num_at_pos (*notebook, abs_x, abs_y);
-
- if (*page_num < 0)
- {
- return *page_num;
- }
- else
- {
- return 0;
- }
-}
-
-void
-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), GTK_WIDGET (tab), dest_position);
-
- if (src->priv->drag_in_progress == FALSE)
- {
- g_signal_emit (G_OBJECT (src), signals[TABS_REORDERED], 0);
- }
- }
-#ifndef KEEP_TAB_IN_SAME_TOPLEVEL
- else
- {
- /* make sure the tab isn't destroyed while we move it */
- g_object_ref (tab);
- ephy_notebook_remove_tab (src, tab);
- ephy_notebook_add_tab (dest, tab, dest_position, TRUE);
- g_object_unref (tab);
- }
-#endif
-}
-
-static void
-drag_stop (EphyNotebook *notebook,
- guint32 time)
-{
- EphyNotebookPrivate *priv = notebook->priv;
- GtkWidget *widget = GTK_WIDGET (notebook);
- GtkWidget *toplevel, *child;
-
- if (priv->drag_in_progress)
- {
- LOG ("Drag Stop");
-
- toplevel = gtk_widget_get_toplevel (widget);
- g_return_if_fail (GTK_WIDGET_TOPLEVEL (toplevel));
-
- child = gtk_bin_get_child (GTK_BIN (toplevel));
- g_return_if_fail (child != NULL);
-
- /* disconnect the signals before ungrabbing! */
- if (priv->toplevel_grab_broken_handler_id != 0)
- {
- g_signal_handler_disconnect (toplevel,
- priv->toplevel_grab_broken_handler_id);
- priv->toplevel_grab_broken_handler_id = 0;
- }
- if (priv->grab_notify_handler_id != 0)
- {
- g_signal_handler_disconnect (notebook,
- priv->grab_notify_handler_id);
- priv->grab_notify_handler_id = 0;
- }
- if (priv->toplevel_motion_notify_handler_id != 0)
- {
- g_signal_handler_disconnect (toplevel,
- priv->toplevel_motion_notify_handler_id);
- priv->toplevel_motion_notify_handler_id = 0;
- }
- if (priv->toplevel_button_release_handler_id != 0)
- {
- g_signal_handler_disconnect (toplevel,
- priv->toplevel_button_release_handler_id);
- priv->toplevel_button_release_handler_id = 0;
- }
-
- /* ungrab the pointer if it's grabbed */
- /* FIXME multihead */
- if (gdk_pointer_is_grabbed ())
- {
- gdk_pointer_ungrab (time);
- }
-
- gtk_grab_remove (toplevel);
-
- g_signal_emit (G_OBJECT (notebook), signals[TABS_REORDERED], 0);
- }
-
- if (priv->motion_notify_handler_id != 0)
- {
- g_signal_handler_disconnect (notebook,
- priv->motion_notify_handler_id);
- priv->motion_notify_handler_id = 0;
- }
-
- priv->drag_in_progress = FALSE;
-}
-
-static gboolean
-grab_broken_event_cb (GtkWidget *widget,
- GdkEventGrabBroken *event,
- EphyNotebook *notebook)
-{
- LOG ("Grab Broken [%p]", notebook);
-
- drag_stop (notebook, GDK_CURRENT_TIME /* FIXME? */);
-
- return FALSE;
-}
-
-static void
-grab_notify_cb (GtkWidget *widget,
- gboolean was_grabbed,
- EphyNotebook *notebook)
-{
- LOG ("Grab Notify [%p, was-grabbed:%s]", notebook, was_grabbed ? "t" : "f");
-
- drag_stop (notebook, GDK_CURRENT_TIME /* FIXME? */);
-}
-
-static gboolean
-toplevel_motion_notify_cb (GtkWidget *toplevel,
- GdkEventMotion *event,
- EphyNotebook *notebook)
-{
- EphyNotebook *dest = NULL;
- int page_num, result;
-
- result = find_notebook_and_tab_at_pos ((gint)event->x_root,
- (gint)event->y_root,
- &dest, &page_num);
-
- if (result != NOT_IN_APP_WINDOWS)
- {
- if (dest != notebook)
- {
- move_tab_to_another_notebook (notebook, dest,
- event, page_num);
- }
- else
- {
- g_assert (page_num >= -1);
- move_tab (notebook, page_num);
- }
- }
-
- return FALSE;
-}
-
-static gboolean
-toplevel_button_release_cb (GtkWidget *toplevel,
- GdkEventButton *event,
- EphyNotebook *notebook)
-{
-#ifndef KEEP_TAB_IN_SAME_TOPLEVEL
- EphyNotebookPrivate *priv = notebook->priv;
-
- if (priv->drag_in_progress)
- {
- gint cur_page_num;
- GtkWidget *cur_page;
-
- cur_page_num =
- gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
- cur_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook),
- cur_page_num);
-
- if (!is_in_notebook_window (notebook, event->x_root, event->y_root)
- && gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) > 1)
- {
- /* Tab was detached */
- g_signal_emit (G_OBJECT (notebook),
- signals[TAB_DETACHED], 0, cur_page);
- }
- }
-#endif
-
- /* This must be called even if a drag isn't happening */
- drag_stop (notebook, event->time);
-
- return FALSE;
-}
-
-static gboolean
-drag_start (EphyNotebook *notebook,
- guint32 time)
-{
- EphyNotebookPrivate *priv = notebook->priv;
- GtkWidget *widget = GTK_WIDGET (notebook);
- GtkWidget *toplevel, *child;
-
- /* FIXME multihead */
- if (priv->drag_in_progress || gdk_pointer_is_grabbed ()) return FALSE;
-
- LOG ("Drag Start");
-
- priv->drag_in_progress = TRUE;
-
- /* get a new cursor, if necessary */
- /* FIXME multi-head */
- if (!cursor) cursor = gdk_cursor_new (GDK_FLEUR);
-
- toplevel = gtk_widget_get_toplevel (widget);
- g_return_val_if_fail (GTK_WIDGET_TOPLEVEL (toplevel), FALSE);
-
- child = gtk_bin_get_child (GTK_BIN (toplevel));
- g_return_val_if_fail (child != NULL, FALSE);
-
- /* grab the pointer */
- gtk_grab_add (toplevel);
-
- /* FIXME multi-head */
- if (gdk_pointer_grab (toplevel->window,
- FALSE,
- GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
- NULL, cursor, time) != GDK_GRAB_SUCCESS)
- {
- drag_stop (notebook, time);
- return FALSE;
- }
-
- g_return_val_if_fail (priv->toplevel_grab_broken_handler_id == 0, FALSE);
- g_return_val_if_fail (priv->toplevel_motion_notify_handler_id == 0, FALSE);
- g_return_val_if_fail (priv->toplevel_button_release_handler_id == 0, FALSE);
- g_return_val_if_fail (priv->grab_notify_handler_id == 0, FALSE);
-
- priv->toplevel_grab_broken_handler_id =
- g_signal_connect (toplevel, "grab-broken-event",
- G_CALLBACK (grab_broken_event_cb), notebook);
- priv->toplevel_motion_notify_handler_id =
- g_signal_connect (toplevel, "motion-notify-event",
- G_CALLBACK (toplevel_motion_notify_cb), notebook);
- priv->toplevel_button_release_handler_id =
- g_signal_connect (toplevel, "button-release-event",
- G_CALLBACK (toplevel_button_release_cb), notebook);
- priv->grab_notify_handler_id =
- g_signal_connect (notebook, "grab-notify",
- G_CALLBACK (grab_notify_cb), notebook);
-
- return TRUE;
-}
-
-/* this function is only called during dnd, we don't need to emit TABS_REORDERED
- * here, instead we do it on drag_stop
- */
-static void
-move_tab (EphyNotebook *notebook,
- int dest_position)
-{
- gint cur_page_num;
-
- cur_page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
-
- if (dest_position != cur_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);
- }
-}
-
-static gboolean
-motion_notify_cb (EphyNotebook *notebook,
- GdkEventMotion *event,
- gpointer data)
-{
- EphyNotebookPrivate *priv = notebook->priv;
-
- if (priv->drag_in_progress == FALSE)
- {
- if (gtk_drag_check_threshold (GTK_WIDGET (notebook),
- notebook->priv->x_start,
- notebook->priv->y_start,
- event->x_root, event->y_root))
- {
- return drag_start (notebook, event->time);
- }
-
- return FALSE;
- }
-
- return FALSE;
-}
-
-static void
-move_tab_to_another_notebook (EphyNotebook *src,
- EphyNotebook *dest,
- GdkEventMotion *event,
- int dest_position)
-{
-#ifndef KEEP_TAB_IN_SAME_TOPLEVEL
- 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
- * to that new notebook, and let this notebook handle the
- * drag
- */
- g_assert (EPHY_IS_NOTEBOOK (dest));
- g_assert (dest != src);
-
- /* Check if the dest notebook can accept the drag */
- if (!dest->priv->dnd_enabled) return;
-
- cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (src));
- tab = EPHY_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (src), cur_page));
-
- /* stop drag in origin window */
- drag_stop (src, event->time);
-
- ephy_notebook_move_tab (src, dest, tab, dest_position);
-
- /* start drag handling in dest notebook */
-
- dest->priv->motion_notify_handler_id =
- g_signal_connect (G_OBJECT (dest),
- "motion-notify-event",
- G_CALLBACK (motion_notify_cb),
- NULL);
-
- drag_start (dest, event->time);
-#endif /* KEEP_TAB_IN_SAME_TOPLEVEL */
-}
-
-static gboolean
-button_release_cb (EphyNotebook *notebook,
- GdkEventButton *event,
- gpointer data)
-{
- /* This must be called even if a drag isn't happening */
- drag_stop (notebook, event->time);
-
- return FALSE;
-}
-
static gboolean
button_press_cb (EphyNotebook *notebook,
GdkEventButton *event,
gpointer data)
{
- EphyNotebookPrivate *priv = notebook->priv;
int tab_clicked;
- if (!notebook->priv->dnd_enabled) return FALSE;
-
tab_clicked = find_tab_num_at_pos (notebook, event->x_root, event->y_root);
- /* FIXME: how could there be a drag in progress!? */
- if (notebook->priv->drag_in_progress)
- {
- return TRUE;
- }
-
- if ((event->button == 1) && (event->type == GDK_BUTTON_PRESS)
- && (tab_clicked >= 0))
- {
- priv->x_start = event->x_root;
- priv->y_start = event->y_root;
- priv->motion_notify_handler_id =
- g_signal_connect (notebook, "motion-notify-event",
- G_CALLBACK (motion_notify_cb), NULL);
- }
- else if (GDK_BUTTON_PRESS == event->type && 3 == event->button)
+ if (event->type == GDK_BUTTON_PRESS &&
+ event->button == 3 &&
+ (event->state & gtk_accelerator_get_default_mod_mask ()) == 0)
{
if (tab_clicked == -1)
{
@@ -782,22 +362,14 @@ button_press_cb (EphyNotebook *notebook,
*/
return TRUE;
}
- else
- {
- /* switch to the page the mouse is over, but don't consume the event */
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), tab_clicked);
- }
+
+ /* switch to the page the mouse is over, but don't consume the event */
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), tab_clicked);
}
return FALSE;
}
-GtkWidget *
-ephy_notebook_new (void)
-{
- return GTK_WIDGET (g_object_new (EPHY_TYPE_NOTEBOOK, NULL));
-}
-
static void
ephy_notebook_switch_page_cb (GtkNotebook *notebook,
GtkNotebookPage *page,
@@ -920,19 +492,16 @@ ephy_notebook_init (EphyNotebook *notebook)
g_signal_connect (notebook, "button-press-event",
(GCallback)button_press_cb, NULL);
- g_signal_connect (notebook, "button-release-event",
- (GCallback)button_release_cb, NULL);
- gtk_widget_add_events (GTK_WIDGET (notebook), GDK_BUTTON1_MOTION_MASK);
-
- g_signal_connect_after (G_OBJECT (notebook), "switch_page",
+ g_signal_connect_after (notebook, "switch-page",
G_CALLBACK (ephy_notebook_switch_page_cb),
NULL);
/* Set up drag-and-drop target */
- g_signal_connect (G_OBJECT(notebook), "drag_data_received",
- G_CALLBACK(notebook_drag_data_received_cb),
+ g_signal_connect (notebook, "drag-data-received",
+ G_CALLBACK (notebook_drag_data_received_cb),
NULL);
- gtk_drag_dest_set (GTK_WIDGET(notebook), GTK_DEST_DEFAULT_MOTION |
+ gtk_drag_dest_set (GTK_WIDGET (notebook),
+ GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
url_drag_types, G_N_ELEMENTS (url_drag_types),
GDK_ACTION_MOVE | GDK_ACTION_COPY);
@@ -1091,9 +660,8 @@ build_tab_label (EphyNotebook *nb, EphyTab *tab)
gtk_tooltips_set_tip (nb->priv->title_tips, close_button,
_("Close tab"), NULL);
- g_signal_connect (G_OBJECT (close_button), "clicked",
- G_CALLBACK (close_button_clicked_cb),
- tab);
+ g_signal_connect (close_button, "clicked",
+ G_CALLBACK (close_button_clicked_cb), tab);
/* setup load feedback */
spinner = ephy_spinner_new ();
@@ -1116,6 +684,13 @@ build_tab_label (EphyNotebook *nb, EphyTab *tab)
g_signal_connect (hbox, "style-set",
G_CALLBACK (tab_label_style_set_cb), NULL);
+ /* Set up drag-and-drop target */
+ g_signal_connect (hbox, "drag_data_received",
+ G_CALLBACK (notebook_drag_data_received_cb), tab);
+ gtk_drag_dest_set (hbox, GTK_DEST_DEFAULT_ALL,
+ url_drag_types, G_N_ELEMENTS (url_drag_types),
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
+
gtk_widget_show (hbox);
gtk_widget_show (label_ebox);
gtk_widget_show (label_hbox);
@@ -1130,6 +705,18 @@ build_tab_label (EphyNotebook *nb, EphyTab *tab)
g_object_set_data (G_OBJECT (hbox), "close-button", close_button);
g_object_set_data (G_OBJECT (hbox), "tooltips", nb->priv->title_tips);
+ /* Hook the label up to the tab properties */
+ sync_icon (tab, NULL, hbox);
+ sync_label (tab, NULL, hbox);
+ sync_load_status (tab, NULL, hbox);
+
+ g_signal_connect_object (tab, "notify::icon",
+ G_CALLBACK (sync_icon), hbox, 0);
+ g_signal_connect_object (tab, "notify::title",
+ G_CALLBACK (sync_label), hbox, 0);
+ g_signal_connect_object (tab, "notify::load-status",
+ G_CALLBACK (sync_load_status), hbox, 0);
+
return hbox;
}
@@ -1141,67 +728,82 @@ ephy_notebook_set_show_tabs (EphyNotebook *nb, gboolean show_tabs)
update_tabs_visibility (nb, FALSE);
}
-void
-ephy_notebook_add_tab (EphyNotebook *nb,
- EphyTab *tab,
- int position,
- gboolean jump_to)
+static int
+ephy_notebook_insert_page (GtkNotebook *gnotebook,
+ GtkWidget *tab_widget,
+ GtkWidget *tab_label,
+ GtkWidget *menu_label,
+ int position)
{
- GtkWidget *label;
+ EphyNotebook *notebook = EPHY_NOTEBOOK (gnotebook);
- g_return_if_fail (EPHY_IS_TAB (tab));
+ /* Destroy passed-in tab label */
+ if (tab_label != NULL)
+ {
+ g_object_ref_sink (tab_label);
+ g_object_unref (tab_label);
+ }
- label = build_tab_label (nb, tab);
+ g_assert (EPHY_IS_TAB (tab_widget));
- update_tabs_visibility (nb, TRUE);
+ tab_label = build_tab_label (notebook, EPHY_TAB (tab_widget));
- gtk_notebook_insert_page (GTK_NOTEBOOK (nb), GTK_WIDGET (tab),
- label, position);
+ update_tabs_visibility (notebook, TRUE);
- /* Set up drag-and-drop target */
- g_signal_connect (G_OBJECT(label), "drag_data_received",
- G_CALLBACK(notebook_drag_data_received_cb), tab);
- gtk_drag_dest_set (label, GTK_DEST_DEFAULT_ALL,
- url_drag_types, G_N_ELEMENTS (url_drag_types),
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ position = GTK_NOTEBOOK_CLASS (parent_class)->insert_page (gnotebook,
+ tab_widget,
+ tab_label,
+ menu_label,
+ position);
- sync_icon (tab, NULL, label);
- sync_label (tab, NULL, label);
- sync_load_status (tab, NULL, label);
+ gtk_notebook_set_tab_reorderable (gnotebook, tab_widget, TRUE);
- g_signal_connect_object (tab, "notify::icon",
- G_CALLBACK (sync_icon), label, 0);
- g_signal_connect_object (tab, "notify::title",
- G_CALLBACK (sync_label), label, 0);
- g_signal_connect_object (tab, "notify::load-status",
- G_CALLBACK (sync_load_status), label, 0);
+ return position;
+}
+
+int
+ephy_notebook_add_tab (EphyNotebook *notebook,
+ EphyTab *tab,
+ int position,
+ gboolean jump_to)
+{
+ GtkNotebook *gnotebook = GTK_NOTEBOOK (notebook);
+
+ g_return_val_if_fail (EPHY_IS_NOTEBOOK (notebook), -1);
- g_signal_emit (G_OBJECT (nb), signals[TAB_ADDED], 0, tab);
+ position = gtk_notebook_insert_page (GTK_NOTEBOOK (notebook),
+ GTK_WIDGET (tab),
+ NULL,
+ position);
+ /* FIXME gtk bug! */
/* The signal handler may have reordered the tabs */
- position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));
+ position = gtk_notebook_page_num (gnotebook, GTK_WIDGET (tab));
if (jump_to)
{
- gtk_notebook_set_current_page (GTK_NOTEBOOK (nb), position);
+ gtk_notebook_set_current_page (gnotebook, position);
g_object_set_data (G_OBJECT (tab), "jump_to",
GINT_TO_POINTER (jump_to));
}
+
+ return position;
}
static void
-smart_tab_switching_on_closure (EphyNotebook *nb,
- EphyTab *tab)
+smart_tab_switching_on_closure (EphyNotebook *notebook,
+ GtkWidget *tab)
{
+ EphyNotebookPrivate *priv = notebook->priv;
gboolean jump_to;
jump_to = GPOINTER_TO_INT (g_object_get_data
(G_OBJECT (tab), "jump_to"));
- if (!jump_to || !nb->priv->focused_pages)
+ if (!jump_to || !priv->focused_pages)
{
- gtk_notebook_next_page (GTK_NOTEBOOK (nb));
+ gtk_notebook_next_page (GTK_NOTEBOOK (notebook));
}
else
{
@@ -1210,65 +812,57 @@ smart_tab_switching_on_closure (EphyNotebook *nb,
int page_num;
/* activate the last focused tab */
- l = g_list_last (nb->priv->focused_pages);
+ l = g_list_last (priv->focused_pages);
child = GTK_WIDGET (l->data);
- page_num = gtk_notebook_page_num (GTK_NOTEBOOK (nb),
+ page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook),
child);
- gtk_notebook_set_current_page
- (GTK_NOTEBOOK (nb), page_num);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook),
+ page_num);
}
}
-void
-ephy_notebook_remove_tab (EphyNotebook *nb,
- EphyTab *tab)
+static void
+ephy_notebook_remove (GtkContainer *container,
+ GtkWidget *tab_widget)
{
+ GtkNotebook *gnotebook = GTK_NOTEBOOK (container);
+ EphyNotebook *notebook = EPHY_NOTEBOOK (container);
+ EphyNotebookPrivate *priv = notebook->priv;
+ GtkWidget *tab_label, *ebox;
int position, curr;
- GtkWidget *label, *ebox;
- g_return_if_fail (EPHY_IS_NOTEBOOK (nb));
- g_return_if_fail (EPHY_IS_TAB (tab));
+ g_assert (EPHY_IS_TAB (tab_widget));
/* Remove the page from the focused pages list */
- nb->priv->focused_pages = g_list_remove (nb->priv->focused_pages,
- tab);
+ priv->focused_pages = g_list_remove (priv->focused_pages, tab_widget);
- position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));
- curr = gtk_notebook_get_current_page (GTK_NOTEBOOK (nb));
+ position = gtk_notebook_page_num (gnotebook, tab_widget);
+ curr = gtk_notebook_get_current_page (gnotebook);
if (position == curr)
{
- smart_tab_switching_on_closure (nb, tab);
+ smart_tab_switching_on_closure (notebook, tab_widget);
}
- 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 (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);
+ /* Prepare tab label for destruction */
+ tab_label = gtk_notebook_get_tab_label (gnotebook, tab_widget);
+ ebox = GTK_WIDGET (g_object_get_data (G_OBJECT (tab_label), "label-ebox"));
+ gtk_tooltips_set_tip (GTK_TOOLTIPS (priv->title_tips), ebox, NULL, NULL);
- /**
- * we ref the tab so that it's still alive while the tabs_removed
- * signal is processed.
- */
- g_object_ref (tab);
-
- gtk_notebook_remove_page (GTK_NOTEBOOK (nb), position);
-
- update_tabs_visibility (nb, FALSE);
+ g_signal_handlers_disconnect_by_func
+ (tab_widget, G_CALLBACK (sync_icon), tab_label);
+ g_signal_handlers_disconnect_by_func
+ (tab_widget, G_CALLBACK (sync_label), tab_label);
+ g_signal_handlers_disconnect_by_func
+ (tab_widget, G_CALLBACK (sync_load_status), tab_label);
- g_signal_emit (G_OBJECT (nb), signals[TAB_REMOVED], 0, tab);
+ GTK_CONTAINER_CLASS (parent_class)->remove (container, tab_widget);
- g_object_unref (tab);
+ update_tabs_visibility (notebook, FALSE);
/* if that was the last tab, destroy the window */
- if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb)) == 0)
+ if (gtk_notebook_get_n_pages (gnotebook) == 0)
{
- gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (nb)));
+ gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET (notebook)));
}
}
diff --git a/src/ephy-notebook.h b/src/ephy-notebook.h
index 6ad66d870..b04fcbb15 100644
--- a/src/ephy-notebook.h
+++ b/src/ephy-notebook.h
@@ -54,34 +54,17 @@ struct _EphyNotebookClass
GtkNotebookClass parent_class;
/* Signals */
- void (* tab_added) (EphyNotebook *notebook,
- EphyTab *tab);
- void (* tab_removed) (EphyNotebook *notebook,
- EphyTab *tab);
- void (* tab_detached) (EphyNotebook *notebook,
- EphyTab *tab);
- void (* tabs_reordered) (EphyNotebook *notebook);
void (* tab_close_req) (EphyNotebook *notebook,
EphyTab *tab);
};
GType ephy_notebook_get_type (void);
-GtkWidget *ephy_notebook_new (void);
-
-void ephy_notebook_add_tab (EphyNotebook *nb,
+int ephy_notebook_add_tab (EphyNotebook *nb,
EphyTab *tab,
int position,
gboolean jump_to);
-
-void ephy_notebook_remove_tab (EphyNotebook *nb,
- EphyTab *tab);
-
-void ephy_notebook_move_tab (EphyNotebook *src,
- EphyNotebook *dest,
- 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 10b3e5d9c..3b8ccaf7f 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -431,18 +431,20 @@ net_stop_cb (EphyEmbed *embed,
}
static void
-tab_added_cb (GtkWidget *notebook,
- EphyTab *tab,
- EphySession *session)
+notebook_page_added_cb (GtkWidget *notebook,
+ EphyTab *tab,
+ guint position,
+ EphySession *session)
{
g_signal_connect (ephy_tab_get_embed (tab), "net-stop",
G_CALLBACK (net_stop_cb), session);
}
static void
-tab_removed_cb (GtkWidget *notebook,
- EphyTab *tab,
- EphySession *session)
+notebook_page_removed_cb (GtkWidget *notebook,
+ EphyTab *tab,
+ guint position,
+ EphySession *session)
{
ephy_session_save (session, SESSION_CRASHED);
@@ -451,8 +453,10 @@ tab_removed_cb (GtkWidget *notebook,
}
static void
-tabs_reordered_cb (GtkWidget *notebook,
- EphySession *session)
+notebook_page_reordered_cb (GtkWidget *notebook,
+ GtkWidget *tab,
+ guint position,
+ EphySession *session)
{
ephy_session_save (session, SESSION_CRASHED);
}
@@ -820,12 +824,12 @@ impl_attach_window (EphyExtension *extension,
G_CALLBACK (window_focus_in_event_cb), session);
notebook = ephy_window_get_notebook (window);
- g_signal_connect (notebook, "tab-added",
- G_CALLBACK (tab_added_cb), session);
- g_signal_connect (notebook, "tab-removed",
- G_CALLBACK (tab_removed_cb), session);
- g_signal_connect (notebook, "tabs-reordered",
- G_CALLBACK (tabs_reordered_cb), session);
+ g_signal_connect (notebook, "page-added",
+ G_CALLBACK (notebook_page_added_cb), session);
+ g_signal_connect (notebook, "page-removed",
+ G_CALLBACK (notebook_page_removed_cb), session);
+ g_signal_connect (notebook, "page-reordered",
+ G_CALLBACK (notebook_page_reordered_cb), session);
/* Set unique identifier as role, so that on restore, the WM can
* place the window on the right workspace
diff --git a/src/ephy-tabs-menu.c b/src/ephy-tabs-menu.c
index 98a0cfeca..c79220719 100644
--- a/src/ephy-tabs-menu.c
+++ b/src/ephy-tabs-menu.c
@@ -130,9 +130,10 @@ sync_tab_title (EphyTab *tab,
}
static void
-tab_added_cb (EphyNotebook *notebook,
- EphyTab *tab,
- EphyTabsMenu *menu)
+notebook_page_added_cb (EphyNotebook *notebook,
+ EphyTab *tab,
+ guint position,
+ EphyTabsMenu *menu)
{
EphyTabsMenuPrivate *priv = menu->priv;
GtkAction *action;
@@ -176,9 +177,10 @@ tab_added_cb (EphyNotebook *notebook,
}
static void
-tab_removed_cb (EphyNotebook *notebook,
- EphyTab *tab,
- EphyTabsMenu *menu)
+notebook_page_removed_cb (EphyNotebook *notebook,
+ EphyTab *tab,
+ guint position,
+ EphyTabsMenu *menu)
{
EphyTabsMenuPrivate *priv = menu->priv;
GtkAction *action;
@@ -201,8 +203,10 @@ tab_removed_cb (EphyNotebook *notebook,
}
static void
-tabs_reordered_cb (EphyNotebook *notebook,
- EphyTabsMenu *menu)
+notebook_page_reordered_cb (EphyNotebook *notebook,
+ EphyTab *tab,
+ guint position,
+ EphyTabsMenu *menu)
{
LOG ("tabs_reordered_cb");
@@ -278,12 +282,12 @@ ephy_tabs_menu_set_window (EphyTabsMenu *menu,
G_CALLBACK (sync_active_tab), menu);
notebook = ephy_window_get_notebook (window);
- g_signal_connect_object (notebook, "tab_added",
- 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);
+ g_signal_connect_object (notebook, "page-added",
+ G_CALLBACK (notebook_page_added_cb), menu, 0);
+ g_signal_connect_object (notebook, "page-removed",
+ G_CALLBACK (notebook_page_removed_cb), menu, 0);
+ g_signal_connect_object (notebook, "page-reordered",
+ G_CALLBACK (notebook_page_reordered_cb), menu, 0);
}
static void
diff --git a/src/ephy-window.c b/src/ephy-window.c
index be9cfdbf0..8534a01ba 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -87,7 +87,7 @@ static EphyTab *ephy_window_open_link (EphyLink *link,
const char *address,
EphyTab *tab,
EphyLinkFlags flags);
-static void ephy_window_notebook_switch_page_cb (GtkNotebook *notebook,
+static void notebook_switch_page_cb (GtkNotebook *notebook,
GtkNotebookPage *page,
guint page_num,
EphyWindow *window);
@@ -256,9 +256,6 @@ static const GtkActionEntry ephy_menu_entries [] = {
{ "TabsMoveRight", NULL, N_("Move Tab _Right"), "<shift><control>Page_Down",
N_("Move current tab to right"),
G_CALLBACK (window_cmd_tabs_move_right) },
- { "TabsDetach", NULL, N_("_Detach Tab"), "<shift><control>M",
- N_("Detach current tab"),
- G_CALLBACK (window_cmd_tabs_detach) },
/* Help menu */
@@ -398,7 +395,6 @@ static const struct
#define SETTINGS_CONNECTION_DATA_KEY "EphyWindowSettings"
/* Until https://bugzilla.mozilla.org/show_bug.cgi?id=296002 is fixed */
-#define KEEP_TAB_IN_SAME_TOPLEVEL
#define EPHY_WINDOW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_WINDOW, EphyWindowPrivate))
@@ -2203,35 +2199,28 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
static void
update_tabs_menu_sensitivity (EphyWindow *window)
{
- gboolean prev_tab, next_tab, move_left, move_right, detach;
+ EphyWindowPrivate *priv = window->priv;
GtkActionGroup *action_group;
GtkAction *action;
- int current;
- int last;
-
- current = gtk_notebook_get_current_page
- (GTK_NOTEBOOK (window->priv->notebook));
- last = gtk_notebook_get_n_pages
- (GTK_NOTEBOOK (window->priv->notebook)) - 1;
- prev_tab = move_left = (current > 0);
- next_tab = move_right = (current < last);
- detach = gtk_notebook_get_n_pages
- (GTK_NOTEBOOK (window->priv->notebook)) > 1;
+ GtkNotebook *notebook;
+ int page, n_pages;
+ gboolean not_first, not_last;
- action_group = window->priv->action_group;
+ notebook = GTK_NOTEBOOK (priv->notebook);
+ page = gtk_notebook_get_current_page (notebook);
+ n_pages = gtk_notebook_get_n_pages (notebook);
+ not_first = page > 0;
+ not_last = page + 1 < n_pages;
+
+ action_group = priv->action_group;
action = gtk_action_group_get_action (action_group, "TabsPrevious");
- gtk_action_set_sensitive (action, prev_tab);
+ gtk_action_set_sensitive (action, not_first);
action = gtk_action_group_get_action (action_group, "TabsNext");
- gtk_action_set_sensitive (action, next_tab);
+ gtk_action_set_sensitive (action, not_last);
action = gtk_action_group_get_action (action_group, "TabsMoveLeft");
- gtk_action_set_sensitive (action, move_left);
+ gtk_action_set_sensitive (action, not_first);
action = gtk_action_group_get_action (action_group, "TabsMoveRight");
- gtk_action_set_sensitive (action, move_right);
- action = gtk_action_group_get_action (action_group, "TabsDetach");
- ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME, !detach);
-#ifdef KEEP_TAB_IN_SAME_TOPLEVEL
- gtk_action_set_visible (action, FALSE);
-#endif
+ gtk_action_set_sensitive (action, not_last);
}
static gboolean
@@ -2264,14 +2253,15 @@ embed_modal_alert_cb (EphyEmbed *embed,
}
static gboolean
-idle_tab_remove_cb (EphyTab *tab)
+idle_tab_remove_cb (GtkWidget *tab)
{
GtkWidget *toplevel;
EphyWindow *window;
EphyWindowPrivate *priv;
- EphyNotebook *notebook;
+ GtkNotebook *notebook;
+ int position;
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (tab));
+ toplevel = gtk_widget_get_toplevel (tab);
if (!EPHY_IS_WINDOW (toplevel)) return FALSE; /* FIXME should this ever occur? */
window = EPHY_WINDOW (toplevel);
@@ -2281,8 +2271,10 @@ idle_tab_remove_cb (EphyTab *tab)
g_hash_table_remove (priv->tabs_to_remove, tab);
- notebook = EPHY_NOTEBOOK (ephy_window_get_notebook (window));
- ephy_notebook_remove_tab (notebook, tab);
+ notebook = GTK_NOTEBOOK (ephy_window_get_notebook (window));
+
+ position = gtk_notebook_page_num (notebook, tab);
+ gtk_notebook_remove_page (notebook, position);
/* don't run again */
return FALSE;
@@ -2404,22 +2396,26 @@ notebook_popup_menu_cb (GtkNotebook *notebook,
}
static void
-tab_added_cb (EphyNotebook *notebook,
- EphyTab *tab,
- EphyWindow *window)
+notebook_page_added_cb (EphyNotebook *notebook,
+ EphyTab *tab,
+ guint position,
+ EphyWindow *window)
{
+ EphyWindowPrivate *priv = window->priv;
EphyExtension *manager;
EphyEmbed *embed;
+ LOG ("page-added notebook %p tab %p position %u\n", notebook, tab, position);
+
g_return_if_fail (EPHY_IS_TAB (tab));
- window->priv->num_tabs++;
+ priv->num_tabs++;
update_tabs_menu_sensitivity (window);
- g_signal_connect_object (G_OBJECT (tab), "notify::visibility",
+ g_signal_connect_object (tab, "notify::visibility",
G_CALLBACK (sync_tab_visibility), window, 0);
- g_signal_connect_object (G_OBJECT (tab), "open-link",
+ g_signal_connect_object (tab, "open-link",
G_CALLBACK (ephy_link_open), window,
G_CONNECT_SWAPPED);
@@ -2441,13 +2437,19 @@ tab_added_cb (EphyNotebook *notebook,
}
static void
-tab_removed_cb (EphyNotebook *notebook,
- EphyTab *tab,
- EphyWindow *window)
+notebook_page_removed_cb (EphyNotebook *notebook,
+ EphyTab *tab,
+ guint position,
+ EphyWindow *window)
{
+ EphyWindowPrivate *priv = window->priv;
EphyExtension *manager;
EphyEmbed *embed;
+ LOG ("page-removed notebook %p tab %p position %u\n", notebook, tab, position);
+
+ if (priv->closing) return;
+
g_return_if_fail (EPHY_IS_TAB (tab));
/* Let the extensions remove themselves from the tab */
@@ -2461,9 +2463,9 @@ tab_removed_cb (EphyNotebook *notebook,
G_CALLBACK (ephy_link_open),
window);
- window->priv->num_tabs--;
+ priv->num_tabs--;
- if (window->priv->num_tabs > 0)
+ if (priv->num_tabs > 0)
{
update_tabs_menu_sensitivity (window);
}
@@ -2474,42 +2476,24 @@ tab_removed_cb (EphyNotebook *notebook,
g_signal_handlers_disconnect_by_func
(embed, G_CALLBACK (embed_modal_alert_cb), window);
g_signal_handlers_disconnect_by_func
- (embed, G_CALLBACK (embed_close_request_cb), window);
+ (embed, G_CALLBACK (embed_close_request_cb), window);
g_signal_handlers_disconnect_by_func
- (embed, G_CALLBACK (embed_destroy_browser_cb), window);
+ (embed, G_CALLBACK (embed_destroy_browser_cb), window);
}
static void
-tab_detached_cb (EphyNotebook *notebook,
- EphyTab *tab,
- gpointer data)
-{
- EphyWindow *window;
-
- g_return_if_fail (EPHY_IS_TAB (tab));
-
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_FULLSCREEN))
- {
- return;
- }
-
- window = ephy_window_new ();
- ephy_notebook_move_tab (notebook,
- EPHY_NOTEBOOK (ephy_window_get_notebook (window)),
- tab, 0);
- gtk_widget_show (GTK_WIDGET (window));
-}
-
-static void
-tabs_reordered_cb (EphyNotebook *notebook, EphyWindow *window)
+notebook_page_reordered_cb (EphyNotebook *notebook,
+ EphyTab *tab,
+ guint position,
+ EphyWindow *window)
{
update_tabs_menu_sensitivity (window);
}
static void
-tab_close_request_cb (EphyNotebook *notebook,
- EphyTab *tab,
- EphyWindow *window)
+notebook_page_close_request_cb (EphyNotebook *notebook,
+ EphyTab *tab,
+ EphyWindow *window)
{
EphyWindowPrivate *priv = window->priv;
EphyEmbed *embed;
@@ -2535,28 +2519,25 @@ setup_notebook (EphyWindow *window)
{
GtkNotebook *notebook;
- notebook = GTK_NOTEBOOK (ephy_notebook_new ());
+ notebook = GTK_NOTEBOOK (g_object_new (EPHY_TYPE_NOTEBOOK, NULL));
- g_signal_connect_after (G_OBJECT (notebook), "switch_page",
- G_CALLBACK (
- ephy_window_notebook_switch_page_cb),
+ g_signal_connect_after (notebook, "switch-page",
+ G_CALLBACK (notebook_switch_page_cb),
window);
g_signal_connect (notebook, "popup-menu",
G_CALLBACK (notebook_popup_menu_cb), window);
g_signal_connect (notebook, "button-press-event",
- G_CALLBACK(notebook_button_press_cb), window);
-
- g_signal_connect (G_OBJECT (notebook), "tab_added",
- G_CALLBACK (tab_added_cb), window);
- g_signal_connect (G_OBJECT (notebook), "tab_removed",
- G_CALLBACK (tab_removed_cb), window);
- g_signal_connect (G_OBJECT (notebook), "tab_detached",
- G_CALLBACK (tab_detached_cb), NULL);
- g_signal_connect (G_OBJECT (notebook), "tabs_reordered",
- G_CALLBACK (tabs_reordered_cb), window);
- g_signal_connect (G_OBJECT (notebook), "tab_close_request",
- G_CALLBACK (tab_close_request_cb), window);
+ G_CALLBACK (notebook_button_press_cb), window);
+
+ g_signal_connect (notebook, "page-added",
+ G_CALLBACK (notebook_page_added_cb), window);
+ g_signal_connect (notebook, "page-removed",
+ G_CALLBACK (notebook_page_removed_cb), window);
+ g_signal_connect (notebook, "page-reordered",
+ G_CALLBACK (notebook_page_reordered_cb), window);
+ g_signal_connect (notebook, "tab-close-request",
+ G_CALLBACK (notebook_page_close_request_cb), window);
return notebook;
}
@@ -3432,8 +3413,11 @@ void
ephy_window_remove_tab (EphyWindow *window,
EphyTab *tab)
{
+ EphyWindowPrivate *priv = window->priv;
EphyEmbed *embed;
+ GtkNotebook *notebook;
gboolean modified;
+ int position;
g_return_if_fail (EPHY_IS_WINDOW (window));
g_return_if_fail (EPHY_IS_TAB (tab));
@@ -3449,7 +3433,9 @@ ephy_window_remove_tab (EphyWindow *window,
return;
}
- ephy_notebook_remove_tab (EPHY_NOTEBOOK (window->priv->notebook), tab);
+ notebook = GTK_NOTEBOOK (priv->notebook);
+ position = gtk_notebook_page_num (notebook, GTK_WIDGET (tab));
+ gtk_notebook_remove_page (notebook, position);
}
/**
@@ -3570,15 +3556,17 @@ ephy_window_get_tabs (EphyWindow *window)
}
static void
-ephy_window_notebook_switch_page_cb (GtkNotebook *notebook,
- GtkNotebookPage *page,
- guint page_num,
- EphyWindow *window)
+notebook_switch_page_cb (GtkNotebook *notebook,
+ GtkNotebookPage *page,
+ guint page_num,
+ EphyWindow *window)
{
EphyWindowPrivate *priv = window->priv;
EphyTab *tab;
EphyEmbed *embed;
+ LOG ("switch-page notebook %p position %u\n", notebook, page_num);
+
if (priv->closing) return;
/* get the new tab */
diff --git a/src/epiphany.defs b/src/epiphany.defs
index f81bd2c8f..e3b4ef116 100644
--- a/src/epiphany.defs
+++ b/src/epiphany.defs
@@ -2888,12 +2888,6 @@
(return-type "GType")
)
-(define-function ephy_notebook_new
- (c-name "ephy_notebook_new")
- (is-constructor-of "EphyNotebook")
- (return-type "GtkWidget*")
-)
-
(define-method add_tab
(of-object "EphyNotebook")
(c-name "ephy_notebook_add_tab")
@@ -2905,26 +2899,6 @@
)
)
-(define-method remove_tab
- (of-object "EphyNotebook")
- (c-name "ephy_notebook_remove_tab")
- (return-type "none")
- (parameters
- '("EphyTab*" "tab")
- )
-)
-
-(define-method move_tab
- (of-object "EphyNotebook")
- (c-name "ephy_notebook_move_tab")
- (return-type "none")
- (parameters
- '("EphyNotebook*" "dest")
- '("EphyTab*" "tab")
- '("int" "dest_position")
- )
-)
-
(define-method set_show_tabs
(of-object "EphyNotebook")
(c-name "ephy_notebook_set_show_tabs")
diff --git a/src/window-commands.c b/src/window-commands.c
index f0f6b04e8..fa36cfc9b 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -833,61 +833,32 @@ void
window_cmd_tabs_move_left (GtkAction *action,
EphyWindow *window)
{
- GtkWidget *notebook;
+ GtkWidget *child;
+ GtkNotebook *notebook;
int page;
- notebook = ephy_window_get_notebook (window);
- page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
-
- if (page > 0)
- {
- GtkWidget *child;
+ notebook = GTK_NOTEBOOK (ephy_window_get_notebook (window));
+ page = gtk_notebook_get_current_page (notebook);
+ if (page < 1) return;
- child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page);
- ephy_notebook_move_tab (EPHY_NOTEBOOK (notebook), NULL,
- EPHY_TAB (child), page - 1);
- }
+ child = gtk_notebook_get_nth_page (notebook, page);
+ gtk_notebook_reorder_child (notebook, child, page - 1);
}
void window_cmd_tabs_move_right (GtkAction *action,
EphyWindow *window)
{
- GtkWidget *notebook;
- int page;
- int last_page;
-
- notebook = ephy_window_get_notebook (window);
- page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
- last_page = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) - 1;
-
- if (page != last_page)
- {
- GtkWidget *child;
-
- child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page);
- ephy_notebook_move_tab (EPHY_NOTEBOOK (notebook), NULL,
- EPHY_TAB (child), page + 1);
- }
-}
-
-void
-window_cmd_tabs_detach (GtkAction *action,
- EphyWindow *window)
-{
- EphyTab *tab;
- GtkWidget *nb;
- EphyWindow *new_win;
+ GtkWidget *child;
+ GtkNotebook *notebook;
+ int page, n_pages;
- nb = ephy_window_get_notebook (window);
- if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb)) <= 1) return;
-
- tab = ephy_window_get_active_tab (window);
+ notebook = GTK_NOTEBOOK (ephy_window_get_notebook (window));
+ page = gtk_notebook_get_current_page (notebook);
+ n_pages = gtk_notebook_get_n_pages (notebook) - 1;
+ if (page > n_pages - 1) return;
- new_win = ephy_window_new ();
- ephy_notebook_move_tab (EPHY_NOTEBOOK (ephy_window_get_notebook (window)),
- EPHY_NOTEBOOK (ephy_window_get_notebook (new_win)),
- tab, 0);
- gtk_widget_show (GTK_WIDGET (new_win));
+ child = gtk_notebook_get_nth_page (notebook, page);
+ gtk_notebook_reorder_child (notebook, child, page + 1);
}
void