remove e_comp_list(), deprecate all related functions for pending removal
[platform/upstream/enlightenment.git] / src / bin / e_font.c
index cb89563..43aa7f2 100644 (file)
@@ -2,19 +2,19 @@
 
 #define E_TOK_STYLE ":style="
 
-static Eina_Bool _font_hash_free_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__);
-static Eina_Hash *_e_font_available_hash_add(Eina_Hash *font_hash, const char *full_name);
+static Eina_Bool          _font_hash_free_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__);
+static Eina_Hash         *_e_font_available_hash_add(Eina_Hash *font_hash, const char *full_name);
 static E_Font_Properties *_e_font_fontconfig_name_parse(Eina_Hash **font_hash, E_Font_Properties *efp, const char *font);
 static char _fn_buf[1024];
 
-EAPI int
+EINTERN int
 e_font_init(void)
 {
    /* all init stuff is in e_config */
    return 1;
 }
 
-EAPI int
+EINTERN int
 e_font_shutdown(void)
 {
    /* e_config will do this */
@@ -25,8 +25,8 @@ EAPI void
 e_font_apply(void)
 {
    char buf[1024];
-   Eina_List *l;
-   E_Border *bd;
+   const Eina_List *l;
+   E_Client *ec;
    E_Font_Default *efd;
    E_Font_Fallback *eff;
    int blen, len;
@@ -38,29 +38,29 @@ e_font_apply(void)
    l = e_config->font_fallbacks;
    if (l)
      {
-       eff = eina_list_data_get(l);
-       len = strlen(eff->name);
-       if (len < blen)
-         {
-            strcpy(buf, eff->name);
-            blen -= len;
-         }
-       EINA_LIST_FOREACH(eina_list_next(l), l, eff)
-         {
-            len = 1;
-            if (len < blen)
-              {
-                 strcat(buf, ",");
-                 blen -= len;
-              }
-            len = strlen(eff->name);
-            if (len < blen)
-              {
-                 strcat(buf, eff->name);
-                 blen -= len;
-              }
-         }
-       edje_fontset_append_set(buf);
+        eff = eina_list_data_get(l);
+        len = strlen(eff->name);
+        if (len < blen)
+          {
+             strcpy(buf, eff->name);
+             blen -= len;
+          }
+        EINA_LIST_FOREACH(eina_list_next(l), l, eff)
+          {
+             len = 1;
+             if (len < blen)
+               {
+                  strcat(buf, ",");
+                  blen -= len;
+               }
+             len = strlen(eff->name);
+             if (len < blen)
+               {
+                  strcat(buf, eff->name);
+                  blen -= len;
+               }
+          }
+        edje_fontset_append_set(buf);
      }
    else
      edje_fontset_append_set(NULL);
@@ -68,14 +68,13 @@ e_font_apply(void)
    /* setup edje text classes */
    EINA_LIST_FOREACH(e_config->font_defaults, l, efd)
      {
-       edje_text_class_set(efd->text_class, efd->font, efd->size);
+        edje_text_class_set(efd->text_class, efd->font, efd->size);
      }
 
-   /* Update borders */
-   EINA_LIST_FOREACH(e_border_client_list(), l, bd)
-     {
-       e_border_frame_recalc(bd);
-     }
+   /* Update clients */
+   if (!e_comp) return;
+   EINA_LIST_FOREACH(e_comp->clients, l, ec)
+     e_client_frame_recalc(ec);
 }
 
 EAPI Eina_List *
@@ -85,28 +84,23 @@ e_font_available_list(void)
    Eina_List *e_fonts;
    Eina_List *l;
    const char *evas_font;
-   E_Manager *man;
-   E_Container *con;
+   E_Comp *c;
 
-   man = e_manager_current_get();
-   if (!man) return NULL;
-   con = e_container_current_get(man);
-   if (!con) con = e_container_number_get(man, 0);
-   if (!con) return NULL;
+   c = e_util_comp_current_get();
 
-   evas_fonts = evas_font_available_list(con->bg_evas);
+   evas_fonts = evas_font_available_list(c->evas);
 
    e_fonts = NULL;
    EINA_LIST_FOREACH(evas_fonts, l, evas_font)
      {
-       E_Font_Available *efa;
-       
-       efa = E_NEW(E_Font_Available, 1);
-       efa->name = eina_stringshare_add(evas_font);
-       e_fonts = eina_list_append(e_fonts, efa);
+        E_Font_Available *efa;
+
+        efa = E_NEW(E_Font_Available, 1);
+        efa->name = eina_stringshare_add(evas_font);
+        e_fonts = eina_list_append(e_fonts, efa);
      }
 
-   evas_font_available_list_free(con->bg_evas, evas_fonts);
+   evas_font_available_list_free(c->evas, evas_fonts);
 
    return e_fonts;
 }
