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

git pushed a commit to branch master
in repository efm2.

View the commit online.

commit 0f827d10e207a9ea2b6db6bbc43e640fe72fc937
Author: Carsten Haitzler (Rasterman) <[email protected]>
AuthorDate: Sun Nov 16 13:44:59 2025 +0000

    add order sort flag and ui to change sort flags
---
 src/efm/efm.h  |  1 +
 src/efm/main.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/efm/sort.c | 29 +++++++++++++++++--
 3 files changed, 115 insertions(+), 3 deletions(-)

diff --git a/src/efm/efm.h b/src/efm/efm.h
index 46ada84..80e4def 100644
--- a/src/efm/efm.h
+++ b/src/efm/efm.h
@@ -22,6 +22,7 @@ typedef enum
   EFM_SORT_MODE_DIRS_FIRST     = (1 << 16), // show dirs first then files
   EFM_SORT_MODE_NOCASE         = (1 << 17), // don't account for case in sort
   EFM_SORT_MODE_LABEL_NOT_PATH = (1 << 18), // use label not filename
+  EFM_SORT_MODE_ORDER          = (1 << 19), // use explicit ordering data
   // mask for field
   EFM_SORT_MODE_MASK = 0xffff, // lower 16 bits is the sort field
   // fields
diff --git a/src/efm/main.c b/src/efm/main.c
index 37c3e68..a42f8b4 100644
--- a/src/efm/main.c
+++ b/src/efm/main.c
@@ -2,6 +2,7 @@
 #include "Elementary.h"
 #include "efm.h"
 #include "eina_types.h"
+#include "elm_check.h"
 
 // #include "efm_icon.h"
 
@@ -104,6 +105,50 @@ _cb_list_detailed(void *data, Evas_Object *obj EINA_UNUSED,
   efm_path_view_mode_set(data, EFM_VIEW_MODE_LIST_DETAILED);
 }
 
+static void
+_cb_sort_dirs_first(void *data, Evas_Object *obj EINA_UNUSED,
+                    void *event_info EINA_UNUSED)
+{
+  Efm_Sort_Mode mode = efm_path_sort_mode_get(data);
+  Efm_Sort_Mode m    = EFM_SORT_MODE_DIRS_FIRST;
+  if (elm_check_state_get(obj)) mode = mode | m;
+  else mode = mode & (~m);
+  efm_path_sort_mode_set(data, mode);
+}
+
+static void
+_cb_sort_no_case(void *data, Evas_Object *obj EINA_UNUSED,
+                 void *event_info EINA_UNUSED)
+{
+  Efm_Sort_Mode mode = efm_path_sort_mode_get(data);
+  Efm_Sort_Mode m    = EFM_SORT_MODE_NOCASE;
+  if (elm_check_state_get(obj)) mode = mode | m;
+  else mode = mode & (~m);
+  efm_path_sort_mode_set(data, mode);
+}
+
+static void
+_cb_sort_label_not_path(void *data, Evas_Object *obj EINA_UNUSED,
+                        void *event_info EINA_UNUSED)
+{
+  Efm_Sort_Mode mode = efm_path_sort_mode_get(data);
+  Efm_Sort_Mode m    = EFM_SORT_MODE_LABEL_NOT_PATH;
+  if (elm_check_state_get(obj)) mode = mode | m;
+  else mode = mode & (~m);
+  efm_path_sort_mode_set(data, mode);
+}
+
+static void
+_cb_sort_order(void *data, Evas_Object *obj EINA_UNUSED,
+               void *event_info EINA_UNUSED)
+{
+  Efm_Sort_Mode mode = efm_path_sort_mode_get(data);
+  Efm_Sort_Mode m    = EFM_SORT_MODE_ORDER;
+  if (elm_check_state_get(obj)) mode = mode | m;
+  else mode = mode & (~m);
+  efm_path_sort_mode_set(data, mode);
+}
+
 static void
 _cb_header_change(void *data, Evas_Object *obj EINA_UNUSED,
                   void *event_info EINA_UNUSED)
@@ -318,6 +363,49 @@ elm_main(int argc, char **argv)
   elm_box_pack_end(bx2, o);
   evas_object_show(o);
 
