<commit_before>/*
 * file.c
 *
 * Copyright (c) 2015 <NAME>
 */

#include "war2edit.h"
#include <elm_interface_fileselector.h>

/*============================================================================*
 *                                 Private API                                *
 *============================================================================*/

static void
_fs_show(Editor *ed)
{
   if (inwin_id_is(ed, INWIN_FILE_SELECTOR))
     inwin_activate(ed);
   else
     inwin_set(ed, ed->fs,
               INWIN_FILE_SELECTOR,
               NULL, NULL, NULL, NULL);
   evas_object_show(ed->fs);
}

static void
_fs_hide(Editor *ed)
{
   inwin_dismiss(ed);
   evas_object_hide(ed->fs);
}


/*============================================================================*
 *                                  Callbacks                                 *
 *============================================================================*/

static void
_done_cb(void        *data,
         Evas_Object *obj   EINA_UNUSED,
         void        *event)
{
   Editor *ed = data;
   Eina_Stringshare *file = event;
   Eina_Bool save;

   if (!file) goto hide_fileselector;

   eo_do(obj, save = elm_interface_fileselector_is_save_get());
   if (save)
     {
        if (ecore_file_is_dir(file))
          {
             ERR("You have selected a directory dumbass!");
             return;
          }

        INF("Saving at path \"%s\"...", file);
        editor_save(ed, file);
     }
   else /* Load */
     {
    // XXX    if (ed->pud)
    // XXX      {
    // XXX         // TODO
    // XXX         CRI("TODO PROMPT FOR SAVE");
    // XXX         pud_close(ed->pud);
    // XXX      }
    // XXX    ed->pud = pud_open(file, PUD_OPEN_MODE_R);
    // XXX    if (EINA_UNLIKELY(!ed->pud))
    // XXX      {
    // XXX         ERR("Failed to open PUD from file \"%s\"", file);
    // XXX         goto hide_fileselector;
    // XXX      }
    // XXX    file_load(ed, ed->pud);
     }

hide_fileselector:
   _fs_hide(ed);
}


/*============================================================================*
 *                                 Public API                                 *
 *============================================================================*/

Eina_Bool
file_selector_add(Editor *ed)
{
   Evas_Object *obj;
<commit_msg>file: restore load option<commit_after>/*
 * file.c
 *
 * Copyright (c) 2015 <NAME>
 */

#include "war2edit.h"
#include <elm_interface_fileselector.h>

/*============================================================================*
 *                                 Private API                                *
 *============================================================================*/

static void
_fs_show(Editor *ed)
{
   if (inwin_id_is(ed, INWIN_FILE_SELECTOR))
     inwin_activate(ed);
   else
     inwin_set(ed, ed->fs,
               INWIN_FILE_SELECTOR,
               NULL, NULL, NULL, NULL);
   evas_object_show(ed->fs);
}

static void
_fs_hide(Editor *ed)
{
   inwin_dismiss(ed);
   evas_object_hide(ed->fs);
}


/*============================================================================*
 *                                  Callbacks                                 *
 *============================================================================*/

static void
_done_cb(void        *data,
         Evas_Object *obj   EINA_UNUSED,
         void        *event)
{
   Editor *ed = data;
   Eina_Stringshare *file = event;
   Eina_Bool save;

   if (!file) goto hide_fileselector;

   eo_do(obj, save = elm_interface_fileselector_is_save_get());
   if (save)
     {
        if (ecore_file_is_dir(file))
          {
             ERR("You have selected a directory dumbass!");
             return;
          }

        INF("Saving at path \"%s\"...", file);
        editor_save(ed, file);
     }
   else /* Load */
     {
        if (ed->pud)
          {
             // TODO
             CRI("TODO PROMPT FOR SAVE");
          }
        editor_load(ed, file);
     }

hide_fileselector:
   _fs_hide(ed);
}


/*============================================================================*
 *                                 Public API                                 *
 *============================================================================*/

Eina_Bool
file_selector_add(Editor *ed)
{
   Evas_Object *obj;

{'fraction_non_alphanumeric': 0.306672760511883, 'fraction_numerical': 0.0022851919561243145, 'mean_word_length': 2.0629811056682996, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '440475', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1200, 'n_words': 228}