#endif
}
-static gboolean
-midori_browser_tab_destroy_cb (GtkWidget* widget,
+static void
+midori_browser_tab_destroy_cb (MidoriView* view,
MidoriBrowser* browser)
{
- KatzeItem* item;
-
- if (browser->proxy_array && MIDORI_IS_VIEW (widget))
+ if (browser->proxy_array)
{
- item = midori_view_get_proxy_item (MIDORI_VIEW (widget));
- if (browser->trash && !midori_view_is_blank (MIDORI_VIEW (widget)))
+ KatzeItem* item = midori_view_get_proxy_item (view);
+ if (browser->trash && !midori_view_is_blank (view))
katze_array_add_item (browser->trash, item);
katze_array_remove_item (browser->proxy_array, item);
- }
-
- _midori_browser_update_actions (browser);
-
- /* This callback must only be called once, but we need to ensure
- that "remove-tab" is emitted in any case */
- g_signal_handlers_disconnect_by_func (widget,
- midori_browser_tab_destroy_cb, browser);
-
- g_signal_emit (browser, signals[REMOVE_TAB], 0, widget);
/* We don't ever want to be in a situation with no tabs,
so just create an empty one if the last one is closed.
The only exception is when we are closing the window,
which is indicated by the proxy array having been unset. */
- if (browser->proxy_array && !midori_browser_get_current_tab (browser))
- midori_browser_add_uri (browser, "");
- return FALSE;
+ if (midori_browser_get_n_pages (browser) == 0)
+ midori_browser_add_uri (browser, "");
+ }
+
+ _midori_browser_update_actions (browser);
+}
+
+static void
+_midori_browser_remove_tab (MidoriBrowser* browser,
+ GtkWidget* widget)
+{
}
#ifndef HAVE_GRANITE
_midori_browser_update_actions (browser);
}
-static void
-_midori_browser_remove_tab (MidoriBrowser* browser,
- GtkWidget* view)
-{
- gtk_widget_destroy (view);
- midori_browser_notebook_size_allocate_cb (browser->notebook, NULL, browser);
-}
-
/**
* midori_browser_foreach:
* @browser: a #MidoriBrowser
MidoriBrowser* browser)
{
GtkWidget* widget = midori_browser_get_current_tab (browser);
+ MidoriView* view = MIDORI_VIEW (widget);
gboolean last_tab = midori_browser_get_n_pages (browser) == 1;
if (last_tab && sokoke_is_app_or_private ())
{
gtk_widget_destroy (GTK_WIDGET (browser));
return;
}
- if (last_tab && midori_view_is_blank (MIDORI_VIEW (widget)))
+ if (last_tab && midori_view_is_blank (view))
return;
- gtk_widget_destroy (widget);
+ midori_browser_remove_tab (browser, widget);
}
static void
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
uri = katze_item_get_uri (item);
-
- if (uri && *uri)
- {
- MidoriBrowser* new_browser;
- g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser);
- midori_browser_add_uri (new_browser, uri);
- }
+ midori_view_new_window_cb (NULL, uri, browser);
}
static void
midori_view_set_uri (MIDORI_VIEW (view), "");
}
+static gboolean
+midori_browser_notebook_tab_removed_cb (GtkWidget* notebook,
+ GraniteWidgetsTab* tab,
+ MidoriBrowser* browser)
+{
+ MidoriView* view = MIDORI_VIEW (granite_widgets_tab_get_page (tab));
+ g_signal_emit (browser, signals[REMOVE_TAB], 0, view);
+ gtk_widget_destroy (view);
+ return TRUE;
+}
+
static void
midori_browser_notebook_tab_switched_cb (GraniteWidgetsDynamicNotebook* notebook,
GraniteWidgetsTab* old_tab,
MidoriBrowser* browser)
{
_midori_browser_remove_tab (browser, view);
+ midori_browser_notebook_size_allocate_cb (browser->notebook, NULL, browser);
}
static gboolean
g_signal_connect (browser->notebook, "tab-added",
G_CALLBACK (midori_browser_notebook_tab_added_cb),
browser);
+ g_signal_connect (browser->notebook, "tab-removed",
+ G_CALLBACK (midori_browser_notebook_tab_removed_cb),
+ browser);
g_signal_connect (browser->notebook, "tab-switched",
G_CALLBACK (midori_browser_notebook_tab_switched_cb),
browser);
g_return_if_fail (GTK_IS_WIDGET (view));
g_signal_emit (browser, signals[REMOVE_TAB], 0, view);
+ #ifdef HAVE_GRANITE
+ granite_widgets_dynamic_notebook_remove_tab (
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook),
+ midori_view_get_tab (MIDORI_VIEW (view)));
+ #else
+ gtk_widget_destroy (view);
+ #endif
}
/**
{
GtkWidget* remaining_view = data;
if (view != remaining_view)
- gtk_widget_destroy (view);
+ midori_browser_remove_tab (midori_browser_get_for_widget (view), view);
}
static void
midori_view_tab_label_menu_close_cb (GtkWidget* menuitem,
GtkWidget* view)
{
- gtk_widget_destroy (view);
+ midori_browser_remove_tab (midori_browser_get_for_widget (view), view);
}
/**
if (event->button == 2)
{
/* Close the widget on middle click */
- gtk_widget_destroy (widget);
+ midori_browser_remove_tab (midori_browser_get_for_widget (widget), widget);
return TRUE;
}
else if (MIDORI_EVENT_CONTEXT_MENU (event))
midori_view_tab_close_clicked (GtkWidget* tab_close,
GtkWidget* widget)
{
- gtk_widget_destroy (widget);
+ midori_browser_remove_tab (midori_browser_get_for_widget (widget), widget);
}
#if !GTK_CHECK_VERSION (3, 0, 0)