Exemple #1
0
static Game_Entry *
_parse_desktop_game(const char *file)
{
    Game_Entry *game = NULL;
    const char *categories;
    ini_t *ini = ini_new (file);

    ini_parse(ini);
  
    categories = ini_get_string(ini, "Desktop Entry", "Categories");
    if (categories && strstr(categories, "Game"))
    {
        char *tmpicon;
        const char *name = ini_get_string(ini, "Desktop Entry", "Name");
        const char *icon = ini_get_string(ini, "Desktop Entry", "Icon");
        const char *exec = ini_get_string(ini, "Desktop Entry", "Exec");
        
        game = ENNA_NEW(Game_Entry, 1);
        game->name = strdup(name);
        game->exec = strdup(exec);

        if (!ecore_file_is_dir(icon) && ecore_file_can_read(icon))
            game->icon = strdup(icon);
        else if ((tmpicon = _find_icon(icon, "/usr/share/icons")))
            game->icon = tmpicon;
        else if ((tmpicon = _find_icon(icon, "/usr/share/pixmaps")))
            game->icon = tmpicon;
    }
  
    ini_free(ini);
  
    return game;
}
Exemple #2
0
static char *
_check_icon(const char *icon, const char *dir, const char *ext)
{
    char tmp[PATH_MAX];
    char *format;
   
    if (ext)
        format = "%s/%s.%s";
    else
        format = "%s/%s";

    snprintf(tmp, sizeof (tmp), format, dir, icon, ext);

    if (!ecore_file_is_dir(tmp) && ecore_file_can_read(tmp))
        return strdup(tmp);
    else
        return NULL;
}
Exemple #3
0
/* Sets the folder displayed in the iconbox */
static void _etk_test_iconbox_folder_set(Etk_Iconbox *iconbox, const char *folder)
{
   Eina_List *files;
   Eina_List *l;
   char *filename;
   char file_path[PATH_MAX];
   Etk_Iconbox_Icon *iicon;

   if (!iconbox)
      return;
   if (!folder && !(folder = getenv("HOME")))
      return;
   if (!(files = ecore_file_ls(folder)))
      return;

   etk_iconbox_clear(iconbox);
   etk_iconbox_append(iconbox, etk_theme_icon_path_get(), "actions/go-up_48", "..");

   /* First, add the folders */
   EINA_LIST_FOREACH(files, l, filename)
   {
      if (filename[0] == '.')
         continue;

      snprintf(file_path, PATH_MAX, "%s/%s", folder, filename);
      if (!ecore_file_is_dir(file_path))
         continue;

      iicon = etk_iconbox_append(iconbox, etk_theme_icon_path_get(), "places/folder_48", filename);
      
      if (!ecore_file_can_read(file_path))
         etk_iconbox_icon_emblem_set_from_stock(iicon, "unreadable");
      else if (!ecore_file_can_write(file_path))
         etk_iconbox_icon_emblem_set_from_stock(iicon, "readonly");
   }

   /* Then the files */
   EINA_LIST_FOREACH(files, l, filename)
   {
      const char *ext;
      char *icon = NULL;
      int i;

      if (filename[0] == '.')
         continue;

      snprintf(file_path, PATH_MAX, "%s/%s", folder, filename);
      if (ecore_file_is_dir(file_path))
         continue;

      if ((ext = strrchr(filename, '.')) && (ext = ext + 1))
      {
         for (i = 0; i < _etk_test_iconbox_num_types; i++)
         {
            if (strcasecmp(ext, _etk_test_iconbox_types[i].extension) == 0)
            {
               icon = _etk_test_iconbox_types[i].icon;
               break;
            }
         }
      }

      iicon = etk_iconbox_append(iconbox, etk_theme_icon_path_get(), icon ? icon : "mimetypes/text-x-generic_48", filename);
      if (!ecore_file_can_read(file_path))
         etk_iconbox_icon_emblem_set_from_stock(iicon, "unreadable");
      else if (!ecore_file_can_write(file_path))
         etk_iconbox_icon_emblem_set_from_stock(iicon, "readonly");
      else if (ecore_file_can_exec(file_path))
         etk_iconbox_icon_emblem_set_from_stock(iicon, "system");
   }

   EINA_LIST_FREE(files, filename)
     free(filename);

   if (!_etk_test_iconbox_current_folder)
      _etk_test_iconbox_current_folder = etk_string_new(NULL);
   etk_string_set(_etk_test_iconbox_current_folder, folder);
   etk_window_title_set(ETK_WINDOW(win), folder);
}