<commit_before>#include "elm_file_display_priv.h"

Elm_File_MimeType_Cache *cache;

static Eina_Bool
_drop_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event EINA_UNUSED)
{
 eo_do(data,
         eo_event_callback_call(ELM_FILE_DISPLAY_EVENT_DND_ITEM_DROPED, NULL));
   return EINA_FALSE;
}

static Eina_Bool
_hover_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event EINA_UNUSED)
{
   eo_do(data,
         eo_event_callback_call(ELM_FILE_DISPLAY_EVENT_DND_ITEM_HOVER, NULL));
   return EINA_FALSE;
}

Evas_Object*
icon_create(Evas_Object *par, Efm_File *file)
{
   Evas_Object *ic, *widget;

   widget = elm_object_parent_widget_get(par);

   #if 1
      ic = eo_add(ELM_FILE_ICON_CLASS, par);
      eo_do(ic,
        elm_obj_file_icon_mimetype_cache_set(cache);
        elm_obj_file_icon_fm_monitor_file_set(file);
        eo_event_callback_add(ELM_FILE_ICON_EVENT_ITEM_DROP, _drop_cb, widget);
        eo_event_callback_add(ELM_FILE_ICON_EVENT_ITEM_HOVER, _hover_cb, widget)
      );
   #else
      const char *name;
      name = efm_file_path_get(file);
      ic = elm_label_add(par);
      elm_object_text_set(ic, name);
   #endif
   evas_object_show(ic);

   return ic;
}

static int
sort_name_func(const void *data1, const void *data2)
{
   Efm_File *f1 = ((Efm_File*)data1), *f2 = ((Efm_File*)data2);
   if (config->sort.type == ELM_FILE_DISPLAY_SORT_TYPE_NAME)
     {
        const char *n1 = efm_file_filename_get(f1);
        const char *n2 = efm_file_filename_get(f2);
        int c = 0;
#if 0
        if (n1[0] == '.')
          n1 ++;
        if (n2[0] == '.')
          n2 ++;
#endif
        while(n1[c] != '\0' && n2[c] != '\0')
          {
             if (n1[c] < n2[c])
               return -1;
             else if (n1[c] > n2[c])
               return 1;
             c ++;
          }
        return 0;
     }
   else if (config->sort.type == ELM_FILE_DISPLAY_SORT_TYPE_SIZE)
     {
       Efm_File_Stat *st1, *st2;

        st1 = efm_file_stat_get(f1);
        st2 = efm_file_stat_get(f2);

        if (st1->mtime > st2->mtime)
          return 1;
        else
          return -1;
     }
   else if (config->sort.type == ELM_FILE_DISPLAY_SORT_TYPE_DATE)
     {
        Efm_File_Stat *st1, *st2;

        st1 = efm_file_stat_get(f1);
        st2 = efm_file_stat_get(f2);

        if (st1->size > st2->size)
          return 1;
        else
          return -1;
     }
   else //if (config->sort.type == SORT_TYPE_EXTENSION)<commit_msg>elm_file_display: The sorttype says SIZE not timestamp<commit_after>#include "elm_file_display_priv.h"

Elm_File_MimeType_Cache *cache;

static Eina_Bool
_drop_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event EINA_UNUSED)
{
 eo_do(data,
         eo_event_callback_call(ELM_FILE_DISPLAY_EVENT_DND_ITEM_DROPED, NULL));
   return EINA_FALSE;
}

static Eina_Bool
_hover_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event EINA_UNUSED)
{
   eo_do(data,
         eo_event_callback_call(ELM_FILE_DISPLAY_EVENT_DND_ITEM_HOVER, NULL));
   return EINA_FALSE;
}

Evas_Object*
icon_create(Evas_Object *par, Efm_File *file)
{
   Evas_Object *ic, *widget;

   widget = elm_object_parent_widget_get(par);

   #if 1
      ic = eo_add(ELM_FILE_ICON_CLASS, par);
      eo_do(ic,
        elm_obj_file_icon_mimetype_cache_set(cache);
        elm_obj_file_icon_fm_monitor_file_set(file);
        eo_event_callback_add(ELM_FILE_ICON_EVENT_ITEM_DROP, _drop_cb, widget);
        eo_event_callback_add(ELM_FILE_ICON_EVENT_ITEM_HOVER, _hover_cb, widget)
      );
   #else
      const char *name;
      name = efm_file_path_get(file);
      ic = elm_label_add(par);
      elm_object_text_set(ic, name);
   #endif
   evas_object_show(ic);

   return ic;
}

static int
sort_name_func(const void *data1, const void *data2)
{
   Efm_File *f1 = ((Efm_File*)data1), *f2 = ((Efm_File*)data2);
   if (config->sort.type == ELM_FILE_DISPLAY_SORT_TYPE_NAME)
     {
        const char *n1 = efm_file_filename_get(f1);
        const char *n2 = efm_file_filename_get(f2);
        int c = 0;
#if 0
        if (n1[0] == '.')
          n1 ++;
        if (n2[0] == '.')
          n2 ++;
#endif
        while(n1[c] != '\0' && n2[c] != '\0')
          {
             if (n1[c] < n2[c])
               return -1;
             else if (n1[c] > n2[c])
               return 1;
             c ++;
          }
        return 0;
     }
   else if (config->sort.type == ELM_FILE_DISPLAY_SORT_TYPE_SIZE)
     {
       Efm_File_Stat *st1, *st2;

        st1 = efm_file_stat_get(f1);
        st2 = efm_file_stat_get(f2);

        if (st1->size > st2->size)
          return 1;
        else
          return -1;
     }
   else if (config->sort.type == ELM_FILE_DISPLAY_SORT_TYPE_DATE)
     {
        Efm_File_Stat *st1, *st2;

        st1 = efm_file_stat_get(f1);
        st2 = efm_file_stat_get(f2);

        if (st1->size > st2->size)
          return 1;
        else
          return -1;
     }
   else //if (config->sort.type == SORT_TYPE_EXTENSION)
{'fraction_non_alphanumeric': 0.11297560975609756, 'fraction_numerical': 0.01951219512195122, 'mean_word_length': 2.602248770203795, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2256024', 'n_tokens_mistral': 2090, 'n_tokens_neox': 2053, 'n_words': 357}