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; }
static void _parse_directory(Evas_Object *list, const char *dir_path) { struct dirent *dp; DIR *dir; if (!(dir = opendir(dir_path))) return; while ((dp = readdir(dir))) { Game_Entry *game; char dsfile[4096]; if (!enna_util_str_has_extension(dp->d_name, "desktop")) continue; sprintf(dsfile, "%s/%s", dir_path, dp->d_name); if ((game = _parse_desktop_game(dsfile))) { Enna_File *item; item = ENNA_NEW(Enna_File, 1); item->label = strdup(game->name); item->is_menu = 1; if (game->icon) item->icon = strdup(game->icon); enna_list_file_append(list, item, _play, strdup(game->exec));//TODO free this dup mod->count++; ENNA_FREE(game->name); ENNA_FREE(game->icon); ENNA_FREE(game->exec); ENNA_FREE(game); } } closedir(dir); }
static void module_init(Enna_Module *em) { sd = ENNA_NEW(Smart_Data, 1); enna_gadgets_register(&gadget); }
Enna_Volume * enna_volume_new (void) { Enna_Volume *v; v = ENNA_NEW (Enna_Volume, 1); return v; }
static void games_sys_show(Evas_Object *edje) { mod = ENNA_NEW(Games_Service_System, 1); mod->o_edje = edje; games_sys_create_games_list(); }
/* externally accessible functions */ Evas_Object * enna_mainmenu_add(Evas_Object *parent) { Smart_Data *sd; sd = ENNA_NEW(Smart_Data, 1); if (!sd) return NULL; /* connect to the input signal */ _enna_mainmenu_load_from_activities(sd); return NULL; }
Enna_Volumes_Listener * enna_volumes_listener_add(const char *name, EnnaVolumesFunc add, EnnaVolumesFunc rmv, void *data) { Enna_Volumes_Listener *vl; vl = ENNA_NEW(Enna_Volumes_Listener, 1); vl->name = eina_stringshare_add(name); vl->add = add; vl->remove = rmv; vl->data = data; enna_log(ENNA_MSG_EVENT, "volumes", "Add: %s listener", vl->name); enna_volumes_listeners = eina_list_append(enna_volumes_listeners, vl); return vl; }
static Enna_Module * enna_module_open(Enna_Module_Api *api) { Enna_Module *m; if (!api || !api->name) return NULL; if (api->version != ENNA_MODULE_VERSION ) { /* FIXME: popup error message */ /* Module version doesn't match enna version */ enna_log(ENNA_MSG_WARNING, NULL, "Bad module version, %s module", api->name); return NULL; } m = ENNA_NEW(Enna_Module, 1); m->api = api; m->enabled = 0; _enna_modules = eina_list_append(_enna_modules, m); return m; }
/** * @brief Register a new configuration panel * @param label The label to show, with locale applied * @param icon The name of the icon to use * @param create_cb This is the function to call when the panel need to be showed * @param destroy_cb This is the function to call when the panel need to be destroyed * @param data This is the user data pointer, use as you like * @return The object handler (needed to unregister) * * With this function modules (and not) can register item to be showed in * the configuration panel. The use is quite simple: give in a label and the * icon that rapresent your panel. * You need to implement 2 functions: * * Evas_Object *create_cb(void *data) * This function must return the main Evas_Object of your panel * The data pointer is the data you set in the register function * * void *destroy_cb(void *data) * In this function you must hide your panel, and possiby free some resource * */ Enna_Config_Panel * enna_config_panel_register(const char *label, const char *icon, Evas_Object *(*create_cb)(void *data), void (*destroy_cb)(void *data), void *data) { Enna_Config_Panel *ecp; if (!label) return NULL; ecp = ENNA_NEW(Enna_Config_Panel, 1); if (!ecp) return EINA_FALSE; ecp->label = eina_stringshare_add(label); ecp->icon = eina_stringshare_add(icon); ecp->create_cb = create_cb; ecp->destroy_cb = destroy_cb; ecp->data = data; _config_panels = eina_list_append(_config_panels, ecp); //TODO here emit an event like ENNA_CONFIG_PANEL_CHANGED return ecp; }
/* externally accessible functions */ Evas_Object * enna_mainmenu_add(Evas_Object *parent) { Smart_Data *sd; sd = ENNA_NEW(Smart_Data, 1); if (!sd) return NULL; /* cover view */ sd->o_menu = enna_box_add(parent, "list"); evas_object_data_set(sd->o_menu, "mainmenu_data", sd); //elm_layout_content_set(enna->layout, "enna.mainmenu.swallow", sd->o_menu); evas_object_size_hint_align_set(sd->o_menu, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(sd->o_menu, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(sd->o_menu); /* connect to the input signal */ sd->listener = enna_input_listener_add("mainmenu", _input_events_cb, sd); _enna_mainmenu_load_from_activities(sd); return sd->o_menu; }
static void __class_init(const char *name, Class_Private_Data **priv, ENNA_VFS_CAPS caps, char *key) { Class_Private_Data *data; Root_Directories *root; char buf[PATH_MAX + 7]; Eina_List *path_list; Eina_List *l; data = calloc(1, sizeof(Class_Private_Data)); *priv = data; data->prev_uri = NULL; data->name = eina_stringshare_add(name); data->config = calloc(1, sizeof(Module_Config)); data->config->root_directories = NULL; switch (caps) { case ENNA_CAPS_ALL: path_list = localfiles_cfg.path_all; break; case ENNA_CAPS_MUSIC: path_list = localfiles_cfg.path_music; break; case ENNA_CAPS_VIDEO: path_list = localfiles_cfg.path_video; break; case ENNA_CAPS_PHOTO: path_list = localfiles_cfg.path_photo; break; default: return; } for (l = path_list; l; l = l->next) { localfiles_path_t *p; p = l->data; root = calloc(1, sizeof(Root_Directories)); root->name = eina_stringshare_add(p->label); root->uri = strdup(p->uri); root->label = strdup(p->label); root->icon = strdup(p->icon); data->config->root_directories = eina_list_append(data->config->root_directories, root); } // add home directory entry root = ENNA_NEW(Root_Directories, 1); snprintf(buf, sizeof(buf), "file://%s", enna_util_user_home_get()); root->name = eina_stringshare_add("Home"); root->uri = strdup(buf); root->label = strdup("Home"); root->icon = strdup("icon/home"); data->config->root_directories = eina_list_append(data->config->root_directories, root); // add Root (/) directory entry root = ENNA_NEW(Root_Directories, 1); snprintf(buf, sizeof(buf), "file:///"); root->name = eina_stringshare_add("Root"); root->uri = strdup(buf); root->label = strdup("Root"); root->icon = strdup("icon/root"); data->config->root_directories = eina_list_append(data->config->root_directories, root); }
_date_del, }; /* Module interface */ #ifdef USE_STATIC_MODULES #undef MOD_PREFIX #define MOD_PREFIX enna_mod_gadget_date #endif /* USE_STATIC_MODULES */ static void module_init(Enna_Module *em EINA_UNUSED) { sd = ENNA_NEW(Smart_Data, 1); enna_gadgets_register(&gadget); } static void module_shutdown(Enna_Module *em EINA_UNUSED) { ENNA_OBJECT_DEL(sd->obj); ENNA_FREE(sd); sd = NULL; } Enna_Module_Api ENNA_MODULE_API = {