[gnome-text-editor] sidebaritem: add compare func by mtime



commit 85414462f6d33e0f65ea759d433ad4cc6cefba75
Author: Christian Hergert <chergert redhat com>
Date:   Wed Oct 20 13:00:51 2021 -0700

    sidebaritem: add compare func by mtime

 src/editor-sidebar-item-private.h |  2 ++
 src/editor-sidebar-item.c         | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
---
diff --git a/src/editor-sidebar-item-private.h b/src/editor-sidebar-item-private.h
index 7dc8174..1dd09d0 100644
--- a/src/editor-sidebar-item-private.h
+++ b/src/editor-sidebar-item-private.h
@@ -54,5 +54,7 @@ void               _editor_sidebar_item_open            (EditorSidebarItem *self
                                                          EditorWindow      *window);
 gboolean           _editor_sidebar_item_matches         (EditorSidebarItem *self,
                                                          GPatternSpec      *spec);
+int                _editor_sidebar_item_compare         (EditorSidebarItem *a,
+                                                         EditorSidebarItem *b);
 
 G_END_DECLS
diff --git a/src/editor-sidebar-item.c b/src/editor-sidebar-item.c
index 5bb25bc..a9b1b96 100644
--- a/src/editor-sidebar-item.c
+++ b/src/editor-sidebar-item.c
@@ -582,3 +582,20 @@ _editor_sidebar_item_get_age (EditorSidebarItem *self)
 
   return NULL;
 }
+
+int
+_editor_sidebar_item_compare (EditorSidebarItem *a,
+                              EditorSidebarItem *b)
+{
+  g_return_val_if_fail (EDITOR_IS_SIDEBAR_ITEM (a), 0);
+  g_return_val_if_fail (EDITOR_IS_SIDEBAR_ITEM (b), 0);
+
+  /* More recent sorts first (larger numeric value) */
+
+  if (a->age < b->age)
+    return 1;
+  else if (a->age > b->age)
+    return -1;
+  else
+    return 0;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]