+  bx2 = o = elm_box_add(win);
+  evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, 0);
+  evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0);
+  elm_box_homogeneous_set(o, EINA_TRUE);
+  elm_box_horizontal_set(o, EINA_TRUE);
+  elm_box_pack_end(bx, o);
+  evas_object_show(o);
+
+  o = elm_check_add(win);
+  evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, 0);
+  evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0);
+  elm_object_text_set(o, "Dirs First");
+  elm_check_state_set(o, EINA_TRUE);
+  evas_object_smart_callback_add(o, "changed", _cb_sort_dirs_first, efm);
+  elm_box_pack_end(bx2, o);
+  evas_object_show(o);
+
+  o = elm_check_add(win);
+  evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, 0);
+  evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0);
+  elm_object_text_set(o, "No Case");
+  elm_check_state_set(o, EINA_TRUE);
+  evas_object_smart_callback_add(o, "changed", _cb_sort_no_case, efm);
+  elm_box_pack_end(bx2, o);
+  evas_object_show(o);
+
+  o = elm_check_add(win);
+  evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, 0);
+  evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0);
+  elm_object_text_set(o, "Label Not Path");
+  elm_check_state_set(o, EINA_TRUE);
+  evas_object_smart_callback_add(o, "changed", _cb_sort_label_not_path, efm);
+  elm_box_pack_end(bx2, o);
+  evas_object_show(o);
+
+  o = elm_check_add(win);
+  evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, 0);
+  evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0);
+  elm_object_text_set(o, "Order");
+  evas_object_smart_callback_add(o, "changed", _cb_sort_order, efm);
+  elm_box_pack_end(bx2, o);
+  evas_object_show(o);
+
   evas_object_resize(win, ELM_SCALE_SIZE(700), ELM_SCALE_SIZE(300));
   evas_object_show(win);
 
diff --git a/src/efm/sort.c b/src/efm/sort.c
index 27fd7a7..3accabe 100644
--- a/src/efm/sort.c
+++ b/src/efm/sort.c
@@ -194,10 +194,10 @@ _sort_dir_not_dir(const Cmd *c1, const Cmd *c2)
 static int
 _sort_cmd_do(const Cmd *c1, const Cmd *c2)
 {
-  int           dir_not_dir = SORT_INVALID;
-  Efm_Sort_Mode sort_mode;
+  Efm_Sort_Mode  sort_mode;
   int (*cmpfn)(const char *s1, const char *s2) = strcmp;
-  Eina_Bool label_sort                         = EINA_FALSE;
+  int dir_not_dir                                       = SORT_INVALID;
+  Eina_Bool      label_sort                             = EINA_FALSE;
 
   sort_mode = c1->sort_mode;
   // handle flags
@@ -205,7 +205,30 @@ _sort_cmd_do(const Cmd *c1, const Cmd *c2)
     dir_not_dir = _sort_dir_not_dir(c1, c2);
   if (sort_mode & EFM_SORT_MODE_NOCASE) cmpfn = strcasecmp;
   if (sort_mode & EFM_SORT_MODE_LABEL_NOT_PATH) label_sort = EINA_TRUE;
+  if (sort_mode & EFM_SORT_MODE_ORDER)
+    { // if we're doing explicit order sorting  use order-index
+      int order1 = 0, order2 = 0;
+      const char *s;
 
+      s = cmd_key_find(c1, "order-index");
+      if (s) order1 = atoi(s);
+      s = cmd_key_find(c2, "order-index");
+      if (s) order2 = atoi(s);
+      // order-index if provided is > 0 .... 1, 2, 3 ... etc.
+      if ((order1 > 0) && (order2 > 0))
+        { // order index provided by both files so compare them
+          if (order1 > order2) return SORT_MORE;
+          else if (order1 < order2) return SORT_LESS;
+          // if order1 == order2? fall through to other info sorting below
+        }
+      else
+        {
+          // 2nd file has order, 1st doesnt
+          if ((order1 == 0) && (order2 > 0)) return SORT_MORE;
+          // 1st file has order, 2nd doesnt
+          if ((order2 == 0) && (order1 > 0)) return SORT_LESS;
+        }
+    }
   // handle each sort mode
 
   // if one is a dir and one is not - other sorting compares are not useful

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

Reply via email to