2019-12-03 04:43:14 +00:00
|
|
|
/*
|
|
|
|
* 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_SORTER_H__
|
|
|
|
#define __GTK_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/gtkenums.h>
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkSorterOrder:
|
2021-05-20 13:17:04 +00:00
|
|
|
* @GTK_SORTER_ORDER_PARTIAL: A partial order. Any `GtkOrdering` is possible.
|
2019-12-03 04:43:14 +00:00
|
|
|
* @GTK_SORTER_ORDER_NONE: No order, all elements are considered equal.
|
2021-05-18 21:05:26 +00:00
|
|
|
* gtk_sorter_compare() will only return %GTK_ORDERING_EQUAL.
|
2019-12-03 04:43:14 +00:00
|
|
|
* @GTK_SORTER_ORDER_TOTAL: A total order. gtk_sorter_compare() will only
|
2021-05-18 21:05:26 +00:00
|
|
|
* return %GTK_ORDERING_EQUAL if an item is compared with itself. Two
|
|
|
|
* different items will never cause this value to be returned.
|
2019-12-03 04:43:14 +00:00
|
|
|
*
|
2021-02-28 18:10:56 +00:00
|
|
|
* Describes the type of order that a `GtkSorter` may produce.
|
2019-12-03 04:43:14 +00:00
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
GTK_SORTER_ORDER_PARTIAL,
|
|
|
|
GTK_SORTER_ORDER_NONE,
|
|
|
|
GTK_SORTER_ORDER_TOTAL
|
|
|
|
} GtkSorterOrder;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkSorterChange:
|
|
|
|
* @GTK_SORTER_CHANGE_DIFFERENT: The sorter change cannot be described
|
2021-05-18 21:05:26 +00:00
|
|
|
* by any of the other enumeration values
|
2019-12-03 04:43:14 +00:00
|
|
|
* @GTK_SORTER_CHANGE_INVERTED: The sort order was inverted. Comparisons
|
2021-05-18 21:05:26 +00:00
|
|
|
* that returned %GTK_ORDERING_SMALLER now return %GTK_ORDERING_LARGER
|
|
|
|
* and vice versa. Other comparisons return the same values as before.
|
2019-12-03 04:43:14 +00:00
|
|
|
* @GTK_SORTER_CHANGE_LESS_STRICT: The sorter is less strict: Comparisons
|
2021-05-18 21:05:26 +00:00
|
|
|
* may now return %GTK_ORDERING_EQUAL that did not do so before.
|
2019-12-03 04:43:14 +00:00
|
|
|
* @GTK_SORTER_CHANGE_MORE_STRICT: The sorter is more strict: Comparisons
|
2021-05-18 21:05:26 +00:00
|
|
|
* that did return %GTK_ORDERING_EQUAL may not do so anymore.
|
2019-12-03 04:43:14 +00:00
|
|
|
*
|
|
|
|
* Describes changes in a sorter in more detail and allows users
|
|
|
|
* to optimize resorting.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
GTK_SORTER_CHANGE_DIFFERENT,
|
|
|
|
GTK_SORTER_CHANGE_INVERTED,
|
|
|
|
GTK_SORTER_CHANGE_LESS_STRICT,
|
|
|
|
GTK_SORTER_CHANGE_MORE_STRICT
|
|
|
|
} GtkSorterChange;
|
|
|
|
|
|
|
|
#define GTK_TYPE_SORTER (gtk_sorter_get_type ())
|
|
|
|
|
|
|
|
GDK_AVAILABLE_IN_ALL
|
|
|
|
G_DECLARE_DERIVABLE_TYPE (GtkSorter, gtk_sorter, GTK, SORTER, GObject)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkSorterClass
|
|
|
|
* @compare: Compare two items. See gtk_sorter_compare() for details.
|
2021-05-20 13:17:04 +00:00
|
|
|
* @get_order: Get the `GtkSorderOrder` that applies to the current sorter.
|
2021-05-18 21:05:26 +00:00
|
|
|
* If unimplemented, it returns %GTK_SORTER_ORDER_PARTIAL.
|
2019-12-03 04:43:14 +00:00
|
|
|
*
|
2021-02-28 18:10:56 +00:00
|
|
|
* The virtual table for `GtkSorter`.
|
2019-12-03 04:43:14 +00:00
|
|
|
*/
|
|
|
|
struct _GtkSorterClass
|
|
|
|
{
|
|
|
|
GObjectClass parent_class;
|
|
|
|
|
|
|
|
GtkOrdering (* compare) (GtkSorter *self,
|
|
|
|
gpointer item1,
|
|
|
|
gpointer item2);
|
|
|
|
|
|
|
|
/* optional */
|
|
|
|
GtkSorterOrder (* get_order) (GtkSorter *self);
|
|
|
|
|
|
|
|
/* Padding for future expansion */
|
|
|
|
void (*_gtk_reserved1) (void);
|
|
|
|
void (*_gtk_reserved2) (void);
|
|
|
|
void (*_gtk_reserved3) (void);
|
|
|
|
void (*_gtk_reserved4) (void);
|
|
|
|
void (*_gtk_reserved5) (void);
|
|
|
|
void (*_gtk_reserved6) (void);
|
|
|
|
void (*_gtk_reserved7) (void);
|
|
|
|
void (*_gtk_reserved8) (void);
|
|
|
|
};
|
|
|
|
|
|
|
|
GDK_AVAILABLE_IN_ALL
|
|
|
|
GtkOrdering gtk_sorter_compare (GtkSorter *self,
|
|
|
|
gpointer item1,
|
|
|
|
gpointer item2);
|
|
|
|
GDK_AVAILABLE_IN_ALL
|
|
|
|
GtkSorterOrder gtk_sorter_get_order (GtkSorter *self);
|
|
|
|
|
|
|
|
/* for sorter implementations */
|
|
|
|
GDK_AVAILABLE_IN_ALL
|
|
|
|
void gtk_sorter_changed (GtkSorter *self,
|
|
|
|
GtkSorterChange change);
|
|
|
|
|
2020-07-15 18:17:55 +00:00
|
|
|
|
2019-12-03 04:43:14 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GTK_SORTER_H__ */
|
|
|
|
|