Commit d1ac8b49 authored by Luca Bacci's avatar Luca Bacci

Use natural size inside Gtk::ScrolledWindows

Starting from Gtk 3.22 GtkScrolledWindow behaviour was changed to request the
minimum size for its child by default [2]. An API was added to make it
explicitely request the natural size [3]
This was done to have better support out of the box for dynamic content inside
scrolled windows, that is, content that may change allocated size.
when scrolled window content is not dynamic it is best to request the natural
size, especially in presence of wrapping labels, that may otherwise end up
taking a very small width.

Explicitely request natural size allocation to Gtk::ScrolledWindow child when
Gtk >= 3.22.

References:

[1] GNOME Bugzilla - Bug 766569 Better size requisition for GTK_SCROLL_NATURAL children
    https://bugzilla.gnome.org/show_bug.cgi?id=766569

[2] Gtk Commit - GtkScrolledWindow: Make propagation of natural child sizes optional
    GNOME/gtk@0984d162
    "Making propagation of child natural sizes mandatory (or default, even) was
    evidently a mistake as this causes dynamic content in a scrolled window
    to resize it's parent when the scrolled window is competing for space
    with an adjacent widget."

[3] Gtk 3.22 Reference Documentation - GtkScrolledWindow/set_propagate_natural_width/height()
    https://developer.gnome.org/gtk3/3.22/GtkScrolledWindow.html#gtk-scrolled-window-set-propagate-natural-width

[4] Gtkmm 3.21.6 NEWS
    https://gitlab.gnome.org/GNOME/gtkmm/blob/3.21.6/NEWS
    "* ScrolledWindow:
       - Added get/set_propagate_natural_height/width()
         and the properties."
parent d906b907
Pipeline #78876 canceled with stages
in 3 minutes and 31 seconds
......@@ -242,6 +242,17 @@ if test "x$need_cxx_compile_stdcxx_11" = xyes; then
fi
dnl Check for gtkmm >= 3.22 to determine availability of Gtk::ScrolledWindow::set_propagate_natural_width/height().
AC_MSG_CHECKING([for Gtk::ScrolledWindow::set_propagate_natural_width/height() methods])
PKG_CHECK_EXISTS(
[gtkmm-3.0 >= 3.22.0],
[AC_DEFINE([GTKMM_HAVE_GTK_SCROLLED_WINDOW_SET_PROPAGATE_NATURAL_WIDTH_HEIGHT], 1,
[Define to 1 if gtkmm provides Gtk::ScrolledWindow::set_propagate_natural_width/height() methods.])
AC_MSG_RESULT([yes])
],
[AC_MSG_RESULT([no])]
)
dnl Definitions for building of and with gtest. Gets flags for pthread via earlier
dnl gthread package check.
......
......@@ -52,6 +52,10 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition ) : pa
info_msg_vbox.set_orientation(Gtk::ORIENTATION_VERTICAL);
info_msg_vbox .set_border_width( 6 ) ;
info_scrolled .set_policy( Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC ) ;
#if GTKMM_HAVE_GTK_SCROLLED_WINDOW_SET_PROPAGATE_NATURAL_WIDTH_HEIGHT
info_scrolled.set_propagate_natural_width(true);
info_scrolled.set_propagate_natural_height(true);
#endif
info_scrolled .add( info_msg_vbox ) ;
// As Gtk::Box widget info_msg_vbox doesn't have a native scrolling capability a
// Gtk::Viewport is automatically created to contain it when it is added to the
......
......@@ -658,6 +658,10 @@ void Win_GParted::init_hpaned_main()
scrollwindow = manage( new Gtk::ScrolledWindow() ) ;
scrollwindow ->set_shadow_type( Gtk::SHADOW_ETCHED_IN );
scrollwindow ->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
#if GTKMM_HAVE_GTK_SCROLLED_WINDOW_SET_PROPAGATE_NATURAL_WIDTH_HEIGHT
scrollwindow->set_propagate_natural_width(true);
scrollwindow->set_propagate_natural_height(true);
#endif
hpaned_main .pack1( *scrollwindow, true, true );
scrollwindow ->add( vbox_info );
......@@ -666,7 +670,11 @@ void Win_GParted::init_hpaned_main()
scrollwindow = manage( new Gtk::ScrolledWindow() ) ;
scrollwindow ->set_shadow_type( Gtk::SHADOW_ETCHED_IN );
scrollwindow ->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
#if GTKMM_HAVE_GTK_SCROLLED_WINDOW_SET_PROPAGATE_NATURAL_WIDTH_HEIGHT
scrollwindow->set_propagate_natural_width(true);
scrollwindow->set_propagate_natural_height(true);
#endif
//connect signals and add treeview_detail
treeview_detail .signal_partition_selected .connect( sigc::mem_fun( this, &Win_GParted::on_partition_selected ) );
treeview_detail .signal_partition_activated .connect( sigc::mem_fun( this, &Win_GParted::on_partition_activated ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment