<commit_before>/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"

/* TODO:
 * More filtering/sorting of left side to make managing thousands of apps easy.
 *
 * These things require support from e_fm -
 * Stop user from deleting standard directories on right side.
 * Stop user from creating new directories on left side.
 */


static void *_create_data(E_Config_Dialog *cfd);
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
#if 0
static void _move_file_up_in_order(const char *order, const char *file);
static void _move_file_down_in_order(const char *order, const char *file);
#endif
static void _append_to_order(const char *order, const char *file);

struct _E_Config_Dialog_Data
{
   E_Config_Dialog *cfd;
   E_Fm2_Icon_Info *info;
   char *selected;
   char path_all[PATH_MAX], path_menu[PATH_MAX], path_everything[PATH_MAX], path[PATH_MAX], *homedir;
   int sorted;
   struct {
      Evas_Object *o_fm_all;
      Evas_Object *o_fm;
      Evas_Object *o_frame;
      Evas_Object *o_up_button;
      Evas_Object *o_up_all_button;
      Evas_Object *o_add_button;
      Evas_Object *o_create_button;
      Evas_Object *o_delete_left_button;
      Evas_Object *o_delete_right_button;
      Evas_Object *o_regen_button;
      Evas_Object *o_move_up_button;
      Evas_Object *o_move_down_button;
   } gui;
   E_App_Edit *editor;
};

typedef struct _E_Config_Once
{
   const char *title;
   const char *label;
   const char *path;
   int (*func) (void *data, const char *path);
   void *data;
} E_Config_Once;

EAPI E_Config_Dialog *
e_int_config_apps_once(E_Container *con, const char *title, const char *label, const char *path, int (*func) (void *data, const char *path), void *data)
{
   E_Config_Dialog *cfd;
   E_Config_Dialog_View *v;
   E_Config_Once *once = NULL;
   
   v = E_NEW(E_Config_Dialog_View, 1);

   v->create_cfdata           = _create_data;
   v->free_cfdata             = _free_data;
   v->basic.create_widgets    = _basic_create_widgets;

   if ((path) || (func))
      {
         once = E_NEW(E_Config_Once, 1);
	 if (once)
	    {
	       once->title = title;
	       once->label = label;
	       once->path = path;
	       once->func = func;
	       once->data = data;
	    }
      }

   if (!path) 
     {
	cfd = e_config_dialog_new(con,
				  _("Applications"),
				  "E", "_config_applications_dialog",
				  "enlightenment/applications", 0, v, once);
	return cfd;
     }
   else 
     {
	char buf[4096];
	
	snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar", e_user_homedir_get());
	if (!strcmp(path, buf))
	  {
	     cfd = e_config_dialog_new(con,
				       _("Applications"),
				       "E", "_config_applications_dialog",
				       "enlightenment/ibar_applications", 0, v, once);
	     return cfd;
	  }
	snprintf(buf, sizeof(buf), "%s/.e/e/applications/startup", e_user_homedir_get());
	if (!strcmp(path, buf)) 
	  {
	     cfd = e_config_dialog_new(con,
				       _("Applications"),
				       "E", "_config_applications_dialog",
				       "enlightenment/startup_applications", 0, v, once);
	     return cfd;
	  }
	snprintf(buf, sizeof(buf), "%s/.e/e/applications/restart", e_user_homedir_get());
	if (!strcmp(path, buf)) 
	  {
	     cfd = e_config_dialog_new(con,
				       _("Applications"),
				       "E", "_config_applications_dialog",
				       "enlightenment/restart_applications", 0, v, once);
	     return cfd;
	  }
     }
}

EAPI E_Config_Dialog *
e_int_config_apps(E_Container *con)
{
   if (e_config_dialog_find("E", "_config_applications_dialog")) return NULL;
   return e_int_config_apps_once(con, NULL, NULL, NULL, NULL, NULL);
}

EAPI E_Config_Dialog *
e_int_config_apps_ibar(E_Container *con) 
{
   char path[4096];

   if (e_config_dialog_find("E", "_config_applications_dialog")) return NULL;
   snprintf(path, sizeof(path), "%s/.e/e/applications/bar", e_user_homedir_get());
   return e_int_config_apps_once(con, _("IBar"), NULL, path, NULL, NULL);
}

EAPI E_Config_Dialog *
e_int_config_apps_restart(E_Container *con) 
{
   char path[4096];

   if (e_config_dialog_find("E", "_config_applications_dialog")) return NULL;
   snprintf(path, sizeof(path), "%s/.e/e/applications/restart", e_user_homedir_get());
   return e_int_config_apps_once(con, _("Restart"), NULL, path, NULL, NULL);
}<commit_msg>Use a much simplier/cleaner method of setting the Applications dialog(s) icon.<commit_after>/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"

