_toggle_tabbar_smartly (MidoriBrowser* browser,
gboolean ignore_fullscreen)
{
+ gboolean has_tabs = midori_browser_get_n_pages (browser) > 1;
#ifdef HAVE_GRANITE
- gboolean has_tabs = !(midori_browser_is_fullscreen (browser) || ignore_fullscreen);
+ gboolean show_tabs = !(midori_browser_is_fullscreen (browser) || ignore_fullscreen);
granite_widgets_dynamic_notebook_set_show_tabs (
- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), has_tabs);
+ GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), show_tabs);
#else
- gboolean has_tabs =
- gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), 1) != NULL;
gboolean show_tabs =
browser->show_tabs
&& (!midori_browser_is_fullscreen (browser) || ignore_fullscreen)
midori_findbar_search_text (MIDORI_FINDBAR (browser->find), view, found, typing);
}
-static gint
+gint
midori_browser_get_n_pages (MidoriBrowser* browser)
{
#ifdef HAVE_GRANITE
}
static void
-_midori_browser_add_tab (MidoriBrowser* browser,
- GtkWidget* view)
+midori_browser_connect_tab (MidoriBrowser* browser,
+ GtkWidget* view)
{
- GtkWidget* notebook = browser->notebook;
-#ifndef HAVE_GRANITE
- GtkWidget* tab_label;
-#endif
- KatzeItem* item;
- guint n;
-
- gtk_widget_set_can_focus (view, TRUE);
- item = midori_view_get_proxy_item (MIDORI_VIEW (view));
+ KatzeItem* item = midori_view_get_proxy_item (MIDORI_VIEW (view));
katze_array_add_item (browser->proxy_array, item);
+ gtk_widget_set_can_focus (view, TRUE);
g_object_connect (view,
"signal::notify::icon",
midori_view_notify_icon_cb, browser,
midori_view_add_speed_dial_cb, browser,
"signal::leave-notify-event",
midori_browser_tab_leave_notify_event_cb, browser,
+ "signal::destroy",
+ midori_browser_tab_destroy_cb, browser,
NULL);
+}
+
+static void
+_midori_browser_add_tab (MidoriBrowser* browser,
+ GtkWidget* view)
+{
+ GtkWidget* notebook = browser->notebook;
+ KatzeItem* item = midori_view_get_proxy_item (MIDORI_VIEW (view));
+ #ifndef HAVE_GRANITE
+ GtkWidget* tab_label;
+ #endif
+ guint n;
+
+ midori_browser_connect_tab (browser, view);
if (!katze_item_get_meta_boolean (item, "append") &&
katze_object_get_boolean (browser->settings, "open-tabs-next-to-current"))
}
else
n = -1;
+ katze_item_set_meta_integer (item, "append", -1);
+
#ifdef HAVE_GRANITE
granite_widgets_dynamic_notebook_insert_tab (
GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (notebook),
gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), view, tab_label, n);
gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), view, TRUE);
gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (notebook), view, TRUE);
+ midori_browser_notebook_size_allocate_cb (browser->notebook, NULL, browser);
#endif
- katze_item_set_meta_integer (item, "append", -1);
-
- /* We want the tab to be removed if the widget is destroyed */
- g_signal_connect (view, "destroy",
- G_CALLBACK (midori_browser_tab_destroy_cb), browser);
_midori_browser_update_actions (browser);
- midori_browser_notebook_size_allocate_cb (browser->notebook, NULL, browser);
}
static void
{
GtkWidget* view = midori_view_new_with_item (NULL, browser->settings);
midori_view_set_tab (MIDORI_VIEW (view), tab);
- gint n = midori_browser_add_tab (browser, view);
- midori_browser_set_current_page (browser, n);
+ midori_browser_connect_tab (browser, view);
+ /* FIXME: signal add-tab */
+ _midori_browser_update_actions (browser);
+ midori_view_set_uri (MIDORI_VIEW (view), "");
}
static void
if (uri)
soup_uri_free (uri);
#ifdef HAVE_GRANITE
- g_object_set (midori_view_get_tab (view),
- "label", display_title, "ellipsize-mode", view->ellipsize, NULL);
+ if (view->tab)
+ g_object_set (view->tab,
+ "label", display_title, "ellipsize-mode", view->ellipsize, NULL);
#else
if (view->tab_label)
{
g_object_notify (G_OBJECT (view), "icon");
#ifdef HAVE_GRANITE
- g_object_set (midori_view_get_tab (view), "icon", icon, NULL);
+ if (view->tab)
+ g_object_set (view->tab, "icon", icon, NULL);
#else
if (view->tab_icon)
{
g_object_notify (G_OBJECT (view), "load-status");
#ifdef HAVE_GRANITE
- g_object_set (midori_view_get_tab (view),
- "working", view->load_status != MIDORI_LOAD_FINISHED, NULL);
+ if (view->tab)
+ g_object_set (view->tab,
+ "working", view->load_status != MIDORI_LOAD_FINISHED, NULL);
#else
if (view->tab_icon)
katze_throbber_set_animated (KATZE_THROBBER (view->tab_icon),
g_signal_handlers_unblock_by_func (view->item,
midori_view_item_meta_data_changed, view);
#ifdef HAVE_GRANITE
- g_object_set (midori_view_get_tab (view), "label",
- "fixed", view->minimized, NULL);
+ if (view->tab)
+ g_object_set (view->tab, "label",
+ "fixed", view->minimized, NULL);
//view->minimized ? NULL : midori_view_get_display_title(view), NULL);
#else
if (view->tab_label)