[Xfce4-commits] [xfce/xfce4-appfinder] 01/01: Enable improved sorting for icon view

noreply at xfce.org noreply at xfce.org
Thu Jun 14 05:13:55 CEST 2018


This is an automated email from the git hooks/post-receive script.

a   n   d   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfce4-appfinder.

commit eb9dbb0df2547b062713b3dfb0444795dc52e266
Author: Andre Miranda <andreldm at xfce.org>
Date:   Thu Jun 14 00:12:59 2018 -0300

    Enable improved sorting for icon view
    
    This requires gtk >= 3.22.27
---
 src/appfinder-window.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/appfinder-window.c b/src/appfinder-window.c
index 1fa3610..be88fac 100644
--- a/src/appfinder-window.c
+++ b/src/appfinder-window.c
@@ -116,6 +116,7 @@ static gint       xfce_appfinder_window_sort_items                    (GtkTreeMo
                                                                        GtkTreeIter                 *a,
                                                                        GtkTreeIter                 *b,
                                                                        gpointer                     data);
+static gboolean   xfce_appfunder_should_sort_icon_view                (void);
 
 struct _XfceAppfinderWindowClass
 {
@@ -694,10 +695,11 @@ xfce_appfinder_window_view (XfceAppfinderWindow *window)
 
   if (icon_view)
     {
-      /* Disable sort model for icon view, since it does not work as expected */
-      /* Example: the user searches for some app and then deletes the text entry. */
-      /* Repeat this operation a couple of times, you will notice that sorting is incorrect. */
-      window->view = view = gtk_icon_view_new_with_model (window->filter_model/*sort_model*/);
+      window->view = view = gtk_icon_view_new_with_model (
+        xfce_appfunder_should_sort_icon_view () ?
+          window->sort_model :
+          window->filter_model);
+
       gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (view), GTK_SELECTION_BROWSE);
       gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (view), XFCE_APPFINDER_MODEL_COLUMN_ICON);
       gtk_icon_view_set_text_column (GTK_ICON_VIEW (view), XFCE_APPFINDER_MODEL_COLUMN_TITLE);
@@ -1712,7 +1714,7 @@ xfce_appfinder_window_execute (XfceAppfinderWindow *window,
         {
           child_model = model;
 
-          if (GTK_IS_TREE_MODEL_SORT (model))
+          if (GTK_IS_TREE_MODEL_SORT (model) || xfce_appfunder_should_sort_icon_view ())
             {
               gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (model), &child_iter, &iter);
               iter = child_iter;
@@ -1878,3 +1880,17 @@ xfce_appfinder_window_sort_items (GtkTreeModel *model,
   g_free (title_b);
   return result;
 }
+
+
+
+/*
+ * Checks for gtk => 3.22.27 during runtime.
+ * This is necessary because sort model for icon view did not work as expected.
+ */
+static gboolean
+xfce_appfunder_should_sort_icon_view (void)
+{
+  return gtk_get_major_version () >= 3  &&
+         gtk_get_micro_version () >= 22 &&
+         gtk_get_micro_version () >= 27;
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list