/* TODO:
 * More filtering/sorting of left side to make managing thousands of apps easy.
 *
 * These things require support from e_fm -
 * Stop user from deleting standard directories on right side.
 * Stop user from creating new directories on left side.
 */


static void *_create_data(E_Config_Dialog *cfd);
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
#if 0
static void _move_file_up_in_order(const char *order, const char *file);
static void _move_file_down_in_order(const char *order, const char *file);
#endif
static void _append_to_order(const char *order, const char *file);

struct _E_Config_Dialog_Data
{
   E_Config_Dialog *cfd;
   E_Fm2_Icon_Info *info;
   char *selected;
   char path_all[PATH_MAX], path_menu[PATH_MAX], path_everything[PATH_MAX], path[PATH_MAX], *homedir;
   int sorted;
   struct {
      Evas_Object *o_fm_all;
      Evas_Object *o_fm;
      Evas_Object *o_frame;
      Evas_Object *o_up_button;
      Evas_Object *o_up_all_button;
      Evas_Object *o_add_button;
      Evas_Object *o_create_button;
      Evas_Object *o_delete_left_button;
      Evas_Object *o_delete_right_button;
      Evas_Object *o_regen_button;
      Evas_Object *o_move_up_button;
      Evas_Object *o_move_down_button;
   } gui;
   E_App_Edit *editor;
};

typedef struct _E_Config_Once
{
   const char *title;
   const char *label;
   const char *path;
   int (*func) (void *data, const char *path);
   void *data;
} E_Config_Once;

EAPI E_Config_Dialog *
e_int_config_apps_once(E_Container *con, const char *title, const char *label, const char *path, int (*func) (void *data, const char *path), void *data)
{
   E_Config_Dialog *cfd;
   E_Config_Dialog_View *v;
   E_Config_Once *once = NULL;
   
   v = E_NEW(E_Config_Dialog_View, 1);

   v->create_cfdata           = _create_data;
   v->free_cfdata             = _free_data;
   v->basic.create_widgets    = _basic_create_widgets;

   if ((path) || (func))
      {
         once = E_NEW(E_Config_Once, 1);
	 if (once)
	    {
	       once->title = title;
	       once->label = label;
	       once->path = path;
	       once->func = func;
	       once->data = data;
	    }
      }

   if (!path) 
     {
	cfd = e_config_dialog_new(con,
				  _("Applications"),
				  "E", "_config_applications_dialog",
				  "enlightenment/applications", 0, v, once);
     }
   else if (strstr(path, "bar"))
     {
	     cfd = e_config_dialog_new(con,
				       _("Applications"),
				       "E", "_config_applications_dialog",
				       "enlightenment/ibar_applications", 0, v, once);
     }
   else if (strstr(path, "startup"))
     {
	cfd = e_config_dialog_new(con,
				  _("Applications"),
				  "E", "_config_applications_dialog",
				  "enlightenment/startup_applications", 0, v, once);
     }
   else if (strstr(path, "restart"))
     {
	cfd = e_config_dialog_new(con,
				  _("Applications"),
				  "E", "_config_applications_dialog",
				  "enlightenment/restart_applications", 0, v, once);
     }
   return cfd;
}

EAPI E_Config_Dialog *
e_int_config_apps(E_Container *con)
{
   if (e_config_dialog_find("E", "_config_applications_dialog")) return NULL;
   return e_int_config_apps_once(con, NULL, NULL, NULL, NULL, NULL);
}

EAPI E_Config_Dialog *
e_int_config_apps_ibar(E_Container *con) 
{
   char path[4096];

   if (e_config_dialog_find("E", "_config_applications_dialog")) return NULL;
   snprintf(path, sizeof(path), "%s/.e/e/applications/bar", e_user_homedir_get());
   return e_int_config_apps_once(con, _("IBar"), NULL, path, NULL, NULL);
}

EAPI E_Config_Dialog *
e_int_config_apps_restart(E_Container *con) 
{
   char path[4096];

   if (e_config_dialog_find("E", "_config_applications_dialog")) return NULL;
   snprintf(path, sizeof(path), "%s/.e/e/applications/restart", e_user_homedir_get());
   return e_int_config_apps_once(con, _("Restart"), NULL, path, NULL, NULL);
}
{'fraction_non_alphanumeric': 0.12033146591970122, 'fraction_numerical': 0.006069094304388422, 'mean_word_length': 3.723814773980154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '7291458', 'n_tokens_mistral': 3312, 'n_tokens_neox': 3096, 'n_words': 668}