<commit_before>#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>

typedef struct Progressbar_Data
{
   Evas_Object *pb1;
   Evas_Object *pb2;
   Evas_Object *pb3;
   Evas_Object *pb4;
   Evas_Object *pb5;
   Evas_Object *pb6;
   Evas_Object *pb7;
   Ecore_Timer *timer;
   Evas_Object *btn_start;
   Evas_Object *btn_stop;
} Progressbar_Data;

static Eina_Bool
_my_progressbar_value_set(void *data)
{
   double progress;
   Progressbar_Data *pd = data;

   progress = elm_progressbar_value_get (pd->pb1);
   if (progress < 1.0) progress += 0.0123;
   else progress = 0.0;
   elm_progressbar_value_set(pd->pb1, progress);
   elm_progressbar_value_set(pd->pb4, progress);
   elm_progressbar_value_set(pd->pb3, progress);
   elm_progressbar_value_set(pd->pb6, progress);

   if (progress < 1.0) return ECORE_CALLBACK_RENEW;

   pd->timer = NULL;
   return ECORE_CALLBACK_CANCEL;
}

static void
my_progressbar_test_start(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Progressbar_Data *pd = data;
   if (!pd) return;

   fprintf(stderr, "s1\n");
   elm_progressbar_pulse(pd->pb2, EINA_TRUE);
   fprintf(stderr, "s2\n");
   elm_progressbar_pulse(pd->pb5, EINA_TRUE);
   fprintf(stderr, "s3 %p\n", pd->pb7);
   elm_progressbar_pulse(pd->pb7, EINA_TRUE);
   fprintf(stderr, "s4\n");

   elm_object_disabled_set(pd->btn_start, EINA_TRUE);
   elm_object_disabled_set(pd->btn_stop, EINA_FALSE);

   if (!pd->timer)
     pd->timer = ecore_timer_add(0.1, _my_progressbar_value_set, pd);
}

static void
my_progressbar_test_stop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Progressbar_Data *pd = data;
   if (!pd) return;

   elm_progressbar_pulse(pd->pb1, EINA_FALSE);
   elm_progressbar_pulse(pd->pb2, EINA_FALSE);
   elm_progressbar_pulse(pd->pb3, EINA_FALSE);
   elm_object_disabled_set(pd->btn_start, EINA_FALSE);
   elm_object_disabled_set(pd->btn_stop, EINA_TRUE);

   if (pd->timer)
     {
        ecore_timer_del(pd->timer);
        pd->timer = NULL;
     }
}

static void
_progressbar_destroy_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
   Progressbar_Data *pd = data;

   if (pd) free(pd);
   my_progressbar_test_stop(NULL, NULL, NULL);
   evas_object_del(obj);
}

static char *
my_progressbar_format_cb(double val)
{
   char buf[1024];
   int files;

   files = (1-val)*14000;
   if(snprintf(buf, 30, "%i files left", files) > 0)<commit_msg>test_progressbar: delete timer when progressbar is destroyed.<commit_after>#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>

typedef struct Progressbar_Data
{
   Evas_Object *pb1;
   Evas_Object *pb2;
   Evas_Object *pb3;
   Evas_Object *pb4;
   Evas_Object *pb5;
   Evas_Object *pb6;
   Evas_Object *pb7;
   Ecore_Timer *timer;
   Evas_Object *btn_start;
   Evas_Object *btn_stop;
} Progressbar_Data;

static Eina_Bool
_my_progressbar_value_set(void *data)
{
   double progress;
   Progressbar_Data *pd = data;

   progress = elm_progressbar_value_get (pd->pb1);
   if (progress < 1.0) progress += 0.0123;
   else progress = 0.0;
   elm_progressbar_value_set(pd->pb1, progress);
   elm_progressbar_value_set(pd->pb4, progress);
   elm_progressbar_value_set(pd->pb3, progress);
   elm_progressbar_value_set(pd->pb6, progress);

   if (progress < 1.0) return ECORE_CALLBACK_RENEW;

   pd->timer = NULL;
   return ECORE_CALLBACK_CANCEL;
}

static void
my_progressbar_test_start(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Progressbar_Data *pd = data;
   if (!pd) return;

   fprintf(stderr, "s1\n");
   elm_progressbar_pulse(pd->pb2, EINA_TRUE);
   fprintf(stderr, "s2\n");
   elm_progressbar_pulse(pd->pb5, EINA_TRUE);
   fprintf(stderr, "s3 %p\n", pd->pb7);
   elm_progressbar_pulse(pd->pb7, EINA_TRUE);
   fprintf(stderr, "s4\n");

   elm_object_disabled_set(pd->btn_start, EINA_TRUE);
   elm_object_disabled_set(pd->btn_stop, EINA_FALSE);

   if (!pd->timer)
     pd->timer = ecore_timer_add(0.1, _my_progressbar_value_set, pd);
}

static void
my_progressbar_test_stop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Progressbar_Data *pd = data;
   if (!pd) return;

   elm_progressbar_pulse(pd->pb1, EINA_FALSE);
   elm_progressbar_pulse(pd->pb2, EINA_FALSE);
   elm_progressbar_pulse(pd->pb3, EINA_FALSE);
   elm_object_disabled_set(pd->btn_start, EINA_FALSE);
   elm_object_disabled_set(pd->btn_stop, EINA_TRUE);

   if (pd->timer)
     {
        ecore_timer_del(pd->timer);
        pd->timer = NULL;
     }
}

static void
_progressbar_destroy_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
   Progressbar_Data *pd = data;

   if (pd->timer) ecore_timer_del(pd->timer);
   if (pd) free(pd);
   my_progressbar_test_stop(NULL, NULL, NULL);
   evas_object_del(obj);
}

static char *
my_progressbar_format_cb(double val)
{
   char buf[1024];
   int files;

   files = (1-val)*14000;
   if(snprintf(buf, 30, "%i files left", files) > 0)
{'fraction_non_alphanumeric': 0.12160543130990416, 'fraction_numerical': 0.019568690095846646, 'mean_word_length': 4.6407657657657655, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 53, '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': '6116183', 'n_tokens_mistral': 2069, 'n_tokens_neox': 1961, 'n_words': 362}