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

Unable to instantiate Gtk::TreeModelFilter #1298

Closed
LutzLue opened this issue Sep 24, 2019 · 11 comments
Closed

Unable to instantiate Gtk::TreeModelFilter #1298

LutzLue opened this issue Sep 24, 2019 · 11 comments

Comments

@LutzLue
Copy link

LutzLue commented Sep 24, 2019

I have a Gtk::TreeStore (my_tree_store) that I want to be able to sort and filter.
When I try this:
Gtk::TreeModelSort.new(Gtk::TreeModelFilter.new(my_tree_store))
I get
wrong argument type Gtk::TreeModelFilter (expected Hash) (TypeError)
although the docs say Gtk::TreeModelFilter is instantiated with a TreeModel.

@kou
Copy link
Member

kou commented Sep 24, 2019

Could you show a whole script that reproduces this case instead of code snippet?

@LutzLue
Copy link
Author

LutzLue commented Sep 25, 2019

Thx, for the fast reply!

Actually this already reproduces the case in Ruby 2.5.0:

require 'gtk3'

Gtk::TreeModelSort.new(Gtk::TreeModelFilter.new(Gtk::TreeStore.new(Integer)))

@kou
Copy link
Member

kou commented Sep 25, 2019

Thanks.
This is a GTK bug. gtk_tree_model_sort_new_with_model() https://developer.gnome.org/gtk3/stable/GtkTreeModelSort.html#gtk-tree-model-sort-new-with-model is processed as an instance method of GtkTreeModel instead of GtkTreeModelSort. Could you send a merge request to GTK?

diff --git a/gtk/gtktreemodelsort.c b/gtk/gtktreemodelsort.c
index 2e3b808e75..4376365837 100644
--- a/gtk/gtktreemodelsort.c
+++ b/gtk/gtktreemodelsort.c
@@ -529,14 +529,14 @@ gtk_tree_model_sort_drag_source_init (GtkTreeDragSourceIface *iface)
  * gtk_tree_model_sort_new_with_model:
  * @child_model: A #GtkTreeModel
  *
- * Creates a new #GtkTreeModel, with @child_model as the child model.
+ * Creates a new #GtkTreeModelSort, with @child_model as the child model.
  *
- * Returns: (transfer full): A new #GtkTreeModel.
+ * Returns: (transfer full): A new #GtkTreeModelSort.
  */
-GtkTreeModel *
+GtkTreeModelSort *
 gtk_tree_model_sort_new_with_model (GtkTreeModel *child_model)
 {
-  GtkTreeModel *retval;
+  GtkTreeModelSort *retval;
 
   g_return_val_if_fail (GTK_IS_TREE_MODEL (child_model), NULL);
 
diff --git a/gtk/gtktreemodelsort.h b/gtk/gtktreemodelsort.h
index 568372efb3..95742f499f 100644
--- a/gtk/gtktreemodelsort.h
+++ b/gtk/gtktreemodelsort.h
@@ -59,7 +59,7 @@ struct _GtkTreeModelSortClass
 GDK_AVAILABLE_IN_ALL
 GType         gtk_tree_model_sort_get_type                   (void) G_GNUC_CONST;
 GDK_AVAILABLE_IN_ALL
-GtkTreeModel *gtk_tree_model_sort_new_with_model             (GtkTreeModel     *child_model);
+GtkTreeModelSort *gtk_tree_model_sort_new_with_model         (GtkTreeModel     *child_model);
 
 GDK_AVAILABLE_IN_ALL
 GtkTreeModel *gtk_tree_model_sort_get_model                  (GtkTreeModelSort *tree_model);

Related issue: https://gitlab.gnome.org/GNOME/gtk/issues/1077

@kou kou closed this as completed in fbf7966 Sep 25, 2019
@kou
Copy link
Member

kou commented Sep 25, 2019

I've added a workaround for this case to master for now.

@LutzLue
Copy link
Author

LutzLue commented Oct 4, 2019

Thx, for the quick reply and the workaround. Works fine now.
I would like to do the merge request, but I do not know what to do. Can you give me detailed instructions, please? 📜

@kou
Copy link
Member

kou commented Oct 10, 2019

  1. Create an account on https://gitlab.gnome.org/
  2. Fork https://gitlab.gnome.org/GNOME/gtk
  3. Clone the forked repository
  4. Create a topic branch
  5. Commit the patch in Unable to instantiate Gtk::TreeModelFilter #1298 (comment)
  6. Push the topic branch
  7. Send the topic branch as a merge request on https://gitlab.gnome.org/${YOUR_ACCOUNT}/gtk

@LutzLue
Copy link
Author

LutzLue commented Oct 15, 2019

Thx! Currently failing at step one but I will persist! :)

@LutzLue
Copy link
Author

LutzLue commented Oct 16, 2019

@LutzLue
Copy link
Author

LutzLue commented Oct 16, 2019

Unfortunately it does not build. :(

@LutzLue
Copy link
Author

LutzLue commented Dec 4, 2019

Finally success! It got merged! 😄

@kou
Copy link
Member

kou commented Dec 4, 2019

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants