diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 4399236e..e74ebcff 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -1462,6 +1462,31 @@ midori_browser_tab_destroy_cb (GtkWidget* widget, return FALSE; } +static void +_midori_browser_update_notebook (MidoriBrowser* browser) +{ + guint i; + gint new_size = 0; + gint n = gtk_notebook_get_n_pages (GTK_NOTEBOOK(browser->notebook)); + const gint max_size = 150; + const gint min_size = 32; + GtkAllocation notebook_size; + + gtk_widget_get_allocation (browser->notebook, ¬ebook_size); + if (n > 0) new_size = notebook_size.width / n - 7; + if (new_size < min_size) new_size = min_size; + if (new_size > max_size) new_size = max_size; + + for (i = 0; i < n; i++) + { + GtkWidget* view; + GtkWidget* label; + view = gtk_notebook_get_nth_page (GTK_NOTEBOOK(browser->notebook), i); + label = gtk_notebook_get_tab_label (GTK_NOTEBOOK(browser->notebook), view); + gtk_widget_set_size_request (label, new_size, -1); + } +} + static void _midori_browser_add_tab (MidoriBrowser* browser, GtkWidget* view) @@ -1540,6 +1565,7 @@ _midori_browser_add_tab (MidoriBrowser* browser, G_CALLBACK (midori_browser_tab_destroy_cb), browser); _midori_browser_update_actions (browser); + _midori_browser_update_notebook (browser); } static void @@ -1547,6 +1573,7 @@ _midori_browser_remove_tab (MidoriBrowser* browser, GtkWidget* view) { gtk_widget_destroy (view); + _midori_browser_update_notebook (browser); } /** @@ -5199,6 +5226,14 @@ midori_browser_size_allocate_cb (MidoriBrowser* browser, } } +static void +gtk_notebook_size_allocated_cb (GtkWidget* widget, + GdkRectangle* allocation, + MidoriBrowser* browser) +{ + _midori_browser_update_notebook (browser); +} + static void midori_browser_destroy_cb (MidoriBrowser* browser) { @@ -5215,6 +5250,9 @@ midori_browser_destroy_cb (MidoriBrowser* browser) g_signal_handlers_disconnect_by_func (browser->notebook, midori_browser_notebook_reorder_tab_cb, NULL); + g_signal_handlers_disconnect_by_func (browser->notebook, + gtk_notebook_size_allocated_cb, + NULL); gtk_container_foreach (GTK_CONTAINER (browser->notebook), (GtkCallback) gtk_widget_destroy, NULL); } @@ -5934,6 +5972,9 @@ midori_browser_init (MidoriBrowser* browser) g_signal_connect (browser->notebook, "page-reordered", G_CALLBACK (midori_browser_notebook_page_reordered_cb), browser); + g_signal_connect (browser->notebook, "size-allocate", + G_CALLBACK (gtk_notebook_size_allocated_cb), + browser); g_signal_connect_after (browser->notebook, "button-press-event", G_CALLBACK (midori_browser_notebook_button_press_event_after_cb), browser); diff --git a/midori/midori-view.c b/midori/midori-view.c index f4e85e00..654db5f1 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -4591,18 +4591,13 @@ midori_view_update_tab_title (GtkWidget* label, gint size, gdouble angle) { - gint width; - - sokoke_widget_get_text_size (label, "M", &width, NULL); if (angle == 0.0 || angle == 360.0) { - gtk_widget_set_size_request (label, width * size, -1); if (gtk_label_get_ellipsize (GTK_LABEL (label)) != PANGO_ELLIPSIZE_START) gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); } else { - gtk_widget_set_size_request (label, -1, width * size); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_NONE); } gtk_label_set_angle (GTK_LABEL (label), angle); @@ -4767,13 +4762,13 @@ midori_view_get_proxy_tab_label (MidoriView* view) if (katze_object_get_boolean (view->settings, "close-buttons-left")) { gtk_box_pack_end (GTK_BOX (hbox), view->tab_icon, FALSE, FALSE, 0); - gtk_box_pack_end (GTK_BOX (hbox), view->tab_title, FALSE, TRUE, 0); + gtk_box_pack_end (GTK_BOX (hbox), view->tab_title, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), align, FALSE, FALSE, 0); } else { gtk_box_pack_start (GTK_BOX (hbox), view->tab_icon, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), view->tab_title, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), view->tab_title, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (hbox), align, FALSE, FALSE, 0); } gtk_widget_show_all (GTK_WIDGET (event_box));