示例#1
0
Eina_Bool eli_highscore_entry_add(const char * game, const char * username,
                                  float points, pointsType type)
{
    Eina_List * l = NULL;
    Eli_Highscore_Entry * entry;
    
    int (*list_sort) (const void *, const void *);
    int count = 0;

    if (!game || !username || !eet_file_name) return 0;

    entry = _eli_entry_new(username, points, type);

    l = eli_highscore_get(game);
    if (l) count = eina_list_count(l);
    else count = 0;

    /* select the right sorting function */
    switch (type) {
    case POINTS_TYPE_INTEGER_BAD:
    case POINTS_TYPE_FLOAT_BAD:
        list_sort = _eli_highscore_list_sort_bad;
        break;
    default:
        list_sort = _eli_highscore_list_sort_good;
        break;
    }

    /* 10 entries should be enough */
    if (count >= 10) {
        Eina_List * last_l;
        Eli_Highscore_Entry * last_e;

        last_l = eina_list_last(l);
        last_e = eina_list_data_get(last_l);

        if ( list_sort(last_e, entry) < 0) {
            free(entry->username);
            free(entry);
            return 0;
        }
    }

    l = eina_list_append(l, entry);
    if (count) l = eina_list_sort(l, (count + 1), list_sort);
    if (count >= 10) l = eina_list_remove_list(l, eina_list_last(l));

    ecore_hash_set(hiscore_hash, strdup(game), l);
  
    _eli_highscore_write(game);
    
    return 1;
}
示例#2
0
/**
 * @brief Adds an Evas image object or an Edje object in the cache system. If the cache is already full, the oldest
 * object will be removed. The object to cache will also be automatically hidden
 * @param cache a cache system
 * @param object the Evas image object or the Edje object to cache
 * @param filename the filename associated to the object
 * @param key the key associated to the object (the group for an Edje object, the key for an image from an Eet file,
 * or NULL otherwise)
 * @note Once the object is added to the cache, you should keep no reference to it. It may for example be deleted if
 * there is no more space in the cache system
 */
