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

#define BG_SET_DEFAULT_DESK 0
#define BG_SET_THIS_DESK 1
#define BG_SET_ALL_DESK 2

static void        *_create_data              (E_Config_Dialog *cfd);
static void         _free_data                (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static int          _basic_apply_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);
static int          _advanced_apply_data      (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_advanced_create_widgets  (E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static void        _load_bgs                  (E_Config_Dialog *cfd, Evas_Object *il);
void               _ilist_cb_bg_selected      (void *data);

struct _E_Config_Dialog_Data
{
   char *bg, *current_bg;
   int bg_method;
};

EAPI E_Config_Dialog *
e_int_config_background(E_Container *con)
{
   E_Config_Dialog *cfd;
   E_Config_Dialog_View v;

   v.create_cfdata           = _create_data;
   v.free_cfdata             = _free_data;
   v.basic.apply_cfdata      = _basic_apply_data;
   v.basic.create_widgets    = _basic_create_widgets;
   v.advanced.apply_cfdata   = _advanced_apply_data;
   v.advanced.create_widgets = _advanced_create_widgets;

   cfd = e_config_dialog_new(con, _("Background Settings"), NULL, 0, &v, NULL);
   return cfd;
}

static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
   cfdata->bg_method = BG_SET_DEFAULT_DESK;
   if (e_config->desktop_default_background)
     cfdata->current_bg = strdup(e_config->desktop_default_background);
   else
     cfdata->current_bg = NULL;
}

static void *
_create_data(E_Config_Dialog *cfd)
{
   E_Config_Dialog_Data *cfdata;

   cfdata = E_NEW(E_Config_Dialog_Data, 1);
   cfd->cfdata = cfdata;
   _fill_data(cfdata);
   return cfdata;
}

static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
   if (cfdata->current_bg) free(cfdata->current_bg);
   free(cfdata);
}

static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
   Evas_Object *o, *ot, *of, *il, *im;

   _fill_data(cfdata);

   ot = e_widget_table_add(evas, 0);
   il = e_widget_ilist_add(evas, 48, 48, &(cfdata->bg));
   e_widget_ilist_selector_set(il, 1);
   e_widget_min_size_set(il, 180, 40);

   /* Load Bgs */
   _load_bgs(cfd, il);
   im = cfd->data;

   e_widget_focus_set(il, 1);
   e_widget_ilist_go(il);
   e_widget_table_object_append(ot, il, 0, 0, 1, 2, 1, 1, 1, 1);

   of = e_widget_framelist_add(evas, _("Background Preview"), 0);
   e_widget_min_size_set(of, 320, 240);<commit_msg>Radio buttons have focus stealing issues. Disable setting focus to the bg_list in advanced for now as this causes weird behavior with the radios.<commit_after>/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"

#define BG_SET_DEFAULT_DESK 0
#define BG_SET_THIS_DESK 1
#define BG_SET_ALL_DESK 2

static void        *_create_data              (E_Config_Dialog *cfd);
static void         _free_data                (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static int          _basic_apply_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);
static int          _advanced_apply_data      (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_advanced_create_widgets  (E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static void        _load_bgs                  (E_Config_Dialog *cfd, Evas_Object *il);
void               _ilist_cb_bg_selected      (void *data);

struct _E_Config_Dialog_Data
{
   char *bg, *current_bg;
   int bg_method;
};

EAPI E_Config_Dialog *
e_int_config_background(E_Container *con)
{
   E_Config_Dialog *cfd;
   E_Config_Dialog_View v;

   v.create_cfdata           = _create_data;
   v.free_cfdata             = _free_data;
   v.basic.apply_cfdata      = _basic_apply_data;
   v.basic.create_widgets    = _basic_create_widgets;
   v.advanced.apply_cfdata   = _advanced_apply_data;
   v.advanced.create_widgets = _advanced_create_widgets;

   cfd = e_config_dialog_new(con, _("Background Settings"), NULL, 0, &v, NULL);
   return cfd;
}

static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
   cfdata->bg_method = BG_SET_DEFAULT_DESK;
   if (e_config->desktop_default_background)
     cfdata->current_bg = strdup(e_config->desktop_default_background);
   else
     cfdata->current_bg = NULL;
}

static void *
_create_data(E_Config_Dialog *cfd)
{
   E_Config_Dialog_Data *cfdata;

   cfdata = E_NEW(E_Config_Dialog_Data, 1);
   cfd->cfdata = cfdata;
   _fill_data(cfdata);
   return cfdata;
}

static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
   if (cfdata->current_bg) free(cfdata->current_bg);
   free(cfdata);
}

static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
   Evas_Object *o, *ot, *of, *il, *im;

   _fill_data(cfdata);

   ot = e_widget_table_add(evas, 0);
   il = e_widget_ilist_add(evas, 48, 48, &(cfdata->bg));
   e_widget_ilist_selector_set(il, 1);
   e_widget_min_size_set(il, 180, 40);

   /* Load Bgs */
   _load_bgs(cfd, il);
   im = cfd->data;

   /* e_widget_focus_set(il, 1); */
   e_widget_ilist_go(il);
   e_widget_table_object_append(ot, il, 0, 0, 1, 2, 1, 1, 1, 1);

   of = e_widget_framelist_add(evas, _("Background Preview"), 0);
   e_widget_min_size_set(of, 320, 240);
{'fraction_non_alphanumeric': 0.10426206410707996, 'fraction_numerical': 0.014089468122578372, 'mean_word_length': 4.052491103202847, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1988110', 'n_tokens_mistral': 2308, 'n_tokens_neox': 2177, 'n_words': 416}