[gtk] Revert "progressbar: Avoid redundant storage"
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] Revert "progressbar: Avoid redundant storage"
- Date: Tue, 15 Jun 2021 11:39:07 +0000 (UTC)
commit a3882763d8b0f9548da1e9dfaa1dff9473e617d0
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jun 15 07:37:57 2021 -0400
Revert "progressbar: Avoid redundant storage"
This reverts commit 95747b1a4082709d8e5320dc2171a8c53cedce19.
This was wrong - it turns out that while GtkProgressBar
allows you to change its orientation, its box layout is
always vertical.
Fixes: #4037
gtk/gtkprogressbar.c | 39 ++++++++++++++++++---------------------
1 file changed, 18 insertions(+), 21 deletions(-)
---
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c
index 9a82ab0273..d49c7f4868 100644
--- a/gtk/gtkprogressbar.c
+++ b/gtk/gtkprogressbar.c
@@ -106,6 +106,8 @@ struct _GtkProgressBar
double activity_pos;
guint activity_blocks;
+ GtkOrientation orientation;
+
guint tick_id;
GtkProgressTracker tracker;
gint64 pulse1;
@@ -311,9 +313,6 @@ update_node_classes (GtkProgressBar *pbar)
gboolean right = FALSE;
gboolean top = FALSE;
gboolean bottom = FALSE;
- GtkOrientation orientation;
-
- orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (pbar));
/* Here we set positional classes, depending on which end of the
* progressbar the progress touches.
@@ -321,7 +320,7 @@ update_node_classes (GtkProgressBar *pbar)
if (pbar->activity_mode)
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
left = pbar->activity_pos <= 0.0;
right = pbar->activity_pos >= 1.0;
@@ -339,11 +338,11 @@ update_node_classes (GtkProgressBar *pbar)
inverted = pbar->inverted;
if (gtk_widget_get_direction (GTK_WIDGET (pbar)) == GTK_TEXT_DIR_RTL)
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
inverted = !inverted;
}
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
left = !inverted || pbar->fraction >= 1.0;
right = inverted || pbar->fraction >= 1.0;
@@ -389,14 +388,11 @@ allocate_trough (GtkGizmo *gizmo,
GtkAllocation alloc;
int progress_width, progress_height;
gboolean inverted;
- GtkOrientation orientation;
-
- orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (pbar));
inverted = pbar->inverted;
if (gtk_widget_get_direction (GTK_WIDGET (pbar)) == GTK_TEXT_DIR_RTL)
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
inverted = !inverted;
}
@@ -410,7 +406,7 @@ allocate_trough (GtkGizmo *gizmo,
if (pbar->activity_mode)
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
alloc.width = progress_width + (width - progress_width) / pbar->activity_blocks;
alloc.x = pbar->activity_pos * (width - alloc.width);
@@ -428,7 +424,7 @@ allocate_trough (GtkGizmo *gizmo,
}
else
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
alloc.width = progress_width + (width - progress_width) * pbar->fraction;
alloc.height = progress_height;
@@ -485,9 +481,9 @@ gtk_progress_bar_init (GtkProgressBar *pbar)
gtk_widget_set_parent (pbar->progress_widget, pbar->trough_widget);
/* horizontal is default */
- gtk_orientable_set_orientation (GTK_ORIENTABLE (gtk_widget_get_layout_manager (GTK_WIDGET (pbar))),
- GTK_ORIENTATION_VERTICAL);
+ pbar->orientation = GTK_ORIENTATION_VERTICAL; /* Just to force an update... */
gtk_progress_bar_set_orientation (pbar, GTK_ORIENTATION_HORIZONTAL);
+ gtk_widget_update_orientation (GTK_WIDGET (pbar), pbar->orientation);
gtk_accessible_update_property (GTK_ACCESSIBLE (pbar),
GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 1.0,
@@ -546,7 +542,7 @@ gtk_progress_bar_get_property (GObject *object,
switch (prop_id)
{
case PROP_ORIENTATION:
- g_value_set_enum (value, gtk_orientable_get_orientation (GTK_ORIENTABLE (gtk_widget_get_layout_manager
(GTK_WIDGET (pbar)))));
+ g_value_set_enum (value, pbar->orientation);
break;
case PROP_INVERTED:
g_value_set_boolean (value, pbar->inverted);
@@ -695,7 +691,7 @@ gtk_progress_bar_act_mode_enter (GtkProgressBar *pbar)
inverted = pbar->inverted;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
{
- if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == GTK_ORIENTATION_HORIZONTAL)
+ if (pbar->orientation == GTK_ORIENTATION_HORIZONTAL)
inverted = !inverted;
}
@@ -979,12 +975,10 @@ gtk_progress_bar_set_orientation (GtkProgressBar *pbar,
{
GtkBoxLayout *layout;
- layout = GTK_BOX_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (pbar)));
-
- if (gtk_orientable_get_orientation (GTK_ORIENTABLE (layout)) == orientation)
+ if (pbar->orientation == orientation)
return;
- gtk_orientable_set_orientation (GTK_ORIENTABLE (layout), orientation);
+ pbar->orientation = orientation;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
@@ -1001,9 +995,12 @@ gtk_progress_bar_set_orientation (GtkProgressBar *pbar,
gtk_widget_set_valign (pbar->trough_widget, GTK_ALIGN_FILL);
}
- gtk_widget_update_orientation (GTK_WIDGET (pbar), orientation);
+ gtk_widget_update_orientation (GTK_WIDGET (pbar), pbar->orientation);
update_node_classes (pbar);
+ layout = GTK_BOX_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (pbar)));
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (layout), GTK_ORIENTATION_VERTICAL);
+
g_object_notify (G_OBJECT (pbar), "orientation");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]