void etk_cache_add(Etk_Cache *cache, Evas_Object *object, const char *filename, const char *key)
{
   Etk_Cache_Item *item;
   Eina_List *l;

   if (!cache || !object || cache->size <= 0 || !filename)
      return;

   /* If the object is already cached, we move it at the end of the cache */
   if ((l = evas_object_data_get(object, "_Etk_Cache::Node")))
   {
      item = l->data;
      if (item->filename != filename)
      {
         free(item->filename);
         item->filename = strdup(filename);
      }
      if (item->key != key)
      {
         free(item->key);
         item->key = strdup(key);
      }
      cache->cached_objects = eina_list_remove_list(cache->cached_objects, l);
      cache->cached_objects = eina_list_append(cache->cached_objects, item);
      evas_object_data_set(item->object, "_Etk_Cache::Node", eina_list_last(cache->cached_objects));
      return;
   }

   /* If no more space is available, we remove the oldest object of the cache */
   if (eina_list_count(cache->cached_objects) >= cache->size)
   {
      item = cache->cached_objects->data;
      //evas_object_event_callback_call(item->object, EVAS_CALLBACK_FREE, NULL);
      evas_object_event_callback_del(item->object, EVAS_CALLBACK_FREE, _etk_cache_object_deleted_cb);
      evas_object_del(item->object);
   }

   /* We create a new cache-item for the object and we add it to the cache */
   item = malloc(sizeof(Etk_Cache_Item));
   item->filename = strdup(filename);
   item->key = key ? strdup(key) : NULL;
   item->object = object;

   evas_object_hide(object);
   evas_object_event_callback_add(object, EVAS_CALLBACK_FREE, _etk_cache_object_deleted_cb, cache);

   cache->cached_objects = eina_list_append(cache->cached_objects, item);
   evas_object_data_set(item->object, "_Etk_Cache::Node", eina_list_last(cache->cached_objects));
}
static void
_cb_feed_down(void *data, void *data2)
{
   E_Config_Dialog_Data *cfdata;
   News_Feed *f;
   News_Item *ni;
   News_Feed_Ref *ref;
   Eina_List *sel, *l, *lf;

   cfdata = data;
   ni = cfdata->ni;

   for (sel=eina_list_last(cfdata->ilist_selected_feeds_sel); sel; sel=eina_list_prev(sel))
     {
        f = sel->data;
        ref = news_feed_ref_find(f, ni);
        if (!ref) return;

        l = eina_list_data_find_list(ni->config->feed_refs, ref);
        lf = eina_list_next(l);
        if (!lf) return;
  
        ni->config->feed_refs = eina_list_remove_list(ni->config->feed_refs, l);
        ni->config->feed_refs = eina_list_append_relative_list(ni->config->feed_refs,
                                                               ref, lf);
     }

   news_item_refresh(ni, 1, 0, 0);
   news_config_dialog_item_content_refresh_selected_feeds(ni);
}
示例#4
0
文件: eina_list.c 项目: jigpu/efl
static Eina_Bool
eina_list_accessor_get_at(Eina_Accessor_List *it, unsigned int idx, void **data)
{
   const Eina_List *over;
   unsigned int middle;
   unsigned int i;

   EINA_MAGIC_CHECK_LIST_ACCESSOR(it, EINA_FALSE);

   if (idx >= eina_list_count(it->head))
     return EINA_FALSE;

   if (it->index == idx)
     over = it->current;
   else if (idx > it->index)
     {
        /* After current position. */
        middle = ((eina_list_count(it->head) - it->index) >> 1) + it->index;

        if (idx > middle)
          /* Go backward from the end. */
          for (i = eina_list_count(it->head) - 1,
               over = eina_list_last(it->head);
               i > idx && over;
               --i, over = eina_list_prev(over))
            ;
        else
          /* Go forward from current. */
          for (i = it->index, over = it->current;
               i < idx && over;
               ++i, over = eina_list_next(over))
            ;
     }
示例#5
0
static void
new_statement(void)
{
   char *id;
   int i;
   int handled = 0;

   id = stack_id();
   for (i = 0; i < statement_handler_num(); i++)
     {
	if (!strcmp(statement_handlers[i].type, id))
	  {
	     handled = 1;
	     if (statement_handlers[i].func)
	       {
		  statement_handlers[i].func();
	       }
	     break;
	  }
     }
   if (!handled)
     {
	ERR("%s: Error. %s:%i unhandled keyword %s",
	    progname, file_in, line - 1,
	    (char *)eina_list_data_get(eina_list_last(stack)));
	exit(-1);
     }
   free(id);
}
示例#6
0
文件: eina_list_04.c 项目: Limsik/e17
int
main(int argc, char **argv)
{
   Eina_List *list = NULL;
   Eina_List *l;
   void *list_data;

   eina_init();

   list = eina_list_append(list, eina_stringshare_add("calvin"));
   list = eina_list_append(list, eina_stringshare_add("Leoben"));
   list = eina_list_append(list, eina_stringshare_add("D'Anna"));
   list = eina_list_append(list, eina_stringshare_add("Simon"));
   list = eina_list_append(list, eina_stringshare_add("Doral"));
   list = eina_list_append(list, eina_stringshare_add("Six"));
   list = eina_list_append(list, eina_stringshare_add("Sharon"));

   for(l = list; l; l = eina_list_next(l))
     printf("%s\n", (char*)l->data);

   for(l = eina_list_last(list); l; l = eina_list_prev(l))
      printf("%s\n", (char*)eina_list_data_get(l));

   EINA_LIST_FREE(list, list_data)
     eina_stringshare_del(list_data);

   eina_shutdown();

   return 0;
}
示例#7
0
文件: wm.c 项目: playya/Enlightenment
OD_Window      *
od_wm_window_prev_by_window_class_get(const char *name)
{
    Eina_List      *l = NULL;
    Eina_List      *tmp = NULL;
    Eina_List      *last = NULL;
    OD_Window      *win = NULL;
    OD_Window      *result = NULL;
    OD_Window      *current = NULL;

    if ((current = evas_hash_find(clients_current, name))) {
        clients_current = evas_hash_del(clients_current, name, current);
        for (l = clients; l; l = l->next) {
            if ((win = l->data)) {
                if (od_wm_iconified(win->id))
                    continue;
                if (win->applnk && win->applnk->data.applnk.winclass) {
                    if (!strcmp(name, win->applnk->data.applnk.winclass)) {
                        tmp = eina_list_append(tmp, win);
                    }
                }
            }
        }
        for (l = tmp; l; l = l->next) {
#if 0
            fprintf(stderr, "%8x %8x\n", ((OD_Window *) l->data)->id, current->id);
#endif
            if ((l->data == current) && (l->prev)) {
                result = l->prev->data;
            }
        }

        if (tmp) {
            last = eina_list_last(tmp);
            if (!result && last)
                result = last->data;
        }
        eina_list_free(tmp);
    } else {
        for (l = clients; l; l = l->next) {
            if ((win = l->data)) {
                if (win->applnk && win->applnk->data.applnk.winclass) {
                    if (od_wm_iconified(win->id))
                        continue;
                    if (!strcmp(name, win->applnk->data.applnk.winclass)) {
                        result = win;
#if 0
                        fprintf(stderr, "%s(%8x)\n", name, win->id);
#endif
                        break;
                    }
                }
            }
        }
    }
    if (result) {
        clients_current = evas_hash_add(clients_current, name, result);
    }
    return (result);
}
示例#8
0
static void
_evas_render2_all_sync(void)
{
   // wait for ALL canvases to stop rendering
   Eo *eo_e;

   if (!_rendering) return;
   eo_e = eina_list_data_get(eina_list_last(_rendering));
   _evas_render2_wait(eo_e);
}
News_Config_Item *
news_config_item_add(const char *id)
{
   News_Config_Item *nic;
   Eina_List *l;
   char buf[128];

   DCONF(("Item new config"));

   if (!id)
     {
	int  num = 0;

	/* Create id */
	if (news->config->items)
	  {
	     const char *p;
	     nic = eina_list_last(news->config->items)->data;
	     p = strrchr(nic->id, '.');
	     if (p) num = atoi(p + 1) + 1;
	  }
	snprintf(buf, sizeof(buf), "%s.%d", _gc_name(), num);
	id = buf;
     }
   else
     {
	/* is there already an item config for this id ? */
	for (l=news->config->items; l; l=eina_list_next(l))
	  {
	     nic = eina_list_data_get(l);
	     if (!strcmp(nic->id, id))
	       {
		  DCONF(("config found ! %s", nic->id));
		  return nic;
	       }
	  }
     }

   DCONF(("config NOT found ! creating new one %s", id));
   /* no, create a new item config */
   nic = E_NEW(News_Config_Item, 1);

   nic->id = eina_stringshare_add(id);
   nic->view_mode = NEWS_ITEM_VIEW_MODE_DEFAULT;
   nic->openmethod = NEWS_ITEM_OPENMETHOD_DEFAULT;
   nic->browser_open_home = NEWS_ITEM_BROWSER_OPEN_HOME_DEFAULT;

   news->config->items = eina_list_append(news->config->items, nic);

   return nic;
}
示例#10
0
static Config_Item *
_forecasts_config_item_get(const char *id)
{
   Eina_List *l;
   Config_Item *ci;
   char buf[128];

   if (!id)
     {
        int num = 0;

        /* Create id */
        if (forecasts_config->items)
          {
             const char *p;
             ci = eina_list_last(forecasts_config->items)->data;
             p = strrchr(ci->id, '.');
             if (p) num = strtol(p + 1, NULL, 10) + 1;
          }
        snprintf(buf, sizeof(buf), "%s.%d", _gadcon_class.name, num);
        id = buf;
     }
   else
     {
        for (l = forecasts_config->items; l; l = l->next)
          {
             ci = l->data;
             if (!ci->id)
               continue;
             if (!strcmp(ci->id, id))
               return ci;
          }
     }

   ci = E_NEW(Config_Item, 1);
   ci->id = eina_stringshare_add(id);
   ci->poll_time = 60.0;
   ci->days = 15.0;
   ci->degrees = DEGREES_C;
   ci->host = eina_stringshare_add("query.yahooapis.com");
   ci->code = eina_stringshare_add(DEFAULT_LOCATION);
   ci->show_text = 1;
   ci->popup_on_hover = 1;
   ci->by_code = 1;

   forecasts_config->items = eina_list_append(forecasts_config->items, ci);
   return ci;
}
示例#11
0
void 
theme_status_set(const char *txt, int type)
{
   Exquisite_Text_Line *t = NULL;

   if(!txt || (txt[0] == 0) || !messages) return;

   t = (Exquisite_Text_Line *)(eina_list_last(messages)->data);
   
   t->status = type;
   if(t->status_text) eina_stringshare_del(t->status_text);
   t->status_text = eina_stringshare_add(txt);
   
   /*A 2 means that a status update signal will be sent*/
   theme_update_text(2);
}
示例#12
0
void
line_array_polar(Line * line, double x0, double y0, int num, double dalpha)
{
    int                 i;

    if (!line)
        return;
    if (num < 1)
        return;
    for (i = 1; i < num; i++)
      {
          line_clone(line, 0, 0);
          line_rotate(eina_list_last(drawing->current_layer->objects)->data,
                      x0, y0, i * dalpha);
      }
}
示例#13
0
static Config_Item *
_wlan_config_item_get (const char *id)
{
   Eina_List *l;
   Config_Item *ci;
   char buf[128];

   if (!id)
     {
	int  num = 0;

	/* Create id */
	if (wlan_config->items)
	  {
	     const char *p;

	     ci = eina_list_last (wlan_config->items)->data;
	     p = strrchr (ci->id, '.');
	     if (p) num = atoi (p + 1) + 1;
	  }
	snprintf (buf, sizeof (buf), "%s.%d", _gc_class.name, num);
	id = buf;
     }
   else
     {
	for (l = wlan_config->items; l; l = l->next)
	  {
	     ci = l->data;
	     if (!ci->id) continue;
	     if (!strcmp (ci->id, id)) 
	       {
		  if (!ci->device)
		    ci->device = eina_stringshare_add ("wlan0");
		  return ci;
	       }
	  }
     }
   ci = E_NEW (Config_Item, 1);
   ci->id = eina_stringshare_add (id);
   ci->device = eina_stringshare_add ("wlan0");  
   ci->poll_time = 1.0;
   ci->always_text = 0;
   ci->show_percent = 1;

   wlan_config->items = eina_list_append (wlan_config->items, ci);
   return ci;
}
static Config_Item *
_tclock_config_item_get(const char *id)
{
   Eina_List *l;
   Config_Item *ci;

   if (!id)
     {
	int  num = 0;
        char buf[128];

	/* Create id */
	if (tclock_config->items)
	  {
	     const char *p;

	     ci = eina_list_last(tclock_config->items)->data;
	     p = strrchr(ci->id, '.');
	     if (p) num = atoi(p + 1) + 1;
	  }
	snprintf(buf, sizeof(buf), "%s.%d", _gc_class.name, num);
	id = buf;
     }
   else
     {
	for (l = tclock_config->items; l; l = l->next)
	  {
	     ci = l->data;
	     if (!ci->id) continue;
	     if (!strcmp(ci->id, id)) return ci;
	  }
     }

   ci = E_NEW(Config_Item, 1);
   ci->id = eina_stringshare_add(id);
   ci->show_date = 1;
   ci->show_time = 1;
   ci->show_tip = 1;
   ci->time_format = eina_stringshare_add("%T");
   ci->time_offset = eina_stringshare_add("0");
   
   ci->date_format = eina_stringshare_add("%d/%m/%y");
   ci->tip_format = eina_stringshare_add("%A, %B %d, %Y");

   tclock_config->items = eina_list_append(tclock_config->items, ci);
   return ci;
}
示例#15
0
static Config_Item *
_mpdule_config_item_get (const char *id)
{
  Eina_List *l;
  Config_Item *ci;
  char buf[128];


  if (!id)
    {
      int num = 0;

      /* Create id */
      if (mpdule_config->items)
	{
	  const char *p;
	  ci = eina_list_last (mpdule_config->items)->data;
	  p = strrchr (ci->id, '.');
	  if (p)
	    num = atoi (p + 1) + 1;
	}
      snprintf (buf, sizeof (buf), "%s.%d", _gc_class.name, num);
      id = buf;
    }
  else
    {
      for (l = mpdule_config->items; l; l = l->next)
	{
	  ci = l->data;
	  if (!ci->id)
	    continue;
	  if (!strcmp (ci->id, id))
	    return ci;
	}
    }

  ci = E_NEW (Config_Item, 1);
  ci->id = eina_stringshare_add (id);
  ci->poll_time = 1.0;
  ci->hostname = eina_stringshare_add ("localhost");
  ci->port = 6600;
  ci->show_popup = 1;

  mpdule_config->items = eina_list_append (mpdule_config->items, ci);
  return ci;
}
示例#16
0
void language_xml_clear(Language_XML *xml)
{
    Language_XML_Node *n_cur;

    if ((!xml) || (!xml->current))
    {
        DBG("One of values is NULL, returning with error.");
        return;
    }

    xml->current = xml->top;

    n_cur = xml->current;
    if (!n_cur)
    {
        DBG("One of values is NULL, returning with error.");
        return;
    }

    n_cur = n_cur->parent;

    if (n_cur)
    {
        Language_XML_Node *c_parent = n_cur;
        Eina_List *c_list = c_parent->children;
        void *data;

        c_list = eina_list_data_find_list(c_list, xml->current);
        EINA_LIST_FREE(c_list, data) E_FREE(data);
        if (!(n_cur = eina_list_data_get(c_list)))
            if (!(n_cur = eina_list_last(c_list))) n_cur = c_parent;
    }
    else
    {
        xml->top = NULL;
        void *data;
        if (xml->current)
        {
            eina_hash_free(xml->current->attributes);
            EINA_LIST_FREE(xml->current->children, data) E_FREE(data);
            E_FREE(xml->current);
        }
    }

    xml->current = n_cur;
}
示例#17
0
static Config_Item *
_mail_config_item_get (const char *id)
{
   Eina_List *l;
   Config_Item *ci;
   char buf[128];

   if (!id)
     {
	int  num = 0;

	/* Create id */
	if (mail_config->items)
	  {
	     const char *p;
	     ci = eina_list_last (mail_config->items)->data;
	     p = strrchr (ci->id, '.');
	     if (p) num = atoi (p + 1) + 1;
	  }
	snprintf (buf, sizeof (buf), "%s.%d", _gc_class.name, num);
	id = buf;
     }
   else
     {
	for (l = mail_config->items; l; l = l->next)
	  {
	     ci = l->data;
	     if (!ci->id)
	       continue;
	     if (!strcmp (ci->id, id))
	       return ci;
	  }
     }

   ci = E_NEW (Config_Item, 1);
   ci->id = eina_stringshare_add (id);
   ci->show_label = 1;
   ci->check_time = 15.0;
   ci->show_popup = 1;
   ci->show_popup_empty = 0;
   ci->boxes = NULL;

   mail_config->items = eina_list_append (mail_config->items, ci);
   return ci;
}
示例#18
0
Eina_List*
find_points(Eina_List *poly, double x1, double y1, double x2, double y2)
{
    XY                 *a, *b;
    Eina_List          *sect = NULL;
    Eina_List          *l;
    double              x3, x4, y3, y4;
    XY                 *ret;

    if (!poly)
        return NULL;

    a = (XY *) eina_list_last(poly)->data;
    x3 = a->x;
    y3 = a->y;
    b = (XY *) poly->data;
    x4 = b->x;
    y4 = b->y;
    ret = _get_point(x1, y1, x2, y2, x3, y3, x4, y4);
    if (ret)
        sect = eina_list_append(sect, ret);

    for (l = poly; l->next; l = l->next)
      {
          a = (XY *) l->data;
          x3 = a->x;
          y3 = a->y;
          b = (XY *) l->next->data;
          x4 = b->x;
          y4 = b->y;
          ret = _get_point(x1, y1, x2, y2, x3, y3, x4, y4);
          if (ret)
              sect = eina_list_append(sect, ret);
      }
    if (!sect)
        return NULL;
    if (!sect->next)
        return NULL;

    for (l = sect; l; l = l->next)
        ENGY_ASSERT(l->data);
    return sort_list(sect);
}
示例#19
0
SH_API Eina_Bool _read_stdin_list(void *data, Ecore_Fd_Handler *fd_handler)
{
   char **splitted;
   char *buffer;
   char c;
   int i = 0;
   int len = 0;
   Evas_Object *obj = data;

   if (!_stdin_prepare(fd_handler)) return 0;

   // allocate initial buffer
   buffer = malloc(sizeof(char));

   // get the buffer
   do {
     c = getc(stdin);
     buffer[i] = c;
     buffer = realloc(buffer, i + sizeof(buffer));
     i++;
   } while (c != EOF);

   // terminate the string.
   buffer[i - 1] = '\0';

   // split and append
   splitted = eina_str_split_full(buffer, "\n", 0, &len);

   for (i = 0; i < len; i++)
     elm_list_item_append(obj, splitted[i], NULL, NULL, NULL, NULL);

   elm_object_item_del(eina_list_data_get(eina_list_last(elm_list_items_get(obj))));

   elm_list_go(obj);

   // free the the pointers, delete handler when we don't need it
   E_FREE(splitted);
   E_FREE(buffer);
   ecore_main_fd_handler_del(fd_handler);
   return 0;

}
示例#20
0
文件: e_mod_main.c 项目: Limsik/e17
static Config_Item *
_ut_config_item_get (const char *id)
{
   Eina_List *l;
   Config_Item *ci;
   char buf[128];

   if (!id)
     {
	int  num = 0;

	/* Create id */
	if (ut_config->items)
	  {
	     const char *p;

	     ci = eina_list_last (ut_config->items)->data;
	     p = strrchr (ci->id, '.');
	     if (p) num = atoi (p + 1) + 1;
	  }
	snprintf (buf, sizeof (buf), "%s.%d", _gc_class.name, num);
	id = buf;
     }
   else
     {
	for (l = ut_config->items; l; l = l->next)
	  {
	     ci = l->data;
	     if (!ci->id) continue;
	     if (strcmp (ci->id, id) == 0) return ci;
	  }
     }

   ci = E_NEW (Config_Item, 1);
   ci->id = eina_stringshare_add (id);
   ci->check_interval = 60.0;
   ci->update_interval = 60.0;

   ut_config->items = eina_list_append (ut_config->items, ci);

   return ci;
}
Config_Item *
_net_config_item_get(const char *id) 
{
   Eina_List *l;
   Config_Item *ci;
   char buf[128];

   if (!id)
     {
	int  num = 0;

	/* Create id */
	if (net_cfg->items)
	  {
	     const char *p;
	     ci = eina_list_last(net_cfg->items)->data;
	     p = strrchr(ci->id, '.');
	     if (p) num = atoi(p + 1) + 1;
	  }
	snprintf(buf, sizeof(buf), "%s.%d", _net_gc_name(), num);
	id = buf;
     }
   else
     {
	for (l = net_cfg->items; l; l = l->next) 
	  {
	     ci = l->data;
	     if (!ci->id) continue;
	     if (!strcmp(ci->id, id)) return ci;
	  }
     }
   ci = E_NEW(Config_Item, 1);
   ci->id = eina_stringshare_add(id);
   ci->device = eina_stringshare_add("eth0");
   ci->app = eina_stringshare_add("");
   ci->limit = 0;
   ci->show_text = 1;
   ci->show_popup = 0;
   net_cfg->items = eina_list_append(net_cfg->items, ci);
   return ci;
}
示例#22
0
static void
load_page(eoi_help_info_t * info, const char *page)
{
    char *lang = setlocale(LC_ALL, "");
    if (lang) {
        lang = strdup(lang);

        char *lang_end = lang;
        while (lang_end[0] != '\0' && lang_end[0] != '_'
                && lang_end[0] != '@' && lang_end[0] != '.')
            ++lang_end;
        *lang_end = '\0';

        if (!lang[0] || !strcmp(lang, "C") || !strcmp(lang, "POSIX")) {
            free(lang);
            lang = strdup("en");
        }
    } else
        lang = strdup("en");

    char *text = load_page_text(info->application, lang, page);
    if (!text)
        text = load_page_text(info->application, "en", page);
    free(lang);

    if (!text)
        return;

    if (info->keys_info && info->keys_context) {
        char *subst =
            eoi_subst_keys(text, info->keys_info, info->keys_context);
        free(text);
        text = subst;
    }

    eoi_textbox_text_set(info->textbox, text);
    free(text);
    info->history =
        eina_list_last(eina_list_append(info->history, strdup(page)));
}
示例#23
0
文件: eet_loader.c 项目: Limsik/e17
static Eina_Bool
_elixir_eet_release(const Elixir_Loader_File *file)
{
   Elixir_Eet_Filename *lookup;
   Eina_List *last;

   /* LRU must never be bigger than 8 file. */
   if (eina_list_count(lru) > 8)
     {
	last = eina_list_last(lru);
	lookup = eina_list_data_get(last);

	eina_hash_del(cache, lookup->filename, lookup);

	lru = eina_list_remove_list(lru, last);
     }

   file->file->reference--;

   lookup = eina_hash_find(cache, file->file->filename);
   if (lookup == file->file)
     lru = eina_list_prepend(lru, file->file);
   else
     if (file->file->reference < 0)
       {
	  eet_close(file->file->eet);
	  free(file->file->filename);
	  free(file->file);
       }

   if (stack && eina_array_count_get(stack) > 0)
     eina_array_pop(stack);

   if (file->free_content) free(file->content);
   if (file->free_compiled) free(file->compiled);
   free(file->section);
   free((void*) file);

   return EINA_TRUE;
}
示例#24
0
/**
 * @brief Attachs a widget to the table
 * @param table a table
 * @param child the widget to attach
 * @param left_attach the column where the left side of the child will be attached (starting from 0)
 * @param right_attach the column where the right side of the child will be attached (starting from 0)
 * @param top_attach the row where the top side of the child will be attached (starting from 0)
 * @param bottom_attach the row where the bottom side of the child will be attached (starting from 0)
 * @param fill_policy The fill policy of the child
 * @param x_padding the amount of free space on the left and on the right sides of the child widget
 * @param y_padding the amount of free space on the top and on the bottom sides of the child widget
 */
void etk_table_attach(Etk_Table *table, Etk_Widget *child, int left_attach, int right_attach, int top_attach, int bottom_attach, Etk_Table_Fill_Policy fill_policy, int x_padding, int y_padding)
{
   Etk_Table_Cell *cell;
   int i, j;

   if (!table || !table->cells || !child)
      return;

   left_attach = ETK_CLAMP(left_attach, 0, table->num_cols - 1);
   right_attach = ETK_CLAMP(right_attach, left_attach, table->num_cols - 1);
   top_attach = ETK_CLAMP(top_attach, 0, table->num_rows - 1);
   bottom_attach = ETK_CLAMP(bottom_attach, top_attach, table->num_rows - 1);

   cell = malloc(sizeof(Etk_Table_Cell));
   cell->left_attach = left_attach;
   cell->right_attach = right_attach;
   cell->top_attach = top_attach;
   cell->bottom_attach = bottom_attach;
   cell->x_padding = x_padding;
   cell->y_padding = y_padding;
   cell->fill_policy = fill_policy;
   cell->child = child;

   for (i = left_attach; i <= right_attach; i++)
   {
      for (j = top_attach; j <= bottom_attach; j++)
      {
         etk_table_cell_clear(table, i, j);
         table->cells[CELL_INDEX(table, i, j)] = cell;
      }
   }

   table->cells_list = eina_list_append(table->cells_list, cell);
   cell->node = eina_list_last(table->cells_list);

   etk_object_data_set(ETK_OBJECT(child), "_Etk_Table::Cell", cell);
   etk_widget_parent_set(child, ETK_WIDGET(table));
   etk_signal_emit(ETK_CONTAINER_CHILD_ADDED_SIGNAL, ETK_OBJECT(table), child);
}
示例#25
0
void
ghost_line_redraw(Eina_List *data, double x, double y)
{
    XY                 *xy;
    Evas               *e;
    Drawing            *d;
    double              x1, y1, x2, y2;

    if (!data)
        return;
    e = shell->evas;
    d = drawing;
    if (!d)
        return;

    xy = (XY *) eina_list_last(data)->data;
    x1 = w2s_x(xy->x);
    y1 = w2s_y(xy->y);
    x2 = w2s_x(x);
    y2 = w2s_y(y);

    evas_object_show(o_line);
    evas_object_line_xy_set(o_line, x1, y1, x2, y2);
}
示例#26
0
void
etox_line_apply_context(Etox_Line *line, Etox_Context *context, Evas_Object *start, Evas_Object *end)
{
#ifdef DEBUG
  printf("etox_line_apply_context() - called\n");
fflush(stdout);
#endif
  Eina_List *l, *ls = NULL, *le = NULL;

  ls = eina_list_data_find_list(line->bits, start);
  le = eina_list_data_find_list(line->bits, end);
#ifdef DEBUG
  printf("etox_line_apply_context() - found start and end bits\n");
fflush(stdout);
#endif
  
  /* make sure start and end exist and are in line->bits */
  if ( !ls )
    ls = line->bits;
  if ( !le ) 
    le = eina_list_last(line->bits);

  for (l = ls; l; l = l->next)
  {
    Evas_Object *bit;

    bit = l->data;

    if (!l->prev && line->flags & ETOX_LINE_WRAPPED)
    {
#ifdef DEBUG
  printf("etox_line_apply_context() - first bit of line. skipping obstacles...\n");
fflush(stdout);
#endif
      /* go past any obstacles */
      while (etox_style_fixed(bit))
      {
        /* if there are only obstacles on the line (can this happen?) */
        if (!l->next)
          return;

        l = l->next;
        bit = l->data;
      }
#ifdef DEBUG
  printf("etox_line_apply_context() - applying context to marker bit\n");
fflush(stdout);
#endif
      etox_style_set_text(bit, context->marker.text);
      etox_style_set_style(bit, context->marker.style);
      evas_object_color_set(bit, context->marker.r, context->marker.g,
                           context->marker.b, context->marker.a);
    }
    else
    {
#ifdef DEBUG
  printf("etox_line_apply_context() - applying context to bit\n");
fflush(stdout);
#endif
      etox_style_set_style(bit, context->style);
      evas_object_color_set(bit, context->r, context->g, context->b,
                            context->a);
      etox_style_set_font(bit, context->font, context->font_size);
    }
    if (l == le)
      break;
  }
#ifdef DEBUG
  printf("etox_line_apply_context() - done\n");
fflush(stdout);
#endif
}
示例#27
0
static void
set_api_state(api_data *api)
{
   const Eina_List *items = elm_box_children_get(api->box);
   if (!eina_list_count(items))
     return;

   /* use elm_box_children_get() to get list of children */
   switch(api->state)
     { /* Put all api-changes under switch */
      case BOX_PACK_START:  /* Move last item to begining */
         elm_box_unpack(api->box, eina_list_data_get(eina_list_last(items)));
         elm_box_pack_start(api->box, eina_list_data_get(eina_list_last(items)));
         break;

      case BOX_PACK_BEFORE:
         if (eina_list_count(items) > 1)
               {  /* Put last item before the one preceeding it */
                  elm_box_unpack(api->box, eina_list_data_get(eina_list_last(items)));
                  elm_box_pack_before(api->box,
                        eina_list_data_get(eina_list_last(items)),
                        eina_list_nth(items, eina_list_count(items)-2));
               }
         break;

      case BOX_PACK_AFTER:
         if (eina_list_count(items) > 1)
               {  /* Put item before last to last */
                  elm_box_unpack(api->box, eina_list_nth(items,
                           eina_list_count(items)-2));
                  elm_box_pack_after(api->box,
                        eina_list_nth(items, eina_list_count(items)-2),
                        eina_list_data_get(eina_list_last(items)));
               }
         break;

      case BOX_PADDING_SET:
         elm_box_padding_set(api->box, 30, 15);
         break;

      case BOX_ALIGN_SET:
         elm_box_align_set(api->box, 0.25, 0.75);
         break;

      case BOX_HOMOGENEOUS_SET:
         elm_box_homogeneous_set(api->box, EINA_TRUE);
         break;

      case BOX_UNPACK_ALL:
           {
              Eina_List *l;
              Evas_Object *data;
              elm_box_unpack_all(api->box);
              EINA_LIST_REVERSE_FOREACH(items, l, data)
                 elm_box_pack_end(api->box, data);
           }
         break;

      case BOX_CLEAR:
         elm_box_clear(api->box);
         break;

      case API_STATE_LAST:

         break;
      default:
         return;
     }
}
示例#28
0
static void
set_api_state(api_data *api)
{
/** HOW TO TEST ************************
0 ITEM PREPEND
Scroll to end
1 INSERT BEFORE
Scroll to end
2 INSERT AFTER
3 INSERT SEPERATOR
Scroll to end
4 ITEM DEL
5 POLICY ON, BOUNCE_SET(TRUE, TRUE)
6 POLICY OFF
Scroll to end
7 TOOLTIP last-item
8 Cancel tootip
9 Curosr set on last item
10 Cursor style set last item
11 DISABLE last item
12 MODE COMPRESS
13 MODE LIMIT
14 MODE EXPAND
15 HORIZ SET
16 VERT MODE, BOUNCE(TRUE, FALSE) try to bounce on Y-axis
17 List clear
*** HOW TO TEST ***********************/
   Evas_Object *li = api->list;

   switch(api->state)
     { /* Put all api-changes under switch */
      case ITEM_PREPEND: /* 0 */
           {
              const Eina_List *items = elm_list_items_get(li);
              elm_list_item_prepend(li, "PREPEND", NULL, NULL, NULL, NULL);
              elm_list_go(li);
              elm_list_item_bring_in(eina_list_nth(items, 0));
           }
         break;

      case ITEM_INSERT_BEFORE: /* 1 */
           {
              const Eina_List *items = elm_list_items_get(li);
              if (eina_list_count(items))
                {
                  elm_list_item_insert_before(li,
                        eina_list_nth(items, eina_list_count(items)-1),
                        "1-before-last", NULL, NULL, NULL, NULL);
                  elm_list_go(li);
                  elm_list_item_bring_in(eina_list_data_get(eina_list_last(items)));
                }
           }
         break;

      case ITEM_INSERT_AFTER: /* 2 */
           {
              const Eina_List *items = elm_list_items_get(li);
              if (eina_list_count(items))
                {
                  elm_list_item_insert_after(li,
                        eina_list_nth(items, eina_list_count(items)-2),
                        "insert-after", NULL, NULL, NULL, NULL);
                  elm_list_go(li);
                  elm_list_item_bring_in(eina_list_data_get(eina_list_last(items)));
                }
           }
         break;

      case ITEM_SEPARATOR_SET: /* 3 */
           {
              const Eina_List *items = elm_list_items_get(li);
              if (eina_list_count(items))
                {
                  elm_list_item_separator_set(eina_list_nth(items, eina_list_count(items)-3), EINA_TRUE);
                  elm_list_item_bring_in(eina_list_nth(items, eina_list_count(items)-3));
                  elm_list_go(li);
                }
           }
         break;

      case LIST_ITEM_DEL: /* 4 */
           {
              const Eina_List *items = elm_list_items_get(li);
              if (eina_list_count(items))
                {
                  elm_object_item_del(eina_list_data_get(eina_list_last(items)));
                }
           }
         break;

      case SCROLLER_POLICY_SET_ON: /* 5 */
         elm_scroller_bounce_set(li, EINA_TRUE, EINA_TRUE);
         elm_scroller_policy_set(li, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_ON);
         break;

      case SCROLLER_POLICY_SET_OFF: /* Back to AUTO next (6) */
         elm_scroller_policy_set(li, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
         break;

      case TOOLTIP_TEXT_SET: /* 7 */
           {
              const Eina_List *items = elm_list_items_get(li);
              if (eina_list_count(items))
                {
                  elm_object_item_tooltip_text_set(eina_list_data_get(eina_list_last(items)), "Tooltip set from API");
                }
              elm_scroller_policy_set(li, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO);
           }
         break;

      case TOOLTIP_UNSET: /* 8 */
           {
              const Eina_List *items = elm_list_items_get(li);
              if (eina_list_count(items))
                {
                  elm_object_item_tooltip_unset(eina_list_data_get(eina_list_last(items)));
                }
           }
         break;

      case ITEM_CURSOR_SET: /* 9 */
           {
              const Eina_List *items = elm_list_items_get(li);
              if (eina_list_count(items))
                {
                  elm_object_item_cursor_set(eina_list_data_get(eina_list_last(items)), ELM_CURSOR_HAND2);
                }
           }
         break;

      case ITEM_CURSOR_STYLE_SET: /* 10 */
           {
              const Eina_List *items = elm_list_items_get(li);
              if (eina_list_count(items))
                {
                  elm_object_item_cursor_style_set(eina_list_data_get(eina_list_last(items)), "transparent");
                }
           }
         break;

      case DISABLED_SET: /* 11 */
           {
              const Eina_List *items = elm_list_items_get(li);
              if (eina_list_count(items))
                {
                  elm_object_item_disabled_set(eina_list_data_get(eina_list_last(items)), EINA_TRUE);
                }
           }
         break;

      case MODE_SET_COMPRESS: /* 12 */
         elm_list_mode_set(li, ELM_LIST_COMPRESS);
         break;

      case MODE_SET_LIMIT: /* 13 */
         elm_list_mode_set(li, ELM_LIST_LIMIT);
         break;

      case MODE_SET_EXPAND: /* 14 */
         elm_list_mode_set(li, ELM_LIST_EXPAND);
         break;

      case HORIZONTAL_SET: /* 15 */
         elm_list_mode_set(li, ELM_LIST_SCROLL); /* return to default mode */
         elm_list_horizontal_set(li, EINA_TRUE);
         break;

      case BOUNCE_SET: /* 16 */
         elm_list_horizontal_set(li, EINA_FALSE);
         elm_scroller_bounce_set(li, EINA_TRUE, EINA_FALSE);
         break;

      case LIST_CLEAR: /* 17 */
         elm_list_clear(li);
         break;

      case API_STATE_LAST:
         break;

      default:
         return;
     }
}
示例#29
0
static void
_on_key_down(void *data, Evas *e, Evas_Object *o, void *event_info)
{
    Evas_Event_Key_Down *ev = event_info;
    Evas_Object *em = data;

    if (!strcmp(ev->keyname, "Return"))
    {
        emotion_object_play_set(em, EINA_TRUE);
    }
    else if (!strcmp(ev->keyname, "space"))
    {
        emotion_object_play_set(em, EINA_FALSE);
    }
    else if (!strcmp(ev->keyname, "Escape"))
    {
        ecore_main_loop_quit();
    }
    else if (!strcmp(ev->keyname, "t"))
    {
        int w, h;
        emotion_object_size_get(em, &w, &h);
        fprintf(stderr, "example -> size: %dx%d\n", w, h);
    }
    else if (!strcmp(ev->keyname, "s"))
    {
        float len, pos;
        len = emotion_object_play_length_get(em);
        pos = 0.98 * len;
        fprintf(stderr, "skipping to position %0.3f\n", pos);
        emotion_object_position_set(em, pos);
    }
    else if (!strcmp(ev->keyname, "1"))
    {
        fprintf(stderr, "setting speed to 1.0\n");
        emotion_object_play_speed_set(em, 1.0);
    }
    else if (!strcmp(ev->keyname, "2"))
    {
        fprintf(stderr, "setting speed to 2.0\n");
        emotion_object_play_speed_set(em, 2.0);
    }
    else if (!strcmp(ev->keyname, "n"))
    {
        const char *file;
        if (!curfile)
            curfile = filenames;
        else
            curfile = eina_list_next(curfile);
        file = eina_list_data_get(curfile);
        fprintf(stderr, "playing next file: %s\n", file);
        emotion_object_file_set(em, file);
    }
    else if (!strcmp(ev->keyname, "p"))
    {
        const char *file;
        if (!curfile)
            curfile = eina_list_last(filenames);
        else
            curfile = eina_list_prev(curfile);
        file = eina_list_data_get(curfile);
        fprintf(stderr, "playing next file: %s\n", file);
        emotion_object_file_set(em, file);
    }
    else if (!strcmp(ev->keyname, "d"))
    {
        evas_object_del(em);
    }
    else if (!strcmp(ev->keyname, "l"))
    {
        // force frame dropping
        sleep(5);
    }
    else
    {
        fprintf(stderr, "unhandled key: %s\n", ev->keyname);
    }
}
示例#30
0
void
_create_tiled_line(Line * line)
{
    int                 flag, sign = 1;
    Eina_List          *list = NULL, *l, *lo;
    Evas               *e;
    Evas_Object        *o;
    Drawing            *d;
    float               x, y, dx, dy, len;
    double              x1, y1, x2, y2;
    XY                 *xy;

    d = drawing;

    dx = line->x2 - line->x1;
    if (dx == 0)
        dx = 1e-40;             /* ok for 1200 dpi? */
    sign = fabs(dx) / dx;

    dy = line->y2 - line->y1;
    len = hypot(dx, dy);

    flag = linestyle_get_odd();

    list = linestyle_get_points(len, line->line_scale);
    ENGY_ASSERT(list);

    trans_rotate(list, atan(-dy / dx) + M_PI * (sign - 1) / 2);
    trans_move(list, line->x1, line->y1);

    e = shell->evas;

    lo = line->list;

    for (l = list->next; l; l = l->next)
      {
          XY                 *a, *b;

          a = (XY *) l->prev->data;
          b = (XY *) l->data;

          flag = !flag;

          if (flag)
            {
                if (!lo || !lo->data)
                  {
                      o = _line_item(e, line->thickness *
                                     shell->context.show_thickness * d->scale);
                      evas_object_layer_set(o, 10);
                      evas_object_pass_events_set(o, 1);
                      line->list = eina_list_append(line->list, o);
                      lo = eina_list_last(line->list);
                  }
                o = lo->data;
                lo = lo->next;
                x1 = w2s_x(a->x);
                y1 = w2s_y(a->y);
                x2 = w2s_x(b->x);
                y2 = w2s_y(b->y);
                if (line->flags & FLAG_VISIBLE)
                  {
                      evas_object_color_set(o,
			line->color.red*line->color.alpha/255,
			line->color.green*line->color.alpha/255,
			line->color.blue*line->color.alpha/255, 
			line->color.alpha);
                  }
                else
                  {
                      evas_object_color_set(o, 0, 0, 0, 0);
                  }

                if (line->flags & FLAG_SELECTED)
                    evas_object_color_set(o, 
				    ALPHA5, 
				    ALPHA5/5, 
				    ALPHA5/5, 
				    ALPHA5);
                if (line->flags & FLAG_DELETED)
                    evas_object_color_set(o, 0, 0, 0, 0);
                _line_item_xy(e, o, x1, y1, x2, y2,
                              line->thickness *
                              shell->context.show_thickness * d->scale);
                evas_object_show(o);
            }
      }

    for (l = list; l; l = l->next)
        FREE(l->data);
    list = eina_list_free(list);
}