[gtk/prop-list: 3/3] Redo inverted sorting
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/prop-list: 3/3] Redo inverted sorting
- Date: Tue, 3 Dec 2019 20:12:26 +0000 (UTC)
commit bdb80c7925545a2f8969f11c1023c778897a3c80
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Dec 3 15:11:04 2019 -0500
Redo inverted sorting
Break this out into a GtkInvertibleSorter class and
use that from the GtkColumnViewColumn.
gtk/gtk.h | 1 +
gtk/gtkcolumnviewcolumn.c | 21 +++-
gtk/gtkcolumnviewcolumnprivate.h | 2 +
gtk/gtkcolumnviewtitle.c | 20 ++--
gtk/gtkinvertiblesorter.c | 238 +++++++++++++++++++++++++++++++++++++++
gtk/gtkinvertiblesorter.h | 56 +++++++++
gtk/gtksorter.c | 97 +---------------
gtk/gtksorter.h | 7 --
gtk/meson.build | 2 +
tests/testlistview-animating.c | 9 +-
10 files changed, 334 insertions(+), 119 deletions(-)
---
diff --git a/gtk/gtk.h b/gtk/gtk.h
index 1e7652d612..0d97331c50 100644
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
@@ -155,6 +155,7 @@
#include <gtk/gtkimcontextsimple.h>
#include <gtk/gtkimmulticontext.h>
#include <gtk/gtkinfobar.h>
+#include <gtk/gtkinvertiblesorter.h>
#include <gtk/gtklabel.h>
#include <gtk/gtklayoutmanager.h>
#include <gtk/gtklayoutchild.h>
diff --git a/gtk/gtkcolumnviewcolumn.c b/gtk/gtkcolumnviewcolumn.c
index 7cfbb1a5ce..8f90f0b1f1 100644
--- a/gtk/gtkcolumnviewcolumn.c
+++ b/gtk/gtkcolumnviewcolumn.c
@@ -32,7 +32,7 @@
#include "gtksizegroup.h"
#include "gtkstylecontext.h"
#include "gtkwidgetprivate.h"
-#include "gtksorter.h"
+#include "gtkinvertiblesorter.h"
/**
* SECTION:gtkcolumnviewcolumn
@@ -49,7 +49,7 @@ struct _GtkColumnViewColumn
GtkListItemFactory *factory;
char *title;
- GtkSorter *sorter;
+ GtkInvertibleSorter *sorter;
/* data for the view */
GtkColumnView *view;
@@ -93,6 +93,7 @@ gtk_column_view_column_dispose (GObject *object)
g_assert (self->first_cell == NULL); /* no view = no children */
g_clear_object (&self->factory);
+ g_clear_object (&self->sorter);
g_clear_pointer (&self->title, g_free);
G_OBJECT_CLASS (gtk_column_view_column_parent_class)->dispose (object);
@@ -121,7 +122,7 @@ gtk_column_view_column_get_property (GObject *object,
break;
case PROP_SORTER:
- g_value_set_object (value, self->sorter);
+ g_value_set_object (value, gtk_invertible_sorter_get_sorter (self->sorter));
break;
default:
@@ -218,6 +219,8 @@ gtk_column_view_column_init (GtkColumnViewColumn *self)
{
self->minimum_size_request = -1;
self->natural_size_request = -1;
+
+ self->sorter = GTK_INVERTIBLE_SORTER (gtk_invertible_sorter_new (NULL));
}
/**
@@ -577,9 +580,11 @@ gtk_column_view_column_set_sorter (GtkColumnViewColumn *self,
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
g_return_if_fail (sorter == NULL || GTK_IS_SORTER (sorter));
- if (!g_set_object (&self->sorter, sorter))
+ if (gtk_invertible_sorter_get_sorter (self->sorter) == sorter)
return;
+ gtk_invertible_sorter_set_sorter (self->sorter, sorter);
+
if (self->header)
gtk_column_view_title_update (GTK_COLUMN_VIEW_TITLE (self->header));
@@ -591,7 +596,7 @@ gtk_column_view_column_get_sorter (GtkColumnViewColumn *self)
{
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), NULL);
- return self->sorter;
+ return gtk_invertible_sorter_get_sorter (self->sorter);
}
void
@@ -600,3 +605,9 @@ gtk_column_view_column_active_sorter_changed (GtkColumnViewColumn *self)
if (self->header)
gtk_column_view_title_update (GTK_COLUMN_VIEW_TITLE (self->header));
}
+
+GtkInvertibleSorter *
+gtk_column_view_column_get_invertible_sorter (GtkColumnViewColumn *self)
+{
+ return self->sorter;
+}
diff --git a/gtk/gtkcolumnviewcolumnprivate.h b/gtk/gtkcolumnviewcolumnprivate.h
index 3df2958c07..203acbc7dd 100644
--- a/gtk/gtkcolumnviewcolumnprivate.h
+++ b/gtk/gtkcolumnviewcolumnprivate.h
@@ -23,6 +23,7 @@
#include "gtk/gtkcolumnviewcolumn.h"
#include "gtk/gtkcolumnviewcellprivate.h"
+#include "gtk/gtkinvertiblesorter.h"
void gtk_column_view_column_set_column_view (GtkColumnViewColumn *self,
GtkColumnView *view);
@@ -44,5 +45,6 @@ void gtk_column_view_column_get_allocation (GtkColu
int *offset,
int *size);
void gtk_column_view_column_active_sorter_changed (GtkColumnViewColumn *self);
+GtkInvertibleSorter * gtk_column_view_column_get_invertible_sorter (GtkColumnViewColumn *Self);
#endif /* __GTK_COLUMN_VIEW_COLUMN_PRIVATE_H__ */
diff --git a/gtk/gtkcolumnviewtitle.c b/gtk/gtkcolumnviewtitle.c
index 69063f9be0..8b780e359b 100644
--- a/gtk/gtkcolumnviewtitle.c
+++ b/gtk/gtkcolumnviewtitle.c
@@ -117,22 +117,22 @@ click_pressed_cb (GtkGestureClick *gesture,
GtkWidget *widget)
{
GtkColumnViewTitle *self = GTK_COLUMN_VIEW_TITLE (widget);
- GtkSorter *sorter;
+ GtkInvertibleSorter *sorter;
GtkSorter *active_sorter;
- sorter = gtk_column_view_column_get_sorter (self->column);
+ sorter = gtk_column_view_column_get_invertible_sorter (self->column);
active_sorter = gtk_column_view_get_sorter (gtk_column_view_column_get_column_view (self->column));
if (sorter)
{
- if (sorter == active_sorter)
+ if (GTK_SORTER (sorter) == active_sorter)
{
- gtk_sorter_set_sort_direction (sorter, 1 - gtk_sorter_get_sort_direction (sorter));
+ gtk_invertible_sorter_set_direction (sorter, 1 - gtk_invertible_sorter_get_direction (sorter));
}
else
{
- gtk_sorter_set_sort_direction (sorter, GTK_SORT_ASCENDING);
- gtk_column_view_set_sorter (gtk_column_view_column_get_column_view (self->column), sorter);
+ gtk_invertible_sorter_set_direction (sorter, GTK_SORT_ASCENDING);
+ gtk_column_view_set_sorter (gtk_column_view_column_get_column_view (self->column), GTK_SORTER
(sorter));
}
}
@@ -177,20 +177,20 @@ gtk_column_view_title_new (GtkColumnViewColumn *column)
void
gtk_column_view_title_update (GtkColumnViewTitle *self)
{
- GtkSorter *sorter;
+ GtkInvertibleSorter *sorter;
GtkSorter *active_sorter;
gtk_label_set_label (GTK_LABEL (self->title), gtk_column_view_column_get_title (self->column));
- sorter = gtk_column_view_column_get_sorter (self->column);
+ sorter = gtk_column_view_column_get_invertible_sorter (self->column);
active_sorter = gtk_column_view_get_sorter (gtk_column_view_column_get_column_view (self->column));
if (sorter)
{
gtk_widget_show (self->sort);
- if (sorter == active_sorter)
+ if (GTK_SORTER (sorter) == active_sorter)
{
- if (gtk_sorter_get_sort_direction (sorter) == GTK_SORT_ASCENDING)
+ if (gtk_invertible_sorter_get_direction (sorter) == GTK_SORT_ASCENDING)
gtk_image_set_from_icon_name (GTK_IMAGE (self->sort), "pan-down-symbolic");
else
gtk_image_set_from_icon_name (GTK_IMAGE (self->sort), "pan-up-symbolic");
diff --git a/gtk/gtkinvertiblesorter.c b/gtk/gtkinvertiblesorter.c
new file mode 100644
index 0000000000..9231a83bf8
--- /dev/null
+++ b/gtk/gtkinvertiblesorter.c
@@ -0,0 +1,238 @@
+/*
+ * Copyright © 2019 Matthias Clasen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Matthias Clasen <mclasen redhat com>
+ */
+
+#include "config.h"
+
+#include "gtkinvertiblesorter.h"
+
+#include "gtkintl.h"
+#include "gtktypebuiltins.h"
+
+struct _GtkInvertibleSorter
+{
+ GtkSorter parent_instance;
+
+ GtkSortType direction;
+
+ GtkSorter *sorter;
+};
+
+enum {
+ PROP_0,
+ PROP_SORTER,
+ PROP_DIRECTION,
+ NUM_PROPERTIES
+};
+
+G_DEFINE_TYPE (GtkInvertibleSorter, gtk_invertible_sorter, GTK_TYPE_SORTER)
+
+static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
+
+static int
+gtk_invertible_sorter_compare (GtkSorter *sorter,
+ gpointer item1,
+ gpointer item2)
+{
+ GtkInvertibleSorter *self = GTK_INVERTIBLE_SORTER (sorter);
+ int result;
+
+ if (self->sorter == NULL)
+ return 0;
+
+ result = gtk_sorter_compare (self->sorter, item1, item2);
+
+ if (self->direction == GTK_SORT_ASCENDING)
+ return result;
+ else
+ return - result;
+}
+
+static void
+gtk_invertible_sorter_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkInvertibleSorter *self = GTK_INVERTIBLE_SORTER (object);
+
+ switch (prop_id)
+ {
+ case PROP_SORTER:
+ gtk_invertible_sorter_set_sorter (self, g_value_get_object (value));
+ break;
+
+ case PROP_DIRECTION:
+ gtk_invertible_sorter_set_direction (self, g_value_get_enum (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_invertible_sorter_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkInvertibleSorter *self = GTK_INVERTIBLE_SORTER (object);
+
+ switch (prop_id)
+ {
+ case PROP_SORTER:
+ g_value_set_object (value, self->sorter);
+ break;
+
+ case PROP_DIRECTION:
+ g_value_set_enum (value, self->direction);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void changed_cb (GtkSorter *sorter, int change, gpointer data);
+
+static void
+gtk_invertible_sorter_dispose (GObject *object)
+{
+ GtkInvertibleSorter *self = GTK_INVERTIBLE_SORTER (object);
+
+ if (self->sorter)
+ g_signal_handlers_disconnect_by_func (self->sorter, changed_cb, self);
+ g_clear_object (&self->sorter);
+
+ G_OBJECT_CLASS (gtk_invertible_sorter_parent_class)->dispose (object);
+}
+
+static void
+gtk_invertible_sorter_class_init (GtkInvertibleSorterClass *class)
+{
+ GtkSorterClass *sorter_class = GTK_SORTER_CLASS (class);
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ sorter_class->compare = gtk_invertible_sorter_compare;
+
+ object_class->get_property = gtk_invertible_sorter_get_property;
+ object_class->set_property = gtk_invertible_sorter_set_property;
+ object_class->dispose = gtk_invertible_sorter_dispose;
+
+ /**
+ * GtkInvertibleSorter:sorter:
+ *
+ * The underlying sorter
+ */
+ properties[PROP_SORTER] =
+ g_param_spec_object ("sorter",
+ P_("Sorter"),
+ P_("The underlying sorter"),
+ GTK_TYPE_SORTER,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
+ /**
+ * GtkInvertibleSorter:direction:
+ *
+ * The direction to sort in
+ */
+ properties[PROP_DIRECTION] =
+ g_param_spec_enum ("direction",
+ P_("Direction"),
+ P_("The direction to sort in"),
+ GTK_TYPE_SORT_TYPE,
+ GTK_SORT_ASCENDING,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
+ g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
+}
+
+static void
+gtk_invertible_sorter_init (GtkInvertibleSorter *self)
+{
+ self->direction = GTK_SORT_ASCENDING;
+}
+
+GtkSorter *
+gtk_invertible_sorter_new (GtkSorter *sorter)
+{
+ return g_object_new (GTK_TYPE_INVERTIBLE_SORTER,
+ "sorter", sorter,
+ NULL);
+}
+
+GtkSorter *
+gtk_invertible_sorter_get_sorter (GtkInvertibleSorter *self)
+{
+ g_return_val_if_fail (GTK_IS_INVERTIBLE_SORTER (self), NULL);
+
+ return self->sorter;
+}
+
+static void
+changed_cb (GtkSorter *sorter, int change, gpointer data)
+{
+ gtk_sorter_changed (GTK_SORTER (data), change);
+}
+
+void
+gtk_invertible_sorter_set_sorter (GtkInvertibleSorter *self,
+ GtkSorter *sorter)
+{
+ g_return_if_fail (GTK_IS_INVERTIBLE_SORTER (self));
+ g_return_if_fail (sorter == NULL || GTK_IS_SORTER (sorter));
+
+ if (self->sorter == sorter)
+ return;
+
+ g_signal_handlers_disconnect_by_func (self->sorter, changed_cb, self);
+ g_set_object (&self->sorter, sorter);
+ if (self->sorter)
+ g_signal_connect (self->sorter, "changed", G_CALLBACK (changed_cb), self);
+
+ gtk_sorter_changed (GTK_SORTER (self), GTK_SORTER_CHANGE_DIFFERENT);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SORTER]);
+}
+
+GtkSortType
+gtk_invertible_sorter_get_direction (GtkInvertibleSorter *self)
+{
+ g_return_val_if_fail (GTK_IS_INVERTIBLE_SORTER (self), GTK_SORT_ASCENDING);
+
+ return self->direction;
+}
+
+void
+gtk_invertible_sorter_set_direction (GtkInvertibleSorter *self,
+ GtkSortType direction)
+{
+ g_return_if_fail (GTK_IS_INVERTIBLE_SORTER (self));
+
+ if (self->direction == direction)
+ return;
+
+ self->direction = direction;
+
+ gtk_sorter_changed (GTK_SORTER (self), GTK_SORTER_CHANGE_INVERTED);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DIRECTION]);
+}
diff --git a/gtk/gtkinvertiblesorter.h b/gtk/gtkinvertiblesorter.h
new file mode 100644
index 0000000000..691b32ab78
--- /dev/null
+++ b/gtk/gtkinvertiblesorter.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2019 Matthias Clasen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Matthias Clasen <mclasen redhat com>
+ */
+
+#ifndef __GTK_INVERTIBLE_SORTER_H__
+#define __GTK_INVERTIBLE_SORTER_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gdk/gdk.h>
+#include <gtk/gtksorter.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_INVERTIBLE_SORTER (gtk_invertible_sorter_get_type ())
+
+GDK_AVAILABLE_IN_ALL
+G_DECLARE_FINAL_TYPE (GtkInvertibleSorter, gtk_invertible_sorter, GTK, INVERTIBLE_SORTER, GtkSorter)
+
+GDK_AVAILABLE_IN_ALL
+GtkSorter * gtk_invertible_sorter_new (GtkSorter *sorter);
+
+GDK_AVAILABLE_IN_ALL
+void gtk_invertible_sorter_set_sorter (GtkInvertibleSorter *self,
+ GtkSorter *sorter);
+GDK_AVAILABLE_IN_ALL
+GtkSorter * gtk_invertible_sorter_get_sorter (GtkInvertibleSorter *self);
+
+GDK_AVAILABLE_IN_ALL
+void gtk_invertible_sorter_set_direction (GtkInvertibleSorter *self,
+ GtkSortType direction);
+
+GDK_AVAILABLE_IN_ALL
+GtkSortType gtk_invertible_sorter_get_direction (GtkInvertibleSorter *self);
+
+G_END_DECLS
+
+#endif /* __GTK_SORTER_H__ */
+
diff --git a/gtk/gtksorter.c b/gtk/gtksorter.c
index 563620e62d..865f523e28 100644
--- a/gtk/gtksorter.c
+++ b/gtk/gtksorter.c
@@ -35,15 +35,9 @@ enum {
LAST_SIGNAL
};
-enum {
- PROP_SORT_DIRECTION = 1,
- NUM_PROPERTIES
-};
-
G_DEFINE_TYPE_WITH_PRIVATE (GtkSorter, gtk_sorter, G_TYPE_OBJECT)
static guint signals[LAST_SIGNAL] = { 0 };
-static GParamSpec *props[NUM_PROPERTIES];
static int
gtk_sorter_default_compare (GtkSorter *self,
@@ -55,65 +49,11 @@ gtk_sorter_default_compare (GtkSorter *self,
return 0;
}
-static void
-gtk_sorter_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GtkSorter *sorter = GTK_SORTER (object);
-
- switch (prop_id)
- {
- case PROP_SORT_DIRECTION:
- gtk_sorter_set_sort_direction (sorter, g_value_get_enum (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gtk_sorter_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GtkSorter *sorter = GTK_SORTER (object);
-
- switch (prop_id)
- {
- case PROP_SORT_DIRECTION:
- g_value_set_enum (value, gtk_sorter_get_sort_direction (sorter));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
static void
gtk_sorter_class_init (GtkSorterClass *class)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
-
- gobject_class->set_property = gtk_sorter_set_property;
- gobject_class->get_property = gtk_sorter_get_property;
-
class->compare = gtk_sorter_default_compare;
- props[PROP_SORT_DIRECTION] =
- g_param_spec_enum ("sort-direction",
- P_("Sort direction"),
- P_("Whether to sort ascending or descending"),
- GTK_TYPE_SORT_TYPE,
- GTK_SORT_ASCENDING,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
-
- g_object_class_install_properties (gobject_class, NUM_PROPERTIES, props);
-
/**
* GtkSearch:changed:
* @self: The #GtkSorter
@@ -123,7 +63,7 @@ gtk_sorter_class_init (GtkSorterClass *class)
*/
signals[CHANGED] =
g_signal_new (I_("changed"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
@@ -131,7 +71,7 @@ gtk_sorter_class_init (GtkSorterClass *class)
G_TYPE_NONE, 1,
GTK_TYPE_SORTER_CHANGE);
g_signal_set_va_marshaller (signals[CHANGED],
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (class),
g_cclosure_marshal_VOID__VOIDv);
}
@@ -150,38 +90,7 @@ gtk_sorter_compare (GtkSorter *self,
g_return_val_if_fail (GTK_IS_SORTER (self), 0);
g_return_val_if_fail (item1 && item2, 0);
- if (priv->sort_direction == GTK_SORT_ASCENDING)
- return GTK_SORTER_GET_CLASS (self)->compare (self, item1, item2);
- else
- return - GTK_SORTER_GET_CLASS (self)->compare (self, item1, item2);
-}
-
-void
-gtk_sorter_set_sort_direction (GtkSorter *self,
- GtkSortType direction)
-{
- GtkSorterPrivate *priv = gtk_sorter_get_instance_private (self);
-
- g_return_if_fail (GTK_IS_SORTER (self));
-
- if (priv->sort_direction == direction)
- return;
-
- priv->sort_direction = direction;
-
- g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SORT_DIRECTION]);
-
- gtk_sorter_changed (self, GTK_SORTER_CHANGE_INVERTED);
-}
-
-GtkSortType
-gtk_sorter_get_sort_direction (GtkSorter *self)
-{
- GtkSorterPrivate *priv = gtk_sorter_get_instance_private (self);
-
- g_return_val_if_fail (GTK_IS_SORTER (self), GTK_SORT_ASCENDING);
-
- return priv->sort_direction;
+ return GTK_SORTER_GET_CLASS (self)->compare (self, item1, item2);
}
void
diff --git a/gtk/gtksorter.h b/gtk/gtksorter.h
index ef43951fcd..62225e2430 100644
--- a/gtk/gtksorter.h
+++ b/gtk/gtksorter.h
@@ -78,13 +78,6 @@ int gtk_sorter_compare (GtkSorter *self,
gpointer item1,
gpointer item2);
-GDK_AVAILABLE_IN_ALL
-void gtk_sorter_set_sort_direction (GtkSorter *self,
- GtkSortType direction);
-
-GDK_AVAILABLE_IN_ALL
-GtkSortType gtk_sorter_get_sort_direction (GtkSorter *self);
-
GDK_AVAILABLE_IN_ALL
void gtk_sorter_changed (GtkSorter *self,
GtkSorterChange change);
diff --git a/gtk/meson.build b/gtk/meson.build
index b42bce8aac..98b304bc0c 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -121,6 +121,7 @@ gtk_private_sources = files([
'gtkiconcache.c',
'tools/gtkiconcachevalidator.c',
'gtkiconhelper.c',
+ 'gtkinvertiblesorter.c',
'gtkkineticscrolling.c',
'gtkkeyhash.c',
'gtkmagnifier.c',
@@ -572,6 +573,7 @@ gtk_public_headers = files([
'gtkimmodule.h',
'gtkimmulticontext.h',
'gtkinfobar.h',
+ 'gtkinvertiblesorter.h',
'gtklabel.h',
'gtklayoutchild.h',
'gtklayoutmanager.h',
diff --git a/tests/testlistview-animating.c b/tests/testlistview-animating.c
index a8077dff11..aa229dd5a8 100644
--- a/tests/testlistview-animating.c
+++ b/tests/testlistview-animating.c
@@ -112,7 +112,7 @@ revert_sort (gpointer sorter)
{
reverse_sort = !reverse_sort;
- gtk_sorter_set_sort_direction (GTK_SORTER (sorter), reverse_sort ? GTK_SORT_ASCENDING :
GTK_SORT_DESCENDING);
+ gtk_invertible_sorter_set_direction (GTK_INVERTIBLE_SORTER (sorter), reverse_sort ? GTK_SORT_ASCENDING :
GTK_SORT_DESCENDING);
return G_SOURCE_CONTINUE;
}
@@ -126,6 +126,7 @@ main (int argc,
GtkSortListModel *sort;
guint i;
GtkSorter *sorter;
+ GtkSorter *sorter2;
gtk_init ();
@@ -133,7 +134,8 @@ main (int argc,
for (i = 0; i < AVERAGE; i++)
add (store);
sorter = gtk_custom_sorter_new (compare, NULL, NULL);
- sort = gtk_sort_list_model_new (G_LIST_MODEL (store), sorter);
+ sorter2 = gtk_invertible_sorter_new (sorter);
+ sort = gtk_sort_list_model_new (G_LIST_MODEL (store), sorter2);
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (win), 400, 600);
@@ -180,7 +182,7 @@ main (int argc,
NULL, NULL);
g_timeout_add (100, do_stuff, store);
- g_timeout_add_seconds (3, revert_sort, sorter);
+ g_timeout_add_seconds (3, revert_sort, sorter2);
gtk_widget_show (win);
@@ -188,6 +190,7 @@ main (int argc,
g_object_unref (store);
g_object_unref (sorter);
+ g_object_unref (sorter2);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]