@@ -117,10 +111,10 @@ e_font_available_list_free(Eina_List *available)
    E_Font_Available *efa;
 
    EINA_LIST_FREE(available, efa)
-     { 
-       if (efa->name) eina_stringshare_del(efa->name);
-       E_FREE(efa);
-    }
+     {
+        if (efa->name) eina_stringshare_del(efa->name);
+        E_FREE(efa);
+     }
 }
 
 EAPI void
@@ -156,7 +150,7 @@ e_font_available_hash_free(Eina_Hash *hash)
 EAPI E_Font_Properties *
 e_font_fontconfig_name_parse(const char *font)
 {
-   if (font == NULL) return NULL;
+   if (!font) return NULL;
    return _e_font_fontconfig_name_parse(NULL, NULL, font);
 }
 
@@ -190,15 +184,15 @@ _e_font_fontconfig_name_parse(Eina_Hash **font_hash, E_Font_Properties *efp, con
              style = s1 + strlen(E_TOK_STYLE);
 
              if (font_hash) efp = eina_hash_find(*font_hash, name);
-             if (efp == NULL)
+             if (!efp)
                {
                   efp = calloc(1, sizeof(E_Font_Properties));
                   efp->name = eina_stringshare_add(name);
-                  if (font_hash) 
-                   {
-                     if (!*font_hash) *font_hash = eina_hash_string_superfast_new(NULL);
-                     eina_hash_add(*font_hash, name, efp);
-                   }
+                  if (font_hash)
+                    {
+                       if (!*font_hash) *font_hash = eina_hash_string_superfast_new(NULL);
+                       eina_hash_add(*font_hash, name, efp);
+                    }
                }
              s2 = strchr(style, ',');
              if (s2)
@@ -217,24 +211,23 @@ _e_font_fontconfig_name_parse(Eina_Hash **font_hash, E_Font_Properties *efp, con
           }
         free(name);
      }
-   else 
+   else
      {
         if (font_hash) efp = eina_hash_find(*font_hash, font);
-        if (efp == NULL)
+        if (!efp)
           {
              efp = calloc(1, sizeof(E_Font_Properties));
              efp->name = eina_stringshare_add(font);
              if (font_hash)
-              {
-                if (!*font_hash) *font_hash = eina_hash_string_superfast_new(NULL);
-                eina_hash_add(*font_hash, font, efp);
-              }
+               {
+                  if (!*font_hash) *font_hash = eina_hash_string_superfast_new(NULL);
+                  eina_hash_add(*font_hash, font, efp);
+               }
           }
      }
    return efp;
 }
 
-
 static Eina_Hash *
 _e_font_available_hash_add(Eina_Hash *font_hash, const char *full_name)
 {
@@ -273,15 +266,14 @@ e_font_available_list_parse(Eina_List *list)
    return font_hash;
 }
 
-
 EAPI const char *
 e_font_fontconfig_name_get(const char *name, const char *style)
 {
    char buf[256];
 
-   if (name == NULL) return NULL;
-   if (style == NULL || style[0] == 0) return eina_stringshare_add(name);
-   snprintf(buf, 256, "%s"E_TOK_STYLE"%s", name, style);
+   if (!name) return NULL;
+   if (!style || style[0] == 0) return eina_stringshare_add(name);
+   snprintf(buf, 256, "%s"E_TOK_STYLE "%s", name, style);
    return eina_stringshare_add(buf);
 }
 
@@ -291,10 +283,10 @@ e_font_fallback_clear(void)
    E_Font_Fallback *eff;
 
    EINA_LIST_FREE(e_config->font_fallbacks, eff)
-     { 
-       if (eff->name) eina_stringshare_del(eff->name);
-       E_FREE(eff);
-    }
+     {
+        if (eff->name) eina_stringshare_del(eff->name);
+        E_FREE(eff);
+     }
 }
 
 EAPI void
@@ -329,14 +321,14 @@ e_font_fallback_remove(const char *font)
 
    EINA_LIST_FOREACH(e_config->font_fallbacks, next, eff)
      {
-       if (!strcmp(eff->name, font))
-         {
-            e_config->font_fallbacks = 
+        if (!e_util_strcmp(eff->name, font))
+          {
+             e_config->font_fallbacks =
                eina_list_remove_list(e_config->font_fallbacks, next);
-            if (eff->name) eina_stringshare_del(eff->name);
-            E_FREE(eff);
-            break;
-         }
+             if (eff->name) eina_stringshare_del(eff->name);
+             E_FREE(eff);
+             break;
+          }
      }
 }
 
