[glom/gtkmm4v4] gtkmm4: Use Widget::measure() instead of get_preferred_*().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/gtkmm4v4] gtkmm4: Use Widget::measure() instead of get_preferred_*().
- Date: Mon, 29 May 2017 19:29:44 +0000 (UTC)
commit 88f8ec3be4e171d0fffd733f569e51cbec97f964
Author: Murray Cumming <murrayc murrayc com>
Date: Mon May 29 18:24:04 2017 +0200
gtkmm4: Use Widget::measure() instead of get_preferred_*().
.../eggspreadtable/eggspreadtable.c | 16 ++--------
.../eggspreadtable/eggspreadtablednd.c | 31 +++++--------------
glom/utility_widgets/flowtable.cc | 5 ++-
3 files changed, 15 insertions(+), 37 deletions(-)
---
diff --git a/glom/utility_widgets/eggspreadtable/eggspreadtable.c
b/glom/utility_widgets/eggspreadtable/eggspreadtable.c
index 640de83..1fa9ae3 100644
--- a/glom/utility_widgets/eggspreadtable/eggspreadtable.c
+++ b/glom/utility_widgets/eggspreadtable/eggspreadtable.c
@@ -321,20 +321,10 @@ get_widget_size (GtkWidget *widget,
gint *min_size,
gint *nat_size)
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- if (for_size < 0)
- gtk_widget_get_preferred_width (widget, min_size, nat_size);
- else
- gtk_widget_get_preferred_width_for_height (widget, for_size, min_size, nat_size);
- }
+ if (for_size < 0)
+ gtk_widget_measure (widget, orientation, -1, min_size, nat_size, NULL, NULL);
else
- {
- if (for_size < 0)
- gtk_widget_get_preferred_height (widget, min_size, nat_size);
- else
- gtk_widget_get_preferred_height_for_width (widget, for_size, min_size, nat_size);
- }
+ gtk_widget_measure (widget, orientation, for_size, min_size, nat_size, NULL, NULL);
}
/* This gets the widest child, it is used to reserve
diff --git a/glom/utility_widgets/eggspreadtable/eggspreadtablednd.c
b/glom/utility_widgets/eggspreadtable/eggspreadtablednd.c
index d3e8495..9ad2986 100644
--- a/glom/utility_widgets/eggspreadtable/eggspreadtablednd.c
+++ b/glom/utility_widgets/eggspreadtable/eggspreadtablednd.c
@@ -406,20 +406,10 @@ get_widget_size (GtkWidget *widget,
gint *min_size,
gint *nat_size)
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- if (for_size < 0)
- gtk_widget_get_preferred_width (widget, min_size, nat_size);
- else
- gtk_widget_get_preferred_width_for_height (widget, for_size, min_size, nat_size);
- }
+ if (for_size < 0)
+ gtk_widget_measure (widget, orientation, -1, min_size, nat_size, NULL, NULL);
else
- {
- if (for_size < 0)
- gtk_widget_get_preferred_height (widget, min_size, nat_size);
- else
- gtk_widget_get_preferred_height_for_width (widget, for_size, min_size, nat_size);
- }
+ gtk_widget_measure (widget, orientation, for_size, min_size, nat_size, NULL, NULL);
}
static void
@@ -649,25 +639,20 @@ get_placeholder_size (EggSpreadTableDnd *spread_table,
if (orientation == GTK_ORIENTATION_VERTICAL)
{
gint min_width;
-
- gtk_widget_get_preferred_width (spread_table->priv->drag_data.child, &min_width, NULL);
+ gtk_widget_measure (spread_table->priv->drag_data.child, GTK_ORIENTATION_HORIZONTAL, -1, &min_width,
NULL, NULL, NULL);
*width = MAX (line_width, min_width);
-
- gtk_widget_get_preferred_height_for_width (spread_table->priv->drag_data.child,
- *width, height, NULL);
}
else
{
gint min_height;
-
- gtk_widget_get_preferred_width (spread_table->priv->drag_data.child, &min_height, NULL);
+ gtk_widget_measure (spread_table->priv->drag_data.child, GTK_ORIENTATION_VERTICAL, -1, &min_height,
NULL, NULL, NULL);
*height = MAX (line_width, min_height);
-
- gtk_widget_get_preferred_width_for_height (spread_table->priv->drag_data.child,
- *height, width, NULL);
}
+
+ gtk_widget_measure (spread_table->priv->drag_data.child, orientation,
+ *width, height, NULL, NULL, NULL);
}
static gboolean
diff --git a/glom/utility_widgets/flowtable.cc b/glom/utility_widgets/flowtable.cc
index 396e2e9..5f496c4 100644
--- a/glom/utility_widgets/flowtable.cc
+++ b/glom/utility_widgets/flowtable.cc
@@ -225,9 +225,12 @@ bool FlowTable::get_column_for_first_widget(const Gtk::Widget& first, guint& col
if(!child)
return false;
+ int width = 0;
int width_min = 0;
int width_natural = 0;
- child->get_preferred_width(width_min, width_natural);
+ int baseline_min = 0;
+ int baseline_natural = 0;
+ child->measure(Gtk::Orientation::HORIZONTAL, width, width_min, width_natural, baseline_min,
baseline_natural);
//std::cout << G_STRFUNC << ": Calling get_child_line() with child=" << child << ", for first=" << &first
<< std::endl;
//Get the internal parent GtkEventBox, if any,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]