forked from AuroraMiddleware/gtk
Make sorter constructors return exact types
Make functions like gtk_custom_sorter_new() return the actual type they construct. Update all callers.
This commit is contained in:
parent
dfabe74c59
commit
24389a0ef5
@ -1022,31 +1022,31 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
/* An empty multisorter doesn't do any sorting and the sortmodel is
|
||||
* smart enough to know that.
|
||||
*/
|
||||
sorter = gtk_multi_sorter_new ();
|
||||
sorter = GTK_SORTER (gtk_multi_sorter_new ());
|
||||
set_title (sorter, "Unsorted");
|
||||
g_list_store_append (sorters, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
sorter = gtk_string_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "name"));
|
||||
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "name")));
|
||||
set_title (sorter, "Name");
|
||||
g_list_store_append (sorters, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
multi_sorter = gtk_multi_sorter_new ();
|
||||
multi_sorter = GTK_SORTER (gtk_multi_sorter_new ());
|
||||
|
||||
sorter = gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "red"));
|
||||
sorter = GTK_SORTER (gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "red")));
|
||||
gtk_numeric_sorter_set_sort_order (GTK_NUMERIC_SORTER (sorter), GTK_SORT_DESCENDING);
|
||||
set_title (sorter, "Red");
|
||||
g_list_store_append (sorters, sorter);
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi_sorter), sorter);
|
||||
|
||||
sorter = gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "green"));
|
||||
sorter = GTK_SORTER (gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "green")));
|
||||
gtk_numeric_sorter_set_sort_order (GTK_NUMERIC_SORTER (sorter), GTK_SORT_DESCENDING);
|
||||
set_title (sorter, "Green");
|
||||
g_list_store_append (sorters, sorter);
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi_sorter), sorter);
|
||||
|
||||
sorter = gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "blue"));
|
||||
sorter = GTK_SORTER (gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "blue")));
|
||||
gtk_numeric_sorter_set_sort_order (GTK_NUMERIC_SORTER (sorter), GTK_SORT_DESCENDING);
|
||||
set_title (sorter, "Blue");
|
||||
g_list_store_append (sorters, sorter);
|
||||
@ -1056,21 +1056,21 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
g_list_store_append (sorters, multi_sorter);
|
||||
g_object_unref (multi_sorter);
|
||||
|
||||
multi_sorter = gtk_multi_sorter_new ();
|
||||
multi_sorter = GTK_SORTER (gtk_multi_sorter_new ());
|
||||
|
||||
sorter = gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "hue"));
|
||||
sorter = GTK_SORTER (gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "hue")));
|
||||
gtk_numeric_sorter_set_sort_order (GTK_NUMERIC_SORTER (sorter), GTK_SORT_DESCENDING);
|
||||
set_title (sorter, "Hue");
|
||||
g_list_store_append (sorters, sorter);
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi_sorter), sorter);
|
||||
|
||||
sorter = gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "saturation"));
|
||||
sorter = GTK_SORTER (gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "saturation")));
|
||||
gtk_numeric_sorter_set_sort_order (GTK_NUMERIC_SORTER (sorter), GTK_SORT_DESCENDING);
|
||||
set_title (sorter, "Saturation");
|
||||
g_list_store_append (sorters, sorter);
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi_sorter), sorter);
|
||||
|
||||
sorter = gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "value"));
|
||||
sorter = GTK_SORTER (gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "value")));
|
||||
gtk_numeric_sorter_set_sort_order (GTK_NUMERIC_SORTER (sorter), GTK_SORT_DESCENDING);
|
||||
set_title (sorter, "Value");
|
||||
g_list_store_append (sorters, sorter);
|
||||
|
@ -1163,7 +1163,7 @@ gtk_column_view_init (GtkColumnView *self)
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (gtk_column_view_drag_leave), NULL);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||
|
||||
self->sorter = gtk_column_view_sorter_new ();
|
||||
self->sorter = GTK_SORTER (gtk_column_view_sorter_new ());
|
||||
self->factory = gtk_column_list_item_factory_new (self);
|
||||
self->listview = GTK_LIST_VIEW (gtk_list_view_new (NULL,
|
||||
GTK_LIST_ITEM_FACTORY (g_object_ref (self->factory))));
|
||||
|
@ -146,7 +146,7 @@ gtk_column_view_sorter_init (GtkColumnViewSorter *self)
|
||||
self->sorters = g_sequence_new (free_sorter);
|
||||
}
|
||||
|
||||
GtkSorter *
|
||||
GtkColumnViewSorter *
|
||||
gtk_column_view_sorter_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_COLUMN_VIEW_SORTER, NULL);
|
||||
|
@ -34,7 +34,7 @@ G_BEGIN_DECLS
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GtkColumnViewSorter, gtk_column_view_sorter, GTK, COLUMN_VIEW_SORTER, GtkSorter)
|
||||
|
||||
GtkSorter * gtk_column_view_sorter_new (void);
|
||||
GtkColumnViewSorter * gtk_column_view_sorter_new (void);
|
||||
|
||||
gboolean gtk_column_view_sorter_add_column (GtkColumnViewSorter *self,
|
||||
GtkColumnViewColumn *column);
|
||||
|
@ -110,9 +110,9 @@ gtk_custom_sorter_init (GtkCustomSorter *self)
|
||||
*
|
||||
* If @sort_func is %NULL, all items are considered equal.
|
||||
*
|
||||
* Returns: a new #GtkSorter
|
||||
* Returns: a new #GtkCustomSorter
|
||||
*/
|
||||
GtkSorter *
|
||||
GtkCustomSorter *
|
||||
gtk_custom_sorter_new (GCompareDataFunc sort_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy)
|
||||
@ -123,7 +123,7 @@ gtk_custom_sorter_new (GCompareDataFunc sort_func,
|
||||
|
||||
gtk_custom_sorter_set_sort_func (sorter, sort_func, user_data, user_destroy);
|
||||
|
||||
return GTK_SORTER (sorter);
|
||||
return sorter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkCustomSorter, gtk_custom_sorter, GTK, CUSTOM_SORTER, GtkSorter)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkSorter * gtk_custom_sorter_new (GCompareDataFunc sort_func,
|
||||
GtkCustomSorter * gtk_custom_sorter_new (GCompareDataFunc sort_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy);
|
||||
|
||||
|
@ -375,9 +375,9 @@ gtk_multi_sorter_init (GtkMultiSorter *self)
|
||||
* no sorter has been added to it, it will always compare
|
||||
* items as equal.
|
||||
*
|
||||
* Returns: a new #GtkSorter
|
||||
* Returns: a new #GtkMultiSorter
|
||||
*/
|
||||
GtkSorter *
|
||||
GtkMultiSorter *
|
||||
gtk_multi_sorter_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_MULTI_SORTER, NULL);
|
||||
|
@ -34,7 +34,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkMultiSorter, gtk_multi_sorter, GTK, MULTI_SORTER, GtkSorter)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkSorter * gtk_multi_sorter_new (void);
|
||||
GtkMultiSorter * gtk_multi_sorter_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_multi_sorter_append (GtkMultiSorter *self,
|
||||
|
@ -587,12 +587,12 @@ gtk_numeric_sorter_init (GtkNumericSorter *self)
|
||||
* Smaller numbers will be sorted first. You can call
|
||||
* gtk_numeric_sorter_set_sort_order() to change this.
|
||||
*
|
||||
* Returns: a new #GtkSorter
|
||||
* Returns: a new #GtkNumericSorter
|
||||
*/
|
||||
GtkSorter *
|
||||
GtkNumericSorter *
|
||||
gtk_numeric_sorter_new (GtkExpression *expression)
|
||||
{
|
||||
GtkSorter *result;
|
||||
GtkNumericSorter *result;
|
||||
|
||||
result = g_object_new (GTK_TYPE_NUMERIC_SORTER,
|
||||
"expression", expression,
|
||||
|
@ -34,7 +34,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkNumericSorter, gtk_numeric_sorter, GTK, NUMERIC_SORTER, GtkSorter)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkSorter * gtk_numeric_sorter_new (GtkExpression *expression);
|
||||
GtkNumericSorter * gtk_numeric_sorter_new (GtkExpression *expression);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkExpression * gtk_numeric_sorter_get_expression (GtkNumericSorter *self);
|
||||
|
@ -811,7 +811,7 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
||||
|
||||
/* Load backends */
|
||||
model = load_print_backends (dialog);
|
||||
sorter = gtk_custom_sorter_new (default_printer_list_sort_func, NULL, NULL);
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (default_printer_list_sort_func, NULL, NULL));
|
||||
sorted = G_LIST_MODEL (gtk_sort_list_model_new (model, sorter));
|
||||
|
||||
filter = GTK_FILTER (gtk_every_filter_new ());
|
||||
|
@ -333,12 +333,12 @@ gtk_string_sorter_init (GtkStringSorter *self)
|
||||
* Unless an expression is set on it, this sorter will always
|
||||
* compare items as invalid.
|
||||
*
|
||||
* Returns: a new #GtkSorter
|
||||
* Returns: a new #GtkStringSorter
|
||||
*/
|
||||
GtkSorter *
|
||||
GtkStringSorter *
|
||||
gtk_string_sorter_new (GtkExpression *expression)
|
||||
{
|
||||
GtkSorter *result;
|
||||
GtkStringSorter *result;
|
||||
|
||||
result = g_object_new (GTK_TYPE_STRING_SORTER,
|
||||
"expression", expression,
|
||||
|
@ -34,7 +34,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkStringSorter, gtk_string_sorter, GTK, STRING_SORTER, GtkSorter)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkSorter * gtk_string_sorter_new (GtkExpression *expression);
|
||||
GtkStringSorter * gtk_string_sorter_new (GtkExpression *expression);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkExpression * gtk_string_sorter_get_expression (GtkStringSorter *self);
|
||||
|
@ -567,12 +567,12 @@ gtk_tree_list_row_sorter_init (GtkTreeListRowSorter *self)
|
||||
* Note that this sorter relies on #GtkTreeListModel:passthrough
|
||||
* being %FALSE as it can only sort #GtkTreeListRows.
|
||||
*
|
||||
* Returns: a new #GtkSorter
|
||||
* Returns: a new #GtkTreeListRowSorter
|
||||
*/
|
||||
GtkSorter *
|
||||
GtkTreeListRowSorter *
|
||||
gtk_tree_list_row_sorter_new (GtkSorter *sorter)
|
||||
{
|
||||
GtkSorter *result;
|
||||
GtkTreeListRowSorter *result;
|
||||
|
||||
g_return_val_if_fail (sorter == NULL || GTK_IS_SORTER (sorter), NULL);
|
||||
|
||||
|
@ -34,7 +34,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkTreeListRowSorter, gtk_tree_list_row_sorter, GTK, TREE_LIST_ROW_SORTER, GtkSorter)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkSorter * gtk_tree_list_row_sorter_new (GtkSorter *sorter);
|
||||
GtkTreeListRowSorter * gtk_tree_list_row_sorter_new (GtkSorter *sorter);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkSorter * gtk_tree_list_row_sorter_get_sorter (GtkTreeListRowSorter *self);
|
||||
|
@ -389,11 +389,11 @@ constructed (GObject *object)
|
||||
g_signal_connect_swapped (sl->button, "clicked",
|
||||
G_CALLBACK (refresh_all), sl);
|
||||
|
||||
sorter = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING,
|
||||
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING,
|
||||
NULL,
|
||||
0, NULL,
|
||||
(GCallback)holder_name,
|
||||
NULL, NULL));
|
||||
NULL, NULL)));
|
||||
gtk_column_view_column_set_sorter (sl->name, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
|
@ -246,7 +246,7 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *self,
|
||||
|
||||
flatten_model = gtk_flatten_list_model_new (G_LIST_MODEL (map_model));
|
||||
|
||||
sorter = gtk_custom_sorter_new (compare_controllers, NULL, NULL);
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (compare_controllers, NULL, NULL));
|
||||
sort_model = gtk_sort_list_model_new (G_LIST_MODEL (flatten_model), sorter);
|
||||
|
||||
gtk_list_box_bind_model (GTK_LIST_BOX (self->listbox),
|
||||
|
@ -116,10 +116,10 @@ gtk_inspector_prop_list_init (GtkInspectorPropList *pl)
|
||||
pl->priv->filter = gtk_string_filter_new (NULL);
|
||||
gtk_string_filter_set_match_mode (pl->priv->filter, GTK_STRING_FILTER_MATCH_MODE_SUBSTRING);
|
||||
|
||||
sorter = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
0, NULL,
|
||||
(GCallback)holder_prop,
|
||||
NULL, NULL));
|
||||
NULL, NULL)));
|
||||
|
||||
gtk_string_filter_set_expression (pl->priv->filter,
|
||||
gtk_string_sorter_get_expression (GTK_STRING_SORTER (sorter)));
|
||||
@ -127,18 +127,18 @@ gtk_inspector_prop_list_init (GtkInspectorPropList *pl)
|
||||
gtk_column_view_column_set_sorter (pl->priv->name, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
sorter = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
0, NULL,
|
||||
(GCallback)holder_type,
|
||||
NULL, NULL));
|
||||
NULL, NULL)));
|
||||
|
||||
gtk_column_view_column_set_sorter (pl->priv->type, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
sorter = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
0, NULL,
|
||||
(GCallback)holder_origin,
|
||||
NULL, NULL));
|
||||
NULL, NULL)));
|
||||
|
||||
gtk_column_view_column_set_sorter (pl->priv->origin, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
@ -652,26 +652,26 @@ gtk_inspector_resource_list_init (GtkInspectorResourceList *rl)
|
||||
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (rl->search_bar),
|
||||
GTK_EDITABLE (rl->search_entry));
|
||||
|
||||
sorter = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
0, NULL,
|
||||
(GCallback)holder_name,
|
||||
NULL, NULL));
|
||||
NULL, NULL)));
|
||||
|
||||
gtk_column_view_column_set_sorter (rl->path, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
sorter = gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_INT, NULL,
|
||||
sorter = GTK_SORTER (gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_INT, NULL,
|
||||
0, NULL,
|
||||
(GCallback)holder_count,
|
||||
NULL, NULL));
|
||||
NULL, NULL)));
|
||||
|
||||
gtk_column_view_column_set_sorter (rl->count, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
sorter = gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT64, NULL,
|
||||
sorter = GTK_SORTER (gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT64, NULL,
|
||||
0, NULL,
|
||||
(GCallback)holder_size,
|
||||
NULL, NULL));
|
||||
NULL, NULL)));
|
||||
|
||||
gtk_column_view_column_set_sorter (rl->size, sorter);
|
||||
g_object_unref (sorter);
|
||||
@ -709,7 +709,7 @@ constructed (GObject *object)
|
||||
NULL);
|
||||
|
||||
column_sorter = gtk_column_view_get_sorter (GTK_COLUMN_VIEW (rl->list));
|
||||
sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter));
|
||||
sorter = GTK_SORTER (gtk_tree_list_row_sorter_new (g_object_ref (column_sorter)));
|
||||
sort_model = G_LIST_MODEL (gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (rl->tree_model)), sorter));
|
||||
rl->selection = gtk_single_selection_new (sort_model);
|
||||
|
||||
|
@ -665,7 +665,7 @@ add_extra_columns (GtkColumnView *view,
|
||||
column = gtk_column_view_column_new_with_factory (extra_columns[i].title,
|
||||
gtk_builder_list_item_factory_new_from_bytes (scope, bytes));
|
||||
g_bytes_unref (bytes);
|
||||
sorter = gtk_custom_sorter_new (compare_file_attribute, (gpointer) extra_columns[i].attribute, NULL);
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (compare_file_attribute, (gpointer) extra_columns[i].attribute, NULL));
|
||||
gtk_column_view_column_set_sorter (column, sorter);
|
||||
g_object_unref (sorter);
|
||||
gtk_column_view_append_column (view, column);
|
||||
@ -753,7 +753,7 @@ main (int argc, char *argv[])
|
||||
create_list_model_for_file_info,
|
||||
NULL, NULL);
|
||||
|
||||
sorter = gtk_tree_list_row_sorter_new (g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (view))));
|
||||
sorter = GTK_SORTER (gtk_tree_list_row_sorter_new (g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (view)))));
|
||||
sort = gtk_sort_list_model_new (G_LIST_MODEL (tree), sorter);
|
||||
|
||||
custom_filter = GTK_FILTER (gtk_custom_filter_new (match_file, g_object_ref (search_entry), g_object_unref));
|
||||
|
@ -126,7 +126,7 @@ main (int argc,
|
||||
store = g_list_store_new (G_TYPE_OBJECT);
|
||||
for (i = 0; i < AVERAGE; i++)
|
||||
add (store);
|
||||
sorter = gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL));
|
||||
sorter = GTK_SORTER (gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL)));
|
||||
sort = gtk_sort_list_model_new (G_LIST_MODEL (store), sorter);
|
||||
|
||||
win = gtk_window_new ();
|
||||
|
@ -325,7 +325,7 @@ create_list_model_for_directory (gpointer file)
|
||||
return NULL;
|
||||
|
||||
dir = create_directory_list (file);
|
||||
sorter = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, (GCallback) get_file_path, NULL, NULL));
|
||||
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, (GCallback) get_file_path, NULL, NULL)));
|
||||
|
||||
return G_LIST_MODEL (gtk_sort_list_model_new (G_LIST_MODEL (dir), sorter));
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ test_simple (void)
|
||||
model = new_model (20, NULL);
|
||||
assert_not_model (model, "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20");
|
||||
|
||||
sorter = gtk_custom_sorter_new (compare_numbers, NULL, NULL);
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (compare_numbers, NULL, NULL));
|
||||
gtk_sort_list_model_set_sorter (model, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
@ -296,7 +296,7 @@ test_string (void)
|
||||
model = new_model (20, NULL);
|
||||
assert_not_model (model, "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20");
|
||||
|
||||
sorter = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, (GCallback)get_string, NULL, NULL));
|
||||
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, (GCallback)get_string, NULL, NULL)));
|
||||
|
||||
gtk_sort_list_model_set_sorter (model, sorter);
|
||||
g_object_unref (sorter);
|
||||
@ -330,7 +330,7 @@ test_change (void)
|
||||
GtkExpression *expression;
|
||||
int counter = 0;
|
||||
|
||||
sorter = gtk_string_sorter_new (NULL);
|
||||
sorter = GTK_SORTER (gtk_string_sorter_new (NULL));
|
||||
g_signal_connect (sorter, "changed", G_CALLBACK (inc_counter), &counter);
|
||||
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, (GCallback)get_string, NULL, NULL);
|
||||
@ -360,7 +360,7 @@ test_numeric (void)
|
||||
model = new_model (20, NULL);
|
||||
assert_not_model (model, "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20");
|
||||
|
||||
sorter = gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL));
|
||||
sorter = GTK_SORTER (gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL)));
|
||||
gtk_sort_list_model_set_sorter (model, sorter);
|
||||
assert_model (model, "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20");
|
||||
|
||||
@ -409,7 +409,7 @@ test_multi (void)
|
||||
model = new_model (20, NULL);
|
||||
assert_not_model (model, "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20");
|
||||
|
||||
sorter2 = gtk_numeric_sorter_new (NULL);
|
||||
sorter2 = GTK_SORTER (gtk_numeric_sorter_new (NULL));
|
||||
gtk_sort_list_model_set_sorter (model, sorter2);
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL);
|
||||
gtk_numeric_sorter_set_expression (GTK_NUMERIC_SORTER (sorter2), expression);
|
||||
@ -417,10 +417,10 @@ test_multi (void)
|
||||
|
||||
assert_model (model, "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20");
|
||||
|
||||
sorter = gtk_multi_sorter_new ();
|
||||
sorter = GTK_SORTER (gtk_multi_sorter_new ());
|
||||
gtk_sort_list_model_set_sorter (model, sorter);
|
||||
|
||||
sorter1 = gtk_custom_sorter_new (compare_even, NULL, NULL);
|
||||
sorter1 = GTK_SORTER (gtk_custom_sorter_new (compare_even, NULL, NULL));
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (sorter), sorter1);
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (sorter), sorter2);
|
||||
|
||||
@ -446,8 +446,8 @@ test_multi_destruct (void)
|
||||
{
|
||||
GtkSorter *multi, *sorter;
|
||||
|
||||
multi = gtk_multi_sorter_new ();
|
||||
sorter = gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL));
|
||||
multi = GTK_SORTER (gtk_multi_sorter_new ());
|
||||
sorter = GTK_SORTER (gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL)));
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi), g_object_ref (sorter));
|
||||
g_object_unref (multi);
|
||||
|
||||
@ -470,13 +470,13 @@ test_multi_changes (void)
|
||||
model = gtk_sort_list_model_new (G_LIST_MODEL (new_store (1, 20, 1)), NULL);
|
||||
assert_model (model, "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20");
|
||||
|
||||
multi = gtk_multi_sorter_new ();
|
||||
multi = GTK_SORTER (gtk_multi_sorter_new ());
|
||||
g_signal_connect (multi, "changed", G_CALLBACK (inc_counter), &counter);
|
||||
gtk_sort_list_model_set_sorter (model, multi);
|
||||
assert_model (model, "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20");
|
||||
g_assert_cmpint (counter, ==, 0);
|
||||
|
||||
sorter1 = gtk_numeric_sorter_new (NULL);
|
||||
sorter1 = GTK_SORTER (gtk_numeric_sorter_new (NULL));
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi), sorter1);
|
||||
assert_model (model, "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20");
|
||||
g_assert_cmpint (counter, ==, 1);
|
||||
@ -491,7 +491,7 @@ test_multi_changes (void)
|
||||
assert_model (model, "4 9 14 19 3 8 13 18 2 7 12 17 1 6 11 16 5 10 15 20");
|
||||
g_assert_cmpint (counter, ==, 3);
|
||||
|
||||
sorter2 = gtk_custom_sorter_new (compare_even, NULL, NULL);
|
||||
sorter2 = GTK_SORTER (gtk_custom_sorter_new (compare_even, NULL, NULL));
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi), sorter2);
|
||||
assert_model (model, "4 14 9 19 8 18 3 13 2 12 7 17 6 16 1 11 10 20 5 15");
|
||||
g_assert_cmpint (counter, ==, 4);
|
||||
@ -500,7 +500,7 @@ test_multi_changes (void)
|
||||
assert_model (model, "10 20 5 15 6 16 1 11 2 12 7 17 8 18 3 13 4 14 9 19");
|
||||
g_assert_cmpint (counter, ==, 5);
|
||||
|
||||
sorter3 = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, (GCallback)get_spelled_out, NULL, NULL));
|
||||
sorter3 = GTK_SORTER (gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, (GCallback)get_spelled_out, NULL, NULL)));
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi), sorter3);
|
||||
assert_model (model, "10 20 15 5 6 16 11 1 12 2 7 17 8 18 13 3 4 14 9 19");
|
||||
g_assert_cmpint (counter, ==, 6);
|
||||
@ -524,13 +524,13 @@ test_multi_changes (void)
|
||||
static GtkSorter *
|
||||
even_odd_sorter_new (void)
|
||||
{
|
||||
return gtk_custom_sorter_new (compare_even, NULL, NULL);
|
||||
return GTK_SORTER (gtk_custom_sorter_new (compare_even, NULL, NULL));
|
||||
}
|
||||
|
||||
static GtkSorter *
|
||||
numeric_sorter_new (void)
|
||||
{
|
||||
return gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL));
|
||||
return GTK_SORTER (gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL)));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -615,8 +615,8 @@ test_stable (void)
|
||||
GtkSorter *multi, *a, *b;
|
||||
guint i;
|
||||
|
||||
a = gtk_multi_sorter_new ();
|
||||
b = gtk_multi_sorter_new ();
|
||||
a = GTK_SORTER (gtk_multi_sorter_new ());
|
||||
b = GTK_SORTER (gtk_multi_sorter_new ());
|
||||
/* We create 2 setups:
|
||||
* 1. sortmodel (multisorter [a, b])
|
||||
* 2. sortmodel (b) => sortmodel (a)
|
||||
@ -627,7 +627,7 @@ test_stable (void)
|
||||
* All we do is make a and b random sorters and assert that the 2 setups
|
||||
* produce the same order every time.
|
||||
*/
|
||||
multi = gtk_multi_sorter_new ();
|
||||
multi = GTK_SORTER (gtk_multi_sorter_new ());
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi), a);
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi), b);
|
||||
model1 = new_model (20, multi);
|
||||
|
@ -252,12 +252,12 @@ create_sorter (gsize id)
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
return gtk_string_sorter_new (NULL);
|
||||
return GTK_SORTER (gtk_string_sorter_new (NULL));
|
||||
|
||||
case 1:
|
||||
case 2:
|
||||
/* match all As, Bs and nothing */
|
||||
sorter = gtk_string_sorter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string"));
|
||||
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string")));
|
||||
if (id == 1)
|
||||
gtk_string_sorter_set_ignore_case (GTK_STRING_SORTER (sorter), TRUE);
|
||||
return sorter;
|
||||
@ -304,7 +304,7 @@ test_two_sorters (gconstpointer model_id)
|
||||
model2 = create_sort_list_model (model_id, TRUE, source, NULL);
|
||||
/* can't track changes from a sortmodel, where the same items get reordered */
|
||||
model1 = create_sort_list_model (model_id, FALSE, G_LIST_MODEL (model2), NULL);
|
||||
every = gtk_multi_sorter_new ();
|
||||
every = GTK_SORTER (gtk_multi_sorter_new ());
|
||||
compare = create_sort_list_model (model_id, TRUE, source, every);
|
||||
g_object_unref (every);
|
||||
g_object_unref (source);
|
||||
|
@ -219,7 +219,7 @@ new_model (gpointer model)
|
||||
{
|
||||
GtkSorter *sorter;
|
||||
|
||||
sorter = gtk_custom_sorter_new (compare, NULL, NULL);
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (compare, NULL, NULL));
|
||||
result = gtk_sort_list_model_new (g_object_ref (model), sorter);
|
||||
}
|
||||
else
|
||||
@ -312,7 +312,7 @@ test_set_sorter (void)
|
||||
assert_model (sort, "2 4 6 8 10");
|
||||
assert_changes (sort, "");
|
||||
|
||||
sorter = gtk_custom_sorter_new (compare_modulo, GUINT_TO_POINTER (5), NULL);
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (compare_modulo, GUINT_TO_POINTER (5), NULL));
|
||||
gtk_sort_list_model_set_sorter (sort, sorter);
|
||||
g_object_unref (sorter);
|
||||
assert_model (sort, "10 6 2 8 4");
|
||||
@ -322,7 +322,7 @@ test_set_sorter (void)
|
||||
assert_model (sort, "4 8 2 6 10");
|
||||
assert_changes (sort, "0-5+5");
|
||||
|
||||
sorter = gtk_custom_sorter_new (compare, NULL, NULL);
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (compare, NULL, NULL));
|
||||
gtk_sort_list_model_set_sorter (sort, sorter);
|
||||
g_object_unref (sorter);
|
||||
assert_model (sort, "2 4 6 8 10");
|
||||
@ -424,7 +424,7 @@ test_stability (void)
|
||||
assert_model (sort, "1 11 21 31");
|
||||
assert_changes (sort, "");
|
||||
|
||||
sorter = gtk_custom_sorter_new (compare_modulo, GUINT_TO_POINTER (5), NULL);
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (compare_modulo, GUINT_TO_POINTER (5), NULL));
|
||||
gtk_sort_list_model_set_sorter (sort, sorter);
|
||||
g_object_unref (sorter);
|
||||
assert_model (sort, "11 31 21 1");
|
||||
@ -467,7 +467,7 @@ test_incremental_remove (void)
|
||||
|
||||
gtk_sort_list_model_set_model (model, G_LIST_MODEL (store));
|
||||
|
||||
sorter = gtk_custom_sorter_new (compare, NULL, NULL);
|
||||
sorter = GTK_SORTER (gtk_custom_sorter_new (compare, NULL, NULL));
|
||||
gtk_sort_list_model_set_sorter (model, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
|
@ -175,7 +175,7 @@ test_simple (void)
|
||||
model = new_model (3);
|
||||
assert_model (model, "1 2 21 3 31 32 321");
|
||||
|
||||
sorter = gtk_tree_list_row_sorter_new (NULL);
|
||||
sorter = GTK_SORTER (gtk_tree_list_row_sorter_new (NULL));
|
||||
sort = gtk_sort_list_model_new (model, sorter);
|
||||
assert_model (sort, "1 2 21 3 31 32 321");
|
||||
|
||||
@ -185,7 +185,7 @@ test_simple (void)
|
||||
static GtkSorter *
|
||||
new_numeric_sorter (void)
|
||||
{
|
||||
return gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL));
|
||||
return GTK_SORTER (gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL)));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -198,7 +198,7 @@ test_compare_total_order (void)
|
||||
model = new_model (3);
|
||||
assert_model (model, "1 2 21 3 31 32 321");
|
||||
|
||||
sorter = gtk_tree_list_row_sorter_new (new_numeric_sorter ());
|
||||
sorter = GTK_SORTER (gtk_tree_list_row_sorter_new (new_numeric_sorter ()));
|
||||
|
||||
n = g_list_model_get_n_items (model);
|
||||
for (i = 0; i < n; i++)
|
||||
@ -228,7 +228,7 @@ test_compare_no_order (void)
|
||||
model = new_model (3);
|
||||
assert_model (model, "1 2 21 3 31 32 321");
|
||||
|
||||
sorter = gtk_tree_list_row_sorter_new (NULL);
|
||||
sorter = GTK_SORTER (gtk_tree_list_row_sorter_new (NULL));
|
||||
|
||||
n = g_list_model_get_n_items (model);
|
||||
for (i = 0; i < n; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user