[gparted] Request natural width in Gtk::ScrolledWindows for Gtk >= 3.22 (!39)
- From: Mike Fleetwood <mfleetwo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Request natural width in Gtk::ScrolledWindows for Gtk >= 3.22 (!39)
- Date: Mon, 13 May 2019 20:30:51 +0000 (UTC)
commit eeffd50531213269680f96a162423a5045711975
Author: Luca Bacci <luca bacci982 gmail com>
Date: Wed May 1 12:57:38 2019 +0200
Request natural width in Gtk::ScrolledWindows for Gtk >= 3.22 (!39)
Before Gtk 3.22 GtkScrolledWindow propagated natural size to its
Children and so on to descendants. In Gtk 3.22 this was changed to
always request the minimum size. This was done because it is believed
to be a safer default (gives a better behaviour) in case of dynamic
content inside the scrolled window, that is, content that may change
allocated size. [1][2][3]
When the scrolled window content is not dynamic the natural size is
preferable because it gives a better looking layout and without any
downside.
In the case of GParted content which is not dynamic, so request the
scrolled windows to allocate children at natural sizes for Gtk >= 3.22.
The benefits of natural size allocation are evident in presence of
wrapping labels (for example inside the "Partition Info" dialog), that
with the minimum size request likely end up taking a very small width.
References:
[1] Gtk commit from 2016-08-31:
GtkScrolledWindow: Make propagation of natural child sizes optional
https://gitlab.gnome.org/GNOME/gtk/commit/0984d1622d022bf67207f985f7842b6299818e20
"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."
[2] Gtk 3.22 Reference Documentation -
gtk_scrolled_window_set_propagate_natural_width
https://developer.gnome.org/gtk3/3.22/GtkScrolledWindow.html#gtk-scrolled-window-set-propagate-natural-width
[3] Gtkmm 3.24 Gtk::ScrolledWindow Class Reference,
set_propagate_natural_width() method
https://developer.gnome.org/gtkmm/3.24/classGtk_1_1ScrolledWindow.html#a2d4cb945688ecb8739efd70b18742779
[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."
Closes !39 - Always request natural size inside Gtk::ScrolledWindow
configure.ac | 11 +++++++++++
src/Dialog_Partition_Info.cc | 3 +++
src/Win_GParted.cc | 8 +++++++-
3 files changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/configure.ac b/configure.ac
index 4016c715..63fd222e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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().
+AC_MSG_CHECKING([for Gtk::ScrolledWindow::set_propagate_natural_width() method])
+PKG_CHECK_EXISTS(
+ [gtkmm-3.0 >= 3.22.0],
+ [AC_DEFINE([HAVE_SET_PROPAGATE_NATURAL_WIDTH], 1,
+ [Define to 1 if gtkmm provides Gtk::ScrolledWindow::set_propagate_natural_width() method.])
+ 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.
diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc
index af13e702..68e831d7 100644
--- a/src/Dialog_Partition_Info.cc
+++ b/src/Dialog_Partition_Info.cc
@@ -52,6 +52,9 @@ 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 HAVE_SET_PROPAGATE_NATURAL_WIDTH
+ info_scrolled.set_propagate_natural_width(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
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 71d18553..4f006b85 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -658,6 +658,9 @@ 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 HAVE_SET_PROPAGATE_NATURAL_WIDTH
+ scrollwindow->set_propagate_natural_width(true);
+#endif
hpaned_main .pack1( *scrollwindow, true, true );
scrollwindow ->add( vbox_info );
@@ -666,7 +669,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 HAVE_SET_PROPAGATE_NATURAL_WIDTH
+ scrollwindow->set_propagate_natural_width(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 ) );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]