Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree model sort #777

Merged
merged 4 commits into from Feb 6, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+168 −2
Diff settings

Always

Just for now

@@ -1692,6 +1692,10 @@ status = "generate"
# Replaced by TreeModelFilter::new
ignore = true
[[object.function]]
name = " sort_new_with_model"
# Replaced by TreeModelSort::new
ignore = true

This comment has been minimized.

Copy link
@sdroege

sdroege Feb 6, 2019

Member

Ah this is placed on the wrong type in the gir file? TreeModel instead of TreeModelSort? Please create an issue in GNOME GitLab and link the issue from here

This comment has been minimized.

Copy link
@sdroege

sdroege Feb 6, 2019

Member

Link it from inside the .toml file I mean

[[object.function]]
name = "iter_children"
[[object.function.parameter]]
name = "parent"
@@ -1744,6 +1748,39 @@ status = "generate"
#value recordboxed
ignore = true

[[object]]
name = "Gtk.TreeModelSort"
status = "generate"
[[object.function]]
name = "convert_child_path_to_path"
[[object.function.parameter]]
name = "child_path"
const = true
[[object.function]]
name = "convert_path_to_child_path"
[[object.function.parameter]]
name = "sorted_path"
const = true
[[object.function]]
name = "convert_iter_to_child_iter"
[[object.function.parameter]]
name = "sorted_iter"
const = true
[[object.function]]
name = "convert_child_iter_to_iter"
[[object.function.parameter]]
name = "child_iter"
const = true
[[object.function]]
name = "iter_is_valid"
[[object.function.parameter]]
name = "iter"
const = true
[[object.function]]
name = "get_model"
[object.function.return]
nullable = false

[[object]]
name = "Gtk.TreePath"
status = "generate"
2 gir
Submodule gir updated 2 files
+150 −138 Cargo.lock
+3 −3 Cargo.toml
@@ -817,6 +817,10 @@ mod tree_model_filter;
pub use self::tree_model_filter::{TreeModelFilter, TreeModelFilterClass, NONE_TREE_MODEL_FILTER};
pub use self::tree_model_filter::TreeModelFilterExt;

mod tree_model_sort;
pub use self::tree_model_sort::{TreeModelSort, TreeModelSortClass, NONE_TREE_MODEL_SORT};
pub use self::tree_model_sort::TreeModelSortExt;

mod tree_selection;
pub use self::tree_selection::{TreeSelection, TreeSelectionClass, NONE_TREE_SELECTION};
pub use self::tree_selection::TreeSelectionExt;
@@ -1495,6 +1499,7 @@ pub mod traits {
pub use super::TreeDragSourceExt;
pub use super::TreeModelExt;
pub use super::TreeModelFilterExt;
pub use super::TreeModelSortExt;
pub use super::TreeSelectionExt;
pub use super::TreeSortableExt;
pub use super::TreeStoreExt;
@@ -0,0 +1,101 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use TreeDragSource;
use TreeIter;
use TreeModel;
use TreePath;
use TreeSortable;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;

glib_wrapper! {
pub struct TreeModelSort(Object<ffi::GtkTreeModelSort, ffi::GtkTreeModelSortClass, TreeModelSortClass>) @implements TreeDragSource, TreeModel, TreeSortable;

match fn {
get_type => || ffi::gtk_tree_model_sort_get_type(),
}
}

pub const NONE_TREE_MODEL_SORT: Option<&TreeModelSort> = None;

pub trait TreeModelSortExt: 'static {
fn clear_cache(&self);

fn convert_child_iter_to_iter(&self, child_iter: &TreeIter) -> Option<TreeIter>;

fn convert_child_path_to_path(&self, child_path: &TreePath) -> Option<TreePath>;

fn convert_iter_to_child_iter(&self, sorted_iter: &TreeIter) -> TreeIter;

fn convert_path_to_child_path(&self, sorted_path: &TreePath) -> Option<TreePath>;

fn get_model(&self) -> TreeModel;

fn iter_is_valid(&self, iter: &TreeIter) -> bool;

fn reset_default_sort_func(&self);
}

impl<O: IsA<TreeModelSort>> TreeModelSortExt for O {
fn clear_cache(&self) {
unsafe {
ffi::gtk_tree_model_sort_clear_cache(self.as_ref().to_glib_none().0);
}
}

fn convert_child_iter_to_iter(&self, child_iter: &TreeIter) -> Option<TreeIter> {
unsafe {
let mut sort_iter = TreeIter::uninitialized();
let ret = from_glib(ffi::gtk_tree_model_sort_convert_child_iter_to_iter(self.as_ref().to_glib_none().0, sort_iter.to_glib_none_mut().0, mut_override(child_iter.to_glib_none().0)));
if ret { Some(sort_iter) } else { None }
}
}

fn convert_child_path_to_path(&self, child_path: &TreePath) -> Option<TreePath> {
unsafe {
from_glib_full(ffi::gtk_tree_model_sort_convert_child_path_to_path(self.as_ref().to_glib_none().0, mut_override(child_path.to_glib_none().0)))
}
}

fn convert_iter_to_child_iter(&self, sorted_iter: &TreeIter) -> TreeIter {
unsafe {
let mut child_iter = TreeIter::uninitialized();
ffi::gtk_tree_model_sort_convert_iter_to_child_iter(self.as_ref().to_glib_none().0, child_iter.to_glib_none_mut().0, mut_override(sorted_iter.to_glib_none().0));
child_iter
}
}

fn convert_path_to_child_path(&self, sorted_path: &TreePath) -> Option<TreePath> {
unsafe {
from_glib_full(ffi::gtk_tree_model_sort_convert_path_to_child_path(self.as_ref().to_glib_none().0, mut_override(sorted_path.to_glib_none().0)))
}
}

fn get_model(&self) -> TreeModel {
unsafe {
from_glib_none(ffi::gtk_tree_model_sort_get_model(self.as_ref().to_glib_none().0))
}
}

fn iter_is_valid(&self, iter: &TreeIter) -> bool {
unsafe {
from_glib(ffi::gtk_tree_model_sort_iter_is_valid(self.as_ref().to_glib_none().0, mut_override(iter.to_glib_none().0)))
}
}

fn reset_default_sort_func(&self) {
unsafe {
ffi::gtk_tree_model_sort_reset_default_sort_func(self.as_ref().to_glib_none().0);
}
}
}

impl fmt::Display for TreeModelSort {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "TreeModelSort")
}
}
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ f5d3eab)
Generated by gir (https://github.com/gtk-rs/gir @ 4a198d9)
from gir-files (https://github.com/gtk-rs/gir-files @ 02dfee2)
@@ -268,6 +268,7 @@ mod target_list;
mod text_buffer;
mod text_iter;
mod tree_model_filter;
mod tree_model_sort;
mod tree_row_reference;
mod tree_sortable;
mod tree_path;
@@ -0,0 +1,22 @@
// Copyright 2013-2015, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>

use ffi;
use glib::Cast;
use glib::object::IsA;
use glib::translate::*;

use {TreeModel, TreeModelSort};

impl TreeModelSort {
pub fn new<T: IsA<TreeModel>>(child_model: &T) -> TreeModelSort {
skip_assert_initialized!();
unsafe {
TreeModel::from_glib_none(
ffi::gtk_tree_model_sort_new_with_model(
child_model.as_ref().to_glib_none().0)
).unsafe_cast()
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.