@@ -355,21 +347,21 @@ e_font_default_set(const char *text_class, const char *font, Evas_Font_Size size
    /* search for the text class */
    EINA_LIST_FOREACH(e_config->font_defaults, next, efd)
      {
-       if (!strcmp(efd->text_class, text_class))
-         {
-            if (efd->font) eina_stringshare_del(efd->font);
-            efd->font = eina_stringshare_add(font);
-            efd->size = size;
-            /* move to the front of the list */
-            e_config->font_defaults = 
+        if (!strcmp(efd->text_class, text_class))
+          {
+             if (efd->font) eina_stringshare_del(efd->font);
+             efd->font = eina_stringshare_add(font);
+             efd->size = size;
+             /* move to the front of the list */
+             e_config->font_defaults =
                eina_list_remove_list(e_config->font_defaults, next);
-            e_config->font_defaults = 
+             e_config->font_defaults =
                eina_list_prepend(e_config->font_defaults, efd);
-            return;
-         }
+             return;
+          }
      }
 
-   /* the text class doesnt exist */
+   /* the text class doesn't exist */
    efd = E_NEW(E_Font_Default, 1);
    efd->text_class = eina_stringshare_add(text_class);
    efd->font = eina_stringshare_add(font);
@@ -390,18 +382,18 @@ e_font_default_get(const char *text_class)
    /* search for the text class */
    EINA_LIST_FOREACH(e_config->font_defaults, next, efd)
      {
-       if (!strcmp(efd->text_class, text_class))
-         {
-            /* move to the front of the list */
-            e_config->font_defaults = 
+        if (!strcmp(efd->text_class, text_class))
+          {
+             /* move to the front of the list */
+             e_config->font_defaults =
                eina_list_remove_list(e_config->font_defaults, next);
-            e_config->font_defaults = 
+             e_config->font_defaults =
                eina_list_prepend(e_config->font_defaults, efd);
-            return efd;
-         }
-       if (!strcmp(efd->text_class, "default")) defd = efd;
+             return efd;
+          }
+        if (!strcmp(efd->text_class, "default")) defd = efd;
      }
-   if (!defd) defd  = efd;
+   if (!defd) defd = efd;
    return defd;
 }
 
@@ -414,17 +406,17 @@ e_font_default_remove(const char *text_class)
    /* search for the text class */
    EINA_LIST_FOREACH(e_config->font_defaults, next, efd)
      {
-       if (!strcmp(efd->text_class, text_class))
-         {
-            e_config->font_defaults = 
+        if (!e_util_strcmp(efd->text_class, text_class))
+          {
+             e_config->font_defaults =
                eina_list_remove_list(e_config->font_defaults, next);
-            if (efd->text_class) eina_stringshare_del(efd->text_class);
-            if (efd->font) eina_stringshare_del(efd->font);
-            E_FREE(efd);
-            edje_text_class_del(text_class);
-            return;
-         }
-    }
+             if (efd->text_class) eina_stringshare_del(efd->text_class);
+             if (efd->font) eina_stringshare_del(efd->font);
+             E_FREE(efd);
+             edje_text_class_del(text_class);
+             return;
+          }
+     }
 }
 
 EAPI Eina_List *
@@ -449,34 +441,35 @@ e_font_default_string_get(const char *text_class, Evas_Font_Size *size_ret)
    efd = e_font_default_get(text_class);
    if (!efd)
      {
-       if (size_ret) *size_ret = 0;
-       return "";
+        if (size_ret) *size_ret = 0;
+        return "";
      }
    blen = sizeof(_fn_buf) - 1;
 
    len = strlen(efd->font);
    if (len < blen)
      {
-       strcpy(_fn_buf, efd->font);
-       blen -= len;
+        strcpy(_fn_buf, efd->font);
+        blen -= len;
      }
 
    EINA_LIST_FOREACH(e_config->font_fallbacks, next, eff)
      {
-       len = 1;
-       if (len < blen)
-         {
-            strcat(_fn_buf, ",");
-            blen -= len;
-         }
-       len = strlen(eff->name);
-       if (len < blen)
-         {
-            strcat(_fn_buf, eff->name);
-            blen -= len;
-         }
+        len = 1;
+        if (len < blen)
+          {
+             strcat(_fn_buf, ",");
+             blen -= len;
+          }
+        len = strlen(eff->name);
+        if (len < blen)
+          {
+             strcat(_fn_buf, eff->name);
+             blen -= len;
+          }
      }
 
    if (size_ret) *size_ret = efd->size;
    return _fn_buf;
 }
+