From 22056692ce29110774bf5486214f8b55b5006922 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 20 Sep 2017 16:35:48 -0400 Subject: src/tab-chrome.c: Try to resize tab history scrolled windows Doesn't work. --- (limited to 'src/tab-chrome.c') diff --git a/src/tab-chrome.c b/src/tab-chrome.c index cdaa51c..924be33 100644 --- a/src/tab-chrome.c +++ b/src/tab-chrome.c @@ -41,6 +41,27 @@ forward_clicked_cb(GtkButton __attribute__((unused)) *toolbutton, } static void +back_forward_scrolled_window_size_allocate_cb( + GtkScrolledWindow *scrolled_window, + GdkRectangle __attribute__((unused)) *allocation, GtkWidget *child) +{ + GtkRequisition child_req; + GtkRequisition hscrollbar_req; + GtkRequisition vscrollbar_req; + + gtk_widget_get_preferred_size(child, NULL, &child_req); + gtk_widget_get_preferred_size(gtk_scrolled_window_get_hscrollbar( + scrolled_window), NULL, &hscrollbar_req); + gtk_widget_get_preferred_size(gtk_scrolled_window_get_hscrollbar( + scrolled_window), NULL, &vscrollbar_req); + + gtk_widget_set_size_request(GTK_WIDGET(scrolled_window), + child_req.width + vscrollbar_req.width, + child_req.height + hscrollbar_req.height); + gtk_widget_queue_resize(GTK_WIDGET(scrolled_window)); +} + +static void back_forward_toggle_button_toggled_cb(GtkToggleButton *toggle_button, GtkStack *stack) { @@ -200,11 +221,19 @@ back_forward_box_button_press_cb(GtkWidget *widget, GdkEvent *event, ++chrome->back_items; } + GtkRequisition min_req, nat_req; + gtk_widget_get_preferred_size(list_box, &min_req, &nat_req); + g_print("Min req: %dx%d\n", min_req.width, min_req.height); + g_print("Nat req: %dx%d\n", nat_req.width, nat_req.height); + /* Set up the stack. */ stack = gtk_stack_new(); scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + g_signal_connect(scrolled_window, "size-allocate", + G_CALLBACK(back_forward_scrolled_window_size_allocate_cb), + list_box); /* gtk_scrolled_window_set_propagate_natural_width( GTK_SCROLLED_WINDOW(scrolled_window), TRUE); */ gtk_container_add(GTK_CONTAINER(scrolled_window), list_box); @@ -212,6 +241,9 @@ back_forward_box_button_press_cb(GtkWidget *widget, GdkEvent *event, scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + g_signal_connect(scrolled_window, "size-allocate", + G_CALLBACK(back_forward_scrolled_window_size_allocate_cb), + text_view); /* gtk_scrolled_window_set_propagate_natural_width( GTK_SCROLLED_WINDOW(scrolled_window), TRUE); */ gtk_container_add(GTK_CONTAINER(scrolled_window), text_view); -- cgit v0.9.1