[gtk/wip/otte/listview: 109/155] listbase: Move orientable implementation here
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/listview: 109/155] listbase: Move orientable implementation here
- Date: Tue, 4 Feb 2020 19:44:18 +0000 (UTC)
commit 0c67445e4c5985a9421f6c751bdb5f667991079d
Author: Benjamin Otte <otte redhat com>
Date: Thu Oct 24 02:07:37 2019 +0200
listbase: Move orientable implementation here
gtk/gtkgridview.c | 89 +++++++++++++++---------------------------------
gtk/gtklistbase.c | 49 +++++++++++++++++++++++++-
gtk/gtklistbaseprivate.h | 3 ++
gtk/gtklistview.c | 74 +++++++++-------------------------------
4 files changed, 95 insertions(+), 120 deletions(-)
---
diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c
index 97786d714d..af4465954d 100644
--- a/gtk/gtkgridview.c
+++ b/gtk/gtkgridview.c
@@ -27,10 +27,8 @@
#include "gtklistitemfactory.h"
#include "gtklistitemmanagerprivate.h"
#include "gtkmain.h"
-#include "gtkorientableprivate.h"
#include "gtkprivate.h"
#include "gtksingleselection.h"
-#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
/* Maximum number of list items created by the gridview.
@@ -62,7 +60,6 @@ struct _GtkGridView
GListModel *model;
GtkListItemManager *item_manager;
- GtkOrientation orientation;
guint min_columns;
guint max_columns;
/* set in size_allocate */
@@ -103,7 +100,6 @@ enum
PROP_MAX_COLUMNS,
PROP_MIN_COLUMNS,
PROP_MODEL,
- PROP_ORIENTATION,
N_PROPS
};
@@ -113,8 +109,7 @@ enum {
LAST_SIGNAL
};
-G_DEFINE_TYPE_WITH_CODE (GtkGridView, gtk_grid_view, GTK_TYPE_LIST_BASE,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
+G_DEFINE_TYPE (GtkGridView, gtk_grid_view, GTK_TYPE_LIST_BASE)
static GParamSpec *properties[N_PROPS] = { NULL, };
static guint signals[LAST_SIGNAL] = { 0 };
@@ -476,7 +471,7 @@ gtk_grid_view_adjustment_value_changed (GtkListBase *base,
anchor_pos = gtk_list_item_tracker_get_position (self->item_manager, self->anchor);
n_items = g_list_model_get_n_items (self->model);
- if (orientation == self->orientation)
+ if (orientation == gtk_list_base_get_orientation (GTK_LIST_BASE (self)))
{
/* Compute how far down we've scrolled. That's the height
* we want to align to. */
@@ -574,7 +569,7 @@ gtk_grid_view_adjustment_value_changed (GtkListBase *base,
* to fill the row.
* Do it the hard way then... */
gtk_list_base_get_adjustment_values (base,
- OPPOSITE_ORIENTATION (self->orientation),
+ gtk_list_base_get_opposite_orientation (base),
&value, &total_size, &page_size);
pos = n_items - 1;
@@ -600,7 +595,7 @@ gtk_grid_view_update_adjustment (GtkGridView *self,
page_size = gtk_widget_get_size (GTK_WIDGET (self), orientation);
- if (self->orientation == orientation)
+ if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == orientation)
{
Cell *cell;
CellAugment *aug;
@@ -619,7 +614,7 @@ gtk_grid_view_update_adjustment (GtkGridView *self,
value += cell_size;
value = gtk_list_base_set_adjustment_values (GTK_LIST_BASE (self),
- self->orientation,
+ orientation,
value - self->anchor_yalign * page_size,
aug->size,
page_size);
@@ -635,7 +630,7 @@ gtk_grid_view_update_adjustment (GtkGridView *self,
total_size = round (self->n_columns * self->column_width);
value = gtk_list_base_set_adjustment_values (GTK_LIST_BASE (self),
- OPPOSITE_ORIENTATION (self->orientation),
+ orientation,
value - self->anchor_xalign * page_size,
total_size,
page_size);
@@ -674,7 +669,7 @@ gtk_grid_view_measure_column_size (GtkGridView *self,
min = 0;
nat = 0;
- opposite = OPPOSITE_ORIENTATION (self->orientation);
+ opposite = gtk_list_base_get_opposite_orientation (GTK_LIST_BASE (self));
for (cell = gtk_list_item_manager_get_first (self->item_manager);
cell != NULL;
@@ -718,7 +713,8 @@ gtk_grid_view_compute_n_columns (GtkGridView *self,
guint n_columns;
/* rounding down is exactly what we want here, so int division works */
- if (gtk_list_base_get_scroll_policy (GTK_LIST_BASE (self), OPPOSITE_ORIENTATION (self->orientation)) ==
GTK_SCROLL_MINIMUM)
+ if (gtk_list_base_get_scroll_policy (GTK_LIST_BASE (self),
+ gtk_list_base_get_opposite_orientation (GTK_LIST_BASE (self))) ==
GTK_SCROLL_MINIMUM)
n_columns = for_size / MAX (1, min);
else
n_columns = for_size / MAX (1, nat);
@@ -743,7 +739,7 @@ gtk_grid_view_measure_list (GtkWidget *widget,
guint n_unknown, n_columns;
guint i;
- scroll_policy = gtk_list_base_get_scroll_policy (GTK_LIST_BASE (self), self->orientation);
+ scroll_policy = gtk_list_base_get_scroll_policy (GTK_LIST_BASE (self), gtk_list_base_get_orientation
(GTK_LIST_BASE (self)));
heights = g_array_new (FALSE, FALSE, sizeof (int));
n_unknown = 0;
height = 0;
@@ -763,7 +759,8 @@ gtk_grid_view_measure_list (GtkWidget *widget,
if (cell->parent.widget)
{
gtk_widget_measure (cell->parent.widget,
- self->orientation, column_size,
+ gtk_list_base_get_orientation (GTK_LIST_BASE (self)),
+ column_size,
&child_min, &child_nat, NULL, NULL);
if (scroll_policy == GTK_SCROLL_MINIMUM)
row_height = MAX (row_height, child_min);
@@ -820,7 +817,7 @@ gtk_grid_view_measure (GtkWidget *widget,
{
GtkGridView *self = GTK_GRID_VIEW (widget);
- if (orientation == self->orientation)
+ if (orientation == gtk_list_base_get_orientation (GTK_LIST_BASE (self)))
gtk_grid_view_measure_list (widget, for_size, minimum, natural);
else
gtk_grid_view_measure_across (widget, for_size, minimum, natural);
@@ -847,7 +844,7 @@ gtk_grid_view_size_allocate_child (GtkGridView *self,
{
GtkAllocation child_allocation;
- if (self->orientation == GTK_ORIENTATION_VERTICAL)
+ if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == GTK_ORIENTATION_VERTICAL)
{
child_allocation.x = x;
child_allocation.y = y;
@@ -884,14 +881,15 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
Cell *cell, *start;
GArray *heights;
int min_row_height, row_height, col_min, col_nat;
- GtkOrientation opposite_orientation;
+ GtkOrientation orientation, opposite_orientation;
GtkScrollablePolicy scroll_policy;
gboolean known;
int x, y;
guint i;
- scroll_policy = gtk_list_base_get_scroll_policy (GTK_LIST_BASE (self), self->orientation);
- opposite_orientation = OPPOSITE_ORIENTATION (self->orientation);
+ orientation = gtk_list_base_get_orientation (GTK_LIST_BASE (self));
+ scroll_policy = gtk_list_base_get_scroll_policy (GTK_LIST_BASE (self), orientation);
+ opposite_orientation = OPPOSITE_ORIENTATION (orientation);
min_row_height = ceil ((double) height / GTK_GRID_VIEW_MAX_VISIBLE_ROWS);
/* step 0: exit early if list is empty */
@@ -901,9 +899,9 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
/* step 1: determine width of the list */
gtk_grid_view_measure_column_size (self, &col_min, &col_nat);
self->n_columns = gtk_grid_view_compute_n_columns (self,
- self->orientation == GTK_ORIENTATION_VERTICAL ? width :
height,
+ orientation == GTK_ORIENTATION_VERTICAL ? width :
height,
col_min, col_nat);
- self->column_width = (self->orientation == GTK_ORIENTATION_VERTICAL ? width : height) / self->n_columns;
+ self->column_width = (orientation == GTK_ORIENTATION_VERTICAL ? width : height) / self->n_columns;
self->column_width = MAX (self->column_width, col_min);
/* step 2: determine height of known rows */
@@ -922,7 +920,8 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
if (cell->parent.widget)
{
int min, nat, size;
- gtk_widget_measure (cell->parent.widget, self->orientation,
+ gtk_widget_measure (cell->parent.widget,
+ gtk_list_base_get_orientation (GTK_LIST_BASE (self)),
self->column_width,
&min, &nat, NULL, NULL);
if (scroll_policy == GTK_SCROLL_MINIMUM)
@@ -986,7 +985,7 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
/* step 4: update the adjustments */
x = - gtk_grid_view_update_adjustment (self, opposite_orientation);
- y = - gtk_grid_view_update_adjustment (self, self->orientation);
+ y = - gtk_grid_view_update_adjustment (self, orientation);
/* step 5: run the size_allocate loop */
x = -x;
@@ -1093,10 +1092,6 @@ gtk_grid_view_get_property (GObject *object,
g_value_set_object (value, self->model);
break;
- case PROP_ORIENTATION:
- g_value_set_enum (value, self->orientation);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -1125,19 +1120,6 @@ gtk_grid_view_set_property (GObject *object,
gtk_grid_view_set_min_columns (self, g_value_get_uint (value));
break;
- case PROP_ORIENTATION:
- {
- GtkOrientation orientation = g_value_get_enum (value);
- if (self->orientation != orientation)
- {
- self->orientation = orientation;
- _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
- gtk_widget_queue_resize (GTK_WIDGET (self));
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ORIENTATION]);
- }
- }
- break;
-
case PROP_MODEL:
gtk_grid_view_set_model (self, g_value_get_object (value));
break;
@@ -1251,7 +1233,7 @@ gtk_grid_view_scroll_to_item (GtkWidget *widget,
end += start;
gtk_grid_view_compute_scroll_align (self,
- self->orientation,
+ gtk_list_base_get_orientation (GTK_LIST_BASE (self)),
start, end,
self->anchor_yalign, self->anchor_ystart,
&yalign, &ystart);
@@ -1260,7 +1242,7 @@ gtk_grid_view_scroll_to_item (GtkWidget *widget,
start = floor (self->column_width * (pos % self->n_columns));
end = floor (self->column_width * ((pos % self->n_columns) + 1));
gtk_grid_view_compute_scroll_align (self,
- OPPOSITE_ORIENTATION (self->orientation),
+ gtk_list_base_get_opposite_orientation (GTK_LIST_BASE (self)),
start, end,
self->anchor_xalign, self->anchor_xstart,
&xalign, &xstart);
@@ -1307,7 +1289,7 @@ gtk_grid_view_move_cursor (GtkWidget *widget,
g_variant_get (args, "(ubbbi)", &orientation, &select, &modify, &extend, &amount);
- if (self->orientation == orientation)
+ if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == orientation)
amount *= self->n_columns;
if (orientation == GTK_ORIENTATION_HORIZONTAL &&
@@ -1385,7 +1367,7 @@ gtk_grid_view_move_cursor_page_up (GtkWidget *widget,
if (!gtk_grid_view_get_size_at_position (self, pos, &start, &size))
return;
gtk_list_base_get_adjustment_values (GTK_LIST_BASE (self),
- self->orientation,
+ gtk_list_base_get_orientation (GTK_LIST_BASE (self)),
NULL, NULL, &page_size);
if (!gtk_grid_view_get_cell_at_y (self,
MAX (0, start + size - page_size),
@@ -1422,7 +1404,7 @@ gtk_grid_view_move_cursor_page_down (GtkWidget *widget,
if (!gtk_grid_view_get_size_at_position (self, pos, &start, NULL))
return;
gtk_list_base_get_adjustment_values (GTK_LIST_BASE (self),
- self->orientation,
+ gtk_list_base_get_orientation (GTK_LIST_BASE (self)),
NULL, NULL, &page_size);
if (gtk_grid_view_get_cell_at_y (self,
start + page_size,
@@ -1587,20 +1569,6 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
- /**
- * GtkGridView:orientation:
- *
- * The orientation of the gridview. See GtkOrientable:orientation
- * for details.
- */
- properties[PROP_ORIENTATION] =
- g_param_spec_enum ("orientation",
- P_("Orientation"),
- P_("The orientation of the orientable"),
- GTK_TYPE_ORIENTATION,
- GTK_ORIENTATION_VERTICAL,
- GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
-
g_object_class_install_properties (gobject_class, N_PROPS, properties);
/**
@@ -1692,7 +1660,6 @@ gtk_grid_view_init (GtkGridView *self)
self->min_columns = 1;
self->max_columns = DEFAULT_MAX_COLUMNS;
- self->orientation = GTK_ORIENTATION_VERTICAL;
}
/**
diff --git a/gtk/gtklistbase.c b/gtk/gtklistbase.c
index f637cdff28..c7ad383bc7 100644
--- a/gtk/gtklistbase.c
+++ b/gtk/gtklistbase.c
@@ -22,13 +22,17 @@
#include "gtklistbaseprivate.h"
#include "gtkadjustment.h"
+#include "gtkintl.h"
+#include "gtkorientableprivate.h"
#include "gtkscrollable.h"
+#include "gtktypebuiltins.h"
typedef struct _GtkListBasePrivate GtkListBasePrivate;
struct _GtkListBasePrivate
{
GtkListItemManager *item_manager;
+ GtkOrientation orientation;
GtkAdjustment *adjustment[2];
GtkScrollablePolicy scroll_policy[2];
@@ -41,6 +45,7 @@ enum
PROP_0,
PROP_HADJUSTMENT,
PROP_HSCROLL_POLICY,
+ PROP_ORIENTATION,
PROP_VADJUSTMENT,
PROP_VSCROLL_POLICY,
@@ -52,6 +57,7 @@ static void gtk_list_base_init_real (GtkListBase *self, GtkListBaseClass *g_clas
#define g_type_register_static_simple(a,b,c,d,e,evil,f) g_type_register_static_simple(a,b,c,d,e,
(GInstanceInitFunc) gtk_list_base_init_real, f);
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GtkListBase, gtk_list_base, GTK_TYPE_WIDGET,
G_ADD_PRIVATE (GtkListBase)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE,
NULL)
G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE,
NULL))
#undef g_type_register_static_simple
G_GNUC_UNUSED static void gtk_list_base_init (GtkListBase *self) { }
@@ -166,6 +172,10 @@ gtk_list_base_get_property (GObject *object,
g_value_set_enum (value, priv->scroll_policy[GTK_ORIENTATION_HORIZONTAL]);
break;
+ case PROP_ORIENTATION:
+ g_value_set_enum (value, priv->orientation);
+ break;
+
case PROP_VADJUSTMENT:
g_value_set_object (value, priv->adjustment[GTK_ORIENTATION_VERTICAL]);
break;
@@ -232,6 +242,7 @@ gtk_list_base_set_property (GObject *object,
GParamSpec *pspec)
{
GtkListBase *self = GTK_LIST_BASE (object);
+ GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
switch (property_id)
{
@@ -243,6 +254,19 @@ gtk_list_base_set_property (GObject *object,
gtk_list_base_set_scroll_policy (self, GTK_ORIENTATION_HORIZONTAL, g_value_get_enum (value));
break;
+ case PROP_ORIENTATION:
+ {
+ GtkOrientation orientation = g_value_get_enum (value);
+ if (priv->orientation != orientation)
+ {
+ priv->orientation = orientation;
+ _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
+ gtk_widget_queue_resize (GTK_WIDGET (self));
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ORIENTATION]);
+ }
+ }
+ break;
+
case PROP_VADJUSTMENT:
gtk_list_base_set_adjustment (self, GTK_ORIENTATION_VERTICAL, g_value_get_object (value));
break;
@@ -329,6 +353,20 @@ gtk_list_base_class_init (GtkListBaseClass *klass)
g_param_spec_override ("vscroll-policy",
g_object_interface_find_property (iface, "vscroll-policy"));
+ /**
+ * GtkListBase:orientation:
+ *
+ * The orientation of the list. See GtkOrientable:orientation
+ * for details.
+ */
+ properties[PROP_ORIENTATION] =
+ g_param_spec_enum ("orientation",
+ P_("Orientation"),
+ P_("The orientation of the orientable"),
+ GTK_TYPE_ORIENTATION,
+ GTK_ORIENTATION_VERTICAL,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (gobject_class, N_PROPS, properties);
/**
@@ -389,12 +427,13 @@ gtk_list_base_init_real (GtkListBase *self,
g_class->list_item_size,
g_class->list_item_augment_size,
g_class->list_item_augment_func);
-
priv->selected = gtk_list_item_tracker_new (priv->item_manager);
priv->adjustment[GTK_ORIENTATION_HORIZONTAL] = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
priv->adjustment[GTK_ORIENTATION_VERTICAL] = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ priv->orientation = GTK_ORIENTATION_VERTICAL;
+
gtk_widget_set_overflow (GTK_WIDGET (self), GTK_OVERFLOW_HIDDEN);
}
@@ -473,6 +512,14 @@ gtk_list_base_get_scroll_policy (GtkListBase *self,
return priv->scroll_policy[orientation];
}
+GtkOrientation
+gtk_list_base_get_orientation (GtkListBase *self)
+{
+ GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
+
+ return priv->orientation;
+}
+
GtkListItemManager *
gtk_list_base_get_manager (GtkListBase *self)
{
diff --git a/gtk/gtklistbaseprivate.h b/gtk/gtklistbaseprivate.h
index 47fd7f31b8..e6b070c508 100644
--- a/gtk/gtklistbaseprivate.h
+++ b/gtk/gtklistbaseprivate.h
@@ -23,6 +23,7 @@
#include "gtklistbase.h"
#include "gtklistitemmanagerprivate.h"
+#include "gtkprivate.h"
struct _GtkListBase
{
@@ -42,6 +43,8 @@ struct _GtkListBaseClass
GtkOrientation orientation);
};
+GtkOrientation gtk_list_base_get_orientation (GtkListBase *self);
+#define gtk_list_base_get_opposite_orientation(self)
OPPOSITE_ORIENTATION(gtk_list_base_get_orientation(self))
GtkListItemManager * gtk_list_base_get_manager (GtkListBase *self);
GtkScrollablePolicy gtk_list_base_get_scroll_policy (GtkListBase *self,
GtkOrientation orientation);
diff --git a/gtk/gtklistview.c b/gtk/gtklistview.c
index 5edefee409..a57a647b22 100644
--- a/gtk/gtklistview.c
+++ b/gtk/gtklistview.c
@@ -26,13 +26,11 @@
#include "gtklistbaseprivate.h"
#include "gtklistitemmanagerprivate.h"
#include "gtkmain.h"
-#include "gtkorientableprivate.h"
#include "gtkprivate.h"
#include "gtkrbtreeprivate.h"
#include "gtkselectionmodel.h"
#include "gtksingleselection.h"
#include "gtkstylecontext.h"
-#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
/* Maximum number of list items created by the listview.
@@ -63,7 +61,6 @@ struct _GtkListView
GListModel *model;
GtkListItemManager *item_manager;
gboolean show_separators;
- GtkOrientation orientation;
int list_width;
@@ -96,7 +93,6 @@ enum
PROP_0,
PROP_FACTORY,
PROP_MODEL,
- PROP_ORIENTATION,
PROP_SHOW_SEPARATORS,
N_PROPS
@@ -107,8 +103,7 @@ enum {
LAST_SIGNAL
};
-G_DEFINE_TYPE_WITH_CODE (GtkListView, gtk_list_view, GTK_TYPE_LIST_BASE,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
+G_DEFINE_TYPE (GtkListView, gtk_list_view, GTK_TYPE_LIST_BASE)
static GParamSpec *properties[N_PROPS] = { NULL, };
static guint signals[LAST_SIGNAL] = { 0 };
@@ -339,7 +334,7 @@ gtk_list_view_adjustment_value_changed (GtkListBase *base,
{
GtkListView *self = GTK_LIST_VIEW (base);
- if (orientation == self->orientation)
+ if (orientation == gtk_list_base_get_orientation (GTK_LIST_BASE (self)))
{
int page_size, total_size, value, from_start;
int row_start, row_end;
@@ -406,7 +401,7 @@ gtk_list_view_update_adjustments (GtkListView *self,
page_size = gtk_widget_get_size (GTK_WIDGET (self), orientation);
- if (orientation == self->orientation)
+ if (orientation == gtk_list_base_get_orientation (GTK_LIST_BASE (self)))
{
int offset, size;
guint anchor_pos;
@@ -552,7 +547,7 @@ gtk_list_view_measure (GtkWidget *widget,
{
GtkListView *self = GTK_LIST_VIEW (widget);
- if (orientation == self->orientation)
+ if (orientation == gtk_list_base_get_orientation (GTK_LIST_BASE (self)))
gtk_list_view_measure_list (widget, orientation, for_size, minimum, natural);
else
gtk_list_view_measure_across (widget, orientation, for_size, minimum, natural);
@@ -568,7 +563,7 @@ gtk_list_view_size_allocate_child (GtkListView *self,
{
GtkAllocation child_allocation;
- if (self->orientation == GTK_ORIENTATION_VERTICAL)
+ if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) == GTK_ORIENTATION_VERTICAL)
{
child_allocation.x = x;
child_allocation.y = y;
@@ -606,11 +601,12 @@ gtk_list_view_size_allocate (GtkWidget *widget,
GArray *heights;
int min, nat, row_height;
int x, y;
- GtkOrientation opposite_orientation;
+ GtkOrientation orientation, opposite_orientation;
GtkScrollablePolicy scroll_policy;
- opposite_orientation = OPPOSITE_ORIENTATION (self->orientation);
- scroll_policy = gtk_list_base_get_scroll_policy (GTK_LIST_BASE (self), self->orientation);
+ orientation = gtk_list_base_get_orientation (GTK_LIST_BASE (self));
+ opposite_orientation = OPPOSITE_ORIENTATION (orientation);
+ scroll_policy = gtk_list_base_get_scroll_policy (GTK_LIST_BASE (self), orientation);
/* step 0: exit early if list is empty */
if (gtk_list_item_manager_get_root (self->item_manager) == NULL)
@@ -620,7 +616,7 @@ gtk_list_view_size_allocate (GtkWidget *widget,
gtk_widget_measure (widget, opposite_orientation,
-1,
&min, &nat, NULL, NULL);
- self->list_width = self->orientation == GTK_ORIENTATION_VERTICAL ? width : height;
+ self->list_width = orientation == GTK_ORIENTATION_VERTICAL ? width : height;
if (scroll_policy == GTK_SCROLL_MINIMUM)
self->list_width = MAX (min, self->list_width);
else
@@ -636,7 +632,7 @@ gtk_list_view_size_allocate (GtkWidget *widget,
if (row->parent.widget == NULL)
continue;
- gtk_widget_measure (row->parent.widget, self->orientation,
+ gtk_widget_measure (row->parent.widget, orientation,
self->list_width,
&min, &nat, NULL, NULL);
if (scroll_policy == GTK_SCROLL_MINIMUM)
@@ -671,7 +667,7 @@ gtk_list_view_size_allocate (GtkWidget *widget,
/* step 3: update the adjustments */
x = - gtk_list_view_update_adjustments (self, opposite_orientation);
- y = - gtk_list_view_update_adjustments (self, self->orientation);
+ y = - gtk_list_view_update_adjustments (self, orientation);
/* step 4: actually allocate the widgets */
@@ -789,10 +785,6 @@ gtk_list_view_get_property (GObject *object,
g_value_set_object (value, self->model);
break;
- case PROP_ORIENTATION:
- g_value_set_enum (value, self->orientation);
- break;
-
case PROP_SHOW_SEPARATORS:
g_value_set_boolean (value, self->show_separators);
break;
@@ -821,19 +813,6 @@ gtk_list_view_set_property (GObject *object,
gtk_list_view_set_model (self, g_value_get_object (value));
break;
- case PROP_ORIENTATION:
- {
- GtkOrientation orientation = g_value_get_enum (value);
- if (self->orientation != orientation)
- {
- self->orientation = orientation;
- _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
- gtk_widget_queue_resize (GTK_WIDGET (self));
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ORIENTATION]);
- }
- }
- break;
-
case PROP_SHOW_SEPARATORS:
gtk_list_view_set_show_separators (self, g_value_get_boolean (value));
break;
@@ -949,7 +928,7 @@ gtk_list_view_scroll_to_item (GtkWidget *widget,
end += start;
gtk_list_view_compute_scroll_align (self,
- self->orientation,
+ gtk_list_base_get_orientation (GTK_LIST_BASE (self)),
start, end,
self->anchor_align, self->anchor_start,
&align, &top);
@@ -996,7 +975,7 @@ gtk_list_view_move_cursor (GtkWidget *widget,
g_variant_get (args, "(ubbbi)", &orientation, &select, &modify, &extend, &amount);
- if (self->orientation != orientation)
+ if (gtk_list_base_get_orientation (GTK_LIST_BASE (self)) != orientation)
return;
if (orientation == GTK_ORIENTATION_HORIZONTAL &&
@@ -1073,10 +1052,7 @@ gtk_list_view_move_cursor_page_up (GtkWidget *widget,
if (n_items == 0 || start == 0)
return;
- if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
- pixels = gtk_widget_get_width (widget);
- else
- pixels = gtk_widget_get_height (widget);
+ pixels = gtk_widget_get_size (widget, gtk_list_base_get_orientation (GTK_LIST_BASE (self)));
pixels -= row->height;
pos = gtk_list_view_get_position_at_y (self,
@@ -1117,10 +1093,7 @@ gtk_list_view_move_cursor_page_down (GtkWidget *widget,
if (n_items == 0 || start >= n_items - 1)
return;
- if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
- pixels = gtk_widget_get_width (widget);
- else
- pixels = gtk_widget_get_height (widget);
+ pixels = gtk_widget_get_size (widget, gtk_list_base_get_orientation (GTK_LIST_BASE (self)));
pos = gtk_list_view_get_position_at_y (self,
list_row_get_y (self, row) + pixels,
@@ -1243,20 +1216,6 @@ gtk_list_view_class_init (GtkListViewClass *klass)
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
- /**
- * GtkListView:orientation:
- *
- * The orientation of the orientable. See GtkOrientable:orientation
- * for details.
- */
- properties[PROP_ORIENTATION] =
- g_param_spec_enum ("orientation",
- P_("Orientation"),
- P_("The orientation of the orientable"),
- GTK_TYPE_ORIENTATION,
- GTK_ORIENTATION_VERTICAL,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
-
/**
* GtkListView:show-separators:
*
@@ -1354,7 +1313,6 @@ gtk_list_view_init (GtkListView *self)
self->item_manager = gtk_list_base_get_manager (GTK_LIST_BASE (self));
self->focus = gtk_list_item_tracker_new (self->item_manager);
self->anchor = gtk_list_item_tracker_new (self->item_manager);
- self->orientation = GTK_ORIENTATION_VERTICAL;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]